Skip to content

Commit

Permalink
Fix lighting-app build error for nrf52840dongle (#13285)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lmpprk authored and pull[bot] committed Jul 21, 2023
1 parent ca9305c commit 5631658
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 91 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/examples-nrfconnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ jobs:
nrfconnect nrf52840dk_nrf52840 lighting-app \
examples/lighting-app/nrfconnect/build/nrf52840dk_nrf52840/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: Build example nRF Connect SDK Lighting App on nRF52840 Dongle
timeout-minutes: 10
run: |
scripts/examples/nrfconnect_example.sh lighting-app nrf52840dongle_nrf52840
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
nrfconnect nrf52840dongle_nrf52840 lighting-app \
examples/lighting-app/nrfconnect/build/nrf52840dongle_nrf52840/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: Build example nRF Connect SDK Lighting App on nRF52840 DK with RPC
timeout-minutes: 10
run: |
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
# Load NCS/Zephyr build system
set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)

if (EXISTS boards/${BOARD}.conf)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
list(APPEND CONF_FILE boards/${BOARD}.conf)
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y

# Configure shell and logging over USB
CONFIG_USB=y
CONFIG_USB_UART_CONSOLE=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51

# The minimal logging mode does not work properly with the USB CDC device, so use the deferred mode
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2021 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/ {
chosen {
zephyr,shell-uart = &cdc_acm_uart0;
};
};

&zephyr_udc0 {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
label = "CDC_ACM_0";
};
};
4 changes: 2 additions & 2 deletions examples/lighting-app/nrfconnect/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "Rpc.h"
#endif

#ifdef CONFIG_USB
#ifdef CONFIG_USB_DEVICE_STACK
#include <usb/usb_device.h>
#endif

Expand All @@ -47,7 +47,7 @@ int main(void)
int ret = 0;
CHIP_ERROR err = CHIP_NO_ERROR;

#ifdef CONFIG_USB
#ifdef CONFIG_USB_DEVICE_STACK
ret = usb_enable(nullptr);
if (ret)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
# Load NCS/Zephyr build system
set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)

if (EXISTS boards/${BOARD}.conf)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
list(APPEND CONF_FILE boards/${BOARD}.conf)
endif()

Expand Down
4 changes: 4 additions & 0 deletions examples/pigweed-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ endif()
list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
list(APPEND CONF_FILE boards/${BOARD}.conf)
endif()

project(chip-nrf52840-pigweed-example)

include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake)
Expand Down
2 changes: 1 addition & 1 deletion examples/pump-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
# Load NCS/Zephyr build system
set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)

if (EXISTS boards/${BOARD}.conf)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
list(APPEND CONF_FILE boards/${BOARD}.conf)
endif()

Expand Down
2 changes: 1 addition & 1 deletion examples/pump-controller-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake)
# Load NCS/Zephyr build system
set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)

if (EXISTS boards/${BOARD}.conf)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
list(APPEND CONF_FILE boards/${BOARD}.conf)
endif()

Expand Down
4 changes: 4 additions & 0 deletions examples/shell/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf)
list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf)
list(APPEND CONF_FILE boards/${BOARD}.conf)
endif()

project(chip-nrfconnect-shell-example)

include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake)
Expand Down
9 changes: 6 additions & 3 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,13 @@ def NrfTargets():
yield target.Extend('native-posix-64-tests', board=NrfBoard.NATIVE_POSIX_64, app=NrfApp.UNIT_TESTS)

targets = [
target.Extend('nrf5340', board=NrfBoard.NRF5340),
target.Extend('nrf52840', board=NrfBoard.NRF52840),
target.Extend('nrf5340dk', board=NrfBoard.NRF5340DK),
target.Extend('nrf52840dk', board=NrfBoard.NRF52840DK),
]

# Enable nrf52840dongle for lighting app only
yield target.Extend('nrf52840dongle-light', board=NrfBoard.NRF52840DONGLE, app=NrfApp.LIGHT)

