Changes between Version 22 and Version 23 of provisioning


Ignore:
Timestamp:
03/07/2023 08:55:19 PM (15 months ago)
Author:
Tim Harvey
Comment:

fix ubifs image transfer instructions

Legend:

Unmodified
Added
Removed
Modified
  • provisioning

    v22 v23  
    327327
    328328==== Root Filesystem ====
    329 The ubi root filesystem is originally built by the build system of the specific BSP your using, however if you end up imaging this onto a board, and customizing it, you may be able to pull it back off as long as your flash size is far less than your memory:
    330  * From Linux assuming /tmp is a tmpfs (ram based) and that you are booted into the filesystem you are copying and you have more ram available than the size of /dev/mtd2 (such as a 256MB flash on a 512MB system)
    331 {{{#!bash
    332 dd if=/dev/mtd2 of=/tmp/ubi bs=4M
    333 }}}
    334  * From U-Boot
    335 {{{#!bash
    336 # read the rootfs (filesystem) partition into temporary memory, note the size reported below as 0xef00000
    337 
    338 Ventana > nand read ${loadaddr} rootfs
    339 
    340 NAND read: device 0 offset 0x1100000, size 0xef00000
    341  250609664 bytes read: OK
    342 
    343 
    344 # store it to file on micro-SD with an ext4 fs (size re-used from above)
    345 Ventana > mmc dev 0 && ext4write mmc 0:1 ${loadaddr} /rootfs 0xef00000
    346 switch to partitions #0, OK
    347 mmc0 is current device
    348 File System is consistent
    349 update journal finished
    350 250609664 bytes written in 57489 ms (4.2 MiB/s)
    351 Ventana >
    352 
    353 # or store it to file on USB mass storage with an ext4 fs
    354 usb start && usb dev 0 && ext4write usb 0:1 ${loadaddr} /rootfs 0xef00000
    355 }}}
    356   - Note that your ext4 filesystem must not have checksums enabled (metadata_csum, a feature added to newer e2fsprogs) as U-Boot does not support this in ext4write.
     329The ubi root filesystem is originally built by the build system of the specific BSP your using, however if you end up imaging this onto a board, and customizing it, you will not be able to bit-per-bit copy it to another board due to flash geometry changes and bad block mapping on the physical raw NAND parts.
     330
     331Instead, you will have to boot a ramdisk based Linux rescue image, mount the ubifs and create a tarball of the files which you can then use to re-create a ubi on a Linux development host that can be applied to a new target board via U-Boot or Linux.
     332
     333Procedure:
     334 1. Boot a Linux rescue image that has networking and UBI/EXT4/FAT filesystem support. The [wiki:buildroot#VentanaIMX6 buildroot based image] is suitable for this. You will need to copy the uImage and dtb files from http://dev.gateworks.com/buildroot/ventana/minimal/ to a TFTP server on your network or a removable microSD or USB storage device and boot with one of the following:
     335  a. boot rescue image from network tftpserver
     336{{{#!bash
     337setenv bootargs console=ttymxc1,115200
     338setenv fsload tftpboot
     339setenv bootdir ventana # set this to the prefix of your tftp dir
     340run loadfdt && $fsload $loadaddr $bootdir/uImage && bootm $loadaddr - $fdt_addr
     341}}}
     342  b. boot rescue image from microSD (dev 0 partition 1) with ext/fat filesystem
     343{{{#!bash
     344setenv bootargs console=ttymxc1,115200
     345setenv fsload load mmc 0:1
     346setenv bootdir . # set this to the prefix of your tftp dir
     347run loadfdt && $fsload $loadaddr $bootdir/uImage && bootm $loadaddr - $fdt_addr
     348}}}
     349  c. boot rescue image from USB (dev 0 partition 1) with ext/fat filesystem
     350{{{#!bash
     351setenv bootargs console=ttymxc1,115200
     352setenv fsload load usb 0:1
     353usb start
     354setenv bootdir . # set this to the prefix of your tftp dir
     355run loadfdt && $fsload $loadaddr $bootdir/uImage && bootm $loadaddr - $fdt_addr
     356}}}
     357 2. Mount a filesystem on removable storage (you could use a tmpfs filesystem to do this on a ramdisk if you have enough space):
     358{{{#!bash
     359mkdir /mnt/removable
     360mount /dev/sda1 /mnt/removable
     361}}}
     362  * /dev/sd* would be for USB or mSATA devices and /dev/mmc* would be for microSD devices
     363 3. Mount the ubifs:
     364{{{#!bash
     365ubiattach /dev/ubi_ctrl -m 2 # attach /dev/mtd2 as /dev/ubi0
     366mkdir -p /mnt/ubifs # create a mountpoint for it
     367mount -t ubifs ubi0:rootfs /mnt/ubifs # mount 'rootfs' volume
     368}}}
     369  * Note that at this point you could create a tarball of the rootfs if you want to perfor the following steps later or on a Linux development host (tar --numeric-owner -cvzf /mnt/removable/rootfs.tar.gz -C /mnt/ubifs .)
     370 4. Create a ubi image for the particular flash geometry of the target device (see wiki:linux/ubi#creatingubi):
     371  a. 'normal' geometry FLASH devices (2048 byte page size)
     372{{{#!bash
     373# create a ubifs image
     374mkfs.ubifs -F -m 2048 -e 124KiB -c 16248 -x zlib -o /mnt/removable/root.ubifs -d /mnt/ubifs
     375# create a ubi image
     376cat <<EOF > ubinize.cfg
     377[ubifs]
     378mode=ubi
     379image=/mnt/removable/root.ubifs
     380vol_id=0
     381vol_type=dynamic
     382vol_name=rootfs
     383vol_flags=autoresize
     384EOF
     385# create ubi suitable for 2048byte page size and 128KiB block size devices
     386ubinize -m 2048 -p 128KiB -o /mnt/removable/root.ubi ubinize.cfg
     387}}}
     388   * Note that the mkfs.ubifs process can take quite a bit of time with no output depending on the size of your filesystem; takes about 8 minutes for a 1GiB filesystem
     389  b. 'large' geometry FLASH devices (4096 byte page size)
     390{{{#!bash
     391# create a ubif image
     392mkfs.ubifs -F -m 4096 -e 248KiB -c 8124 -x zlib -o /mnt/removable/root.ubifs -d /mnt/ubifs
     393# create a ubi image
     394cat <<EOF > ubinize.cfg
     395[ubifs]
     396mode=ubi
     397image=/mnt/removable/root.ubifs
     398vol_id=0
     399vol_type=dynamic
     400vol_name=rootfs
     401vol_flags=autoresize
     402EOF
     403# create ubi suitable for 4096byte page size and 256KiB block size devices
     404ubinize -m 4096 -p 256KiB -o /mnt/removable/root.ubi ubinize.cfg
     405}}}
     406   * Note that the mkfs.ubifs process can take quite a bit of time with no output depending on the size of your filesystem; takes about 8 minutes for a 1GiB filesystem
     407 5. Unmount the filesystems:
     408{{{#!bash
     409umount /mnt/removable
     410umount /mnt/ubifs
     411ubidetach /dev/ubi_ctrl -m 2
     412}}}
    357413
    358414
     
    369425}}}
    370426 2. once the above is flashed with the Gateworks JTAG adapter and software you can flash the ubi (much more quickly than via JTAG) within U-Boot
    371  3. break out into the bootloader, transfer the ubi image from a tftp server into SDRAM, and flash it:
     427 3. break out into the bootloader and load the ubi image and flash it:
     428  a. from network via tftp:
    372429{{{#!bash
    373430setenv ipaddr 192.168.1.1 # local ip
     
    377434nand write ${loadaddr} rootfs ${filesize} # write the downloaded ubi to rootfs
    378435}}}
     436  b. from removable storage via msata (device 0 partition 1):
     437{{{#!bash
     438sata init
     439load sata 0:1 $loadaddr root.ubi
     440nand erase.part rootfs
     441nand write $loadaddr rootfs $filesize
     442}}}
     443 c. from removable storage via USB (device 0 partition 1):
     444{{{#!bash
     445usb start
     446load usb 0:1 $loadaddr root.ubi
     447nand erase.part rootfs
     448nand write $loadaddr rootfs $filesize
     449}}}
     450 d. from removable storage via microSD (device 0 partition 1):
     451{{{#!bash
     452load mmc 0:1 $loadaddr root.ubi
     453nand erase.part rootfs
     454nand write $loadaddr rootfs $filesize
     455}}}
     456  * Note writing the nand may take some time; several minutes for a 600MB ubi
    379457
    380458Notes: