Starting Linux directly from AT91bootstrap3

Here is an update for our previous article on booting linux directly from AT91bootstrap. On newer ATMEL platforms, you will have to use AT91bootstrap 3. It now has a convenient way to be configured to boot directly to Linux.

You can check it out from github:

git clone git://

That version of AT91bootstrap is using the same configuration mechanism as the Linux kernel. You will find default configurations, named in the form:

  • board_name can be: at91sam9260ek, at91sam9261ek, at91sam9263ek, at91sam9g10ek, at91sam9g20ek, at91sam9m10g45ek, at91sam9n12ek, at91sam9rlek, at91sam9x5ek, at91sam9xeek or at91sama5d3xek
  • storage can be:
    • df for DataFlash
    • nf for NAND flash
    • sd for SD card
  • our main interest will be in boot_strategy which can be:
    • uboot: start u-boot or any other bootloader
    • linux: boot Linux directly, passing a kernel command line
    • linux_dt: boot Linux directly, using a Device Tree
    • android: boot Linux directly, in an Android configuration

Let’s take for example the latest evaluation boards from ATMEL, the SAMA5D3x-EK. If you are booting from NAND flash:

make at91sama5d3xeknf_linux_dt_defconfig

You’ll end up with a file named at91sama5d3xek-nandflashboot-linux-dt-3.5.4.bin in the binaries/ folder. This is your first stage bootloader. It has the same storage layout as used in the u-boot strategy so you can flash it and it will work.

As a last note, I’ll had that less is not always faster. On our benchmarks, booting the SAMA5D31-EK using AT91bootstrap, then Barebox was faster than just using AT91bootstrap. The main reason is that barebox is actually enabling the caches and decompresses the kernel(see below, the kernel is also enaling the caches before decompressing itself) before booting.

About Alexandre Belloni

Alexandre is an Android, kernel and embedded Linux engineer at Free Electrons, which he joined in 2013. His experience with embedded systems started much earlier! More details...
This entry was posted in Technical and tagged , , , , , . Bookmark the permalink.

4 Responses to Starting Linux directly from AT91bootstrap3

  1. Richard Genoud says:

    I’m looking forward to read those benches on AT91bootstrap+barebox. (or even barebox+barebox !).
    I agree that reading the NAND with Dcache enabled is faster, but the decompression should be the same, at least for uImages (the kernel is uncompressing itself, with D/Icache enabled (cf arch/arm/boot/compressed/), or I missed something…).

    • Indeed, you seem to be right, arch/arm/boot/compressed/head.S activates the caches before decompressing. So the speedup is probably due to having the caches while reading the NAND flash. I’m updating the post.

      Regarding the benches, this is what I get when using barebox to load the kernel (measured with grabserial so not so precise):
      – AT91bootstrap: 1.12s
      – barebox 0.46s
      – kernel: 1.49s
      Total: 3.07s

      Without barebox:
      – AT91bootstrap: 1.70s
      – kernel: 2.24s
      Total: 3.94s

      • Richard Genoud says:

        I don’t really understand why the time used by the kernel is not the same in both cases. (1.49s vs 2.24s)
        It’s the time between:
        “Uncompressing Linux… done, booting the kernel.”
        “Freeing unused kernel memory:”
        right ?
        Anyway, with barebox, you’ve got 1.58s to the start of the kernel, and with at91bootstrap only, 1.70s.
        that’s 120ms less.
        Not bad !
        One question though, is at91bootstrat reading the exact kernel size (modulo one block) or more ?

        • I don’t think you can calculate the way you are doing because, as barebox is decompressing the kernel, you will never get Uncompressing Linux… done, booting the kernel. Instead, you have
          booting Linux kernel with devicetree
          [ 0.000000] Booting Linux on physical CPU 0x0

          While I agree that you can’t really compute the time used by each component by using only grabserial, I really think that the speedup while using barebox is more than 120ms.

          In the default configuration, at91bootstrap is reading 3MB of flash while the kernel I used is 1.7MB. You earn about 110ms by reading less blocks.

Leave a Reply

Your email address will not be published. Required fields are marked *