PlatformIO Community

How to create a Custom Platform with a custom linker script

Hello guys!
Is my first time using platformIO and already trying to do something complicated. I have read pages about custom boards, and custom platforms, and yet no clue on how to do what I am planning. Already noticed platformIO is awesome, so I am sure is possible, somehow…

Here is what I am trying to do (not looking for a ready to use solution (unless really obvious to others)):

I have a custom board with an ATSAME51 and I am already using platformIO to program it!

Now I need to be able to write and build small cpp “pluings” that will be “uploaded” to a fixed RAM/Flash address and call functions from the base firmware.

For this I need to edit/reduce available memory used by base firmware; And, I guess, to create a new platform that will build code without any startup code and limited to only use the previously released memory. And also place its entry on a fixed address (so I can call it from main code).

Am I making things harder than necessary?

For this do I really need a new platform or it should be a new board? None?

Any way, I was no able to find any linker script configuration on platformio files (or been looking the wrong documentation).

Any guidance will be appreciated!! Thanks!

For none of this do you need a custom platform.

Change the used linkerscript in the PlatformIO by using build_board.ldscript. Filter out not-wanted sources using src_filter. Change the maximum allowable firmware size (which is only a secondary safegurad after the linker script used by GCC) by changing board_upload.maximum_size. Change the target upload address by adapting board_upload.offset_address.

And yes, you can also use Advanced Scripting to achieve this. For example, to set a different linker script

To compile sources from a specific external folder with a filter applied

Or change env["SRC_FILTER"].

Thanks @maxgerhardt!

I’ve been reading a lot these days and undertand a little better patform IO concepts. You are right no custon platform for may needs, maybe a custom board, right?

Had no change to test it out today, but tomorrow gonna try settings sugested by you.

My new doubt is how to get ride of prototype board and simple focus on a clean build for the MCU I am using.

There is only a few boards using ATSAME51, I’ve selected one from adafruit. And realised it’s not even using flat framework-arduino-samd, which I assume is a base version, but framework-arduino-samd-adafruit that is including a lot of libraries…

So, looking how to create a minimumn configuration for my MCU (my code do not need libraries, it’s going to call functions from main code only)

Will let you know results of your sugestion. thanks!