diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | hexedit/.gitignore | 1 | ||||
-rw-r--r-- | hexedit/Makefile | 52 | ||||
-rw-r--r-- | octedit/Makefile | 23 |
4 files changed, 55 insertions, 29 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8fa25f4 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +.PHONY: hexedit +hexedit: octedit + $(MAKE) -C hexedit serial + +.PHONY: octedit +octedit: + $(MAKE) -C octedit flash + diff --git a/hexedit/.gitignore b/hexedit/.gitignore new file mode 100644 index 0000000..ef90be6 --- /dev/null +++ b/hexedit/.gitignore @@ -0,0 +1 @@ +hexedit.oe 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 diff --git a/octedit/Makefile b/octedit/Makefile index cc3773d..d318811 100644 --- a/octedit/Makefile +++ b/octedit/Makefile @@ -1,6 +1,4 @@ -all: build - -build: octedit.uf2 +PICO = /dev/disk/by-label/RPI-RP2 octedit.uf2: octedit.bin echo -ne "\x55\x46\x32\x0A" > octedit.uf2 # Magic 0 @@ -19,9 +17,6 @@ octedit.bin: octedit.elf crc32 arm-none-eabi-objcopy -O binary octedit.elf octedit.bin ./crc32 < octedit.bin >> octedit.bin -crc32: crc32.c - gcc crc32.c -o crc32 - objects = setup.o octedit.o uart.o octedit.elf: $(objects) pico_persist.ld @@ -30,9 +25,19 @@ octedit.elf: $(objects) pico_persist.ld $(objects): %.o: %.s arm-none-eabi-as -o $@ $< +.PHONY: clean clean: rm octedit.elf octedit.bin octedit.uf2 *.o crc32 -flash: octedit.uf2 - [ -h /dev/disk/by-label/RPI-RP2 ] || sleep 3s - cat octedit.uf2 > /dev/disk/by-label/RPI-RP2 +.PHONY: flash +flash: $(PICO) octedit.uf2 + cat octedit.uf2 > $(PICO) + +.PHONY: check +check: $(PICO) + @echo Ready to flash + +$(PICO): + @echo "RPI-RP2 bootloader drive not found" + @echo Connect the pico with USB cable while holding bootsel button + @false |