Changes

Jump to: navigation, search

Standalone boot (SDVX)

42 bytes removed, 12:39, 1 October 2018
no edit summary
== Introduction ==
This document was written and tested with the software/hardware combination described in the history table above. However, it contains general concepts that can be adapted on any DAVE Embedded Systems' Linux platform.
 
{{ImportantMessage|text=The following programming examples are intended for <b>laboratory usage</b> or for ''preliminary deployment strategy''.<br><br>A complete deployment strategy has to be carefully identifiyed taking into account the overall arguments like: boot speed, safe boot, recovery mechanisms, watchdog supervisor, etc.}}
We'll explain how to program and configure an [[:Category:SDVX |SDVX]] to boot in standalone mode, without the need of a system microSD card or an NFS server, with threee options:
* booting with eMMC only
** in this configuration the whole system will boot without the need of a NOR/NAND flashes storage, all images and the root file system will be fetched from eMMC flash
 
{{ImportantMessage|text=The following programming examples are intended for <b>laboratory usage</b> or for ''preliminary deployment strategy''.<br><br>A complete deployment strategy has to be carefully identifiyed taking into account the overall arguments like: boot speed, safe boot, recovery mechanisms, watchdog supervisor, etc.}}
 
== Program root file system into ...==
 
This is a common step for both booting options.
 
=== ...NAND flash ===
 
