diff --git a/Makefile b/Makefile index f864f18..2711655 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -TARGET=crow +TARGET=parafocus EXECUTABLE=$(TARGET).elf GIT_VERSION := $(shell git describe --tags) @@ -8,11 +8,8 @@ HALS=$(CUBE)/STM32F7xx_HAL_Driver/Src USBD=submodules/STM32CubeF7_USB/STM32_USB_Device_Library WRLIB=submodules/wrLib WRDSP=submodules/wrDsp -LUAS=submodules/lua/src BOOTLOADER=submodules/dfu-stm32f7 -BUILD_DIR := build -PRJ_DIR=crow -LUAC_CROSS=util/luacc +PRJ_DIR=parafocus CC=arm-none-eabi-gcc LD=arm-none-eabi-gcc @@ -21,8 +18,6 @@ AS=arm-none-eabi-as CP=arm-none-eabi-objcopy OBJDUMP=arm-none-eabi-objdump -FENNEL=fennel - # BIN=$(CP) -O ihex BIN = $(TARGET).bin @@ -52,11 +47,9 @@ CFLAGS += $(MCFLAGS) CFLAGS += $(OPTIMIZE) CFLAGS += $(DEFS) -I. -I./ $(STM32_INCLUDES) CFLAGS += -fsingle-precision-constant -Wdouble-promotion -CFLAGS += -DLUA_32BITS CFLAGS += -fno-common CFLAGS += -DVERSION=\"$(GIT_VERSION)\" CFLAGS += -ffunction-sections -fdata-sections # provides majority of LTO binary size reduction -CFLAGS += -DLUA_COMPAT_MATHLIB # debugger: choose between uart (=0) & swtrace(=1). latter requires hardware mod TRACE ?= 0 @@ -115,82 +108,15 @@ SRC = main.c \ $(WRDSP)/wrFilter.c \ -# lua tests -LTESTS = $(wildcard tests/*.lua) \ - - # recipes! all: $(TARGET).hex $(BIN) -### pre-process only files - -# fennel script conversion to lua -FNL_SRC = $(wildcard lua/*.fnl) \ - -FNL_PP = $(FNL_SRC:%.fnl=%.lua) - -# i2c descriptors -II_SRCD = lua/ii -II_SRC = $(wildcard $(II_SRCD)/*.lua) - -$(BUILD_DIR)/ii_c_layer.h: $(II_SRC) util/ii_c_layer.lua | $(BUILD_DIR) - @lua util/ii_c_layer.lua $(II_SRCD) $@ - @echo "ii-c-layer $@" - -$(BUILD_DIR)/ii_mod_gen.h: $(II_SRC) util/ii_mod_gen.lua | $(BUILD_DIR) - @lua util/ii_mod_gen.lua $(II_SRCD) $@ - @echo "ii-mod-gen $@" - - -### destination sources - -# lua srcs: these get converted to bytecode strings wrapped in c-headers -LUA_SRC += lua/asl.lua -LUA_SRC += lua/asllib.lua -LUA_SRC += lua/calibrate.lua -LUA_SRC += lua/clock.lua -LUA_SRC += lua/crowlib.lua -LUA_SRC += lua/First.lua -LUA_SRC += lua/ii.lua -LUA_SRC += lua/input.lua -LUA_SRC += lua/metro.lua -LUA_SRC += lua/output.lua -LUA_SRC += lua/public.lua -LUA_SRC += lua/quote.lua -LUA_SRC += lua/sequins.lua -LUA_SRC += lua/timeline.lua -LUA_SRC += lua/hotswap.lua - -LUA_PP = $(LUA_SRC:%.lua=%.lua.h) -LUA_PP: $(LUA_SRC) - @echo "pre-compiling lua sources to bytecode wrapped in c headers" - -LUACORE_OBJS= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ - lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \ - ltm.o lundump.o lvm.o lzio.o -LUALIB_OBJS= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \ - lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o - - # build the objects from c source OBJDIR = . OBJS = $(SRC:%.c=$(OBJDIR)/%.o) -OBJS += $(addprefix $(LUAS)/,$(LUACORE_OBJS) $(LUALIB_OBJS) ) OBJS += Startup.o -$(OBJS): $(LUA_PP) - -# specific objects that require built dependencies (ii) -$(OBJDIR)/lib/l_bootstrap.o: $(LUA_PP) #$(BUILD_DIR)/ii_lualink.h -$(OBJDIR)/lib/ii.o: $(BUILD_DIR)/ii_c_layer.h -$(OBJDIR)/lib/l_ii_mod.o: $(BUILD_DIR)/ii_mod_gen.h - -# generate the build directory -$(BUILD_DIR): - @echo build_dir $(BUILD_DIR)/ - @mkdir -p $(BUILD_DIR) - # C dependencies echoed into Makefile DEP = $(OBJS:.o=.d) # one dependency file for each source @@ -206,12 +132,6 @@ ifeq ($(UNAME), Darwin) endif -.PHONY: tests -tests: - @for t in $(LTESTS); do \ - lua $$t; \ - done - # include all DEP files in the makefile # will rebuild elements if dependent C headers are changed -include $(DEP) @@ -232,18 +152,18 @@ $(BIN): $(EXECUTABLE) @echo "symbol table: $@.dmp" @echo "Release: "$(R) @$(GETSIZE) $(BIN) | grep 'Size' - @echo " ^ must be less than 384kB (384,000)" + @echo " ^ must be less than 512kB" # 512kb -64kb(bootloader) -128kb(scripts) flash: $(BIN) - st-flash write $(BIN) 0x08020000 + st-flash write $(BIN) 0x08000000 debug: make flash TRACE=1 stlink-trace -c 216 dfu: $(BIN) - sudo dfu-util -a 0 -s 0x08020000 -R -D $(BIN) -d ,0483:df11 + sudo dfu-util -a 0 -s 0x08000000 -R -D $(BIN) -d ,0483:df11 dfureset: @stty -F /dev/ttyACM0 raw speed 115200 @@ -254,7 +174,7 @@ pydfu: $(TARGET).dfu $(BIN) @python3 util/pydfu.py -u $< $(TARGET).dfu: $(BIN) - python3 util/dfu.py -D 0x0483:0xDF11 -b 0x08020000:$^ $@ + python3 util/dfu.py -D 0x0483:0xDF11 -b 0x08000000:$^ $@ boot: cd $(BOOTLOADER) && \ @@ -281,50 +201,16 @@ zip: $(BIN) $(TARGET).dfu %.s: %.c @$(CC) -ggdb $(CFLAGS) -S $< -o $@ -%.lua: %.fnl - @echo f2l $< "->" $@ - @$(FENNEL) --compile $< > $@ - -# a bunch of gnarly make-functions to massage the intermediate stage filenames -# everything goes into /build now, and we have to save output of LUAC_CROSS into -# named files for (xxd -i) to build include files with valid names -# could be avoided by a more complicated pass in (sed), but this was easier -# 1. cross-compile all .lua files into .lc bytecode for stm32-arm-cortex-m7 format -# 2. wrap the .lc binary files into .h headers with auto-generated names -# 3. add const qualifiers to headers to satisfy C99 struct initializer requirement - -%.lua.h: %.lua $(BUILD_DIR) - @echo l2h $< "->" $(addprefix $(BUILD_DIR)/, $(notdir $(subst .lua.h,.h,$@))) - @$(LUAC_CROSS) -s -o $(addprefix $(BUILD_DIR)/, $(notdir $(subst .lua,.lc,$<))) $< - @xxd -i $(addprefix $(BUILD_DIR)/, $(notdir $(subst .lua,.lc,$<))) $(addprefix $(BUILD_DIR)/, $(notdir $(subst .lua.h,.h,$@))) - @sed -i 's/unsigned int/const unsigned int/g' $(addprefix $(BUILD_DIR)/, $(notdir $(subst .lua.h,.h,$@))) - Startup.o: $(STARTUP) @$(CC) $(CFLAGS) -c $< -o $@ @echo $@ -wav: fsk-wav - -fsk-wav: $(BIN) - export PYTHONPATH=$$PYTHONPATH:'.' && \ - cd .. && python stm-audio-bootloader/fsk/encoder.py \ - -s 48000 -b 16 -n 8 -z 4 -p 256 -g 16384 -k 1800 \ - $(PRJ_DIR)/$(BIN) - erase: st-flash erase -norns: - lua util/ii_norns_actions.lua lua/ii/ $(NORNS_DIR)/lua/core/crow/ii_actions.lua - lua util/ii_norns_events.lua lua/ii/ $(NORNS_DIR)/lua/core/crow/ii_events.lua - .PHONY: clean clean: @rm -rf Startup.lst $(TARGET).elf.lst $(OBJS) $(AUTOGEN) \ $(TARGET).bin $(TARGET).out $(TARGET).hex $(TARGET).dfu \ $(TARGET).map $(TARGET).dmp $(EXECUTABLE) $(DEP) \ - $(BUILD_DIR) lua/*.lua.h \ $(TARGET)-$(GIT_VERSION)/ *.zip \ - -splint: - splint -I. -I./ $(STM32_INCLUDES) *.c diff --git a/stm32_flash.ld b/stm32_flash.ld index 23da864..da8f99a 100755 --- a/stm32_flash.ld +++ b/stm32_flash.ld @@ -40,8 +40,7 @@ _Min_Stack_Size = 0x10000; /* required amount of stack */ /* Specify the memory areas */ MEMORY { - /* FLASH (rx) : ORIGIN = 0x00200000, LENGTH = 512K */ /* ITCM interface */ - FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* AXIM interface */ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* AXIM interface */ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K /* MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K */ /* CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K */ diff --git a/system_stm32f7xx.c b/system_stm32f7xx.c index b9b1aac..d47a20b 100644 --- a/system_stm32f7xx.c +++ b/system_stm32f7xx.c @@ -97,7 +97,7 @@ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x20000 /*!< Vector Table base offset field. +#define VECT_TAB_OFFSET 0x0000 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /******************************************************************************/