Skip to content

Commit 5631658

Browse files
lmpprkpull[bot]
authored andcommitted
Fix lighting-app build error for nrf52840dongle (#13285)
* Update for building nrf52840dongle with zephyr 2.7 * Fix example script not loading the board overlays * restyle update * Use array for params avoid empty string in param * fix style * update to support nrf52840 dongle * fix for restyle * limit dongle to lighting-app target; update test data * avoid empty args; fix root path * fix CMakeList.txt isntead of fixing the scripts
1 parent ca9305c commit 5631658

File tree

15 files changed

+153
-91
lines changed

15 files changed

+153
-91
lines changed

.github/workflows/examples-nrfconnect.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ jobs:
8080
nrfconnect nrf52840dk_nrf52840 lighting-app \
8181
examples/lighting-app/nrfconnect/build/nrf52840dk_nrf52840/zephyr/zephyr.elf \
8282
/tmp/bloat_reports/
83+
- name: Build example nRF Connect SDK Lighting App on nRF52840 Dongle
84+
timeout-minutes: 10
85+
run: |
86+
scripts/examples/nrfconnect_example.sh lighting-app nrf52840dongle_nrf52840
87+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
88+
nrfconnect nrf52840dongle_nrf52840 lighting-app \
89+
examples/lighting-app/nrfconnect/build/nrf52840dongle_nrf52840/zephyr/zephyr.elf \
90+
/tmp/bloat_reports/
8391
- name: Build example nRF Connect SDK Lighting App on nRF52840 DK with RPC
8492
timeout-minutes: 10
8593
run: |

examples/lighting-app/nrfconnect/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
2626
# Load NCS/Zephyr build system
2727
set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)
2828

29-
if (EXISTS boards/${BOARD}.conf)
29+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
3030
list(APPEND CONF_FILE boards/${BOARD}.conf)
3131
endif()
3232

examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840.conf

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y
2020

2121
# Configure shell and logging over USB
22-
CONFIG_USB=y
23-
CONFIG_USB_UART_CONSOLE=y
22+
CONFIG_USB_DEVICE_STACK=y
2423
CONFIG_UART_INTERRUPT_DRIVEN=y
2524
CONFIG_UART_LINE_CTRL=y
26-
CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"
2725
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
2826

2927
# The minimal logging mode does not work properly with the USB CDC device, so use the deferred mode
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2021 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/ {
18+
chosen {
19+
zephyr,shell-uart = &cdc_acm_uart0;
20+
};
21+
};
22+
23+
&zephyr_udc0 {
24+
cdc_acm_uart0: cdc_acm_uart0 {
25+
compatible = "zephyr,cdc-acm-uart";
26+
label = "CDC_ACM_0";
27+
};
28+
};

examples/lighting-app/nrfconnect/main/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "Rpc.h"
2929
#endif
3030

31-
#ifdef CONFIG_USB
31+
#ifdef CONFIG_USB_DEVICE_STACK
3232
#include <usb/usb_device.h>
3333
#endif
3434

@@ -47,7 +47,7 @@ int main(void)
4747
int ret = 0;
4848
CHIP_ERROR err = CHIP_NO_ERROR;
4949

50-
#ifdef CONFIG_USB
50+
#ifdef CONFIG_USB_DEVICE_STACK
5151
ret = usb_enable(nullptr);
5252
if (ret)
5353
{

examples/lock-app/nrfconnect/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
2525
# Load NCS/Zephyr build system
2626
set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)
2727

28-
if (EXISTS boards/${BOARD}.conf)
28+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
2929
list(APPEND CONF_FILE boards/${BOARD}.conf)
3030
endif()
3131

examples/pigweed-app/nrfconnect/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ endif()
2929
list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module)
3030
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
3131

32+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
33+
list(APPEND CONF_FILE boards/${BOARD}.conf)
34+
endif()
35+
3236
project(chip-nrf52840-pigweed-example)
3337

3438
include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake)

examples/pump-app/nrfconnect/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
2525
# Load NCS/Zephyr build system
2626
set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)
2727

28-
if (EXISTS boards/${BOARD}.conf)
28+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
2929
list(APPEND CONF_FILE boards/${BOARD}.conf)
3030
endif()
3131

examples/pump-controller-app/nrfconnect/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
2525
# Load NCS/Zephyr build system
2626
set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)
2727

28-
if (EXISTS boards/${BOARD}.conf)
28+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
2929
list(APPEND CONF_FILE boards/${BOARD}.conf)
3030
endif()
3131

examples/shell/nrfconnect/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)
2525
list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module)
2626
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
2727

28+
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
29+
list(APPEND CONF_FILE boards/${BOARD}.conf)
30+
endif()
31+
2832
project(chip-nrfconnect-shell-example)
2933

3034
include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake)

scripts/build/build/targets.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,13 @@ def NrfTargets():
266266
yield target.Extend('native-posix-64-tests', board=NrfBoard.NATIVE_POSIX_64, app=NrfApp.UNIT_TESTS)
267267

268268
targets = [
269-
target.Extend('nrf5340', board=NrfBoard.NRF5340),
270-
target.Extend('nrf52840', board=NrfBoard.NRF52840),
269+
target.Extend('nrf5340dk', board=NrfBoard.NRF5340DK),
270+
target.Extend('nrf52840dk', board=NrfBoard.NRF52840DK),
271271
]
272272

