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.

Environment:

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 https://github.com/Lichee-Pi/u-boot.git

  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 https://github.com/Icenowy/sunxi-tools.git
    cd sunxi-tools
    make
    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 https://github.com/Lichee-Pi/linux.git

  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

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

Leave a Reply