Flash the NAND using tftp For Rugged Board i.MX6UL

Objective:

This guide describes a method of flashing the NAND using tftp for the Rugged Board i.MX6UL .

Materials:

Hardware:

Software:

  • Ubuntu 16.04

Booting the Board from Network :-

Booting from network means loading the kernel and device-tree over TFTP. The bootloader itself must already be loaded from any other boot device available.

Procedure:

Development Host Preparations :-

On the development host, a TFTP server must be installed and configured. The following tools will be needed to boot the Kernel from Ethernet:

  1. A TFTP server and

  2. An optional tool for starting/stopping a service (xinetd).

  • Following packages need to be install in the host PC.Before installing the below packages, please check your internet(Ethernet Cable) connection.

Ubuntu and Debian:

$ sudo apt-get update

$ sudo apt-get install tftpd-hpa xinetd

After the installation, there are two ways to configure the TFTP server :

  1. As a standalone daemon

  2. Controlled and handled by xinetd

  • First, create a directory to store the TFTP files :

host$ sudo mkdir /tftpboot
host$ sudo chmod -R 777 /tftpboot
host$ sudo chown -R nobody /tftpboot 
## This command is changing the ownership of the "/tftpboot" directory and everything underneath it to the user or group specified as "nobody."
Then copy your BSP image files to this directory.You also need to configure a static IP address for the appropriate interface. The default IP address of the PHYTEC evaluation boards is 192.168.3.11. So setting 192.168.3.10 with netmask 255.255.255.0 as a host address is a good choice.

Configure TFTP as a stand alone daemon

  • Create or edit /etc/default/tftpd-hpa :

host$ sudo nano /etc/default/tftpd-hpa

 # /etc/default/tftpd-hpa
   TFTP_USERNAME="nobody"
   TFTP_DIRECTORY="/tftpboot"
   TFTP_ADDRESS="192.168.3.10:69"
   TFTP_OPTIONS="-s -c"

for save the changes press ctrl+o then press enter button then press  crtl+x 
Then connect the ethernet cable from your pc to board and check it as below:-

Check the (inet 192.168.3.10) is showing or not.
Set TFTP_DIRECTORY to your TFTP server root directory

Set TFTP_ADDRESS to the host address the server is listening to (set to 192.168.3.10:69 )

Set TFTP_OPTIONS, following command shows the available options:

Restart the services to pick-up the configuration changes :

host$ sudo service tftpd-hpa restart
NOTE:- If any error will popup then check the ip adress proporly changed or not.
The TFTP server is automatically mounted to /mnt/tftp

If “tftp” file is not present inside the /mnt/ as below : 
Then copy the tftp file manually : 
  • NOTE:- You can download the “tftp” file from below link :

