Patches & Script for AOSP to run on Xuantie RISC-V CPU

Overview

aosp.gif Graph 1. AOSP on RISC-V 64(XuanTie 910)

Video for Android on XuanTie910

News and related resources

Chip

ICE is a XuanTie C910 based high performance SoC board developed by T-Head. The ICE SoC has integrated 3 XuanTie C910 cores (RISC-V 64) and 1 GPU core; featuring speed and intelligence with a high cost-effective ratio. The chip can provide [email protected] HEVC/AVC/JPEG decoding ability, and varieties of high-speed interfaces and peripherals for controlling and data exchange; suits for 3D graphics, visual AI and multimedia processing.

ice.jpg

Graph 2. ICE chip

For more information about XuanTie 910 CPU core IP, please check: XuanTie C910 introduction

Board

RVB-ICE is development board based on ICE. It is equipped with 7-inch LCD touch screen, integrates WIFl and GMACnetwork communication interface, has 16GB EMMC memory, and supports interfaces such as Bluetooth keyboard and mouse.

rvb_ice.jpg

The board detail and pre-order link can be found in page: RVB-ICE

QUICKSTART

This port is based on android10-release (platform/manifest 1c222b02bde285fe1272b4440584750154d3882d). All the source code developed by T-Head is contained in the repository, anyone interested in this project can reproduce the environment with RVB-ICE/emulator.

Before downloading AOSP source code please check you work environment, it is recommended to install a Linux system(Ubuntu 16.04 is preferred) with at list 200G disk space and more than 8 CPU cores. Then follow the instructions from the links below:

https://source.android.com/setup/develop#installing-repo

https://source.android.com/setup/build/initializing

To setup the build enviroment, run reproduce.sh to download aosp to current directory and build AOSP for RISC-V. If repo sync is aborted, re-run the script.

Setup emulator environment

Run the reproduce.sh with no argument, the reproduce.sh will lunch the config "aosp_riscv64-eng", and compile all the required images for emulator environment.

Finally, use the following command to start emulator:

cd ${AOSP_RISCV_BUILD_TOP}
source ./build/envsetup.sh
lunch aosp_riscv64-eng
emulator -selinux permissive -qemu -smp 2 -m 3800M -bios ${AOSP_RISCV_BUILD_TOP}/prebuilts/qemu-kernel/riscv64/ranchu/fw_jump.bin

Setup RVB-ICE environment

Prepare binaries

Run the reproduce.sh with an argument "ice", the reproduce.sh will lunch the config "ice910dk-userdebug", and compile all the required images for the RVB-ICE.

The final images will be under:

aosp/out/target/product/ice910dk/
aosp/device/thead/thead_ice910/kernel/

The required image files include:
ramdisk.img
kernel
system.img
thead-ice910.dtb
u-boot-with-spl.bin
userdata.img
vendor.img

Copy these file to fastboot dir:
 mkdir fastboot
 cp aosp/out/target/product/ice910dk/ramdisk.img fastboot/boot
 cp aosp/out/target/product/ice910dk/kernel fastboot/boot/uImage
 cp aosp/out/target/product/ice910dk/system.img fastboot
 cp aosp/out/target/product/ice910dk/thead-ice910.dtb fastboot/boot
 cp aosp/out/target/product/ice910dk/userdata.img fastboot
 cp aosp/out/target/product/ice910dk/vendor.img fastboot
 cp aosp/device/thead/thead_ice910/kernel/fw_jump.bin fastboot/boot
 cp aosp/device/thead/thead_ice910/kernel/u-boot-with-spl.bin fastboot
 cd fastboot

Create boot image:

 make_ext4fs -l 20M boot.ext4 boot/

Program the device

Connect the power socket to 5V power supply, and the USB Type-C connector to host computer.

rvb_ice_port.jpg

You can program the device with the files under fastboot directory or prebuilt images downloaded from this link: Prebuilt images

Press the reboot button on the board; type in any key to get into console mode when the following prompt shows on the terminal.

Warning: [email protected] (eth0) using random MAC address - a6:7d:bc:02:7d:4d
eth0: [email protected]
Hit any key to stop autoboot:  3

Use the gpt tool to config the eMMC partitions size:

# reset to default env
env default -a

# Config the eMMC partitions size
setenv partitions "name=sparse,size=2031kb"
setenv partitions "$partitions;name=bootpart,size=60MiB"
setenv partitions "$partitions;name=system,size=1500MiB"
setenv partitions "$partitions;name=vendor,size=100MiB"
setenv partitions "$partitions;name=cache,size=256MiB"
setenv partitions "$partitions;name=userdata,size=-"

