mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-25 03:56:54 +01:00
Updated libdragon (now incorporating open source IPL3)
This commit is contained in:
parent
8e50e4c1e1
commit
cceb37e694
10
Makefile
10
Makefile
@ -96,23 +96,19 @@ $(@info $(shell mkdir -p ./$(OUTPUT_DIR) &> /dev/null))
|
||||
$(OUTPUT_DIR)/$(PROJECT_NAME).n64: $(PROJECT_NAME).z64
|
||||
@mv $< $@
|
||||
|
||||
$(BUILD_DIR)/$(PROJECT_NAME)_stripped.n64: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
|
||||
python3 ./tools/strip_debug_data.py $(BUILD_DIR)/$(PROJECT_NAME).elf $< $@
|
||||
@$(N64_CHKSUM) $@ > /dev/null
|
||||
|
||||
64drive: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
|
||||
@cp $< $(OUTPUT_DIR)/menu.bin
|
||||
.PHONY: 64drive
|
||||
|
||||
ed64: $(BUILD_DIR)/$(PROJECT_NAME)_stripped.n64
|
||||
ed64: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
|
||||
@cp $< $(OUTPUT_DIR)/OS64.v64
|
||||
.PHONY: ed64
|
||||
|
||||
ed64-clone: $(BUILD_DIR)/$(PROJECT_NAME)_stripped.n64
|
||||
ed64-clone: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
|
||||
@cp $< $(OUTPUT_DIR)/OS64P.v64
|
||||
.PHONY: ed64-clone
|
||||
|
||||
sc64: $(BUILD_DIR)/$(PROJECT_NAME)_stripped.n64
|
||||
sc64: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
|
||||
@cp $< $(OUTPUT_DIR)/sc64menu.n64
|
||||
.PHONY: sc64
|
||||
|
||||
|
@ -67,6 +67,7 @@ static uint64_t cic_calculate_ipl3_checksum (uint8_t *ipl3, uint8_t seed) {
|
||||
}
|
||||
|
||||
next = _get(ipl3, i);
|
||||
|
||||
buf[10] = _sum(_add(buf[10], data), next, i);
|
||||
buf[11] = _sum(buf[11] ^ data, next, i);
|
||||
buf[12] = _add(buf[12], buf[8] ^ data);
|
||||
|
@ -1,58 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
|
||||
def get_symbol_address(elf, symbol):
|
||||
p1 = Popen(f'readelf -s --wide {elf}'.split(), stdout=PIPE)
|
||||
p2 = Popen(f'grep -m 1 {symbol}'.split(), stdin=p1.stdout, stdout=PIPE)
|
||||
stdout, _ = p2.communicate()
|
||||
|
||||
symbol_data = stdout.decode('UTF-8').split()
|
||||
address = symbol_data[1]
|
||||
name = symbol_data[7]
|
||||
|
||||
if (symbol != name):
|
||||
raise Exception(f'Inexact symbol name found [{symbol} != {name}]')
|
||||
|
||||
return int(address, 16)
|
||||
|
||||
|
||||
def get_rom_data_end_offset(elf):
|
||||
ROM_ENTRY_OFFSET = 0x1000
|
||||
|
||||
libdragon_text_start = get_symbol_address(elf, '__libdragon_text_start')
|
||||
rom_end = get_symbol_address(elf, '__rom_end')
|
||||
|
||||
return ROM_ENTRY_OFFSET + (rom_end - libdragon_text_start)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if (len(sys.argv) != 4):
|
||||
print(f'Usage: python {sys.argv[0]} elf input output')
|
||||
sys.exit(1)
|
||||
|
||||
elf_file = sys.argv[1]
|
||||
input_file = sys.argv[2]
|
||||
output_file = sys.argv[3]
|
||||
|
||||
ALIGN = 512
|
||||
|
||||
try:
|
||||
length = get_rom_data_end_offset(elf_file)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit(2)
|
||||
|
||||
stripped_data = b''
|
||||
with open(input_file, 'rb') as f:
|
||||
stripped_data = f.read(length)
|
||||
|
||||
modulo = (length % ALIGN)
|
||||
if (modulo > 0):
|
||||
stripped_data += b'\x00' * (ALIGN - modulo)
|
||||
|
||||
with open(output_file, 'wb') as f:
|
||||
f.write(stripped_data)
|
Loading…
Reference in New Issue
Block a user