platformio / platform-intel_mcs51

Intel MCS-51 (8051): development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/intel_mcs51
Apache License 2.0
56 stars 44 forks source link

How to make it support board_build_offfset option for stc 51 mcu? #42

Closed SSSANTON closed 2 years ago

SSSANTON commented 2 years ago

I want to change the start address of the HEX file after build for IAP function, but I don't find a method to change the start address in platformIO. In keil or IAR, it's easy to change its ROM start address in target tab of project option.

zerog2k commented 2 years ago

Compiler/linker is sdcc, so you can look at the options they provide for mcs51 targets. I believe there was some limited control over some of this. See sections 3.3.5 Linker Options 3.3.6 MCS51 Options http://sdcc.sourceforge.net/doc/sdccman.pdf note that this is the latest 4.1.x manual, and that may not be what is currently packaged w/ platform "Intel MCS-51" (this) I believe it's currently toolchain-sdcc containing sdcc 3.8.4

Also, due to the platformio "wrapper" around the toolchain (i.e. compilation & linking), some things can be passed, but others may not. (It has been a long while since I played around with passing exotic sdcc options, but I recall having to resort to custom build scripts to modify some lower-level linker options, etc.. Ref: https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#extra-linker-flags-without-wl-prefix)

SSSANTON commented 2 years ago

OK, I found the SDDC has an option named "--codec-loc", it can set the start location of the code segment, I have been tried and it works, although it came out a new probelm that the address of the interrupt vetor table can't be changed in my MCU.