Yocto Flash From Net

From Variscite Wiki


VAR-SOM-AM62 - Flash Yocto images from network

{{#ifnot: |

|}}

Flashing a complete Yocto system from Network using TFTP & NFS

NOTES:
  1. Please make sure your host system is ready to use TFTP/NFS. Use our Wiki if required: Yocto Setup TFTP/NFS
  2. This is a concept Wiki. Please adapt it to your system and your requirements.
  3. Android and Debian can be flashed in the same way.

Build minimal file system

To setup a build environment follow steps 1 & 3 of the Build Yocto from source code guide.
Then, append the following to the conf/local.conf file in your Yocto build directory:

IMAGE_INSTALL:append = " bash e2fsprogs-mke2fs tar dosfstools zstd"

And build the image:

$ MACHINE=am62x-var-som bitbake core-image-minimal

Create a root file system and copy files:

$ mkdir ~/flash_rootfs
$ sudo tar xf deploy-ti/images/am62x-var-som/core-image-minimal-am62x-var-som.tar.zst -C ~/flash_rootfs
$ sudo cp -a ~/flash_rootfs/boot/* /tftpboot/

Edit /etc/exports. E.g.

$ sudo gedit /etc/exports

...and add the following line to it (replace <uname> with the actual username):

/home/<uname>/flash_rootfs    *(rw,sync,no_root_squash,no_all_squash,no_subtree_check) 

Restart the NFS server:

$ sudo /etc/init.d/nfs-kernel-server restart

Insert the recovery SD card into your host PC and copy the following files from it (assuming it is mounted at /media):

$ sudo mkdir ~/flash_rootfs/opt/
$ sudo cp -a /media/$USER/root/opt/images ~/flash_rootfs/opt/images
$ sudo cp /media/$USER/root/usr/bin/*.sh  ~/flash_rootfs/usr/bin/

Boot the board, stop the autoboot to get to the U-Boot command line, and set the following environment variables:

=> setenv serverip <HOST_IP_ADDRESS>                (replace <HOST_IP_ADDRESS> with the actual IP address of your host - run 'ifconfig' on the host to get it)
=> setenv ipaddr <TARGET_IP_ADDRESS>                (replace <TARGET_IP_ADDRESS> with the IP address for the target)
=> setenv image Image
=> setenv fdtfile k3-am625-var-som-symphony.dtb
=> setenv rootpath "/home/<user>/rootfs"            (replace <user> with the username on your host computer)
=> setenv netargs 'setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},nolock,v3 rw ip=${ipaddr}:::::eth0'
=> setenv netboot 'tftp ${loadaddr} ${image}; tftp ${fdtaddr} ${fdtfile}; run netargs; booti ${loadaddr} - ${fdtaddr}'

=> setenv bootcmd 'run netboot'
=> saveenv
=> boot

On the target flash your system:

# install_yocto.sh

A complete system is flashed into the SOMs internal storage (NAND flash/eMMC).
Once the file system is built you can use it again and again to flash your VAR-SOM-AM62.
You can update the images to use your images and/or customize install_yocto.sh to your requirements.