Skip to content

Commit 919baf8

Browse files
de-nordicnashif
authored andcommitted
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 <[email protected]>
1 parent d5e3215 commit 919baf8

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* The SRAM is defined for nrf52840 in DTS to take entire 256KiB
8+
* of RAM there is. We need some for the Disk, so we need to
9+
* remove the original definition and replace it with smaller one.
10+
*/
11+
/delete-node/ &sram0;
12+
13+
/ {
14+
15+
soc {
16+
/* This is defined based on dts and dtsi files for
17+
* nrf52840 SoC; because we are not able to just
18+
* change the size, what we have to do is to remove
19+
* the sram0 definition, which is a combined result
20+
* of all the sram0 referencing entries in included
21+
* dts files, and replace it with our own.
22+
* The first one is reduced in size original sram0:
23+
*/
24+
sram0: memory@20000000 {
25+
compatible = "mmio-sram";
26+
reg = <0x20000000 DT_SIZE_K(192)>;
27+
};
28+
/* The second one is 64kiB region taken out of SRAM,
29+
* labeled here ram_disk, label can be anything,
30+
* used later in disk definition.
31+
*/
32+
ram_disk: memory@20030000 {
33+
compatible = "mmio-sram";
34+
reg = <0x20030000 DT_SIZE_K(64)>;
35+
};
36+
};
37+
38+
msc_disk0 {
39+
status="okay";
40+
compatible = "zephyr,ram-disk";
41+
/* Sample, to make things easier, mounts all FAT
42+
* systems at "SD".
43+
*/
44+
disk-name = "SD";
45+
/* Disk size is 64kB, 128 sectors of 512B, the minimal
46+
* required by FAT FS.
47+
*/
48+
sector-size = <512>;
49+
sector-count = <128>;
50+
/* Here is the reference to the memory reserved for our
51+
* disk using a phandle; note that we reference the
52+
* region by label we have defined it above.
53+
*/
54+
ram-region = <&ram_disk>;
55+
};
56+
};

samples/subsys/fs/fs_sample/sample.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ tests:
3737
extra_args:
3838
- OVERLAY_CONFIG=boards/nrf52840dk_nrf52840_ram_disk.conf
3939
- DTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840_ram_disk.overlay
40+
sample.filesystem.fat_fs.nrf52840dk_nrf52840_ram_disk_region:
41+
build_only: true
42+
platform_allow: nrf52840dk/nrf52840
43+
extra_args:
44+
- OVERLAY_CONFIG=boards/nrf52840dk_nrf52840_ram_disk.conf
45+
- DTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840_ram_disk_region.overlay
4046
sample.filesystem.fat_fs.nrf52840dk_nrf52840.qspi:
4147
build_only: true
4248
platform_allow: nrf52840dk/nrf52840

0 commit comments

Comments
 (0)