February 23, 2025
In Part 1 I described connecting to the pcDuino serial port and accessing the U-Boot subsystem. With this access to the boot environment, the task of booting to a root file system other than the NAND flash looked promising.
The pcDuino accepts a micro-SD card (I just refer to it as SD to save typing) for additional storage. It is best to partition and format the card with a Linux file system for use on the pcDuino. If you are attempting this, the following steps will result in a loss of all data already on an SD card.
For some of the steps below, additional software needed to be installed on the pcDuino. For formatting a DOS FAT partition, the dosfstools package must be installed. For copying the files between filesystems, I use the rsync package.
1 2 3 |
sudo apt-get update sudo apt-get install -y dosfstools suod apt-get install -y rsync |
First, the SD card must be inserted in the card slot and partitioned. By default, the pcDuino will attempt to automatically mount the SD card partitions, so these partitions must be unmounted after inserting the card. I’m lazy, so I just ask the system to unmount every thing accociated with the SD card slot. The redirection to /dev/null is to avoid error messages I would just ignore.
1 |
for m in /dev/mmcblk0* ; do sudo umount $m >/dev/null 2>/dev/null ; done |
Next, the new partitions need defined. I set my card up with a small (16MB) FAT partition for future use as a /boot file system, and used the remaining space for the root file system. The pcDuino desktop DiskManager allows the formatting to be done from from a graphical interface. Or, as I prefer, the fdisk command line application can be used.
Once the partitions are created, the file systems need to be created, mounted, and a copy of the existing operating system copied to the corresponding locations. For my configuration, the following commands were used to accomplish this task.
1 2 |
mkfs.vfat /dev/mmcblk0p1 mkfs.ext4 /dev/mmcblk0p2 |
With the new file systems on the card, I needed to make certain they were not automatically mounted.
1 |
for m in /dev/mmcblk0* ; do sudo umount $m >/dev/null 2>/dev/null ; done |
Then, the file systems were copied. Starting with the /boot partition
1 2 3 4 5 |
sudo mount /dev/mmcblk0p1 /mnt sudo mount /dev/nanda /boot sudo rsync -aqPx -H --numeric-ids /boot/ /mnt sudo umount /mnt sudo umount /boot |
And the root / file system
1 2 3 |
sudo mount /dev/mmcblk0p2 /mnt sudo rsync -aqPx -H --numeric-ids / /mnt sudo umount /mnt |
To test, I rebooted the system with the serial debug output connected to my lap top as I described in Part 1 and entered into the U-Boot command line. From the U-Boot prompt, I set the default root device to my root partition on the SD card and booted.
1 2 |
setenv nand_root /dev/mmcblk0p2 boot |
After booting, it was necessary to check if the root / was being used from the SD card.
1 2 3 4 |
df -h Filesystem Size Used Avail Use% Mounted on /dev/mmcblk0p2 15G 1.4G 13G 10% / ... |
CONFIRMED: The pcDuino will boot to an alternate root file system. All that’s needed now is to make it permanent.
Time to reboot the system and back into U-Boot to make the environment change permanent. The saveenv command is used to permanently write environment changes to non-volatile storage. In the case of the pcDuino the environment is saved to a specific NAND flash area.
1 2 3 |
setenv nand_root /dev/mmcblk0p2 saveenv boot |
No errors were displayed, and a check of the mounted file systems showed the SD card was being used for the root file system. Time for the critical test. Reboot without entering U-Boot to confirm the change is permanent.
1 2 3 4 5 6 |
sudo reboot ... df -h Filesystem Size Used Avail Use% Mounted on /dev/nandd 1.9G 1.2G 700M 63% / ... |
FAILURE! The changes are not persistent. The saveenv did not work. No errors were displayed, but the environment was not updated.
After a detailed investigation, I concluded the saveenv was non-functional in the pcDuino U-Boot version. The NAND flash write routines are not present or operational. More details of the investigation into alternatives for controlling the boot process will be in Part 3 and a workable solution will be presented. Stay tuned!
ONLY TRY THE ABOVE IF YOU UNDERSTAND WHAT YOU ARE DOING. Connecting to the serial debug port has the potential to damage your pcDuino if your connections are incorrect. Changes to the U-Boot environment can render your pcDuino unbootable. YOU HAVE BEEN WARNED!
Update 15-Mar-2013: Add information for installing dosfstools and rsync packages.
Pingback: pcDuino U-Boot – Part 1- Enjoy!
Pingback: pcDuino U-Boot – Part 3- Enjoy!