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
4 changes: 4 additions & 0 deletions .editorconfig-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"loader/blobs/",
"llext-edk/",
"extra/build.sh",
"extra/bootstrap.sh",
"extra/package_tool.sh",
"\\.github/workflows/package_core\\.yml",
"\\.github/workflows/package_tool\\.yml",
"loader/CMakeLists.txt",
"^CMakeLists\\.txt$"
]
Expand Down
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ updates:
schedule:
interval: "weekly"

- package-ecosystem: "gomod"
directory: "/tools/mcumgr"
schedule:
interval: "weekly"

- package-ecosystem: "gomod"
directory: "/tools/sync-zephyr-artifacts"
schedule:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/package_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,12 @@ jobs:
grep -i "warning:" $REPORT.stdout > $REPORT.warnings || true

# extract the memory usage table (from the header to the first non-% line)
# There is one table per image with sysbuild, so skip the MCUboot one.
# override the size of the Flash with the size of the loader partition
# and add the size of the sketch partition (not reported by Zephyr)
LOADER_SIZE=$(( $(cat variants/${{ matrix.variant }}/syms-static.ld | grep '_loader_max_size' | cut -d '=' -f 2 | tr -d ') ;') ))
SKETCH_SIZE=$(( $(cat variants/${{ matrix.variant }}/syms-static.ld | grep '_sketch_max_size' | cut -d '=' -f 2 | tr -d ') ;') ))
cat $REPORT.stdout | sed -n '/^Memory region/,/^[^%]*$/p' | head -n -1 \
cat $REPORT.stdout | awk '/^Memory region/ {t=""; f=1; next} f && /%/ {t=t $0 "\n"; next} f {f=0; if ($0 !~ /\/mcuboot\//) printf "%s", t}' \
Comment thread
srcnert marked this conversation as resolved.
| awk 'BEGIN {split("B KB MB GB", u); for(i in u) m[u[i]]=1024^(i-1)} /:/ {print "[\"" $1 "\"," $2*m[$3] "," $4*m[$5] "]"}' \
| sort \
| jq -s "map((select(.[0] == \"FLASH:\") | .[2]) |= ${LOADER_SIZE}) + [ [ \"SKETCH:\", 0, ${SKETCH_SIZE} ] ]" > $REPORT.meminfo
Expand All @@ -245,7 +246,7 @@ jobs:
ls reports/* >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

# Preprare an archive of the built binaries (and build dir on failure)
# Prepare an archive of the built binaries (and build dir on failure)
[ "${{ job.status }}" == "failure" ] && FULL_BUILD_DIR="build/${{ matrix.variant }}/"
sed -e '/^#/d' boards.local.txt > boards.local_${{ matrix.variant }}.txt
tar chf - \
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/package_tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ jobs:
build-tool:
name: Build ${{ matrix.tool }} ${{ matrix.version }}
needs: setup
runs-on: ubuntu-latest
# MCUmgr's macOS binaries need cgo, so they cannot be cross-compiled on Linux.
runs-on: ${{ matrix.tool == 'mcumgr' && 'macos-latest' || 'ubuntu-latest' }}
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rak-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
run: |
mkdir -p venv/bin && touch venv/bin/activate
./extra/build.sh nrf52840dk
./extra/build.sh rak4631 --mcuboot
./extra/build.sh rak4631

- name: Build samples
# Standalone Zephyr build of the samples. The sample list comes
Expand Down
2 changes: 1 addition & 1 deletion .vscode/flash_loader.jlink
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
loadfile firmwares/mcuboot-rak4631_nrf52840.hex
loadfile firmwares/zephyr-rak4631_nrf52840.mcuboot.hex
Comment thread
srcnert marked this conversation as resolved.
loadfile firmwares/zephyr-rak4631_nrf52840.hex
r
g
Expand Down
1 change: 0 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"args": [
"${BOARD_ARD}",
// "--debug",
"--mcuboot"
],
"group": "build",
"problemMatcher": ["$gcc"]
Expand Down
14 changes: 7 additions & 7 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -795,20 +795,20 @@ rak4631.menu.baseboard.rak19007=RAK19007
rak4631.menu.baseboard.rak19007.build.extra_flags=-DWISBLOCK_BASE_19007

rak4631.build.zephyr_target=rak4631/nrf52840
rak4631.build.zephyr_args=
rak4631.build.zephyr_args=--sysbuild
rak4631.build.zephyr_hals=hal_nordic
rak4631.build.zephyr_toolchain=arm-zephyr-eabi
rak4631.build.variant=rak4631_nrf52840

rak4631.build.extra_flags=
rak4631.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
rak4631.build.board=RAK4631
rak4631.vid.0=0x1915
rak4631.pid.0=0x5300
rak4631.upload_port.0.vid=0x1915
rak4631.upload_port.0.pid=0x5300
rak4631.upload_port.1.vid=0x1915
rak4631.upload_port.1.pid=0x5301
rak4631.vid.0=0x1209
rak4631.pid.0=0x0003
rak4631.upload_port.0.vid=0x1209
rak4631.upload_port.0.pid=0x0003
rak4631.upload_port.1.vid=0x1209
rak4631.upload_port.1.pid=0x0004
rak4631.upload.target=nrf52840

rak4631.upload.tool=mcumgr
Expand Down
8 changes: 0 additions & 8 deletions cores/arduino/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,7 @@ void __attribute__((weak)) __loopHook(void) {

int main(void) {
#if ZARD_BOARD_HAS_SERIALUSB
/*
* Skip the auto-begin only when a shell runs on the sketch's own CDC
* port (chosen zephyr,shell-uart == cdc-acm-serial).
*/
#if !(defined(CONFIG_SHELL) && DT_HAS_CHOSEN(zephyr_shell_uart) && \
DT_SAME_NODE(DT_CHOSEN(zephyr_shell_uart), \
DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), cdc_acm_serial, 0)))
SerialUSB.begin(115200);
#endif
#endif

