| 49 | == eMMC boot partition |
| 50 | By default since around Jan 2024 Gateworks has been placing boot firmware on the eMMC 'boot0' hardware partition (instead of the 'user' hardware partition) which accomplishes two things: |
| 51 | 1. keeps your boot firmware isolated from your OS (filesystems as well as disk partition table) |
| 52 | 2. allows compressed disk images now representing the OS only to be shared between the various IMX8M SoC's supported by the venice family (imx8mm, imx8mn, imx8mp) which have different boot firmware images |
| 53 | |
| 54 | At this same time the U-Boot environment data was moved from an offset of 0xfe0000 (16M - 128K) to an offset of 0x3e0000 (4M - 128K) so that it fit within the minimal size of the 4MB boot hardware partitions. However regardless of what hardware partition the eMMC boots from, the U-Boot environment data is always at the same offset on that hardware partition (the top of the 4MB boundary) |
| 55 | |
| 56 | If you wish to move the boot firmware between user, boot0, and boot1 eMMC hardware partitions note the following: |
| 57 | - the different SoC BOOT ROM's use different offsets depending on the emmc hardware partition. Specifically: |
| 58 | * IMX8MM BOOT ROM will always fetch boot code at a 33KB offset for eMMC devices regardless of the hardware partition |
| 59 | * IMX8MN/IMX8MP BOOT ROM will fetch boot code at a 32KB offset for eMMC devices booting from user and 0KB offset for eMMC devices booting from boot0 or boot1 |
| 60 | - the eMMC PARTITION_CONFIG register (EXT CSD 179) BOOT_PARTITION_ENABLE field specifies what eMMC hardware partition is active on power-up so if you move the boot firmware you must update the PARTITION_CONFIG register (via U-Boot 'mmc partconf' command, via Linux 'mmc bootpart' command (from the 'mmc-utils' package) or via JTAG by specifying the '--partconf' cmdline parameter to the mkimage_jtag script used to create a JTAG image |
| 61 | |
| 62 | To determine what hardware partition is currently being used: |
| 63 | - if using the latest boot firmware U-Boot SPL will announce the hardware partition such as 'Trying to boot from eMMC boot0'. If the hardware partition (boot0, boot1, user) is not shown then you are using an older boot firmware |
| 64 | - use the U-Boot 'mmc partconf 2' command (2 is the eMMC device for Venice) and examine the 'BOOT_PARTITION_ENABLE' field. If using a using a newer boot firmware it will show both the numeric value as well as what that value represents, for example 'BOOT_PARTITION_ENABLE: 0x1 (boot0)' (and if just the number is shown you are using an older boot firmware). Note the possible values for BOOT_PARTITION_ENABLE are: 0x1 (boot0), 0x2 (boot1), 0x7 (user). |
| 65 | - use the Linux 'mmc extcsd read' command and look at the PARTITION_CONFIG register {{{bits[5:3]}}} |
| 66 | |
| 67 | |
| 68 | Examples: |
| 69 | * show the current eMMC boot partition: |
| 70 | - from U-Boot: |
| 71 | {{{#!bash |
| 72 | u-boot=> mmc partconf 2 |
| 73 | EXT_CSD[179], PARTITION_CONFIG: |
| 74 | BOOT_ACK: 0x0 |
| 75 | BOOT_PARTITION_ENABLE: 0x1 (boot0) |
| 76 | PARTITION_ACCESS: 0x0 |
| 77 | }}} |
| 78 | - BOOT_PARTITION_ENABLE 0x1 represents boot0 (0x1=boot0, 0x2=boot1, 0x7=user) |
| 79 | - from Linux: |
| 80 | {{{#!bash |
| 81 | root@jammy-venice:~# mmc extcsd read /dev/mmcblk2 | grep PARTITION_CONFIG |
| 82 | Boot configuration bytes [PARTITION_CONFIG: 0x08] |
| 83 | root@jammy-venice:~# echo $(($((0x08 >> 3)) & 0x7)) # show bits[5:3] |
| 84 | 1 |
| 85 | root@jammy-venice:~# echo $(($(( $(mmc extcsd read /dev/mmcblk2 | sed -n 's/.*PARTITION_CONFIG: \(.*\)]/\1/p') >> 3)) & 0x7)) # 1-line version |
| 86 | 1 |
| 87 | }}} |
| 88 | - BOOT_PARTITION_ENABLE is represented by {{{bits[5:3]}}} of PARTITION_CONFIG which can be read from the EXT CSD register 179 named 'PARTITION_CONFIG' (1=boot0, 2=boot1, 7=user) |
| 89 | * IMX8MM: Program boot firmware to user: |
| 90 | - from U-Boot |
| 91 | {{{#!bash |
| 92 | # fetch flash.bin boot firmware |
| 93 | tftpboot $loadaddr $dir/venice-$soc-flash.bin |
| 94 | # set blkcnt to $filesize/512 (convert to 512 byte blocks) |
| 95 | setexpr blkcnt $filesize + 0x1ff && setexpr blkcnt $blkcnt / 0x200 |
| 96 | # select the emmc (dev=2) user hardware partition (part=0) |
| 97 | mmc dev 2 0 |
| 98 | # write to 33K (which is 0x42 hex 512 byte blocks) |
| 99 | mmc write $loadaddr 0x42 $blkcnt |
| 100 | # set PARTITION_CONFIG to BOOT_ACK=1 BOOT_PARTITION_ENABLE=7 to boot from user |
| 101 | mmc partconf 2 1 7 0 |
| 102 | }}} |
| 103 | - from Linux |
| 104 | {{{#!bash |
| 105 | # fetch flash.bin boot firmware |
| 106 | wget https://dev.gateworks.com/venice/boot_firmware/venice-imx8mm-flash.bin |
| 107 | # write it to mmcblk2 (user) at offset 33KB |
| 108 | dd if=venice-imx8mm-flash.bin of=/dev/mmcblk2 bs=1k seek=33 conv=notrunc |
| 109 | # set BOOT_PARTITION_ENABLE to 7 for mmcblk2 (eMMC) |
| 110 | mmc bootpart enable 7 0 /dev/mmcblk2 |
| 111 | }}} |
| 112 | - via JTAG: |
| 113 | {{{#!bash |
| 114 | # start with soc-specific position-independent boot firmware binary |
| 115 | wget https://dev.gateworks.com/venice/boot_firmware/venice-imx8mm-flash.bin |
| 116 | # create a 4MB file and copy the position-independent boot firmware to where the BOOT ROM expects it (33K in this case) |
| 117 | truncate -s 4M firmware.img |
| 118 | dd if=venice-imx8mm-flash.bin of=firwmare.img bs=1k seek=33 conv=notrunc |
| 119 | # use the mkimage_jtag script to create a JTAG binary that flashes this image and sets the PARTITION_CONFIG register |
| 120 | ./mkimage_jtag --soc imx8mm --emmc -s --partconf=user \ |
| 121 | firmware.img@user:erase_part:0-8192 \ |
| 122 | > firmware-venice-imx8mm.bin |
| 123 | }}} |
| 124 | * IMX8MM: Program boot firmware to boot0: |
| 125 | - from U-Boot |
| 126 | {{{#!bash |
| 127 | # fetch flash.bin boot firmware |
| 128 | tftpboot $loadaddr $dir/venice-$soc-flash.bin |
| 129 | # set blkcnt to $filesize/512 (convert to 512 byte blocks) |
| 130 | setexpr blkcnt $filesize + 0x1ff && setexpr blkcnt $blkcnt / 0x200 |
| 131 | # select the emmc (dev=2) boot0 hardware partition (part=1) |
| 132 | mmc dev 2 1 |
| 133 | # write to 33K (which is 0x42 hex 512 byte blocks) |
| 134 | mmc write $loadaddr 0x42 $blkcnt |
| 135 | # set PARTITION_CONFIG to BOOT_ACK=1 BOOT_PARTITION_ENABLE=1 to boot from boot0 |
| 136 | mmc partconf 2 1 1 0 |
| 137 | }}} |
| 138 | - from Linux |
| 139 | {{{#!bash |
| 140 | # fetch flash.bin boot firmware |
| 141 | wget https://dev.gateworks.com/venice/boot_firmware/venice-imx8mm-flash.bin |
| 142 | # write it to mmcblk2boot0 at offset 33KB |
| 143 | echo 0 > /sys/class/block/mmcblk2boot0/force_ro |
| 144 | dd if=venice-imx8mm-flash.bin of=/dev/mmcblk2boot0 bs=1k seek=33 conv=notrunc |
| 145 | # set BOOT_PARTITION_ENABLE to 1 for mmcblk2 (eMMC) |
| 146 | mmc bootpart enable 1 0 /dev/mmcblk2 |
| 147 | }}} |
| 148 | - via JTAG: |
| 149 | {{{#!bash |
| 150 | # start with soc-specific position-independent boot firmware binary |
| 151 | wget https://dev.gateworks.com/venice/boot_firmware/venice-imx8mm-flash.bin |
| 152 | # create a 4MB file and copy the position-independent boot firmware to where the BOOT ROM expects it (33K in this case) |
| 153 | truncate -s 4M firmware.img |
| 154 | dd if=venice-imx8mm-flash.bin of=firmware.img bs=1k seek=33 conv=notrunc |
| 155 | # use the mkimage_jtag script to create a JTAG binary that flashes this image and sets the PARTITION_CONFIG register |
| 156 | ./mkimage_jtag --soc imx8mm --emmc -s --partconf=boot0 \ |
| 157 | firmware.img@boot0:erase_part:0-8192 \ |
| 158 | > firmware-venice-imx8mm.bin |
| 159 | }}} |
| 160 | * IMX8MP: Program boot firmware to user: |
| 161 | - from U-Boot |
| 162 | {{{#!bash |
| 163 | # fetch flash.bin boot firmware |
| 164 | tftpboot $loadaddr $dir/venice-$soc-flash.bin |
| 165 | # set blkcnt to $filesize/512 (convert to 512 byte blocks) |
| 166 | setexpr blkcnt $filesize + 0x1ff && setexpr blkcnt $blkcnt / 0x200 |
| 167 | # select the emmc (dev=2) user hardware partition (part=0) |
| 168 | mmc dev 2 0 |
| 169 | # write to 32K (which is 0x40 hex 512 byte blocks) |
| 170 | mmc write $loadaddr 0x40 $blkcnt |
| 171 | # set PARTITION_CONFIG |
| 172 | mmc partconf 2 1 user user |
| 173 | }}} |
| 174 | - from Linux |
| 175 | {{{#!bash |
| 176 | # fetch flash.bin boot firmware |
| 177 | wget https://dev.gateworks.com/venice/boot_firmware/venice-imx8mp-flash.bin |
| 178 | # write it to mmcblk2 (user) at offset 32KB |
| 179 | dd if=venice-imx8mp-flash.bin of=/dev/mmcblk2 bs=1k seek=32 conv=notrunc |
| 180 | # set BOOT_PARTITION_ENABLE to 7 for mmcblk2 (eMMC) |
| 181 | mmc bootpart enable 7 0 /dev/mmcblk2 |
| 182 | }}} |
| 183 | - via JTAG: |
| 184 | {{{#!bash |
| 185 | # start with soc-specific position-independent boot firmware binary |
| 186 | wget https://dev.gateworks.com/venice/boot_firmware/venice-imx8mp-flash.bin |
| 187 | # create a 4MB file and copy the position-independent boot firmware to where the BOOT ROM expects it (32K in this case) |
| 188 | truncate -s 4M firmware.img |
| 189 | dd if=venice-imx8mp-flash.bin of=firmware.img bs=1k seek=32 conv=notrunc |
| 190 | # use the mkimage_jtag script to create a JTAG binary that flashes this image and sets the PARTITION_CONFIG register |
| 191 | ./mkimage_jtag --soc imx8mp --emmc -s --partconf=user \ |
| 192 | firmware.img@user:erase_part:0-8192 \ |
| 193 | > firmware-venice-imx8mp.bin |
| 194 | }}} |
| 195 | * IMX8MM: Program boot firmware to boot0: |
| 196 | - from U-Boot |
| 197 | {{{#!bash |
| 198 | # fetch flash.bin boot firmware |
| 199 | tftpboot $loadaddr $dir/venice-$soc-flash.bin |
| 200 | # set blkcnt to $filesize/512 (conver to 512 byte blocks) |
| 201 | setexpr blkcnt $filesize + 0x1ff && setexpr blkcnt $blkcnt / 0x200 |
| 202 | # select the emmc (dev=2) boot0 hardware partition (part=1) |
| 203 | mmc dev 2 1 |
| 204 | # write to 0K |
| 205 | mmc write $loadaddr 0x0 $blkcnt |
| 206 | # set PARTITION_CONFIG to BOOT_ACK=1 BOOT_PARTITION_ENABLE=1 to boot from boot0 |
| 207 | mmc partconf 2 1 1 0 |
| 208 | }}} |
| 209 | - from Linux |
| 210 | {{{#!bash |
| 211 | # fetch flash.bin boot firmware |
| 212 | wget https://dev.gateworks.com/venice/boot_firmware/venice-imx8mp-flash.bin |
| 213 | # write it to mmcblk2boot0 at offset 0KB |
| 214 | echo 0 > /sys/class/block/mmcblk2boot0/force_ro |
| 215 | dd if=venice-imx8mp-flash.bin of=/dev/mmcblk2boot0 bs=1k seek=0 conv=notrunc |
| 216 | # set BOOT_PARTITION_ENABLE to 1 (boot0) for mmcblk2 (eMMC) |
| 217 | mmc bootpart enable 1 0 /dev/mmcblk2 |
| 218 | }}} |
| 219 | - via JTAG: |
| 220 | {{{#!bash |
| 221 | # start with soc-specific position-independent boot firmware binary |
| 222 | wget https://dev.gateworks.com/venice/boot_firmware/venice-imx8mp-flash.bin |
| 223 | # create a 4MB file and copy the position-independent boot firmware to where the BOOT ROM expects it (0K in this case) |
| 224 | truncate -s 4M firmware.img |
| 225 | dd if=venice-imx8mp-flash.bin of=firmware.img bs=1k seek=0 conv=notrunc |
| 226 | # use the mkimage_jtag script to create a JTAG binary that flashes this image and sets the PARTITION_CONFIG register |
| 227 | ./mkimage_jtag --soc imx8mp --emmc -s --partconf=boot0 \ |
| 228 | firmware.img@boot0:erase_part:0-8192 \ |
| 229 | > firmware-venice-imx8mp.bin |
| 230 | }}} |
| 231 | |
| 232 | The examples above start with the position-independent boot firmware therefore they do not contain the U-Boot environment area which is always stored at the top of the 4MB boundary of the eMMC hardware partition that U-Boot boots from. You can create and update this environment data via: |
| 233 | * Create environment data: |
| 234 | - from Gateworks default firmware image: |
| 235 | {{{#!bash |
| 236 | wget https://dev.gateworks.com/venice/images/firmware-venice-imx8mm.img |
| 237 | dd if=firmware-venice-imx8mm.img of=env.bin bs=1k skip=4032 count=128 |
| 238 | }}} |
| 239 | * Update U-Boot env (to $bootpart) from U-Boot |
| 240 | {{{#!bash |
| 241 | tftpboot $loadaddr env.bin && mmc dev $dev $bootpart && mmc write $loadaddr 0x1f80 0x80 |
| 242 | }}} |
| 243 | * Update U-Boot env to user from Linux |
| 244 | {{{#!bash |
| 245 | dd if=env.bin of=/dev/mmcblk2 bs=1k seek=4032 conv=notrunc |
| 246 | }}} |
| 247 | * Update U-Boot env to boot0 from Linux |
| 248 | {{{#!bash |
| 249 | echo 0 > /sys/class/block/mmcblk2boot0/force_ro |
| 250 | dd if=env.bin of=/dev/mmcblk2boot0 bs=1k seek=4032 conv=notrunc |
| 251 | }}} |
| 252 | |
| 253 | |
| 254 | |