Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards/risc-v: Add support for PINE64 Star64 JH7110 SBC #10094

Merged
merged 1 commit into from Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Documentation/introduction/detailed_support.rst
Expand Up @@ -3051,6 +3051,13 @@ Espressif ESP32-C6 Devkit board.
Please, refer to the :doc:`ESP32-C6 </platforms/risc-v/esp32c6/index>` on NuttX for
further information.

StarFive JH7110
---------------

The basic port has been completed for the following StarFive JH7110 board:

- **PINE64 Star64**: Refer to :doc:`PINE64 Star64 </platforms/risc-v/jh7110/boards/star64/index>` for further information.

ESP32 (Dual Xtensa LX6)
=======================

Expand Down
220 changes: 220 additions & 0 deletions Documentation/platforms/risc-v/jh7110/boards/star64/index.rst
@@ -0,0 +1,220 @@
=============
PINE64 Star64
=============

`Star64 <https://wiki.pine64.org/wiki/STAR64>`_ is a 64-bit RISC-V based
Single Board Computer powered by StarFive JH7110 Quad-Core SiFive U74 64-Bit CPU,
Imagination Technology BX-4-32 GPU and supports up to 8GB 1866MHz LPDDR4 memory.

It provides an eMMC module socket, MicroSD Card slot, PCI-e, Pi-2 Bus, USB 3.0
and many other peripheral interfaces for makers to integrate with sensors
and other devices.

Features
========

- **System on Chip:** StarFive JH7110
- **CPU:** SiFive RISC-V U74 Application Cores (4 cores, RV64GCB) and SiFive RISC-V S7 Monitor Core (single core, RV64IMACB)
- **GPU:** Imagination Technology BXE-4-32
- **RAM:** LPDDR4 2GB / 4GB / 8GB
- **Video:** Digital Video Output up to 4K @ 30 Hz, 4K HDR @ 60 fps
- **Audio:** 3.5mm Audio Jack
- **Ethernet:** Single or Dual 10 / 100 / 1000Mbps
- **Wireless:** 2.4 GHz / 5 Ghz MIMO WiFi 802.11 b/g/n/ac with Bluetooth 5.2 (Realtek RTL8852BU)
- **Storage:** 128 Mbit (16 MByte) XSPI NOR flash Memory, Bootable microSD (SDHC and SDXC up to 256 GB), Bootable eMMC
- **USB:** 1 x USB 3.0 Dedicated Host Port, 3 x USB 2.0 Host Ports
- **Expansion Ports:** PCIe 2.0 x 1 lane, 2 x 20 pins "Pi2" GPIO Header
- **MIPI DSI Port:** 4-lane MIPI DSI port for LCD Panel
- **MIPI CSI Port:** 4-lane MIPI CSI port for Camera Module

Serial Console
==============

A **USB Serial Adapter** (like `CH340G Serial Adapter <https://pine64.com/product/serial-console-woodpecker-edition/>`_)
is required to run NuttX on Star64.

Connect the USB Serial Adapter to Star64's **GPIO Header** at:

========== ===========
USB Serial GPIO Header
========== ===========
GND Pin 6 (GND)
RX Pin 8 (UART0 TX)
TX Pin 10 (UART0 RX)
========== ===========

On the USB Serial Adapter, set the **Voltage Level** to 3V3.

Connect Star64 to our computer with the USB Serial Adapter.
On our computer, start a Serial Terminal and connect to the USB Serial Port
at **115.2 kbps**.

NuttX will appear in the Serial Console when it boots on Star64.

RISC-V Toolchain
================

Before building NuttX for Star64, download the **RISC-V Toolchain riscv64-unknown-elf**
from `SiFive RISC-V Tools <https://github.com/sifive/freedom-tools/releases/tag/v2020.12.0>`_.

Add the downloaded toolchain ``riscv64-unknown-elf-toolchain-.../bin``
to the ``PATH`` Environment Variable.

Check the RISC-V Toolchain:

.. code:: console

$ riscv64-unknown-elf-gcc -v

Building
========

To build NuttX for Star64, :doc:`install the prerequisites </quickstart/install>` and
:doc:`clone the git repositories </quickstart/install>` for ``nuttx`` and ``apps``.

Configure the NuttX project and build the project:

.. code:: console

$ cd nuttx
$ tools/configure.sh star64:nsh
$ make
$ riscv64-unknown-elf-objcopy -O binary nuttx nuttx.bin

This produces the NuttX Kernel ``nuttx.bin``. Next, build the NuttX Apps Filesystem:

.. code:: console

$ make export
$ pushd ../apps
$ tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
$ make import
$ popd
$ genromfs -f initrd -d ../apps/bin -V "NuttXBootVol"

This generates the Initial RAM Disk ``initrd``.