initVariant();
Expand Down
1 change: 1 addition & 0 deletions extra/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ west config manifest.project-filter -- "$HAL_FILTER"
west update $WEST_MODULES_CACHE "$@"
west zephyr-export
pip3 install -r ../zephyr/scripts/requirements-base.txt
pip3 install -r ../bootloader/mcuboot/scripts/requirements.txt
log_msg "endgroup"

TOOLCHAIN_VERSIONS=$(for tc in $NEEDED_TOOLCHAINS; do
Expand Down
27 changes: 11 additions & 16 deletions extra/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fi
if [ $# -eq 0 ] || [ x$1 == x"-h" ] || [ x$1 == x"--help" ]; then
cat << EOF
Usage:
$0 <arduino_board> [--debug] [--mcuboot]
$0 <arduino_board> [--debug]
$0 <zephyr_board> [<west_args>]
Build the loader for the given target.

Expand Down Expand Up @@ -60,21 +60,15 @@ if ! [ -z "$chosen_board" ]; then
fi
upload_offset=$(jq -cr '.upload_offset' <<< "$chosen_board")

# Check for debug and mcuboot flags and append
for opt in "${@:2}"; do
case "$opt" in
--debug) debug=1 ;;
--mcuboot) mcuboot=1 ;;
*) echo "Unknown option: $opt"; exit 1 ;;
esac
done

# Boards with '--sysbuild' in their zephyr_args boot the loader through MCUboot
conf=""
if [ -n "$mcuboot" ]; then
args+=(--sysbuild)
if [[ " ${args[*]} " == *" --sysbuild "* ]]; then
Comment thread
srcnert marked this conversation as resolved.
mcuboot=1
conf="overlay_mcuboot.conf"
fi
if [ -n "$debug" ]; then

# Check for debug flag and append
if [ x$2 == x"--debug" ]; then
conf="${conf:+$conf;}../extra/debug.conf"
fi
if [ -n "$conf" ]; then
Expand Down Expand Up @@ -150,7 +144,7 @@ IMG=${LOADER_DIR}/zephyr/zephyr
if [ -n "$mcuboot" ]; then
for ext in bin hex; do
if [ ! -f $IMG.signed.$ext ]; then
echo "error: --mcuboot build produced no $IMG.signed.$ext" >&2
echo "error: MCUboot build produced no $IMG.signed.$ext" >&2
exit 1
fi
done
Expand All @@ -165,9 +159,10 @@ for ext in elf bin hex uf2; do
fi
done
done
rm -f firmwares/mcuboot-$variant.hex
# named zephyr-$variant.* so that package_core.sh ships it with the core
rm -f firmwares/zephyr-$variant.mcuboot.hex
if [ -n "$mcuboot" ]; then
cp ${BUILD_DIR}/mcuboot/zephyr/zephyr.hex firmwares/mcuboot-$variant.hex
cp ${BUILD_DIR}/mcuboot/zephyr/zephyr.hex firmwares/zephyr-$variant.mcuboot.hex
fi
cp ${LOADER_DIR}/zephyr/zephyr.dts firmwares/zephyr-$variant.dts
cp ${LOADER_DIR}/zephyr/.config firmwares/zephyr-$variant.config
Expand Down
33 changes: 5 additions & 28 deletions extra/debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,18 @@ CONFIG_THREAD_MONITOR=y
CONFIG_THREAD_NAME=y
CONFIG_DEBUG_THREAD_INFO=y

# Keep optimizing for size.
CONFIG_SIZE_OPTIMIZATIONS=y
# Disable compiler optimizations
#CONFIG_DEBUG_OPTIMIZATIONS=y

