├── new_kern.txt ├── old_kern.txt ├── videocon.txt ├── serialcon.txt ├── Makefile ├── reset.txt ├── uboot-env.conf ├── u-boot.txt ├── README-environments ├── README-uboot-env ├── default.txt ├── README-custom └── uboot-env.c /new_kern.txt: -------------------------------------------------------------------------------- 1 | bootfile= 2 | bootkern= 3 | fdt_load= 4 | -------------------------------------------------------------------------------- /old_kern.txt: -------------------------------------------------------------------------------- 1 | bootfile=uImage 2 | bootkern=bootm 3 | fdt_load=no 4 | -------------------------------------------------------------------------------- /videocon.txt: -------------------------------------------------------------------------------- 1 | console= 2 | stdin=serial,usbkbd 3 | stdout=serial,vga 4 | stderr=serial,vga 5 | -------------------------------------------------------------------------------- /serialcon.txt: -------------------------------------------------------------------------------- 1 | console=console=ttymxc0,115200 2 | stdin=serial,usbkbd 3 | stdout=serial 4 | stderr=serial 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: uboot-env 2 | 3 | install: uboot-env 4 | cp uboot-env $INSTALL/sbin 5 | cp uboot-env.conf $INSTALL/etc 6 | 7 | uboot-env: uboot-env.c 8 | cc -Os -mthumb -o uboot-env uboot-env.c 9 | strip uboot-env 10 | -------------------------------------------------------------------------------- /reset.txt: -------------------------------------------------------------------------------- 1 | baudrate=115200 2 | console=ttymxc0,115200 3 | stdin=serial,usbkbd 4 | stdout=serial,vga 5 | stderr=serial,vga 6 | bootdev= 7 | bootunit= 8 | bootpart= 9 | bootroot= 10 | envfile= 11 | bootfile= 12 | rootdev= 13 | rootunit= 14 | rootpart= 15 | rootfs= 16 | fdt_load= 17 | fdt_dev= 18 | fdt_unit= 19 | fdt_part= 20 | fdt_dir= 21 | fdt_cpu= 22 | fdt_board= 23 | fdt_file= 24 | bootkern= 25 | -------------------------------------------------------------------------------- /uboot-env.conf: -------------------------------------------------------------------------------- 1 | # anything before the default line is applied to everything 2 | # anything after the default line, before the first name line, 3 | # applies only to -f file references 4 | # 5 | length 0x2000 # default length for everything 6 | # note: overrides ALL length settings below 7 | 8 | default mmc # default to SD card slot 9 | offset 0 # default for non-device 10 | 11 | name mmc 12 | device /dev/mmcblk0 13 | 14 | name sda 15 | device /dev/sda 16 | 17 | name /dev/mmcblk0 # SD card slot 18 | offset 0x60000 19 | 20 | name /dev/sda # USB or eSATA (first detected) 21 | offset 0x60000 22 | -------------------------------------------------------------------------------- /u-boot.txt: -------------------------------------------------------------------------------- 1 | baudrate=115200 2 | bootcmd=run preset bootset bootenv bootload bootstart 3 | bootdelay=3 4 | bootload=load $bootdev $bootunit:$bootpart 0x$loadaddr $bootroot$loadfile; if test $fdt_load = yes; then load $fdt_dev $fdt_unit:$fdt_part 0x$fdt_addr $fdt_file; bootrun="$bootkern $loadaddr - $fdt_addr"; else bootrun=$bootkern; fi 5 | bootset=setenv bootenv 'run set$rootdev; setenv bootargs $root $video $console $bootextra'; if load $bootdev $bootunit:$bootpart 0x$loadaddr $envfile; then env import -t $loadaddr $filesize; fi; loadfile=$bootfile; rootdev=$bootdev; rootunit=$bootunit; rootpart=$bootpart; fdt_dev=$bootdev; fdt_unit=$bootunit; fdt_part=$bootpart; fdt_dir=${bootroot}; if test $cpu = 6Q; then fdt_cpu=imx6q; else fdt_cpu=imx6dl; fi; if test $board = mx6-cubox-i; then fdt_board=cubox-i; else fdt_board=hummingboard; fi; fdt_file=$fdt_dir$fdt_cpu-$fdt_board.dtb 6 | bootstart=echo $bootfile $bootargs; echo $bootrun $loadfile; $bootrun 7 | console=console=ttymxc0,115200 8 | fdt_high=ffffffff 9 | loadaddr=14000000 10 | mmc=run reset; mmc rescan 11 | new_kern=env del bootfile bootkern fdt_load 12 | old_kern=setenv bootfile uImage; setenv bootkern bootm; setenv fdt_load no 13 | preboot=usb start 14 | preset=bootdev=mmc; bootunit=0; bootpart=1; bootroot=/boot/; envfile=${bootroot}uEnv.txt; bootfile=zImage; rootfs=ext4; rootextra="rootfstype=$rootfs ro rootwait"; bootkern=bootz; fdt_load=yes; fdt_addr=1c000000 15 | reset=env del bootdev bootunit bootpart bootroot envfile bootfile bootkern rootdev rootunit rootpart rootfs rootextra; env del fdt_load fdt_dev fdt_unit fdt_part fdt_dir fdt_cpu fdt_board fdt_file bootkern 16 | serialcon=setenv console console=ttymxc0,$baudrate; setenv stdout serial; setenv stderr serial; setenv stdin serial,usbkbd 17 | setlabel=root="root=$rootlabel $rootextra" 18 | setmmc=root="root=/dev/mmcblk${rootunit}p$rootpart $rootextra" 19 | setusb=root="root=/dev/sda$rootpart $rootextra" 20 | splashpos=m,m 21 | stderr=serial,vga 22 | stdin=serial,usbkbd 23 | stdout=serial,vga 24 | usb=run reset; setenv bootdev usb; usb reset 25 | videocon=setenv console; setenv stdout vga; setenv stderr vga; setenv stdin serial,usbkbd 26 | -------------------------------------------------------------------------------- /README-environments: -------------------------------------------------------------------------------- 1 | There are several environment text files included, these are targeted 2 | towards the CuBox-i, but may be useful for other devices. 3 | 4 | default.txt Contains the default boot scripts and variables for 5 | the CuBox-i U-Boot. 6 | 7 | u-boot.txt Contains a custom boot environment with scripts and 8 | variables. The following environment files pertain 9 | to this custom environment. 10 | 11 | reset.txt Resets all parameters back to default. Same as using 12 | the "run reset" command in U-Boot. 13 | 14 | videocon.txt Set variables to use the video console with USB keyboard. 15 | This also affects the bootargs kernel command line. Same 16 | as using "run videocon" in U-Boot. 17 | 18 | serialcon.txt Set variables to use the serial console. Same as using 19 | "run serialcon" in U-Boot. 20 | 21 | old_kern.txt Set variables to use older kernel (uImage, no dtb file), 22 | same as using "run old_kern" in U-Boot. 23 | 24 | new_kern.txt Set variables to use newer kernel (zImage, dtb file), same 25 | as using "run new_kern" in U-Boot. This is the default. 26 | 27 | To use any of these, run (for example, with the serialcon.txt file): 28 | 29 | uboot-env set < serialcon.txt 30 | 31 | If you want to load the u-boot.txt or default.txt, you may want to clear 32 | all other variables out: 33 | 34 | uboot-env del -i 35 | uboot-env set < default.txt 36 | 37 | You can also force the default U-Boot environment by corrupting the save 38 | area; the cleanest way to do this is to use dd to zero the area (thus 39 | the checksum fails, and U-Boot loads default environment). The following 40 | command works on the CuBox-i, with an offset of 0x60000 and length of 41 | 0x2000. VERIFY the command, be certain you're writing to the correct 42 | device or you will lose data. 43 | 44 | verify that U-Boot variables are installed (if this fails, either you 45 | don't need to run the dd command, or the offset/length is WRONG so 46 | you should NOT run the dd command): 47 | 48 | uboot-env -o 0x60000 -l 0x2000 -d /dev/mmcblk0 del -i 49 | 50 | If that command succeeds with no error, you can safely use: 51 | 52 | dd if=/dev/zero bs=8K count=1 seek=48 of=/dev/mmcblk0 53 | 54 | 8K = 0x2000, 48 * 8K = 0x60000 55 | -------------------------------------------------------------------------------- /README-uboot-env: -------------------------------------------------------------------------------- 1 | This program is used to read or modify U-Boot environment variables in 2 | an image file or on a block boot device (e.g. SD card or USB drive that 3 | contains U-Boot). 4 | 5 | The configuration file (/etc/uboot-env.conf) contains valid device 6 | names with offsets and lengths. The default configuration may need to 7 | be changed for your specific device. 8 | 9 | The config file distributed is one that works with the CuBox-i, with 10 | an offset of 0x60000 for 0x2000. 11 | 12 | If you specify an image file (one that's intended to be written directly 13 | to the block device used to boot a system) you'll need to specify the 14 | offset. Although the configuration file could be modified to have a 15 | non-zero default for the offset, it probably isn't a good idea. 16 | 17 | The environment save area is protected by a CRC32 checksum. For safety, 18 | uboot-env will immediately exit if the checksum is not correct, unless 19 | the -I flag is used (in which case the checksum must NOT be correct, it 20 | can only be used to initialize an area known to be invalid). 21 | 22 | 23 | Usage: uboot-env [-cdfol] get -s filename 24 | uboot-env [-cdfol] get [var1 ... ] 25 | uboot-env [-cdfol] del [var1 ... ] 26 | uboot-env [-cdfol] del -[i|I] 27 | uboot-env [-cdfol] set -s filename 28 | uboot-env [-cdfol] set var val 29 | uboot-env [-cdfol] set < uEnv.txt 30 | 31 | -c config Alternate config file 32 | -d devicename Device with environment 33 | -f filename File with environment 34 | -s filename Save to or set from file 35 | -o offset Offset into device 36 | -l length Length in device 37 | -i Initialize environment 38 | -I Forced initialize 39 | 40 | When using the -s option with get, the referenced file will be overwritten 41 | and the entire environment area will be saved (including checksum). 42 | When used with set, the file must be long enough and the checksum must 43 | be valid; the entire environment area on the target will be replaced. 44 | Note that any offset applies only to the target, the save file always 45 | has an offset of zero. 46 | 47 | When setting a variable on the command line, you must provide one 48 | variable name and one value argument; if there are embedded spaces or 49 | other special characters in the value, you'll need to quote or escape it. 50 | A variable name may not contain "=". 51 | 52 | Setting a variable to an empty value will delete the variable. 53 | 54 | When using the set option with no further arguments, variables and 55 | values are read from stdin, with an "=" separating the two. Again, 56 | setting an empty value will delete the variable. 57 | 58 | It is not an error to delete a non-existent variable. 59 | 60 | When getting variables, more than one variable name may be specified. 61 | The variables will be displayed in alphabetic order. If no variables 62 | are specified, all variables are retrieved. 63 | -------------------------------------------------------------------------------- /default.txt: -------------------------------------------------------------------------------- 1 | autoboot=echo Booting ${boot_file}; if test ${boot_file} = zImage; then bootz; else bootm; fi; 2 | autobootfdt=echo Booting ${boot_file}; if test ${boot_file} = zImage; then bootz ${loadaddr} - ${fdt_addr}; else bootm ${loadaddr} - ${fdt_addr}; fi; 3 | autodetectfdt=if test ${cpu} = 6SOLO || test ${cpu} = 6DL; then setenv fdt_prefix imx6dl; else setenv fdt_prefix imx6q; fi; if test ${board} = mx6-cubox-i; then setenv fdt_file ${fdt_prefix}-cubox-i.dtb; else setenv fdt_file ${fdt_prefix}-hummingboard.dtb; fi; 4 | baudrate=115200 5 | boot_fdt=try 6 | boot_prefixes=/ /boot/ 7 | bootcmd=mmc dev ${mmcdev}; if mmc rescan; then for prefix in ${boot_prefixes}; do setenv file_prefix ${prefix}; if run loadbootscript; then run bootscript; else run autodetectfdt; if run loadbootenv; then run importbootenv; fi; if test ${bootfile} = auto; then setenv origbootfile auto; setenv bootfile zImage; if run loadbootfile; then run mmcboot; else setenv bootfile uImage; fi; fi; if run loadbootfile; then run mmcboot; else setenv bootfile ${origbootfile}; fi; fi; done; fi; run netboot; 8 | bootdelay=3 9 | bootenv=uEnv.txt 10 | bootfile=auto 11 | bootit=setenv boot_file ${bootfile}; if test ${boot_file} = zImage; then if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then run autobootfdt; else if test ${boot_fdt} = try; then echo WARN: Cannot load the DTB and boot file is type zImage;echo if you have not appended a dtb to the file it may;echo hang after displaying Starting kernel...;echo ;run autoboot; else echo WARN: Cannot load the DT; fi; fi; else run autoboot; fi; else run autoboot; fi; 12 | bootscript=echo Running bootscript from mmc ...; source; 13 | console=ttymxc0 14 | ethprime=FEC 15 | fdt_addr=0x18000000 16 | fdt_high=0xffffffff 17 | importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}; 18 | initrd_high=0xffffffff 19 | ip_dyn=yes 20 | loadaddr=0x10800000 21 | loadbootenv=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bootenv}; 22 | loadbootfile=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${file_prefix}${bootfile}; 23 | loadbootscript=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script}; 24 | loadfdt=if test ${boottype} = mmc; then load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${file_prefix}${fdt_file}; else ${get_cmd} ${fdt_addr} ${fdt_file}; fi; 25 | mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}; 26 | mmcboot=echo Booting from mmc ...; run mmcargs; setenv boottype mmc; run bootit; 27 | mmcdev=0 28 | mmcpart=1 29 | mmcroot=/dev/mmcblk0p2 rootwait rw 30 | netargs=setenv bootargs console=${console},${baudrate} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp; 31 | netboot=echo Booting from net ...; run netargs; setenv boottype net; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if test ${bootfile} = auto; then setenv bootfile zImage; if ${get_cmd} ${bootfile}; then run bootit; else setenv bootfile uImage; fi; fi; ${get_cmd} ${bootfile}; run bootit; 32 | preboot=usb start 33 | script=boot.scr 34 | splashpos=m,m 35 | stderr=serial,vga 36 | stdin=serial,usbkbd 37 | stdout=serial,vga 38 | update_sd_firmware=if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if mmc dev ${mmcdev}; then if ${get_cmd} ${update_sd_firmware_filename}; then setexpr fw_sz ${filesize} / 0x200; setexpr fw_sz ${fw_sz} + 1; mmc write ${loadaddr} 0x2 ${fw_sz}; fi; fi; 39 | update_sd_firmware_filename=u-boot.imx 40 | -------------------------------------------------------------------------------- /README-custom: -------------------------------------------------------------------------------- 1 | An explanation of the custom U-Boot boot scripts/variables in u-boot.txt 2 | 3 | bootcmd (what the "boot" command executes) run preset, bootset, 4 | bootenv, bootload and bootstart in that order. Note, when 5 | run in a sequence with a single run command, it will abort 6 | if any individual script fails. 7 | 8 | Main boot scripts: 9 | 10 | preset initialize default values. Environment variables take 11 | precedence over shell variables. 12 | 13 | bootset set up the bootenv variable, attempts to load and import 14 | uEnv.txt file, sets some default values and determines the 15 | name of the dtb file based on the (automatically set) cpu 16 | and board variables. 17 | 18 | bootenv this variable is set up in the bootset script, with a possible 19 | override from a uEnv.txt file. It's executed after bootset, 20 | which allows for variable expansion. 21 | 22 | bootload load the kernel or boot script file, optionally loads the 23 | dtb file, sets the correct bootrun value. 24 | 25 | bootstart execute what's in the bootrun variable. 26 | 27 | 28 | 29 | Auxiliary (set-up) scripts, execute with "run