Cannot find linker script file

I am using a custom board (i have divided memory into high and low, each one is defined as a board) but when i build it does not find the linker script

The .json file:

"build": {
    "core": "arduino",
    "cpu": "cortex-m3",
    "extra_flags": "-D__SAM3X8E__ -DARDUINO_ARCH_SAM -DARDUINO_SAM_DUE",
    "f_cpu": "84000000L",
    "hwids": [
    "ldscript": "flash_low.ld",
    "mcu": "at91sam3x8e",
    "usb_product": "Arduino Due",
    "variant": "arduino_due_x"
  "connectivity": [
  "debug": {
    "jlink_device": "ATSAM3X8E",
    "openocd_chipname": "at91sam3X8E",
    "openocd_target": "at91sam3XXX",
    "svd_path": "ATSAM3X8E.svd"
  "frameworks": [
  "name": "Arduino Due (Low Bootloader)",
  "upload": {
    "disable_flushing": true,
    "maximum_ram_size": 98304,
    "maximum_size": 524288,
    "native_usb": false,
    "protocol": "sam-ba",
    "protocols": [
    "require_upload_port": true,
    "use_1200bps_touch": true,
    "wait_for_upload_port": false
  "url": "",
  "vendor": "Arduino"

I added the board to the .platformio/packages/framework-arduino-same/boards.txt file: Due (Low bootloader)
arduino_due_xhb.upload.native_usb=true"Arduino LLC""Arduino Due" -mthumb {build.usb_flags}

Made the necessary modifications and copied flash_low.ld to ~/.platformio/packages/framework-arduinosam/variants/arduino_due_x/linker_scripts/gcc

Where could it be looking for the ld script?

The original board file gives this in a different construct, not in the “build” object directly

Does the error go away when you use it like that with the value flash_low.ld?

Also, with the project task “Advanced → Verbose Build” you can get every compiler invocation. The last invocation should be the linker invocation with -o [..] firmware.elf. This command has a bunch of -L switches to add paths to the library search paths and a -T flag that gives the linker script. The linker will only find the linker script if it’s within one of the -L paths it was informed about. What does the linker command look like in full?

Any modifications to this file is completely ignored, PlatformIO does not read information from Arduino’s board.txt file. It sources its information from the board JSON files and the rest is done in the builder script logic (e.g. here).

1 Like

Indeed it needed to be inside arduino construct. I ran the Advanceed verbose build but i could’nt see those paths.

Thank you again for helping the newbie get the project running :slight_smile:

Actually this is really bad for portability onto another computer too – you shouldn’t modify framework packages.

The builder scripts give you the opportunity to specify a custom locations for the variants folder.

Meaning you can copy just the ~/.platformio/packages/framework-arduinosam/variants/arduino_due_x/ folder into the project that uses it under e.g. custom_variants/arduino_due_x and then just set

board_build.variants_dir = custom_variants

in the platformio.ini to make the builder script use it.

Then no modification of framework files is needed and the project is 100% portable (if you only added / changed variant files – though even for changed framework files you can use platform_packages).

So i define it in platformio.ini and run the builder script to create the proper folders?

No, you just move / copy the variant folder and put the info for that path into the platformio.ini. The builder script ( is automatically invoked by PlatformIO every time you build the project, you don’t have to explicitly call it. Also it just uses the information that you have configured in the platformio.ini, it doesn’t create the variant folder by itself.

1 Like