# Enable and configure the shell
CONFIG_SHELL=y
CONFIG_SHELL_BACKEND_SERIAL=y
CONFIG_SHELL_BACKEND_SERIAL_CHECK_DTR=y
CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL_NONE=y
# Print log messages into the shell session if debug port cannot print logs.
# The shell backend is DTR-gated, so nothing is emitted discarded before a
# terminal attaches.
#CONFIG_NET_SHELL=y
#CONFIG_NET_L2_WIFI_SHELL=y
CONFIG_SHELL_LOG_BACKEND=n
CONFIG_SHELL_STACK_SIZE=8192
CONFIG_LOG_BACKEND_UART_AUTOSTART=n
CONFIG_LOG_BACKEND_UART_AUTOSTART=y
Comment thread
srcnert marked this conversation as resolved.
Comment thread
srcnert marked this conversation as resolved.
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_REBOOT=y
CONFIG_LORA_SHELL=y

# Enable runtime statistics
CONFIG_SYS_HEAP_RUNTIME_STATS=y
CONFIG_THREAD_RUNTIME_STATS=y
Comment thread
srcnert marked this conversation as resolved.

# Logging
# Keep the whole USB path quiet
CONFIG_USBD_CDC_ACM_LOG_LEVEL_OFF=y
CONFIG_UDC_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USBD_LOG_LEVEL_ERR=y
CONFIG_NRF_USBD_COMMON_LOG_LEVEL_OFF=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_RUNTIME_FILTERING=n
CONFIG_LOG_BUFFER_SIZE=4096
# Buffer log messages and send them from the log thread instead of the
# without sending directly; drops on overflow rather than blocking, so verbose
# logging cannot deadlock the CDC-ACM console it is routed through
CONFIG_LOG_MODE_DEFERRED=y
# Enabled log modules
CONFIG_LORA_LOG_LEVEL_INF=y
CONFIG_LORAWAN_LOG_LEVEL_DBG=y
11 changes: 8 additions & 3 deletions extra/package_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ hash_file() {
plat=$1
file=$2
name=$(basename $file)
hash=$(sha256sum $file | cut -d ' ' -f 1)
len=$(stat -c %s $file)
hash=$(shasum -a 256 $file | cut -d ' ' -f 1)
len=$(wc -c < $file | tr -d ' ')
cat << EOF
{
"host": "$plat",
Expand Down Expand Up @@ -55,9 +55,14 @@ build_for_arch() {
local build_file="$TOOL_NAME$app_ext"
local package_file="$tool_stem-$plat$pkg_ext"

# The macOS binaries of MCUmgr need cgo, which Go only enables for the
# native target: force it on for both macOS targets when the host is a Mac
local cgo_env=""
[ "$os" == "darwin" ] && [ "$(uname)" == "Darwin" ] && cgo_env="CGO_ENABLED=1"

echo "Building $TOOL_NAME for $os/$arch ($plat)"
mkdir -p "$build_dir"
(cd $TOOL_DIR && GOOS="$os" GOARCH="$arch" go build -o "$build_dir/$build_file")
(cd $TOOL_DIR && env $cgo_env GOOS="$os" GOARCH="$arch" go build -o "$build_dir/$build_file")
(cd "$tool_stem" && $pkg_cmd "$package_file" $plat/)
hash_file $plat "$package_file" > $build_dir.json
}
Expand Down
15 changes: 10 additions & 5 deletions extra/rak/checkall.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ def _build_checks(board):
if not variant or not target:
log.die(f"Board '{board}' not found in boards.txt / boards.local.txt")

# Boards with --sysbuild in their zephyr_args boot through MCUboot (see
# extra/build.sh); the loader is then one image among several and has
# its own build directory, which is where compile_commands.json lives.
zephyr_args = utils.board_property(board, "build.zephyr_args") or ""
build_dir = f"build/{variant}"
if "--sysbuild" in zephyr_args.split():
Comment thread
srcnert marked this conversation as resolved.
build_dir += "/loader"

return [
(f"loader build ({board})", ["./extra/build.sh", board, "--mcuboot"]),
(
"cppcheck static analysis",
["west", "rak-lint", "-b", f"build/{variant}/loader"],
),
(f"loader build ({board})", ["./extra/build.sh", board]),
("cppcheck static analysis", ["west", "rak-lint", "-b", build_dir]),
(f"sketch compilation ({board})", ["west", "rak-sketch-check", "-b", board]),
(f"sample build ({target})", ["west", "rak-sample-check", "-b", target]),
]
Expand Down
2 changes: 1 addition & 1 deletion extra/rak/license_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}

# Never checked, matched by exact file name (dotfiles have no suffix).
IGNORE_NAMES = {".gitignore", "VERSION"}
IGNORE_NAMES = {".gitignore", "VERSION", "dependabot.yml"}
# Checked even though their suffix is ignored.
SOURCE_NAMES = {"CMakeLists.txt"}

Expand Down
3 changes: 1 addition & 2 deletions loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ cmake_minimum_required(VERSION 3.20.0)

# get value of NORMALIZED_BOARD_TARGET early
# 'basic_settings' must load before 'boards' so the board lookup works under
# sysbuild: it creates the sysbuild_cache target that the boards module reads.
# It is a no-op in a non-sysbuild build, so plain builds are unaffected.
# sysbuild.
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS basic_settings yaml boards)

set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
Expand Down
Loading
Loading