| 389 | |
| 390 | |
| 391 | [=#ubootenv] |
| 392 | == U-Boot environment provisioning |
| 393 | The U-Boot bootloader uses environment variables and scripts to control the booting of a board. Often it is desirable to override the default environment the Gateworks BSP's create and create your own. |
| 394 | |
| 395 | The device, location, size, and redundancy details of how the U-Boot environment is stored vary from board to board based on U-Boot's configuration: |
| 396 | * Venice: 32KiB (0x8000) redundant env stored at 16320KiB (0xff0000) offset for MMC |
| 397 | * Newport: 32KiB (0x8000) redundant env stored at 16320KiB (0xff0000) offset for MMC |
| 398 | * Ventana: |
| 399 | - MMC: 128MiB redundant env stored at 709KiB offset |
| 400 | - NAND: 128MiB redundant env stored at 16MiB offset |
| 401 | |
| 402 | There are some tools from the U-Boot project available in the u-boot-tools package that can be used to alter or create an env that can then be copied directly to flash: |
| 403 | * fw_setenv / fw_getenv - requires a config file and can get or alter the env. If there is no valid env where the config file points to a default env hard coded into the bootloader will be returned. |
| 404 | * mkenvimage - create an env image from scratch with a specified size and redundancy. |
| 405 | |
| 406 | For examples of how the default env is created for the various Gateworks products: |
| 407 | - Venice BSP uses fw_setenv to alter the hard-coded default env. For details see: |
| 408 | * https://github.com/Gateworks/bsp-venice/blob/master/Makefile |
| 409 | * https://github.com/Gateworks/bsp-venice/blob/master/venice.env |
| 410 | * https://github.com/Gateworks/bsp-venice/blob/master/fw_env.config |
| 411 | - Newport BSP uses fw_setenv to alter the hard-coded default env. For details see: |
| 412 | * https://github.com/Gateworks/bsp-newport/blob/sdk-10.1.1.0-newport/Makefile |
| 413 | * https://github.com/Gateworks/bsp-newport/blob/sdk-10.1.1.0-newport/newport.env |
| 414 | * https://github.com/Gateworks/bsp-newport/blob/sdk-10.1.1.0-newport/fw_env.config |
| 415 | - Ventana firmware images have a blank env area therefore use hard-coded default env from U-Boot |
| 416 | |
| 417 | To create a specific env from scratch (ie without inheriting any defaults) use the {{{mkenvimage}}} tool from the u-boot-tools package |
| 418 | 1. Create an env.txt file with 'name=value' pairs. Be sure to include everything that is necessary as no defaults will be available other than variables that are set at runtime on the fly such as serial#, model, and macaddr: |
| 419 | {{{#!bash |
| 420 | cat << EOF >> env.txt |
| 421 | baudrate=115200 |
| 422 | bootcmd=run distro_boot |
| 423 | ... |
| 424 | EOF |
| 425 | }}} |
| 426 | {{{#!bash |
| 427 | cat << EOF >> env.txt |
| 428 | baudrate=115200 |
| 429 | loadaddr=0x48200000 |
| 430 | ipaddr=192.168.1.1 |
| 431 | serverip=192.168.1.146 |
| 432 | update_all=tftpboot $loadaddr venice/venice-focal-imx8mm.img.gz && gzwrite mmc 2 $loadaddr $filesize |
| 433 | update_env=tftpboot $loadaddr venice/env.bin && mmc dev 2 && mmc write $loadaddr 0x7f80 $filesize |
| 434 | EOF |
| 435 | }}} |
| 436 | 2. Use {{{mkenvimage}}} taking care to specify the env size the bootloader is configured to use and specify '-r' for redundancy if the bootloader is configured for that: |
| 437 | * Venice / Newport |
| 438 | {{{#!bash |
| 439 | mkenvimage -r -s $((32 * 1024)) -o env.bin env.txt |
| 440 | }}} |
| 441 | * Ventana: |
| 442 | {{{#!bash |
| 443 | mkenvimage -r -s $((128 * 1024)) -o env.bin env.txt |
| 444 | }}} |
| 445 | 3. Place this image in FLASH: |
| 446 | * Venice / Newport: |
| 447 | - Example: compressed disk image for Venice / Newport: |
| 448 | {{{#!bash |
| 449 | gunzip disk.img.gz |
| 450 | dd if=env.bin of=disk.img bs=1K seek=16320 oflag=notrunc |
| 451 | gzip disk.img |
| 452 | }}} |
| 453 | - Example: update from Linux: |
| 454 | {{{#!bash |
| 455 | dd if=env.bin of=/dev/mmcblk0 bs=1K seek=16320 oflag=notrunc |
| 456 | }}} |
| 457 | - Example: update from U-Boot (16320KiB is equivalent to 0x7f80 512byte blocks in hex) |
| 458 | {{{#!bash |
| 459 | tftp $loadaddr env.bin && mmc write $loadaddr 0x7f80 $filesize |
| 460 | }}} |
| 461 | * Ventana: |
| 462 | - Example: JTAG binary image for a Ventana NAND device: |
| 463 | {{{#!bash |
| 464 | mkimage_jtag -e SPL@0 u-boot.img@14M env.bin@16M ubi@17M > image.bin |
| 465 | }}} |
| 466 | - Example: update from Linux: |
| 467 | {{{#!bash |
| 468 | dd if=env.bin of=/dev/mmcblk0 bs=1K seek=16384 oflag=notrunc |
| 469 | }}} |
| 470 | - Example: update from U-Boot (16384MiB is equivalent to 0x8000 512byte blocks in hex) |
| 471 | {{{#!bash |
| 472 | tftp $loadaddr env.bin && mmc write $loadaddr 0x8000 $filesize |
| 473 | }}} |