Changes between Version 20 and Version 21 of ventana/bootloader


Ignore:
Timestamp:
05/01/2023 09:43:38 PM (19 months ago)
Author:
Tim Harvey
Comment:

moved some info to common U-Boot page

Legend:

Unmodified
Added
Removed
Modified
  • ventana/bootloader

    v20 v21  
    291291U-Boot uses many environment variables which are stored in persistent media and used to alter the boot. Some variables are actually scripts executed with the {{{run}}} command.
    292292
    293 The most common env vars used for the Ventana bootloader are:
     293Notable ventana U-Boot env vars:
    294294||= Name    =||= Purpose  =||
    295295|| bootcmd   || script executed at boot ||
     
    327327When the bootloader boots it will load the environment from persistent storage (device and location based on the boot device). By default this data is blank so it is normal to see a message indicating there is a CRC error and that the '''default environment''' will be used. This means that the environment that was built into U-Boot at build time for the board is used. Note that some of the values above are dynamically set when the bootloader runs unless overridden by manually setting it ({{{ethaddr}}}, {{{eth1addr}}}, {{{mem_mb}}}, {{{model}}}, {{{serial#}}}, {{{fdt_file*}}} etc)
    328328
    329 You can use {{{env}}} commands to get or set env vars. For example:
    330  * Get a var:
    331 {{{#!bash
    332 env print model
    333 }}}
    334  * Set a var:
    335 {{{#!bash
    336 env set quiet 1
    337 }}}
    338  * Load default values (does not save):
    339 {{{#!bash
    340 env default -f -a
    341 }}}
    342  * Save current env:
    343 {{{#!bash
    344 env save
    345 }}}
    346 
    347329If you want to erase the env so that the CRC fails and loads defaults (only useful over a {{{env default -f -a; env save}}} if you like to see the fact that its using defaults):
    348330{{{#!bash
     
    355337}}}
    356338
    357 [=#uboot-envtools]
    358 === U-Boot envtools (fw_printenv / fw_setenv) ===
    359 The {{{fw_printenv}}} and {{{fw_setenv}}} tools from U-Boot provide a way to allow reading and writing to U-Boot's env variables provided you have a proper configuration file. On OpenWrt these are in the  {{{uboot-envtools}}} package and on Ubuntu they are in the {{{u-boot-tools}}} package. In order to use u-boot envtools in Linux for Ventana the environment must be saved at least once in the bootloader:
    360 {{{#!bash
    361 saveenv
    362 }}}
    363 
    364 Assuming you're using a board with NAND flash as the primary boot device and the U-Boot env is in the 2nd partition the following shows a valid config file:
    365 {{{#!bash
    366 cat /proc/mtd
    367 dev:    size   erasesize  name
    368 mtd0: 01000000 00040000 "uboot"
    369 mtd1: 00100000 00040000 "env"
    370 mtd2: 7ef00000 00040000 "rootfs"
    371 cat /etc/fw_env.config
    372 # device  offset size erasesize
    373 /dev/mtd1 0x0 0x20000 0x40000
    374 /dev/mtd1 0x80000 0x20000 0x40000
    375 }}}
    376 
    377 Assuming you are using a NAND-less board booting to micro-SD a valid config file looks like:
    378 {{{#!bash
    379 cat /etc/fw_env.config
    380 # device  offset size erasesize
    381 /dev/mmcblk0 0xb1400 0x20000 0x20000
    382 /dev/mmcblk0 0xd1400 0x20000 0x20000
    383 }}}
    384 
    385 * ''Booting rootfs from microSD does not necessarily constitute "NAND-less", env variables are still stored on NAND when NAND is present.''
    386 
    387 
    388 
    389 It is important to realize the meaning of the '''Warning: Bad CRC, using default environment''' message. This means that the non-volatile env area is empty or corrupt (Note that this is the way Gateworks Ventana boards ship by default) and that the built-in env within U-Boot will be used.
    390 
    391 If you use {{{fw_setenv}}} on an environment in this state it will properly set the variable you specify and all other variables will continue to use their built-in default values within U-Boot. Essentially you are 'overriding' the defaults as you would expect.
    392 
    393 
    394 ==== Configuring u-boot-tools
    395 A file defining where your environment is located must be provided to {{{fw_printenv}}} and {{{fw_setenv}}} with the {{{-c <file>}}} paramater. Note that older versions of these tools lacked this argument and required the config file to be in {{{/etc/fw_env.config}}}
    396 
    397 Examples:
    398 * Ventana booting from NAND
    399 {{{#!bash
    400 #Create config file
    401 cat << EOF > ventana_nand_env.config
    402 # device  offset size erasesize
    403 /dev/mtd1 0x0 0x20000 0x40000
    404 /dev/mtd1 0x80000 0x20000 0x40000
    405 EOF
    406 }}}
    407 * Ventana MMC only
    408 {{{#!bash
    409 #Create config file
    410 cat << EOF > ventana_mmc_env.config
    411 # device  offset size erasesize
    412 /dev/mmcblk0 0xb1400 0x20000 0x20000
    413 /dev/mmcblk0 0xd1400 0x20000 0x20000
    414 EOF
    415 }}}
    416 * A file that can be flashed later on NAND or inserted to a JTAG image:
    417 {{{#!bash
    418 #Create config file
    419 cat << EOF > fw_env.config
    420 # device  offset size erasesize
    421 envVentana.bin 0x00000 0x20000
    422 envVentana.bin 0x80000 0x20000
    423 EOF
    424 }}}
    425 
    426 This will define the device being used, offset according to flash layout, size from flash map, and size of erase block (unless the device is a file). Ventana U-boot environment is redundant hence two entries, both locations need their variables updated. 
    427 
    428 ==== Usage example
    429 
    430 {{{#!bash
    431 # display environment
    432 fw_printenv -c fw_env.config
    433 # set environment variable
    434 fw_setenv  -c fw_env.config foo bar #foo being variable name bar being value variable will be set to
    435 #second example
    436 fw_setenv  -c fw_env.config ipaddr 192.168.1.10
    437 #print single environment variable
    438 fw_printenv  -c fw_env.config foo
    439 #second example
    440 fw_printenv ipaddr
    441 }}}
    442339
    443340
     
    489386}}}
    490387
    491 
    492 [=#usb]
    493 == USB Mass Storage Support ==
    494 The Ventana U-Boot supports USB Mass Storage devices on both the EHCI port and the OTG port on applicable hardware. The usb subsystem will apply power to a USB device for a specific time according to the USB specification before it scans the device. Some USB storage devices have been found to not adhere to the USB specification and require longer warm-up times. You can set the {{{usb_pgood_delay}}} to the number of ms required for your device to work around this issue. If your USB Mass storage device fails to be detected when you do a {{{usb start}}} in U-Boot try setting this to a value of 2000 or larger (2 seconds+) and issue the command again to see if that helps:
    495 
    496 General command:
    497 {{{#!bash
    498 setenv usb_pgood_delay 2000
    499 }}}
    500 
    501 Example:
    502 {{{#!bash
    503 Ventana > usb start
    504 (Re)start USB...
    505 USB0:   lowlevel init failed
    506 USB1:   USB EHCI 1.00
    507 scanning bus 1 for devices... 2 USB Device(s) found
    508        scanning usb for storage devices... 0 Storage Device(s) found
    509        scanning usb for ethernet devices... 0 Ethernet Device(s) found
    510 Ventana > setenv usb_pgood_delay 2000
    511 Ventana > usb start
    512 (Re)start USB...
    513 USB0:   lowlevel init failed
    514 USB1:   USB EHCI 1.00
    515 scanning bus 1 for devices... 2 USB Device(s) found
    516        scanning usb for storage devices... 1 Storage Device(s) found
    517        scanning usb for ethernet devices... 0 Ethernet Device(s) found
    518 }}}
    519 
    520 Be sure to run the {{{saveenv}}} command afterwards to save the setting:
    521 {{{#!bash
    522 saveenv
    523 }}}
    524 
    525 
    526 [=#otg]
    527 == USB OTG ==
    528 The USB OTG host controller on the IMX6 is supported under U-Boot in both host and gadget mode.
    529 
    530 Common uses in '''host mode''' include attaching to a:
    531  * USB Mass storage device
    532  * USB Network Interface (two common devices are supported - see [#usbnet below]
    533 
    534 Common uses in '''device mode''' include attaching to a PC:
    535  * emulating a USB Mass storage device - see [#ums below]
    536 
    537 [=#ums]
    538 === USB Mass Storage emulation to a Host over OTG ===
    539 One of the more handy features of USB OTG support is connecting to a PC and using the {{{ums}}} command to implement the USB Mass Storage device protocol thus allowing access from a PC to block storage devices (USB Mass Storage, micro-SD, mSATA) attached to the Ventana board.
    540 
    541 Examples:
    542  * IMX6 micro-SD host controller (this is on-board micro-SD, not a USB based micro-SD reader/writer such as the GW16103)
    543 {{{#!bash
    544 ums 0 mmc 0
    545 }}}
    546  * USB Mass Storage device:
    547 {{{#!bash
    548 usb start && ums 0 usb 0
    549 }}}
    550  * mSATA device:
    551 {{{#!bash
    552 sata init && ums 0 sata 0
    553 }}}
    554 
    555 '''This feature is available in Gateworks U-Boot 2015.04'''
    556 
    557 
    558 [=#gpio]
    559 == General Purpose IO (GPIO) ==
    560 The {{{gpio}}} command provides the ability to list and configure board-specific GPIO's. The IMX6 has 7 banks of 32 GPIOs. The {{{pin}}} value used for the {{{gpio}}} command will match the Linux gpio, which follows the equation {{{(bank-1) * 32 + io}}}. The {{{status}}} command however will list the GPIO's as {{{GPIO<bank>_<io>}}} so when determining the pin value you need to do the math.
    561 
    562 For example, on Ventana boards that support MSATA the MSATA enable is GPIO2_IO8 (bank2 io8) or gpio-40 ((2-1)*32 + 8) so the pin value of 40 is used.
    563 
    564 Examples:
    565  * List GPIO's:
    566 {{{#!bash
    567 gpio status
    568 }}}
    569  * set GPIO2_8 (gpio 40) (set to logic 1) (enables MSATA on boards that have it):
    570 {{{#!bash
    571 gpio set 40
    572 }}}
    573  * clear GPIO2_8 (gpio 40) (set to logic 0) (disables MSATA and selects PCI on boards that have it):
    574 {{{#!bash
    575 gpio clear 40
    576 }}}
    577  * set GPIO1_17 (gpio 17) as an input and get its value
    578 {{{#!bash
    579 gpio input 17
    580 }}}
    581 
    582 '''This feature is available in Gateworks U-Boot 2015.04'''
    583388
    584389[=#enablepci]
     
    755560 * USB Network devices (ASIX AX8817X, SMSC LAN95xx)
    756561
    757 The following U-Boot environment variables affect networking:
    758  * {{{ipaddr}}} - local IP address
    759  * {{{serverip}}} - TFTP server IP
    760  * {{{ethprime}}} - controls which interface is used first
    761  * {{{ethact}}} - controls which interface is currently active
    762  * {{{ethrotate}}} - when set to 'no' uboot does not go through all available network interfaces and instead just stays at the currently selected interface (ethact)
    763  * {{{netretry}}} - when set to 'no' each network operation will either success or fail without retrying. When set to 'once' the operation will fail only when all available network interfaces have been tried once without success.
    764  * {{{tftpsrcport}}} - UDP source port (if not set uses default)
    765  * {{{tftpdstport}}} - UDP dest port (if not set uses well known port 69)
    766  * {{{tftpblocksize}}} - if not set will use TFTP server's default block size
    767  * {{{tftptimeout}}} - retransmission timeout for TFTP packets in ms (min value is 1000, default is 5000)
    768 
    769 
    770562[=#pcinet]
    771563=== PCIe Network Devices ===
     
    808600
    809601
    810 [=#usbeth]
    811 === USB Ethernet Device support ===
    812 There is support in U-Boot for a few USB chipsets that are commonly available in low-cost USB Ethernet dongles:
    813  * ASIX AX8817X - (ie [http://plugable.com/products/usb2-e100 Plugable USB2-E100 10/100mbps)
    814   * network device: asx0
    815  * SMSC LAN95xx
    816   * network device: sms0
    817 
    818 To use these use the following U-Boot configuration:
    819  1. scan USB bus for supported devices:
    820 {{{#!bash
    821 usb start
    822 }}}
    823   * If you have a supported USB device attached you will see a message to that effect
    824  2. set active ethernet device - for example an ASIX device:
    825 {{{#!bash
    826 setenv ethact asx0
    827 }}}
    828  3. Use networking as needed:
    829 {{{#!bash
    830 ping 192.168.1.254
    831 tftp ${loadaddr} ${file}
    832 }}}
    833 
    834 
    835 
    836 [=#netconsole]
    837 === !NetConsole (access U-Boot console from network) ===
    838 U-Boot does not contain any TCP implementation and as such there is no 'telnet server' or 'telnetd' support. There is however something similar called '!NetConsole' which will allow stdin/stdout/stderr to be directed to a UDP network port. If you set this up you can use the Linux 'nc' or 'netcat' tool or use the the 'netconsole' shell script provided in tools/netconsole (which uses these tools) to talk to U-Boot's interpreter from a Linux host.
    839 
    840 Using !NetConsole, the paradigm is reversed from the telnet/ssh perspective a bit such that you need to configure U-Boot to listen to a specifc IP address of a server.
    841 
    842 To enable !NetConsole you must do the following:
    843  - U-Boot:
    844   * configure networking: For example have a network interface supported by U-boot, set {{{ipaddr}}} env variable and {{{serverip}}} env variable (make sure you can {{{ping $serverip}}}):
    845 {{{
    846 setenv ipaddr 192.168.1.1 # local ip
    847 setenv serverip 192.168.1.146 # host ip running netcat/netconsole
    848 }}}
    849   * set the {{{ncip}}} address to your server:
    850 {{{
    851 setenv ncip ${serverip}
    852 }}}
    853   * set stdin/stdout/stderr as desired to {{{nc}}}:
    854 {{{
    855 setenv stdin nc; setenv stdout nc; setenv stderr nc
    856 }}}
    857   * (optional) if you want these changed persistent, do a {{{saveenv}}}:
    858 {{{
    859 saveenv
    860 }}}
    861  - Linux host:
    862   * make sure you have netcat (either {{{nc}}} or {{{netcat}}} applications)
    863   * grab the {{{netconsole}}} shell script from U-Boot's tools directory:
    864 {{{#!bash
    865 wget https://raw.githubusercontent.com/Gateworks/u-boot-imx6/gateworks_v2015.04/tools/netconsole
    866 chmod +x netconsole
    867 }}}
    868   * use {{{netconsole}}} to listen to your target IP address for input/output:
    869 {{{#!bash
    870 netconsole 192.168.1.1
    871 }}}
    872    - Note that netconsole remaps the interrupt from Cntl-C to Cntl-T so that you can use Cntl-C over the network console
    873 
    874 
    875 For a bootloader configuration that sits waiting for network commands from a specific host but with a timeout you can use the preboot env variable to execute a script prior to bootcmd such as:
    876 {{{
    877 setenv serverip 192.168.1.146 # your server ip
    878 setenv ipaddr 192.168.1.1 # your local ip
    879 setenv netretry no
    880 setenv preboot 'echo "Looking for server at $serverip..."; \
    881  if ping $serverip; then setenv ncip ${serverip}; setenv bootdelay 10; \
    882  echo "Starting NetConsole to ${ncip} and waiting for ${bootdelay} seconds..."; \
    883  setenv stdin nc; setenv stdout nc; setenv stderr nc; \
    884  fi'
    885 saveenv
    886 }}}
    887  * Note that we set {{{netretry}}} to 'no' which causes network operations to not retry (otherwise the ping will go forever). This could also be set to 'once' if you wish to cycle through all available network interfaces (such as on-board NIC's as well as USB nics) instead of just 'ethprime'.
    888 
    889 This only pertains to input/output of the U-Boot environment. Once the bootloader jumps to the kernel, the kernel is in charge of what to do about its input/output, which is controlled via the 'console' kernel cmdline. Note that there is a CONFIG_NETCONSOLE option in the kernel that uses a 'netconsole' kernel cmdline however that option is not enabled in the Gateworks kernels by default
    890 
    891 References:
    892  * https://github.com/Gateworks/u-boot-imx6/blob/gateworks_v2015.04/doc/README.NetConsole
     602
    893603
    894604
     
    939649
    940650
    941 [=#gsc]
    942 == GSC support ==
    943 The Ventana u-boot bootloader has a {{{gsc}}} command that will show you information about the GSC on the target board.
    944 
    945 This command was added in the [wiki:ventana/bootloader#BootloaderVersionHistory U-Boot 2014.04-00177-gc1e54c4 (Jan 28 2015 - 11:33:55)] release
    946 
    947 
    948 === GSC info (Firmware version, Board Temperature and Voltages) ===
    949 The {{{gsc}}} command by itself with no arguments displays information about the GSC firmware version/crc and hwmon voltage rails.
    950 
    951 Example:
    952 {{{#!bash
    953 Ventana > gsc
    954 GSC:   v45 0x30be WDT:disabled
    955 Temp    :537
    956 VIN     :16676
    957 VBATT   :2797
    958 VDD_3P3 :3320
    959 VDD_ARM :1325
    960 VDD_SOC :1330
    961 VDD_HIGH:4987
    962 VDD_DDR :1557
    963 VDD_5P0 :5130
    964 VDD_2P5 :2461
    965 VDD_1P8 :1845
    966 VDD_IO2 :3090
    967 VDD_IO3 :invalid
    968 }}}
    969 
    970 Note that not all boards use all of the above voltage rails. For example the board above does not have an IO3 voltage rail.
    971 
    972651
    973652[=#devicetree]