gpt write mmc 0 $partitions

# Config the network

# !!!!!!!!!!!!!!!!!!!! Special attention !!!!!!!!!!!!!!!!!!!!!!!!
# If multiple boards are connected to the network, each ethaddr shall be unique
setenv ethaddr 00:a0:a0:a0:a0:a1
setenv ipaddr 192.168.1.100        # Set dev board IP address
setenv netmask 255.255.255.0
ping 192.168.1.1                   # ping host IP,check network connection

# Config the kernel initialization parameter bootargs

setenv bootargs "console=ttyS0,115200"
setenv bootargs "$bootargs root=PARTUUID=$uuid_rootfs rootfstype=ext4"
setenv bootargs "$bootargs earlycon=sbi rdinit=/init security=selinux"
setenv bootargs "$bootargs crashkernel=256M-:128M c910_mmu_v1 printk.devkmsg=on"
setenv bootargs "$bootargs androidboot.selinux=permissive"
setenv bootargs "$bootargs androidboot.hardware=ranchu"
setenv bootargs "$bootargs androidboot.super_partition"

# Config bootcmd
setenv bootcmd "ext4load mmc 0:2 $opensbi_addr fw_jump.bin"
setenv bootcmd "$bootcmd;ext4load mmc 0:2 $dtb_addr ice_evb_c910.dtb"
setenv bootcmd "$bootcmd;ext4load mmc 0:2 $kernel_addr uImage"
setenv bootcmd "$bootcmd;ext4load mmc 0:2 0x02000000 ramdisk.img"
setenv bootcmd "$bootcmd;bootm $kernel_addr - $dtb_addr"

# Save environment variable to eMMC
saveenv

# Start fastboot udp
fastboot udp

Program the device using fastboot:

 sudo apt install fastboot
 fastboot -s udp:192.168.1.100 -S 5M flash boot output-android/boot.ext4
 fastboot -s udp:192.168.1.100 -S 5M flash system output-android/system.img
 fastboot -s udp:192.168.1.100 -S 5M flash vendor output-android/vendor.img
 fastboot -s udp:192.168.1.100 -S 5M flash cache output-android/cache.img
 fastboot -s udp:192.168.1.100 -S 5M flash userdata output-android/userdata.img

Build kernel & u-boot

The kernel and u-boot images are under the prebuilt directory, it is required to recompile these files from the source if you want to change the configurations.

Export the aosp-riscv directory for copy reference.

cd aosp-riscv
export AOSP_RISCV_PATH=`pwd`

Get a RISC-V toolchain and install:

 mkdir rvtools
 cd rvtools
 wget https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource/1836682/1629195585549/Xuantie-900-gcc-linux-5.4.36-glibc-x86_64-V2.0.3-20210806.tar.gz
 tar -xf Xuantie-900-gcc-linux-5.4.36-glibc-x86_64-V2.0.3-20210806.tar.gz
 export PATH=`pwd`/bin:$PATH

Build u-boot:

 git clone https://gitee.com/thead-linux/u-boot.git
 cd u-boot
 make ARCH=riscv ice_evb_c910_defconfig
 make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- -j
 cp u-boot-with-spl.bin $(AOSP_RISCV_PATH)/device/thead/thead_ice910/kernel/

Build kernel:

 git clone https://github.com/T-head-Semi/linux.git
 cd kernel
 git checkout  origin/linux-5.4-aosp
 make ARCH=riscv ice_c910_defconfig
 make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- -j Image dtbs
 mkdir ../output-kernel
 mkimage -A riscv -O linux -T kernel -C none -a 0x00200000 -e 0x00200000 -n Linux -d ./arch/riscv/boot/Image ./uImage
 cp uImage $(AOSP_RISCV_PATH)/device/thead/thead_ice910/kernel/kernel
 cp arch/riscv/boot/dts/thead/ice_evb_c910.dtb $(AOSP_RISCV_PATH)/device/thead/thead_ice910/kernel/
