Giter Site home page Giter Site logo

licheerv-boot-build's Introduction

Sipeed LicheeRV - Nezha CM C906 building boots

Alternate to official instruction small BSP building.

The current official guide seems very uncomfortable :

  • some software PhoenixCard (Windows) is need and it works crappy
  • minimum size for sdcard is 16G
  • large SDK >10G which is required to download from mega

so we ended up with alternate one.

Thanks to Samuel Holland [email protected] to make this thing easy.

Contents

  • boot0 : zsbl (zero stage boot loader) that is used instead of u-boot SPL temporary
  • opensbi : mostly mainline with small changes for Allwinner D1
  • u-boot : very hacked but really better than official one
  • linux : a solid work on the top of v5.15 (almost the most recent)
  • riscv-gnu-toolchain : linux toolchain (currently used, can be replaced with Xuantie toolchain)

I've disabled emac and spi-nand in separate dts currently, they are no harm but still useless for LicheeRV RV Dock and pure LicheeRV, for 86 Panel a modification is also required, so we use sun20i-d1-nezha-lichee.dts instead of sun20i-d1-nezha.dts for now.

Build

Install the prerequisites for the riscv-gnu-toolchain:

https://github.com/riscv-collab/riscv-gnu-toolchain/tree/f640044a947afb39c78b96fa1ba1db8aa31b1d89#prerequisites

You don't have to do any other steps except the prerequisites.

Install additional prerequisites (may be required for fresh Ubuntu installation, thanks to Alexander Fomichev for sharing this):

apt install python3-distutils swig python3-dev libssl-dev python3-pkg-resources cpio

Fetch all submodules:

$ git submodule update --init --recursive

Bundled toochain:

$ make

External toochain

Either provide TARGET_CROSS_PREFIX:

$ TARGET_CROSS_PREFIX=riscv64-unknown-linux-gnu make

Or simply nail it down in Makefile before ifndef TARGET_CROSS_PREFIX:

TARGET_CROSS_PREFIX=riscv64-unknown-linux-gnu

ifndef TARGET_CROSS_PREFIX
TARGET_CROSS_PREFIX = ${TOOLCHAIN_PREFIX}/bin/${TARGET_CROSS}
EXTERNAL_CROSS = 0
else
TARGET_CROSS_PATH := $(shell dirname $$(which $${TARGET_CROSS_PREFIX}-gcc))
TARGET_CROSS_PREFIX := ${TARGET_CROSS_PATH}/${TARGET_CROSS_PREFIX}
EXTERNAL_CROSS = 1
endif

$ make

Quick deploy

After make we will need the following files:

  • sun20i_d1_spl/nboot/boot0_sdcard_sun20iw1p1.bin
  • u-boot.toc1
  • u-boot/arch/riscv/dts/sun20i-d1-lichee-rv-dock.dtb
  • build-linux/arch/riscv/boot/Image.gz
  • initramfs.img.gz

I use dtb for Lichee RV Dock currently if you require something different edit toc1/toc1.cfg accordingly.

Example of making a card (assuming card is /dev/sdd and empty) :

# parted /dev/sdd --script mklabel gpt
# parted /dev/sdd --script mkpart primary ext2 40MiB 100MiB
# parted /dev/sdd --script mkpart primary ext4 100MiB 100%
# mkfs.ext2 /dev/sdd1 # partion with kernel, dtb, initramfs
# mkfs.ext4 /dev/sdd2 # partition for rootfs 
# mount /dev/sdd1 /mnt/sdcard/
# cp build-linux/arch/riscv/boot/Image.gz /mnt/sdcard/
# cp initramfs.img.gz /mnt/sdcard/
# umount /mnt/sdcard
# dd if=sun20i_d1_spl/nboot/boot0_sdcard_sun20iw1p1.bin of=/dev/sdd bs=8192 seek=16
# dd if=u-boot.toc1 of=/dev/sdd bs=512 seek=32800 # large offset thats why we make first partion on 40 MiB

We are not using dtb from u-boot or linux kernel, as boot0 patches dtb with DRAM size and location, so we should use dtb patched - located at fdtcontroladdr.

U-Boot boot commands

U-boot commands (i haven't put a u-boot env yet - have to decide what i really need) :

initramfs

> load mmc 0:1 ${kernel_addr_r} Image.gz
> load mmc 0:1 ${ramdisk_addr_r} initramfs.img.gz
> setenv bootargs "earlycon=sbi console=ttyS0,115200n8 root=/dev/ram0 rw rdinit=/init"
> booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdtcontroladdr}

rootfs placed on mmc second partion

