Changes between Initial Version and Version 1 of ventana/bootloader


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ventana/bootloader

    v1 v1  
     1[[PageOutline]]
     2
     3A [wiki:linux/bootloader bootloader] is responsible for configuring the DRAM controller and loading/executing the OS kernel.
     4
     5
     6= Ventana Bootloader =
     7The Ventana bootloader does the following:
     8 * configure DRAM controller per the memory configuration specified in the Gateworks EEPROM
     9 * configure enough of the chipset to load the kernel (uImage) and device-tree blob (DTB) from the boot media and execute the kernel with boot parameters.
     10
     11Gateworks Ventana uses a modern u-boot bootloader supporting a variety of nice features:
     12 * network support:
     13  * for eth0, supporting tftp, bootp, netconsole
     14 * USB gadget support:
     15  * networking over USB OTG device to PC host
     16 * flexible boot media support:
     17  * mmc
     18  * USB EHCI host
     19  * USB OTG
     20  * mSata
     21 * filesystem support:
     22  * fat/ext/ubi
     23 * commandline history and extended scripting support
     24 * [wiki:ventana/SPL SPL] support:
     25  * The BOOT ROM internal to the i.MX6 is the Primary Boot Loader (PBL) which loads the SPL
     26  * U-Boot builds the Secondary Boot Loader (SPL) which configures SDRAM and loads u-boot.img
     27  * U-Boot builds u-boot.img the main U-Boot app
     28  * This allows a single bootloader to support the entire Ventana product family instead of requiring a different static bootloader for each board/cpu/memory configuration
     29  * see [wiki:ventana/SPL here] for more info on the SPL
     30
     31
     32[=#prebuilt]
     33== Pre Built Bootloader ==
     34We encourage customers to use our prebuilt bootloader. Please only build the bootloader if you need to modify something and you know what you are doing.
     35
     36Pre-Built Bootloader:
     37 * [http://svn.gateworks.com/ventana/images/ Pre-Built Bootloader]
     38  * Installation instructions: [wiki:ventana/bootloader#UpdatingSPLandbootloaderviaJTAG JTAG Instructions]
     39  * [wiki:ventana/SPL SPL] - the 'Secondary Program Loader' which is loaded and executed by the internal i.MX6 BOOT ROM
     40  * {{{u-boot.img}}} - the main U-Boot
     41  * {{{u-boot_spl.bin}}} - A JTAG binary containing both the {{{SPL}}} and {{{u-boot.img}}} (the entire bootloader) suitable for updating with the Gateworks JTAG dongle and {{{jtag_usbv4}}} application.
     42
     43
     44[=#versions]
     45== Bootloader Version History ==
     46New feature support, occasional bugfixes, and support for new boards are continually being added to the bootloader.  Please be sure to keep up with the most recent bootloader as needed.
     47
     48To determine your bootloader version:
     49 * Power on the board and look at the very first line, like so:
     50{{{#!bash
     51U-Boot SPL 2015.04-g8a78625 (Apr 21 2015 - 07:24:40)
     52}}}
     53
     54Version History:
     55 * [https://github.com/Gateworks/u-boot-imx6/tree/d8a78625e9f397074a46245b645cd18062115695 d8a78625e9f397074a46245b645cd18062115695]: U-Boot SPL 2015.04-00100-gd8a7862 (Jun 12 2015 - 16:09:57)
     56  * Update to U-Boot 2015.04
     57  * added ums capability
     58  * added Falcon mode
     59  * added thermal support (display CPU temperature and loop if overtemp)
     60  * fix voltage rail for IMX6Solo/Dual-lite booting Yocto / Android kernel causing occasional PCIe corruption and system hangs
     61[[CollapsibleStart(Older History)]]
     62 * [https://github.com/Gateworks/u-boot-imx6/tree/5c40c723bb16867e612280a3c0b6dd4bb6e6b355 5c40c723bb16867e612280a3c0b6dd4bb6e6b355]: U-Boot 2014.04-g5c40c72 (Apr 21 2015 - 07:24:40)
     63  * PCI changes (to support GW16103 / GW16112 add-in cards)
     64   * enable PCI enumeration for all models
     65   * default msata/pci mux to PCI before PCI enumeration
     66   * fix PCIe reset for GW522x
     67  * MMC support for NAND-less boards:
     68   * enable support for dynamic env storage (MMC/NAND)
     69   * update MMC env configuration
     70 * f830d9d60ec7c53570ccdb23a24221e40ce8d707: U-Boot 2014.04-00184-gf830d9d (Feb 24 2015 - 08:11:33)
     71  * add {{{gsc wd}}} command for enabling and disabling GSC watchdog
     72  * display GSC WD state (enabled|disabled) along with FW ver and CRC
     73  * GW51xx-A/B - disable wdog node instead of removing it
     74  * added device-tree display configuration for LVDS displays
     75  * add support for DLC-700JMGT4 and DLC-800FIGT3 LCD displays
     76  * add new fdt_fixup_display function to configure display
     77  * add fixfdt script to apply manual fdt fixups
     78  * add DT fixup for GW54xx compatibility with older kernels
     79 * c1e54c495a68e41affde7927542b0a19544b49b5: U-Boot 2014.04-00177-gc1e54c4 (Jan 28 2015 - 11:33:55)
     80  * update DRAM configuration for GW551x
     81  * add device-tree fixup for GW551x video
     82 * 2dbf1be8c86deeba8ec7c39e941860ae02d5e785: U-Boot 2014.04-00174-g2dbf1be (Jan 09 2015 - 06:13:55)
     83  * add support for GW551x
     84  * add WDIS# pinmux for GW552x
     85  * add usb_pgood_delay set to 2000ms for USB devices
     86  * update hwmon for new power rails and remove min/max check
     87  * set new env vars used by Android boot script
     88   * set dtype env var to boot media
     89   * set mem_mb dynamic env var to size of memory
     90 * 9fd0ca4c29df2d0af52ed7afa6ab132d979e79b9: U-Boot 2014.04-00165-g9fd0ca4 (Sep 25 2014 - 14:52:25)
     91  * increase PMIC core voltages for GW51xx/GW52xx/GW53xx
     92  * disable IMX6 WDOG on GW51xx RevA/RevB as work-around for board-errata
     93 * 7bb92397a5c29d1e391124c12a985a8bc408d56c: U-Boot 2014.04-00162-g7bb9239 (Sep 22 2014 - 15:08:54)
     94  * added support for 4Gb density mem devices with IMX6DL CPU
     95  * enable DDR3 precharge power-down fast-exit mode to support Winbond DDR3 memory
     96  * add 'usb_pgood_delay' env var to specify ms delay to allow USB Mass Storage devices to warm-up before scan
     97  * enable PCIe 1.5V for GW54xx
     98  * add usb_pcisel hwconfig support for GW52xx
     99 * 6730a70db6a25f93b4522f6097e004c2577cc4e2: U-Boot 2014.04-00151-g6730a70 (Aug 19 2014 - 08:29:54)
     100  * refreshed Gateworks patchset on top of U-Boot v2014.04
     101  * added video enable gpio pinmux for GW54xx
     102  * add missing crlf to an informational print
     103  * configure i2c_dis# pin properly for gw53xx
     104  * enable SION bit on gpio outputs (this allows linux gpio-sysfs to properly
     105    report the value of gpio putputs)
     106  * configure PCISKT_WDIS# gpio
     107  * disable 4k tftp/nfs packages (until issues usign large packets are resolved)
     108  * updated SPL SDRAM calibration
     109   * use SDRAM width and size properties from Gateworks EEPROM
     110    (no longer board model specific)
     111   * add 256Mb parts (allowing up to 2GB on GW54xx/GW53xx and 1GB on others)
     112  * add GW552x support
     113   * enable uboot PCI support (but default to disabled for non GW52xx)
     114   * add PCI configuration for PLX switch
     115   * add i210 network device support
     116   * leave PCI reset de-asserted if PCI enabled
     117   * assign default ethprim dynamically to the first detected eth device
     118   * fix occasional uboot PCI link failures and display an error when no link
     119     occurs
     120  * add display support for AUO G070VW01 LCD display
     121  * fix occasional hang on IMX6SOLO/IMX6DL processors following disabling of
     122    display before launching OS
     123 * b795e679fdb4ec6476bb77efc190abcbfe8521ea: U-Boot 2014.04-00124-gb795e67 (May 16 2014 - 16:38:32)
     124  * update to U-Boot v2014.01 (released 2014-04-14)
     125  * added SPL support so that a single bootloader works for the entire Ventana product family
     126  * added econfig command for modifying configuration bits stored in Ventana EEPROM
     127 * 3a3583f5e7d118de8d067f9bc34c03224f478b0d: U-Boot 2014.01-00002-g3a3583f (Jan 21 2014 - 10:46:23)
     128  * update to U-Boot v2014.01 (released 2014-01-20)
     129  * added USB OTG support (USB Mass Storage and Ethernet gadget device)
     130  * added !NetConsole support (see [http://lxr.missinglinkelectronics.com/uboot/doc/README.NetConsole here])
     131 * 792fc2133397832de31548529dbab16a8bd6aa3b: U-Boot 2013.07-g5801172 (Jan 15 2014 - 08:12:49)
     132  * remove invalid 1.0V ADC from GW51xx
     133  * add DIO pad config to hwconfig
     134  * remove extra call to ft_board_setup
     135  * change default ubi for update
     136  * increase delay for USB polling
     137   - this resolves issues detecting some USB Mass Storage devices
     138  * increase command-line buffer size from 512 bytes to 1024 bytes
     139  * add stat_boot env script and boot support
     140  * add bootdevs env variable to dictate devices and order to boot from
     141  * add memory configuration for IMX6DL/1GB (GW53xx)
     142  * adjust default DIO padconf (removed Open Drain)
     143   - default is 100k pu, 10mA drive strength
     144 * ea5aeb54619b1deaf95c8e2acb2acc1d398264fc: U-Boot 2013.07-00019-gea5aeb5 (Dec 06 2013 - 13:12:48)
     145  * added GW53XX support
     146  * always set dts partition info regardless of model
     147  * leave PCI_RST# de-asserted to keep devices in reset until clock is valid
     148  * enable IP fragments for larger packet size
     149  * increase tftp/nfs blocksize to 4096
     150 * 88e0a40464116907932ab1b1f48e0ccac69bad67: U-Boot 2013.07-00012-g88e0a40 (Sep 25 2013 - 13:36:02)
     151  * resolved several LED/GPIO configuration issues
     152  * resolved GW5400-A (SPI FLASH) environment issues
     153  * added 'board' property to devicetree showing Gateworks board model
     154 * b33846792bafee8008c2fdac92dd18cad47c670d: U-Boot 2013.07-00004-gb338467 (Sep 12 2013 - 10:18:46)
     155  * Added GW51xx support
     156 * 4324c3b0e8c8a1fa53c2210c1e4be5ba43f8c786: U-Boot 2013.07-00003-g4324c3b (Jul 30 2013 - 15:03:56)
     157  * Initial release based on U-Boot 2013.07
     158[[CollapsibleEnd]]
     159
     160
     161[=#source]
     162== Sourcecode ==
     163We host the sourcecode for the Ventana bootloader on Github here: https://github.com/Gateworks/u-boot-imx6
     164
     165source branches:
     166 * gateworks_v2015.04 - based on u-boot-2015.04 release (Apr 2015) - Latest - Commits [https://github.com/Gateworks/u-boot-imx6/commits/gateworks_v2015.04]
     167 * gateworks_v2014.04 - based on u-boot-2014.04 release (Apr 2014) - deprecated
     168 * gateworks_v2014.01 - based on u-boot-2014.01 release (Jan 2014) - deprecated
     169 * gateworks_v2013.07 - based on u-boot-2013.07 release (Jul 2013) - deprecated
     170 * gateworks_v2013.04 - based on u-boot-2013.04 release (Mar 2013) - deprecated
     171
     172References:
     173 * [https://github.com/Gateworks/u-boot-imx6/commits/gateworks_v2014.04 Bootloader Commit Log]
     174
     175
     176[=#building]
     177== Building from Source ==
     178'''We encourage customers to use a prebuilt bootloader compiled by Gateworks. See above for Pre-Built Bootloaders and skip down to installation below [#ProgrammingInstallingu-boot] '''
     179
     180Install an armv7 toolchain:
     181 * such as the one built from the OpenWrt BSP for the Ventana Family by following the step-by-step instructions [wiki:ventana/openwrt here].
     182 * or you can download a pre-built OpenWrt toolchain [http://dev.gateworks.com/openwrt/14.08/imx6/OpenWrt-Toolchain-imx6-for-arm_cortex-a9+neon-gcc-4.8-linaro_uClibc-0.9.33.2_eabi.tar.bz2 here]
     183
     184Step-by-Step Instructions for building U-Boot:
     1851. Download U-Boot from Github
     186{{{#!bash
     187> git clone https://github.com/Gateworks/u-boot-imx6.git
     188Cloning into 'u-boot-imx6'...
     189remote: Reusing existing pack: 244857, done.
     190remote: Total 244857 (delta 0), reused 0 (delta 0)
     191Receiving objects: 100% (244857/244857), 59.16 MiB | 9.61 MiB/s, done.
     192Resolving deltas: 100% (197013/197013), done.
     193> cd u-boot-imx6
     194}}}
     1952. Configure Path of Toolchain (modify path below to contain the path from your OpenWrt {{{staging_dir}}} that contains {{{arm-openwrt-linux-gcc}}})
     196{{{#!bash
     197export PATH=$PATH:/usr/src/jackson/builds/1602git/gateworks-openwrt/staging_dir/toolchain-arm_cortex-a9+neon_gcc-5.2.0_musl-1.1.12_eabi/bin
     198export STAGING_DIR=/usr/src/jackson/builds/1602git/gateworks-openwrt/staging_dir
     199export CROSS_COMPILE=arm-openwrt-linux-
     200}}}
     2013. Configure U-Boot for the Ventana boards:
     202{{{#!bash
     203> make gwventana_config
     204Configuring for gwventana - Board: gw_ventana, Options: IMX_CONFIG=board/gateworks/gw_ventana/gw_ventana.cfg,MX6QDL,SPL
     205}}}
     2064. Build U-Boot. When done, it will create {{{SPL}}} and {{{u-boot.img}}}
     207{{{#!bash
     208make
     209}}}
     2105. Create a JTAG binary suitable for programming via the Gateworks JTAG dongle and {{{jtag_usbv4}}} software (Optional) using the [http://svn.gateworks.com/ventana/images/mkimage_jtag mkimage_jtag script]
     211{{{#!bash
     212./mkimage_jtag SPL u-boot.img > uboot_spl.bin
     213}}}
     2146. Copy the binary artifacts ({{{SPL}}}, {{{u-boot.img}}}) to a http/tftp server (Optional)
     215{{{#!bash
     216mkdir /tftpboot/ventana
     217cp SPL u-boot.img /tftpboot/ventana/
     218}}}
     219
     220
     221[=#flashing]
     222== Programming / Installing U-Boot ==
     223The procedure for updating the bootloader depends on what part of the bootloader you wish to update, the {{{SPL}}}, {{{u-boot.img}}}, (or both) and what storage media you are upating to (ie NAND Flash, or micro-SD).
     224
     225The Secondary Program Loader ({{{SPL}}}) is firmware built by the Gateworks U-Boot bootloader source and is loaded and executed by the Primary Boot Loader (PBL) which is the i.MX6 BOOT ROM (firmware inside the i.MX6 SoC). It has the following responsibilities:
     226 * determine board info: memory width, memory size, board model
     227 * configure the i.MX6 SDRAM Controller (MMDC) for the particular memory configuration and board-specific calibration values
     228 * load the main bootloader ({{{u-boot.img}}}) from the boot media (usually NAND flash) and execute it.
     229
     230The U-Boot bootloader is also built from the Gateworks U-Boot bootloader source and is loaded and executed by the Secondary Program Loader ({{{SPL}}}). It has the following responsibilities:
     231 * provide a flexible configuration environment (menu or scriptable command interface)
     232 * load and execute the OS
     233
     234The {{{u-boot.img}}}, or main bootloader, handles everything the bootloader does other than SDRAM configuration. This is what is updated when new features are added to u-boot and therefore is what you would be updating more often than the {{{SPL}}}.
     235
     236[=#nand]
     237=== NAND Flash ===
     238The majority of Gateworks Ventana boards contain a NAND flash device and boot directly from that. For instructions on update a micro-SD for boards without flash see [#microsd below].
     239
     240The partitioning scheme Gateworks uses for NAND flash storage is as follows:
     241||= Start =||= Size =||= Usage                  =||
     242|| 0K      || 14MB   || SPL                      ||
     243|| 14MB    || 16MB   || U-Boot                   ||
     244|| 16MB    || 17MB   || env (2x redundant 128KB) ||
     245|| 17MB    || -      || root partitions          ||
     246 * Note that while the {{{SPL}}} is certainly much smaller than 14MB (it actually needs to fit within the IMX6 iRAM and is less than 69KB) the reason for the excessive space has to do with redundantly storing the DCD table, the IVT table, and the {{{SPL}}} itself to deal with the possibility of bad blocks occuring in either of those data structures. It is this special layout requirement that presents the need for a special utility ({{{kobs-ng}}}) to program the {{{SPL}}} to flash.
     247
     248
     249[=#nandjtag]
     250==== Updating SPL and bootloader via JTAG ====
     251You can use JTAG on boards with NAND flash to program the {{{u-boot_spl.bin}}} downloaded from the [wiki:ventana/bootloader#prebuilt pre-built] bootloaders or created by building the source above. This file contains both the {{{SPL}}} and the bootloader and thus both will be updated simultaneously.
     252
     253Using the Gateworks JTAG dongle and the Linux [http://svn.gateworks.com/jtag/linux/x86/jtag_usbv4 jtag_usbv4] software, you can update the entire bootloader via JTAG from a Linux PC:
     254{{{#!bash
     255sudo rmmod ftdi_sio
     256sudo jtag_usbv4 -p u-boot_spl.bin
     257}}}
     258
     259Note that programming {{{u-boot_spl.bin}}} will only erase the {{{SPL}}} and {{{u-boot.img}}} portions of flash (and not the bootloader environment settings or any other portion of flash).
     260
     261Please see the [wiki:jtag_instructions JTAG Page] for more information about the JTAG programmer.
     262
     263
     264[=#nandspl]
     265==== SPL (Secondary Program Loader) ====
     266There is rarely a reason to update the {{{SPL}}}. Gateworks does not recommend downgrading the {{{SPL}}} (moving to an older version) because you may be missing important updates required to memory configuration for memory changes on the board.
     267
     268There are two main methods for flashing the SPL bootloader on a NAND flash. One is to use our {{{jtag_usbv4}}} program (see [#jtag above]) to update the entire bootloader using {{{u-boot_spl.bin}}} and the other is to use the {{{kobs-ng}}} utility from within Linux.
     269
     270In order to use the {{{kobs-ng}}} application to update the {{{SPL}}} bootloader, you must boot to Linux.  As NAND devices can have bad blocks (this keeps the cost/density ratio low) the i.mx6 boot ROM allows for multiple copies of the bootloader+headers (referred to as the 'bootstream') to be placed on NAND flash.  The {{{kobs-ng}}} application understands the flash layout and handles the gory details for you.
     271
     2721. Boot to OpenWrt Linux ('''NOTE: This does not occur in the bootloader, boot all the way into Linux''')
     2732. fetch the {{{SPL}}} bootloader
     274{{{#!bash
     275cd /tmp
     276wget http://svn.gateworks.com/ventana/images/SPL
     277}}}
     2783. execute {{{kobs-ng}}} with the following parameters
     279{{{#!bash
     280kobs-ng init -v -x --search_exponent=1 --chip_0_size=0xe00000 SPL
     281}}}
     282 * Note that you must have a version of {{{kobs-ng}}} that understands the {{{--chip_0_size}}} parameter, otherwise you need to adjust your mtd partitions such that {{{/dev/mtd0}}} is 14MB (0xe00000) in size and not 16MB (0x1000000). The Gateworks OpenWrt BSP has this version of {{{kobs-ng}}}.
     2834. You probably want to reset your U-Boot environment to use new scripts/defaults contained in the updated bootloader.  You can do this in two ways:
     284 * from Linux:
     285{{{#!bash
     286flash_eraseall /dev/mtd1
     287}}}
     288 * from U-Boot:
     289{{{#!bash
     290env default -f -a #reset to defaults
     291saveenv #save variables
     292}}}
     293
     294
     295[=#nanduboot]
     296==== u-boot.img (The main bootloader application) ====
     297Updating {{{u-boot.img}}} on a NAND flash device can be done within u-boot, or within Linux.
     298 * Updating {{{u-boot.img}}} from u-boot itself:
     299{{{#!bash
     300wget http://svn.gateworks.com/ventana/images/u-boot.img
     301tftp ${loadaddr} ventana/u-boot.img && \
     302  nand erase 0xe00000 0x200000 && \
     303  nand write ${loadaddr} 0xe00000 ${filesize}
     304}}}
     305 * Updating {{{u-boot.img}}} from Linux via {{{mtd-utils}}}:
     306{{{#!bash
     307wget http://svn.gateworks.com/ventana/images/u-boot.img
     308flash_erase /dev/mtd0 0xe00000 0 && \
     309  nandwrite --start=0xe00000 --pad /dev/mtd0 u-boot.img
     310}}}
     311
     312
     313[=#microsd]
     314=== micro-SD (boards without flash storage) ===
     315While the majority of Gateworks Ventana boards contain a NAND flash device they boot directly from (see [#nand above] for instructions on updating NAND flash), there are certain models that instead have only a micro-SD socket.
     316
     317The [wiki:ventana/SPL] supports loading the bootloader via a variety of methods including raw offset, raw partition, FAT filesystem, and EXT filesystem. The Gateworks default {{{SPL}}} is configured to load the the bootloader via a raw offset because this provides the fastest execution, simplest code, and is more in line with how we use NAND flash.
     318
     319The partitioning scheme Gateworks uses for micro-SD storage is as follows:
     320||= Start =||= Size =||= Sectors         =||= Usage                  =||
     321|| 0K      || 1KB    || 0 - 1 (2)         || Partition Table etc      ||
     322|| 1KB     || 68KB   || 2 - 137 (136)     || SPL                      ||
     323|| 69KB    || 640KB  || 138 - 1279 (141)  || U-Boot                   ||
     324|| 709KB   || 256KB  || 1418 - 1929 (512) || env (2x redundant 128KB) ||
     325|| 965KB   || 59KB   || 1930 - 2047 (117) || unused                   ||
     326|| 1024KB  || -      || 2048 -            || root partitions          ||
     327
     328
     329[=#microsdspl]
     330==== SPL (Secondary Program Loader) ====
     331You can program the {{{SPL}}} from U-Boot or Linux:
     332 * from U-Boot:
     333{{{#!bash
     334tftp ${loadaddr} SPL && mmc erase 0x0 0x2 && mmc write ${loadaddr} 0x0 0x2
     335}}}
     336  * Note that U-Boot uses hex numbers thus the values above are the sector numbers and sizes in hex
     337 * from Linux via {{{mtd-utils}}} (assuming storage device is {{{/dev/sdc}}}):
     338{{{#!bash
     339sudo dd if=SPL of=/dev/sdc bs=1K seek=1 oflag=sync # copy SPL to 1KB offset
     340}}}
     341
     342
     343[=#microsduboot]
     344==== u-boot.img (The main bootloader application_) ====
     345Updating {{{u-boot.img}}} on a NAND flashs device can be done within u-boot, or within Linux.
     346 * Updating from U-boot:
     347{{{#!bash
     348tftp ${loadaddr} u-boot.img && mmc erase 0x8a 0x500 && mmc write ${loadaddr} 0x8a 0x500
     349}}}
     350 * from Linux via {{{mtd-utils}}} (assuming storage device is {{{/dev/sdc}}}):
     351{{{#!bash
     352sudo dd if=u-boot.img of=/dev/sdc bs=1K seek=69 oflag=sync # copy uboot.img to 69KB offset
     353}}}
     354
     355
     356[=#env]
     357== environment variables ==
     358U-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.
     359
     360The most common env vars used for the Ventana bootloader are:
     361||= Name    =||= Purpose  =||
     362|| bootcmd   || script executed at boot ||
     363|| baudrate  || baudrate of serial console ||
     364|| bootdelay || number of seconds to wait for a key to abort automatic boot (if 0 will not wait) ||
     365|| bootdevs  || Used by ventana bootcmd script to specify the prioritized list of devices to boot from (usb mmc sata flash) ||
     366|| console   || device of serial console ||
     367|| ethaddr   || mac addr of first eth interface ||
     368|| eth1addr  || mac addr of second eth interface ||
     369|| ethact    || active ethernet device (current) ||
     370|| athprime  || primary ethernet device (used at boot) ||
     371|| extra     || Used by ventana boot scripts as extra info appended to the kernel bootargs ||
     372|| fdt_addr  || Address used to load flattened device-tree blob ||
     373|| fdt_file  || first choice of fdt file name (full board model and revision) ||
     374|| fdt_file1 || second choice of fdt file name (full board model) ||
     375|| fdt_file2 || third choice of fdt file name (board model family) ||
     376|| flash_boot || Ventana boot script for booting from FLASH device ||
     377|| ipaddr    || local ip address ||
     378|| loadaddr  || Address used for tftp and load commands ||
     379|| loadfdt   || Ventana boot script to load flattened device tree ||
     380|| mem_mb    || Board memory size in MB's ||
     381|| mmc_boot  || Ventana boot script for booting from micro-SD ||
     382|| model     || board model ||
     383|| mtdids    || MTD device ||
     384|| mtdparts  || MTD partitions for mtd device (merged into device-tree) ||
     385|| quiet     || if set to '1' will quiet down some of the bootloader output ||
     386|| sata_boot || Ventana boot script for booting from SATA device ||
     387|| serial#   || board serial number ||
     388|| serverip  || ip address of server for tftp commands ||
     389|| soctype   || SoC type (imx6q or imx6dl) ||
     390|| uimage    || kernel image to load ||
     391
     392
     393When 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)
     394
     395You can use {{{env}}} commands to get or set env vars. For example:
     396 * Get a var:
     397{{{#!bash
     398env print model
     399}}}
     400 * Set a var:
     401{{{#!bash
     402env set quiet 1
     403}}}
     404 * Load default values (does not save):
     405{{{#!bash
     406env default -f -a
     407}}}
     408 * Save current env:
     409{{{#!bash
     410env save
     411}}}
     412
     413If 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):
     414{{{#!bash
     415nand erase part.env
     416}}}
     417
     418To do the same from within Linux:
     419{{{#!bash
     420flash_erase /dev/mtd1 0 0
     421}}}
     422
     423[=#uboot-envtools]
     424=== U-Boot envtools (fw_printenv / fw_setenv) ===
     425The {{{uboot-envtools}}} package provides tools to allow reading and writing to U-Boot's env variables provided you have a proper configuration file.
     426
     427Assuming your 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:
     428{{{#!bash
     429> cat /proc/mtd
     430dev:    size   erasesize  name
     431mtd0: 01000000 00040000 "uboot"
     432mtd1: 00100000 00040000 "env"
     433mtd2: 7ef00000 00040000 "rootfs"
     434> cat /etc/fw_env.config
     435/dev/mtd1 0x0 0x20000 0x40000
     436/dev/mtd1 0x80000 0x20000 0x40000
     437}}}
     438
     439Assuming you are using a NAND-less board booting to micro-SD a valid config file looks like:
     440{{{#!bash
     441> cat /etc/fw_env.config
     442/dev/mmcblk0 0xb1400 0x20000 0x20000
     443/dev/mmcblk0 0xd1400 0x20000 0x20000
     444}}}
     445
     446It 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 boards ship by default) and that the built-in env within U-Boot will be used.
     447
     448If 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.
     449
     450
     451[=#nand-env]
     452=== extracting env storage (for provisioning) ===
     453When you provision boards (flashing your tailored firmware on the FLASH or creating tailored bootable media) you often want to use a modified env.
     454
     455After a board's U-Boot environment has been changed with {{{saveenv}}} you can read it back and store it in a file for re-deployment on another media.
     456
     457When extracting env be sure to clear the following vars which are usually meant to be board-specific:
     458 * {{{fdt_file}}}
     459 * {{{ethaddr}}}
     460 * {{{eth1addr}}}
     461
     462See [wiki:provisioning#nandprovisioning NAND Provisioning] for more details
     463
     464
     465[=#memmap]
     466== Memory Map ==
     467The IMX6 DRAM is physically addressed at 0x1000000 and has IRAM (internal RAM) addressed at 0x00907000. The SPL is loaded by the BOOT ROM to to 0x00908000 with 64K of code space and a 32K stack at 0x00918000. The SPL will load U-Boot to 0x1780000 which will re-locate itself to the top of DRAM with a stack and heap underneath it leaving the bottom of RAM usable by the bootloader. Because exception handlers exist at the base of DRAM the {{{loadaddr}}} is set to DRAM+32MB which is 0x1200000.
     468
     469
     470[=#bootorder]
     471== Boot order and boot scripts ==
     472u-boot by default executes the env var {{{bootcmd}}} as a script after initialization.  The Ventana bootloader default bootcmd will iterate over {{{bootdevs}}} and attempt to boot off each device mentioned there.  The default {{{bootdevs}}} is {{{usb mmc sata flash}}}
     473 * usb - USB Mass storage device
     474 * mmc - uSD card
     475 * sata - mSATA
     476 * flash - NAND/SPI flash
     477
     478In order to boot from one of the above devices there must be a {{{boot/uImage}}} on the filesystem (ext filesystem for usb/mmc/sata, and ubifs for NAND flash).  It adds time to the bootup sequence to scan these devices so you may want to change {{{bootdevs}}} if you wish to speedup boot time.
     479
     480Booting from USB Mass Storage devices:
     481 * note that if you have multiple USB Mass Storage (UMS) devices and you want your boot device to be something other than the first detected UMS device you will need to alter the default {{{usb_boot}}} script as it assumes the first device ({{{usb dev 0}}}), ext2/3/4 filesystem and the first partition ({{{ext2load usb 0:1}}}).
     482
     483Filesystem types:
     484 * note that if you want to use a filesystem other than ext2/3/4 you will need to alter the default boot scripts as they use {{{ext2load}}} commands compatible with ext2/3/4 filesystems.
     485
     486Examples:
     487 * boot straight to mmc:
     488{{{#!bash
     489setenv bootdevs mmc
     490saveenv
     491}}}
     492 * try to boot off mmc before usb:
     493{{{#!bash
     494setenv bootdevs mmc usb sata flash
     495saveenv
     496}}}
     497
     498
     499[=#usb]
     500== USB Mass Storage Support ==
     501The 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:
     502
     503General command:
     504{{{#!bash
     505setenv usb_pgood_delay 2000
     506}}}
     507
     508Example:
     509{{{#!bash
     510Ventana > usb start
     511(Re)start USB...
     512USB0:   lowlevel init failed
     513USB1:   USB EHCI 1.00
     514scanning bus 1 for devices... 2 USB Device(s) found
     515       scanning usb for storage devices... 0 Storage Device(s) found
     516       scanning usb for ethernet devices... 0 Ethernet Device(s) found
     517Ventana > setenv usb_pgood_delay 2000
     518Ventana > usb start
     519(Re)start USB...
     520USB0:   lowlevel init failed
     521USB1:   USB EHCI 1.00
     522scanning bus 1 for devices... 2 USB Device(s) found
     523       scanning usb for storage devices... 1 Storage Device(s) found
     524       scanning usb for ethernet devices... 0 Ethernet Device(s) found
     525}}}
     526
     527Be sure to run the {{{saveenv}}} command afterwards to save the setting:
     528{{{#!bash
     529saveenv
     530}}}
     531
     532
     533[=#otg]
     534== USB OTG ==
     535The USB OTG host controller on the IMX6 is supported under U-Boot in both host and gadget mode.
     536
     537Common uses in '''host mode''' include attaching to a:
     538 * USB Mass storage device
     539 * USB Network Interface (two common devices are supported - see [#usbnet below]
     540
     541Common uses in '''device mode''' include attaching to a PC:
     542 * emulating a USB Mass storage device - see [#ums below]
     543
     544[=#ums]
     545=== USB Mass Storage emulation to a Host over OTG ===
     546One 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.
     547
     548Examples:
     549 * IMX6 micro-SD host controller (this is on-board micro-SD, not a USB based micro-SD reader/writer such as the GW16103)
     550{{{#!bash
     551ums 0 mmc 0
     552}}}
     553 * USB Mass Storage device:
     554{{{#!bash
     555usb start && ums 0 usb 0
     556}}}
     557 * mSATA device:
     558{{{#!bash
     559sata init && ums 0 sata 0
     560}}}
     561
     562'''This feature is available in Gateworks U-Boot 2015.04'''
     563
     564
     565[=#gpio]
     566== General Purpose IO (GPIO) ==
     567The {{{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.
     568
     569For 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.
     570
     571Examples:
     572 * List GPIO's:
     573{{{#!bash
     574gpio status
     575}}}
     576 * set GPIO2_8 (gpio 40) (set to logic 1) (enables MSATA on boards that have it):
     577{{{#!bash
     578gpio set 40
     579}}}
     580 * clear GPIO2_8 (gpio 40) (set to logic 0) (disables MSATA and selects PCI on boards that have it):
     581{{{#!bash
     582gpio clear 40
     583}}}
     584 * set GPIO1_17 (gpio 17) as an input and get its value
     585{{{#!bash
     586gpio input 17
     587}}}
     588
     589'''This feature is available in Gateworks U-Boot 2015.04'''
     590
     591
     592[=#hwconfig]
     593== Hardware Configuration (hwconfig) ==
     594Several board configuration details are done by the bootloader at powerup such as:
     595 * DIO configuration:
     596  * pinmux: GPIO vs PWM (most of the Ventana user configurable DIO's can be configured as a PWM as well as a GPIO - see [wiki:ventana/DigitalIO#Mapping here] for details)
     597  * padctrl: The characteristics of the IO driver such as pull-up, pull-down, drive-strength etc
     598 * mSATA enabling: Board with mSATA support need to select if they wish to enable it (which disables PCIe to that socket)
     599 * rs232 driver enabling: The RS232 driver can be disabled to avoid contention between something driving the RX signal from the JTAG connector, and something driving the signal from the RS232 connector).
     600
     601The {{{hwconfig}}} env variable consists of a series of configurations separated by ';'.  Use {{{setenv}}}/{{{printenv}}}/{{{saveenv}}} to modify them.  Note that the board needs to be reset/power-cycled for the settings to take effect.  Each DIO has a ''mode'' argument (controlling pinmux) and an optional ''padctrl'' (controlling padconf).  The mode agument can be either ''gpio'' or ''pwm''.  The pwm mode is only available for certain DIO's on various boards (see [wiki:ventana/DigitalIO#Mapping here] for details).
     602
     603The bootloader will display messages showing what was configured via {{{hwconfig}}} at bootup.  For example:
     604{{{#!bash
     605U-Boot 2013.07-g5801172 (Jan 15 2014 - 08:13:16)
     606
     607CPU:   Freescale i.MX6DL rev1.1 at 792 MHz
     608...
     609MSATA: enabled
     610RS232: enabled
     611DIO0:  GPIO1_IO16 (gpio-16)
     612DIO1:  GPIO1_IO19 (gpio-19)
     613DIO2:  GPIO1_IO17 (gpio-17)
     614DIO3:  GPIO1_IO20 (gpio-20)
     615...
     616Ventana > print hwconfig
     617hwconfig=msata;rs232;dio0:mode=gpio;dio1:mode=gpio;dio2:mode=gpio;dio3:mode=gpio
     618}}}
     619
     620
     621[=#msata]
     622=== mSATA enable ===
     623''' mSATA requires a quad-core processor on Ventana'''
     624
     625On boards that support mSATA, the mSATA signals are muxed with PCIe signals on one PCIe socket of the board.  Therefore the user needs to choose whether they want to use mSATA or PCI on that socket.  This is done by adding 'msata' to {{{hwconfig}}} to enable mSATA or removing it from hwconfig to use PCIe in that socket.
     626
     627{{{#!bash
     628Ventana > setenv hwconfig "msata;${hwconfig}"
     629Ventana > saveenv
     630Ventana > reset
     631}}}
     632
     633
     634[=#usbrouting]
     635=== USB Front-panel vs PCIe socket routing ===
     636The GW52xx allows USB OTG to be routed to the front-panel connector or the J8 MiniPCIe socket (for use with a cellular modem or the [wiki:expansion/gw16103 GW16103] for example). The default routing is the front-panel connector. This can be changed to route USB OTG to the MiniPCIe J8 socket by setting the 'usb_pcisel' {{{hwconfig}}}.
     637
     638For example:
     639{{{#!bash
     640Ventana > print hwconfig
     641hwconfig=rs232;dio0:mode=gpio;dio1:mode=gpio;dio2:mode=gpio;dio3:mode=gpio
     642Ventana > setenv hwconfig "usb_pcisel;${hwconfig}"
     643Ventana > print hwconfig
     644hwconfig=usb_pcisel;rs232;dio0:mode=gpio;dio1:mode=gpio;dio2:mode=gpio;dio3:mode=gpio
     645Ventana > saveenv
     646Ventana > reset
     647}}}
     648 * The board must be reset for this to take effect
     649 * This is only supported in the bootloader at this time (vs steering at runtime with GPIO). If you are trying to boot from a USB based device (or one on a USB bus off the MiniPCIe socket you will need to do this in the bootloader)
     650
     651
     652[=#rs232enable]
     653=== rs232 driver enable ===
     654Most Ventana boards have a connector with RS232 using a UART that is shared with the one that also goes to the JTAG connector.  This is UART2 ({{{/dev/ttymxc1}}}) on all Ventana boards.  When you have hardware connected to both connectors at the same time you have a situation where two sources are driving the RX signal back to the i.MX6 at the same time and inconsistent results will occur (For example, the RS232 driver in the Gateworks JTAG dongle is a stronger driver than the one on the Ventana boards, so if you have the JTAG dongle connected you will receive characters sent from the JTAG connector serial port, but not from what is connected to the RS232 port).  To avoid this contention you can disable the RS232 driver (Note this does not disable the TX signal but only the RX input to the i.MX6).
     655
     656To enable the driver, set the {{{rs232}}} variable, to disable it remove it.
     657
     658
     659[=#dioconfig]
     660=== DIO configuration ===
     661The Ventana boards have 4 user controllable IO's from the i.MX6 going to a header.  Depending on the board, some of these can be configured as GPIO ''or'' PWM (pulse-width-modulation) signals (where the PWM frequency/period is controlled by hardware).
     662
     663To configure a dio as a gpio, set its {{{mode=gpio}}}, and to configure it as a pwm set {{{mode=pwm}}}.
     664
     665The optional ''padctrl'' argument is a hexidecimal number with leading 0x with bit descriptions below (this is equivalent to the IMX6 PAD_CTL register definition):
     666||= Bits =||= Description =||
     667|| 31-17[[BR]]reserved   || This read-only field is reserved and always has the value 0 ||
     668|| 16[[BR]]HYS           || Hysteresis Enable Field:[[BR]]- 0 DISABLED: CMOS input[[BR]]- 1 ENABLED: Schmitt trigger input ||
     669|| 15–14[[BR]]PUS        || Pull Up / Down Config:[[BR]]- 00 100K_OHM_PD: 100K Ohm Pull Down[[BR]]- 01 47K_OHM_PU: 47K Ohm Pull Up[[BR]]- 10 100K_OHM_PU : 100K Ohm Pull Up[[BR]]- 11 22K_OHM_PU: 22K Ohm Pull Up ||
     670|| 13[[BR]]PUE || Pull / Keep Select:[[BR]]- 0 KEEP: Keeper Enabled[[BR]]- 1 PULL: Pull Enabled ||
     671|| 12[[BR]]PKE || Pull / Keep Enable:[[BR]]- 0 DISABLED: Pull / Keeper Disabled[[BR]]- 1 ENABLED: Pull / Keeper Enabled ||
     672|| 11[[BR]]ODE || Open Drain Enable:[[BR]]- 0 DISABLED: Output is CMOS[[BR]]- 1 ENABLED: Output is Open Drain ||
     673|| 10–8[[BR]]Reserved || This read-only field is reserved and always has the value 0 ||
     674|| 7–6[[BR]]SPEED || Speed Field:[[BR]]- 00 Reserved[[BR]]- 01 50MHZ: Low (50 MHz)[[BR]]- 10 100MHZ: Medium (100 MHz)[[BR]]- 11 200MHZ: Maximum (200 MHz) ||
     675|| 5–3[[BR]]DSE || Drive Strength:[[BR]]- 000 HIZ: HI-Z[[BR]]- 001 240_OHM[[BR]]- 010 120_OHM[[BR]]- 011 80_OHM[[BR]]- 100 60_OHM[[BR]]- 101 48_OHM[[BR]]- 110 40_OHM[[BR]]- 111 34_OHM ||
     676|| 2–1[[BR]]Reserved || This read-only field is reserved and always has the value 0 ||
     677|| 0[[BR]]SRE || Slew Rate:[[BR]]- 0 SLOW: Slow Slew Rate[[BR]]- 1 FAST: Fast Slew Rate ||
     678
     679If unspecified the padctrl register is set to 0x1B0B9:
     680 * hysteresis
     681 * 100k pull-up
     682 * medium speed
     683 * fast slew rate
     684 * 34ohm DSE
     685
     686Examples:
     687 * to set DIO0, DIO1 to PWM and DIO2, DIO3 as a GPIO leaving the default padctrl:
     688{{{#!bash
     689setenv hwconfig 'rs232;dio0:mode=pwm;dio1:mode=pwm;dio2:mode=gpio;dio3:mode=gpio'
     690}}}
     691 * and the same but removing the pull-up from all:
     692{{{#!bash
     693setenv hwconfig 'rs232;dio0:mode=pwm,padctrl=0x1a0b9;dio1:mode=pwm,padctrl=0x1a0b9;dio2:mode=gpio,padctrl=0x1a0b9;dio3:mode=gpio,padctrl=0x1a0b9'
     694}}}
     695
     696By default, DIO's configured as PWM's register with the same driver the LED's use. This makes it easier to write PWM values to the pin. This can be accomplished by doing exactly what you would to an  LED. Writing a value of 127 (the floor of 255/2) would yield a PWM signal at 50% duty cycle. The following would accomplish this write:
     697
     698{{{#!bash
     699root@ventana:~# echo "127" > /sys/class/leds/user1/brightness
     700}}}
     701
     702DIO's configured as GPIO's register with the gpio class driver and can be controlled via {{{/sys/class/gpio}}}.
     703
     704'''Note''' - GPIO's used as outputs will read back the value the IMX6 is driving them unless the mux_mode register SION bit is set, enabling the input path. When SION is set you will read back the actual state of the pin, instead of the state the IMX6 is trying to drive. Enabling the input path by setting the SION bit does increase power draw slightly and for this reason the bit is set only for GPIO's that we may want to read the current hardware state via {{{gpio_get_value}}} or {{{gpiolib}}}.
     705
     706=== Examples ===
     707To help explain, here are some examples:
     708 * GW5400: enable mSATA on J11, enable RS232 driver, and set all DIO's to GPIO mode (the following example is with a Crucial M4-CT032M4SSD3 32GB mSATA disk):
     709{{{#!bash
     710Ventana > setenv hwconfig 'msata;rs232;dio0:mode=gpio;dio1:mode=gpio;dio2:mode=gpio;dio3:mode=gpio'
     711Ventana > saveenv
     712Ventana > reset
     713...
     714Ventana > sata part
     715AHCI 0001.0300 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
     716flags: ncq stag pm led clo only pmp pio slum part
     717SATA Device Info:
     718S/N: 00000000121903596B47
     719Product model number: M4-CT032M4SSD3
     720Firmware version: 04MH
     721Capacity: 62533296 sectors
     722
     723Partition Map for SATA device 0  --   Partition Type: DOS
     724
     725Part    Start Sector    Num Sectors     UUID            Type
     726  1     1               40959           00000000-01     83 Boot
     727  2     40960           40960           00000000-02     83
     728  3     81920           2097152         00000000-03     05 Extd
     729  4     2179072         60352512        00000000-04     83
     730  5     81921           1048575         00000000-05     83
     731  6     1130497         102399          00000000-06     83
     732  7     1232897         20479           00000000-07     83
     733  8     1253377         20479           00000000-08     83
     734}}}
     735 * GW5400: disable mSATA (use PCIe on J11), enable RS232 driver, and set DIO1,2 to PWM:
     736{{{#!bash
     737Ventana > setenv hwconfig 'rs232;dio0:mode=gpio;dio1:mode=pwm;dio2:mode=pwm;dio3:mode=gpio'
     738Ventana > saveenv
     739Ventana > reset
     740}}}
     741
     742
     743[=#network]
     744== Network Support ==
     745The Ventana U-Boot has support for the following network devices:
     746 * IMX6 FEC (eth0 on most Ventana boards)
     747 * Intel i210 (eth0 and eth1 on GW5520)
     748 * IMX6 USB OTG network gadget - usbnet (network connection between Ventana USB OTG port and host PC)
     749 * USB Network devices (ASIX AX8817X, SMSC LAN95xx)
     750
     751The following U-Boot environment variables affect networking:
     752 * {{{ipaddr}}} - local IP address
     753 * {{{serverip}}} - TFTP server IP
     754 * {{{ethprime}}} - controls which interface is used first
     755 * {{{ethact}}} - controls which interface is currently active
     756 * {{{ethrotate}}} - when set to 'no' uboot does not go through all available network interfaces and instead just stays at the currently selected interface (ethact)
     757 * {{{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.
     758 * {{{tftpsrcport}}} - UDP source port (if not set uses default)
     759 * {{{tftpdstport}}} - UDP dest port (if not set uses well known port 69)
     760 * {{{tftpblocksize}}} - if not set will use TFTP server's default block size
     761 * {{{tftptimeout}}} - retransmission timeout for TFTP packets in ms (min value is 1000, default is 5000)
     762
     763
     764[=#usbnet]
     765=== usbnet (USB OTG network Gadget support) ===
     766The Ventana bootloader supports usbnet which allows network connectivity to a PC host connected to a Ventana's USB OTG port using the CDC ethernet device standard, which is supported on Linux by the cdc-ether driver (and should be supported on other OS's as well).
     767
     768Because U-Boot is not a full fledged OS is does not support background Gadget drivers. Instead it brings up the gadget drivers when needed and takes them down when the necessary operation has completed. This means that simply connecting a PC USB host to the OTG port won't cause a new network device to appear on your host 'until' you use a U-Boot networking command such as {{{ping}}} or {{{tftpboot}}}. For this reason, its important to preconfigure your host OS for a networking port based on the MAC address that the OTG gadget driver will use (specified by the {{{usbnet_hostaddr}}} var) with an IPv4 configuration to talk to the target board.
     769
     770This is likely best explained by an example:
     771 1. configure {{{usbnet}}} on the Ventana target board:
     772{{{#!bash
     773setenv usbnet_hostaddr 00:d0:12:00:00:01
     774setenv usbnet_devaddr 00:d0:12:00:00:02
     775setenv ipaddr 10.0.0.2
     776setenv netmask 255.255.255.0
     777}}}
     778  * this specifies that the MAC address the OTG gadget will present to the CDC ethernet host to use is '00:d0:12:00:00:01' (use a unique MAC address on your network as one is not allocated for the board to use for the OTG port)
     779  * similarly the MAC address the OTG gadget target side will respond to is specified by the {{{usbnet_devaddr}}} address and it also needs to be a unique MAC address on your network.
     780
     781 2. Configure your host PC with a network interface for the specific MAC addressed defined in the usbnet_hostaddr variable above and provide it with an IPv4 configuration with an IP/netmask of 10.0.0.1/255.255.255.0. For Ubuntu hosts, you can use the Network Manager icon to create a new Interface by going to Edit Connections -> Add -> Connection Type 'Ethernet' then specify Ethernet -> Device MAC address (matching the above usbnet_hostaddr MAC), then specifying the IP/netmask under the IPv4 Settings tab.
     782
     783 3. On the Ventana target specify the active network interface is {{{usb_ether}}}:
     784{{{#!bash
     785setenv ethact usb_ether
     786}}}
     787
     788 4. On the Ventana target you can now use {{{ping}}} and {{{tftpboot}}} to communicate with the network device you created on the PC host. Note that the network interface won't 'appear' in your system until these commands start on the target:
     789{{{#!bash
     790ping 10.0.0.1
     791tftpboot ${loadaddr} uImage
     792}}}
     793
     794
     795[=#usbeth]
     796=== USB Ethernet Device support ===
     797There is support in U-Boot for a few USB chipsets that are commonly available in low-cost USB Ethernet dongles:
     798 * ASIX AX8817X - (ie [http://plugable.com/products/usb2-e100 Plugable USB2-E100 10/100mbps)
     799  * network device: asx0
     800 * SMSC LAN95xx
     801  * network device: sms0
     802
     803To use these use the following U-Boot configuration:
     804 1. scan USB bus for supported devices:
     805{{{#!bash
     806usb start
     807}}}
     808  * If you have a supported USB device attached you will see a message to that effect
     809 2. set active ethernet device - for example an ASIX device:
     810{{{#!bash
     811setenv ethact asx0
     812}}}
     813 3. Use networking as needed:
     814{{{#!bash
     815ping 192.168.1.254
     816tftp ${loadaddr} ${file}
     817}}}
     818
     819
     820
     821[=#netconsole]
     822=== !NetConsole (access U-Boot console from network) ===
     823U-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.
     824
     825Using !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.
     826
     827To enable !NetConsole you must do the following:
     828 - U-Boot:
     829  * 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}}}):
     830{{{
     831setenv ipaddr 192.168.1.1 # local ip
     832setenv serverip 192.168.1.146 # host ip running netcat/netconsole
     833}}}
     834  * set the {{{ncip}}} address to your server:
     835{{{
     836setenv ncip ${serverip}
     837}}}
     838  * set stdin/stdout/stderr as desired to {{{nc}}}:
     839{{{
     840setenv stdin nc; setenv stdout nc; setenv stderr nc
     841}}}
     842  * (optional) if you want these changed persistent, do a {{{saveenv}}}:
     843{{{
     844saveenv
     845}}}
     846 - Linux host:
     847  * make sure you have netcat (either {{{nc}}} or {{{netcat}}} applications)
     848  * grab the {{{netconsole}}} shell script from U-Boot's tools directory:
     849{{{#!bash
     850wget https://raw.githubusercontent.com/Gateworks/u-boot-imx6/gateworks_v2015.04/tools/netconsole
     851chmod +x netconsole
     852}}}
     853  * use {{{netconsole}}} to listen to your target IP address for input/output:
     854{{{#!bash
     855netconsole 192.168.1.1
     856}}}
     857   - Note that netconsole remaps the interrupt from Cntl-C to Cntl-T so that you can use Cntl-C over the network console
     858
     859
     860For 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:
     861{{{
     862setenv serverip 192.168.1.146 # your server ip
     863setenv ipaddr 192.168.1.1 # your local ip
     864setenv netretry no
     865setenv preboot 'echo "Looking for server at $serverip..."; \
     866 if ping $serverip; then setenv ncip ${serverip}; setenv bootdelay 10; \
     867 echo "Starting NetConsole to ${ncip} and waiting for ${bootdelay} seconds..."; \
     868 setenv stdin nc; setenv stdout nc; setenv stderr nc; \
     869 fi'
     870saveenv
     871}}}
     872 * 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'.
     873
     874This 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
     875
     876References:
     877 * https://github.com/Gateworks/u-boot-imx6/blob/gateworks_v2015.04/doc/README.NetConsole
     878
     879
     880[=#display]
     881== Display support ==
     882The u-boot bootloader has some rudimentary support for displays including LVDS displays and HDMI monitors. The most recent Gateworks bootloader will display a Gateworks logo centered within the display (older versions would display a Linux 'tux' logo in the upper left hand corner along with the uboot version and build information).
     883
     884The {{{panel}}} env variable is used to set the display type in the bootloader and can be set to the following:
     885 - **HDMI** (1024x768 resolution - no EDID info used for monitor preferences)
     886 - **Hannstar-XGA** - Freescale MXC-LVDS1 (!HannStar HSD100PXN1-A00 w/ egalax touchscreen controller)
     887 - **DLC800FIGT3** - 8in XGA (1024x768)
     888 - **DLC700JMGT4** - 7in WSVGA (1024x600)
     889 - **none** - any other string such as 'none' will disable display support in the bootloader
     890
     891If the {{{panel}}} env variable is not set the display device will attempt to be detected by first looking to see if an HDMI monitor is connected to the HDMI phy, and next to see if an i2c device at 0x04 (touchscreen controller) which is assumed to be the Hannstar-XGA.
     892
     893The {{{display}}} env variable is used to configure the Gateworks kernel display timings (via device-tree properties). Additionally the boot scripts used for various OS's such as Yocto or Android configure kernel parameters for various display options.
     894
     895Examples:
     896 * display the bootloader splash and configure Linux OS for DLC800FIGT3:
     897{{{#!bash
     898setenv panel DLC800FIGT3
     899setenv display DLC800FIGT3
     900saveenv
     901reset
     902}}}
     903 * display the bootloader splash for DLC800FIGT3 but do not configure Linux OS
     904{{{#!bash
     905setenv panel DLC800FIGT3
     906setenv display none
     907saveenv
     908reset
     909}}}
     910 * disable bootloader splash but configure Linux OS for DLC800FIGT3:
     911{{{#!bash
     912setenv panel none
     913setenv display DLC800FIGT3
     914saveenv
     915reset
     916}}}
     917
     918Some Linux OS's may behave differently or have additional features - please see OS specific notes on the respective wiki pages:
     919 * [wiki:Yocto/Video_Out#bootscript Yocto or other third-party-linux distros using the Gateworks kernel]
     920 * [wiki:Android/Booting#display Android]
     921
     922
     923[=#gsc]
     924== GSC support ==
     925The Ventana u-boot bootloader has a {{{gsc}}} command that will show you information about the GSC on the target board.
     926
     927This command was added in the [wiki:ventana/bootloader#BootloaderVersionHistory U-Boot 2014.04-00177-gc1e54c4 (Jan 28 2015 - 11:33:55)] release
     928
     929
     930=== GSC info (Firmware version, Board Temperature and Voltages, and Watchdog info) ===
     931The {{{gsc}}} command by itself with no arguments displays information about the GSC firmware version/crc and watchdog state (enabled or disabled and whether or not it caused a board power-cycle)
     932
     933Example:
     934{{{#!bash
     935Ventana > gsc
     936GSC:   v45 0x30be WDT:disabled
     937Temp    :537
     938VIN     :16676
     939VBATT   :2797
     940VDD_3P3 :3320
     941VDD_ARM :1325
     942VDD_SOC :1330
     943VDD_HIGH:4987
     944VDD_DDR :1557
     945VDD_5P0 :5130
     946VDD_2P5 :2461
     947VDD_1P8 :1845
     948VDD_IO2 :3090
     949VDD_IO3 :invalid
     950}}}
     951
     952Note that not all boards use all of the above voltage rails. For example the board above does not have an IO3 voltage rail.
     953
     954
     955=== GSC Watchdog Enable / Disable ===
     956The {{{gsc}}} command can be used to enable or disable the GSC hardware watchdog with the following usage:
     957{{{#!bash
     958gsc [wd enable [30|60]]|[wd disable]
     959}}}
     960
     961Examples:
     962 * Enable the watchdog for a 30 second timeout
     963{{{#!bash
     964gsc wd enable 30
     965}}}
     966  * If the time is not specified it will default to 30 seconds
     967  * only 30 seconds and 60 seconds are valid
     968  * once enabled make sure you have something managing the watchdog in your OS
     969 * Disable the GSC watchdog
     970{{{#!bash
     971gsc wd disable
     972}}}
     973
     974References:
     975 * [wiki:watchdog General Watchdog info]
     976 * [wiki:gsc#HardwareWatchdog GSC Hardware Watchdog info]
     977 * [wiki:gsc#GSCWatchdogkerneldriver GSC Hardware Watchdog linux drivers]
     978
     979
     980[=#devicetree]
     981== Flattened Device-Tree ==
     982The Ventana kernel (with the exception of the 3.0.35 kernel used in early Yocto v1.3 and Android jellybean BSP's) is a device-tree kernel. This means the bootloader is responsible for loading the device-tree blob (DTB) and adjusting it per bootloader configuration (and occasionally hardware errata).
     983
     984The  {{{loadfdt}}} script is used to load the device-tree blob (dtb) in all standard boot cases for the Gateworks bootloader. This script attempts to load a dtb three times, each time with a more generic filename (from the {{{fdt_file}}}, {{{fdt_file1}}}, and {{{fdt_file2}}}) env variable which if not set (overridden) will get set per the board model defined in the Gateworks EEPROM. For example a GW5400-C would have the following:
     985{{{#!bash
     986Ventana >  print fdt_file
     987fdt_file=imx6q-gw5400-c.dtb
     988Ventana >  print fdt_file1
     989fdt_file1=imx6q-gw5400.dtb
     990Ventana >  print fdt_file2
     991fdt_file2=imx6q-gw54xx.dtb
     992}}}
     993
     994The only dtb files we have required thus far is the most generic version specified by {{{fdt_file2}}}. You can see the dtb files in the boot directory of the root filesystem of our BSP's.
     995
     996
     997=== Using the fixfdt script to apply custom fdt fixups ===
     998The Ventana bootloader U-Boot scripts run a script called {{{fixfdt}}} to apply any custom fixups you may want to implement. Specifically this script is called from the {{{loadfdt}}} script.
     999
     1000Example:
     1001 * add an fdt fixup to disable pcie driver
     1002{{{#!bash
     1003setenv fixfdt 'fdt addr ${fdt_addr}; fdt resize; fdt set /soc/pcie@0x01000000 status disabled'
     1004saveenv
     1005}}}
     1006 * To find the path on a running live system, run the following command to see the device tree on the target board:
     1007{{{#!bash
     1008find /proc/device-tree
     1009}}}
     1010  * You can then grep for whatever item is needed:
     1011{{{#!bash
     1012root@OpenWrt:/# find /proc/device-tree/ | grep lvds
     1013/proc/device-tree/soc/aips-bus@02000000/ldb@020e0008/lvds-channel@1
     1014/proc/device-tree/soc/aips-bus@02000000/ldb@020e0008/lvds-channel@1/name
     1015/proc/device-tree/soc/aips-bus@02000000/ldb@020e0008/lvds-channel@1/crtcs
     1016/proc/device-tree/soc/aips-bus@02000000/ldb@020e0008/lvds-channel@1/status
     1017}}}
     1018  * The status field is typically what should be changed to 'disabled'
     1019{{{#!bash
     1020root@OpenWrt:/# cat /proc/device-tree/soc/aips-bus@02000000/ldb@020e0008/lvds-channel@0/status
     1021okay
     1022}}}
     1023  * To disable this LVDS, it would look like
     1024{{{#!bash
     1025setenv fixfdt 'fdt addr ${fdt_addr}; fdt resize; fdt set /soc/aips-bus@02000000/ldb@020e0008/lvds-channel@0 status disabled'
     1026saveenv
     1027}}}
     1028
     1029This script is available in '''U-Boot 2014.04-00184-gf830d9d (Feb 24 2015 - 08:11:33)'''.
     1030
     1031
     1032=== Specifying an alternate device-tree blob (DTB) ===
     1033Knowing that the  {{{loadfdt}}} attempts to load {{{fdt_file}}}, {{{fdt_file1}}}, {{{fdt_file2}}} in that order, you can override {{{fdt_file}}} to specify an alternate DTB. This would be useful if you need to alter the device-tree to add support for an off-board peripheral for example and i2c device.
     1034
     1035If you have built a dtb that you want loaded instead of the default model-based fdt you can specify it as follows in the bootloader:
     1036{{{#!bash
     1037setenv fdt_file my-custom.dtb
     1038saveenv
     1039}}}
     1040
     1041If you ever want to revert back, just erase your bootloader environment or unset the {{{fdt_file}}} by setting it to nothing:
     1042{{{#!bash
     1043setenv fdt_file
     1044saveenv
     1045}}}
     1046
     1047Don't forget that by default the {{{loadfdt}}} script assumes the dtb's are located on the rootfs in the {{{/boot}}} directory.