43 lines
901 B
Makefile
43 lines
901 B
Makefile
|
|
||
|
OPENOCD_HOST ?= localhost
|
||
|
OPENOCD_PORT_GDB ?= 3333
|
||
|
OPENOCD_PORT_TELNET ?= 4444
|
||
|
PREFIX ?= arm-none-eabi-
|
||
|
|
||
|
CC = $(PREFIX)gcc
|
||
|
CFLAGS = -mcpu=arm1176jzf-s
|
||
|
LDFLAGS = -T rpi.ld -nostartfiles -nostdlib
|
||
|
GDB ?= $(PREFIX)gdb
|
||
|
PYTHON3 ?= python3
|
||
|
NC ?= nc
|
||
|
|
||
|
default: all
|
||
|
|
||
|
all: rpi.elf
|
||
|
|
||
|
rpi.o: rpi.c
|
||
|
$(CC) $(CFLAGS) -c -o "$@" "$<"
|
||
|
|
||
|
rpi.elf: rpi.o
|
||
|
$(CC) $(CFLAGS) $(LDFLAGS) -o "$@" $^
|
||
|
|
||
|
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:
|
||
|
@$(RM) -v rpi.o rpi.elf
|
||
|
|
||
|
.PHONY: all clean openocd-launch openocd-load gdb
|