platformio / platform-nxplpc

NXP LPC: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/nxplpc
Apache License 2.0
9 stars 12 forks source link

Linker script produces excessively large binaries for LPC1549 #23

Closed ducky64 closed 3 years ago

ducky64 commented 3 years ago

The firmware.bin files are 33,587,200 bytes (=0x2008000), which is equivalent to the contents of flash, empty space inbetween, ram1, and ram2 banks. This causes problems with OpenOCD flashing, which uses the .bin (instead of .elf) files and seems to try to write past the flash banks.

This seems to be a problem in the LPC1549.ld and a result of different RAM banks for the .data and .heap sections, since (at least some) other LPC targets do not have this issue.

Experimentally, the firmware.bin files have saner sizes if:

I'm not super familiar with linker scripts, so I don't know which of the above is the right fix. But this might be an easy fix for someone more familiar with linker scripts?

Second issue is how to make the fix, since the LPC1549 target is no longer supported by mbed (the nxplpc platform pulls in an old version of mbed for these deprecated targets), and the LPC1549.ld file no longer exists on master.

valeros commented 3 years ago

Hi @ducky64 ! It might be a good idea to submit an issue to the mbed repository as this repo is not the right place to fix the problem. As a workaround you can specify your own linker script in the platformio.ini file:

platform = nxplpc
framework = mbed
board = ...
board_build.ldscript = /path/to/script.ld