Download the `Device Tree jh7110-visionfive-v2.dtb <https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v3.1.5/jh7110-visionfive-v2.dtb>`_
from `StarFive VisionFive2 Software Releases <https://github.com/starfive-tech/VisionFive2/releases>`_
into the ``nuttx`` folder.

Inside the ``nuttx`` folder, create a Text File named ``nuttx.its``
with the following content:

::

/dts-v1/;

/ {
description = "NuttX FIT image";
#address-cells = <2>;

images {
vmlinux {
description = "vmlinux";
data = /incbin/("./nuttx.bin");
type = "kernel";
arch = "riscv";
os = "linux";
load = <0x0 0x40200000>;
entry = <0x0 0x40200000>;
compression = "none";
};

ramdisk {
description = "buildroot initramfs";
data = /incbin/("./initrd");
type = "ramdisk";
arch = "riscv";
os = "linux";
load = <0x0 0x46100000>;
compression = "none";
hash-1 {
algo = "sha256";
};
};

fdt {
data = /incbin/("./jh7110-visionfive-v2.dtb");
type = "flat_dt";
arch = "riscv";
load = <0x0 0x46000000>;
compression = "none";
hash-1 {
algo = "sha256";
};
};
};

configurations {
default = "nuttx";

nuttx {
description = "NuttX";
kernel = "vmlinux";
fdt = "fdt";
loadables = "ramdisk";
};
};
};

Package the NuttX Kernel, Initial RAM Disk and Device Tree into a
Flat Image Tree:

.. code:: console

$ sudo apt install u-boot-tools
$ mkimage -f nuttx.its -A riscv -O linux -T flat_dt starfiveu.fit

The Flat Image Tree ``starfiveu.fit`` will be copied to a microSD Card
in the next step.

Booting
=======

NuttX boots on Star64 via a microSD Card. To prepare the microSD Card, download the
`microSD Image sdcard.img <https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v3.1.5/sdcard.img>`_
from `StarFive VisionFive2 Software Releases <https://github.com/starfive-tech/VisionFive2/releases>`_.

Write the downloaded image to a microSD Card with
`Balena Etcher <https://www.balena.io/etcher/>`_ or
`GNOME Disks <https://wiki.gnome.org/Apps/Disks>`_.

Copy the file ``starfiveu.fit`` from the previous section
and overwrite the file on the microSD Card.

Check that Star64 is connected to our computer via a USB Serial Adapter.

Insert the microSD Card into Star64 and power up Star64.
NuttX boots on Star64 and NuttShell (nsh) appears in the Serial Console.

To see the available commands in NuttShell:

.. code:: console

$ help

`Booting NuttX over TFTP <https://lupyuen.github.io/articles/tftp>`_
is also supported on Star64.

Configurations
==============

nsh
---

Basic configuration that runs NuttShell (nsh).
This configuration is focused on low level, command-line driver testing.
Built-in applications are supported, but none are enabled.
Serial Console is enabled on UART0 at 115.2 kbps.

Peripheral Support
==================

NuttX for PinePhone supports these peripherals:

======================== ======= =====
Peripheral Support NOTES
======================== ======= =====
UART Yes
======================== ======= =====
29 changes: 29 additions & 0 deletions Documentation/platforms/risc-v/jh7110/index.rst
@@ -0,0 +1,29 @@
===============
StarFive JH7110
===============

`StarFive JH7110 <https://doc-en.rvspace.org/Doc_Center/jh7110.html>`_ is a 64-bit RISC-V SoC that features:

- **CPU:** SiFive RISC-V U74 Application Cores (4 cores, RV64GCB) and SiFive RISC-V S7 Monitor Core (single core, RV64IMACB)
- **GPU:** Imagination Technology BXE-4-32
- **RAM:** 32-bit LPDDR4 / DDR4 / LPDDR3 / DDR3
- **Video Decoder:** 4K @ 30 fps multi-stream for H.264/H.265
- **Video Encoder:** 1080p @ 30 fps multi-stream for H.265
- **Video Input:** 1 x DVP and 1 x MIPI-CSI with 4D1C
- **Video Output:** MIPI DSI with 4D1C
- **HDMI:** 1 x HDMI 2.0 port display up to 4K @ 30 fps
- **Parallel Interface:**: 24-bit RGB parallel interface
- **PCIe:** 2 x PCIe 2.0, 1 lane
- **USB:** USB 3.0 Host / Device
- **Ethernet:** 2 x Ethernet MAC 1,000 Mbps, 2 x CAN 2.0B
- **Security:** TRNG, OTP
- **Peripherals:** UART, I2C, SPI, SDIO, DPI, PCM / I2S, Timers, Temperature Sensor, INTC, PWM, WDT, GPIO, DVP, GPCLK

Supported Boards
================

.. toctree::
:glob:
:maxdepth: 1

