From 4b8a6d724a3a1ab284e2388227a13b5fce8a41bd Mon Sep 17 00:00:00 2001 From: Matt Knight Date: Thu, 25 Apr 2024 21:42:14 -0700 Subject: [PATCH] add linkerscript for bootloaded applications --- build.zig | 1 - src/badge/demos/usb_cdc.zig | 2 +- src/badge/samd51j19a_self.ld | 22 ++++++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index 852efe9..88598ec 100644 --- a/build.zig +++ b/build.zig @@ -110,7 +110,6 @@ pub fn build(b: *Build) void { .optimize = optimize, .root_source_file = .{ .path = std.fmt.comptimePrint("src/badge/demos/{s}.zig", .{name}) }, }); - mvp.artifact.image_base = 0x4000; mz.install_firmware(b, mvp, .{}); mz.install_firmware(b, mvp, .{ .format = .{ .uf2 = .SAMD51 }, diff --git a/src/badge/demos/usb_cdc.zig b/src/badge/demos/usb_cdc.zig index ccaa7c9..a02a98b 100644 --- a/src/badge/demos/usb_cdc.zig +++ b/src/badge/demos/usb_cdc.zig @@ -228,7 +228,7 @@ pub fn main() !void { while (USB.DEVICE.SYNCBUSY.read().ENABLE != 0) {} while (true) { - tick(); + //tick(); } } diff --git a/src/badge/samd51j19a_self.ld b/src/badge/samd51j19a_self.ld index adedca4..255e065 100644 --- a/src/badge/samd51j19a_self.ld +++ b/src/badge/samd51j19a_self.ld @@ -28,9 +28,11 @@ */ +/* OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) SEARCH_DIR(.) +*/ ENTRY(microzig_main) @@ -43,6 +45,14 @@ MEMORY qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000 } +PHDRS +{ + ph_rom PT_LOAD FLAGS(0x5); + ph_ram PT_LOAD FLAGS(0x7); + ph_bkupram PT_LOAD FLAGS(0x7); + ph_qspi PT_LOAD FLAGS(0x7); +} + /* Section Definitions */ SECTIONS { @@ -92,14 +102,14 @@ SECTIONS KEEP (*crtend.o(.dtors)) . = ALIGN(4); - } > rom + } > rom : ph_rom /* .ARM.exidx is sorted, so has to go in its own output section. */ PROVIDE_HIDDEN (__exidx_start = .); .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > rom + } > rom : ph_rom PROVIDE_HIDDEN (__exidx_end = .); microzig_data_start = .; @@ -116,7 +126,7 @@ SECTIONS *(.data .data.*); . = ALIGN(4); microzig_data_end = .; - } > ram + } > ram : ph_ram .bkupram (NOLOAD): { @@ -125,7 +135,7 @@ SECTIONS *(.bkupram .bkupram.*); . = ALIGN(8); _ebkupram = .; - } > bkupram + } > bkupram : ph_bkupram .qspi (NOLOAD): { @@ -134,7 +144,7 @@ SECTIONS *(.qspi .qspi.*); . = ALIGN(8); _eqspi = .; - } > qspi + } > qspi : ph_qspi .bss (NOLOAD) : { @@ -144,7 +154,7 @@ SECTIONS *(COMMON) . = ALIGN(4); microzig_bss_end = .; - } > ram + } > ram : ph_ram . = ALIGN(4); _end = . ;