#1 Adding non-volatile storage to Petalinux 2023.2
In this note, we are going to see how to use the SD card of a Zynq SOC/Zynq MPSOC board as a non-volatile storage. This will allow us to save the configurations made in the OS, and also keep the file created in previous boots. This note is based on the UG1144 from AMD.
In the Petalinux build, we have to open the configuration menu.
pablo@ares:~/workspace_local/zuboard_amp/os$ petalinux-config
In the configuration window, we need to navigate to Image Packaging Configuration > Root file system type
. here, we will change the configuration to EXT4 (SD/eMMC/SATA/USB)
Now, we need to add to the device-tree a node for the SD card. The file we need to modify is the system-user.dtsi
pablo@ares:~/workspace_local/zuboard_amp/os/project-spec/meta-user/recipes-bsp/device-tree/files$ nano system-user.dtsi
Once the file is open, we just need to add this code at the end of the file.
&sdhci1 {
status = "okay";
xlnx,has-cd = <0x1>;
xlnx,has-power = <0x0>;
xlnx,has-wp = <0x1>;
disable-wp;
no-1-8-v;
};
Now, throughout the Petalinux boot, we will see the following lines.
[ 0.000000] Kernel command line: earlycon console=ttyPS0,115200 clk_ignore_unused root=/dev/mmcblk0p2 ro rootwait
...
[ 2.309675] Waiting for root device /dev/mmcblk0p2...
...
[ 2.370441] EXT4-fs (mmcblk0p2): INFO: recovery required on readonly filesystem
[ 2.377752] EXT4-fs (mmcblk0p2): write access will be enabled during recovery
...
[ 2.452557] EXT4-fs (mmcblk0p2): recovery complete
[ 2.458776] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Quota mode: none.
...
[ 4.723112] EXT4-fs (mmcblk0p2): re-mounted. Quota mode: none.
At this point, first, the password we have to configure in the first boot will be saved, so for the rest of the boots, the password won’t change. Also, if we install some Python packages, or create a file, in the following boots, these changes will be kept.