Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

130 lines
3.4 KiB

  1. ARMOBJDUMP?= arm-none-eabi-objdump
  2. ARMCC?= arm-none-eabi-gcc
  3. ARMTARGET?= -mcpu=cortex-m3 -mthumb -DSTROBE_SINGLE_THREAD=1
  4. # Clang doesn't work due to no-nano libc
  5. #ARMCC?=clang-mp-9.0
  6. #ARMTARGET?= -nostdlib -ffreestanding -target arm-none-eabi -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
  7. PROG = lora.irr
  8. PROGEXT = .elf
  9. SRCS = main.c
  10. SRCS+= board.c
  11. SRCS+= misc.c
  12. SRCS+= strobe_rng_init.c
  13. CFLAGS+= -I$(.CURDIR)
  14. CFLAGS+= -g
  15. #CFLAGS+= -DNDEBUG
  16. # Strobe
  17. .PATH: $(.CURDIR)/strobe
  18. CFLAGS+= -I$(.CURDIR)/strobe
  19. SRCS+= strobe.c \
  20. x25519.c
  21. # LoRamac (SX1276) radio code
  22. LORAMAC_SRC = $(.CURDIR)/loramac/src
  23. .PATH: $(LORAMAC_SRC)/radio/sx1276 $(LORAMAC_SRC)/system $(LORAMAC_SRC)/boards/mcu $(LORAMAC_SRC)/boards/NucleoL152
  24. CFLAGS+= -I$(LORAMAC_SRC)/boards
  25. CFLAGS+= -I$(LORAMAC_SRC)/system
  26. CFLAGS+= -I$(LORAMAC_SRC)/radio
  27. CFLAGS+= -DUSE_HAL_DRIVER -DSX1276MB1LAS
  28. SRCS+= sx1276.c
  29. SRCS+= utilities.c
  30. SRCS+= adc.c timer.c delay.c gpio.c uart.c fifo.c
  31. 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
  32. # Microcontroller
  33. STM32=$(.CURDIR)/stm32
  34. .PATH: $(STM32)/l151ccux
  35. LINKER_SCRIPT=$(STM32)/l151ccux/STM32L151CCUX_FLASH.ld
  36. SRCS+= \
  37. startup_stm32l151ccux.s \
  38. stm32l1xx_hal.c \
  39. stm32l1xx_hal_adc.c \
  40. stm32l1xx_hal_adc_ex.c \
  41. stm32l1xx_hal_cortex.c \
  42. stm32l1xx_hal_dma.c \
  43. stm32l1xx_hal_gpio.c \
  44. stm32l1xx_hal_spi.c \
  45. stm32l1xx_hal_pwr.c \
  46. stm32l1xx_hal_pwr_ex.c \
  47. stm32l1xx_hal_pcd.c \
  48. stm32l1xx_hal_pcd_ex.c \
  49. stm32l1xx_hal_rcc.c \
  50. stm32l1xx_hal_rcc_ex.c \
  51. stm32l1xx_hal_rtc.c \
  52. stm32l1xx_hal_rtc_ex.c \
  53. stm32l1xx_hal_uart.c \
  54. system_stm32l1xx.c
  55. SRCS+= \
  56. stm32l1xx_it.c \
  57. stm32l1xx_hal_msp.c
  58. CFLAGS+= -I$(STM32)
  59. CFLAGS+= -I$(STM32)/l151ccux
  60. CFLAGS+= -DSTM32L151xC
  61. # USB
  62. .PATH: $(STM32)/usb
  63. SRCS+= \
  64. stm32l1xx_ll_usb.c \
  65. usb_device.c \
  66. usbd_cdc.c \
  67. usbd_cdc_if.c \
  68. usbd_conf.c \
  69. usbd_core.c \
  70. usbd_ctlreq.c \
  71. usbd_desc.c \
  72. usbd_ioreq.c
  73. CFLAGS+= -I$(STM32)/usb
  74. OBJS = $(SRCS:C/.c$/.o/)
  75. CFLAGS+= -Werror -Wall
  76. .PHONY: all
  77. all: $(PROG)$(PROGEXT) $(PROG).list
  78. .PHONY: depend
  79. depend: $(SRCS)
  80. $(ARMCC) $(ARMTARGET) $(CFLAGS) $(.ALLSRC) -MM > .depend || rm -f .depend
  81. $(PROG)$(PROGEXT): $(OBJS)
  82. $(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
  83. $(PROG).list: $(PROG)$(PROGEXT)
  84. $(ARMOBJDUMP) -h -S $(.ALLSRC) > $@ || rm -f $@
  85. .PHONY: runbuild
  86. runbuild: $(SRCS)
  87. for i in $(.MAKEFILE_LIST) $(.ALLSRC) $$(gsed ':x; /\\$$/ { N; s/\\\n//; tx }' < .depend | sed -e 's/^[^:]*://'); do if [ "$$i" != ".." ]; then echo $$i; fi; done | entr -d sh -c 'echo starting...; cd $(.CURDIR) && $(MAKE) $(.MAKEFLAGS) depend && $(MAKE) $(.MAKEFLAGS) all'
  88. .PHONY: runtests
  89. runtests: lora.py
  90. ls $(.ALLSRC) | entr sh -c 'PYTHONPATH="$(.CURDIR)" python -m coverage run -m unittest lora && coverage report --omit=p/\* -m -i'
  91. .c.o:
  92. $(ARMCC) $(ARMTARGET) $(CFLAGS) -c $< -o $@
  93. STROBE_NAME = strobe
  94. STROBE_REPO = https://git.code.sf.net/p/strobe/code
  95. STROBE_BRANCH = master
  96. LORAMAC_NAME = loramac
  97. LORAMAC_REPO = https://github.com/Lora-net/LoRaMac-node.git
  98. LORAMAC_BRANCH = master
  99. .for module in STROBE LORAMAC
  100. .PHONY: init-$($(module)_NAME)
  101. init-$($(module)_NAME):
  102. git subtree add -P $($(module)_NAME) --squash $($(module)_REPO) $($(module)_BRANCH)
  103. .PHONY: update-$($(module)_NAME)
  104. update-$($(module)_NAME):
  105. git subtree pull -P $($(module)_NAME) --squash $($(module)_REPO) $($(module)_BRANCH)
  106. .endfor