Owner
T-Head Semiconductor Co., Ltd.
T-Head Semiconductor Co., Ltd.
Comments
  • android10-release sources from https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest URL failing to download.

    android10-release sources from https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest URL failing to download.

    I was facing an issue while downloading android10 sources from https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest URL as follow's,

    $ cd ${AOSP_RISCV_BUILD_TOP} $ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android10-release

    error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received. fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed

    platform/prebuilts/misc: remote: Counting objects: 1582, done.
    remote: Compressing objects: 100% (1118/1118), done.
    error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received. fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed

    remote: Counting objects: 1582, done. MiB | 44.00 KiB/s
    remote: Compressing objects: 100% (1118/1118), done.
    remote: Total 12081 (delta 6032), reused 10083 (delta 5385)
    Receiving objects: 100% (12081/12081), 108.40 MiB | 55.00 KiB/s, done. Resolving deltas: 100% (6032/6032), done. remote: Counting objects: 25, done. 7 MiB | 74.00 KiB/s objects: 96% (9959/10289), 821.60 MiB | 86.00 KiB/s
    remote: Compressing objects: 100% (20/20), done.
    error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received. fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed

    platform/prebuilts/misc: remote: Counting objects: 1582, done.
    remote: Compressing objects: 100% (1118/1118), done.
    error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received. fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed

    Can any one help me out to reslove this issue.

    Thanks in advance Ghalib khan.

  • reproduce.sh script is failing to clone sources.

    reproduce.sh script is failing to clone sources.

    Hello,

    Am trying to reproduce build of aosp-riscv on x86 Machine, i have cloned https://github.com/T-head-Semi/aosp-riscv.git and run the reproduce script there it was failing to clone prebuilt sources as follows.

    Can any one know why this was happen and help me to resolve this issue.

    $ ./reproduce.sh --2021-02-01 17:41:19-- https://rosp-riscv.oss-cn-hangzhou.aliyuncs.com/prebuilts/android-emulator/linux-x86_64.zip Resolving rosp-riscv.oss-cn-hangzhou.aliyuncs.com (rosp-riscv.oss-cn-hangzhou.aliyuncs.com)... failed: Name or service not known. wget: unable to resolve host address ‘rosp-riscv.oss-cn-hangzhou.aliyuncs.com’ --2021-02-01 17:41:20-- https://rosp-riscv.oss-cn-hangzhou.aliyuncs.com/prebuilts/clang-tools/linux-x86.zip Resolving rosp-riscv.oss-cn-hangzhou.aliyuncs.com (rosp-riscv.oss-cn-hangzhou.aliyuncs.com)... failed: Name or service not known. wget: unable to resolve host address ‘rosp-riscv.oss-cn-hangzhou.aliyuncs.com’ --2021-02-01 17:41:20-- https://rosp-riscv.oss-cn-hangzhou.aliyuncs.com/prebuilts/clang/host/linux-x86/clang-dev.zip Resolving rosp-riscv.oss-cn-hangzhou.aliyuncs.com (rosp-riscv.oss-cn-hangzhou.aliyuncs.com)... failed: Name or service not known. wget: unable to resolve host address ‘rosp-riscv.oss-cn-hangzhou.aliyuncs.com’ --2021-02-01 17:41:20-- https://rosp-riscv.oss-cn-hangzhou.aliyuncs.com/prebuilts/gcc/linux-x86/riscv64/riscv64.zip Resolving rosp-riscv.oss-cn-hangzhou.aliyuncs.com (rosp-riscv.oss-cn-hangzhou.aliyuncs.com)... failed: Name or service not known. wget: unable to resolve host address ‘rosp-riscv.oss-cn-hangzhou.aliyuncs.com’ --2021-02-01 17:41:20-- https://rosp-riscv.oss-cn-hangzhou.aliyuncs.com/prebuilts/misc/riscv64.zip Resolving rosp-riscv.oss-cn-hangzhou.aliyuncs.com (rosp-riscv.oss-cn-hangzhou.aliyuncs.com)... failed: Name or service not known. wget: unable to resolve host address ‘rosp-riscv.oss-cn-hangzhou.aliyuncs.com’ --2021-02-01 17:41:20-- https://rosp-riscv.oss-cn-hangzhou.aliyuncs.com/prebuilts/ndk/r20.zip Resolving rosp-riscv.oss-cn-hangzhou.aliyuncs.com (rosp-riscv.oss-cn-hangzhou.aliyuncs.com)... failed: Name or service not known. wget: unable to resolve host address ‘rosp-riscv.oss-cn-hangzhou.aliyuncs.com’ --2021-02-01 17:41:20-- https://rosp-riscv.oss-cn-hangzhou.aliyuncs.com/prebuilts/qemu-kernel/riscv64.zip Resolving rosp-riscv.oss-cn-hangzhou.aliyuncs.com (rosp-riscv.oss-cn-hangzhou.aliyuncs.com)... failed: Name or service not known. wget: unable to resolve host address ‘rosp-riscv.oss-cn-hangzhou.aliyuncs.com’ --2021-02-01 17:41:20-- https://rosp-riscv.oss-cn-hangzhou.aliyuncs.com/prebuilts/vndk/v28/riscv64.zip Resolving rosp-riscv.oss-cn-hangzhou.aliyuncs.com (rosp-riscv.oss-cn-hangzhou.aliyuncs.com)... failed: Name or service not known. wget: unable to resolve host address ‘rosp-riscv.oss-cn-hangzhou.aliyuncs.com’

    Thanks in advance. Ghalib khan.

  • Build failed!

    Build failed!

    hi, I tried to build and failed, error log attached, anybody else see the similar issue? error.log

    machine info, FYI:

    LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch Distributor ID: Ubuntu Description: Ubuntu 18.04.5 LTS Release: 18.04 Codename: bionic

  • binder loop error

    binder loop error

    Hi,

    I have build and trying to boot ramdisk. system & vendor images. while booting am hitting the following Error, can anyone resolve this issue to get till ADB shell.

    fu540_andriod-selinux-boot.log

  • Building image for real Hardware.

    Building image for real Hardware.

    Hello folks,

    I want to build android OS to real RISC-V target Machine, can anyone help me out, How can build android OS.

    Thanks in advance, Ghalib khan c.

  • Emulator failing once it Lunched.

    Emulator failing once it Lunched.

    Hello,

    I have cloned and build aosp-riscv, Currently there was 2 issues like,

    1. when i lunch emulator it's failing and throwing an Error as follows,

    $ emulator -selinux permissive -qemu -smp 2 -m 3800M -bios /home/performance-server/ghalib-khan/android/aosp-riscv/aosp-riscv/aosp/prebuilts/qemu-kernel/riscv64/ranchu/fw_jump.bin emulator: WARNING: encryption is off emulator: ERROR: VkCommonOperations.cpp:537: Failed to create Vulkan instance. ProbeKVM: This user doesn't have permissions to use KVM (/dev/kvm). The KVM line in /etc/group is: [LINE_NOT_FOUND]

    If the current user has KVM permissions, the KVM line in /etc/group should end with ":" followed by your username.

    If we see LINE_NOT_FOUND, the kvm group may need to be created along with permissions: sudo groupadd -r kvm # Then ensure /lib/udev/rules.d/50-udev-default.rules contains something like: # KERNEL=="kvm", GROUP="kvm", MODE="0660" # and then run: sudo gpasswd -a $USER kvm

    If we see kvm:... but no username at the end, running the following command may allow KVM access: sudo gpasswd -a $USER kvm

    You may need to log out and back in for changes to take effect.

    [email protected], [email protected] qemu-system-riscv64: plic: invalid register write: 000001fc qemu-system-riscv64: plic: invalid register read: 00002090 qemu-system-riscv64: plic: invalid register write: 00002090 qemu-system-riscv64: plic: invalid register read: 00002190 qemu-system-riscv64: plic: invalid register write: 00002190 Segmentation fault (core dumped)

    1. In Emulator Graphical thinks are not visible.

    Can any help me out resolve this issue.

    Thanks in advance, Ghalib khan c.

  • seems that there is some issue when building the whole image

    seems that there is some issue when building the whole image

    ./reproduce.sh

    ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=10 TARGET_PRODUCT=aosp_riscv64 TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_ARCH=riscv64 TARGET_ARCH_VARIANT=riscv64 TARGET_CPU_VARIANT=generic HOST_ARCH=x86_64 HOST_2ND_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-4.15.0-118-generic-x86_64-Ubuntu-16.04.6-LTS HOST_CROSS_OS=windows HOST_CROSS_ARCH=x86 HOST_CROSS_2ND_ARCH=x86_64 HOST_BUILD_TYPE=release BUILD_ID=QP1A.191105.004 OUT_DIR=out

    ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=10 TARGET_PRODUCT=aosp_riscv64 TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_ARCH=riscv64 TARGET_ARCH_VARIANT=riscv64 TARGET_CPU_VARIANT=generic HOST_ARCH=x86_64 HOST_2ND_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-4.15.0-118-generic-x86_64-Ubuntu-16.04.6-LTS HOST_CROSS_OS=windows HOST_CROSS_ARCH=x86 HOST_CROSS_2ND_ARCH=x86_64 HOST_BUILD_TYPE=release BUILD_ID=QP1A.191105.004 OUT_DIR=out

    [100% 46/46] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja FAILED: out/soong/build.ninja out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp error: test/suite_harness/common/host-side/util/Android.bp:15:1: "compatibility-host-util" depends on undefined module "cts_error_prone_rules" 18:45:07 soong bootstrap failed with: exit status 1

