Start working on nRF52 firmware; copy code from https://github.com/jbentham/nrf_test
This commit is contained in:
parent
c19b86f7ea
commit
8a8f0cf915
|
@ -0,0 +1,74 @@
|
|||
# Build Nordic NRF52832 example
|
||||
|
||||
TARGET := nrf52-fw.elf
|
||||
HEXFILE := $(TARGET:.elf=.hex)
|
||||
BUILD_DIR := build
|
||||
SDK := ./nrf5_sdk
|
||||
PROJ := $(CURDIR)
|
||||
LINKER_SCRIPT := nrf52_test.ld
|
||||
OPTIMISE := -O3
|
||||
|
||||
GCC := arm-none-eabi-gcc
|
||||
OBJCOPY := arm-none-eabi-objcopy
|
||||
OBJSIZE := arm-none-eabi-size
|
||||
|
||||
HEAP_SIZE := 8192
|
||||
STACK_SIZE := 8192
|
||||
|
||||
SRC_FILES += $(SDK)/modules/nrfx/mdk/gcc_startup_nrf52.S
|
||||
SRC_FILES += $(SDK)/modules/nrfx/mdk/system_nrf52.c
|
||||
SRC_FILES += $(PROJ)/main.c
|
||||
|
||||
SRC_DIRS := $(dir $(SRC_FILES))
|
||||
SRCES := $(notdir $(SRC_FILES))
|
||||
OBJECTS := $(SRCES:=.o)
|
||||
OBJ_FILES := $(addprefix $(BUILD_DIR)/,$(OBJECTS))
|
||||
|
||||
INC_FOLDERS += $(PROJ)
|
||||
INC_FOLDERS += $(SDK)/modules/nrfx $(SDK)/modules/nrfx/mdk
|
||||
INC_FOLDERS += $(SDK)/modules/nrfx/hal
|
||||
INC_FOLDERS += $(SDK)/components/libraries/strerror $(SDK)/components/toolchain/cmsis/include
|
||||
INC_FOLDERS += $(SDK)/components/libraries/util $(SDK)/components/libraries/balloc
|
||||
INC_FOLDERS += $(SDK)/components/libraries/ringbuf $(SDK)/components/libraries/bsp
|
||||
INC_FOLDERS += $(SDK)/components/libraries/log $(SDK)/components/libraries/experimental_section_vars
|
||||
INC_FOLDERS += $(SDK)/components/libraries/delay $(SDK)/components/drivers_nrf/nrf_soc_nosd
|
||||
INC_FOLDERS += $(SDK)/components/libraries/atomic $(SDK)/components/boards
|
||||
INC_FOLDERS += $(SDK)/components/libraries/memobj $(SDK)/components/libraries/log/src
|
||||
INC_FOLDERS += $(SDK)/external/fprintf $(SDK)/integration/nrfx
|
||||
|
||||
CFLAGS += -std=c99 -MP -MD -c -g3 $(OPTIMISE)
|
||||
CFLAGS += -DBOARD_CUSTOM -DBSP_DEFINES_ONLY -DCONFIG_GPIO_AS_PINRESET -DFLOAT_ABI_HARD -DNRF52 -DNRF52832_XXAA -DNRF52_PAN_74
|
||||
CFLAGS += -mcpu=cortex-m4 -mthumb -mabi=aapcs -Wall -Werror -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections
|
||||
CFLAGS += -fno-strict-aliasing -fno-builtin -fshort-enums -D__HEAP_SIZE=$(HEAP_SIZE) -D__STACK_SIZE=$(STACK_SIZE)
|
||||
|
||||
LNFLAGS += -O3 -g3 -mthumb -mabi=aapcs -L$(SDK)/modules/nrfx/mdk -T$(LINKER_SCRIPT) -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
LNFLAGS += -Wl,--gc-sections --specs=nano.specs
|
||||
LNFLAGS2 += -Wl,-Map=build/blinky.map -lc -lnosys -lm
|
||||
|
||||
VPATH := $(SRC_DIRS)
|
||||
|
||||
$(BUILD_DIR)/$(TARGET): $(OBJ_FILES)
|
||||
@echo Linking $@
|
||||
@$(GCC) $(LNFLAGS) -o $@ $^ $(LNFLAGS2)
|
||||
@$(OBJCOPY) -O ihex $(BUILD_DIR)/$(TARGET) $(BUILD_DIR)/$(HEXFILE)
|
||||
@$(OBJCOPY) -O binary $(BUILD_DIR)/$(TARGET) $(BUILD_DIR)/$(TARGET:.elf=.bin)
|
||||
@$(OBJSIZE) $(BUILD_DIR)/$(TARGET)
|
||||
|
||||
$(BUILD_DIR)/%.c.o: %.c
|
||||
@echo Compiling $<
|
||||
@$(GCC) $(CFLAGS) -o $@ $< $(addprefix -I,$(INC_FOLDERS))
|
||||
|
||||
$(BUILD_DIR)/%.S.o: %.S
|
||||
@echo Assembling $<
|
||||
@$(GCC) $(CFLAGS) -o $@ $<
|
||||
|
||||
jflash: $(BUILD_DIR)/$(TARGET)
|
||||
@echo Flashing $(HEXFILE)
|
||||
nrfjprog --program $(BUILD_DIR)/$(HEXFILE) --sectorerase
|
||||
nrfjprog --reset
|
||||
|
||||
ocdflash: $(BUILD_DIR)/$(TARGET)
|
||||
sudo openocd -f ../openocd/rpi2.cfg -f ../openocd/nrf52_swd.cfg -c "program $(BUILD_DIR)/$(TARGET) verify reset exit"
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#include "nrf_gpio.h"
|
||||
#include "nrf_delay.h"
|
||||
|
||||
// LED definitions
|
||||
#define LED_PIN 7
|
||||
#define LED_BIT (1 << LED_PIN)
|
||||
|
||||
int main(void) {
|
||||
nrf_gpio_cfg_output(LED_PIN);
|
||||
while (1) {
|
||||
nrf_delay_ms(500);
|
||||
NRF_GPIO->OUT ^= LED_BIT;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue