My program in flash end at some point. From that endpoint on I'd like to fill up the whole flash with 0xff.
Something like
.equ FlashDictionaryEnde, 0x00100000 .equ numberofbytes , FlashDictionaryEnde-. .space numberofbytes,0xff
doesn't work.
How can I achieve this?
Since 0xFF is the erased state of the flash, the obvious choice would simply be not to program the flash past the end of the code. This can be done if you can produce a binary file of the correct length, or a hex file that only contains data up to that offset, which is what the toolchain usually produces. Actually programming lots of 0xFFs into the flash wastes time.
Yes, sure. But when you program the flash without erasing it - there are situations, where you program the flash in two steps at different addresses, it could well be desirable to pad the space after the program with 0xff.
My question was actually aiming at the ARM assembler syntax to use in order to fill exactly the amount of data longing from the end of the program to the end of the flash. That's why I posted a piece of assembler instructions that were syntactically probbly wrong but which should show what I meant.
It sounds like you are expecting that you can write 0xFF to a location that has something else in it, and having it actually leave 0xFF there. Programming can only turn 1's into 0's. To turn 0's back into 1's, you have to erase. Or maybe I'm misunderstanding you. Or are you saying you want to use 0xFFs to skip over some area that is already programmed? That would probably work, but some programmers might complain if they include verification in the programming operation.
As to your asm question, I'm no ARM assembler expert, but in general, subtracting a symbol from a constant only works if the symbol has a non-relocatable value. I'm not sure the ARM assembler even provides a way to create code at absolute addresses, so the subtraction won't produce a meaningful value. Perhaps it just defaults to zero, although I would expect at least a warning. This is the sort of thing you could do with a linker script, because the linker is what assigns physical addresses, and it has a FILL directive. If, however, the program only has one module, and you know it will eventually be flashed starting at address 0, you could define a symbol at the start of the module, and subtract that from your expression, because the difference between . and that start symbol would indeed be an absolute quantity.
Let me exaplain what was the reason behind and why it came to my question:
In the first place I was only interested in the ARM assembler syntax. That was my original question. And I found the solution by myself.
Re-thinking about the original intention behind it was the following:
Consider you program a piece of program from 0x0800000 to 0x080001a0, would it be possible to do another program step from 0x080001a1 to 0x08001fff, so to say fit a second piece of program seamlessly right after the end of the first one? (without "damaging" the first piece?)
As you won't necessarily know the end address of the code at assemble time, I recommend you use the linker to fill the region via scatterloading. A section defined as (something like) the below will likely work:
FILL_REGION +0 FILL 0xFFFFFFFF{}
See https://www.keil.com/support/man/docs/armlink/armlink_pge1362075670305.htm
Thanks. That's what I was looking for in another context also. Good to know. Excellent!
@Paul DeRocco answered very early in this thread - I'm citing - :
"Since 0xFF is the erased state of the flash, the obvious choice would simply be not to program the flash past the end of the code"