Hi, It’s quite a while now, and it been ~1 year since I bought Lichee pi nano and tried to upgrade from 16M SPI-NOR flash to QSPI-NAND W25N01GV 128M flash, I f**ked around with U-boot for year to make it boot but I didn’t until 10 days ago (from the time of writing). I can FINALLY make it boot ! YAY!!! but I didn’t stop there. Let get started
Hardware requirement
- Lichee pi nano x1
- W25N01GVZE (WSON-8 package) x1
- Micro SD card, the size at lease 1GB
- USB to UART at 3.3v logic level
U- boot compilation
first you need to install the dependencies software on your PC (next time will be called “Host“). Install followings
swig python-dev python3-dev libncurses5-dev zlib1g-dev gcc-arm-linux-gnueabi libssl-dev
plus other dependencies that I recommended to lookup on google and using keyword like “building uboot” or “install build essential”
Then next you need to git clone my repo from github by using command :
git clone https://github.com/TiNredmc/u-boot.git
after that, lets build the u-boot image
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- licheepi_nano_spinand_defconfig
wait until the “.config” file is created and then : NOTE N is your CPU core number.
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -jN
after compiled, there will be the file name “u-boot-sunxi-with-spl.bin” you need to convert the image into boot-able nand image by running command :
sh f1c100_uboot_spinand.sh uboot_nand.bin u-boot-sunxi-with-spl.bin
There will be output image called “uboot_nand.bin” that you can later flash to the nand.
Linux kernel compilation
TBH, I’m not sure about the dependencies for Host side but you can google up for “Building Linux dependencies”
Now lets clone the repo
git clone https://github.com/TiNredmc/linux.git
Then : NOTE N is your CPU core number. “.config” build configuration file is already in the repo
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -jN
wait and wait… and there will be 2 files you need to grab from
(at the kernel folder)/arch/arm/boot/zImage
(at the kernel folder)/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dtb
we need two of these file before we deploy the rootfs
Kernel command line (In Boot option menu)
console=ttyS0,115200 panic=5 earlyprintk rootwait ubi.mtd=3,2048 root=ubi0:rootfs rw rootfstype=ubifs
Buiding Buildroot
as always, git clone
then BUILD the BUILDROOT !!! : You probably notice the -jN and know what to do ;D
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -jN
after it done copy 2 files(one for SPI-NAND and one for SD card).
(at the buildroot folder)/output/images/rootfs.ubifs
(at the buildroot folder)/output/images/rootfs.tar.gz
Gather all the files into one place
uboot_nand.bin , suniv-f1c100s-licheepi-nano.dtb , zImage and rootfs.ubifs
install sunxi-fel
I won’t go through this step but you can google up
Flash U-boot, Device tree blob and kernel
first you need 2 special u-boot as a flashing tools, They are inside folder of u-boot name “util-images“
First one is “u-boot-usb.bin” this will be used when flashing U-boot and DTB files
The second one is “u-boot-8M-usb.bin” this will be used when file is between 1MiB and 8MiB, In this case it’s zImage.
Before using sunxi-fel command
MAKE SURE THAT YOUR BOARD IS IN FEL MODE
AND ALREADY OPENED THE TTY SERIAL ON LICHEE PI NANO,
AND YOU HAVE TO RELEASE THE SPI CS PIN HOLDING AFTER ENTERED FEL MODE EACH TIME.
U-boot flash command
sunxi-fel -p uboot u-boot-usb.bin write 0x80000000 uboot_nand.img
after that, if you see in the Lichee’s tty serial , the flashing progress will happen automatically. your can type “reset” in the TTY to exit u-boot fel .
DTB flash command
on Host do
sunxi-fel -p uboot u-boot-usb.bin write 0x80000000 suniv-f1c100s-licheepi-nano.dtb
on TTY SERIAL do
PRESS ANY KEY BEFORE COUNTDOWN STOP
>mtd list
>mtd write spi-nand0 0x80000000 0x80000 0x3000
HOLD CS PIN PREPARING TO ENTER FEL MODE
>reset
RELEASE CS PIN HOLDING
zImage flash command
on Host do
sunxi-fel -p uboot u-boot-8M-usb.bin write 0x80000000 zImage
on TTY SERIAL do
PRESS ANY KEY BEFORE COUNTDOWN STOP
>mtd list
>mtd write spi-nand0 0x80000000 0xA0000 0x400000
HOLD CS PIN PREPARING TO ENTER FEL MODE
>reset
RELEASE CS PIN HOLDING
now I recommend you to try booting the nano up, if nothings went wrong, it should boot into kernel and KERNEL PANIC since we haven’t deploy rootfs yet.
Deploy rootfs
at this part is the most trickiest part of all. let start !
- get your micro sd card totally formatted and delete all partition
- create 2 partitions one with first, FAT16 at 16M and the second one EXT4 at all the space left
- grab the u-boot-tf.img and boot.scr from (u-boot folder)/util-images
- run following command on Host ,X is your sd card drive letter like sda sdb….
sudo dd if=/dev/zero of=/dev/sdX bs=1024 seek=8 count=512
sudo dd if=u-boot-tf.img of=/dev/sdX bs=1024 seek=8
Next is to copy boot.scr suniv-f1c100s-licheepi-nano.dtb and zImage to the FAT16 partition.
Now we gonna deploy the rootfs onto sd card and will later on our pi nano ❤
- mount the Ext4 partition somewhere, assuming at /mnt/sdroot
- on Host run
sudo tar xzvf rootfs.tar.gz -C /mnt/sdroot
sudo cp rootfs.ubifs /mnt/sdroot/root
after that, put sd card into the lichee pi nano, power it up and wait until login prompt on TTY SERIAL
Username and password are “root“
inside the TTY SERIAL type
ubiformat /dev/mtd3
ubiattach -p /dev/mtd3
ubimkvol /dev/ubi0 -N rootfs -s 100MiB
ubiupdatevol /dev/ubi0_0 rootfs.ubifs
after that, you can disconnect lichee pi nano from power, remove sd card and boot up the nano again and Voila ! Lichee Pi Nano with W25N01GV NAND chip.