Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mcuboot: Add bootloader support + enable sysbuild #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 23 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"configurations": [
{
"name": "ARM",
"name": "teal-caniot-device",
"compileCommands": "${workspaceRoot}/build/compile_commands.json",
"intelliSenseMode": "gcc-arm",
"browse": {
Expand All @@ -10,6 +10,28 @@
]
},
"cStandard": "c23"
},
{
"name": "teal-caniot-device (sysbuild)",
"compileCommands": "${workspaceRoot}/build/teal-caniot-device/compile_commands.json",
"intelliSenseMode": "gcc-arm",
"browse": {
"path": [
"${workspaceFolder}"
]
},
"cStandard": "c23"
},
{
"name": "mcuboot (sysbuild)",
"compileCommands": "${workspaceRoot}/build/mcuboot/compile_commands.json",
"intelliSenseMode": "gcc-arm",
"browse": {
"path": [
"${workspaceFolder}"
]
},
"cStandard": "c23"
}
],
"version": 4
Expand Down
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"recommendations": [
"xaver.clang-format",
"nordic-semiconductor.nrf-connect-extension-pack"
"nordic-semiconductor.nrf-connect-extension-pack",
"ms-vscode.cpptools",
"twxs.cmake"
]
}
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
"runToEntryPoint": "main",
"gdbPath": "/home/lucas/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb"
},
{
"name": "external teal (attach, sysbuild)",
"cwd": "${workspaceRoot}",
"executable": "./build/teal-caniot-device/zephyr/teal.elf",
"request": "attach",
"type": "cortex-debug",
"servertype": "external",
"gdbTarget": ":3333",
"device": "stm32l462re",
"runToEntryPoint": "main",
"gdbPath": "/home/lucas/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb"
},
{
"name": "external nucleo_l452re (launch)",
"cwd": "${workspaceRoot}",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"files.associations": {
"kernel.h": "c",
"inttypes.h": "c"
}
},
}
14 changes: 8 additions & 6 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@


menuconfig APPLICATION
bool "Application"
help
Enable application
menu "Application Configuration"

if APPLICATION
config APP_USB_DFU_FW_DOWNLOAD
bool "USB DFU firmware download"
default y
select USB_DFU_CLASS
help
Enable USB DFU firmware download.

endif
endmenu

menuconfig TEST
bool "Test firmware"
Expand Down
30 changes: 14 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
.PHONY: build flash debugserver debug menuconfig clean reports teal nucleo_l452 nucleo_f072 nucleo_h745 nucleo_f429
.PHONY: build flash debugserver debug menuconfig clean reports teal sysbuild

all: build
all: build teal flash debug menuconfig reports clean

build:
west build
# nucleo_l452re nucleo_f429zi
BOARD=teal_caniot

build: teal

# board specific build
teal:
west build -b teal_caniot

nucleo_l452:
west build -b nucleo_l452re
west build -b $(BOARD)

nucleo_f072:
west build -b teal_f072
test:
west build -b $(BOARD) -- -DFILE_SUFFIX=test

nucleo_h745:
west build -b nucleo_h745zi_q/stm32h745xx/m7
sysbuild_test:
west build -b $(BOARD) --sysbuild -- -DFILE_SUFFIX=test

nucleo_f429:
west build -b nucleo_f429zi
sysbuild:
west build -b $(BOARD) --sysbuild

# tools
flash:
Expand All @@ -35,8 +34,7 @@ menuconfig:
west build -t menuconfig

reports:
west build -t ram_report > build/ram_report.txt
west build -t rom_report > build/rom_report.txt
./scripts/zephyr-report.sh

clean:
rm -rf build
2 changes: 1 addition & 1 deletion app.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
status = "okay";
compatible = "zephyr,cdc-acm-uart";
};
};
};
47 changes: 47 additions & 0 deletions boards/arm/teal_caniot/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright (c) 2024 Lucas Dietrich <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
#

if BOARD_TEAL_CANIOT

config BOARD_TEAL_CANIOT_FULL_FEATURED
bool "Enable extended configuration for Teal CANIoT"
default y

endif

if BOARD_TEAL_CANIOT_FULL_FEATURED

config I2C
default y

config SPI
default y

config ADC
default y

config CAN
default y

config CRC
default y

config W1
default y

config USB_CDC_ACM
default y

