samples: fs: fat_fs: RAM disk in SRAM region for nrf52840dk

Add overlay, for nrf52840dk, that reserves RAM in internal
SRAM using the DTS definition.
The sample with such region can be built with the config
file nrf52840dk_nrf52840_ram_disk_region.conf, but, instead
of automatically allocating memory, the Disk driver will
use the pre-defined region provided by the DTS overlay.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2024-03-04 14:51:30 +00:00 committed by Anas Nashif
parent d5e321516a
commit 919baf84d6
2 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/* The SRAM is defined for nrf52840 in DTS to take entire 256KiB
* of RAM there is. We need some for the Disk, so we need to
* remove the original definition and replace it with smaller one.
*/
/delete-node/ &sram0;
/ {
soc {
/* This is defined based on dts and dtsi files for
* nrf52840 SoC; because we are not able to just
* change the size, what we have to do is to remove
* the sram0 definition, which is a combined result
* of all the sram0 referencing entries in included
* dts files, and replace it with our own.
* The first one is reduced in size original sram0:
*/
sram0: memory@20000000 {
compatible = "mmio-sram";
reg = <0x20000000 DT_SIZE_K(192)>;
};
/* The second one is 64kiB region taken out of SRAM,
* labeled here ram_disk, label can be anything,
* used later in disk definition.
*/
ram_disk: memory@20030000 {
compatible = "mmio-sram";
reg = <0x20030000 DT_SIZE_K(64)>;
};
};
msc_disk0 {
status="okay";
compatible = "zephyr,ram-disk";
/* Sample, to make things easier, mounts all FAT
* systems at "SD".
*/
disk-name = "SD";
/* Disk size is 64kB, 128 sectors of 512B, the minimal
* required by FAT FS.
*/
sector-size = <512>;
sector-count = <128>;
/* Here is the reference to the memory reserved for our
* disk using a phandle; note that we reference the
* region by label we have defined it above.
*/
ram-region = <&ram_disk>;
};
};

View file

@ -37,6 +37,12 @@ tests:
extra_args:
- OVERLAY_CONFIG=boards/nrf52840dk_nrf52840_ram_disk.conf
- DTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840_ram_disk.overlay
sample.filesystem.fat_fs.nrf52840dk_nrf52840_ram_disk_region:
build_only: true
platform_allow: nrf52840dk/nrf52840
extra_args:
- OVERLAY_CONFIG=boards/nrf52840dk_nrf52840_ram_disk.conf
- DTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840_ram_disk_region.overlay
sample.filesystem.fat_fs.nrf52840dk_nrf52840.qspi:
build_only: true
platform_allow: nrf52840dk/nrf52840