Fork of the RPCEmu RISC PC emulator, with patches. The "master" branch is the original RPCEmu, the "philpem" branch contains my patches.

RPCEmu ~~~~~~ RPCEmu is an emulator of Acorn's Risc PC and A7000 machines. It is a work in progress and should be considered of Alpha Quality. The l

Jan 21, 2022
Linux 4.19 + PS4 patches + Latest security patches

Linux kernel ============ There are several guides for kernel developers and users. These guides can be rendered in a number of formats, like HTML an

Oct 12, 2021
Linux v4.14 with the latest security patches and PS4 patches.

Patches are from https://github.com/Ps3itaTeam/ps4-linux Linux kernel ============ This file was moved to Documentation/admin-guide/README.rst Plea

Oct 12, 2021
This device repo aims to support booting AOSP on SDM845 devices supported by the mainline Linux kernel

device/generic/sdm845 (AOSP device config for SDM845 devices) This device repo aims to support booting AOSP on SDM845 devices supported by the mainlin

Jan 2, 2023
Crappy RISC-V CPU and fancy peripherals designed to be useful.
Crappy RISC-V CPU and fancy peripherals designed to be useful.

Crappy RISC-V CPU and fancy peripherals designed to be useful. Always half-baked. Prioritize compatibility over performance.

