Boot scripts for main-line U-Boot on i.MX6

As discussed in yesterday’s post on upgrading (and downgrading) U-Boot to the latest version, we’re changing the name of the boot script from 6q_bootscript to 6x_bootscript to reflect the syntax changes between the two and to allow userspace images to continue to operate with either version in the near term. In this post, we’ll walk through the structure of the new boot scripts, which have auto-configuration of displays as discussed in in this post. We’ll also provide sample source and binaries for both Android and non-Android Linux userspaces.

Boot script review

To recap a lot of other posts, boot scripts provide a very flexible means of setting up the environment for a particular Operating system. For Linux-based systems, this generally involves four steps:

  1. Load the kernel,
  2. Optionally load a RAM disk image,
  3. Configure bootargs (the kernel command-line), and
  4. Launch the kernel
Each of these steps have distribution-specific tweaks. For example, Android wants command-line arguments for things like androidboot.console and calibration. Ubuntu and Debian systems often use a flag like fixrtc to prevent extraneous filesystem checks.

Boot scripts are essentially text files with a 64-byte header that contains a checksum of the content.

There’s an on-line tool to compile a boot script on this page.

Auto-configuration of displays

Configuration of displays under Linux on i.MX6 involves mostly adding a set of “video=” clauses to the kernel command-line, but for high-resolution displays, the “fbmem=” clause is also needed.

The following code snippet will be included in all of the 6x_bootscript sources that we’ll use to set these variables.
setenv nextcon 0;
if hdmidet ; then
	setenv bootargs $bootargs video=mxcfb${nextcon}:dev=hdmi,1280x720M@60,if=RGB24
	setenv fbcon "fbcon=28M";
	setexpr nextcon $nextcon + 1
	echo "------ no HDMI monitor";

i2c dev 2
if i2c probe 0x04 ; then
	setenv bootargs $bootargs video=mxcfb${nextcon}:dev=ldb,LDB-XGA,if=RGB666
	if test "0" -eq $nextcon; then
		setenv fbcon "fbcon=10M";
		setenv fbcon ${fbcon},10M
	setexpr nextcon $nextcon + 1
	echo "------ no Freescale display";

if i2c probe 0x38 ; then
	setenv bootargs $bootargs video=mxcfb${nextcon}:dev=ldb,1024x600M@60,if=RGB666
	if test "0" -eq $nextcon; then
		setenv fbcon "fbcon=10M";
		setenv fbcon ${fbcon},10M
	setexpr nextcon $nextcon + 1
	echo "------ no 1024x600 display";

if i2c probe 0x48 ; then
	setenv bootargs $bootargs video=mxcfb${nextcon}:dev=lcd,CLAA-WVGA,if=RGB666
	if test "0" -eq $nextcon; then
		setenv fbcon "fbcon=10M";
		setenv fbcon ${fbcon},10M
	setexpr nextcon $nextcon + 1
	echo "------ no 800x480 display";

while test "3" -ne $nextcon ; do
	setenv bootargs $bootargs video=mxcfb${nextcon}:off ;
	setexpr nextcon $nextcon + 1 ;
This is a lot of script, but has a pretty simple form. As discussed in the post on auto-configuration, we’re making use of the hdmidetect and i2c detect commands to determine whether an HDMI monitor or set of touch screen controllers is connected to the system.

The ordering of the display detection code is from highest resolution to lowest resolution, and if multiple are connected, the first will be the primary display.

At the tail end of the script, a while loop will explicitly turn off all remaining displays because the Linux kernel will otherwise default to enabling a 1024x768 display.

Reference boot scripts

The following is a list of reference boot scripts. In order to use each, you’ll need to rename the binary file to /6x_bootscript on the first partition of your bootable media.

Operating systemSourceBinaryDetails
Android android-bootscript-20121110.txt android-bootscript-20121110 Loads /uImage and /uramdisk.img.
Non-Android Linux 6x_bootscript-20121110.txt 6x_bootscript-20121110 Sets root=/dev/mmcblk0p1 (the first partition of the first SD card)
All 6x_upgrade-20121111.txt 6x_upgrade-20121111 Validates U-Boot in SPI-NOR from /u-boot.imx or //u-boot.nopadding.

Updated images

If you don’t already have an SD card image for your platform, we’ve updated the following images to contain 6x_bootscript:

To-do list

We’re in the process of cleaning up our patch set and re-basing on the latest main-line code base. As soon as this is done, we’ll publish a new branch of source code in the production branch of this project on GitHub:

We’ll also create a blog post with instructions on how to get and compile the image.

If you’re in a hurry, you can look at the nit6x-prerelease branch.


