jacking/Makefile

53 lines
1.3 KiB
Makefile
Raw Normal View History

2022-01-21 04:15:36 +00:00
2022-01-22 01:16:16 +00:00
OPENOCD_HOST ?= localhost
OPENOCD_PORT_GDB ?= 3333
OPENOCD_PORT_TELNET ?= 4444
PREFIX ?= arm-none-eabi-
2022-01-21 04:15:36 +00:00
2022-01-22 01:16:16 +00:00
CC = $(PREFIX)gcc
GDB ?= $(PREFIX)gdb
2022-01-21 04:15:36 +00:00
CGENFLAGS = -mcpu=arm926ej-s -mthumb-interwork -fno-pie -DARM9
2022-01-24 01:12:57 +00:00
WARN = -Wall -Wextra -Werror=return-type -Werror=implicit-function-declaration
2022-01-21 04:15:36 +00:00
OPTIMIZE = -g -Og
INCLUDE = -I.
GENDEP = -MMD -MP
DEFS = -DPLL_FBDIV=20
CFLAGS = -std=gnu17 $(CGENFLAGS) $(WARN) $(OPTIMIZE) $(INCLUDE) $(GENDEP) $(DEFS)
LDFLAGS = -static -nostartfiles -T bsp/fx3.ld -Wl,-z,max-page-size=4096,-Map,$(basename $@).map
VPATH = bsp
2022-01-22 01:16:16 +00:00
OBJS = main.o usb.o gpif.o gctl.o gpio.o uart.o util.o dma.o irq.o cache.o vectors.o jazelle.o nl-glue.o
2022-01-21 04:15:36 +00:00
all : jazelle.img
jazelle.img: jazelle.elf
python3 elf2img.py $< $@
clean :
rm -f jazelle.img jazelle.elf jazelle.map $(OBJS) $(OBJS:.o=.d)
jazelle.elf : $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
2022-01-22 01:16:16 +00:00
openocd-launch:
openocd -c "bindto $(OPENOCD_HOST)" -f ./arm926ejs_fx3.cfg -c init # TODO: ports
openocd-load: jazelle.elf
printf 'reset halt\nload_image jazelle.elf\nexit\n' \
| nc $(OPENOCD_HOST) $(OPENOCD_PORT_TELNET)
gdb:
$(GDB) -ex 'target extended-remote $(OPENOCD_HOST):$(OPENOCD_PORT_GDB)' \
2022-01-24 01:12:57 +00:00
-ex 'set $$pc=_start' \
$(GDB_EXTRA_CMDS) \
-ex c jazelle.elf
# -ex 'b jazelle_exec' \
2022-01-22 01:16:16 +00:00
2022-01-21 04:15:36 +00:00
-include $(OBJS:.o=.d)
2022-01-22 01:16:16 +00:00
.PHONY: all clean openocd-launch openocd-load gdb