159189a8bSTim HarveyU-Boot for the Gateworks Ventana Product Family boards
259189a8bSTim Harvey
359189a8bSTim HarveyThis file contains information for the port of U-Boot to the Gateworks
459189a8bSTim HarveyVentana Product family boards.
559189a8bSTim Harvey
6*40e999caSTim HarveyThe entire Ventana product family (http://www.gateworks.com/product#ventana)
7*40e999caSTim Harveyis supported by a single bootloader build by using a common SPL and U-Boot
8*40e999caSTim Harveythat dynamically determines the characterstics of the board at runtime via
9*40e999caSTim Harveyinformation from an EEPROM on the board programmed at the factory and supports
10*40e999caSTim Harveyall of the various boot mediums available.
11*40e999caSTim Harvey
120cc11deaSTim Harvey1. Secondary Program Loader (SPL)
130cc11deaSTim Harvey---------------------------------
140cc11deaSTim Harvey
150cc11deaSTim HarveyThe i.MX6 has a BOOT ROM PPL (Primary Program Loader) which supports loading
160cc11deaSTim Harveyan executable image from various boot devices.
170cc11deaSTim Harvey
180cc11deaSTim HarveyThe Gateworks Ventana board config uses an SPL build configuration. This
190cc11deaSTim Harveywill build the following artifacts from u-boot source:
200cc11deaSTim Harvey - SPL - Secondary Program Loader that the i.MX6 BOOT ROM (Primary Program
210cc11deaSTim Harvey         Loader) boots.  This detects CPU/DRAM configuration, configures
220cc11deaSTim Harvey         The DRAM controller, loads u-boot.img from the detected boot device,
230cc11deaSTim Harvey         and jumps to it.  As this is booted from the PPL, it has an IVT/DCD
240cc11deaSTim Harvey         table.
250cc11deaSTim Harvey - u-boot.img - The main u-boot core which is u-boot.bin with a image header.
260cc11deaSTim Harvey
270cc11deaSTim Harvey
280cc11deaSTim Harvey2. Build
290cc11deaSTim Harvey--------
300cc11deaSTim Harvey
310cc11deaSTim HarveyTo build U-Boot for the Gateworks Ventana product family:
320cc11deaSTim Harvey
330cc11deaSTim Harvey make gwventana_config
340cc11deaSTim Harvey make
350cc11deaSTim Harvey
360cc11deaSTim Harvey
37*40e999caSTim Harvey3. Boot source:
38*40e999caSTim Harvey---------------
39*40e999caSTim Harvey
40*40e999caSTim HarveyThe Gateworks Ventana boards support booting from NAND or micro-SD depending
41*40e999caSTim Harveyon the board model. The IMX6 BOOT ROM will choose a boot media based on eFUSE
42*40e999caSTim Harveysettings programmed at the factory.
43*40e999caSTim Harvey
44*40e999caSTim HarveyBoards with NAND flash will always boot from NAND, and NAND-less boards will
45*40e999caSTim Harveyalways boot from micro-SD. However, it is possible to use the U-Boot bmode
46*40e999caSTim Harveycommand (or the technique it uses) to essentially bootstrap to another boot
47*40e999caSTim Harveymedia at runtime.
48*40e999caSTim Harvey
49*40e999caSTim Harvey3.1. boot from NAND
50*40e999caSTim Harvey-------------------
5159189a8bSTim Harvey
5259189a8bSTim HarveyThe i.MX6 BOOT ROM expects some structures that provide details of NAND layout
5359189a8bSTim Harveyand bad block information (referred to as 'bootstreams') which are replicated
540cc11deaSTim Harveymultiple times in NAND. The number of replications and their spacing (referred
550cc11deaSTim Harveyto as search stride) is configurable through board strapping options and/or
560cc11deaSTim HarveyeFUSE settings (BOOT_SEARCH_COUNT / Pages in block from BOOT_CFG2). In
570cc11deaSTim Harveyaddition, the i.MX6 BOOT ROM Flash Configuration Block (FCB) supports two
580cc11deaSTim Harveycopies of a bootloader in flash in the case that a bad block has corrupted one.
590cc11deaSTim HarveyThe Freescale 'kobs-ng' application from the Freescale LTIB BSP, which runs
600cc11deaSTim Harveyunder Linux and operates on an MTD partition, must be used to program the
610cc11deaSTim Harveybootstream in order to setup this flash structure correctly.
6259189a8bSTim Harvey
6359189a8bSTim HarveyThe Gateworks Ventana boards with NAND flash have been factory programmed
6459189a8bSTim Harveysuch that their eFUSE settings expect 2 copies of the boostream (this is
6559189a8bSTim Harveyspecified by providing kobs-ng with the --search_exponent=1 argument). Once in
660cc11deaSTim HarveyLinux with MTD support for the NAND on /dev/mtd0 you can program the SPL
6759189a8bSTim Harveywith:
6859189a8bSTim Harvey
690cc11deaSTim Harveykobs-ng init -v -x --search_exponent=1 SPL
7059189a8bSTim Harvey
710cc11deaSTim HarveyThe kobs-ng application uses an imximage which contains the Image Vector Table
720cc11deaSTim Harvey(IVT) and Device Configuration Data (DCD) structures that the i.MX6 BOOT ROM
730cc11deaSTim Harveyrequires to boot.  The kobs-ng adds the Firmware Configuration Block (FCB) and
740cc11deaSTim HarveyDiscovered Bad Block Table (DBBT).  The SPL build artifact from u-boot is
750cc11deaSTim Harveyan imximage.
760cc11deaSTim Harvey
770cc11deaSTim HarveyThe u-boot.img, which is the non SPL u-boot binary appended to a u-boot image
780cc11deaSTim Harveyheader must be programmed in the NAND flash boot device at an offset hard
790cc11deaSTim Harveycoded in the SPL. For the Ventana boards, this has been chosen to be 14MB.
800cc11deaSTim HarveyThe image can be programmed from either u-boot or Linux:
810cc11deaSTim Harvey
820cc11deaSTim Harveyu-boot:
830cc11deaSTim HarveyVentana > setenv mtdparts mtdparts=nand:14m(spl),2m(uboot),1m(env),-(rootfs)
840cc11deaSTim HarveyVentana > tftp ${loadaddr} u-boot.img && nand erase.part uboot && \
850cc11deaSTim Harvey          nand write ${loadaddr} uboot ${filesize}
860cc11deaSTim Harvey
870cc11deaSTim HarveyLinux:
880cc11deaSTim Harveynandwrite /dev/mtd1 u-boot.img
890cc11deaSTim Harvey
900cc11deaSTim HarveyThe above assumes the default Ventana partitioning scheme which is configured
910cc11deaSTim Harveyvia the mtdparts env var:
920cc11deaSTim Harvey - spl: 14MB
930cc11deaSTim Harvey - uboot: 2M
940cc11deaSTim Harvey - env: 1M
950cc11deaSTim Harvey - rootfs: the rest
9659189a8bSTim Harvey
9759189a8bSTim HarveyThis information is taken from:
98*40e999caSTim Harvey  http://trac.gateworks.com/wiki/ventana/bootloader#nand
99*40e999caSTim Harvey
100*40e999caSTim HarveyMore details about the i.MX6 BOOT ROM can be found in the IMX6 reference manual.
101*40e999caSTim Harvey
102*40e999caSTim Harvey3.1. boot from micro-SD
103*40e999caSTim Harvey-----------------------
104*40e999caSTim Harvey
105*40e999caSTim HarveyWhen the IMX6 eFUSE settings have been factory programmed to boot from
106*40e999caSTim Harveymicro-SD the SPL will be loaded from offset 0x400 (1KB). Once the SPL is
107*40e999caSTim Harveybooted, it will load and execute U-boot (u-boot.img) from offset 69KB
108*40e999caSTim Harveyon the micro-SD (defined by CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR).
109*40e999caSTim Harvey
110*40e999caSTim HarveyWhile it is technically possible to enable the SPL to be able to load
111*40e999caSTim HarveyU-Boot from a file on a FAT/EXT filesystem on the micro-SD, we chose to
112*40e999caSTim Harveyuse raw micro-SD access to keep the code-size and boot time of the SPL down.
113*40e999caSTim Harvey
114*40e999caSTim HarveyFor these reasons a micro-SD that will be used as an IMX6 primary boot
115*40e999caSTim Harveydevice must be carefully partitioned and prepared.
116*40e999caSTim Harvey
117*40e999caSTim HarveyThe following shell commands are executed on a Linux host (adjust DEV to the
118*40e999caSTim Harveyblock storage device of your micro-SD):
119*40e999caSTim Harvey
120*40e999caSTim Harvey DEV=/dev/sdc
121*40e999caSTim Harvey # zero out 1MB of device
122*40e999caSTim Harvey sudo dd if=/dev/zero of=$DEV count=1 bs=1M oflag=sync status=none && sync
123*40e999caSTim Harvey # copy SPL to 1KB offset
124*40e999caSTim Harvey sudo dd if=SPL of=$DEV bs=1K seek=1 oflag=sync status=none && sync
125*40e999caSTim Harvey # copy U-Boot to 69KB offset
126*40e999caSTim Harvey sudo dd if=u-boot.img of=$DEV bs=1K seek=69 oflag=sync status=none && sync
127*40e999caSTim Harvey # create a partition table with a single rootfs partition starting at 1MB
128*40e999caSTim Harvey printf "1,,L\n" | sudo sfdisk --in-order --no-reread -L -uM $DEV && sync
129*40e999caSTim Harvey # format partition
130*40e999caSTim Harvey sudo mkfs.ext4 -L root ${DEV}1
131*40e999caSTim Harvey # mount the partition
132*40e999caSTim Harvey sudo udisks --mount ${DEV}1
133*40e999caSTim Harvey # extract filesystem
134*40e999caSTim Harvey sudo tar xvf rootfs.tar.gz -C /media/root
135*40e999caSTim Harvey # flush and unmount
136*40e999caSTim Harvey sync && sudo umount /media/root
137*40e999caSTim Harvey
138*40e999caSTim HarveyThe above assumes the default Ventana micro-SD partitioning scheme
139*40e999caSTim Harvey - spl    :   1KB-69KB  (68KB)  required by IMX6 BOOT ROM
140*40e999caSTim Harvey - uboot  :  69KB-709KB (640KB) defined by
141*40e999caSTim Harvey                                CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
142*40e999caSTim Harvey - env    : 709KB-965KB (256KB) defined by
143*40e999caSTim Harvey                                CONFIG_ENV_MMC_SIZE
144*40e999caSTim Harvey                                CONFIG_ENV_MMC_OFFSET_REDUND
145*40e999caSTim Harvey - rootfs :   1MB-
146*40e999caSTim Harvey
147*40e999caSTim HarveyThis information is taken from:
148*40e999caSTim Harvey  http://trac.gateworks.com/wiki/ventana/bootloader#microsd
14959189a8bSTim Harvey
15059189a8bSTim HarveyMore details about the i.MX6 BOOT ROM can be found in the IMX6 reference manual.
15159189a8bSTim Harvey
152