for target in targets:
yield target.Extend('lock', app=NrfApp.LOCK)
yield target.Extend('light', app=NrfApp.LIGHT)
Expand All @@ -279,7 +282,7 @@ def NrfTargets():

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

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

Expand Down
23 changes: 15 additions & 8 deletions scripts/build/builders/nrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,17 @@ def FlashBundleName(self):


class NrfBoard(Enum):
NRF52840 = auto()
NRF5340 = auto()
NRF52840DK = auto()
NRF52840DONGLE = auto()
NRF5340DK = auto()
NATIVE_POSIX_64 = auto()

def GnArgName(self):
if self == NrfBoard.NRF52840:
if self == NrfBoard.NRF52840DK:
return 'nrf52840dk_nrf52840'
elif self == NrfBoard.NRF5340:
elif self == NrfBoard.NRF52840DONGLE:
return 'nrf52840dongle_nrf52840'
elif self == NrfBoard.NRF5340DK:
return 'nrf5340dk_nrf5340_cpuapp'
elif self == NrfBoard.NATIVE_POSIX_64:
return 'native_posix_64'
Expand All @@ -105,7 +108,7 @@ def __init__(self,
root,
runner,
app: NrfApp = NrfApp.LIGHT,
board: NrfBoard = NrfBoard.NRF52840,
board: NrfBoard = NrfBoard.NRF52840DK,
enable_rpcs: bool = False):
super(NrfConnectBuilder, self).__init__(root, runner)
self.app = app
Expand Down Expand Up @@ -139,18 +142,22 @@ def generate(self):

raise Exception('ZEPHYR_BASE validation failed')

overlays = []
if self.enable_rpcs:
overlays.append("-DOVERLAY_CONFIG=rpc.overlay")

cmd = '''
source "$ZEPHYR_BASE/zephyr-env.sh";
export GNUARMEMB_TOOLCHAIN_PATH="$PW_PIGWEED_CIPD_INSTALL_DIR";
west build --cmake-only -d {outdir} -b {board} {sourcedir}{rpcs}
west build --cmake-only -d {outdir} -b {board} {sourcedir}{overlayflags}
'''.format(
outdir=shlex.quote(self.output_dir),
board=self.board.GnArgName(),
sourcedir=shlex.quote(os.path.join(
self.root, self.app.AppPath(), 'nrfconnect')),
rpcs=" -- -DOVERLAY_CONFIG=rpc.overlay" if self.enable_rpcs else ""
overlayflags=" -- " +
" ".join(overlays) if len(overlays) > 0 else ""
).strip()

self._Execute(['bash', '-c', cmd],
title='Generating ' + self.identifier)

Expand Down
25 changes: 13 additions & 12 deletions scripts/build/testdata/all_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,19 @@ mbed-CY8CPROTO_062_4343W-shell-debug (NOGLOB: Compile only for debugging purpose
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)
mbed-CY8CPROTO_062_4343W-shell-release
nrf-native-posix-64-tests
nrf-nrf52840-light
nrf-nrf52840-light-rpc
nrf-nrf52840-lock
nrf-nrf52840-pump
nrf-nrf52840-pump-controller
nrf-nrf52840-shell
nrf-nrf5340-light
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)
nrf-nrf5340-lock
nrf-nrf5340-pump
nrf-nrf5340-pump-controller
nrf-nrf5340-shell
nrf-nrf52840dk-light
nrf-nrf52840dk-light-rpc
nrf-nrf52840dk-lock
nrf-nrf52840dk-pump
nrf-nrf52840dk-pump-controller
nrf-nrf52840dk-shell
nrf-nrf52840dongle-light
nrf-nrf5340dk-light
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)
nrf-nrf5340dk-lock
nrf-nrf5340dk-pump
nrf-nrf5340dk-pump-controller
nrf-nrf5340dk-shell
qpg-qpg6100-lock
telink-tlsr9518adk80d-light
tizen-arm-light
Loading

0 comments on commit 5631658

Please sign in to comment.