Allwinner V3s u-boot Compilation & SPI NOR boot

V3s Boot Process:

The first step of booting is an internal 32KB boot ROM(BROM). This is a common practice among ARM processors in order to eliminate external parallel NOR Flash. The BROM would try to load program from external storage (SD/MMC, then SPI NOR, last SPI NAND). This program is called boot0 by Allwinner, but specifically SPL here. If the BROM failed to load this program, it would enter USB boot operation.
The second step is the SPL. The SPL is actually a minimal u-boot with few specific tasks. The SPL would be loaded into V3s’ internal SRAM, and the SPL would do the following things:

  • Initialize Clock/UART/DRAM and boot device (SD/MMC/SPI Flash)
  • Copy the full u-boot from boot device to DRAM
  • Jump to the full u-boot.

The third step is the u-boot, which would load the kernel.


OS: Ubuntu MATE 17.04

Board: Lichee Pi Zero (Allwinner V3s, with W25X64 SPI NOR)

Uboot Compilation

  1. Install tools:

    apt-get install build-essential libncurses5-dev u-boot-tools debootstrap git binfmt-support libusb-1.0-0-dev pkg-config device-tree-compiler
    apt-get install gcc-arm-linux-gnueabihf

  2. Download uboot source code:

    git clone -b v3s-spi-experimental

  3. Compile

    cd u-boot
    make distclean CROSS_COMPILE=arm-linux-gnueabihf-
    make CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_config
    make CROSS_COMPILE=arm-linux-gnueabihf-

Write u-boot image

  1. Install Icesnowy’s sunxi-tools fork

    git -b spi-rebase clone
    cd sunxi-tools
    sudo make install

  2. Enter FEL mode. This can be done by using a FEL-boot SD card. To make one, write the image in sunxi-tools/bin to a SD card:

    dd if=fel-sdboot.sunxi of=/dev/mmcblk0 bs=1024 seek=8

  3. Check SPI Flash information:

    sudo sunxi-fel spiflash-info

    You should be able to see things like “Manufacturer: Winbond (EFh), model: 40h, size 8388608 bytes”.

  4. Write u-boot image

    sudo sunxi-fel spiflash-write 0 ../u-boot/u-boot-sunxi-with-spl.bin

Compile Linux Kernel

  1. Download source code

    git -b zero-4.10.y clone

  2. Config the kernel

    cd linux
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- licheepi_zero_defconfig
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

  3. Build the kernel image

    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16

3 thoughts on “Allwinner V3s u-boot Compilation & SPI NOR boot

  1. Gaston

    Hi great tutorial. Trying to find information about V3s I read this tutorial. Im really new in the embedded world and I wanna try with the V3s (everybody says the software is a mess!! and that only use ubuntu..). Im using Opensuse TW and already have buildroot2018, but I really dont know what toolchain to use (arm-cross or Linaro in opensuse). Also a few questions:
    1) How to start from scratch (not use a defconfig by default instead use my own config)
    2) The sunxi tools needs to be build too?
    3) the step are:
    a) build u-boot
    b)build kernel
    c)build sunxi tools and then make the sd card boot?
    Thanks for your help

Leave a Reply