This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: MSP432P4111
Hi,
I need some support how to read and write from the main flash. I read some threads and all documents but I don't why it isn't working.
#define FLASH_ADR_CFG 0x0 uint8_t cfgData[4096]; void flash_rd(void){ for (int i = 0; i < 10; ++i) { Display_printf(displayHandle, 0, 0, "cfgData sram=%u flash=%u", cfgData[i], *(uint8_t*)(i+FLASH_ADR_CFG)); } } void flash_wr(void){ MAP_FlashCtl_A_unprotectMemory(FLASH_ADR_CFG,FLASH_ADR_CFG+10); if(!MAP_FlashCtl_A_programMemory(cfgData, (void*) FLASH_ADR_CFG, 4096)) { while(1); } MAP_FlashCtl_A_protectMemory(FLASH_ADR_CFG,FLASH_ADR_CFG+10); } // with button 1: for (int i = 0; i < 10; ++i) { cfgData[i] = i; } flash_wr(); // with button 2: flash_rd();
If I read the first time before writing I get (putty):
cfgData sram=0 flash=0 cfgData sram=0 flash=0 cfgData sram=0 flash=4 cfgData sram=0 flash=32 cfgData sram=0 flash=177 cfgData sram=0 flash=1 cfgData sram=0 flash=2 cfgData sram=0 flash=0 cfgData sram=0 flash=187 cfgData sram=0 flash=193
After writing I get always:
cfgData sram=0 flash=0 cfgData sram=1 flash=0 cfgData sram=2 flash=0 cfgData sram=3 flash=0 cfgData sram=4 flash=0 cfgData sram=5 flash=1 cfgData sram=6 flash=2 cfgData sram=7 flash=0 cfgData sram=8 flash=8 cfgData sram=9 flash=1
I would expect 0...9. And if reupload the code I get an error:
CORTEX_M4_0: GEL Output: Memory Map Initialization Complete
CORTEX_M4_0: GEL Output: Halting Watchdog Timer
CORTEX_M4_0: File Loader: Failed to initialize flash programming: Target failed to read 0xE004300C
CORTEX_M4_0: GEL: File: C:\...\flash_a_program_memory_MSP_EXP432P4111_nortos_ccs\Debug\flash_a_program_memory_MSP_EXP432P4111_nortos_ccs.out: Load failed.
With the next upload I don't get an error. When I see this error message I'm asking me, if this is a problem because I'm using FreeRTOS?
Thanks for any help!
Ok, the vector table is from 0x0...0x268. Are there any more addresses that are used by the system?
Now I start from main memory bank0 0x10 000. But I read some random values:
cfgData sram=0 flash=225
cfgData sram=0 flash=84
cfgData sram=0 flash=65
cfgData sram=0 flash=63
cfgData sram=0 flash=97
cfgData sram=0 flash=206
cfgData sram=0 flash=39
cfgData sram=0 flash=63
cfgData sram=0 flash=183
cfgData sram=0 flash=150
After flash writing:
cfgData sram=0 flash=0
cfgData sram=1 flash=0
cfgData sram=2 flash=0
cfgData sram=3 flash=3
cfgData sram=4 flash=0
cfgData sram=5 flash=4
cfgData sram=6 flash=6
cfgData sram=7 flash=7
cfgData sram=8 flash=0
cfgData sram=9 flash=0
... some value matches some not.
The good thing is that this error message is gone.
But if I restart the MCU I read out the old values:
cfgData sram=0 flash=225
...
For another test I start from main memory bank1 0x10 0000. The values after restart are:
cfgData sram=0 flash=255
cfgData sram=0 flash=255
cfgData sram=0 flash=255
cfgData sram=0 flash=255
cfgData sram=0 flash=255
cfgData sram=0 flash=255
cfgData sram=0 flash=255
cfgData sram=0 flash=255
cfgData sram=0 flash=255
cfgData sram=0 flash=255
After flash writing:
cfgData sram=0 flash=0
cfgData sram=1 flash=1
cfgData sram=2 flash=2
cfgData sram=3 flash=3
cfgData sram=4 flash=4
cfgData sram=5 flash=5
cfgData sram=6 flash=6
cfgData sram=7 flash=7
cfgData sram=8 flash=8
cfgData sram=9 flash=9
all values I had written I can read from flash. But again, if I restart the MCU and read out the old values are there:
cfgData sram=0 flash=225
cfgData sram=0 flash=255
...
What's going wrong?
Hi,
when I restart a debug session with ccs after I switched the "Erase-Configuration" in "Debug-Configuration->MSP432_Settings" from "Erase main memory only" to "Do not erase Flash memory" then ccs ends up in different "errors" at beginning of the code. The only way I can recover this is to switch back to "Erase main memory only". But then the programmed values are gone...
So I'm asking me is this the right way to prevent ccs for delete the memory?
Thanks
If you want to reflash the application code but leave the space that you have written to, then you can either use the 'Erase and download necessary segments only' or in the linker command file you can create a section to which the IDE does not write to. Additionally, in CCS you can launch a target configuration and connect to the device and look at the memory content without actually downloading any code and running the debugger.
Regards,
Chris
Hi Chris,
thank you for your answer. 'Erase and download necessary segments only' I tried before but it also ends up in errors.
linker command file - create a section to which the IDE does not write to:
* ======== MSP_EXP432P4111_FREERTOS.cmd ======== * Define the memory block start/length for the MSP_EXP432P4111 M4 */ --stack_size=1024 --heap_size=0 /* minimize heap since we're using heap_4.c */ --entry_point=resetISR MEMORY { MAIN (RX) : origin = 0x00000000, length = 0x00200000 INFO (RX) : origin = 0x00200000, length = 0x00008000 ALIAS { SRAM_CODE (RWX): origin = 0x01000000 SRAM_DATA (RW) : origin = 0x20000000 } length = 0x00040000 } /* Section allocation in memory */ SECTIONS {
Can you explain how to do this in this file?
Is there a tutorial how to do this: "launch a target configuration and connect to the device and look at the memory content without actually downloading any code and running the debugger" ?
Thanks
Hello,
Please check out this example:
If you look into the linker command file: http://dev.ti.com/tirex/explore/node?node=APaqSb5Gq.hTaeSQBTXwBA__kmPly-e__LATEST
You will find the main is limited to 0xFE000, the lower 1MB of the part.
MEMORY { OAD_BSL (RX) : origin = 0x00000000, length = 0x00002000 MAIN (RX) : origin = 0x00002000, length = 0x000FE000 INFO (RX) : origin = 0x00200000, length = 0x00008000 ALIAS { SRAM_CODE (RWX): origin = 0x01000000 SRAM_DATA (RW) : origin = 0x20000000 } length = 0x00040000 }
Let me know if that is not clear
Regards,
Chris
Thank you Chris for answering.
I reduced the range of the main flash to ony bank 0:
MAIN (RX) : origin = 0x00000000, length = 0x000FFFFF
But after restart debugging, the written values beginning from 0x10 0000 are all erased (FF).
Normally it shouldn't erase the not declared range bank1 0x10 000.... (even with the setup is "Erase main memory only").
What's going wrong?
As far as I understand, the
That '1' can't be programmed is clear to me.
This statement is not correct:
Using the erase main memory will invoke the mass erase in the device and erase main memory. Please perform a simple experiment to prove this to yourself.
Regards.
Chris
**Attention** This is a public forum