2019-09-08 12:23 AM
I'm trying to allocate 768KB For the Flash for the user program. at address 0x08000000
And also save constant data starting from address 0x08100000 consuming 1024 K bytes
Now from my understanding I should have free space for example sector 10,11.
I'm trying to erase and write to these sections, but there are write protections error, sector 11 can be erased sucessfully but data can not be written to, section 10 can neither be erased nor written to it.
What would be the problem ?
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20080000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x1000; /* required amount of heap */
_Min_Stack_Size = 0x2000; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 768K
FLASH2 (r) : ORIGIN = 0x08100000, LENGTH = 1024K
SRAM1 (xrw) : ORIGIN = 0x20020000, LENGTH = 368K
SRAM2 (xrw) : ORIGIN = 0x2007C000, LENGTH = 16K
DTCMRAM (wal) : ORIGIN = 0x20000000, LENGTH = 128K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}
2019-09-08 06:48 AM
That's strange that no one answered, is it that hard question ?
2019-09-08 07:07 AM
Lacking in usable information.
The flashing tools reporting the error, or your own code?
If your own code, nothing here to review.
Check .MAP to confirm linker is building what you expect.
Check flash banking settings.
2019-09-08 07:15 AM
My own code can't erase the flash, it says write protection error. The flash is configured in dual banking code.
The erase and writing flash is correct. I really don't know what's wrong.
2019-09-08 07:24 AM
Hard to guess from here.
You'll need to instrument your code, and dump out memory and register contents as the code is encountering them. Confirm your expectations and reality.
Ideally test outside of debugger.
2019-09-08 07:25 AM
Which steps do I need to make for testing outside the debugger ?
2019-09-08 07:28 AM
is it possible to erase, program, erase program, at runtime many times ? or it's just one time possible ?
2019-09-08 07:29 AM
2019-09-08 07:30 AM
and flash operations here is it https://github.com/trezor/trezor-firmware/blob/master/core/embed/trezorhal/flash.c
2019-09-08 07:50 AM
Outside debugger you'd use a serial channel, and instrument code to see what it is doing, and the memory/register context is sees.
The memory should permit page/sector level erase and write, multiple times, and depending on the settings/options selected.
Dump out the write protect bits, and follow the logic returning the write protect error. You're trying to understand why, so you need to look at what the code is looking at and doing.