Advertisement
Guest User

Untitled

a guest
Apr 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 13.92 KB | None | 0 0
  1. #*************************************************************************
  2. #
  3. # Makefile for compiling and programming CowDevice
  4. # __________________
  5. #
  6. #  Copyright 2017 - 2018, Politechnika Wrocławska
  7. #  All Rights Reserved.
  8. #
  9.  
  10. PROJECT_NAME     := cowdevice_app
  11. TARGETS          := nrf52832_xxaa
  12. OUTPUT_DIRECTORY := _build
  13.  
  14. # make parameters, call:
  15. #     make <param_name>=<value>
  16. SET_CLOCK        := false  # SET_CLOCK := true  - sets RTC to __DATE__ and __TIME__ of main.c compilation, run make with option -W main.c  to make suer main.c is recompiled
  17. COWDEVICE_NO     := 0     # COWDEVICE_NO := xx - sets name of the device to MAFIAxx, where xx is the number of a device
  18.  
  19. # Default project placement: folder cowsensor in SDK dir
  20. SDK_ROOT := ../../nRF5_SDK_14.2.0_17b948a
  21. PROJ_DIR := ./
  22.  
  23. # Setup nrfjprog path
  24. NRFJPROG_DIR := ../../nRF5x-Command-Line-Tools/nrfjprog
  25. NRFJPROG = $(NRFJPROG_DIR)/nrfjprog
  26.  
  27. # Board version
  28. BOARD_FLAG = -DBOARD_COWDEVICE_V2_2_1
  29.  
  30. # If the program is bigger, check LINKER_SCRIPT
  31. $(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \
  32.   LINKER_SCRIPT  := cowdevice_app.ld
  33.  
  34. # Source files common to all targets
  35. SRC_FILES += \
  36.     $(PROJ_DIR)/../boards/cowdevice_v2_2_1.c \
  37.     $(PROJ_DIR)/../cowdevice/cowdevice_ble.c \
  38.     $(PROJ_DIR)/../cowdevice/cowdevice_gatt.c \
  39.     $(PROJ_DIR)/../cowdevice/cowdevice_led.c \
  40.     $(PROJ_DIR)/../cowdevice/cowdevice_lsm303.c \
  41.     $(PROJ_DIR)/../cowdevice/cowdevice_msg10s.c \
  42.     $(PROJ_DIR)/../cowdevice/cowdevice_timer.c \
  43.     $(PROJ_DIR)/../cowdevice/cowdevice_twi_helper.c \
  44.     $(PROJ_DIR)/../cowdevice/cowdevice_twi_rtc_mag.c \
  45.   $(PROJ_DIR)/../cowdevice/cowdevice_common.c \
  46.   $(PROJ_DIR)/../cowdevice/cowdevice_led_signals.c \
  47.   $(PROJ_DIR)/../cowdevice/cowdevice_vcc.c \
  48.   $(PROJ_DIR)/../cowdevice/gcc_startup_nrf52.S \
  49.   $(PROJ_DIR)/main.c \
  50.   $(SDK_ROOT)/components/ble/common/ble_advdata.c \
  51.   $(SDK_ROOT)/components/ble/common/ble_conn_params.c \
  52.   $(SDK_ROOT)/components/ble/common/ble_conn_state.c \
  53.   $(SDK_ROOT)/components/ble/common/ble_srv_common.c \
  54.   $(SDK_ROOT)/components/ble/nrf_ble_gatt/nrf_ble_gatt.c \
  55.   $(SDK_ROOT)/components/ble/nrf_ble_gatt/nrf_ble_gatt.c \
  56.   $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \
  57.   $(SDK_ROOT)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \
  58.   $(SDK_ROOT)/components/drivers_nrf/hal/nrf_saadc.c \
  59.   $(SDK_ROOT)/components/drivers_nrf/saadc/nrf_drv_saadc.c \
  60.   $(SDK_ROOT)/components/drivers_nrf/spi_master/nrf_drv_spi.c \
  61.   $(SDK_ROOT)/components/drivers_nrf/twi_master/nrf_drv_twi.c \
  62.   $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \
  63.   $(SDK_ROOT)/components/libraries/block_dev/sdc/nrf_block_dev_sdc.c \
  64.   $(SDK_ROOT)/components/libraries/bsp/bsp_nfc.c \
  65.   $(SDK_ROOT)/components/libraries/bsp/bsp.c \
  66.   $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_backend_rtt.c \
  67.   $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_backend_serial.c \
  68.   $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_default_backends.c \
  69.   $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_frontend.c \
  70.   $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_str_formatter.c \
  71.   $(SDK_ROOT)/components/libraries/experimental_memobj/nrf_memobj.c \
  72.   $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \
  73.   $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \
  74.   $(SDK_ROOT)/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c \
  75.   $(SDK_ROOT)/components/libraries/sdcard/app_sdcard.c \
  76.   $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \
  77.   $(SDK_ROOT)/components/libraries/timer/app_timer.c \
  78.   $(SDK_ROOT)/components/libraries/util/app_error_weak.c \
  79.   $(SDK_ROOT)/components/libraries/util/app_error.c \
  80.   $(SDK_ROOT)/components/libraries/util/app_util_platform.c \
  81.   $(SDK_ROOT)/components/libraries/util/nrf_assert.c \
  82.   $(SDK_ROOT)/components/libraries/util/sdk_mapped_flags.c \
  83.   $(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \
  84.   $(SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \
  85.   $(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \
  86.   $(SDK_ROOT)/components/toolchain/system_nrf52.c \
  87.   $(SDK_ROOT)/external/fatfs/port/diskio_blkdev.c \
  88.   $(SDK_ROOT)/external/fatfs/src/ff.c \
  89.   $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \
  90.   $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \
  91.   $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
  92.   $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
  93.   $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
  94.  
  95. # Include folders common to all targets
  96. INC_FOLDERS += \
  97.   $(PROJ_DIR) \
  98.   $(PROJ_DIR)/../boards \
  99.   $(PROJ_DIR)/../cowdevice \
  100.   $(SDK_ROOT)/components \
  101.   $(SDK_ROOT)/components/ble/ble_advertising \
  102.   $(SDK_ROOT)/components/ble/ble_dtm \
  103.   $(SDK_ROOT)/components/ble/ble_racp \
  104.   $(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \
  105.   $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \
  106.   $(SDK_ROOT)/components/ble/ble_services/ble_bas \
  107.   $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \
  108.   $(SDK_ROOT)/components/ble/ble_services/ble_cscs \
  109.   $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \
  110.   $(SDK_ROOT)/components/ble/ble_services/ble_dfu \
  111.   $(SDK_ROOT)/components/ble/ble_services/ble_dis \
  112.   $(SDK_ROOT)/components/ble/ble_services/ble_gls \
  113.   $(SDK_ROOT)/components/ble/ble_services/ble_hids \
  114.   $(SDK_ROOT)/components/ble/ble_services/ble_hrs \
  115.   $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \
  116.   $(SDK_ROOT)/components/ble/ble_services/ble_hts \
  117.   $(SDK_ROOT)/components/ble/ble_services/ble_ias \
  118.   $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \
  119.   $(SDK_ROOT)/components/ble/ble_services/ble_lbs \
  120.   $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \
  121.   $(SDK_ROOT)/components/ble/ble_services/ble_lls \
  122.   $(SDK_ROOT)/components/ble/ble_services/ble_nus \
  123.   $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \
  124.   $(SDK_ROOT)/components/ble/ble_services/ble_rscs \
  125.   $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \
  126.   $(SDK_ROOT)/components/ble/ble_services/ble_tps \
  127.   $(SDK_ROOT)/components/ble/common \
  128.   $(SDK_ROOT)/components/ble/nrf_ble_gatt \
  129.   $(SDK_ROOT)/components/ble/nrf_ble_gatt \
  130.   $(SDK_ROOT)/components/ble/nrf_ble_qwr \
  131.   $(SDK_ROOT)/components/ble/peer_manager \
  132.   $(SDK_ROOT)/components/device \
  133.   $(SDK_ROOT)/components/drivers_nrf/clock \
  134.   $(SDK_ROOT)/components/drivers_nrf/common \
  135.   $(SDK_ROOT)/components/drivers_nrf/comp \
  136.   $(SDK_ROOT)/components/drivers_nrf/delay \
  137.   $(SDK_ROOT)/components/drivers_nrf/delay \
  138.   $(SDK_ROOT)/components/drivers_nrf/gpiote \
  139.   $(SDK_ROOT)/components/drivers_nrf/hal \
  140.   $(SDK_ROOT)/components/drivers_nrf/i2s \
  141.   $(SDK_ROOT)/components/drivers_nrf/lpcomp \
  142.   $(SDK_ROOT)/components/drivers_nrf/pdm \
  143.   $(SDK_ROOT)/components/drivers_nrf/power \
  144.   $(SDK_ROOT)/components/drivers_nrf/ppi \
  145.   $(SDK_ROOT)/components/drivers_nrf/pwm \
  146.   $(SDK_ROOT)/components/drivers_nrf/qdec \
  147.   $(SDK_ROOT)/components/drivers_nrf/rng \
  148.   $(SDK_ROOT)/components/drivers_nrf/rtc \
  149.   $(SDK_ROOT)/components/drivers_nrf/saadc \
  150.   $(SDK_ROOT)/components/drivers_nrf/spi_master \
  151.   $(SDK_ROOT)/components/drivers_nrf/spi_master \
  152.   $(SDK_ROOT)/components/drivers_nrf/spi_slave \
  153.   $(SDK_ROOT)/components/drivers_nrf/swi \
  154.   $(SDK_ROOT)/components/drivers_nrf/timer \
  155.   $(SDK_ROOT)/components/drivers_nrf/twi_master \
  156.   $(SDK_ROOT)/components/drivers_nrf/twi_master \
  157.   $(SDK_ROOT)/components/drivers_nrf/twis_slave \
  158.   $(SDK_ROOT)/components/drivers_nrf/uart \
  159.   $(SDK_ROOT)/components/drivers_nrf/usbd \
  160.   $(SDK_ROOT)/components/drivers_nrf/wdt \
  161.   $(SDK_ROOT)/components/libraries/atomic \
  162.   $(SDK_ROOT)/components/libraries/atomic_fifo \
  163.   $(SDK_ROOT)/components/libraries/balloc \
  164.   $(SDK_ROOT)/components/libraries/block_dev \
  165.   $(SDK_ROOT)/components/libraries/block_dev/sdc \
  166.   $(SDK_ROOT)/components/libraries/bsp \
  167.   $(SDK_ROOT)/components/libraries/button \
  168.   $(SDK_ROOT)/components/libraries/cli \
  169.   $(SDK_ROOT)/components/libraries/crc16 \
  170.   $(SDK_ROOT)/components/libraries/crc32 \
  171.   $(SDK_ROOT)/components/libraries/csense \
  172.   $(SDK_ROOT)/components/libraries/csense_drv \
  173.   $(SDK_ROOT)/components/libraries/ecc \
  174.   $(SDK_ROOT)/components/libraries/experimental_log \
  175.   $(SDK_ROOT)/components/libraries/experimental_log/src \
  176.   $(SDK_ROOT)/components/libraries/experimental_memobj \
  177.   $(SDK_ROOT)/components/libraries/experimental_section_vars \
  178.   $(SDK_ROOT)/components/libraries/fds \
  179.   $(SDK_ROOT)/components/libraries/fifo \
  180.   $(SDK_ROOT)/components/libraries/fstorage \
  181.   $(SDK_ROOT)/components/libraries/gpiote \
  182.   $(SDK_ROOT)/components/libraries/hardfault \
  183.   $(SDK_ROOT)/components/libraries/hci \
  184.   $(SDK_ROOT)/components/libraries/led_softblink \
  185.   $(SDK_ROOT)/components/libraries/low_power_pwm \
  186.   $(SDK_ROOT)/components/libraries/mem_manager \
  187.   $(SDK_ROOT)/components/libraries/mutex \
  188.   $(SDK_ROOT)/components/libraries/pwr_mgmt \
  189.   $(SDK_ROOT)/components/libraries/queue \
  190.   $(SDK_ROOT)/components/libraries/scheduler \
  191.   $(SDK_ROOT)/components/libraries/scheduler \
  192.   $(SDK_ROOT)/components/libraries/sdcard \
  193.   $(SDK_ROOT)/components/libraries/slip \
  194.   $(SDK_ROOT)/components/libraries/strerror \
  195.   $(SDK_ROOT)/components/libraries/timer \
  196.   $(SDK_ROOT)/components/libraries/twi \
  197.   $(SDK_ROOT)/components/libraries/twi_mngr \
  198.   $(SDK_ROOT)/components/libraries/uart \
  199.   $(SDK_ROOT)/components/libraries/usbd \
  200.   $(SDK_ROOT)/components/libraries/usbd/class/audio \
  201.   $(SDK_ROOT)/components/libraries/usbd/class/cdc \
  202.   $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \
  203.   $(SDK_ROOT)/components/libraries/usbd/class/hid \
  204.   $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \
  205.   $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \
  206.   $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \
  207.   $(SDK_ROOT)/components/libraries/usbd/class/msc \
  208.   $(SDK_ROOT)/components/libraries/usbd/config \
  209.   $(SDK_ROOT)/components/libraries/util \
  210.   $(SDK_ROOT)/components/softdevice/common \
  211.   $(SDK_ROOT)/components/softdevice/s132/headers \
  212.   $(SDK_ROOT)/components/softdevice/s132/headers/nrf52 \
  213.   $(SDK_ROOT)/components/toolchain \
  214.   $(SDK_ROOT)/components/toolchain/cmsis/include \
  215.   $(SDK_ROOT)/components/toolchain/gcc \
  216.   $(SDK_ROOT)/external/fatfs/port \
  217.   $(SDK_ROOT)/external/fatfs/src \
  218.   $(SDK_ROOT)/external/fprintf \
  219.   $(SDK_ROOT)/external/protothreads \
  220.   $(SDK_ROOT)/external/protothreads/pt-1.4 \
  221.   $(SDK_ROOT)/external/segger_rtt \
  222.  
  223. # Libraries common to all targets
  224. LIB_FILES += \
  225.  
  226. # Optimization flags
  227. OPT = -O0 -g3
  228. # Uncomment the line below to enable link time optimization (powoduje błędy)
  229. # OPT += -flto
  230.  
  231. # C flags common to all targets
  232. CFLAGS += $(OPT)
  233. CFLAGS += $(BOARD_FLAG)
  234. CFLAGS += -DCONFIG_GPIO_AS_PINRESET
  235. CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS # Pins 9 and 10 as GPIO
  236. CFLAGS += -DFLOAT_ABI_HARD
  237. CFLAGS += -DNRF52
  238. CFLAGS += -DNRF52832_XXAA
  239. CFLAGS += -DNRF52_PAN_74
  240. CFLAGS += -DNRF_SD_BLE_API_VERSION=5
  241. CFLAGS += -DS132
  242. CFLAGS += -DSOFTDEVICE_PRESENT
  243. CFLAGS += -DSWI_DISABLE0
  244. CFLAGS += -mcpu=cortex-m4
  245. CFLAGS += -mthumb -mabi=aapcs
  246. # CFLAGS +=  -Wall -Werror
  247. CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  248. # keep every function in a separate section, this allows linker to discard unused ones
  249. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  250. CFLAGS += -fno-builtin -fshort-enums
  251. CFLAGS += -DSET_CLOCK=$(SET_CLOCK)
  252. CFLAGS += -DCOWDEVICE_NO=$(COWDEVICE_NO)
  253. CFLAGS += -DUSE_SD_CARD=$(USE_SD_CARD)
  254. CFLAGS += -DHIGH_MEASURE=$(HIGH_MEASURE)
  255. # enable colors in gcc output
  256. CFLAGS += -fdiagnostics-color
  257.  
  258. # C++ flags common to all targets
  259. CXXFLAGS += $(OPT)
  260.  
  261. # Assembler flags common to all targets
  262. ASMFLAGS += -g3
  263. ASMFLAGS += -mcpu=cortex-m4
  264. ASMFLAGS += -mthumb -mabi=aapcs
  265. ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  266. ASMFLAGS += $(BOARD_FLAG)
  267. ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
  268. ASMFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS # Pin 9 and 10 as GPIO
  269. ASMFLAGS += -DFLOAT_ABI_HARD
  270. ASMFLAGS += -DNRF52
  271. ASMFLAGS += -DNRF52832_XXAA
  272. ASMFLAGS += -DNRF52_PAN_74
  273. ASMFLAGS += -DNRF_SD_BLE_API_VERSION=5
  274. ASMFLAGS += -DS132
  275. ASMFLAGS += -DSOFTDEVICE_PRESENT
  276. ASMFLAGS += -DSWI_DISABLE0
  277.  
  278. # Linker flags
  279. LDFLAGS += $(OPT)
  280. LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
  281. LDFLAGS += -mcpu=cortex-m4
  282. LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  283. # let linker dump unused sections
  284. LDFLAGS += -Wl,--gc-sections
  285. # use newlib in nano version
  286. LDFLAGS += --specs=nano.specs
  287.  
  288.  
  289. # Add standard libraries at the very end of the linker input, after all objects
  290. # that may need symbols provided by these libraries.
  291. LIB_FILES += -lc -lnosys -lm
  292.  
  293.  
  294. .PHONY: default help
  295.  
  296. # Default target - first one defined
  297. default: nrf52832_xxaa
  298.  
  299. # Print all targets that can be built
  300. help:
  301.     @echo following targets are available:
  302.     @echo       nrf52832_xxaa
  303.     @echo       flash_softdevice
  304.     @echo       sdk_config - starting external tool for editing sdk_config.h
  305.     @echo       flash      - flashing binary
  306.     @echo   erase      - erase the nRF52 program memory
  307.     @echo   reset      - resets the nRF52 chip
  308.     @echo   verify     - verify outputed hex file with memory content of nRF52 chip
  309.  
  310. TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
  311.  
  312.  
  313. include $(TEMPLATE_PATH)/Makefile.common
  314.  
  315. $(foreach target, $(TARGETS), $(call define_target, $(target)))
  316.  
  317. .PHONY: flash flash_softdevice erase verify
  318.  
  319. # Flash the program
  320. flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
  321.     @echo Flashing: $<
  322.     $(NRFJPROG) -f nrf52 --program $< --sectorerase
  323.     $(NRFJPROG) -f nrf52 --reset
  324.  
  325. # Flash softdevice
  326. flash_softdevice:
  327.     @echo Flashing: s132_nrf52_5.0.0_softdevice.hex
  328.     $(NRFJPROG) -f nrf52 --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_5.0.0_softdevice.hex --sectorerase
  329.     $(NRFJPROG) -f nrf52 --reset
  330.  
  331. erase:
  332.     $(NRFJPROG) -f nrf52 --eraseall
  333.  
  334. SDK_CONFIG_FILE := ./sdk_config.h
  335. CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
  336. sdk_config:
  337.     java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)
  338.  
  339. reset:
  340.     $(NRFJPROG) -f nrf52 --reset
  341.  
  342. verify:
  343.     @echo Verifying: $<
  344.     $(NRFJPROG) -f nrf52 --verify $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement