From dcc1d0e49c6f283053f30df0ef8192947971206c Mon Sep 17 00:00:00 2001 From: Jacob Winther Date: Mon, 23 Sep 2024 21:04:16 +1200 Subject: [PATCH] boards: nrf52840 common uf2 partition Common uf2 partition configurations to avoid duplication in boards. There appears to be a bit of confusion about exactly what a proper UF2 partition map looks like for the nrf52840, so common dts configurations should help to avoid confusion. Configuration for SoftDevice v6 and v7 provided as thats what was fouond in use in tree already. Signed-off-by: Jacob Winther --- .../adafruit_feather_nrf52840_flash_uf2.dtsi | 53 ------------------ ...it_feather_nrf52840_nrf52840_sense_uf2.dts | 2 +- ...adafruit_feather_nrf52840_nrf52840_uf2.dts | 2 +- .../itsybitsy/adafruit_itsybitsy_nrf52840.dts | 39 +------------- boards/seeed/xiao_ble/xiao_ble_common.dtsi | 39 +------------- .../nordic/nrf52840_partition_uf2_sdv6.dtsi | 54 +++++++++++++++++++ .../nordic/nrf52840_partition_uf2_sdv7.dtsi | 52 ++++++++++++++++++ 7 files changed, 110 insertions(+), 131 deletions(-) delete mode 100644 boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash_uf2.dtsi create mode 100644 dts/common/nordic/nrf52840_partition_uf2_sdv6.dtsi create mode 100644 dts/common/nordic/nrf52840_partition_uf2_sdv7.dtsi diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash_uf2.dtsi b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash_uf2.dtsi deleted file mode 100644 index 805b853ce31..00000000000 --- a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash_uf2.dtsi +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2024 Jacob Winther - * - * SPDX-License-Identifier: Apache-2.0 - * - * Default flash layout for nrf52840 using UF2 - */ - -/ { - chosen { - zephyr,sram = &sram0; - zephyr,flash = &flash0; - zephyr,code-partition = &code_partition; - }; -}; - -&flash0 { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - /* To enable flashing with UF2 bootloader, we - * must reserve a partition for SoftDevice. - * See https://learn.adafruit.com/ - * introducing-the-adafruit-nrf52840-feather?view=all#hathach-memory-map - */ - reserved_partition_0: partition@0 { - label = "SoftDevice"; - read-only; - reg = <0x000000000 DT_SIZE_K(152)>; - }; - code_partition: partition@26000 { - label = "Application"; - reg = <0x00026000 DT_SIZE_K(796)>; - }; - - /* - * The flash starting at 0x000ed000 and ending at - * 0x000f4000 is reserved for use by the application. - */ - storage_partition: partition@ed000 { - label = "storage"; - reg = <0x0000ed000 DT_SIZE_K(28)>; - }; - - boot_partition: partition@f4000 { - label = "UF2"; - read-only; - reg = <0x000f4000 DT_SIZE_K(48)>; - }; - }; -}; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.dts b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.dts index 0ad7ee1e960..719577abc0d 100644 --- a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.dts +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.dts @@ -7,7 +7,7 @@ /dts-v1/; #include "adafruit_feather_nrf52840_common.dtsi" -#include "adafruit_feather_nrf52840_flash_uf2.dtsi" +#include / { model = "Adafruit Feather nRF52840 Sense"; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.dts b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.dts index 33f2d3e598c..bc4f67a9931 100644 --- a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.dts +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.dts @@ -6,7 +6,7 @@ /dts-v1/; #include "adafruit_feather_nrf52840_common.dtsi" -#include "adafruit_feather_nrf52840_flash_uf2.dtsi" +#include / { model = "Adafruit Feather nRF52840 Express"; diff --git a/boards/adafruit/itsybitsy/adafruit_itsybitsy_nrf52840.dts b/boards/adafruit/itsybitsy/adafruit_itsybitsy_nrf52840.dts index 087ddc17307..ee74d886940 100644 --- a/boards/adafruit/itsybitsy/adafruit_itsybitsy_nrf52840.dts +++ b/boards/adafruit/itsybitsy/adafruit_itsybitsy_nrf52840.dts @@ -6,6 +6,7 @@ /dts-v1/; #include +#include #include "adafruit_itsybitsy_nrf52840-pinctrl.dtsi" #include #include @@ -20,9 +21,6 @@ zephyr,uart-mcumgr = &cdc_acm_uart0; zephyr,bt-mon-uart = &cdc_acm_uart0; zephyr,bt-c2h-uart = &cdc_acm_uart0; - zephyr,sram = &sram0; - zephyr,flash = &flash0; - zephyr,code-partition = &code_partition; zephyr,ieee802154 = &ieee802154; }; @@ -142,41 +140,6 @@ status = "okay"; }; -&flash0 { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - /* To enable flashing with UF2 bootloader, we - * must reserve a partition for SoftDevice. - * See https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather?view=all#hathach-memory-map - */ - reserved_partition_0: partition@0 { - label = "SoftDevice"; - reg = <0x000000000 DT_SIZE_K(152)>; - }; - code_partition: partition@26000 { - label = "Application"; - reg = <0x00026000 DT_SIZE_K(796)>; - }; - - /* - * The flash starting at 0x000ed000 and ending at - * 0x000f4000 is reserved for use by the application. - */ - storage_partition: partition@ed000 { - label = "storage"; - reg = <0x0000ed000 DT_SIZE_K(28)>; - }; - - boot_partition: partition@f4000 { - label = "UF2"; - reg = <0x000f4000 DT_SIZE_K(48)>; - }; - }; -}; - &gd25q16 { partitions { compatible = "fixed-partitions"; diff --git a/boards/seeed/xiao_ble/xiao_ble_common.dtsi b/boards/seeed/xiao_ble/xiao_ble_common.dtsi index db00fbf1368..b8f4f259c10 100644 --- a/boards/seeed/xiao_ble/xiao_ble_common.dtsi +++ b/boards/seeed/xiao_ble/xiao_ble_common.dtsi @@ -6,6 +6,7 @@ */ #include +#include #include "xiao_ble-pinctrl.dtsi" #include "seeed_xiao_connector.dtsi" @@ -16,9 +17,6 @@ zephyr,uart-mcumgr = &usb_cdc_acm_uart; zephyr,bt-mon-uart = &usb_cdc_acm_uart; zephyr,bt-c2h-uart = &usb_cdc_acm_uart; - zephyr,sram = &sram0; - zephyr,flash = &flash0; - zephyr,code-partition = &code_partition; zephyr,ieee802154 = &ieee802154; }; @@ -145,41 +143,6 @@ status = "okay"; }; -&flash0 { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - sd_partition: partition@0 { - label = "softdevice"; - reg = <0x00000000 0x00027000>; - }; - - code_partition: partition@27000 { - label = "code_partition"; - reg = <0x00027000 0x000c5000>; - }; - - /* - * The flash starting at 0x000ec000 and ending at - * 0x000f3fff is reserved for use by the application. - * - * Storage partition will be used by FCB/LittleFS/NVS - * if enabled. - */ - storage_partition: partition@ec000 { - label = "storage"; - reg = <0x000ec000 0x00008000>; - }; - - boot_partition: partition@f4000 { - label = "adafruit_boot"; - reg = <0x000f4000 0x0000c000>; - }; - }; -}; - zephyr_udc0: &usbd { compatible = "nordic,nrf-usbd"; status = "okay"; diff --git a/dts/common/nordic/nrf52840_partition_uf2_sdv6.dtsi b/dts/common/nordic/nrf52840_partition_uf2_sdv6.dtsi new file mode 100644 index 00000000000..37387fd782f --- /dev/null +++ b/dts/common/nordic/nrf52840_partition_uf2_sdv6.dtsi @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Jacob Winther + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +/ { + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &code_partition; + }; +}; + +&flash0 { + /* + * Default flash layout for nrf52840 using UF2 and SoftDevice s140 v6 + * + * 0x00000000 SoftDevice s140 v6 (152 kB) + * 0x00026000 Application partition (792 kB) + * 0x000ec000 Storage partition (32 kB) + * 0x000f4000 UF2 boot partition (48 kB) + * + * See https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/hathach-memory-map + */ + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + reserved_partition_0: partition@0 { + label = "SoftDevice"; + read-only; + reg = <0x00000000 0x00026000>; + }; + code_partition: partition@26000 { + label = "Application"; + reg = <0x00026000 0x000C6000>; + }; + + storage_partition: partition@ec000 { + label = "Storage"; + reg = <0x000ec000 0x00008000>; + }; + + boot_partition: partition@f4000 { + label = "UF2"; + read-only; + reg = <0x000f4000 0x0000c000>; + }; + }; +}; diff --git a/dts/common/nordic/nrf52840_partition_uf2_sdv7.dtsi b/dts/common/nordic/nrf52840_partition_uf2_sdv7.dtsi new file mode 100644 index 00000000000..e6aaf73ca14 --- /dev/null +++ b/dts/common/nordic/nrf52840_partition_uf2_sdv7.dtsi @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Jacob Winther + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +/ { + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &code_partition; + }; +}; + +&flash0 { + /* + * Default flash layout for nrf52840 using UF2 and SoftDevice s140 v7 + * + * 0x00000000 SoftDevice s140 v7 (156 kB) + * 0x00027000 Application partition (788 kB) + * 0x000ec000 Storage partition (32 kB) + * 0x000f4000 UF2 boot partition (48 kB) + */ + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + reserved_partition_0: partition@0 { + label = "SoftDevice"; + read-only; + reg = <0x00000000 0x00027000>; + }; + code_partition: partition@27000 { + label = "Application"; + reg = <0x00027000 0x000C5000>; + }; + + storage_partition: partition@ec000 { + label = "Storage"; + reg = <0x000ec000 0x00008000>; + }; + + boot_partition: partition@f4000 { + label = "UF2"; + read-only; + reg = <0x000f4000 0x0000c000>; + }; + }; +};