config USB_DEVICE_STACK
default y

config SENSOR
default y

config TCN75A
default y

endif
13 changes: 13 additions & 0 deletions boards/arm/teal_caniot/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Copyright (c) 2024 Lucas Dietrich <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
#

choice BOOTLOADER
default BOOTLOADER_MCUBOOT
endchoice

choice BOOT_SIGNATURE_TYPE
default BOOT_SIGNATURE_TYPE_NONE
endchoice
35 changes: 34 additions & 1 deletion boards/arm/teal_caniot/teal_caniot.dts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <st/l4/stm32l462retx-pinctrl.dtsi>
#include <zephyr/dt-bindings/input/input-event-codes.h>


/ {
model = "Teal CANIoT device board";
compatible = "custom,teal_caniot";
Expand All @@ -20,6 +19,7 @@
zephyr,flash = &flash0;
zephyr,console = &lpuart1;
zephyr,shell-uart = &lpuart1;
zephyr,code-partition = &slot0_partition;
};

gpio_keys {
Expand Down Expand Up @@ -55,6 +55,39 @@
};
};

&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(48)>;
read-only;
};
slot0_partition: partition@C000 {
label = "image-0";
reg = <0x0000C000 DT_SIZE_K(216)>;
};
slot1_partition: partition@42000 {
label = "image-1";
reg = <0x00042000 DT_SIZE_K(216)>;
};

/*
* The flash starting at 78000 and ending at
* 0x0007ffff is reserved for use by the application.
*/

/* Storage partition will be used by FCB/NFFS/NVS if enabled. */
storage_partition: partition@78000 {
label = "storage";
reg = <0x00078000 DT_SIZE_K(32)>;
};
};
};

/* clocks */
&clk_lsi {
status = "okay";
Expand Down
17 changes: 1 addition & 16 deletions boards/arm/teal_caniot/teal_caniot_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
#

# Standard configuration for an application

CONFIG_ARM_MPU=y
CONFIG_HW_STACK_PROTECTION=y
Expand All @@ -18,23 +19,7 @@ CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_LINE_CTRL=y

CONFIG_I2C=y
CONFIG_SPI=y
CONFIG_GPIO=y
CONFIG_ADC=y
CONFIG_CAN=y
CONFIG_CRC=y
CONFIG_W1=y

# usb
CONFIG_USB_CDC_ACM=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_MANUFACTURER="Lucas"
CONFIG_USB_DEVICE_PRODUCT="Teal CANIoT"

# st microelectronics
CONFIG_USB_DEVICE_VID=0x0483
CONFIG_USB_DEVICE_PID=0xFFFF

# tcn75
CONFIG_SENSOR=y
Expand Down
19 changes: 19 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Documentation

## TODOs

- Understand why creating file `sysbuild/mcuboot.overlay` breaks the build:

```dts
&can1 {
status = "disabled";
};

&i2c1 {
status = "disabled";
};

&usb {
status = "disabled";
};
```
28 changes: 25 additions & 3 deletions prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,37 @@
CONFIG_KERNEL_BIN_NAME="teal"
CONFIG_DEBUG=y

# MCUBOOT features
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_STREAM_FLASH=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_IMG_BLOCK_BUF_SIZE=512
CONFIG_IMG_ENABLE_IMAGE_CHECK=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

# usb (TODO move to dedicated board config)
CONFIG_USB_CDC_ACM=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_DFU_CLASS=y

# We need to disable the logs in the USB CDC ACM driver otherwise
# the logs will be printed on the (USB) console causing a chain reaction
# (eventually recursion leading to a stack overflow)
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
# CONFIG_USB_CDC_ACM_LOG_LEVEL_ERR=n

# usb info
CONFIG_USB_DEVICE_MANUFACTURER="Lucas"
CONFIG_USB_DEVICE_PRODUCT="Teal CANIoT"

# st microelectronics
CONFIG_USB_DEVICE_VID=0x0483
CONFIG_USB_DEVICE_PID=0xFFFF

CONFIG_CANIOT_LIB=y
CONFIG_CANIOT_DEVICE_DRIVERS_API=y

CONFIG_TEST=y
CONFIG_STM32L4_MCO=y
# Application specific configurations
CONFIG_APP_USB_DFU_FW_DOWNLOAD=y
Loading