Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ set(TINYUSB_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)
set(UF2CONV_PY ${CMAKE_CURRENT_LIST_DIR}/lib/uf2/utils/uf2conv.py)
set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c)

if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
endif ()

#-------------------
# Bootloader
#-------------------
Expand Down Expand Up @@ -131,7 +135,6 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_include_directories(bootloader PUBLIC
lib/SEGGER_RTT/RTT
)

target_compile_definitions(bootloader PUBLIC
CFG_DEBUG
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
Expand Down Expand Up @@ -175,6 +178,7 @@ target_compile_options(bootloader PUBLIC
)
target_compile_definitions(bootloader PUBLIC
SOFTDEVICE_PRESENT
CONFIG_GPIO_AS_PINRESET
)

if (TRACE_ETM STREQUAL "1")
Expand Down Expand Up @@ -333,4 +337,11 @@ add_custom_target(flash-mbr

add_custom_target(flash-erase
COMMAND ${NRFJPROG} -f nrf52 --eraseall
)
)

# flash skip crc magic ( app valid = 0x0001, crc = 0x0000 )
#add_custom_target(flash-skip-crc
# #COMMAND ${NRFJPROG} --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f nrf52
# COMMAND ${NRFJPROG} --memwr 0xFF000 --val 0x00000001 -f nrf52
# #COMMAND ${NRFJPROG} --memwr 0x7F000 --val 0x00000001 -f nrf52
# )
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,20 @@ You must have have a J-Link available to "unbrick" your device.

### Build:

Firstly clone this repo with following commands
Firstly clone this repo including its submodules with following command:

```
git clone --recurse-submodules https://github.com/adafruit/Adafruit_nRF52_Bootloader
```

For git versions before `2.13.0` you have to do that manually:
```
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
cd Adafruit_nRF52_Bootloader
git submodule update --init
```

#### Build using `make`
Then build it with `make BOARD={board} all`, for example:

```
Expand All @@ -137,6 +143,37 @@ Supported boards are: feather_nrf52840_express feather_nrf52840_express pca10056
Makefile:90: *** BOARD not defined. Stop
```

#### Build using `cmake`

Firstly initialize your build environment by passing your board to `cmake` via `-DBOARD={board}`:

```bash
mkdir build
cd build
cmake .. -DBOARD=feather_nrf52840_express
```

And then build it with:

```bash
make
```

You can also use the generator of your choice. For example adding the `-GNinja` and then you can invoke `ninja build` instead of `make`.

To list all supported targets, run:

```bash
cmake --build . --target help
```

To build individual targets, you can specify it directly with `make` or using `cmake --build`:

```bash
make bootloader
cmake --build . --target bootloader
```

### Flash

To flash the bootloader (without softdevice/mbr) using JLink:
Expand Down