-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split GM9 across two sections in memory. #837
Conversation
This is needed to implement support for Lua. Lua is way to big to fit in a single contigious section of memory without overwriting our copy of boot9 and boot11, so some clever linker manipulation was used to place things in the free space after it. This uses the following memory map: ``` AHBWRAM: 0x08000000 - 0x08080000 .vectors .text .ARM.exidx AHBWRAM2: 0x080a0000 - 0x08100000 .text (files in arm9/source/lua) .rodata .data .bss ```
Makefile
Outdated
$(OUTDIR)/AHBWRAM.bin: $(ELF) | ||
@$(OBJCOPY) -O binary arm9/arm9.elf --only-section=AHBWRAM $@ | ||
|
||
$(OUTDIR)/AHBWRAM2.bin: $(ELF) | ||
@$(OBJCOPY) -O binary arm9/arm9.elf --only-section=AHBWRAM2 $@ | ||
|
||
BINS := $(OUTDIR)/AHBWRAM.bin $(OUTDIR)/AHBWRAM2.bin | ||
|
||
firm: $(ELF) $(BINS) | ||
@mkdir -p $(call dirname,"$(FIRM)") $(call dirname,"$(FIRMD)") | ||
@echo "[FLAVOR] $(FLAVOR)" | ||
@echo "[VERSION] $(VERSION)" | ||
@echo "[BUILD] $(DBUILTL)" | ||
@echo "[FIRM] $(FIRM)" | ||
@$(PY3) -m firmtool build $(FIRM) $(FTFLAGS) -g -D $(ELF) -C NDMA XDMA | ||
@$(PY3) -m firmtool build $(FIRM) $(FTFLAGS) -g -D $(BINS) arm11/arm11.elf \ | ||
-A 0x08000000 0x080a0000 -C NDMA NDMA XDMA -n 0x08000040 | ||
@echo "[FIRM] $(FIRMD)" | ||
@$(PY3) -m firmtool build $(FIRMD) $(FTDFLAGS) -g -D $(ELF) -C NDMA XDMA | ||
@$(PY3) -m firmtool build $(FIRMD) $(FTDFLAGS) -g -D $(BINS) arm11/arm11.elf \ | ||
-A 0x08000000 0x080a0000 -C NDMA NDMA XDMA -n 0x08000040 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, is there way you'd like for this to actually be done?
Hardcoding the the entry-point here also seems quite fragile but I doubt that will suddenly break us unless for some reason we move move _start
or increase the size of .vectors
.
$(OUTDIR)/AHBWRAM_LO.elf: $(ELF) | ||
@$(OBJCOPY) arm9/arm9.elf -j AHBWRAM_LO $@ | ||
|
||
$(OUTDIR)/AHBWRAM_HI.elf: $(ELF) | ||
@$(OBJCOPY) arm9/arm9.elf -j AHBWRAM_HI $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objcopy
is now throwing a warning and it does not provide any option to silence it.
Since this doesn't break the build, do you have any suggestions on how I can silence its output, or if we can even do so?
Trying some stuff with this PR and I think a few features aren't working properly. Specifically I tried building a CIA for a built-in title (Activity Log USA 0004001000021200), and it froze. Building the latest commit of the main repo (ad8b5e0) and it works fine. Is there a chance something else is using arm9 memory? Or is something just weird with my setup? I don't know what else could have broken. |
I'd consider opening a separate issue for that. This reeks of UB. |
turns out the freeze here was actually the exception handler being broken due to a typo in the linker script. this has been fixed |
Wolfvak has offered a much better solution than what is present here. Closing this. |
This is needed to implement support for Lua. Lua is way to big to fit in a single contiguous section of memory without overwriting our copy of boot9 and boot11, so some clever linker manipulation was used to place things in the free space after it. LTO also had to be disabled as we won't be able to split
.text
later with it.This uses the following memory map:
This has been tested on actual hardware and seems to boot up and work fine.