bootloader somehow working
Signed-off-by: Eduard Iten <eduard@iten.pro>
This commit is contained in:
parent
c3c23efc95
commit
0227e54198
|
|
@ -0,0 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(bl_test)
|
||||
|
||||
# Add application source files
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
VERSION_MAJOR = 0
|
||||
VERSION_MINOR = 0
|
||||
PATCHLEVEL = 1
|
||||
VERSION_TWEAK = 1
|
||||
EXTRAVERSION = devel
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# Enable Console and printk for logging via UART
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# Enable more detailed MCUMGR logging
|
||||
CONFIG_MCUMGR_LOG_LEVEL_DBG=y
|
||||
CONFIG_IMG_MANAGER_LOG_LEVEL_DBG=y
|
||||
CONFIG_STREAM_FLASH_LOG_LEVEL_DBG=y
|
||||
|
||||
# Enable USB for MCUMGR only
|
||||
CONFIG_USB_DEVICE_STACK=y
|
||||
CONFIG_USB_CDC_ACM=y
|
||||
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=y
|
||||
|
||||
# USB CDC ACM buffer configuration for better MCUMGR performance
|
||||
CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024
|
||||
|
||||
# Set log level to info for reasonable size
|
||||
CONFIG_LOG_DEFAULT_LEVEL=3
|
||||
|
||||
# Enable MCUMGR info logging (not debug to save space)
|
||||
CONFIG_MCUMGR_LOG_LEVEL_INF=y
|
||||
|
||||
# Enable USB CDC info logging
|
||||
CONFIG_USB_CDC_ACM_LOG_LEVEL_INF=y
|
||||
|
||||
# STEP 5.2 - Enable mcumgr DFU in application
|
||||
# Enable MCUMGR
|
||||
CONFIG_MCUMGR=y # Enable MCUMGR management for both OS and Images
|
||||
CONFIG_MCUMGR_GRP_OS=y
|
||||
CONFIG_MCUMGR_GRP_IMG=y
|
||||
|
||||
# Configure MCUMGR transport to UART (will use USB-CDC via chosen device)
|
||||
CONFIG_MCUMGR_TRANSPORT_UART=y
|
||||
|
||||
# Dependencies
|
||||
# Configure dependencies for CONFIG_MCUMGR
|
||||
CONFIG_NET_BUF=y
|
||||
CONFIG_ZCBOR=y
|
||||
CONFIG_CRC=y # Configure dependencies for CONFIG_MCUMGR_GRP_IMG
|
||||
CONFIG_FLASH=y
|
||||
CONFIG_IMG_MANAGER=y # Configure dependencies for CONFIG_IMG_MANAGER
|
||||
CONFIG_STREAM_FLASH=y
|
||||
CONFIG_FLASH_MAP=y # Configure dependencies for CONFIG_MCUMGR_TRANSPORT_USB_CDC
|
||||
CONFIG_BASE64=y
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
#include <app_version.h>
|
||||
|
||||
LOG_MODULE_REGISTER(bl_test_app, LOG_LEVEL_INF);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
LOG_INF("Hello World from bl_test! This is version %s", APP_VERSION_EXTENDED_STRING);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
SB_CONFIG_BOOTLOADER_MCUBOOT=y
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include "common.dtsi"
|
||||
|
||||
/* Application Configuration - Firmware wird in slot0_partition geschrieben */
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
zephyr,uart-mcumgr = &cdc_acm_uart0;
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Common Devicetree Configuration für weact_stm32g431_core
|
||||
* - Konfiguriert einen W25Q128 Flash-Speicher auf SPI2
|
||||
* - Konfiguriert USB-CDC für MCUMGR
|
||||
* - Setzt den Chip Select (CS) Pin auf PA5
|
||||
* - Weist das Label "flash1" zu
|
||||
*/
|
||||
|
||||
/* Partitions für internes Flash (STM32G431) */
|
||||
&flash0 {
|
||||
/delete-node/ partitions; /* Entferne die Standard-Partitionen */
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* MCUboot bootloader - 48 KB */
|
||||
boot_partition: partition@0 {
|
||||
label = "mcuboot";
|
||||
reg = <0x00000000 0x0000C000>;
|
||||
};
|
||||
|
||||
/* Slot0 partition für primäres Application Image - 80 KB (20 sectors @ 4KB) */
|
||||
slot0_partition: partition@C000 {
|
||||
label = "image-0";
|
||||
reg = <0x0000C000 0x00014000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* USB-CDC Konfiguration für MCUMGR */
|
||||
&usb {
|
||||
status = "okay";
|
||||
cdc_acm_uart0: cdc_acm_uart0 {
|
||||
compatible = "zephyr,cdc-acm-uart";
|
||||
};
|
||||
};
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,uart-mcumgr = &cdc_acm_uart0;
|
||||
};
|
||||
};
|
||||
|
||||
&spi2 {
|
||||
/* Definiere die Pins für SCK, MISO, MOSI auf Port B */
|
||||
pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
|
||||
/* === Chip Select (CS) auf PA5 gesetzt === */
|
||||
cs-gpios = <&gpioa 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
|
||||
/* Definiere den Flash-Chip als SPI NOR Gerät */
|
||||
flash1: flash@0 {
|
||||
compatible = "jedec,spi-nor";
|
||||
reg = <0>;
|
||||
label = "flash1";
|
||||
|
||||
/* JEDEC ID für einen Winbond W25Q128 (16 MBytes) */
|
||||
jedec-id = [ef 40 18];
|
||||
|
||||
/* Speichergröße in Bytes (16 MBytes) */
|
||||
size = <DT_SIZE_M(16)>;
|
||||
|
||||
/* Maximale Taktfrequenz - angepasst an STM32G431 Limits */
|
||||
spi-max-frequency = <1000000>;
|
||||
|
||||
/* Partitions für externes Flash */
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* Slot1 partition für MCUboot (sekundäres Image) - 80 KB (20 sectors @ 4KB) */
|
||||
slot1_partition: partition@0 {
|
||||
label = "image-1";
|
||||
reg = <0x00000000 0x00014000>;
|
||||
};
|
||||
|
||||
/* Scratch partition für MCUboot - 80 KB (20 sectors @ 4KB) */
|
||||
scratch_partition: partition@14000 {
|
||||
label = "scratch";
|
||||
reg = <0x00014000 0x00014000>;
|
||||
};
|
||||
|
||||
/* Speicher partition für LittleFS - ~15.83 MB */
|
||||
storage_partition: partition@28000 {
|
||||
label = "storage";
|
||||
reg = <0x00028000 0x00FD8000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
CONFIG_LOG=y
|
||||
CONFIG_MCUBOOT_LOG_LEVEL_INF=y
|
||||
|
||||
# Enable UART console for MCUboot debug output
|
||||
CONFIG_UART_CONSOLE=y
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_MCUBOOT_INDICATION_LED=y
|
||||
|
||||
# Enable external SPI flash support
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPI_NOR=y
|
||||
CONFIG_SPI_NOR_SFDP_DEVICETREE=n
|
||||
CONFIG_FLASH=y
|
||||
CONFIG_FLASH_MAP=y
|
||||
CONFIG_GPIO=y
|
||||
|
||||
# Add SPI NOR specific configurations - use 4KB page size (required by driver)
|
||||
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
|
||||
CONFIG_SPI_NOR_INIT_PRIORITY=80
|
||||
|
||||
# Set maximum image sectors manually since auto doesn't work with external flash
|
||||
CONFIG_BOOT_MAX_IMG_SECTORS_AUTO=n
|
||||
CONFIG_BOOT_MAX_IMG_SECTORS=80
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#include "common.dtsi"
|
||||
|
||||
/* MCUboot Configuration - Bootloader wird in boot_partition geschrieben */
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,code-partition = &boot_partition;
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue