Friday, October 10, 2014

Mainline U-Boot for RIoTBoard

Well, the days when there was no mainline U-Boot support for RIoTBoard are behind us. The official board support was added with v2014.07. Here are my notes for how to get the latest bootloader for your RIoTBoard, just make sure you have a working ARM cross-compiler.

wget ftp://ftp.denx.de/pub/u-boot/u-boot-2014.10.tar.bz2
tar xf u-boot-2014.10.tar.bz2 && cd u-boot-2014.10
make distclean && make riotboard_defconfig && make u-boot.imx -j4

You can load u-boot.imx on the board either via USB OTG port (by using Freescale's MFGTool or Boundary Devices's imx_usb_boot), just configure the on-board micro-switches for USB OTG boot, as described here.

Otherwise you can flash the new bootloader to your non-volatile boot memory (spi nor, sdcard, raw/managed nand, etc). I prefer to test new bootloaders via USB.

10 comments:

  1. After I have created the kernel as you suggested (with the difference that I cross-compiled it on another sytem) and have created an sd card image with u-boot (2014.10), kernel (3.19) and rootfs (minimal debian) I am trying to boot the board.

    Unfortuneatly am getting stuck at starting the kernel ? Do you have a suggestion maybe ?

    It looks like the kernel cannot find the rootfs or the dtb file?

    This how I start the boot process in u-boot:


    setenv bootargs $bootargs rootwait root=/dev/mmcblk0p1
    mmc dev 0
    ext2load mmc 0 10800000 /boot/uImage
    bootm 10800000

    This is the output of u-boot after this:

    ## Booting kernel from Legacy Image at 10800000 ...

    Image Name: Linux-3.19.0
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 5583856 Bytes = 5.3 MiB
    Load Address: 10008000
    Entry Point: 10008000

    Verifying Checksum ... OK
    Loading Kernel Image ... OK

    Starting kernel ...


    ReplyDelete
  2. Ok I found it out myself. One needs to also load the device tree blob ... How does oneone now the adresses under which they are located???
    Mainline bootloader expects the kernel on 12000000 and dtb on 18000000.


    setenv bootargs $bootargs rootwait root=/dev/mmcblk0p1
    mmc dev 0
    ext2load mmc 0 16800000 /boot/uImage
    bootm 10800000 - 16800000

    ReplyDelete
  3. setenv bootargs $bootargs rootwait root=/dev/mmcblk0p1
    mmc dev 0
    ext2load mmc 0 16800000 /boot/uImage
    ext2load mmc 0 16800000 /boot/imx6dl-riotboard.dtb
    bootm 10800000 - 16800000

    ReplyDelete
  4. I mean
    ext2load mmc 0 10800000 /boot/uImage
    of course

    ReplyDelete
  5. Hi Michael. The kernel is not supposed to find the DTB and rootfs. The bootloader is responsible to load the DTB and pass it to the kernel, and rootfs is usually configured by bootargs.

    If your board's kernel boots, but there are no boot messages after "Starting kernel..." there are 4 possible reasons:
    1. You haven't loaded device tree, so your kernel's serial console driver is not configured
    2. Your serial console port is not configured in the device tree
    3. Your serial port is not passed to the kernel via bootargs
    3. You have some serious issues with your kernel port

    Also, the mainline kernel doesn't expect the load address and device tree addresses to be specific ones - you can load them wherever you want, and the bootloader will pass the appropriate info to the kernel, which will in all cases relocate itself. I usually boot my machines (imx6solo, imx6dual, imx6quad) with "bootm 12000000 - 13000000" and it works both for Freescale and mainline kernels, so don't worry about these addresses, as long as they're in your physical address space (starting at 0x10000000).

    ReplyDelete
  6. These errors appear after the last step, what can be the reason?

    scripts/kconfig/conf --silentoldconfig Kconfig
    CHK include/config.h
    UPD include/config.h
    GEN include/autoconf.mk
    GEN include/autoconf.mk.dep
    cc1: error: bad value (armv5) for -march= switch
    cc1: error: bad value (armv5) for -march= switch
    make[2]: *** [include/autoconf.mk] Error 1
    make[2]: *** Waiting for unfinished jobs....
    make[2]: *** [include/autoconf.mk.dep] Error 1
    make[1]: *** [silentoldconfig] Error 1
    make: *** No rule to make target `include/config/auto.conf', needed by `include/config/uboot.release'. Stop.

    Thanks.

    ReplyDelete
    Replies
    1. Hi Aniruddha. It would be great if you have posted more details about what you're trying to do (like complete list of executed commands, U-Boot version, etc). Without this info the only wrong thing I see is the usage of armv5 compiler, which means that probably you're using a wrong defconfig, as the riotboard defconfig works fine without such issues.

      Delete
  7. Thanks PicMaster for commenting. I am trying to build u-boot for i.MX6solo RIOT Board. and the commands posted above was just a beginning. After I was going to build kernel and file system and was going to flash onto the on board memory using SD card..Simple! and secondly how to check whether I have correct cross compiler running? I have downloaded a lot of cross compilers including fsl-lnaro-toolchain but I dont know whether I am using that or not. Can this be a reason?
    Thanks.

    ReplyDelete
  8. Hi Aniruddha. The fastest way to get a cross-compiled image for riotboard is to try the latest Buildroot. Here are instructions how to do that: http://risc-a-day.blogspot.com/2015/03/buildroot-for-riotboard.html. The whole process takes 15min from start to finish on my build machine. Also the Buildroot build scripts automatically build a cross-compiler, so you won't have to deal with it.

    Another opportunity to build a Linux image for riotboard is to use the latest Yocto Linux. Here's more info about how to do it: http://risc-a-day.blogspot.com/2015/05/building-yocto-18-fido-for-imx6.html. Just change the machine name to imx6dl-riotboard.

    ReplyDelete
  9. Thank you PicMaster, that worked.

    ReplyDelete