* Boot the system via SD or NFS as described in the e [[SDV04 Embedded Linux Kit (SDVX)#Quick_start_guide|Quick start guide]]
* By default, the NAND is already partitioned to allow booting from NAND-only (see next section) and, thus, some partitions are reserved for u-boot and kernel images. Here we won't modify this default configuration. The [[Memory Tecnology Device (MTD)|MTD]] partitions can be dumped with <code>/proc/mtd</code> (the partition's name should be self-explanatory)
<pre class="workstation-terminal">
root@sdvx-lite:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00800000 00020000 "nand-uboot"
mtd1: 00100000 00020000 "nand-env1"
mtd2: 00100000 00020000 "nand-env2"
mtd3: 00100000 00020000 "nand-fdt"
mtd4: 00100000 00020000 "nand-spare"
mtd5: 00800000 00020000 "nand-kernel"
mtd6: 00600000 00020000 "nand-splash"
mtd7: 3e600000 00020000 "nand-ubi"
root@sdvx-lite:~#
</pre>
 
=== ...eMMC flash ===
* Boot the system via SD or NFS as described in the e [[SDV04 Embedded Linux Kit (SDVX)#Quick_start_guide|Quick start guide]]
* eMMC device has to be partitioned and properly formatted choosing the <code>file system</code> for each partition
* an example of SD partitioning script is the following one:
 
<pre>
#!/bin/sh
 
node=$1
 
# partition size in MB
BOOTLOAD_RESERVE=8
BOOT_ROM_SIZE=128
RFS_SIZE=2048
 
# format the SDCARD/DATA/CACHE partition
part=""
echo ${node} | grep mmcblk > /dev/null
if [ "$?" -eq "0" ]; then
part="p"
fi
 
# call sfdisk to create partition table
total_size=`sfdisk -s ${node}`
total_size=`expr ${total_size} / 1024`
echo SD total size: ${total_size}KB
 
boot_start=`expr ${BOOTLOAD_RESERVE} \\* 1024 \\* 1024 / 512`
boot_size=`expr ${BOOT_ROM_SIZE} \\* 1024 \\* 1024 / 512`
rfs_start=`expr ${boot_size} + ${boot_start}`
rfs_size=`expr ${RFS_SIZE} \\* 1024 \\* 1024 / 512`
 
{ echo ${boot_start},${boot_size},0c,-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node}
 
echo "formatting boot"
mkfs.vfat -F 32 -n boot ${node}${part}1
echo "formatting rfs"
mkfs.ext4 -F ${node}${part}2 -Lrfs
</pre>
 
E.g.
 
<pre class="workstation-terminal">
root@sdvx-lite:~# ./sdcard-partition.sh /dev/mmcblk2
SD total size: 3776KB
[ 1341.905014] mmcblk2: p1 p2
Checking that no-one is using this disk right now ... OK
 
Disk /dev/mmcblk2: 3.7 GiB, 3959422976 bytes, 7733248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical):[ 1341.922729] mmcblk2: p1 p2
512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa77eb3f0
 
Old situation:
 
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 2048 264191 262144 128M c W95 FAT32 (LBA)
/dev/mmcblk2p2 264192 4458495 4194304 2G 83 Linux
 
>>> Created a new DOS disklabel with disk identifier 0xcce0c36f.
Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 128 MiB.
/dev/mmcblk2p2: Created a new partition 2 of type 'Linux' and of size 2 GiB.
/dev/mmcblk2p3:
New situation:
 
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 16384 278527 262144 128M c W95 FAT32 (LBA)
/dev/mmcblk2p2 278528 4472831 4194304 2G 83 Linux
 
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
formatting boot
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
formatting rfs
mke2fs 1.43-WIP (18-May-2015)
Discarding device blocks: done
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: 9a685543-1af2-4e39-83f3-b8a32248c021
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
 
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
 
root@sdvx-lite:~#
</pre>
== Program boot images ...==
 
{{ImportantMessage|text=Select the proper <code>u-boot</code>, <code>kernel</code> and <code>device tree</code> binary images according to the Axel Lite or Axel ULite SOM used}}
mmcargs=setenv bootargs root=${mmcroot}
mmcroot=/dev/mmcblk2p2 rootwait rw
</pre>
 
== Program root file system into NAND flash ==
 
* Boot the system via SD or NFS as described in the e [[SDV04 Embedded Linux Kit (SDVX)#Quick_start_guide|Quick start guide]]
* By default, the NAND is already partitioned to allow booting from NAND-only (see next section) and, thus, some partitions are reserved for u-boot and kernel images. Here we won't modify this default configuration. The [[Memory Tecnology Device (MTD)|MTD]] partitions can be dumped with <code>/proc/mtd</code> (the partition's name should be self-explanatory)
<pre class="workstation-terminal">
root@sdvx-lite:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00800000 00020000 "nand-uboot"
mtd1: 00100000 00020000 "nand-env1"
mtd2: 00100000 00020000 "nand-env2"
mtd3: 00100000 00020000 "nand-fdt"
mtd4: 00100000 00020000 "nand-spare"
mtd5: 00800000 00020000 "nand-kernel"
mtd6: 00600000 00020000 "nand-splash"
mtd7: 3e600000 00020000 "nand-ubi"
root@sdvx-lite:~#
</pre>
 
== Program root file system into eMMC flash ==
 
* Boot the system via SD or NFS as described in the e [[SDV04 Embedded Linux Kit (SDVX)#Quick_start_guide|Quick start guide]]
* eMMC device has to be partitioned and properly formatted choosing the <code>file system</code> for each partition
* an example of SD partitioning script is the following one:
 
<pre>
#!/bin/sh
 
node=$1
 
# partition size in MB
BOOTLOAD_RESERVE=8
BOOT_ROM_SIZE=128
RFS_SIZE=2048
 
# format the SDCARD/DATA/CACHE partition
part=""
echo ${node} | grep mmcblk > /dev/null
if [ "$?" -eq "0" ]; then
part="p"
fi
 
# call sfdisk to create partition table
total_size=`sfdisk -s ${node}`
total_size=`expr ${total_size} / 1024`
echo SD total size: ${total_size}KB
 
boot_start=`expr ${BOOTLOAD_RESERVE} \\* 1024 \\* 1024 / 512`
boot_size=`expr ${BOOT_ROM_SIZE} \\* 1024 \\* 1024 / 512`
rfs_start=`expr ${boot_size} + ${boot_start}`
rfs_size=`expr ${RFS_SIZE} \\* 1024 \\* 1024 / 512`
 
{ echo ${boot_start},${boot_size},0c,-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node}
 
echo "formatting boot"
mkfs.vfat -F 32 -n boot ${node}${part}1
echo "formatting rfs"
mkfs.ext4 -F ${node}${part}2 -Lrfs
</pre>
 
E.g.
 
<pre class="workstation-terminal">
root@sdvx-lite:~# ./sdcard-partition.sh /dev/mmcblk2
SD total size: 3776KB
[ 1341.905014] mmcblk2: p1 p2
Checking that no-one is using this disk right now ... OK
 
Disk /dev/mmcblk2: 3.7 GiB, 3959422976 bytes, 7733248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical):[ 1341.922729] mmcblk2: p1 p2
512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa77eb3f0
 
Old situation:
 
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 2048 264191 262144 128M c W95 FAT32 (LBA)
/dev/mmcblk2p2 264192 4458495 4194304 2G 83 Linux
 
>>> Created a new DOS disklabel with disk identifier 0xcce0c36f.
Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 128 MiB.
/dev/mmcblk2p2: Created a new partition 2 of type 'Linux' and of size 2 GiB.
/dev/mmcblk2p3:
New situation:
 
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 16384 278527 262144 128M c W95 FAT32 (LBA)
/dev/mmcblk2p2 278528 4472831 4194304 2G 83 Linux
 
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
formatting boot
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
formatting rfs
mke2fs 1.43-WIP (18-May-2015)
Discarding device blocks: done
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: 9a685543-1af2-4e39-83f3-b8a32248c021
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
 
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
 
root@sdvx-lite:~#
</pre>
8,155
edits

Navigation menu