How to use __RODATA macro from <cr_section_macros.h>?

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

How to use __RODATA macro from <cr_section_macros.h>?

1,657 Views
mattschrader
Contributor I

Working with the LPC54608 and I'm attempting to place const data into the external board flash (SPIFI). In my end application, this will be used mostly for graphics data. I am attempting to use the __RODATA macro from <cr_section_macros.h>, as described here:

Placing code/rodata into different FLASH blocks 

So far this has not been successful. What am I missing?

Details

  • LPCXpresso54608 OM13092
  • MCUXpresso IDE v10.2.0
  • I've modified the "hello world" example from the SDK v2.4 (project files attached)
  • I've tried using both available drivers "LPC5460x_SPIFI_GENERIC.cfx" and "LPC546xx_SPIFI_SFDP.cfx"

According to the build output, it shows up under the "BOARD_FLASH" section:

Memory region               Used Size      Region Size      %age Used
PROGRAM_FLASH:         16308 B             512 KB               3.11%
BOARD_FLASH:                     40 B              16 MB               0.00%
SRAM_0_1_2_3:                 8536 B            160 KB                5.21%
SRAMX:                                  0 GB              32 KB                0.00%
USB_RAM:                             0 GB                8 KB                0.00%
BOARD_SDRAM:                   0 GB             16 MB                0.00%
Finished building target: lpcxpresso54608_hello_world.axf

Debug console indicates it is being written:

Inspected v.2 On-chip Flash Memory LPC5460x_512K.cfx
Image 'LPC5460x (512K Flash) Aug 23 2017 12:13:28'
Inspected v.2 External Flash Device on SPI LPC5460x_SPIFI_GENERIC.cfx
Image 'LPC5460x Generic SPIFI Sep 25 2017 16:15:07'
Opening flash driver LPC5460x_SPIFI_GENERIC.cfx
Sending VECTRESET to run flash driver
flash variant 'MT25QL128AB' detected (16MB = 256*64K at 0x10000000)
Closing flash driver LPC5460x_SPIFI_GENERIC.cfx
NXP: LPC54608J512
Connected: was_reset=true. was_stopped=false
Awaiting telnet connection to port 3330 ...
GDB nonstop mode enabled
Opening flash driver LPC5460x_512K.cfx
Sending VECTRESET to run flash driver
Writing 16308 bytes to address 0x00000000 in Flash
Erased/Wrote page 0-0 with 16308 bytes in 193msec
Closing flash driver LPC5460x_512K.cfx
Flash Write Done
Opening flash driver LPC5460x_SPIFI_GENERIC.cfx
Sending VECTRESET to run flash driver
Writing 40 bytes to address 0x10000000 in Flash
Erased/Wrote page 0-0 with 40 bytes in 191msec
Closing flash driver LPC5460x_SPIFI_GENERIC.cfx
Flash Write Done
Flash Program Summary: 16348 bytes in 0.38 seconds (41.47 KB/sec)
Starting execution using system reset and halt target

Yet when I debug, I cannot see the data in the Memory monitor (address 0x10000000), and a simple printf of the data does not show the expected result.

I'm also seeing that this program gets stuck in SPIFI_ResetCommand() as called by SPIFI_Init(). This makes me think the h/w is being left in a bad state after programming?

Labels (1)
0 Kudos
2 Replies

1,136 Views
mattschrader
Contributor I

Thank you for highlighting that chapter in the manual. I had read it before and decided that use of the __RODATA macro seemed to be the easiest path for my application. After following the example you pointed out in 16.13.2, I still seem to be missing something…

 

First off, the example code I posted initially had some problems around SPIFI initialization, which explains some of the issues. I restarted using the “lpcxpresso54608_spifi_polling_transfer” example. From this example code I was able to achieve the desired result of placing data in the external board flash using the __RODATA macro. This example code is attached.

Then I took that working example and attempted to use the linkerscript method (from 16.13.2). The test data ends up getting placed into the program flash. This example code is also attached. Could you please take a look and tell me what I’m missing?

0 Kudos

1,136 Views
lpcxpresso_supp
NXP Employee
NXP Employee

In the first place, please check out chapter 16, "Memory Configuration and Linker Scripts", of the MCUXpresso IDE v10.2 User Guide. In particular, you probably want to use the linker script templates described in section 16.13.2 : "Configuring projects to span multiple Flash Devices", rather than the __RODATA macro.

Regards,

MCUXpresso IDE Support

0 Kudos