Hi, Im working with a 5340 dk, where i want to add a fatfs msc on the external flash togther with ble. From what i gather from ble examples uses pm and nvs to function.
So in this example https://docs.zephyrproject.org/latest/samples/subsys/usb/mass/README.html
The device tree storage partition is replaced in the overlay, however with the ble example this wont work since its using the PM.
So firstly i tried to modify the example to use PM instead, the overlay would be changed to use nordic,pm-ext-flash but then the application seem to fetch the wrong partition
Area 2 at 0x10000 on flash-controller@39000 for 262144 bytes and creates the filesystem on the internal flash?
Below are code snippets with changes to go from device tree to pm.
I have two questions.
1. How do i fix so that the external flash is targeted?
2. If i want to use ble and msc, how do i keep nvs params in internal flash(not deleting storage_partition?) and put the filesystem on the external flash?
3. The reference storage_partition seems to be static in zephyr, is it possible to add another or should one add the external flash as an id under this partition to be able to reference it in code as its done in the mass example?
Thanks!
/* * Copyright (c) 2020 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ /delete-node/ &storage_partition; &mx25r64 { partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@0 { label = "storage"; reg = <0x00000000 0x00020000>; }; }; }; /{ chosen { nordic,pm-ext-flash = &mx25r64; }; msc_disk0 { compatible = "zephyr,flash-disk"; partition = <&storage_partition>; disk-name = "NAND"; cache-size = <4096>; }; };
Then a pm_static.yml added to the project as follows.
external_flash: address: 0x0 end_address: 0x4000000 size: 0x04000000 device: mx25r64 region: external_flash storage_partition: address: 0x0 device: DT_CHOSEN(nordic_pm_ext_flash) end_address: 0x400000 placement: after: - start region: external_flash size: 0x0400000
With these changes the software now builds and runs but it seems to fetch the wrong partition in the mass example.
Area 2 at 0x10000 on flash-controller@39000 for 262144 bytes
partitions.yaml clearly adds the new partition
app: address: 0x0 end_address: 0x100000 region: flash_primary size: 0x100000 external_flash: address: 0x0 device: mx25r64 end_address: 0x4000000 region: external_flash size: 0x4000000 otp: address: 0xff8100 end_address: 0xff83fc region: otp size: 0x2fc sram_primary: address: 0x20000000 end_address: 0x20080000 region: sram_primary size: 0x80000 storage_partition: address: 0x0 device: DT_CHOSEN(nordic_pm_ext_flash) end_address: 0x400000 placement: after: - start region: external_flash size: 0x400000
The generated devicetree states partitions on the qspi driver
* 11 /soc/peripheral@50000000 * 12 /soc/peripheral@50000000/qspi@2b000 * 13 /soc/peripheral@50000000/qspi@2b000/mx25r6435f@0 * 14 /soc/peripheral@50000000/qspi@2b000/mx25r6435f@0/partitions * 15 /soc/peripheral@50000000/qspi@2b000/mx25r6435f@0/partitions/partition@0 .... * 129 /soc/peripheral@50000000/flash-controller@39000 * 130 /soc/peripheral@50000000/flash-controller@39000/flash@0 * 131 /soc/peripheral@50000000/flash-controller@39000/flash@0/partitions * 132 /soc/peripheral@50000000/flash-controller@39000/flash@0/partitions/partition@0 * 133 /soc/peripheral@50000000/flash-controller@39000/flash@0/partitions/partition@10000 * 134 /soc/peripheral@50000000/flash-controller@39000/flash@0/partitions/partition@50000 * 135 /soc/peripheral@50000000/flash-controller@39000/flash@0/partitions/partition@80000 * 136 /soc/peripheral@50000000/flash-controller@39000/flash@0/partitions/partition@c0000