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.
 
 
 
 
 
 

97 lines
2.2 KiB

  1. ARMCC?= arm-none-eabi-gcc
  2. ARMOBJDUMP?= arm-none-eabi-objdump
  3. ARMTARGET?= -mcpu=cortex-m3 -mthumb -DSTROBE_SINGLE_THREAD=1
  4. PROG = lora.irr
  5. PROGEXT = .elf
  6. SRCS = main.c
  7. SRCS+= board.c
  8. SRCS+= strobe_rng_init.c
  9. CFLAGS+= -I$(.CURDIR)
  10. CFLAGS+= -g
  11. #CFLAGS+= -DNDEBUG
  12. # Strobe
  13. .PATH: $(.CURDIR)/strobe
  14. CFLAGS+= -I$(.CURDIR)/strobe
  15. SRCS+= strobe.c \
  16. x25519.c
  17. # Microcontroller
  18. STM32=$(.CURDIR)/stm32
  19. .PATH: $(STM32)/l151ccux
  20. LINKER_SCRIPT=$(STM32)/l151ccux/STM32L151CCUX_FLASH.ld
  21. SRCS+= \
  22. startup_stm32l151ccux.s \
  23. stm32l1xx_hal.c \
  24. stm32l1xx_hal_cortex.c \
  25. stm32l1xx_hal_gpio.c \
  26. stm32l1xx_hal_pcd.c \
  27. stm32l1xx_hal_pcd_ex.c \
  28. stm32l1xx_hal_rcc.c \
  29. stm32l1xx_hal_rcc_ex.c \
  30. system_stm32l1xx.c
  31. SRCS+= \
  32. stm32l1xx_it.c \
  33. stm32l1xx_hal_msp.c
  34. CFLAGS+= -I$(STM32)
  35. CFLAGS+= -I$(STM32)/l151ccux
  36. CFLAGS+= -DSTM32L151xC
  37. # USB
  38. .PATH: $(STM32)/usb
  39. SRCS+= \
  40. stm32l1xx_ll_usb.c \
  41. usb_device.c \
  42. usbd_cdc.c \
  43. usbd_cdc_if.c \
  44. usbd_conf.c \
  45. usbd_core.c \
  46. usbd_ctlreq.c \
  47. usbd_desc.c \
  48. usbd_ioreq.c
  49. CFLAGS+= -I$(STM32)/usb
  50. OBJS = $(SRCS:C/.c$/.o/)
  51. CFLAGS+= -Werror -Wall
  52. .PHONY: all
  53. all: $(PROG)$(PROGEXT) $(PROG).list
  54. .PHONY: depend
  55. depend: $(SRCS)
  56. $(ARMCC) $(ARMTARGET) $(CFLAGS) $(.ALLSRC) -MM > .depend || rm -f .depend
  57. $(PROG)$(PROGEXT): $(OBJS)
  58. $(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
  59. $(PROG).list: $(PROG)$(PROGEXT)
  60. $(ARMOBJDUMP) -h -S $(.ALLSRC) > $@ || rm -f $@
  61. .PHONY: runbuild
  62. runbuild:
  63. 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'
  64. .PHONY: runtests
  65. runtests:
  66. ls *.py | entr sh -c 'python -m coverage run -m unittest lora && coverage report --omit=p/\* -m -i'
  67. .c.o:
  68. $(ARMCC) $(ARMTARGET) $(CFLAGS) -c $< -o $@
  69. STROBE_REPO = https://git.code.sf.net/p/strobe/code
  70. STROBE_BRANCH = master
  71. .PHONY: init-strobe
  72. init-strobe:
  73. git subtree add -P strobe --squash $(STROBE_REPO) $(STROBE_BRANCH)
  74. .PHONY: update-strobe
  75. update-strobe:
  76. git subtree pull -P strobe --squash $(STROBE_REPO) $(STROBE_BRANCH)