Changes between Version 23 and Version 24 of provisioning
- Timestamp:
- 10/24/2023 11:49:25 PM (13 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
provisioning
v23 v24 7 7 8 8 You could stitch all these various images together into a 'disk image' or 'device image' and flash it as a single object however doing so on a particularly large flash device, say an 8GiB eMMC can take a long time depending on how much data you need to write. 9 10 == Overall Venice Recommendations 11 This wiki page has a great amount of information. 12 13 Provisioning refers to flashing 100s or 1000s of boards with the same software when placing a large order with Gateworks. Gateworks typically does not want a 900MB .bin JTAG file because this will take forever to flash. Gateworks prefers a compressed image that shortens the time to flash the eMMC. 14 15 16 There are two recommended options from Gateworks: 17 * Option A: 18 * Pull off / rip an image of a single known configured system ('gold image') and then flash to 100s of more boards 19 * Can require consideration of unique information such as serial-number from /proc/device-tree/serial-number, a mac address, or a unique ID from a crypto device when duplicated across 100s of boards 20 * Option B: 21 * Create an image programatically by building Ubuntu with changes embedded into the build and then flash to 100s of more boards 22 23 24 === Option A Details 25 * Pull off an image of a single known configured system ('gold image') and then flash to 100s of more boards 26 * Can require consideration of unique information such as serial-number from /proc/device-tree/serial-number, a mac address, or a unique ID from a crypto device when duplicated across 100s of boards 27 28 1. Boot target to a Linux rescue image 29 2. Use the rescue image to create a tarball of your partitions, for example eMMC partition 1 (mmcblk2p1 on venice) 30 {{{ 31 # copy partition table (or just re-create it manually during the install) 32 dd if=/dev/mmcblk2 of=/tmp/partition-table bs=1M count=1 33 # create a tarball of the partition 34 mount /dev/mmcblk2p1 /mnt 35 tar --numeric-owner -cJf /tmp/mmcblk2p1.tar.xz -C /mnt . 36 }}} 37 38 You will either need to store this on a mounted removable storage device partition or store to ramdisk (as above) and transfer them via network. If the compressed data exceeds the size of the ramdisk you will need to go straight to removable storage. 39 40 The reason you do not want to simple compress the entire eMMC device (/dev/mmcblk2 on Venice) or partition (/dev/mmcblk2p1 for example) is because this will end up a) compressing unused data which will very likely not compress well because it is un-allocated and likely random data b) also ends up writing all unused data which takes a lot of time during the installation process 41 42 To install your 'gold image' on a target: 43 1. Boot to a Linux rescue image (below) 44 2. Run a script that creates your partition table and partition contents from the partition tarballs, for example eMMC partition 1 (mmcblk2p1 on venice) 45 {{{ 46 # install the saved partition table 47 dd if=/tmp/partition-table of=/dev/mmcblk2 48 # or create partition table, ie start at 1MiB (2048 512byte blocks) and end at the extent of the device 49 printf "2048,,L,,\n" | sudo sfdisk -uS /dev/mmcblk2 50 # create an ext4 fs on partition 1 51 mkfs.ext4 -q -F -L rootfs /dev/mmcblk2p1 52 # mount it 53 mount /dev/mmcblk2p1 /mnt 54 # extract the tarball to it 55 tar -C /mnt -xf /tmp/mmcblk2p1.tar.xz --keep-directory-symlink 56 # unmount it 57 umount /dev/mmcblk2p1 58 }}} 59 60 Repeat the above for all partitions and follow-up with any additional per-device modifications you would like to make (ie doing something that depends on the devices serial-number from /proc/device-tree/serial-number, a mac address, or a unique ID from a crypto device. 61 62 === Option B Details 63 Create an image programatically by building Ubuntu with changes embedded into the build and then flash to 100s of more boards. 64 65 If you want a more 'programmatic' way of creating your image that doesn't involve ripping the contents of a 'gold image' that may have been created through a complex variety of manual steps (Some engineers always prefer programmatic approaches): 66 1. Create Ubuntu image with packages pre-installed and system pre-configured, see instructions here: [wiki:ubuntu#CreatingUbunturootfsusingqemuandchroot Building Ubuntu Image] 67 1. Boot target to a Linux rescue image (below) 68 1. Run a script that creates your partition table and partition contents from scratch (using the steps from the previous option) 69 70 === Linux Rescue Image 71 A Linux Rescue Image is a self-contained Linux OS that does not rely on an on-board rootfs. This can be a kernel and device-tree with a separate rootfs that is on removable storage, or it can be a kernel with the rootfs built-in (which is how we like to do it at Gateworks just to have one less file/filesystem to worry about). 72 73 It is very easy to create a Linux Rescue image using buildroot to build the root filesystem as well as the kernel. You can include in buildroot all the tools you find necessary for the operations you need to perform. We post pre-built images on http://dev.gateworks.com/buildroot/venice/minimal and document how to build them at http://trac.gateworks.com/wiki/buildroot#VeniceIMX8M 74 75 Provided you are using a kernel Image with a built-in rootfs (such as the prebuilt Images we post on http://dev.gateworks.com/buildroot/venice/minimal/) you can boot this via the following in U-Boot: 76 {{{ 77 # via TFTP 78 u-boot=> setenv bootargs; tftpboot $kernel_addr_r Image && tftpboot $fdt_addr_r imx8mm-venice-gw72xx-0x.dtb && booti $kernel_addr_r - $fdt_addr_r 79 # via USB Mass Storage device (usb device 0 partition 1) 80 u-boot=> setenv bootargs; usb start && load usb 0:1 $kernel_addr_r Image && load usb 0:1 $fdt_addr_r imx8mm-venice-gw72xx-0x.dtb && booti $kernel_addr_r - $fdt_addr_r 81 # via microSD (mmc device 1 partition 1) 82 u-boot=> setenv bootargs; load mmc 1:1 $kernel_addr_r Image && load mmc 1:1 $fdt_addr_r imx8mm-venice-gw72xx-0x.dtb && booti $kernel_addr_r - $fdt_addr_r 83 }}} 84 9 85 10 86 == FLASH programming methods and performance … … 26 102 Summary of Pros and Cons of FLASH programming methods: 27 103 - JTAG: 28 - Pro: no dependence on booting firmware already on the boot device (FLASH can be corrupt/blank)29 - Con: slow transfer rate104 - Pro: No dependence on booting firmware already on the boot device (FLASH can be corrupt/blank) 105 - Con: Slow transfer rate 30 106 - U-Boot: 31 107 - Pro: minimal dependence on boot firmware … … 78 154 79 155 156 80 157 == Hybrid approaches 81 158 There are hybrid approaches you may consider as well. You could choose to create a JTAG'able image that contained custom firmware that automatically boots into a provisioning system that uses Linux for example. This JTAG'able image could be small enough to flash quickly over JTAG and you could even elect to have Gateworks pre-program your image on your boards if you have a Gateworks special or custom build. In this situation for example your image could pull a script from the network to complete your provisioning so that the image programmed on your boards can stay consistent but provide you flexibility in modifying the instructions for provisioning later on. This is the most flexible approach. 82 159 83 Another example of a hy rid approach is to use U-Boot to provision images based on a script of U-Boot commands such that you can program various portions of your disk image at a time. For example if you had a scenario where you have multiple filesystems spread across a large eMMC device you could fetch and program the boot-firmware, partition table, and each filesystem independently keeping the data actually written to your FLASH device as small as possible. While this approach could be done in U-Boot alone, there are likely still multiple advantages to booting a Linux ramdisk image to provide greater flexibility and/or familiarity with tools.160 Another example of a hybrid approach is to use U-Boot to provision images based on a script of U-Boot commands such that you can program various portions of your disk image at a time. For example if you had a scenario where you have multiple filesystems spread across a large eMMC device you could fetch and program the boot-firmware, partition table, and each filesystem independently keeping the data actually written to your FLASH device as small as possible. While this approach could be done in U-Boot alone, there are likely still multiple advantages to booting a Linux ramdisk image to provide greater flexibility and/or familiarity with tools. 84 161 85 162 … … 93 170 A very easy way to build a minimal ramdisk Linux based OS is to use buildroot. All you need is basic kernel support for the target board and a minimal set of tools: 94 171 - minimal root filesystem (only tools you need for your provisioning needs) 95 - minimal kernel config (only drivers/features you need for your 96 provisioning needs) 172 - minimal kernel config (only drivers/features you need for your provisioning needs) 97 173 - ramdisk (build artifact will be a 'Image' which is a kernel + ramdisk) 98 174 - script that performs the provisioning … … 134 210 - Note we set the rootfs partition bit 2 attribute to mark the partition as BIOS bootable in case you are using the U-Boot generic distro config to look for bootscripts on bootable partitions 135 211 - Note the 'end sector' for the rootfs partition above is 0 meaning it will size to the end of the device 136 3. create and populate the rootfs partition212 3. Create and populate the rootfs partition 137 213 {{{#!bash 138 214 # fetch tar archives from network … … 152 228 umount /mnt 153 229 }}} 154 4. create a bootscript if desired (note this requires understanding of how U-Boot generic distro bootconfig works; you could alternately simply put whatever you need directly into U-boot env below)230 4. Create a bootscript if desired (note this requires understanding of how U-Boot generic distro bootconfig works; you could alternately simply put whatever you need directly into U-boot env below) 155 231 {{{#!bash 156 232 cat <<\EOF > /tmp/bootscript … … 168 244 umount /mnt 169 245 }}} 170 5. customize U-Boot env if desired (note this requires understanding where the U-Boot env is located on FLASH)246 5. Customize U-Boot env if desired (note this requires understanding where the U-Boot env is located on FLASH) 171 247 {{{#!bash 172 248 # customize U-Boot env … … 186 262 187 263 188 * provision a Newport board eMMC with a single ext4 root filesystem from a rootfs and kernel tarball:264 * Provision a Newport board eMMC with a single ext4 root filesystem from a rootfs and kernel tarball: 189 265 1. Load and boot kernel+ramdisk buildroot image from TFTP server 190 266 {{{#!bash … … 213 289 - Note we set the rootfs partition's bit 2 attribute to mark the partition as BIOS bootable in case you are using the U-Boot generic distro config to look for bootscripts on bootable partitions 214 290 - Note the 'end sector' for the rootfs partition above is 0 meaning it will size to the end of the device 215 3. create and populate the rootfs partition291 3. Create and populate the rootfs partition 216 292 {{{#!bash 217 293 # fetch tar archives from network … … 228 304 umount /mnt 229 305 }}} 230 4. create a bootscript if desired (note this requires understanding of how U-Boot generic distro bootconfig works; you could alternately simply put whatever you need directly into U-boot env below)306 4. Create a bootscript if desired (note this requires understanding of how U-Boot generic distro bootconfig works; you could alternately simply put whatever you need directly into U-boot env below) 231 307 {{{#!bash 232 308 cat <<\EOF > /tmp/bootscript … … 248 324 umount /mnt 249 325 }}} 250 5. customize U-Boot env if desired (note this requires understanding where the U-Boot env is located on FLASH)326 5. Customize U-Boot env if desired (note this requires understanding where the U-Boot env is located on FLASH) 251 327 {{{#!bash 252 328 # customize U-Boot env