boards/*/*
11 changes: 11 additions & 0 deletions boards/Kconfig
Expand Up @@ -1810,6 +1810,13 @@ config ARCH_BOARD_QEMU_RV_VIRT
This is the board configuration for the port of NuttX to the
QEMU RV32 Virt board. This board features the QEMU RV32 CPU.

config ARCH_BOARD_JH7110_STAR64
bool "PINE64 Star64"
depends on ARCH_CHIP_JH7110
---help---
This options selects support for NuttX on PINE64 Star64 based
on StarFive JH7110 SoC.

config ARCH_BOARD_S32K118EVB
bool "NXP S32K118EVB"
depends on ARCH_CHIP_S32K118
Expand Down Expand Up @@ -3057,6 +3064,7 @@ config ARCH_BOARD
default "mr-canhubk3" if ARCH_BOARD_MR_CANHUBK3
default "rv32m1-vega" if ARCH_BOARD_RV32M1_VEGA
default "rv-virt" if ARCH_BOARD_QEMU_RV_VIRT
default "star64" if ARCH_BOARD_JH7110_STAR64
default "sabre-6quad" if ARCH_BOARD_SABRE_6QUAD
default "qemu-armv8a" if ARCH_BOARD_QEMU_ARMV8A
default "pinephone" if ARCH_BOARD_PINEPHONE
Expand Down Expand Up @@ -3900,6 +3908,9 @@ endif
if ARCH_BOARD_QEMU_RV_VIRT
source "boards/risc-v/qemu-rv/rv-virt/Kconfig"
endif
if ARCH_BOARD_JH7110_STAR64
source "boards/risc-v/jh7110/star64/Kconfig"
endif
if ARCH_BOARD_ESP32C3_DEVKIT
source "boards/risc-v/esp32c3/esp32c3-devkit/Kconfig"
endif
Expand Down
Empty file.
93 changes: 93 additions & 0 deletions boards/risc-v/jh7110/star64/configs/nsh/defconfig
@@ -0,0 +1,93 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_DISABLE_OS_API is not set
# CONFIG_NSH_DISABLE_LOSMART is not set
CONFIG_16550_ADDRWIDTH=0
CONFIG_16550_REGINCR=4
CONFIG_16550_UART0=y
CONFIG_16550_UART0_BASE=0x10000000
CONFIG_16550_UART0_CLOCK=23040000
CONFIG_16550_UART0_IRQ=57
CONFIG_16550_UART0_SERIAL_CONSOLE=y
CONFIG_16550_UART=y
CONFIG_16550_WAIT_LCR=y
CONFIG_ARCH="risc-v"
CONFIG_ARCH_ADDRENV=y
CONFIG_ARCH_BOARD="star64"
CONFIG_ARCH_BOARD_JH7110_STAR64=y
CONFIG_ARCH_CHIP="jh7110"
CONFIG_ARCH_CHIP_JH7110=y
CONFIG_ARCH_DATA_NPAGES=128
CONFIG_ARCH_DATA_VBASE=0xC0100000
CONFIG_ARCH_HEAP_NPAGES=128
CONFIG_ARCH_HEAP_VBASE=0xC0200000
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_KERNEL_STACKSIZE=3072
CONFIG_ARCH_PGPOOL_MAPPING=y
CONFIG_ARCH_PGPOOL_PBASE=0x40600000
CONFIG_ARCH_PGPOOL_SIZE=4194304
CONFIG_ARCH_PGPOOL_VBASE=0x40600000
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_TEXT_NPAGES=128
CONFIG_ARCH_TEXT_VBASE=0xC0000000
CONFIG_ARCH_USE_MMU=y
CONFIG_ARCH_USE_MPU=y
CONFIG_ARCH_USE_S_MODE=y
CONFIG_BOARDCTL_ROMDISK=y
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=116524
CONFIG_BUILD_KERNEL=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y
CONFIG_DEBUG_ERROR=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEBUG_WARN=y
CONFIG_DEV_ZERO=y
CONFIG_ELF=y
CONFIG_EXAMPLES_HELLO=m
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_IDLETHREAD_STACKSIZE=3072
CONFIG_INIT_FILEPATH="/system/bin/init"
CONFIG_INIT_MOUNT=y
CONFIG_INIT_MOUNT_FLAGS=0x1
CONFIG_INIT_MOUNT_TARGET="/system/bin"
CONFIG_INIT_STACKSIZE=3072
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_MEMSET_64BIT=y
CONFIG_MEMSET_OPTSPEED=y
CONFIG_MM_PGALLOC=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_FILE_APPS=y
CONFIG_NSH_READLINE=y
CONFIG_PATH_INITIAL="/system/bin"
CONFIG_RAM_SIZE=1048576
CONFIG_RAM_START=0x40200000
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SERIAL_UART_ARCH_MMIO=y
CONFIG_STACK_COLORATION=y
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2021
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NSH_PROGNAME="init"
CONFIG_TESTING_GETPRIME=y
CONFIG_USEC_PER_TICK=1000