summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorroot <root@lamia.panaceas.james.local>2015-08-31 10:29:39 +0100
committerroot <root@lamia.panaceas.james.local>2015-08-31 10:29:39 +0100
commit261436d22bc93338e08e67956a47142e3b0d5086 (patch)
treee8bac65ae594560000a1030ce33f21586d117d84 /Makefile
downloadbootloader-261436d22bc93338e08e67956a47142e3b0d5086.tar.gz
bootloader-261436d22bc93338e08e67956a47142e3b0d5086.tar.bz2
bootloader-261436d22bc93338e08e67956a47142e3b0d5086.zip
working copy of sdks dfu bootloaderdualbank
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile169
1 files changed, 169 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..721f452
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,169 @@
+PROG=main
+
+DEFINES =
+DEFINES += -DSWI_DISABLE0
+#DEFINES += -DBOARD_PCA10028
+DEFINES += -DBOARD_BLE400
+DEFINES += -DSOFTDEVICE_PRESENT
+DEFINES += -DNRF51
+DEFINES += -D__HEAP_SIZE=0
+DEFINES += -DS130
+DEFINES += -DBLE_STACK_SUPPORT_REQD
+DEFINES += -DBSP_DEFINES_ONLY
+
+CFLAGS=-Os
+LDFLAGS=
+ASFLAGS=
+INCLUDES=
+
+SDK=sdk-9.0.0
+
+SDKCSRCS= \
+ libraries/util/app_error.c \
+ libraries/scheduler/app_scheduler.c \
+ libraries/timer/app_timer.c \
+ libraries/timer/app_timer_appsh.c \
+ libraries/bootloader_dfu/bootloader.c \
+ libraries/bootloader_dfu/bootloader_settings.c \
+ libraries/bootloader_dfu/bootloader_util.c \
+ libraries/crc16/crc16.c \
+ libraries/bootloader_dfu/dfu_dual_bank.c \
+ libraries/bootloader_dfu/dfu_init_template.c \
+ libraries/bootloader_dfu/dfu_transport_ble.c \
+ libraries/hci/hci_mem_pool.c \
+ libraries/util/nrf_assert.c \
+ drivers_nrf/hal/nrf_delay.c \
+ drivers_nrf/pstorage/pstorage_raw.c \
+ ble/common/ble_advdata.c \
+ ble/common/ble_conn_params.c \
+ ble/ble_services/ble_dfu/ble_dfu.c \
+ ble/common/ble_srv_common.c \
+ toolchain/system_nrf51.c \
+ softdevice/common/softdevice_handler/softdevice_handler.c \
+ softdevice/common/softdevice_handler/softdevice_handler_appsh.c \
+
+SDKSSRCS = toolchain/gcc/gcc_startup_nrf51.s
+
+
+CSRCS = \
+ dfu_ble_svc.c \
+ main.c
+
+
+SOFTDEVICE=${SDK}/sdk/softdevice/s130/hex/s130_softdevice.hex
+
+LINKER_SCRIPT=dfu_gcc_nrf51.ld #sdk/toolchain/gcc/s130.ld
+
+INCLUDES += -Isdk-config -I${SDK} -I.
+#INCLUDES += -Iconfig
+
+OOCD=openocd
+OOCD_CFG=openocd.cfg
+
+
+CROSS=arm-none-eabi-
+CC := $(CROSS)gcc
+AS := $(CROSS)as
+AR := $(CROSS)ar
+LD := $(CROSS)ld
+NM := $(CROSS)nm
+OBJDUMP := $(CROSS)objdump
+OBJCOPY := $(CROSS)objcopy
+SIZE := $(CROSS)size
+GDB := $(CROSS)gdb
+
+
+CFLAGS += -mcpu=cortex-m0
+CFLAGS += -mthumb -mabi=aapcs --std=gnu99
+CFLAGS += -Wall -Werror -Os
+CFLAGS += -mfloat-abi=soft
+# keep every function in separate section. This will allow linker to dump unused functions
+CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
+CFLAGS += -fno-builtin --short-enums
+
+# keep every function in separate section. This will allow linker to dump unused functions
+LDFLAGS += -Xlinker -Map=$(PROG).map
+LDFLAGS += -mthumb -mabi=aapcs -L${SDK} -T$(LINKER_SCRIPT)
+LDFLAGS += -mcpu=cortex-m0
+# let linker to dump unused sections
+LDFLAGS += -Wl,--gc-sections
+# use newlib in nano version
+#LDFLAGS += --specs=nano.specs -lc -lnosys
+LIBS += -lc -lnosys
+
+# Assembler flags
+ASFLAGS += -x assembler-with-cpp
+
+CPPFLAGS=$(DEFINES) $(INCLUDES)
+
+
+OBJS=${CSRCS:%.c=%.o} ${SDKCSRCS:%.c=${SDK}/sdk/%.o} ${SDKSSRCS:%.s=${SDK}/sdk/%.o}
+
+default: ${PROG}.bin ${PROG}.hex
+
+clean:
+ /bin/rm -f ${OBJS} ${PROG} ${PROG}.bin ${PROG}.hex
+
+${PROG}:${OBJS}
+ $(CC) $(LDFLAGS) $(CFLAGS) $(OBJS) $(LIBS) -o $@
+ $(SIZE) $@
+
+%.bin:%
+ $(OBJCOPY) -O binary $< $@
+%.hex:%
+ $(OBJCOPY) -O ihex $< $@
+
+
+twongle.o:twongle.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+
+%.o:%.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+
+%.o:%.s
+ $(CC) $(CPPFLAGS) $(ASFLAGS) -c -o $@ $<
+
+
+flash: ${PROG}.hex
+ ${OOCD} -f ${OOCD_CFG} \
+ -c "init" -c "reset init" \
+ -c "flash write_image erase $<" \
+ -c "reset" \
+ -c "shutdown"
+
+
+
+flash_softdevice: ${SOFTDEVICE}
+ ${OOCD} -f ${OOCD_CFG} \
+ -c "init" -c "reset init" \
+ -c "nrf51 mass_erase" \
+ -c "flash write_image erase $<" \
+ -c "reset" \
+ -c "shutdown"
+
+flashall: ${SOFTDEVICE} ${PROG}.hex
+ ${OOCD} -f ${OOCD_CFG} \
+ -c "init" -c "reset init" \
+ -c "nrf51 mass_erase" \
+ -c "flash write_image ${SOFTDEVICE}" \
+ -c "flash write_image ${PROG}.hex" \
+ -c "reset" \
+ -c "shutdown"
+
+
+ds:
+ $(OOCD) -f $(OOCD_CFG)
+
+debug: ${PROG}
+ ${GDB} -x gdb.script ${PROG}
+
+
+
+#flash: $(MAKECMDGOALS)
+# @echo Flashing: $(OUTPUT_BINARY_DIRECTORY)/$<.hex
+# nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/$<.hex
+#
+### Flash softdevice
+#flash_softdevice:
+# @echo Flashing: s130_softdevice.hex
+# nrfjprog --reset --program softdevice/s130/hex/s130_softdevice.hex