Skip to content

Commit

Permalink
temporarily disable bootloader compression due to bugs in the IPL3 + …
Browse files Browse the repository at this point in the history
…code cleanup
  • Loading branch information
Polprzewodnikowy committed Dec 10, 2023
1 parent 29ba0c6 commit bd70402
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 37 deletions.
5 changes: 3 additions & 2 deletions sw/bootloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ $(BUILD_DIR)/bootloader.elf: $(OBJS) N64.ld
$(BUILD_DIR)/bootloader.bin: $(BUILD_DIR)/bootloader.elf
@cp $< $<.stripped
@$(STRIP) -s $<.stripped
@$(N64_ELFCOMPRESS) -c 2 -o $(dir $<) $<.stripped
@$(N64_TOOL) --title "SC64 bootloader" --output $@ --align 256 $<.stripped
@cp $<.stripped $<.compressed
@$(N64_ELFCOMPRESS) -c 0 -o $(dir $<) $<.compressed
@$(N64_TOOL) --title "SC64 bootloader" --output $@ --align 256 $<.compressed

all: $(BUILD_DIR)/bootloader.bin

Expand Down
59 changes: 48 additions & 11 deletions sw/bootloader/N64.ld
Original file line number Diff line number Diff line change
@@ -1,46 +1,83 @@
MEMORY {
ram (rwx) : org = 0x80000000, len = 2M
exceptions (rx) : org = 0x80000000, len = 0x400
ram (rwx) : org = 0x80000400, len = 1M - 0x400
framebuffer (rw) : org = 0x80100000, len = 600k
}

ENTRY(entry_handler)

__exception_stack_size = 8k;
__stack_size = 16k;
__exception_stack_size = 8k;

SECTIONS {
.text : SUBALIGN(8) {
.exceptions : {
KEEP(*(.text.exception_vector));
. = ALIGN(8);
} > exceptions

.text : {
*(.text.entry_handler)
. = ALIGN(8);
*(.text .text.* .gnu.linkonce.t.*)
. = ALIGN(8);
} > ram

.assets : {
*(.assets .assets.*)
*(.rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(8);
} > ram

.rodata : {
*(.rdata .rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(8);
} > ram

.data : {
*(.data .data.* .gnu.linkonce.d.*)
. = ALIGN(8);
} > ram

.sdata : {
_gp = . + 0x8000;
*(.sdata .sdata.* .gnu.linkonce.s.*)
*(.lit8 .lit4)
. = ALIGN(8);
} > ram

.bss : {
.lit8 : {
*(.lit8)
. = ALIGN(8);
} > ram

.lit4 : {
*(.lit4)
. = ALIGN(8);
} > ram

.sbss : {
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon .scommon.*)
. = ALIGN(8);
} > ram

.bss : {
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(64);
*(.framebuffer)
. = ALIGN(8);
} > ram

_sheap = .;
. = ORIGIN(ram) + LENGTH(ram) - __exception_stack_size - __stack_size;
. = ORIGIN(ram) + LENGTH(ram) - __stack_size - __exception_stack_size;
_eheap = .;

. += __stack_size;
_sp = .;

. += __exception_stack_size;
_esp = .;

. += __stack_size;
_sp = .;
.framebuffer (NOLOAD) : SUBALIGN(64) {
*(.framebuffer .framebuffer.*)
} > framebuffer

/DISCARD/ : {
*(.MIPS.*)
Expand Down
1 change: 1 addition & 0 deletions sw/bootloader/assets/assets.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.section .assets.@sym@, "a", %progbits
.balign 8
.type assets_@sym@, %object
.global assets_@sym@
assets_@sym@:
Expand Down
43 changes: 19 additions & 24 deletions sw/cic/cic.ld
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
OUTPUT_ARCH("riscv")
OUTPUT_FORMAT("elf32-littleriscv")

MEMORY {
ram (rwx) : org = 0x80000000, len = 2k
}
Expand All @@ -10,42 +7,40 @@ ENTRY(entry_handler)
SECTIONS {
.text : {
*(.text.entry_handler)
. = ALIGN(4);
*(.text .text.* .gnu.linkonce.t.*)
. = ALIGN(4);
*(.rodata .rodata.* .gnu.linkonce.r.*)
*(.rodata1)
} > ram

.rodata : {
*(.rdata .rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(4);
} > ram : text
} > ram

.data : {
. = ALIGN(4);
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
*(.data1)
*(.data .data.* .gnu.linkonce.d.*)
. = ALIGN(4);
} > ram : data
} > ram

.bss : {
.sdata : {
_gp = . + 0x800;
*(.sdata .sdata.* .gnu.linkonce.s.*)
. = ALIGN(4);
} > ram

.sbss : {
_sbss = .;
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
*(.tbss .tbss.* .gnu.linkonce.tb.*)
*(.tcommon)
*(.scommon)
*(.dynbss)
*(.scommon .scommon.*)
. = ALIGN(4);
} > ram

.bss : {
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
} > ram : bss
} > ram

_sp = ORIGIN(ram) + LENGTH(ram);
}

PHDRS {
text PT_LOAD FLAGS(5);
data PT_LOAD FLAGS(6);
bss PT_LOAD FLAGS(6);
}
1 change: 1 addition & 0 deletions sw/cic/startup.S
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ init_stack_pointer:
.option push
.option norelax
la sp, _sp
la gp, _gp
.option pop

init_bss:
Expand Down

0 comments on commit bd70402

Please sign in to comment.