Skip to content

Commit 0e98348

Browse files
authored
Merge pull request #354 from andreaskurz/askz/fix-cmake-build
fix: CMake build producing too large binaries
2 parents a48e944 + 70da7d8 commit 0e98348

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ set(TINYUSB_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)
3434
set(UF2CONV_PY ${CMAKE_CURRENT_LIST_DIR}/lib/uf2/utils/uf2conv.py)
3535
set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c)
3636

37+
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
38+
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
39+
endif ()
40+
3741
#-------------------
3842
# Bootloader
3943
#-------------------
@@ -131,7 +135,6 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
131135
target_include_directories(bootloader PUBLIC
132136
lib/SEGGER_RTT/RTT
133137
)
134-
135138
target_compile_definitions(bootloader PUBLIC
136139
CFG_DEBUG
137140
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
@@ -175,6 +178,7 @@ target_compile_options(bootloader PUBLIC
175178
)
176179
target_compile_definitions(bootloader PUBLIC
177180
SOFTDEVICE_PRESENT
181+
CONFIG_GPIO_AS_PINRESET
178182
)
179183

180184
if (TRACE_ETM STREQUAL "1")
@@ -333,4 +337,11 @@ add_custom_target(flash-mbr
333337

334338
add_custom_target(flash-erase
335339
COMMAND ${NRFJPROG} -f nrf52 --eraseall
336-
)
340+
)
341+
342+
# flash skip crc magic ( app valid = 0x0001, crc = 0x0000 )
343+
#add_custom_target(flash-skip-crc
344+
# #COMMAND ${NRFJPROG} --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f nrf52
345+
# COMMAND ${NRFJPROG} --memwr 0xFF000 --val 0x00000001 -f nrf52
346+
# #COMMAND ${NRFJPROG} --memwr 0x7F000 --val 0x00000001 -f nrf52
347+
# )

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,20 @@ You must have have a J-Link available to "unbrick" your device.
114114
115115
### Build:
116116
117-
Firstly clone this repo with following commands
117+
Firstly clone this repo including its submodules with following command:
118118
119+
```
120+
git clone --recurse-submodules https://github.com/adafruit/Adafruit_nRF52_Bootloader
121+
```
122+
123+
For git versions before `2.13.0` you have to do that manually:
119124
```
120125
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
121126
cd Adafruit_nRF52_Bootloader
122127
git submodule update --init
123128
```
124129
130+
#### Build using `make`
125131
Then build it with `make BOARD={board} all`, for example:
126132
127133
```
@@ -137,6 +143,37 @@ Supported boards are: feather_nrf52840_express feather_nrf52840_express pca10056
137143
Makefile:90: *** BOARD not defined. Stop
138144
```
139145
146+
#### Build using `cmake`
147+
148+
Firstly initialize your build environment by passing your board to `cmake` via `-DBOARD={board}`:
149+
150+
```bash
151+
mkdir build
152+
cd build
153+
cmake .. -DBOARD=feather_nrf52840_express
154+
```
155+
156+
And then build it with:
157+
158+
```bash
159+
make
160+
```
161+
162+
You can also use the generator of your choice. For example adding the `-GNinja` and then you can invoke `ninja build` instead of `make`.
163+
164+
To list all supported targets, run:
165+
166+
```bash
167+
cmake --build . --target help
168+
```
169+
170+
To build individual targets, you can specify it directly with `make` or using `cmake --build`:
171+
172+
```bash
173+
make bootloader
174+
cmake --build . --target bootloader
175+
```
176+
140177
### Flash
141178

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

0 commit comments

Comments
 (0)