33 Responses to “Boot scripts for main-line U-Boot on i.MX6”

  1. Marcin December 26, 2012 8:36 pm #

    1) Is this script compatible with non Freescale LCDs? Lot of LCD out there do not have control port (I2C) just the RGB, sync and DE. How does this script handle such displays. It seems that only very specific displays are listed in the 4 possible options.
    2) is it possible to deactivate the new display auto-detect option? The “old way” using bootargs worked just fine with my display Newheaven 5.0″ RGB 800×480 24bit with cap touch.


    • ericn December 27, 2012 7:48 am #

      Hi Marcin,

      Yes. It’s possible to deactivate the auto-detect. It simply involves editing the boot script to do what you want to do.

      Here’s an example of a boot script without auto-detect that hard-codes things for an 800×480 display:

      setenv bootargs enable_wait_mode=off
      setenv bootargs $bootargs video=mxcfb0:dev=lcd,CLAA-WVGA,if=RGB666
      setenv bootargs $bootargs video=mxcfb1:off video=mxcfb2:off
      setenv bootargs $bootargs fbmem=10M
      setenv bootargs $bootargs console=ttymxc1,115200 vmalloc=400M root=/dev/mmcblk0p1 rootwait consoleblank=0 ;
      ${fs}load mmc ${disk}:1 10800000 /boot/uImage && bootm 10800000 ; echo "Error loading kernel image"

      You can use the tool at to compile it for you, or you can use a local mkimage install like so:

      ~/$ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot script" \
          -d 6x_bootscript-800x480.txt 6x_bootscript-800x480
  2. Andrew June 14, 2013 6:11 pm #

    If I want to add a particular resolution (320×240) along with all the timings (hsync, vsync, left margin, right margin, etc) which file should I edit/add them to? The board-mx6q_sabrelite.c doesn’t contain any of the fb_videomode structs. Thanks

    • ericn June 15, 2013 8:19 am #

      Hi Andrew,

      If the display is an LVDS panel, you’ll want to add it into drivers/video/mxc/ldb.c as shown in this patch.

      If it’s a parallel display, the file is drivers/video/mxc/mxc_lcdif.c as shown here.

      • Mark June 17, 2013 2:14 pm #

        Hey Eric, looks like your two examples point to the same patch (drivers/video/mxc/ldb.c). I’ve been working with mxc_lcdif.c and not having much luck. Is the patch/change similar to the one for ldb.c? Just add timings to the fb_videomode array?

        • ericn June 17, 2013 2:26 pm #

          So many paste buffers, so little swap space…

          I fixed the link above, and “yes”. All you should have to do is add an entry with your particulars into the table, and change your kernel command-line to include the name.

          So if you add a display named mypanel into the lcdif_modedb array, you can use it by setting this value into bootargs under U-Boot:

  3. Andrew June 17, 2013 9:35 pm #

    Hey Eric, where is the place where I can modify the I2C commands for configuring the display for a new lcd (320×240) that I am adding?

    • ericn June 18, 2013 6:17 am #

      Hi Andrew,

      There are two parts to this.

      • The file nitrogen6x.c contains an array named displays that has the list of supported displays compiled into U-Boot. This is used to define displays supported by U-Boot itself.
      • The file 6x_bootscript.txt contains detection code for configuring bootargs in preparation for launching Linux.
  4. Florian October 15, 2013 4:24 am #


    Is it also possible to add the display settings by adding some env to the Kernel command line like in this example?

  5. diveboatslave November 7, 2013 1:43 am #

    The online tool for compiling boot scripts seems to have gone…

    • ericn November 7, 2013 7:16 am #

      Sorry about that. We switched internet providers and need to update…

  6. P. Stvast November 26, 2013 7:00 am #

    Is there a downloadable version of the compile tool?

    • ericn November 26, 2013 7:09 am #

      On Debian and Ubuntu distributions, this is available as package uboot-mkimage and/or u-boot-tools.

      I have this snippet in my .bashrc file:

      bootscript() { if [ 2 -gt $# ] ; then \
                          echo "usage $0 infile.txt outfile" ; \
                     else \
                          mkimage -A arm -O linux -T script -C none \
                               -a 0 -e 0 -n "boot script" -d $1 $2 ; \
                     fi }

      With this, you can run bootscript as a command like so:

      ~/$ bootscript 6x_bootscript.txt 6x_bootscript
      • P. Stvast November 26, 2013 7:33 am #

        Thanks, this is what I needed.

        The package is ‘uboot-tools’ in fedora for others who are interested.

  7. rob mcpherson January 28, 2014 4:51 pm #


    I tried to follow this post to create a new bootscript for our nitrogen6x board to support a 1024×768 display on lvds. I compiled it using your tool, but it just runs to the u-boot prompt without running the boot script.

    here is what I compiled:

    setenv bootargs enable_wait_mode=off
    setenv nextcon 0
    setenv bootargs $bootargs console=ttymxc1,115200 vmalloc-400M consoleblank=0
    setenv bootargs $bootargs video=mxcfb0:dev=ldb,1024x768@60,RGB24
    setenv fbcon "fbcon=10M"
    setenv bootargs $bootargs fbcon=$fbcon
    ${fs}load ${dtype} ${disk}:1 10800000 uImage && ${fs}load ${dtype} ${disk}:1 12800000 uramdisk.img && bootm 10800000 12800000

    Any help or direction would be appreciated.


    • ericn January 28, 2014 5:17 pm #

      Hi Rob,

      This looks mostly right except:

      The fbcon=10M should be fbmem=10M. This was an old bug of mine that was lingering in the U-Boot tree. That shouldn’t prevent launching the kernel.

      The &&amp statements showed up in your post as & (HTML encoded). This should simply be double ampersands. This would generate a syntax error from U-Boot. Can you post the output from a boot attempt?

      The other thing I notice also stems from your use of either the Android boot script above or the one in the U-Boot tree is that you’re missing some bits that are required in the JB 4.3 release. We added code to allow booting to SATA or either SD card and you’re going to need this.

      Finally, you’re also missing video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off clauses. Without these, you’ll get a second display without knowing it (and it will eat memory bandwidth if nothing else).

      The simplest way to achieve what you’re after is to start with the file in device/boundary/nitrogen6x/ and remove the tests for displays that you don’t need, and change the 1024×768 display to 24bpp.

      I did just that and uploaded the content to our Cloud storage here: 6x_bootscript_jb-ldb-1024x768x24.txt.

  8. rob mcpherson January 29, 2014 1:11 pm #


    I used your script, with some minor modifications:

    setenv bootargs enable_wait_mode=off
    setenv nextcon 0;
    setenv bootargs $bootargs console=ttymxc1,115200 vmalloc=400M consoleblank=0 ;
    setenv bootpart 1
    setexpr rval *0x020CC068 \& 0x180
    if itest.s "x$rval" -eq "x100"; then
    	echo "----------- run fastboot here";
    	if itest.s "x$rval" -eq "x80"; then
    		setenv bootpart 2;
    mw.l 0x020cc068 0 1
    if test -n "$tempfuse" ; then
    	setenv bootargs $bootargs thermal.fuse_override=$tempfuse
    setenv bootargs $bootargs video=mxcfb${nextcon}:dev=ldb,bpp=32,1024x768,if=RGB666
    if test "0" -eq $nextcon; then
        setenv fbmem "fbmem=20M";
        setenv fbmem ${fbmem},20M
    setexpr nextcon $nextcon + 1
    while test "4" -ne $nextcon ; do
    	setenv bootargs $bootargs video=mxcfb${nextcon}:off ;
    	setexpr nextcon $nextcon + 1 ;
    setenv bootargs $bootargs $fbmem androidboot.hardware=freescale
    if itest.s "xsata" == "x$dtype" ; then
    elif itest.s "xusb" == "x$dtype" ; then
    elif itest.s "xmmc" == "x$dtype" ; then
        if itest 1 == ${disk}; then
    setenv bootargs $bootargs androidboot.bootdev=$bootdev
    ${fs}load ${dtype} ${disk}:$bootpart 10800000 uImage && ${fs}load ${dtype} ${disk}:$bootpart 12800000 uramdisk.img && bootm 10800000 12800000
    echo "Error loading kernel image"

    This boots fine, except there is a visible line on the screen at the 1024×600 boundary. What do I need to do to remove this line? Is that a u-boot issue?


    • ericn January 29, 2014 1:40 pm #

      Hi Rob,

      Can you confirm the content of the kernel command-line (cat /proc/cmdline)?

      If that properly got your video clause (video=mxcfb0:dev=ldb,bpp=32,1024x768,if=RGB666 with mxcfb1-3 set to off), then we’re past the boot script and the question is what’s up with the display.

      If you use dd, you can fill the screen buffer like so:

      # dd if=/dev/urandom of=/dev/graphics/fb0

      This will tell us whether the problem you’re seeing is with the content of the frame buffer, or the settings you’re using for your panel.

      Finally, I notice that this says if=RGB666, while your previous attempt said if=RGB24. Do the colors look right?

  9. Felipe Tonello February 24, 2014 7:06 pm #

    Hi Eric,

    I have a SABRE Lite board with two displays: Nit6X_10.1Hannstar and Nit6X_1024x600. Also I have dd’ed a sd card with the latest Android 4.3 version from you guys. This image works fine with the HDMI display but it doesn’ t show any thing with the other two touch screen displays I mentioned above.

    Is there anything or instructions I have to follow?


    Felipe Tonello

    • ericn February 24, 2014 7:15 pm #

      Hello Felipe,

      These displays should be detected automatically by the boot script and also by U-Boot if they’re connected properly. I notice that we don’t seem to have photos of the connections on the product page, and I’ll fix that tomorrow. The cable end that connects to the SABRE Lite has two connectors: one for the LVDS signals and another with the I2C connections.

      Detection happens through the I2C connector (6-pin Molex) on J7.

      Can you forward the output of the serial console for a boot with no SD card inserted? This will tell us whether the screen(s) are being detected properly.

      • Felipe Tonello February 24, 2014 7:21 pm #

        Hi Eric,

        I think I’m connecting them properly. Anyway, this is the output from U-Boot when the Nit6X_10.1Hannstar (10.1″ 1024×768 LVDS) display is connected.

        U-Boot 2013.07-00047-gaf468ad (Aug 26 2013 – 09:35:41)

        CPU: Freescale i.MX6Q rev1.2 at 792 MHz
        Reset cause: POR
        Board: SABRE Lite
        DRAM: 1 GiB
        MMC: FSL_SDHC: 0, FSL_SDHC: 1
        SF: Detected SST25VF016B with page size 4 KiB, total 2 MiB
        *** Warning – bad CRC, using default environment

        auto-detected panel wsvga-lvds
        Display: wsvga-lvds (1024×600)
        In: serial
        Out: serial
        Err: serial
        Net: using phy at 6
        FEC [PRIME]
        Hit any key to stop autoboot: 0
        AHCI 0001.0300 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
        flags: ncq stag pm led clo only pmp pio slum part
        No port device detected!
        ** Bad device size – sata 0 **
        ** Bad device size – sata 0 **

        SATA device 1: unknown device
        ** Bad device sata 1 **
        ** Bad device sata 1 **
        MMC: no card present
        mmc0(part 0) is current device
        MMC: no card present
        ** Bad device mmc 0 **
        MMC: no card present
        ** Bad device mmc 0 **
        MMC: no card present
        mmc1(part 0) is current device
        MMC: no card present
        ** Bad device mmc 1 **
        MMC: no card present
        ** Bad device mmc 1 **

        6x_bootscript not found

        serial console at 115200, 8N1

        details at
        (Re)start USB…
        USB0: USB EHCI 1.00
        scanning bus 0 for devices… 2 USB Device(s) found
        scanning usb for storage devices… 0 Storage Device(s) found
        scanning usb for ethernet devices… 0 Ethernet Device(s) found
        U-Boot >

        • ericn February 24, 2014 7:26 pm #

          Hi Felipe,

          This bit of output says that the 1024×600 display is being detected…

          auto-detected panel wsvga-lvds
          Display: wsvga-lvds (1024×600)

          Do you see output on the display?

          • Felipe Tonello February 24, 2014 7:30 pm

            Hi Eric,

            Exactly. No I don’t see any output.

            When I put the Nit6X_1024x600 I see a messed up output on the display. But only the U-Boot output. Then when it boots up the kernel it becomes black. But at least the backlight is on.

            I will try to build an image tomorrow using the yocto based image to see if I get to see something.

          • ericn February 24, 2014 7:52 pm

            Okay, but your output should not be “messed up” in U-Boot, so Yocto isn’t going to fix things.

            The clocking isn’t 100% accurate in U-Boot, but shouldn’t yield obviously wrong images.

          • Felipe Tonello February 25, 2014 1:23 pm

            I will update the u-boot and see what happens.

            BTW, I tried the displays on other SABRE Lite that we have and it works.

  10. Pensiuni Siriu June 19, 2014 12:36 am #

    Cazare Praid

    It is really a nice and helpful piece of information. I’m
    happy that you just shared this useful info with us. Please stay us informed like this.
    Thank you for sharing.

  11. August 31, 2014 11:01 pm #

    Hi there,
    I am successful to boot from ram now. But become curious about the possibility to boot from on-board flash.
    I assume that SabreLite has 2MB SPI flash. Is that all? Are there any other resources that we can use?
    And most difficult thing should be place the boot script somewhere in the flash. Is it possible to do so in uboot?
    Thanks a lot!

  12. sonnguyen512 October 26, 2014 7:10 pm #

    Hi All,

    How can I download 6x_bootscript for Linux on the link above( The error below appeared when I clicked to that link:

    “This XML file does not appear to have any style information associated with it. The document tree is shown below.

    The specified key does not exist.

    • ericn October 27, 2014 6:03 am #

      We’ve begun shipping a 6q_upgrade script with each of our U-Boot releases, so everything you need is in the latest U-Boot tar-ball.

Leave a Reply