mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-21 21:49:15 +01:00
[SC64][SW] Bootloader fixes
This commit is contained in:
parent
40a4b3e222
commit
65baa521b4
12
build.sh
12
build.sh
@ -30,12 +30,12 @@ build_bootloader () {
|
||||
if [ "$FORCE_CLEAN" = true ]; then
|
||||
make clean
|
||||
fi
|
||||
FLAGS="$USER_FLAGS"
|
||||
if [ ! -z "${GIT_BRANCH+x}" ]; then FLAGS+=" -DGIT_BRANCH='\"$GIT_BRANCH\"'"; fi
|
||||
if [ ! -z "${GIT_TAG+x}" ]; then FLAGS+=" -DGIT_TAG='\"$GIT_TAG\"'"; fi
|
||||
if [ ! -z "${GIT_SHA+x}" ]; then FLAGS+=" -DGIT_SHA='\"$GIT_SHA\"'"; fi
|
||||
if [ ! -z "${GIT_MESSAGE+x}" ]; then FLAGS+=" -DGIT_MESSAGE='\"$GIT_MESSAGE\"'"; fi
|
||||
make all -j USER_FLAGS="$FLAGS"
|
||||
VERSION=""
|
||||
if [ ! -z "${GIT_BRANCH+x}" ]; then VERSION+=" -DGIT_BRANCH='\"$GIT_BRANCH\"'"; fi
|
||||
if [ ! -z "${GIT_TAG+x}" ]; then VERSION+=" -DGIT_TAG='\"$GIT_TAG\"'"; fi
|
||||
if [ ! -z "${GIT_SHA+x}" ]; then VERSION+=" -DGIT_SHA='\"$GIT_SHA\"'"; fi
|
||||
if [ ! -z "${GIT_MESSAGE+x}" ]; then VERSION+=" -DGIT_MESSAGE='\"$GIT_MESSAGE\"'"; fi
|
||||
make all -j VERSION="$VERSION" USER_FLAGS="$USER_FLAGS"
|
||||
popd > /dev/null
|
||||
|
||||
BUILT_BOOTLOADER=true
|
||||
|
@ -10,6 +10,7 @@ FLAGS = -march=vr4300 -mtune=vr4300 $(USER_FLAGS)
|
||||
CFLAGS = -Os -Wall -ffunction-sections -fdata-sections -ffreestanding -MMD -MP
|
||||
ASFLAGS = -Wa,-I$(N64_INST)/mips64-elf/lib
|
||||
LDFLAGS = -lc -nostartfiles -Wl,--gc-sections
|
||||
VERSION ?=
|
||||
|
||||
SRC_DIR = src
|
||||
ASSET_DIR = assets
|
||||
@ -57,6 +58,9 @@ $(BUILD_DIR)/%.S.o: %.S
|
||||
$(BUILD_DIR)/%.c.o: %.c
|
||||
$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/version.c.o: version.c .FORCE
|
||||
$(CC) $(FLAGS) $(CFLAGS) $(VERSION) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.asset: $(ASSET_DIR)/%.png tools/asset_converter.py
|
||||
$(PYTHON) tools/asset_converter.py $< $@ --compress
|
||||
|
||||
@ -67,13 +71,9 @@ $(BUILD_DIR)/bootloader.elf: $(OBJS) N64.ld
|
||||
$(CXX) $(FLAGS) $(LDFLAGS) -TN64.ld $(OBJS) -o $@
|
||||
@$(OBJDUMP) -S $@ > $(BUILD_DIR)/bootloader.lst
|
||||
|
||||
$(BUILD_DIR)/bootloader.bin: $(BUILD_DIR)/bootloader.elf tools/strip.py
|
||||
$(BUILD_DIR)/bootloader.bin: $(BUILD_DIR)/bootloader.elf tools/finalize.py
|
||||
@$(OBJCOPY) -O binary $< $@
|
||||
@chksum64 $@ > /dev/null
|
||||
@$(PYTHON) tools/strip.py $@ 1024
|
||||
|
||||
$(BUILD_DIR)/bootloader.hex: $(BUILD_DIR)/bootloader.bin
|
||||
@$(OBJCOPY) -I binary -O ihex $< $@
|
||||
@$(PYTHON) tools/finalize.py $@ > /dev/null
|
||||
|
||||
print_size: $(BUILD_DIR)/bootloader.elf
|
||||
@echo 'Size of modules:'
|
||||
@ -81,13 +81,11 @@ print_size: $(BUILD_DIR)/bootloader.elf
|
||||
@echo 'Size of bootloader:'
|
||||
@$(SIZE) -B -d $<
|
||||
|
||||
all: $(BUILD_DIR)/bootloader.hex print_size
|
||||
all: $(BUILD_DIR)/bootloader.bin print_size
|
||||
|
||||
clean:
|
||||
@rm -rf ./$(BUILD_DIR)/*
|
||||
|
||||
$(BUILD_DIR)/version.c.o: .FORCE
|
||||
|
||||
.FORCE:
|
||||
|
||||
.PHONY: .FORCE all clean print_size
|
||||
|
@ -45,12 +45,6 @@ SECTIONS {
|
||||
_ebss = .;
|
||||
} > ram
|
||||
|
||||
.fill : {
|
||||
FILL(0xFF);
|
||||
BYTE(0xFF);
|
||||
. = ORIGIN(rom) + LENGTH(rom);
|
||||
} > rom
|
||||
|
||||
_sheap = .;
|
||||
. = ORIGIN(ram) + LENGTH(ram) - __exception_stack_size - __stack_size;
|
||||
_eheap = .;
|
||||
|
@ -1,4 +1,5 @@
|
||||
.section .assets.@sym@
|
||||
.section .assets.@sym@, "a", %progbits
|
||||
.type assets_@sym@, %object
|
||||
.global assets_@sym@
|
||||
assets_@sym@:
|
||||
.incbin "@file@"
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define LINE_SPACING (2)
|
||||
|
||||
|
||||
static io32_t display_framebuffer[SCREEN_WIDTH * SCREEN_HEIGHT] __attribute__((section(".framebuffer")));
|
||||
static io32_t display_framebuffer[SCREEN_WIDTH * SCREEN_HEIGHT] __attribute__((section(".framebuffer, \"aw\", %nobits#")));
|
||||
static int char_x;
|
||||
static int char_y;
|
||||
static const vi_regs_t vi_config[] = {{
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define VECTOR_SIZE (0x80)
|
||||
#define VECTOR_NUM (4)
|
||||
|
||||
#define ZR_OFFSET (0)
|
||||
#define AT_OFFSET (8)
|
||||
#define V0_OFFSET (16)
|
||||
#define V1_OFFSET (24)
|
||||
@ -49,6 +50,7 @@
|
||||
exception_handler:
|
||||
.set noat
|
||||
la $k0, (_esp - SAVE_REGISTERS_SIZE)
|
||||
sd $zero, ZR_OFFSET($k0)
|
||||
sd $at, AT_OFFSET($k0)
|
||||
sd $v0, V0_OFFSET($k0)
|
||||
sd $v1, V1_OFFSET($k0)
|
||||
|
@ -2,7 +2,8 @@
|
||||
.set noreorder
|
||||
|
||||
|
||||
.section .data.ipl2
|
||||
.section .text.ipl2, "ax", %progbits
|
||||
.type ipl2, %object
|
||||
ipl2:
|
||||
.global ipl2
|
||||
lui $t5, 0xBFC0
|
||||
|
@ -6,21 +6,25 @@ static version_t version = {
|
||||
.git_branch = GIT_BRANCH,
|
||||
#else
|
||||
#warning "No GIT_BRANCH provided"
|
||||
.git_branch = "GIT_BRANCH",
|
||||
#endif
|
||||
#ifdef GIT_TAG
|
||||
.git_tag = GIT_TAG,
|
||||
#else
|
||||
#warning "No GIT_TAG provided"
|
||||
.git_tag = "GIT_TAG",
|
||||
#endif
|
||||
#ifdef GIT_SHA
|
||||
.git_sha = GIT_SHA,
|
||||
#else
|
||||
#warning "No GIT_SHA provided"
|
||||
.git_sha = "GIT_SHA",
|
||||
#endif
|
||||
#ifdef GIT_MESSAGE
|
||||
.git_message = GIT_MESSAGE,
|
||||
#else
|
||||
#warning "No GIT_MESSAGE provided"
|
||||
.git_message = "GIT_MESSAGE",
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -33,9 +33,9 @@ def compress(data: bytes, step_size: int=4) -> bytes:
|
||||
return compressed_data
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
if (len(sys.argv) < 3):
|
||||
print(f"Usage: python {sys.argv[0]} input_path output_path [--compress]")
|
||||
print(f'Usage: python {sys.argv[0]} input_path output_path [--compress]')
|
||||
sys.exit(1)
|
||||
|
||||
asset_input = sys.argv[1]
|
||||
@ -47,17 +47,22 @@ if __name__ == "__main__":
|
||||
|
||||
try:
|
||||
source_asset = Image.open(asset_input)
|
||||
converted_asset = source_asset.convert("RGBA").tobytes()
|
||||
converted_asset = source_asset.convert('RGBA').tobytes()
|
||||
|
||||
if (asset_compress):
|
||||
converted_asset = compress(converted_asset)
|
||||
final_asset = open(asset_output, "wb")
|
||||
|
||||
final_asset = open(asset_output, 'wb')
|
||||
final_asset.write(converted_asset)
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"Couldn't open file \"{asset_input}\"")
|
||||
print(f'Couldn\'t open file "{asset_input}"')
|
||||
sys.exit(2)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit(3)
|
||||
|
||||
finally:
|
||||
if (source_asset):
|
||||
source_asset.close()
|
||||
|
50
sw/bootloader/tools/finalize.py
Normal file
50
sw/bootloader/tools/finalize.py
Normal file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if (len(sys.argv) != 2):
|
||||
print(f'Usage: python {sys.argv[0]} file_path')
|
||||
sys.exit(1)
|
||||
|
||||
ALIGN = 1024
|
||||
CHECKSUM_SIZE = 0x101000
|
||||
|
||||
bin_file = sys.argv[1]
|
||||
|
||||
try:
|
||||
bin_data = b''
|
||||
|
||||
with open(bin_file, 'rb') as f:
|
||||
bin_data = f.read()
|
||||
|
||||
pad_size = CHECKSUM_SIZE - len(bin_data)
|
||||
|
||||
if (pad_size > 0):
|
||||
bin_data += b'\xFF' * pad_size
|
||||
with open(bin_file, 'wb') as f:
|
||||
f.write(bin_data)
|
||||
|
||||
subprocess.run(['chksum64', bin_file])
|
||||
|
||||
with open(bin_file, 'rb') as f:
|
||||
bin_data = f.read()
|
||||
|
||||
bin_data = bin_data.strip(b'\xFF')
|
||||
modulo = len(bin_data) % ALIGN
|
||||
if (modulo > 0):
|
||||
bin_data += b'\xFF' * (ALIGN - modulo)
|
||||
|
||||
with open(bin_file, 'wb') as f:
|
||||
f.write(bin_data)
|
||||
|
||||
except FileNotFoundError as e:
|
||||
print(f'Couldn\'t open file "{bin_file}" {e}')
|
||||
sys.exit(2)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit(3)
|
@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if (len(sys.argv) != 3):
|
||||
print(f"Usage: python {sys.argv[0]} file_path align")
|
||||
sys.exit(1)
|
||||
|
||||
file = sys.argv[1]
|
||||
align = int(sys.argv[2], base=0)
|
||||
|
||||
try:
|
||||
data = b''
|
||||
with open(file, 'rb') as f:
|
||||
data = f.read().strip(b'\xFF')
|
||||
with open(file, 'wb') as f:
|
||||
modulo = (len(data) % align) if (align > 0) else 0
|
||||
data += b'\xFF' * ((align - modulo) if (modulo != 0) else 0)
|
||||
f.write(data)
|
||||
except FileNotFoundError:
|
||||
print(f"Couldn't open file \"{file}\"")
|
||||
sys.exit(2)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit(3)
|
Loading…
Reference in New Issue
Block a user