From 996111e3043da0f7c16bad7151b99a378f6fef48 Mon Sep 17 00:00:00 2001 From: Jacques Comeaux Date: Wed, 3 Jul 2024 21:56:54 -0500 Subject: Improve makefiles --- hexedit/Makefile | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'hexedit/Makefile') diff --git a/hexedit/Makefile b/hexedit/Makefile index 01d5224..a42b16a 100644 --- a/hexedit/Makefile +++ b/hexedit/Makefile @@ -1,16 +1,8 @@ -PICO_UART=/dev/ttyUSB0 +PICO = /dev/disk/by-label/RPI-RP2 +PICO_CONSOLE = /dev/ttyUSB0 -all: build - -build: hexedit.uf2 - -dump: hexedit.bin - od hexedit.bin - -serial: hexedit.oe - [ -c PICO_UART ] && \ - (cat hexedit.oe | tr "\n" "\r" > PICO_UART ; echo -n "G" > PICO_UART) || \ - echo No serial device +.PHONY: build +build: hexedit.oe hexedit.oe: hexedit.bin od -An -v hexedit.bin | sed "s/^ //" | tr " " "\n" > hexedit.oe @@ -19,20 +11,40 @@ hexedit.bin: hexedit.o arm-none-eabi-ld -T pico_bin.ld -o hexedit.bin hexedit.o arm-none-eabi-objcopy -O binary hexedit.bin +objects = hexedit.o main.o + +$(objects): %.o: %.s + arm-none-eabi-as -o $@ $< + hexedit.uf2: hexedit.elf ../elf/elf2uf2 hexedit.elf hexedit.uf2 -objects = hexedit.o main.o - hexedit.elf: $(objects) arm-none-eabi-ld -T pico_ram_only.ld -o hexedit.elf $(objects) ../setup/setup.so -$(objects): %.o: %.s - arm-none-eabi-as -o $@ $< - +.PHONY: clean clean: rm -f hexedit.elf hexedit.uf2 hexedit.bin hexedit.oe *.o -flash: hexedit.uf2 - [ -h /dev/disk/by-label/RPI-RP2 ] || sleep 3s - cat hexedit.uf2 > /dev/disk/by-label/RPI-RP2 +.PHONY: dump +dump: hexedit.bin + @od hexedit.bin + +.PHONY: serial +serial: $(PICO_CONSOLE) hexedit.oe + cat hexedit.oe | tr "\n" "\r" > PICO_CONSOLE + echo -n "G" > PICO_CONSOLE + +$(PICO_CONSOLE): + @echo Serial device not found + @echo Connect USB cable from USB-UART bridge + @false + +.PHONY: flash +flash: $(PICO) hexedit.uf2 + cat hexedit.uf2 > $(PICO) + +$(PICO): + @echo "RPI-RP2 bootloader drive not found" + @echo Connect the pico with USB cable while holding bootsel button + @false -- cgit v1.2.3