diff options
author | Ayke van Laethem <[email protected]> | 2023-03-30 20:36:52 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-03-30 23:49:02 +0200 |
commit | e0bf376068ac7f103b0d663460ca9371152e6e0f (patch) | |
tree | 0c9407b9ab288ec39d7fec96d74f523baace84f4 | |
parent | b044d4ff3d672664df560190df68470b4e3eec77 (diff) | |
download | tinygo-e0bf376068ac7f103b0d663460ca9371152e6e0f.tar.gz tinygo-e0bf376068ac7f103b0d663460ca9371152e6e0f.zip |
rp2040: unify all linker scripts using LDFLAGS
The only thing that's different between all these chips is the flash
size, which can easily be passed as a linker flag instead. This removes
a bunch of duplicate code in an uncommon language (linker script).
I've also fixed a few boards with incorrect flash sizes:
* nano-rp2040 has 16MB instead of 2MB
* macropad-rp2040 has 8MB instead of 2MB
* gopher-badge has 8MB instead of 1MB
-rw-r--r-- | targets/badger2040.json | 4 | ||||
-rw-r--r-- | targets/badger2040.ld | 10 | ||||
-rw-r--r-- | targets/challenger-rp2040.json | 4 | ||||
-rw-r--r-- | targets/feather-rp2040.json | 4 | ||||
-rw-r--r-- | targets/feather-rp2040.ld | 10 | ||||
-rw-r--r-- | targets/gopher-badge.json | 4 | ||||
-rw-r--r-- | targets/gopher-badge.ld | 10 | ||||
-rw-r--r-- | targets/kb2040.json | 4 | ||||
-rw-r--r-- | targets/macropad-rp2040.json | 4 | ||||
-rw-r--r-- | targets/nano-rp2040.json | 4 | ||||
-rw-r--r-- | targets/pico.json | 4 | ||||
-rw-r--r-- | targets/pico.ld | 10 | ||||
-rw-r--r-- | targets/qtpy-rp2040.json | 4 | ||||
-rw-r--r-- | targets/qtpy-rp2040.ld | 10 | ||||
-rw-r--r-- | targets/rp2040.json | 1 | ||||
-rw-r--r-- | targets/rp2040.ld | 7 | ||||
-rw-r--r-- | targets/thingplus-rp2040.json | 4 | ||||
-rw-r--r-- | targets/thingplus-rp2040.ld | 10 | ||||
-rw-r--r-- | targets/trinkey-qt2040.json | 4 | ||||
-rw-r--r-- | targets/trinkey-qt2040.ld | 10 | ||||
-rw-r--r-- | targets/tufty2040.json | 4 | ||||
-rw-r--r-- | targets/tufty2040.ld | 10 | ||||
-rw-r--r-- | targets/waveshare-rp2040-zero.json | 4 | ||||
-rw-r--r-- | targets/waveshare-rp2040-zero.ld | 10 | ||||
-rw-r--r-- | targets/xiao-rp2040.json | 4 | ||||
-rw-r--r-- | targets/xiao-rp2040.ld | 10 |
26 files changed, 50 insertions, 114 deletions
diff --git a/targets/badger2040.json b/targets/badger2040.json index d325bd067..34eef117b 100644 --- a/targets/badger2040.json +++ b/targets/badger2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["2e8a:0003"], "build-tags": ["badger2040"], - "linkerscript": "targets/badger2040.ld", + "ldflags": [ + "--defsym=__flash_size=1020K" + ], "extra-files": [ "targets/pico-boot-stage2.S" ] diff --git a/targets/badger2040.ld b/targets/badger2040.ld deleted file mode 100644 index 7e06d7a0a..000000000 --- a/targets/badger2040.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 1020K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld" diff --git a/targets/challenger-rp2040.json b/targets/challenger-rp2040.json index 28591db28..6d187e777 100644 --- a/targets/challenger-rp2040.json +++ b/targets/challenger-rp2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["2e8a:1023"], "build-tags": ["challenger_rp2040"], - "linkerscript": "targets/feather-rp2040.ld", + "ldflags": [ + "--defsym=__flash_size=8M" + ], "extra-files": [ "targets/feather-rp2040-boot-stage2.S" ] diff --git a/targets/feather-rp2040.json b/targets/feather-rp2040.json index 5409f89b3..871cdb45f 100644 --- a/targets/feather-rp2040.json +++ b/targets/feather-rp2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["239a:80f1"], "build-tags": ["feather_rp2040"], - "linkerscript": "targets/feather-rp2040.ld", + "ldflags": [ + "--defsym=__flash_size=8192K" + ], "extra-files": [ "targets/feather-rp2040-boot-stage2.S" ] diff --git a/targets/feather-rp2040.ld b/targets/feather-rp2040.ld deleted file mode 100644 index d97942f5c..000000000 --- a/targets/feather-rp2040.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 8192K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld"
\ No newline at end of file diff --git a/targets/gopher-badge.json b/targets/gopher-badge.json index 8bf4f0c92..ec50b303c 100644 --- a/targets/gopher-badge.json +++ b/targets/gopher-badge.json @@ -4,7 +4,9 @@ ], "serial-port": ["2e8a:0003"], "build-tags": ["gopher_badge"], - "linkerscript": "targets/gopher-badge.ld", + "ldflags": [ + "--defsym=__flash_size=8M" + ], "extra-files": [ "targets/pico-boot-stage2.S" ] diff --git a/targets/gopher-badge.ld b/targets/gopher-badge.ld deleted file mode 100644 index 7e06d7a0a..000000000 --- a/targets/gopher-badge.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 1020K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld" diff --git a/targets/kb2040.json b/targets/kb2040.json index ce9360f50..1fc045b52 100644 --- a/targets/kb2040.json +++ b/targets/kb2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["239a:8106"], "build-tags": ["kb2040"], - "linkerscript": "targets/qtpy-rp2040.ld", + "ldflags": [ + "--defsym=__flash_size=8192K" + ], "extra-files": [ "targets/qtpy-rp2040-boot-stage2.S" ] diff --git a/targets/macropad-rp2040.json b/targets/macropad-rp2040.json index 027657bd7..59db5b2ad 100644 --- a/targets/macropad-rp2040.json +++ b/targets/macropad-rp2040.json @@ -4,7 +4,9 @@ ], "build-tags": ["macropad_rp2040"], "serial-port": ["239a:8107"], - "linkerscript": "targets/pico.ld", + "ldflags": [ + "--defsym=__flash_size=8M" + ], "extra-files": [ "targets/macropad-rp2040-boot-stage2.S" ] diff --git a/targets/nano-rp2040.json b/targets/nano-rp2040.json index f1623dfe8..313fead9c 100644 --- a/targets/nano-rp2040.json +++ b/targets/nano-rp2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["2341:005e"], "build-tags": ["nano_rp2040"], - "linkerscript": "targets/pico.ld", + "ldflags": [ + "--defsym=__flash_size=16M" + ], "extra-files": [ "targets/pico-boot-stage2.S" ] diff --git a/targets/pico.json b/targets/pico.json index 984b92879..88aec23d0 100644 --- a/targets/pico.json +++ b/targets/pico.json @@ -4,7 +4,9 @@ ], "build-tags": ["pico"], "serial-port": ["2e8a:000A"], - "linkerscript": "targets/pico.ld", + "ldflags": [ + "--defsym=__flash_size=2048K" + ], "extra-files": [ "targets/pico-boot-stage2.S" ] diff --git a/targets/pico.ld b/targets/pico.ld deleted file mode 100644 index 6ef32a3cb..000000000 --- a/targets/pico.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 2048K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld" diff --git a/targets/qtpy-rp2040.json b/targets/qtpy-rp2040.json index 0a53accc2..394d83aa6 100644 --- a/targets/qtpy-rp2040.json +++ b/targets/qtpy-rp2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["239a:80f7"], "build-tags": ["qtpy_rp2040"], - "linkerscript": "targets/qtpy-rp2040.ld", + "ldflags": [ + "--defsym=__flash_size=8192K" + ], "extra-files": [ "targets/qtpy-rp2040-boot-stage2.S" ] diff --git a/targets/qtpy-rp2040.ld b/targets/qtpy-rp2040.ld deleted file mode 100644 index d97942f5c..000000000 --- a/targets/qtpy-rp2040.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 8192K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld"
\ No newline at end of file diff --git a/targets/rp2040.json b/targets/rp2040.json index f4dc8c044..99a568a79 100644 --- a/targets/rp2040.json +++ b/targets/rp2040.json @@ -12,6 +12,7 @@ "extra-files": [ "src/device/rp/rp2040.s" ], + "linkerscript": "targets/rp2040.ld", "openocd-interface": "picoprobe", "openocd-transport": "swd", "openocd-target": "rp2040" diff --git a/targets/rp2040.ld b/targets/rp2040.ld index 5aa57ce69..118735e30 100644 --- a/targets/rp2040.ld +++ b/targets/rp2040.ld @@ -1,3 +1,10 @@ +MEMORY +{ + /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ + BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 + FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = __flash_size - 256 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k +} _stack_size = 2K; diff --git a/targets/thingplus-rp2040.json b/targets/thingplus-rp2040.json index dfd71ad30..6718b86d2 100644 --- a/targets/thingplus-rp2040.json +++ b/targets/thingplus-rp2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["1b4f:0026"], "build-tags": ["thingplus_rp2040"], - "linkerscript": "targets/thingplus-rp2040.ld", + "ldflags": [ + "--defsym=__flash_size=16M" + ], "extra-files": [ "targets/pico-boot-stage2.S" ] diff --git a/targets/thingplus-rp2040.ld b/targets/thingplus-rp2040.ld deleted file mode 100644 index 5e49f3b83..000000000 --- a/targets/thingplus-rp2040.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 16384K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld"
\ No newline at end of file diff --git a/targets/trinkey-qt2040.json b/targets/trinkey-qt2040.json index 3678085d7..23ae3f6c5 100644 --- a/targets/trinkey-qt2040.json +++ b/targets/trinkey-qt2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["239a:8109"], "build-tags": ["trinkey_qt2040"], - "linkerscript": "targets/trinkey-qt2040.ld", + "ldflags": [ + "--defsym=__flash_size=8192K" + ], "extra-files": [ "targets/trinkey-qt2040-boot-stage2.S" ] diff --git a/targets/trinkey-qt2040.ld b/targets/trinkey-qt2040.ld deleted file mode 100644 index d97942f5c..000000000 --- a/targets/trinkey-qt2040.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 8192K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld"
\ No newline at end of file diff --git a/targets/tufty2040.json b/targets/tufty2040.json index 5534e4be9..11c4e334e 100644 --- a/targets/tufty2040.json +++ b/targets/tufty2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["2e8a:0003"], "build-tags": ["tufty2040"], - "linkerscript": "targets/tufty2040.ld", + "ldflags": [ + "--defsym=__flash_size=1020K" + ], "extra-files": [ "targets/pico-boot-stage2.S" ] diff --git a/targets/tufty2040.ld b/targets/tufty2040.ld deleted file mode 100644 index 7e06d7a0a..000000000 --- a/targets/tufty2040.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 1020K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld" diff --git a/targets/waveshare-rp2040-zero.json b/targets/waveshare-rp2040-zero.json index 878969afa..a31c4e844 100644 --- a/targets/waveshare-rp2040-zero.json +++ b/targets/waveshare-rp2040-zero.json @@ -4,7 +4,9 @@ ], "serial-port": ["2e8a:0003"], "build-tags": ["waveshare_rp2040_zero"], - "linkerscript": "targets/waveshare-rp2040-zero.ld", + "ldflags": [ + "--defsym=__flash_size=1020K" + ], "extra-files": [ "targets/pico-boot-stage2.S" ] diff --git a/targets/waveshare-rp2040-zero.ld b/targets/waveshare-rp2040-zero.ld deleted file mode 100644 index 7e06d7a0a..000000000 --- a/targets/waveshare-rp2040-zero.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 1020K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld" diff --git a/targets/xiao-rp2040.json b/targets/xiao-rp2040.json index ce967ad0e..02a36c06a 100644 --- a/targets/xiao-rp2040.json +++ b/targets/xiao-rp2040.json @@ -4,7 +4,9 @@ ], "serial-port": ["2e8a:000a"], "build-tags": ["xiao_rp2040"], - "linkerscript": "targets/xiao-rp2040.ld", + "ldflags": [ + "--defsym=__flash_size=1020K" + ], "extra-files": [ "targets/pico-boot-stage2.S" ] diff --git a/targets/xiao-rp2040.ld b/targets/xiao-rp2040.ld deleted file mode 100644 index 7e06d7a0a..000000000 --- a/targets/xiao-rp2040.ld +++ /dev/null @@ -1,10 +0,0 @@ - -MEMORY -{ - /* Reserve exactly 256 bytes at start of flash for second stage bootloader */ - BOOT2_TEXT (rx) : ORIGIN = 0x10000000, LENGTH = 256 - FLASH_TEXT (rx) : ORIGIN = 0x10000000 + 256, LENGTH = 1020K - 256 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k -} - -INCLUDE "targets/rp2040.ld" |