Locating Constant Variable in FLASH

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Locating Constant Variable in FLASH

725 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mvinger on Sun Jun 23 21:23:28 MST 2013
I thought putting the following would create a 64-byte block (1 page) in FLASH.
It does not seem to always work.

[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]const[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FLASHPAGE[16] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]__attribute__[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ((aligned (64)))[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]
[SIZE=2][COLOR=#3f7f5f]Any ideas?
Thanks.
MTV2

[/COLOR][/SIZE][/COLOR][/SIZE]
0 Kudos
13 Replies

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Fri Jun 28 09:41:30 MST 2013
A quick way to see if it is an optimization issue is to enable optimization in the debug build and see if it stops working.
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Jun 27 23:55:59 MST 2013

Quote: mvinger

When debugging the release code, I seemed to see the FLASHPAGE area change to the appropriate value, but because of the strange debug behavior, I could not be 100% sure what I was seeing was correct. For example, when I would single step through the code, the current location highlight would jump up and down through the code but generally move forward. This may be an optimization/debug/release anomaly (not sure).



http://support.code-red-tech.com/CodeRedWiki/CompilerOptimization


Quote:

What is the procedure for connecting to a running target without downloading an updated version of code.



There is another forum  thread running on this right now! The answer is in:

http://support.code-red-tech.com/CodeRedWiki/DebugRunningSystem


Quote:

I noticed LPCXpresso does not always show all the functionality where it is easy to find. It took me ten minutes of going through the pull-down menus to find out how to show the disassembly window and still cannot find how to step through the disassembled code other than using CTRL-R.




http://support.code-red-tech.com/CodeRedWiki/DebugViewAsm

Probably be a good idea for you to read the LPCXpresso Getting Started Guide and also the Red Suite Getting Started (which is also supplied in the product):

http://support.code-red-tech.com/CodeRedWiki/RedSuiteDocs

The FAQs also have a wealth of information (as you might have worked out by now! :D )

http://support.code-red-tech.com/CodeRedWiki/CodeRedFAQ


Quote:

Any ideas on why the code to write to the FLASH would work in debug but not in release???



As per the optimisation FAQ above. Most likely missing volatile or a timing thing.

Regards,
CodeRedSupport
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mvinger on Thu Jun 27 20:33:05 MST 2013
Just to be clear, it is the code that programs the updated Volume value into FLASH that works differently between the debug and release configurations, the actual programming of the executable (etc.) image into FLASH seems to be fine in all cases in that the code seems to execute properly (for the most part).

I have 11 LEDs that display the volume level on another UI board which communicates over ASYNC serial. So I can debug the code on the mainboard while changing the volume and viewing the volume on the UI board. On Volume changes, the UI board reports the change to the mainboard and the mainboard reports back the new volume level. I have a timeout after the last change which programs the new Volume level into the FLASHPAGE location.

When debugging the release code, I seemed to see the FLASHPAGE area change to the appropriate value, but because of the strange debug behavior, I could not be 100% sure what I was seeing was correct. For example, when I would single step through the code, the current location highlight would jump up and down through the code but generally move forward. This may be an optimization/debug/release anomaly (not sure). When I performed an external reset or power cycle, the value would be that which was initialized during the FLASH programming (either from the previous debug session or by directly downloading the code to FLASH).

When debugging the debug configuration, all operations appeared to work as designed and the debug session progressed as it should including looking at the FLASHPAGE location and seeing that it got updated. On reset/power cycle, the updated Volume value was retained as it should be.

What is the procedure for connecting to a running target without downloading an updated version of code. I noticed LPCXpresso does not always show all the functionality where it is easy to find. It took me ten minutes of going through the pull-down menus to find out how to show the disassembly window and still cannot find how to step through the disassembled code other than using CTRL-R.

Anyway, still getting used to the tools as well.

Any ideas on why the code to write to the FLASH would work in debug but not in release???

Thanks for your help.

MTV2
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Jun 27 01:33:34 MST 2013

Quote: mvinger

As you will see I have commented out several things I have tried to get the release version to work. If I have default debugging on for the release and 'debug' the code (which does not seem to work very well) and look at the progress of the procedure after every IAP call, there are no errors and the FLASH location, after all is done, seems to be programmed. However, on cycling power, the location is at its default/initialized value again.

Again, in the debug configuration, the IAP programming works, just not in the release configuration.


As you say, the programming of your image into flash by the debugger appears to actually function correctly.

So when your code runs (as I don't have your hardware here I can't see what it actually does), are you saying that you can see the values in the flash at 0x3fc0 have changed in the memory view? But that when you reset the board, the values have changed again? How are you actually determining this? Obviously if you reload your image via the debugger, then the flash programmer will overwrite the values. However you could try attaching to a running target instead...

http://support.code-red-tech.com/CodeRedWiki/DebugRunningSystem

With regards to debug vs release behaviour, you may find this FAQ of use...

http://support.code-red-tech.com/CodeRedWiki/CompilerOptimization

Regards,
CodeRedSupport
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mvinger on Wed Jun 26 20:06:58 MST 2013
Thank you for the replies.
I am using the current version and atomicdog is correct about -fdata-sections and I did set the same section setting in both the release and debug configs.

I have attached the project.
As you will see I have commented out several things I have tried to get the release version to work. If I have default debugging on for the release and 'debug' the code (which does not seem to work very well) and look at the progress of the procedure after every IAP call, there are no errors and the FLASH location, after all is done, seems to be programmed. However, on cycling power, the location is at its default/initialized value again.

Again, in the debug configuration, the IAP programming works, just not in the release configuration.

Thank you for your help on this matter.

Also, I have changed some of the lpc800 driver library for my application.

But, I have found, with the help of another forum member, a bug in the lpc800 UART init code. The baudrate is set based on the SystemCoreClock which is the MainClock after the divider. However, the UART block runs directly from the MainClock. So, the following line in the UART init code should be changed:

FROM:
[SIZE=2]UARTSysClk=SystemCoreClock[/SIZE][SIZE=2]/LPC_SYSCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]UARTCLKDIV[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
TO:
[SIZE=2]UARTSysClk=(SystemCoreClock*LPC_SYSCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SYSAHBCLKDIV[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])/LPC_SYSCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]UARTCLKDIV[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Wed Jun 26 00:14:00 MST 2013
First of all, make sure that you are using the latest version of LPCXpresso (currently 5.2.4).

If you are seeing issues here with this version, then I suggest that you export and post your project

http://support.code-red-tech.com/CodeRedWiki/ImportExport

If you can't post your project, please post your map file and AXF file.

Also please confirm which probe (LPC-Link?) and what target MCU.

Regards,
CodeRedSupport
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Tue Jun 25 23:03:02 MST 2013

Quote: mvinger
-O0 for debug but -Os for release.
Only --gc-sections for both configurations.

I am also using --section-start=.PARMPAGE=0x3FC0 to place my 64byte block at the top of FLASH memory (the const declaration has the attribute for the .PARMPAGE section).

Thank you for the help.
MTV2


Are you sure only [I]-gc-sections[/I]? I don't think it does much good without the other one. The -gc-section is a linker option while [I]-fdata-sections[/I] is a compiler option (in a different area of the settings properties).

Did you set --section-start for both  Debug and release? I've had trouble with setting parameters for both even though I tried to set the [I]configuration[/I] to " [All Configurations] ". If you only set --section-start for the debug config only then that probably is your problem.
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mvinger on Tue Jun 25 22:37:12 MST 2013
Also, here is a part of the code for reference:

[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// IAP Routines Location (LSb set because Thumb code)

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IAP_LOCATION 0x1FFF1FF1[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]unsigned[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] IAPcommand[5];[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]unsigned[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] IAPresult[4];[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]typedef[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] (*[/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]IAP[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]unsigned[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] [], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]unsigned[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] []);[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]IAP[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] iap_entry = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]IAP[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])IAP_LOCATION;[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// IAP Prepare Sector(s) for Write Operation 50:StartSector#:EndSector#
[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IAPprepSectorWrite 50[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// IAP Copy RAM to FLASH 51:DST64BFLASHaddr:SRCwordAddr:#bytes(64/128/256/512/1024):SYSCLKkHz
[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IAPcopyRAMtoFLASH  51[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// IAP Erase Page 59:StartPage#:EndPage#:SYSCLKkHz

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IAPerasePage       59[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PAGENUM(x) (x/64)[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SECTNUM(x) (x/1024)[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SYSCLKK(x) (x/1000)[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VOL_UPDATE_DELAYx10MS 1000[/SIZE]
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]const[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FLASHPAGE[16] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]__attribute__[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ((section([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]".PARMPAGE"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]))) = {0};[/SIZE]
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]volatile[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] RAMPAGE[16] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]__attribute__[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ((aligned (64))) ={0};[/SIZE]
[SIZE=2][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]volatile[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TT_TO_flag;[/SIZE]

[SIZE=2]...

[SIZE=2]    [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ( TT_TO_flag ) { [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// IF ( CHANGE & TIMEOUT )[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]TT_TO_flag = 0;
RAMPAGE[0] = VOL_MSTR;
RAMPAGE[1] = VOL_BOS;

[/SIZE][SIZE=2]    [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// DISABLE Interrupts[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]LPC_USART0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]INTENCLR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = RXRDY;[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Disable UART interrupt */[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE]
[SIZE=2]    [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// PREPARE SECTOR for WRITE (ADDR/1024)[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]IAPcommand[0] = IAPprepSectorWrite;
[/SIZE][SIZE=2]IAPcommand[2] = IAPcommand[1] = SECTNUM(([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])FLASHPAGE);[/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//    IAPcommand[3] = 0; // NU
//    IAPcommand[4] = 0; // NU
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]iap_entry( IAPcommand, IAPresult );
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// ERASE PAGE (ADDR/64)[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]IAPcommand[0] = IAPerasePage;
[/SIZE][SIZE=2]IAPcommand[2] = IAPcommand[1] = PAGENUM(([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])FLASHPAGE);[/SIZE]
[SIZE=2]IAPcommand[3] = SYSCLKK(SystemCoreClock);
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//    IAPcommand[4] = 0; // NU
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]iap_entry( IAPcommand, IAPresult );
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// PREPARE SECTOR for WRITE (ADDR/1024)[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]IAPcommand[0] = IAPprepSectorWrite;
[/SIZE][SIZE=2]IAPcommand[2] = IAPcommand[1] = SECTNUM(([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])FLASHPAGE);[/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//    IAPcommand[3] = 0; // NU
//    IAPcommand[4] = 0; // NU
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]iap_entry( IAPcommand, IAPresult );
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// COPY RAM to FLASH (ADDR/PAGE)[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]IAPcommand[0] = IAPcopyRAMtoFLASH;
[/SIZE][SIZE=2]IAPcommand[1] = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])FLASHPAGE;[/SIZE]
[SIZE=2][/SIZE][SIZE=2]IAPcommand[2] = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])RAMPAGE;[/SIZE]
[SIZE=2][/SIZE][SIZE=2]IAPcommand[3] = 64; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Write 1 Page[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]IAPcommand[4] = SYSCLKK(SystemCoreClock);
iap_entry( IAPcommand, IAPresult );
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// ENABLE Interrupts[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]LPC_USART0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]INTENSET[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = RXRDY;[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Enable UART interrupt */[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][/SIZE][SIZE=2]} [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// ENDIF ( CHANGE & TIMEOUT )[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE]
[SIZE=2]      [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* END - UPDATE VOL/BAL FLASH BLOCK */[/COLOR][/SIZE][/COLOR][/SIZE]
[COLOR=#3f7f5f][/COLOR]
[COLOR=#3f7f5f]---[/COLOR]
[COLOR=#3f7f5f][/COLOR]
[COLOR=#3f7f5f]The code works when compiled in the debug configuration, but the FLASH memory location appears to always revert back to the 'initialized' value on power cycle when in the release configuration.[/COLOR]
[COLOR=#3f7f5f][/COLOR]
[COLOR=#3f7f5f]???[/COLOR]
[/SIZE]
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mvinger on Tue Jun 25 22:06:13 MST 2013
-O0 for debug but -Os for release.
Only --gc-sections for both configurations.

I am also using --section-start=.PARMPAGE=0x3FC0 to place my 64byte block at the top of FLASH memory (the const declaration has the attribute for the .PARMPAGE section).

Thank you for the help.
MTV2
0 Kudos

680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Tue Jun 25 20:16:50 MST 2013

Quote: mvinger
Thank you for your posts.
I found a clean and simple method to place it with 'section'.

Now I am having odd behavior where when I use the debug configuration the changes are stored in FLASH appropriately, but when I use the release configuration it always reverts back to 0 when I cycle power.

Are you using [I]-O0[/I] for Debug optimization level? Are you using [I]-fdata-sections and --gc-sections[/I]? The linker will get ride of sections that don't look like their being used.


Quote: mvinger

Also, one of my processors seems to not boot all the time on power-up and requires me to 'tap' the external reset line to bring it alive.

Sounds a little like a hardware issue.
0 Kudos

679 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mvinger on Tue Jun 25 19:19:09 MST 2013
Thank you for your posts.
I found a clean and simple method to place it with 'section'.

Now I am having odd behavior where when I use the debug configuration the changes are stored in FLASH appropriately, but when I use the release configuration it always reverts back to 0 when I cycle power.

Also, one of my processors seems to not boot all the time on power-up and requires me to 'tap' the external reset line to bring it alive.

Any ideas?
Thanks.
MTV2
0 Kudos

679 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Mon Jun 24 23:21:06 MST 2013
What doesn't work? Have you looked at the map file to see what's happening with the variable?
0 Kudos

679 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by skeeve on Mon Jun 24 15:34:14 MST 2013

Quote: mvinger
I thought putting the following would create a 64-byte block (1 page) in FLASH.
It does not seem to always work.

[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]const[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FLASHPAGE[16] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]__attribute__[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ((aligned (64)))[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE]

I'm surprised it ever works.
Probably you need to specify a section attribute that will place it in a flash section.
Also, you need at most one of those zeros.
The rest will default to zero.
0 Kudos