Skip to content

Commit 87e1145

Browse files
authored
Allow booting in DSi direct mode without BIOS/firmware/NAND dumps. (#2523)
* Allow booting in DSi direct mode without BIOS/firmware/NAND dumps. This is an initial patch which enables booting programs in DSi direct mode without requiring BIOS/firmware/NAND dumps from increasingly expensive consoles: - The open DSi BIOS is derived from a modified build of FreeBIOS; minor patches have been done (such as moving SWI 0x12 to 0x02), but no new SWI functions have been implemented. - The DSi firmware stub is generated in the same way as the NDS firmware stub; this appears to be good enough for BlocksDS's dswifi to pick up the new AP definitions. - The DSi NAND is currently not stubbed at all; rather, the code has been edited to allow bringup without a NAND image. This is sufficient for DSi mode homebrew; programs running from the cartridge slot are likewise not expected to require NAND access. More work has to be done before it's useful for non-homebrew scenarios. * Implement a less stub DSi::NeedsDirectBoot() * Do not block direct boots if DSi NAND is missing but BIOS/firmware is present * Correctly initialize extended header for DSi generated firmware * Fix overriding firmware language in DSi mode, add experimental support for Chinese language option
1 parent 72aa2bd commit 87e1145

28 files changed

Lines changed: 1837 additions & 1951 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ compile_commands.json
2121
.vscode
2222
CMakeFiles
2323
CMakeCache.txt
24+
25+
freebios/FreeBIOS_Data.h
26+
freebios/bios*
27+
freebios/build/

freebios/Makefile

100755100644
Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
1-
TC_PREFIX = /home/exophase/pandora-dev
2-
PREFIX = $(TC_PREFIX)/arm-2011.03
3-
AS = $(PREFIX)/bin/arm-none-linux-gnueabi-gcc
4-
OBJCOPY = $(PREFIX)/bin/arm-none-linux-gnueabi-objcopy
1+
# SPDX-License-Identifier: CC0-1.0
2+
#
3+
# SPDX-FileContributor: Adrian "asie" Siekierka, 2025
54

6-
BIN_ARM7 = drastic_bios_arm7
7-
BIN_ARM9 = drastic_bios_arm9
5+
BIOS_FILE_NTR_ARM9 = bios_ntr_arm9.bin
6+
BIOS_FILE_NTR_ARM7 = bios_ntr_arm7.bin
7+
BIOS_FILE_TWL_ARM9 = bios_twl_arm9.bin
8+
BIOS_FILE_TWL_ARM7 = bios_twl_arm7.bin
89

9-
all:
10-
$(AS) bios_common.S -DBIOS_ARM7 -march=armv4 -c -Wa,-asl=$(BIN_ARM7).list -o $(BIN_ARM7).o
11-
$(AS) bios_common.S -DBIOS_ARM9 -march=armv5 -c -Wa,-asl=$(BIN_ARM9).list -o $(BIN_ARM9).o
12-
$(OBJCOPY) -O binary $(BIN_ARM7).o $(BIN_ARM7).bin
13-
$(OBJCOPY) -O binary $(BIN_ARM9).o $(BIN_ARM9).bin
10+
BIOS_FILES = \
11+
$(BIOS_FILE_NTR_ARM9) \
12+
$(BIOS_FILE_NTR_ARM7) \
13+
$(BIOS_FILE_TWL_ARM9) \
14+
$(BIOS_FILE_TWL_ARM7)
1415

15-
clean:
16-
rm -f $(BIN_ARM7).bin $(BIN_ARM7).o $(BIN_ARM9).bin $(BIN_ARM9).o
16+
BIOS_HEADERS = \
17+
$(patsubst %.bin,%.h,$(BIOS_FILES))
18+
19+
BIOS_HEADER_ALL = FreeBIOS_Data.h
20+
21+
.PHONY: all clean $(BIOS_FILES) $(BIOS_HEADER_ALL)
22+
23+
all: $(BIOS_FILES) $(BIOS_HEADER_ALL)
24+
25+
$(BIOS_HEADER_ALL): $(BIOS_FILES)
26+
cat $(BIOS_HEADERS) > $(BIOS_HEADER_ALL)
1727

28+
$(BIOS_FILE_NTR_ARM9):
29+
$(MAKE) -f Makefile.bios TARGET=arm9 PLATFORM=ntr OUTPUT=$(BIOS_FILE_NTR_ARM9)
30+
31+
$(BIOS_FILE_NTR_ARM7):
32+
$(MAKE) -f Makefile.bios TARGET=arm7 PLATFORM=ntr OUTPUT=$(BIOS_FILE_NTR_ARM7)
33+
34+
$(BIOS_FILE_TWL_ARM9):
35+
$(MAKE) -f Makefile.bios TARGET=arm9 PLATFORM=twl OUTPUT=$(BIOS_FILE_TWL_ARM9)
36+
37+
$(BIOS_FILE_TWL_ARM7):
38+
$(MAKE) -f Makefile.bios TARGET=arm7 PLATFORM=twl OUTPUT=$(BIOS_FILE_TWL_ARM7)
39+
40+
clean:
41+
rm -fr build || true
42+
rm -r $(BIOS_FILES) || true
43+
rm -r $(BIOS_HEADERS) || true
44+
rm -r $(BIOS_HEADER_ALL) || true

freebios/Makefile.bios

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# SPDX-License-Identifier: CC0-1.0
2+
#
3+
# SPDX-FileContributor: Antonio Niño Díaz, 2023
4+
# SPDX-FileContributor: Adrian "asie" Siekierka, 2025
5+
6+
SOURCEDIRS := src src/$(TARGET)
7+
8+
DEFINES := \
9+
-DPLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z) \
10+
-DTARGET_$(shell echo $(TARGET) | tr a-z A-Z)
11+
12+
HEADER_OUTPUT := $(patsubst %.bin,%.h,$(OUTPUT))
13+
NAME := bios_$(PLATFORM)_$(TARGET)
14+
BUILDDIR := build/$(NAME)
15+
ELF := build/$(NAME).elf
16+
DUMP := build/$(NAME).dump
17+
MAP := build/$(NAME).map
18+
19+
# Tools
20+
# -----
21+
22+
PREFIX := arm-none-eabi-
23+
CC := $(PREFIX)gcc
24+
LD := $(PREFIX)gcc
25+
OBJCOPY := $(PREFIX)objcopy
26+
OBJDUMP := $(PREFIX)objdump
27+
28+
# Verbose flag
29+
# ------------
30+
31+
ifeq ($(VERBOSE),1)
32+
V :=
33+
else
34+
V := @
35+
endif
36+
37+
# Source files
38+
# ------------
39+
40+
SOURCES_S := $(shell find -L $(SOURCEDIRS) -maxdepth 1 -name "*.s")
41+
SOURCES_C := $(shell find -L $(SOURCEDIRS) -maxdepth 1 -name "*.c")
42+
43+
# Compiler and linker flags
44+
# -------------------------
45+
46+
ifeq ($(TARGET),arm9)
47+
ARCH := -mthumb -mcpu=arm946e-s+nofp -Wl,--use-blx
48+
else
49+
ARCH := -mthumb -mcpu=arm7tdmi
50+
endif
51+
52+
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path))
53+
54+
ASFLAGS := -x assembler-with-cpp $(DEFINES) $(INCLUDEFLAGS) \
55+
$(ARCH) -ffunction-sections -fdata-sections
56+
57+
CFLAGS := $(WARNFLAGS) $(DEFINES) $(INCLUDEFLAGS) \
58+
$(ARCH) -ffunction-sections -fdata-sections -Os
59+
60+
LDFLAGS := $(ARCH) -Wl,-Map,$(MAP) $(DEFINES) -nostdlib \
61+
-Wl,--gc-sections -Wl,--no-warn-rwx-segments
62+
63+
LDFLAGS += -Wl,-Ttext 0x00000000 -Wl,-e 0x00000000
64+
65+
# Intermediate build files
66+
# ------------------------
67+
68+
OBJS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
69+
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C)))
70+
71+
DEPS := $(OBJS:.o=.d)
72+
73+
# Targets
74+
# -------
75+
76+
.PHONY: all dump
77+
78+
all: $(OUTPUT) $(HEADER_OUTPUT)
79+
80+
$(HEADER_OUTPUT): $(OUTPUT)
81+
@echo " XXD $@"
82+
$(V)xxd -i -n $(patsubst %.bin,%,$(OUTPUT)) -c 16 $(OUTPUT) $(HEADER_OUTPUT)
83+
84+
$(OUTPUT): $(ELF)
85+
@echo " OBJCOPY $@"
86+
$(V)$(OBJCOPY) -O binary $< $@
87+
88+
$(ELF): $(OBJS)
89+
@echo " LD $@"
90+
$(V)$(LD) -o $@ $(OBJS) $(LDFLAGS)
91+
92+
$(DUMP): $(ELF)
93+
@echo " OBJDUMP $@"
94+
$(V)$(OBJDUMP) -h -C -S $< > $@
95+
96+
dump: $(DUMP)
97+
98+
# Rules
99+
# -----
100+
101+
$(BUILDDIR)/%.s.o : %.s
102+
@echo " AS $<"
103+
@mkdir -p $(@D)
104+
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
105+
106+
$(BUILDDIR)/%.c.o : %.c
107+
@echo " CC $<"
108+
@mkdir -p $(@D)
109+
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
110+
111+
$(BUILDDIR)/%.arm.c.o : %.arm.c
112+
@echo " CC $<"
113+
@mkdir -p $(@D)
114+
$(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $<
115+
116+
# Include dependency files if they exist
117+
# --------------------------------------
118+
119+
-include $(DEPS)

freebios/drastic_bios_arm7.bin

-16 KB
Binary file not shown.

freebios/drastic_bios_arm9.bin

-4 KB
Binary file not shown.

freebios/drastic_bios_readme.txt

100755100644
File mode changed.

0 commit comments

Comments
 (0)