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.
I am trying to store a set of default configuration variables in INFOD flash during program load (when I flash the device) so that my program can load them into RAM at bootup. The program may change these variables during execution and will re-save the modified values for the next cold boot.
However I seem to be doing something wrong.
In my linker cmd file I have put the following:
.infoD : {} > INFOD
I have created a struct to hold the variables as below:
typedef struct
{
unsigned char variable1
unsigned char variable2
unsigned char variable3
unsigned char variable4
}config_block_t
In my program I place the flash_config_block into .infoD by using a pragma:
#pragma DATA_SECTION(flash_config_block, ".infoD")
config_block_t * flash_config_block;
...which seems to properly put the struct into INFOD.
**But how do I initialize the struct with the default values at program load (flash) time?** I don't want to initialize them in the program since this will not allow me to change them for the next time the program boots.
Any thoughts would be much appreciated.
In the CCS Project Properaties -> Debug -> MSP430 Properties -> Download Options set the Erase Options to "Erase main and information memory" rather than "Erase main memory only".MikeH said:**But how do I initialize the struct with the default values at program load (flash) time?**
Also why is the following declared as a pointer to the config_block_t:
Rather than:MikeH said:config_block_t flash_config_block;
config_block_t * flash_config_block;
Chester,
Thanks for the feedback.
Chester Gillon said:Properties -> Download Options set the Erase Options to "Erase main and information memory" rather than "Erase main memory only".
Hmm...this does not appear to be erasing INFOD on my device. What could I be doing wrong. I am looking at 0x1800 in the memory browser and the contents do not change after the program loads.
Also, is this just "erase"? Or is it "erase and download"?
Chester Gillon said:Also why is the following declared as a pointer to the config_block_t:
Rather than:config_block_t flash_config_block;config_block_t * flash_config_block;[/quote]
Error on my part.
Experimenting with CCS 5.4 and a MSP430F5510 connected via an Olimex MSP430-JTAG-TINY-V2 shows that:MikeH said:Hmm...this does not appear to be erasing INFOD on my device. What could I be doing wrong. I am looking at 0x1800 in the memory browser and the contents do not change after the program loads.
a) With the Erase Options set to "Erase main memory only" on a program download CCS does attempt to program the INFOD. If the INFOD was already erased it successfully programs. If the INFOD is already programmed with a different content, then the program attempt of INFOD can fail with data verification failure (since only a program and not erase of INFOD was attempted).
b) Changing the Erease Options to "Erase main and information memory" erases any existing INFOD content and then successfully programs the INFOD content from the program.
Can you verify from the linker map that INFOD actually contains some content, as in the following example where the length is non-zero:
(if the flash_config_block intended for INFOD isn't referenced in your code, the linker may discard it)name origin length used unused attr fill
---------------------- -------- --------- -------- -------- ---- --------
SFR 00000000 00000010 00000000 00000010 RWIX
PERIPHERALS_8BIT 00000010 000000f0 00000000 000000f0 RWIX
PERIPHERALS_16BIT 00000100 00000100 00000000 00000100 RWIX
INFOD 00001800 00000080 00000016 0000006a RWIX
INFOC 00001880 00000080 00000000 00000080 RWIX
INFOB 00001900 00000080 00000000 00000080 RWIX
INFOA 00001980 00000080 00000000 00000080 RWIX
Chester,
Chester Gillon said:Can you verify from the linker map that INFOD actually contains some content, as in the following example where the length is non-zero:
Yes, the .map file does show the 8 bytes I intended to store there (my program is different from the example code above):
SECTION ALLOCATION MAP
output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
.infoD 0 00001800 00000008 UNINITIALIZED00001800 00000008 main.obj (.infoD)
Note the "Uninitialized" attribute.? Is this the problem?
I am using the MSP-FET-430UIF with CCS V5.3
Chester Gillon said:b) Changing the Erease Options to "Erase main and information memory" erases any existing INFOD content and then successfully programs the INFOD content from the program.
This sounds like what I want to do, but something is wrong.
Here's a snapshot of the flash memory location showing the actual variable names. The values are the old values programmed previously. They do not change when the program is loaded.
To aid trying to see what the downloaded program will try and program into the INFO flash, can you go to CCS Project Properties -> Build -> Steps -> Post-build steps and apply the predefined step of "Create flash image: TI-TXT". Rebuilding the project will create a <project-name>.TXT file containing the address and data that CCS will attempt to program to flash during the program download.
If the download is set to write to INFOD flash you should see some data for the INFOD flash address. e.g.:
@1800
05 06 07 08
The example I have been trying contains the following variables targted for INFOC and INFOD flash:
The TI-TXT flash image file shows that the download will write to the INFOC and INFOD flash, which is confirmed when the program is downloaded:#pragma DATA_SECTION(data, ".infoC")
#pragma DATA_SECTION(pad, ".infoC")
const char pad[20]="Padding^Padding";
const unsigned int data = 0x08;
typedef struct
{
unsigned char variable1;
unsigned char variable2;
unsigned char variable3;
unsigned char variable4;
}config_block_t;
#pragma DATA_SECTION(config_block, ".infoD")
const config_block_t config_block={5,6,7,8};
However, if I remove the const qualifiers for the variables then the TI-TXT flash image file no longer shows any variables as being written to INFO flash, which is confirmed when the program is downloaded.@1800
05 06 07 08
@1880
50 61 64 64 69 6E 67 5E 50 61 64 64 69 6E 67 00
00 00 00 00 08 00
How are your variables for INFO flash defined?
I found, as you did, that you MUST define the "variables" and "const" (strange). When I do that, the TXT file shows the proper values targeted to be loaded in INFOD.
@1800
00 03 01 01 14 00 00 00
Now I am running into the "data verification" issue, which I believe is related to not erasing the sector before attempting to load.
MSP430: File Loader: Data verification failed at address 0x00001801 Please verify target memory and memory map.
**Attention** This is a public forum