|
- ARMOBJDUMP?= arm-none-eabi-objdump
- ARMCC?= arm-none-eabi-gcc
- ARMTARGET?= -mcpu=cortex-m3 -mthumb -DSTROBE_SINGLE_THREAD=1
-
- # Clang doesn't work due to no-nano libc
- #ARMCC?=clang-mp-9.0
- #ARMTARGET?= -nostdlib -ffreestanding -target arm-none-eabi -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
-
- PROG = lora.irr
- PROGEXT = .elf
-
- SRCS = main.c
- SRCS+= board.c
- SRCS+= misc.c
- SRCS+= strobe_rng_init.c
-
- CFLAGS+= -I$(.CURDIR)
- CFLAGS+= -g
- #CFLAGS+= -DNDEBUG
-
- # Strobe
- .PATH: $(.CURDIR)/strobe
- CFLAGS+= -I$(.CURDIR)/strobe
- SRCS+= strobe.c \
- x25519.c
-
- # LoRamac (SX1276) radio code
- LORAMAC_SRC = $(.CURDIR)/loramac/src
- .PATH: $(LORAMAC_SRC)/radio/sx1276 $(LORAMAC_SRC)/system $(LORAMAC_SRC)/boards/mcu $(LORAMAC_SRC)/boards/NucleoL152
- CFLAGS+= -I$(LORAMAC_SRC)/boards
- CFLAGS+= -I$(LORAMAC_SRC)/system
- CFLAGS+= -I$(LORAMAC_SRC)/radio
- CFLAGS+= -DUSE_HAL_DRIVER -DSX1276MB1LAS
- SRCS+= sx1276.c
- SRCS+= utilities.c
- SRCS+= adc.c timer.c delay.c gpio.c uart.c fifo.c
- SRCS+= adc-board.c delay-board.c gpio-board.c rtc-board.c lpm-board.c sx1276mb1las-board.c spi-board.c uart-board.c
-
- # Microcontroller
- STM32=$(.CURDIR)/stm32
- .PATH: $(STM32)/l151ccux
- LINKER_SCRIPT=$(STM32)/l151ccux/STM32L151CCUX_FLASH.ld
- SRCS+= \
- startup_stm32l151ccux.s \
- stm32l1xx_hal.c \
- stm32l1xx_hal_adc.c \
- stm32l1xx_hal_adc_ex.c \
- stm32l1xx_hal_cortex.c \
- stm32l1xx_hal_dma.c \
- stm32l1xx_hal_gpio.c \
- stm32l1xx_hal_spi.c \
- stm32l1xx_hal_pwr.c \
- stm32l1xx_hal_pwr_ex.c \
- stm32l1xx_hal_pcd.c \
- stm32l1xx_hal_pcd_ex.c \
- stm32l1xx_hal_rcc.c \
- stm32l1xx_hal_rcc_ex.c \
- stm32l1xx_hal_rtc.c \
- stm32l1xx_hal_rtc_ex.c \
- stm32l1xx_hal_uart.c \
- system_stm32l1xx.c
-
- SRCS+= \
- stm32l1xx_it.c \
- stm32l1xx_hal_msp.c
-
- CFLAGS+= -I$(STM32)
- CFLAGS+= -I$(STM32)/l151ccux
- CFLAGS+= -DSTM32L151xC
-
- # USB
- .PATH: $(STM32)/usb
- SRCS+= \
- stm32l1xx_ll_usb.c \
- usb_device.c \
- usbd_cdc.c \
- usbd_cdc_if.c \
- usbd_conf.c \
- usbd_core.c \
- usbd_ctlreq.c \
- usbd_desc.c \
- usbd_ioreq.c
-
- CFLAGS+= -I$(STM32)/usb
-
- OBJS = $(SRCS:C/.c$/.o/)
- CFLAGS+= -Werror -Wall
-
- .PHONY: all
- all: $(PROG)$(PROGEXT) $(PROG).list
-
- .PHONY: depend
- depend: $(SRCS)
- $(ARMCC) $(ARMTARGET) $(CFLAGS) $(.ALLSRC) -MM > .depend || rm -f .depend
-
- $(PROG)$(PROGEXT): $(OBJS)
- $(ARMCC) $(ARMTARGET) -o $@ $(.ALLSRC) -T$(LINKER_SCRIPT) --specs=nosys.specs -Wl,--gc-sections -static --specs=nano.specs -Wl,--start-group -lc -lm -Wl,--end-group
-
- $(PROG).list: $(PROG)$(PROGEXT)
- $(ARMOBJDUMP) -h -S $(.ALLSRC) > $@ || rm -f $@
-
- .PHONY: runbuild
- runbuild: $(SRCS)
- for i in $(.MAKEFILE_LIST) $(.ALLSRC) $$(gsed ':x; /\\$$/ { N; s/\\\n//; tx }' < .depend | sed -e 's/^[^:]*://'); do echo $$i; done | entr -d sh -c 'echo starting...; cd $(.CURDIR) && $(MAKE) depend && $(MAKE) all'
-
- .PHONY: runtests
- runtests:
- ls *.py | entr sh -c 'python -m coverage run -m unittest lora && coverage report --omit=p/\* -m -i'
-
- .c.o:
- $(ARMCC) $(ARMTARGET) $(CFLAGS) -c $< -o $@
-
- STROBE_NAME = strobe
- STROBE_REPO = https://git.code.sf.net/p/strobe/code
- STROBE_BRANCH = master
-
- LORAMAC_NAME = loramac
- LORAMAC_REPO = https://github.com/Lora-net/LoRaMac-node.git
- LORAMAC_BRANCH = master
-
- .for module in STROBE LORAMAC
- .PHONY: init-$($(module)_NAME)
- init-$($(module)_NAME):
- git subtree add -P $($(module)_NAME) --squash $($(module)_REPO) $($(module)_BRANCH)
-
- .PHONY: update-$($(module)_NAME)
- update-$($(module)_NAME):
- git subtree pull -P $($(module)_NAME) --squash $($(module)_REPO) $($(module)_BRANCH)
- .endfor
|