Dec 9, 2022
A composable container for Adaptive ROS 2 Node computations. Select between FPGA, CPU or GPU at run-time.

adaptive_component A composable stateless container for Adaptive ROS 2 Node computations. Select between FPGA, CPU or GPU at run-time. Nodes using har

Sep 9, 2022
Add extra features to Discord via patches!

DiscordExtras An iOS tweak that lets you apply patches the iOS Discord client. Available on my repo here. Components DiscordExtrasPrefs This includes

Sep 28, 2022
A simple utility that cold patches dwm (uDWM.dll) in order to disable window rounded corners in Windows 11

Win11DisableRoundedCorners A simple utility that cold patches the Desktop Window Manager (uDWM.dll) in order to disable window rounded corners in Wind

Dec 27, 2022
Patches/unpatches an MCC CEA map to use client side hit detection for all weapons

MCC CEA Client-Side Hit Detection Map Patcher This program allows you to patch an MCC map so that all maps use client-side hit detection instead of ju

Aug 30, 2022
My own dwm setup with patches

dwm - dynamic window manager ============================ dwm is an extremely fast, small, and dynamic window manager for X. Requirements ----------

Oct 29, 2021
My experiments with Linux for the Apple M1 platform, based on Asahi and Corellium patches

Linux kernel ============ There are several guides for kernel developers and users. These guides can be rendered in a number of formats, like HTML an

Oct 24, 2021
A utility to automate the installation, maintenance, and debugging of Asterisk/DAHDI, while integrating additional patches to provide the richest telephony experience

PhreakScript A utility to automate the installation, maintenance, and debugging of Asterisk/DAHDI, while integrating additional patches to provide the

Dec 22, 2022
Sources used in making XDKbuild Patches and Tool

XDKbuild v0.05b By Xvistaman2005 This will make you a more or less stock XDK flash for your retail console. The patches included in this release are t

Nov 3, 2022
How do I submit patches to Android Common Kernels

How do I submit patches to Android Common Kernels BEST: Make all of your changes to upstream Linux. If appropriate, backport to the stable releases. T

Apr 7, 2022
A kernel module that patches Linux kernel "on-the-fly" to skip TASK_RSS_EVENTS_THRESH check in check_sync_rss_stat

split-rss-counting-patch A kernel module that patches Linux kernel "on-the-fly" to skip TASK_RSS_EVENTS_THRESH check in check_sync_rss_stat. Why? Read

Mar 6, 2022
Tiny FEL tools for allwinner SOC, support RISC-V D1 chip

XFEL Tiny FEL tools for allwinner SOC, support RISC-V D1 chip. How to build The xfel tools depends on the libusb-1.0 library, you need to install libu

Dec 30, 2022
A Pipelined RISC-V RV32I Core in Verilog
A Pipelined RISC-V RV32I Core in Verilog

Toast-RV32i Toast is a RISC-V soft core written in Verilog that implements a subset of the RV32I ISA version 2.2. Documentation: https://toast-core.re

Dec 20, 2022
RISC-V has a 128-bit ISA that is fairly developed, but not standardized fully yet.

128-bit RISC-V assembler RISC-V has a 128-bit ISA that is fairly developed, but not standardized fully yet. I am maintaining a RISC-V userspace emulat

Nov 20, 2022
Port of MIT's xv6 OS to the Nezha RISC-V board with Allwinner D1 SoC

xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson's Unix Version 6 (v6). xv6 loosely follows the structure and style of v6, but is impl

Dec 12, 2022