diff --git a/examples/rules.mk b/examples/rules.mk index 6314380ec..55e39f4ed 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -182,10 +182,12 @@ flash-jlink: $(BUILD)/$(PROJECT).hex flash-stlink: $(BUILD)/$(PROJECT).elf STM32_Programmer_CLI --connect port=swd --write $< --go -flash-xfel: $(BUILD)/$(PROJECT).bin - xfel ddr - xfel write 0x80000000 $< - xfel exec 0x80000000 +$(BUILD)/$(PROJECT)-sunxi.bin: $(BUILD)/$(PROJECT).bin + $(PYTHON) $(TOP)/tools/mksunxi.py $< $@ + +flash-xfel: $(BUILD)/$(PROJECT)-sunxi.bin + xfel spinor write 0 $< + xfel reset # Flash using pyocd PYOCD_OPTION ?= diff --git a/hw/bsp/f1c100s/board.mk b/hw/bsp/f1c100s/board.mk index 993aa0d24..9bd9380a7 100644 --- a/hw/bsp/f1c100s/board.mk +++ b/hw/bsp/f1c100s/board.mk @@ -41,5 +41,10 @@ INC += \ $(TOP)/$(MCU_DIR)/include \ $(TOP)/$(BOARD_PATH) -# flash target using on-board stlink +# flash target using xfel flash: flash-xfel + +exec: $(BUILD)/$(PROJECT).bin + xfel ddr + xfel write 0x80000000 $< + xfel exec 0x80000000 \ No newline at end of file diff --git a/hw/mcu/allwinner/f1c100s/f1c100s.ld b/hw/mcu/allwinner/f1c100s/f1c100s.ld index a261618e5..43c353bbd 100644 --- a/hw/mcu/allwinner/f1c100s/f1c100s.ld +++ b/hw/mcu/allwinner/f1c100s/f1c100s.ld @@ -21,15 +21,15 @@ SECTIONS PROVIDE(__bootloader_start = .); PROVIDE(__image_start = .); PROVIDE(__text_start = .); - */machine/start.o (.text) - */lib/memcpy.o (.text) - */lib/memset.o (.text) - */machine/sys-uart.o (.text) - */machine/sys-clock.o (.text) - */machine/sys-dram.o (.text) - */machine/sys-mmu.o (.text) - */machine/sys-spi-flash.o (.text) - */machine/sys-copyself.o (.text) + _build/*/obj/hw/mcu/allwinner/*/machine/start_asm.o (.text) + _build/*/obj/hw/mcu/allwinner/*/lib/memcpy_asm.o (.text) + _build/*/obj/hw/mcu/allwinner/*/lib/memset_asm.o (.text) + _build/*/obj/hw/mcu/allwinner/*/machine/sys-uart.o (.text*) + _build/*/obj/hw/mcu/allwinner/*/machine/sys-clock.o (.text*) + _build/*/obj/hw/mcu/allwinner/*/machine/sys-dram.o (.text*) + _build/*/obj/hw/mcu/allwinner/*/machine/sys-mmu.o (.text*) + _build/*/obj/hw/mcu/allwinner/*/machine/sys-spi-flash.o (.text*) + _build/*/obj/hw/mcu/allwinner/*/machine/sys-copyself.o (.text*) PROVIDE(__bootloader_end = .); } > ram @@ -37,7 +37,6 @@ SECTIONS .text : { - */main.o (.text) *(.text*) *(.glue*) *(.note.gnu.build-id) diff --git a/tools/mksunxi.py b/tools/mksunxi.py new file mode 100644 index 000000000..04786f429 --- /dev/null +++ b/tools/mksunxi.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +import sys +import struct + +def align(num, alignment): + if num % alignment != 0: + num += (alignment - num % alignment) + return num + + +def process_file(input, output): + with open(input, 'rb') as fin: + content = bytearray(fin.read()) + + align_value = 512 + padded_length = align(len(content), align_value) + # pad file to actual length + content += b'\x00' * (padded_length - len(content)) + + struct_format = '