Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ compile_commands.json
.vscode
CMakeFiles
CMakeCache.txt

freebios/FreeBIOS_Data.h
freebios/bios*
freebios/build/
53 changes: 40 additions & 13 deletions freebios/Makefile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
TC_PREFIX = /home/exophase/pandora-dev
PREFIX = $(TC_PREFIX)/arm-2011.03
AS = $(PREFIX)/bin/arm-none-linux-gnueabi-gcc
OBJCOPY = $(PREFIX)/bin/arm-none-linux-gnueabi-objcopy
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Adrian "asie" Siekierka, 2025

BIN_ARM7 = drastic_bios_arm7
BIN_ARM9 = drastic_bios_arm9
BIOS_FILE_NTR_ARM9 = bios_ntr_arm9.bin
BIOS_FILE_NTR_ARM7 = bios_ntr_arm7.bin
BIOS_FILE_TWL_ARM9 = bios_twl_arm9.bin
BIOS_FILE_TWL_ARM7 = bios_twl_arm7.bin

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

clean:
rm -f $(BIN_ARM7).bin $(BIN_ARM7).o $(BIN_ARM9).bin $(BIN_ARM9).o
BIOS_HEADERS = \
$(patsubst %.bin,%.h,$(BIOS_FILES))

BIOS_HEADER_ALL = FreeBIOS_Data.h

.PHONY: all clean $(BIOS_FILES) $(BIOS_HEADER_ALL)

all: $(BIOS_FILES) $(BIOS_HEADER_ALL)

$(BIOS_HEADER_ALL): $(BIOS_FILES)
cat $(BIOS_HEADERS) > $(BIOS_HEADER_ALL)

$(BIOS_FILE_NTR_ARM9):
$(MAKE) -f Makefile.bios TARGET=arm9 PLATFORM=ntr OUTPUT=$(BIOS_FILE_NTR_ARM9)

$(BIOS_FILE_NTR_ARM7):
$(MAKE) -f Makefile.bios TARGET=arm7 PLATFORM=ntr OUTPUT=$(BIOS_FILE_NTR_ARM7)

$(BIOS_FILE_TWL_ARM9):
$(MAKE) -f Makefile.bios TARGET=arm9 PLATFORM=twl OUTPUT=$(BIOS_FILE_TWL_ARM9)

$(BIOS_FILE_TWL_ARM7):
$(MAKE) -f Makefile.bios TARGET=arm7 PLATFORM=twl OUTPUT=$(BIOS_FILE_TWL_ARM7)

clean:
rm -fr build || true
rm -r $(BIOS_FILES) || true
rm -r $(BIOS_HEADERS) || true
rm -r $(BIOS_HEADER_ALL) || true
119 changes: 119 additions & 0 deletions freebios/Makefile.bios
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Antonio Niño Díaz, 2023
# SPDX-FileContributor: Adrian "asie" Siekierka, 2025

SOURCEDIRS := src src/$(TARGET)

DEFINES := \
-DPLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z) \
-DTARGET_$(shell echo $(TARGET) | tr a-z A-Z)

HEADER_OUTPUT := $(patsubst %.bin,%.h,$(OUTPUT))
NAME := bios_$(PLATFORM)_$(TARGET)
BUILDDIR := build/$(NAME)
ELF := build/$(NAME).elf
DUMP := build/$(NAME).dump
MAP := build/$(NAME).map

# Tools
# -----

PREFIX := arm-none-eabi-
CC := $(PREFIX)gcc
LD := $(PREFIX)gcc
OBJCOPY := $(PREFIX)objcopy
OBJDUMP := $(PREFIX)objdump

# Verbose flag
# ------------

ifeq ($(VERBOSE),1)
V :=
else
V := @
endif

# Source files
# ------------

SOURCES_S := $(shell find -L $(SOURCEDIRS) -maxdepth 1 -name "*.s")
SOURCES_C := $(shell find -L $(SOURCEDIRS) -maxdepth 1 -name "*.c")

# Compiler and linker flags
# -------------------------

ifeq ($(TARGET),arm9)
ARCH := -mthumb -mcpu=arm946e-s+nofp -Wl,--use-blx
else
ARCH := -mthumb -mcpu=arm7tdmi
endif

INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path))

ASFLAGS := -x assembler-with-cpp $(DEFINES) $(INCLUDEFLAGS) \
$(ARCH) -ffunction-sections -fdata-sections

CFLAGS := $(WARNFLAGS) $(DEFINES) $(INCLUDEFLAGS) \
$(ARCH) -ffunction-sections -fdata-sections -Os

LDFLAGS := $(ARCH) -Wl,-Map,$(MAP) $(DEFINES) -nostdlib \
-Wl,--gc-sections -Wl,--no-warn-rwx-segments

LDFLAGS += -Wl,-Ttext 0x00000000 -Wl,-e 0x00000000

# Intermediate build files
# ------------------------

OBJS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C)))

DEPS := $(OBJS:.o=.d)

# Targets
# -------

.PHONY: all dump

all: $(OUTPUT) $(HEADER_OUTPUT)

$(HEADER_OUTPUT): $(OUTPUT)
@echo " XXD $@"
$(V)xxd -i -n $(patsubst %.bin,%,$(OUTPUT)) -c 16 $(OUTPUT) $(HEADER_OUTPUT)

$(OUTPUT): $(ELF)
@echo " OBJCOPY $@"
$(V)$(OBJCOPY) -O binary $< $@

$(ELF): $(OBJS)
@echo " LD $@"
$(V)$(LD) -o $@ $(OBJS) $(LDFLAGS)

$(DUMP): $(ELF)
@echo " OBJDUMP $@"
$(V)$(OBJDUMP) -h -C -S $< > $@

dump: $(DUMP)

# Rules
# -----

$(BUILDDIR)/%.s.o : %.s
@echo " AS $<"
@mkdir -p $(@D)
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<

$(BUILDDIR)/%.c.o : %.c
@echo " CC $<"
@mkdir -p $(@D)
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<

$(BUILDDIR)/%.arm.c.o : %.arm.c
@echo " CC $<"
@mkdir -p $(@D)
$(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $<

# Include dependency files if they exist
# --------------------------------------

-include $(DEPS)
Binary file removed freebios/drastic_bios_arm7.bin
Binary file not shown.
Binary file removed freebios/drastic_bios_arm9.bin
Binary file not shown.
Empty file modified freebios/drastic_bios_readme.txt
100755 → 100644
Empty file.
Loading
Loading