jacking/rpi/Makefile

58 lines
1.3 KiB
Makefile
Raw Normal View History

OPENOCD_HOST ?= localhost
OPENOCD_PORT_GDB ?= 3333
OPENOCD_PORT_TELNET ?= 4444
PREFIX ?= arm-none-eabi-
CC = $(PREFIX)gcc
2022-01-29 18:09:46 +00:00
CFLAGS = -mcpu=arm1176jzf-s -Wall -O2
LDFLAGS = -T rpi.ld -nostartfiles -Wl,-Map=rpi.map -Wl,--cref
GDB ?= $(PREFIX)gdb
PYTHON3 ?= python3
NC ?= nc
default: all
2022-01-29 18:09:46 +00:00
all: rpi.elf rpi.img
rpi.o: rpi.c
$(CC) $(CFLAGS) -c -o "$@" "$<"
2022-01-29 18:09:46 +00:00
vectors.o: vectors.s
$(CC) -mcpu=arm1176jzf-s -c -o "$@" "$<"
2022-01-29 01:26:40 +00:00
#jazelle.S: ../jazelle.c
# $(CC) $(CFLAGS) -S -o "$@" "$<"
jazelle.o: ../jazelle.c
$(CC) $(CFLAGS) -c -o "$@" "$<"
2022-01-29 18:09:46 +00:00
nl-glue.o: nl-glue.c
$(CC) $(CFLAGS) -c -o "$@" "$<"
rpi.elf: rpi.o vectors.o nl-glue.o jazelle.o
$(CC) $(CFLAGS) $(LDFLAGS) -o "$@" $^
rpi.img: rpi.elf
$(PREFIX)objcopy -O binary "$<" "$@"
openocd-launch:
openocd -f interface/cmsis-dap.cfg -c "transport select jtag" \
-c "adapter speed 50" -f target/bcm2835.cfg \
-c init -c scan_chain
openocd-load: rpi.elf
printf 'halt\nload_image rpi.elf\nexit\n' \
| nc $(OPENOCD_HOST) $(OPENOCD_PORT_TELNET)
gdb:
$(GDB) -ex 'target extended-remote $(OPENOCD_HOST):$(OPENOCD_PORT_GDB)' \
-ex 'set $$pc=_start' \
$(GDB_EXTRA_CMDS) \
rpi.elf
clean:
2022-01-29 20:25:33 +00:00
@$(RM) -v rpi.o rpi.elf vectors.o jazelle.o nl-glue.o rpi.img
.PHONY: all clean openocd-launch openocd-load gdb