( https://drive.google.com/drive/folders/11QuBQWwWUerL_r057QBlQ_IuxvF7FDRz?usp=sharing )

NAND UPDATING STEPS :-

  • Then open the board terminal by :

$ sudo minicom -s 
  • Stop it in bootloader level then type the bellow commands :

Update barebox :

bootloader$ ifup eth0

bootloader$ barebox_update -t nand /mnt/tftp/barebox.bin

We also recommend erasing the environment of the old barebox. Otherwise, the new barebox will use the old environment.

bootloader$ erase /dev/nand0.barebox-environment.bb
After erasing the environment, you have to reset your board. Otherwise, the barebox will still use the old environment.

bootloader$ reset  

 #Again stop it in bootloader level
#Again 

bootloader$ ifup eth0

Update the Kernel and devicetree :

  • Create UBI volumes for Linux kernel, oftree, and root filesystem in NAND :

bootloader$ ubiformat /dev/nand0.root
bootloader$ ubiattach /dev/nand0.root
bootloader$ ubimkvol -t static /dev/nand0.root.ubi kernel 16M
bootloader$ ubimkvol -t static /dev/nand0.root.ubi oftree 1M
bootloader$ ubimkvol -t dynamic /dev/nand0.root.ubi root 0
  • Now get the Linus kernel and oftree from your TFTP server and store it into the NAND Flash :

bootloader$ ubiupdatevol /dev/nand0.root.ubi.kernel /mnt/tftp/zImage
bootloader$ ubiupdatevol /dev/nand0.root.ubi.oftree /mnt/tftp/oftree

Update the root file system :

  • For flashing Linux's root filesystem into NAND, please wait :

bootloader$ cp -v /mnt/tftp/root.ubifs /dev/nand0.root.ubi.root 

 ## change the name of root.ubifs as per your “.ubifs” name.

Follow the below logs :-

barebox 2019.01.0-bsp-yocto-i.mx6ul-pd19.1.0 #1 Tue Feb 7 05:12:29 UTC 2023


Board: Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND
detected i.MX6 UltraLite revision 1.2
i.MX reset reason POR (SRSR: 0x00000001)
i.MX6 UltraLite unique ID: d1e090b62c2fb9d4
mdio_bus: miibus0: probed
eth0: got preset MAC address: 50:2d:f4:24:6f:5b
nand: ONFI flash detected
nand: NAND device: Manufacturer ID: 0x2c, Chip ID: 0xdc (Micron MT29F4G08ABADAH4), 512MiB, page size: 2048, OOB size: 64
Bad block table found at page 262080, version 0x01
Bad block table found at page 262016, version 0x01
imx-usb 2184200.usb@2184200.of: USB EHCI 1.00
imx-esdhc 2190000.usdhc@2190000.of: registered as mmc0
state: New state registered 'state'
state: Using bucket 0@0x00000000
netconsole: registered as netconsole-1
phySOM-i.MX6: Using environment in NAND flash
malloc space: 0x8fe7cec0 -> 0x9fcf9d7f (size 254.5 MiB)
envfs: no envfs (magic mismatch) - envfs never written?
running /env/bin/init...
Hit m for menu or any key to stop autoboot:    2

type exit to get to the menu
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND:/ 
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND:/ 
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND:/ 
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND:/ 


eth0: 100Mbps full duplex link detected
T Image Metadata:
  build: #1 Tue Feb 7 05:12:29 UTC 2023
  release: 2019.01.0-bsp-yocto-i.mx6ul-pd19.1.0
  parameter: memsize=512
imx-bbu-nand-fcb: Firmware @ page 256, size 315 pages has crc32: 0x065837be
imx-bbu-nand-fcb: Firmware @ page 1152, size 315 pages has crc32: 0x065837be
imx-bbu-nand-fcb: Primary firmware is on pages 256-571, valid, clean
imx-bbu-nand-fcb: Secondary firmware is on pages 1152-1467, valid, clean
imx-bbu-nand-fcb: ROM uses slot 0
update barebox from /mnt/tftp/barebox.bin using handler nand to nand0.barebox (y/n)?
updating barebox...
imx-bbu-nand-fcb: updating slot 1
imx-bbu-nand-fcb: writing firmware 1 to block 18 (ofs 0x00240000)
imx-bbu-nand-fcb: Writing FCB/DBBT on block 0
imx-bbu-nand-fcb: Writing FCB/DBBT on block 1
imx-bbu-nand-fcb: Writing FCB/DBBT on block 2
imx-bbu-nand-fcb: Writing FCB/DBBT on block 3
imx-bbu-nand-fcb: updating slot 0
imx-bbu-nand-fcb: writing firmware 0 to block 4 (ofs 0x00080000)
update succeeded

barebox 2019.01.0-bsp-yocto-i.mx6ul-pd19.1.0 #1 Tue Feb 7 05:12:29 UTC 2023


Board: Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND
detected i.MX6 UltraLite revision 1.2
i.MX reset reason WDG (SRSR: 0x00000010)
i.MX6 UltraLite unique ID: d1e090b62c2fb9d4
mdio_bus: miibus0: probed
eth0: got preset MAC address: 50:2d:f4:24:6f:5b
nand: ONFI flash detected
nand: NAND device: Manufacturer ID: 0x2c, Chip ID: 0xdc (Micron MT29F4G08ABADAH4), 512MiB, page size: 2048, OOB size: 64
Bad block table found at page 262080, version 0x01
Bad block table found at page 262016, version 0x01
imx-usb 2184200.usb@2184200.of: USB EHCI 1.00
imx-esdhc 2190000.usdhc@2190000.of: registered as mmc0
state: New state registered 'state'
state: Using bucket 0@0x00000000
netconsole: registered as netconsole-1
phySOM-i.MX6: Using environment in NAND flash
malloc space: 0x8fe7cec0 -> 0x9fcf9d7f (size 254.5 MiB)
envfs: no envfs (magic mismatch) - envfs never written?
running /env/bin/init...
Hit m for menu or any key to stop autoboot:    3

type exit to get to the menu
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND:/ 


ubiformat: nand0.root (nand), size 531628032 bytes (507 MiB), 4056 eraseblocks of 131072 bytes (128 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 4055 -- 100 % complete  
ubiformat: 4052 eraseblocks have valid erase counter, mean value is 2
ubiformat: 4 bad eraseblocks found, numbers: 4052, 4053, 4054, 4055
ubiformat: formatting eraseblock 3751 -- 92 % complete  

ubi0: scanning is finished
ubi0: registering /dev/nand0.root.ubi
ubi0: attached mtd0 (name "nand0.root", size 507 MiB) to ubi0
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi0: good PEBs: 4052, bad PEBs: 4, corrupted PEBs: 0
ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 6/3, WL threshold: 65536, image sequence number: 11977
ubi0: available PEBs: 3970, total reserved PEBs: 82, PEBs reserved for bad PEB handling: 76

ubi0: registering kernel as /dev/nand0.root.ubi.kernel

ubi0: registering oftree as /dev/nand0.root.ubi.oftree

ubi0: registering root as /dev/nand0.root.ubi.root

eth0: 100Mbps full duplex link detected


[####################################################################################################################################]
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND:/

NOTE:- IF any case the zimage and oftree are not updating or showing the log like bellow :-

  • Then you have to check the images are proporly copied into the /tftpboot/ folder or not , if not copied 1st copy the images proporly :

host$ sudo service tftpd-hpa restart
  • Then again follow the NAND updating stapes (from barebox to .Ubifs)

Last updated