aboutsummaryrefslogtreecommitdiff
path: root/hexedit/Makefile
blob: a42b16a3ce7b9543fbdd7be8261c376eeaf1d7d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
PICO = /dev/disk/by-label/RPI-RP2
PICO_CONSOLE = /dev/ttyUSB0

.PHONY: build
build: hexedit.oe

hexedit.oe: hexedit.bin
	od -An -v hexedit.bin | sed "s/^ //" | tr " " "\n" > hexedit.oe

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

hexedit.elf: $(objects)
	arm-none-eabi-ld -T pico_ram_only.ld -o hexedit.elf $(objects) ../setup/setup.so

.PHONY: clean
clean:
	rm -f hexedit.elf hexedit.uf2 hexedit.bin hexedit.oe *.o

.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