common: misc fixes:

- moved external files to lib folder
 - fixed typos
 - added optional "sudo" to flash command
 - fixed redundant file close in script
 - fixed compilation warning
This commit is contained in:
sh83 2022-10-30 21:51:44 +03:00 committed by Eric Callahan
parent 0a24cd4502
commit 2990480d25
7 changed files with 6 additions and 8 deletions

View File

@ -80,7 +80,7 @@ $(OUT)canboot.elf: $(OBJS_canboot.elf)
$(Q)scripts/check-gcc.sh $@ $(OUT)compile_time_request.o
$(OUT)canboot.bin: $(OUT)canboot.elf ./scripts/buildbinary.py
@echo " Creating hex file $@"
@echo " Creating bin file $@"
$(Q)$(OBJCOPY) -O binary $< $(OUT)canboot.work
$(Q)$(PYTHON) ./scripts/buildbinary.py -b $(CONFIG_FLASH_START) -s $(CONFIG_APPLICATION_START) $(BUILDBINARY_FLAGS) $(OUT)canboot.work -c $(OUT)canboot_payload.c $@

View File

@ -174,7 +174,7 @@ int main(int argc, char *argv[]) {
rc = 1;
goto do_exit;
}
fprintf(stderr, "Loaded UF2 image with %lu pages\n", image->num_blocks);
fprintf(stderr, "Loaded UF2 image with %zu pages\n", image->num_blocks);
bool has_target = false;
uint8_t target_bus = 0;

View File

@ -12,7 +12,6 @@ def renumerate(content):
result.extend(block[ : 20])
result.extend(struct.pack("<II", current, total))
result.extend(block[ 28 : ])
# print("address " + hex(int.from_bytes(block[12:16], "little")))
return result
def add_signature(content, address):
@ -42,7 +41,6 @@ def main():
content = renumerate(content)
with open(args.output, 'wb') as f:
f.write(content)
f.close()
if __name__ == '__main__':
main()

View File

@ -3,16 +3,16 @@
# Setup the toolchain
CROSS_PREFIX=arm-none-eabi-
dirs-y += src/rp2040 src/generic lib/rp2040/elf2uf2 lib/fast-hash lib/can2040
dirs-y += src/rp2040 src/generic lib/rp2040/elf2uf2 lib/fast-hash lib/can2040 lib/rp2040/pico/flash/
CFLAGS += -mcpu=cortex-m0plus -mthumb -Ilib/cmsis-core
CFLAGS += -Ilib/rp2040 -Ilib/rp2040/cmsis_include -Ilib/fast-hash -Ilib/can2040
CFLAGS += -Ilib/rp2040 -Ilib/rp2040/cmsis_include -Ilib/fast-hash -Ilib/can2040 -Ilib/rp2040/pico/flash/ -Ilib/rp2040/pico/bootrom/
CFLAGS_canboot.elf += --specs=nano.specs --specs=nosys.specs
CFLAGS_canboot.elf += -T $(OUT)src/rp2040/rp2040_link.ld
# Add source files
mcu-y = rp2040/main.c rp2040/gpio.c rp2040/timer.c rp2040/flash.c rp2040/hw_flash.c
mcu-y = rp2040/main.c rp2040/gpio.c rp2040/timer.c rp2040/flash.c ../lib/rp2040/pico/flash/hw_flash.c
mcu-y += generic/armcm_irq.c generic/crc16_ccitt.c
src-y += rp2040/armcm_canboot.c $(mcu-y)
@ -56,7 +56,7 @@ lib/rp2040_flash/rp2040_flash:
# Flash rules
flash: $(OUT)canboot.uf2 lib/rp2040_flash/rp2040_flash
@echo " Flashing $< "
$(Q)./lib/rp2040_flash/rp2040_flash $(OUT)canboot.uf2
$(Q) $(if $(NOSUDO),,sudo) ./lib/rp2040_flash/rp2040_flash $(OUT)canboot.uf2
# Deployer build
deployer-y += generic/armcm_boot.c generic/armcm_reset.c $(mcu-y)