I’m developing IoT app in LPC54628Expresso board with Mbed 5.14.2.
First, I created an example of blinky in Mbed Online Compiler and exported in IAR program.
Then I modify program in local IAR IDE which version is 8.32.1.
It’s OK at first until I need to increase heap size due to TLS application.
Then I increase the heap size to exceed 0x14000, for example, 0x18000.
To reach that, I add SRAMX, add it to DATA_region.
/* SRAMX */
define symbol __SRAMX_start = 0x04000000;
define symbol __SRAMX_end = 0x04007FFF;
define region DATA_region = mem:[from m_data_start to m_data_end]
| mem:[from __SRAMX_start to __SRAMX_end]
| mem:[from m_usb_sram_start to m_usb_sram_end];
place in DATA_region { readwrite, zi, block CSTACK, block HEAP};
After modification of icf file, if I set heap size 0x14000 in cfg file, it’s OK in running.
If I set heap size 0x18000, build is successful but it causes HardFault at the beginning of running.
I set a breakpoint in mbed_init. It can stop there and after step over mbed_sdk_init(), it throws HardFault.
Then I step into mbed_sdk_init, it throws HardFault after step over BOARD_BootClockFROHF96M();
BTW, I tested similar config of icf file in NXP SDK 2.6.0 lwip_httpsrv examples and also add SRAMX, it runs OK even I set heap size to 0x1C000.
Add more clue:
HardFault status register (0xE000ED2C) value is 0x40000000
image
1326×322 15.4 KB
image
979×167 13.6 KB
Which means need to refer other fault register.
MemManage Fault Status Register (0xE000ED28) value is 0x82
image
1374×450 34.4 KB
image
1409×532 25.2 KB
Look at MMFAR register (0xE000ED34), its value is 0x400’0648 which is address of system_LPC54628.o
So is that mean memory in SRAMX is not permitted by Mbed?