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.
 
 
 
 
 
 

108 lines
2.6 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+= strobe_rng_init.c
  12. CFLAGS+= -I$(.CURDIR)
  13. CFLAGS+= -g
  14. #CFLAGS+= -DNDEBUG
  15. # Strobe
  16. .PATH: $(.CURDIR)/strobe
  17. CFLAGS+= -I$(.CURDIR)/strobe
  18. SRCS+= strobe.c \
  19. x25519.c
  20. # Microcontroller
  21. STM32=$(.CURDIR)/stm32
  22. .PATH: $(STM32)/l151ccux
  23. LINKER_SCRIPT=$(STM32)/l151ccux/STM32L151CCUX_FLASH.ld
  24. SRCS+= \
  25. startup_stm32l151ccux.s \
  26. stm32l1xx_hal.c \
  27. stm32l1xx_hal_cortex.c \
  28. stm32l1xx_hal_gpio.c \
  29. stm32l1xx_hal_pcd.c \
  30. stm32l1xx_hal_pcd_ex.c \
  31. stm32l1xx_hal_rcc.c \
  32. stm32l1xx_hal_rcc_ex.c \
  33. system_stm32l1xx.c
  34. SRCS+= \
  35. stm32l1xx_it.c \
  36. stm32l1xx_hal_msp.c
  37. CFLAGS+= -I$(STM32)
  38. CFLAGS+= -I$(STM32)/l151ccux
  39. CFLAGS+= -DSTM32L151xC
  40. # USB
  41. .PATH: $(STM32)/usb
  42. SRCS+= \
  43. stm32l1xx_ll_usb.c \
  44. usb_device.c \
  45. usbd_cdc.c \
  46. usbd_cdc_if.c \
  47. usbd_conf.c \
  48. usbd_core.c \
  49. usbd_ctlreq.c \
  50. usbd_desc.c \
  51. usbd_ioreq.c
  52. CFLAGS+= -I$(STM32)/usb
  53. OBJS = $(SRCS:C/.c$/.o/)
  54. CFLAGS+= -Werror -Wall
  55. .PHONY: all
  56. all: $(PROG)$(PROGEXT) $(PROG).list
  57. .PHONY: depend
  58. depend: $(SRCS)
  59. $(ARMCC) $(ARMTARGET) $(CFLAGS) $(.ALLSRC) -MM > .depend || rm -f .depend
  60. $(PROG)$(PROGEXT): $(OBJS)
  61. $(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
  62. $(PROG).list: $(PROG)$(PROGEXT)
  63. $(ARMOBJDUMP) -h -S $(.ALLSRC) > $@ || rm -f $@
  64. .PHONY: runbuild
  65. runbuild:
  66. for i in $(.MAKEFILE_LIST) $$(gsed ':x; /\\$$/ { N; s/\\\n//; tx }' < .depend | sed -e 's/^[^:]*://'); do echo $$i; done | entr -d sh -c 'cd $(.CURDIR) && $(MAKE) depend && $(MAKE) all'
  67. .PHONY: runtests
  68. runtests:
  69. ls *.py | entr sh -c 'python -m coverage run -m unittest lora && coverage report --omit=p/\* -m -i'
  70. .c.o:
  71. $(ARMCC) $(ARMTARGET) $(CFLAGS) -c $< -o $@
  72. STROBE_NAME = strobe
  73. STROBE_REPO = https://git.code.sf.net/p/strobe/code
  74. STROBE_BRANCH = master
  75. LORAMAC_NAME = loramac
  76. LORAMAC_REPO = https://github.com/Lora-net/LoRaMac-node.git
  77. LORAMAC_BRANCH = master
  78. .for module in STROBE LORAMAC
  79. .PHONY: init-$($(module)_NAME)
  80. init-$($(module)_NAME):
  81. git subtree add -P $($(module)_NAME) --squash $($(module)_REPO) $($(module)_BRANCH)
  82. .PHONY: update-$($(module)_NAME)
  83. update-$($(module)_NAME):
  84. git subtree pull -P $($(module)_NAME) --squash $($(module)_REPO) $($(module)_BRANCH)
  85. .endfor