Skip to content

Commit

Permalink
add linkerscript for bootloaded applications
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnite committed Apr 27, 2024
1 parent c4b9cc4 commit 4b8a6d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
1 change: 0 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 1 addition & 1 deletion src/badge/demos/usb_cdc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub fn main() !void {
while (USB.DEVICE.SYNCBUSY.read().ENABLE != 0) {}

while (true) {
tick();
//tick();
}
}

Expand Down
22 changes: 16 additions & 6 deletions src/badge/samd51j19a_self.ld
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
*/


/*
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
SEARCH_DIR(.)
*/

ENTRY(microzig_main)

Expand All @@ -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
{
Expand Down Expand Up @@ -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 = .;
Expand All @@ -116,7 +126,7 @@ SECTIONS
*(.data .data.*);
. = ALIGN(4);
microzig_data_end = .;
} > ram
} > ram : ph_ram

.bkupram (NOLOAD):
{
Expand All @@ -125,7 +135,7 @@ SECTIONS
*(.bkupram .bkupram.*);
. = ALIGN(8);
_ebkupram = .;
} > bkupram
} > bkupram : ph_bkupram

.qspi (NOLOAD):
{
Expand All @@ -134,7 +144,7 @@ SECTIONS
*(.qspi .qspi.*);
. = ALIGN(8);
_eqspi = .;
} > qspi
} > qspi : ph_qspi

.bss (NOLOAD) :
{
Expand All @@ -144,7 +154,7 @@ SECTIONS
*(COMMON)
. = ALIGN(4);
microzig_bss_end = .;
} > ram
} > ram : ph_ram

. = ALIGN(4);
_end = . ;
Expand Down

0 comments on commit 4b8a6d7

Please sign in to comment.