> load mmc 0:1 ${kernel_addr_r} Image.gz
> setenv bootargs "earlycon=sbi console=ttyS0,115200n8 root=/dev/mmcblk0p2"
> booti ${kernel_addr_r} - ${fdtcontroladdr}

Enjoy!

Sunxi maillist

Bibliography

licheerv-boot-build's People

Contributors

maquefel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

licheerv-boot-build's Issues

Compile error busybox/include/platform.h:168:11: fatal error: byteswap.h: No such file or directory

Not compile on Archlinux:

make
...
make -f /data/projects/licheeRV/licheerv-boot-build/busybox/scripts/Makefile.build obj=scripts
  /data/projects/licheeRV/licheerv-boot-build/toolchain/riscv64-unknown-linux-gnu/bin/riscv64-unknown-linux-gnu-gcc -Wp,-MD,applets/.applets.o.d  -std=gnu99 -Iinclude -Ilibbb -Iinclude2 -I/data/projects/licheeRV/licheerv-boot-build/busybox/include -I/data/projects/licheeRV/licheerv-boot-build/busybox/libbb -include include/autoconf.h -D_GNU_SOURCE -DNDEBUG -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DBB_VER='"1.34.0"' -I/data/projects/licheeRV/licheerv-boot-build/busybox/applets -Iapplets -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wno-format-security -Wdeclaration-after-statement -Wold-style-definition -finline-limit=0 -fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-builtin-printf -Os  -DKBUILD_BASENAME='"applets"'  -DKBUILD_MODNAME='"applets"' -c -o applets/applets.o /data/projects/licheeRV/licheerv-boot-build/busybox/applets/applets.c
In file included from /data/projects/licheeRV/licheerv-boot-build/busybox/include/libbb.h:13,
                 from /data/projects/licheeRV/licheerv-boot-build/busybox/include/busybox.h:8,
                 from /data/projects/licheeRV/licheerv-boot-build/busybox/applets/applets.c:9:
/data/projects/licheeRV/licheerv-boot-build/busybox/include/platform.h:168:11: fatal error: byteswap.h: No such file or directory
  168 | # include <byteswap.h>
      |           ^~~~~~~~~~~~
compilation terminated.

make: *** [Makefile:55: riscv64-unknown-linux-gnu-gcc] Error 2

After installing flex, bison and gawk, I was able to start TARGET_CROSS_PREFIX=riscv64-unknown-linux-gnu make

which led to:

configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
make[3]: Leaving directory '/home/sander/git/licheerv-boot-build/riscv-gnu-toolchain/build-gdb-linux'
make[2]: *** [Makefile:854: all] Error 2
make[2]: Leaving directory '/home/sander/git/licheerv-boot-build/riscv-gnu-toolchain/build-gdb-linux'
make[1]: *** [Makefile:281: stamps/build-gdb-linux] Error 2
make[1]: Leaving directory '/home/sander/git/licheerv-boot-build/riscv-gnu-toolchain'
make: *** [Makefile:55: riscv64-unknown-linux-gnu-gcc] Error 2

When I google that last line, it looks like I have to install the toolchain, or put it in the path? Isn't that a Baron-von-Munchausen, as AFAIK the process is making the toolchain ... ?

dm9601 resp rtl8150 included in busybox?

I have two (old) fixed-ethernet-usb-adapter, which work on Ubuntu on my laptop, with the drivers dm9601 resp rtl8150.

Does the output below mean those drivers are included in your busybox? Or is that just the linux source, and do I have to go into makemenuconfig (or what is is called) to include them?

sander@brixit:~/git/licheerv-boot-build$ find . | grep -e rtl8150 -e dm9601
./linux/drivers/net/usb/rtl8150.c
./linux/drivers/net/usb/dm9601.c

how to install and use "u-boot" on Ubuntu?

the README says "U-boot commands (i haven't put a u-boot env yet - have to decide what i really need)".

How should I install and start u-boot on Ubuntu? I installed

u-boot-tools
u-boot-menu

but they don't provide a uboot nor u-boot executable?

typo, and more git problems

(On Ubuntu 20.04)

First git clone https://github.com/maquefel/licheerv-boot-build.git.

Then, following the instruction:

sander@brixit:~/git/licheerv-boot-build$ git submodules update --init --recursive
git: 'submodules' is not a git command. See 'git --help'.

The most similar command is
        submodule
sander@brixit:~/git/licheerv-boot-build$

Following that advice:

sander@brixit:~/git/licheerv-boot-build$ git submodule update --init --recursive
Submodule 'busybox' (git://git.busybox.net/busybox) registered for path 'busybox'
fatal: No url found for submodule path 'klibc' in .gitmodules

Tips? Should I use another command? Or ... ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.