273+
# Enable nrf52840dongle for lighting app only
274+
yield target.Extend('nrf52840dongle-light', board=NrfBoard.NRF52840DONGLE, app=NrfApp.LIGHT)
275+
273276
for target in targets:
274277
yield target.Extend('lock', app=NrfApp.LOCK)
275278
yield target.Extend('light', app=NrfApp.LIGHT)
@@ -279,7 +282,7 @@ def NrfTargets():
279282

280283
rpc = target.Extend('light-rpc', app=NrfApp.LIGHT, enable_rpcs=True)
281284

282-
if '-nrf5340-' in rpc.name:
285+
if '-nrf5340dk-' in rpc.name:
283286
rpc = rpc.GlobBlacklist(
284287
'Compile failure due to pw_build args not forwarded to proto compiler. https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66760')
285288

scripts/build/builders/nrf.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,17 @@ def FlashBundleName(self):
8484

8585

8686
class NrfBoard(Enum):
87-
NRF52840 = auto()
88-
NRF5340 = auto()
87+
NRF52840DK = auto()
88+
NRF52840DONGLE = auto()
89+
NRF5340DK = auto()
8990
NATIVE_POSIX_64 = auto()
9091

9192
def GnArgName(self):
92-
if self == NrfBoard.NRF52840:
93+
if self == NrfBoard.NRF52840DK:
9394
return 'nrf52840dk_nrf52840'
94-
elif self == NrfBoard.NRF5340:
95+
elif self == NrfBoard.NRF52840DONGLE:
96+
return 'nrf52840dongle_nrf52840'
97+
elif self == NrfBoard.NRF5340DK:
9598
return 'nrf5340dk_nrf5340_cpuapp'
9699
elif self == NrfBoard.NATIVE_POSIX_64:
97100
return 'native_posix_64'
@@ -105,7 +108,7 @@ def __init__(self,
105108
root,
106109
runner,
107110
app: NrfApp = NrfApp.LIGHT,
108-
board: NrfBoard = NrfBoard.NRF52840,
111+
board: NrfBoard = NrfBoard.NRF52840DK,
109112
enable_rpcs: bool = False):
110113
super(NrfConnectBuilder, self).__init__(root, runner)
111114
self.app = app
@@ -139,18 +142,22 @@ def generate(self):
139142

140143
raise Exception('ZEPHYR_BASE validation failed')
141144

145+
overlays = []
146+
if self.enable_rpcs:
147+
overlays.append("-DOVERLAY_CONFIG=rpc.overlay")
148+
142149
cmd = '''
143150
source "$ZEPHYR_BASE/zephyr-env.sh";
144151
export GNUARMEMB_TOOLCHAIN_PATH="$PW_PIGWEED_CIPD_INSTALL_DIR";
145-
west build --cmake-only -d {outdir} -b {board} {sourcedir}{rpcs}
152+
west build --cmake-only -d {outdir} -b {board} {sourcedir}{overlayflags}
146153
'''.format(
147154
outdir=shlex.quote(self.output_dir),
148155
board=self.board.GnArgName(),
149156
sourcedir=shlex.quote(os.path.join(
150157
self.root, self.app.AppPath(), 'nrfconnect')),
151-
rpcs=" -- -DOVERLAY_CONFIG=rpc.overlay" if self.enable_rpcs else ""
158+
overlayflags=" -- " +
159+
" ".join(overlays) if len(overlays) > 0 else ""
152160
).strip()
153-
154161
self._Execute(['bash', '-c', cmd],
155162
title='Generating ' + self.identifier)
156163

scripts/build/testdata/all_targets_except_host.txt

+13-12
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,19 @@ mbed-CY8CPROTO_062_4343W-shell-debug (NOGLOB: Compile only for debugging purpose
9797
mbed-CY8CPROTO_062_4343W-shell-develop (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html)
9898
mbed-CY8CPROTO_062_4343W-shell-release
9999
nrf-native-posix-64-tests
100-
nrf-nrf52840-light
101-
nrf-nrf52840-light-rpc
102-
nrf-nrf52840-lock
103-
nrf-nrf52840-pump
104-
nrf-nrf52840-pump-controller
105-
nrf-nrf52840-shell
106-
nrf-nrf5340-light
107-
nrf-nrf5340-light-rpc (NOGLOB: Compile failure due to pw_build args not forwarded to proto compiler. https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66760)
108-
nrf-nrf5340-lock
109-
nrf-nrf5340-pump
110-
nrf-nrf5340-pump-controller
111-
nrf-nrf5340-shell
100+
nrf-nrf52840dk-light
101+
nrf-nrf52840dk-light-rpc
102+
nrf-nrf52840dk-lock
103+
nrf-nrf52840dk-pump
104+
nrf-nrf52840dk-pump-controller
105+
nrf-nrf52840dk-shell
106+
nrf-nrf52840dongle-light
107+
nrf-nrf5340dk-light
108+
nrf-nrf5340dk-light-rpc (NOGLOB: Compile failure due to pw_build args not forwarded to proto compiler. https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66760)
109+
nrf-nrf5340dk-lock
110+
nrf-nrf5340dk-pump
111+
nrf-nrf5340dk-pump-controller
112+
nrf-nrf5340dk-shell
112113
qpg-qpg6100-lock
113114
telink-tlsr9518adk80d-light
114115
tizen-arm-light

0 commit comments

Comments
 (0)