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== Storing 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 NOR and NAND internal storage** in this configuration the primary boot images will be fetched fomr NOR flash storage, while the root file system will be fetched from NAND flash* booting with NAND only** in this configuration the whole system will boot without the need of a NOR flash storage, all images and the root file system into will be fetched from NAND flash ==* 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 == Storing 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}}
==... into NOR flash ==
===Uu-Boot===Update to the latest u-boot version allows usage of u-boot environment variables available. <pre class="board-terminal">=> run loadUsing FEC deviceTFTP from server 192.168.0.13; our IP address is 192.168.0.89Filename 'sdvx/u-boot/sdvx-1.0.0_mx6dl_sfczg_spi_u-boot.imx'.Load address: 0x12000000Loading: ################################################################# ################################################################# ## 1.4 MiB/sdoneBytes transferred = 671788 (a402c hex)=> run spi_updateSF: Detected S25FL256S with page size 64 KiB, total 32 MiB=></pre> ===Linux kernel image and device tree=== We assume that the following environment variables are present in u-boot: <pre>loadk=tftpboot ${loadaddr} ${serverip}:${bootfile}loadfdt= ... into NAND flash tftpboot ${fdtaddr} ${serverip}:${fdtfile}spi_updatek=sf erase 200000 800000; sf write ${loadaddr} 200000 ${filesize}spi_updatefdt=sf erase 180000 80000; sf write ${fdtaddr} 180000 ${filesize}spi_loadk=sf read ${loadaddr} 200000 800000spi_loadfdt=sf read ${fdtaddr} 180000 80000spi_nand=sf probe; run spi_loadk spi_loadfdt nandargs addcons addmisc; if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi</pre> * Update the <code>bootfile</code> and <code>fdtfile</code> environment variables to fit the filename as found inside the TFTP server.* Program kernel and device tree on NOR flash with the following U-Bootcommand <pre class="board-terminal">sf probe; run loadk spi_updatek loadfdt spi_updatefdt</pre> E.g.: <pre class="board-terminal">=> sf probe; run loadk spi_updatek loadfdt spi_updatefdtSF: Detected S25FL256S with page size 64 KiB, total 32 MiBUsing FEC deviceTFTP from server 192.168.0.13; our IP address is 192.168.0.98Filename 'sdvx/linux/sdvx-1.0.0_lite_uImage'.Load address: 0x12000000Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ############################################# 1.6 MiB/sdoneBytes transferred =6437016 (623898 hex)Using FEC deviceTFTP from server 192.168.0.13; our IP address is 192.168.0.89Filename 'sdvx/linux/sdvx-1.0.0_lite_imx6dl-sfczg-cb0043.dtb'.Load address: 0x18000000Loading: ######### 1.2 MiB/sdoneBytes transferred =42547 (a633 hex)=Linux kernel image ></pre> Reboot the system and device treeconfigure U-Boot to apply the new configuration <pre class="board-terminal">=> setenv bootcmd run spi_nand=> saveenv</pre>
== ... into NAND flash ==
===u-Boot===
u-boot on NAND flash must be programmed using NXP <code>kobs-ng</code> utility: this tool is required for writing the correct u-boot image on NAND storing all information needed by bootrom to identify the NAND as a boot device.
Here below an example:
* boot the system via SD on NFS
* uses a rfs with <b>kobs-ng</b> utility available on it (e.g. DAVE's rfs provided with XELK)
* copy the related u-boot imx image file on nfs /home/root (for example)
* execute kobs-ng passing the parameters for flashing u-boot on NAND
mmcboot=run mmcargs addcons addmisc; if run mmc_loadk; then if run mmc_loadfdt; then if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi; fi; fi
</pre>
Using an SD card or an eMMC device assumes that <code>bootfile</code>, <code>fdtfile</code> and <code>splashfile</code> are stored into fist MMC device partition.
Then, u-boot uses the previous listed commands for reading the binary images and starting the linux bootstrap from the ''MMC part 2'' (which is reserved for the root-file system storage).
The following u-boot environment variables are present for this purposes:
<pre>
mmcargs=setenv bootargs root=${mmcroot}
mmcroot=/dev/mmcblk2p2 rootwait rw
</pre>
=== boot vars ===
The following environment variables should be configured for u-boot properly reading the boot files from the first SD card partition, e.g.
then save the environment and reboot the system to apply the new configuration:
<pre class="board-terminal">
=> saveenv
Saving Environment to MMC...
Writing to MMC(2)... done
=> reset
</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>
{{ImportantMessage|text=Please note that MTD partition index may change depending of flash device availability, flash device size, u-boot environment variables or kernel device driver load order. Always take care of looking inside <code>/proc/mtd</code> to match your specific layout}}
* Format and initialize ''nand-ubi'' partition, which in our case is <code>mtd7</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
<pre>
ubiformat /dev/mtd7
ubiattach -m 7
ubimkvol /dev/ubi0 -N rootfs -m
</pre>
E.g.
<pre class="board-terminal">
root@sdvx-lite:~# ubiformat /dev/mtd7
ubiformat: mtd7 (nand), size 1048576000 bytes (1000.0 MiB), 8000 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes