Contents
It recommended creating firstly an SD-CARD for testing image built and make the first boot to prepare platform bootloader to be flash into NOR, NAND or eMMC bootable memory.
Updating platform from SD-CARD
Preparing SD-CARD
To create your bootable SD card you should use dd command with root privileges. Be careful to select the correct target SD-CARD device as it is explained bellow !
To prepare to flash SD-CARD you must have an SD-CARD reader port or SD-CARD USB reader.
Open a console into image build folder name as <YOCTO-DIR>/build/tmp/deploy/images/<MACHINE>, the SD-CARD images are named with .sdcard file extension and it is named as <IMAGE_NAME>-<MACHINE>.sdcard
linrt-tiny-image-phyboard-mira-imx6-3.ubifsExample with IMAGE_NAME : linrt-qt5-image and MACHINE : phyboard-mira-imx6-3
PC-HOST$ cd ~/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/ phyboard-mira-imx6-3$ ls *.sdcard linrt-qt5-image-phyboard-mira-imx6-3-20180115081044.rootfs.sdcard linrt-qt5-image-phyboard-mira-imx6-3.sdcard
Insert the SD-CARD into the reader and check the mounted device partitions from the SD-CARD with dmesg command.
Example with USB SD-CARD reader : /dev/sdb
PC-HOST$ dmesg ... [ 4951.182896] usb 1-2: USB disconnect, device number 7 [ 4951.516299] usb 1-2: new high-speed USB device number 8 using xhci_hcd [ 4951.657206] usb 1-2: New USB device found, idVendor=04e8, idProduct=6860 [ 4951.657209] usb 1-2: New USB device strings: Mfr=2, Product=3, SerialNumber=4 [ 4951.657211] usb 1-2: Product: SAMSUNG_Android [ 4951.657213] usb 1-2: Manufacturer: SAMSUNG [ 4951.657214] usb 1-2: SerialNumber: ce0916096b663d0e03 [40369.665723] usb 1-2: USB disconnect, device number 8 [43792.904441] usb 2-6: new SuperSpeed USB device number 2 using xhci_hcd [43792.927297] usb 2-6: New USB device found, idVendor=05dc, idProduct=b051 [43792.927302] usb 2-6: New USB device strings: Mfr=3, Product=4, SerialNumber=5 [43792.927306] usb 2-6: Product: microSD RDNANDR [43792.927309] usb 2-6: Manufacturer: Lexar [43792.927312] usb 2-6: SerialNumber: 000000000001 [43792.963614] usb-storage 2-6:1.0: USB Mass Storage device detected [43792.963681] scsi host4: usb-storage 2-6:1.0 [43792.963755] usbcore: registered new interface driver usb-storage [43792.965185] usbcore: registered new interface driver uas [43793.973706] scsi 4:0:0:0: Direct-Access Lexar microSD RDR 0815 PQ: 0 ANSI: 6 [43793.974585] sd 4:0:0:0: Attached scsi generic sg1 type 0 [43794.315438] sd 4:0:0:0: [sdb] 15954944 512-byte logical blocks: (8.17 GB/7.61 GiB) [43794.316025] sd 4:0:0:0: [sdb] Write Protect is off [43794.316036] sd 4:0:0:0: [sdb] Mode Sense: 23 00 00 00 [43794.316595] sd 4:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Open a console into image build folder name as <YOCTO-DIR>/build/tmp/deploy/images/<MACHINE>, the SD-CARD images are named with .sdcard file extension and it is named as <IMAGE_NAME>-<MACHINE>.sdcard
Example with IMAGE_NAME : linrt-qt5-image and MACHINE : phyboard-mira-imx6-3
[43794.324518] sd 4:0:0:0: [sdb] Attached SCSI removable disk
Example with SD-CARD integrated port reader : /dev/mmcblk0
PC-HOST$ dmesgimx6q-phytec-mira-rdk-nand.dtb ... [43950.062080] mmc0: new ultra high speed SDR50 SDHC card at address 0007 [43950.074551] mmcblk0: mmc0:0007 SD08G 7.42 GiB [43950.075724] mmcblk0: p1 p2 [43950.512964] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Before starting flash command, you must unmount all SD-CARD partitions. For example, using a USB SD-CARD reader mounted as /dev/sdc with one partition :
PC-HOST$ umount /dev/sdc1
Or using a USB SD-CARD reader mounted as /dev/mmcblck0 with 2 partitions
PC-HOST$ umount /dev/mmcblck0p1 PC-HOST$ umount /dev/mmcblck0p2
After having unmounted all partitions, you can flash the bootable SD-CARD with the command sudo dd if=<IMAGE_NAME>-<MACHINE>.sdcard of=/dev/<sdcard_device> bs=1MB; sync
For example with SD-CARD reader /dev/mmcblck0 :
PC-HOST$ cd ~/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/ PC-HOST$ sudo dd if=linrt-qt5-image-phyboard-mira-imx6-3.sdcard of=/dev/mmcblck0 bs=1MB; sync
For booting your platform from SD-CARD, set configuration boot switch correctly !
Refer to the manufacturer hardware configuration data sheet.
Expending root filesystem into SD-CARD after writing process
Writing SD-CARD create a root filesystem limited to the .sdcard image file size. If you want to use SD-CARD as root device and want to enlarge ext4 root filesystem to use all available space on it, you need to boot under Linux and use resisize2fs
TARGET# parted -m /dev/mmcblk0 unit B print BYT; /dev/mmcblk3:3991928832B:sd/mmc:512:512:msdos:SD USD:; 1:4194304B:12582911B:8388608B:::lba; 2:12582912B:138412031B:125829120B:ext4::;
To enlarge the second partition (ext4) on SD-CARD, you can expand it to the end block 3991928832B and resize ext4 filesystem inside :
TARGET# parted /dev/mmcblk0 resizepart 2 3991928831B TARGET# resize2fs /dev/mmcblk0p2 resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 15 The filesystem on /dev/mmcblk0p2 is now 3886080 blocks long.
Flashing/Updating NAND flash from SD-CARD
Flashing bootloader on the NAND
To flash barebox bootloader on the NAND flash from SD-CARD :
barebox:/ barebox_update -t nand /mnt/mmc/barebox.bin
To erase the environment variables from an older barebox installation (recommended), and reset the target:
barebox:/ erase /dev/nand0.barebox-environment.bb barebox:/ reset
Formatting the NAND flash from SD-CARD
If you have not updated Barebox on the target and already create UBI volumes, you just need to update Linux kernel image, devicetree or root filesystem you can take the next step !
Create UBI volumes in NAND to flash Linux kernel image, devicetree and root filesystem.
barebox:/ ubiformat -y /dev/nand0.root barebox:/ ubiattach /dev/nand0.root barebox:/ ubimkvol -t static /dev/nand0.root.ubi kernel 8M barebox:/ ubimkvol -t static /dev/nand0.root.ubi oftree 1M barebox:/ ubimkvol -t dynamic /dev/nand0.root.ubi root 0
Installing/updating Linux system in the NAND flash from SD-CARD
To update Linux Kernel and devicetree from SD-CARD :
barebox:/ ubiupdatevol /dev/nand0.root.ubi.kernel /mnt/mmc/uImage barebox:/ ubiupdatevol /dev/nand0.root.ubi.oftree /mnt/mmc/oftree
To update Linux filesystem from SD-CARD :
barebox:/ cp -v /mnt/mmc/rootfs.ubifs /dev/nand0.root.ubi.root
Flashing/Updating eMMC from SD-CARD
eMMC is supported as a SD-CARD media and can be flashed with .sdcard ext4 image file use to create SD-CARD. The .sdcard file can be downloaded from TFTP server repository through the network.
To check network communication between Host <TFTP_ADDRESS> and Target file :
barebox:/ ifup eth0 barebox:/ ping TFTP_ADDRESS host TFTP_ADDRESS is alive
For flashing eMMC with .sdcard image file, select the right image file as described in “Preparing SD-CARD” chapter.
Example, with IMAGE_NAME : linrt-tiny-image and MACHINE : phyboard-mira-imx6-3
PC-HOST$ cd ~/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/ PC-HOST$ ls *.sdcard linrt-tiny-image-phyboard-mira-imx6-3-20181120110317.rootfs.sdcard linrt-tiny-image-phyboard-mira-imx6-3.sdcard
To flash eMMC from network with linrt-tiny-image-phyboard-mira-imx6-3.sdcard image file :
barebox:/ detect mmc3 barebox:/ cp -v /mnt/tftp/linrt-tiny-image-phyboard-mira-imx6-3.sdcard /dev/mmc3
Expending root filesystem into eMMC after flashing process
Flashing eMMC from SD-CARD create a root filesystem limited to the .sdcard image file size. To enlarge ext4 root filesystem to use the fully eMMC device, you need to boot under Linux and use resisize2fs
TARGET# parted -m /dev/mmcblk3 unit B print BYT; /dev/mmcblk3:3991928832B:sd/mmc:512:512:msdos:SD USD:; 1:4194304B:12582911B:8388608B:::lba; 2:12582912B:138412031B:125829120B:ext4::;
To enlarge the second partition (ext4) on eMMC, you can expand it to the end block 3991928832B and resize ext4 filesystem inside :
TARGET# parted /dev/mmcblk3 resizepart 2 3991928831B TARGET# resize2fs /dev/mmcblk3p2 resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mmcblk3p2 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 15 The filesystem on /dev/mmcblk3p2 is now 3886080 blocks long.
Flashing bootloader on the eMMC from SD-CARD
To flash barebox bootloader on the eMMC from Network :
barebox:/ barebox_update -l barebox:/ barebox_update -t mmc3 /mnt/mmc/barebox.bin
To erase the environment variables from an older barebox installation (recommended),
barebox:/ cp /dev/zero /dev/mmc3.barebox-environment
After erasing the environment variables and before resetting target, make sure eMMC boot parameter is set to “disabled” or “user”
barebox:/ detect mmc3 barebox:/ devinfo mmc3 [...] Parameters: boot: disabled ("disabled", "boot0", "boot1", "user") probe: 0
Updating Linux system on the eMMC from SD-CARD
To update Linux Kernel and devicetree from Network, check the name of devicetree file for your platform before !
Example with MACHINE : phyboard-mira-imx6-3
barebox:/ detect mmc0 barebox:/ ls /mnt/mmc/*.dtb imx6q-phytec-mira-rdk-nand.dtb
To update Linux Kernel and devicetree in the eMMC from SD-CARD with imx6q-phytec-mira-rdk-nand.dtb file :
barebox:/ detect mmc3 barebox:/ cp /mnt/mmc/uImage /mnt/emmc/ barebox:/ cp /mnt/mmc/imx6q-phytec-mira-rdk-nand.dtb /mnt/emmc/
Flashing/Uptading SPI NOR flash from SD-CARD
Flashing bootloader on the SPI NOR
To flash barebox bootloader on the SPI NOR flash from SD-CARD :
barebox:/ erase /dev/m25p0.barebox barebox:/ cp /mnt/mmc/barebox.bin /dev/m25p0.barebox
To erase the environment variables from an older barebox installation (recommended), and reset the target
barebox:/ erase /dev/m25p0.barebox-environment barebox:/ reset
Installing/updating Linux system on the SPI NOR Flash from SD-CARD
To update Linux Kernel and devicetree from SD-CARD :
barebox:/ erase /dev/m25p0.kernel barebox:/ cp /mnt/mmc/uImage /dev/m25p0.kernel barebox:/ erase /dev/m25p0.oftree barebox:/ cp /mnt/mmc/oftree /dev/m25p0.oftree
To update Linux filesystem in the SPI Flash from SD-CARD :
Boot process from SPI Flash mounts filesystem from NAND flash or eMMC, refer to “Installing/updating Linux system in the NAND flash from SD-CARD” or “Installing/updating Linux system in the eMMC” chapters
Updating platform from Network
Preparing Network TFTP server configuration
To prepare to update target from the network you must have a TFTP server for download images to be flashed on target. To install it follow commands :
PC-HOST$ sudo apt-get install tftpd-hpa
Edit TFTP server configuration file to configure it as a stand-alone daemon :
PC-HOST$ sudo nano /etc/default/tftpd-hpa TFTP_USERNAME="nobody" TFTP_DIRECTORY="/home/johndoe/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/" TFTP_ADDRESS="192.168.3.10:69" TFTP_OPTIONS="-s -c"
Notes :
TFTP_ADDRESS is set to the default SERVER IP address defines in the barebox environment variables. If you set another address for your host, refer to “” chapter set change barebox environment variables !
TFTP_DIRECTORY must be set directly to get binaries from the image build folder name as <YOCTO-DIR>/build/tmp/deploy/images/<MACHINE>. The path must be absolute !
To apply new settings, you must restart the TFTP server :
PC-HOST$ sudo service tftpd-hpa restart
Target network configuration
To check network configuration on target bootloader :
barebox:/ ifup eth0 barebox:/ devinfo eth0
The “devinfo” command returns barebox network settings :
ipaddr=192.168.3.11 netmask=255.255.255.0 gateway=192.168.3.10 serverip=192.168.3.10
The “serverip” variable is the IP address uses to get binaries on TFTP server repository
To change settings, you must edit /env/network/eth0 environment file :
barebox:/ edit /env/network/eth0
To quit the editor type CTRL+D and save environment file :
barebox:/saveenvNotes : to set target IP to DHCP, modify variable ip to dhcp into /env/network/eth0 environment file :
ip=dhcpFlashing/Uptading NAND flash from network
To check network communication between Host <TFTP_ADDRESS> and Target file :
barebox:/ ifup eth0 barebox:/ ping TFTP_ADDRESS host TFTP_ADDRESS is alive
Flashing bootloader on the NAND flash from network
To flash barebox bootloader on the NAND flash from Network :
barebox:/ barebox_update -t nand /mnt/tftp/barebox.bin
To erase the environment variables from an older barebox installation (recommended), and reset the target
barebox:/ erase /dev/nand0.barebox-environment.bb barebox:/ reset
Formatting the NAND flash
If you have not uptated Barebox on the target and already create UBI volumes, you just need to update Linux kernel image, devicetree or root filesystem you can take the next step !
Create UBI volumes in NAND to flash Linux kernel image, devicetree and root filesystem.
barebox:/ ubiformat -y /dev/nand0.root barebox:/ ubiattach /dev/nand0.root barebox:/ ubimkvol -t static /dev/nand0.root.ubi kernel 8M barebox:/ ubimkvol -t static /dev/nand0.root.ubi oftree 1M barebox:/ ubimkvol -t dynamic /dev/nand0.root.ubi root 0
Installing/updating Linux system on the NAND flash from network
To update Linux Kernel and devicetree from Network, check the name of devicetree file for your platform before !
Example with MACHINE : phyboard-mira-imx6-3
PC-HOST$ cd ~/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/*.dtb PC-HOST$ ls *.dtb imx6q-phytec-mira-rdk-nand.dtb uImage--4.9-1.0.x-r0-imx6q-phytec-mira-rdk-nand-20181020110317.dtb uImage-imx6q-phytec-mira-rdk-nand.dtb
To update Linux Kernel and devicetree in the NAND Flash from Network with imx6q-phytec-mira-rdk-nand.dtb file :
barebox:/ ubiupdatevol /dev/nand0.root.ubi.kernel /mnt/tftp/uImage barebox:/ ubiupdatevol /dev/nand0.root.ubi.oftree /mnt/tftp/imx6q-phytec-mira-rdk-nand.dtb
To update Linux filesystem from Network, check the name ubifs file for your platform before !
Example with IMAGE_NAME : linrt-tiny-image and MACHINE : phyboard-mira-imx6-3
PC-HOST$ cd ~/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/ PC-HOST$ ls *.ubifs linrt-tiny-image-phyboard-mira-imx6-3-20181120110317.rootfs.ubifs linrt-tiny-image-phyboard-mira-imx6-3.ubifs
To update Linux filesystem from Network with linrt-tiny-image-phyboard-mira-imx6-3.ubifs file:
barebox:/ cp -v /mnt/tftp/linrt-tiny-image-phyboard-mira-imx6-3.ubifs /dev/nand0.root.ubi.root
Flashing/Updating eMMC from Network
eMMC is supported as a SD-CARD media and can be flashed with .sdcard ext4 image file use to create SD-CARD. The .sdcard file can be downloaded from TFTP server repository through the network.
To check network communication between Host <TFTP_ADDRESS> and Target file :
barebox:/ ifup eth0 barebox:/ ping TFTP_ADDRESS host TFTP_ADDRESS is alive
For flashing eMMC with .sdcard image file, select the right image file as described in “Preparing SD-CARD” chapter.
Example, with IMAGE_NAME : linrt-tiny-image and MACHINE : phyboard-mira-imx6-3
PC-HOST$ cd ~/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/ PC-HOST$ ls *.sdcard linrt-tiny-image-phyboard-mira-imx6-3-20181120110317.rootfs.sdcard linrt-tiny-image-phyboard-mira-imx6-3.sdcard
To flash eMMC from network with linrt-tiny-image-phyboard-mira-imx6-3.sdcard image file :
barebox:/ detect mmc3 barebox:/ cp -v /mnt/tftp/linrt-tiny-image-phyboard-mira-imx6-3.sdcard /dev/mmc3
Expending root filesystem into eMMC after flashing process
Flashing eMMC from SD-CARD create a root filesystem limited to the .sdcard image file size. To enlarge ext4 root filesystem to use the fully eMMC device, you need to boot under Linux and use resisize2fs
TARGET# parted -m /dev/mmcblk3 unit B print BYT; /dev/mmcblk3:3991928832B:sd/mmc:512:512:msdos:SD USD:; 1:4194304B:12582911B:8388608B:::lba; 2:12582912B:138412031B:125829120B:ext4::;
To enlarge the second partition (ext4) on eMMC, you can expand it to the end block 3991928832B and resize ext4 filesystem inside :
TARGET# parted /dev/mmcblk3 resizepart 2 3991928831B TARGET# resize2fs /dev/mmcblk3p2 resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mmcblk3p2 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 15 The filesystem on /dev/mmcblk3p2 is now 3886080 blocks long.
Flashing bootloader on the eMMC from network
To flash barebox bootloader on the eMMC from Network :
barebox:/ barebox_update -l barebox:/ barebox_update -t mmc3 /mnt/tftp/barebox.bin
To erase the environment variables from an older barebox installation (recommended),
barebox:/ cp /dev/zero /dev/mmc3.barebox-environment
After erasing the environment variables and before resetting target, make sure eMMC boot parameter is set to “disabled” or “user”
barebox:/ detect mmc3 barebox:/ devinfo mmc3 [...] Parameters: boot: disabled ("disabled", "boot0", "boot1", "user") probe: 0
Updating Linux system on the eMMC from Network
To update Linux Kernel and devicetree from Network, check the name of devicetree file for your platform before !
Example with MACHINE : phyboard-mira-imx6-3
PC-HOST$ cd ~/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/*.dtb PC-HOST$ ls *.dtb imx6q-phytec-mira-rdk-nand.dtb uImage--4.9-1.0.x-r0-imx6q-phytec-mira-rdk-nand-20181020110317.dtb uImage-imx6q-phytec-mira-rdk-nand.dtb
To update Linux Kernel and devicetree in the eMMC from Network with imx6q-phytec-mira-rdk-nand.dtb file :
barebox:/ ls /mnt/emmc barebox:/ cp /mnt/tftp/zImage /mnt/emmc/ barebox:/ cp /mnt/tftp/uImage-imx6q-phytec-mira-rdk-nand.dtb /mnt/emmc/
Flashing/Updating SPI NOR flash from Network
To check network communication between Host <TFTP_ADDRESS> and Target file :
barebox:/ ifup eth0 barebox:/ ping TFTP_ADDRESS host TFTP_ADDRESS is alive
Flashing bootloader on the SPI NOR flash from network
To flash barebox bootloader on the eMMC from Network :
barebox:/ erase /dev/m25p0.barebox barebox:/ cp /mnt/tftp/barebox.bin /dev/m25p0.barebox
To erase the environment variables from an older barebox installation (recommended), and reset the target :
barebox:/ erase /dev/m25p0.barebox-environment barebox:/ reset
Installing/updating Linux system on the SPI NOR flash from network
To update Linux Kernel and devicetree from Network, check the name of devicetree file for your platform before !
Example with MACHINE : phyboard-mira-imx6-3
PC-HOST$ cd ~/yocto/build/tmp/deploy/images/phyboard-mira-imx6-3/*.dtb PC-HOST$ ls *.dtb imx6q-phytec-mira-rdk-nand.dtb uImage--4.9-1.0.x-r0-imx6q-phytec-mira-rdk-nand-20181020110317.dtb uImage-imx6q-phytec-mira-rdk-nand.dtb
To update Linux Kernel and devicetree in the SPI NOR flash from Network with imx6q-phytec-mira-rdk-nand.dtb file :
barebox:/ erase /dev/m25p0.kernel barebox:/ cp /mnt/mmc/uImage /dev/m25p0.kernel barebox:/ erase /dev/m25p0.oftree barebox:/ cp /mnt/mmc/imx6q-phytec-mira-rdk-nand.dtb /dev/m25p0.oftree
To update Linux filesystem from SD-CARD :
Boot process from SPI Flash mount filesystem from NAND flash or eMMC, refer to “Installing/updating Linux system in the NAND flash from SD-CARD” or “Installing/updating Linux system in the eMMC from SD-CARD” chapters
