Milk-V Documentation

website·Indexed 29 days ago

https://sophgocommunity.github.io/SG2042-Wiki/

Technical documentation for Milk-V developer platforms, including the Pioneer motherboard based on the SOPHON SG2042 processor and the Duo embedded platform based on the CV1800B chip. Covers hardware assembly, OS installation for Ubuntu and Anolis OS, BSP building, boot flows, and SDK resources for Cvitek CV180x and CV181x.

Tokens
10.6K
Snippets
50
Records
97
Agent score
75%

What's inside Milk-V

  1. Overview of the CV1800B SoC

    The CV1800B is a high-performance, low-power chip designed for residential consumer surveillance IP cameras and home intelligence products. Key integrated features include:

    • Video Processing: H.264/H.265 video compression encoder and ISP with support for 3D noise reduction, digital broad dynamic range, defogging, and lens distortion correction.
    • AI Capabilities: Built-in intelligent reference solutions for human detection, area detection, and motion detection.
    • Hardware Integration: Integrated DDR, complete peripherals, and an 8-bit MCU subsystem that can replace external MCUs to reduce BOM cost and power consumption.
    • Security: Supports secure boot, secure update, and secure encryption.
  2. Overview of Duo USB&Ethernet IOB expansion board

    The Duo USB&Ethernet IOB is an expansion board for the Milk-V Duo designed to increase development efficiency by providing easier access to common USB peripherals and Ethernet connectivity. It adds the following hardware interfaces: 4 USB ports, 1 RJ45 network port, 1 serial port pinout, and 1 Type-C power input connector.
  3. SOPHON SG2042 Processor Specifications

    The SOPHON SG2042 is a 64-core server-grade chip based on the RISC-V ISA, designed for high-performance computing and compatible with general-purpose operating systems like Linux.

    Key hardware specifications include:

    • CPU Architecture: 64 cores organized into 16 clusters (4 cores per cluster).
    • Clock Speed: 2GHz.
    • Cache Hierarchy:
      • L1: 64KB Instruction (L1-I) and 64KB Data (L1-D) per core.
      • L2: 1MB shared per cluster.
      • L3: 64MB system cache.
    • Memory: 4x DDR4-3200 controllers supporting RDIMM, ECC, and UDIMM.
    • Connectivity & I/O:
      • 32x PCI Express Gen4.0 interfaces.
      • CCIX support for interconnecting two chips.
      • Integrated eMMC 5.1, SDIO 3.0, 2x SPI, 4x I2C, 4x UART, and gigabit Ethernet MAC.
  4. Understand the SG2042 boot sequence

    The SG2042 boot flow follows a multi-stage process to initialize hardware and load the operating system kernel. The sequence is as follows:

    1. Fip.bin: The initial boot binary.
    2. ZSBL (Zero Stage Bootloader): ROM-based code that initializes the DDR, CPU, and Ethernet, then loads OpenSBI and U-Boot.
    3. OpenSBI (RISC-V Open Source Supervisor Binary Interface): Provides a reference implementation of RISC-V SBI specifications for platform-specific firmware executing in M-mode.
    4. conf.ini: A configuration file used to determine the next bootloader to execute.
    5. LinuxBoot: Firmware that replaces the UEFI DXE phase with a Linux kernel and runtime.
    6. U-Boot (Universal Bootloader): Facilitates the booting process of the embedded device.
    7. GRUB2 (GRand Unified Bootloader version 2): Loads and transfers control to the operating system kernel.
    8. Kernel: The final stage where the OS kernel initializes the rest of the system.
  5. Assemble the Pioneer Board into the chassis

    Follow these steps to complete the hardware assembly of the Pioneer Board within the Pioneer Box case:

    1. Install Heatsink and Memory: Attach the heatsink and memory stick to the Pioneer Board.
    2. Install Power Supply: Mount the power supply into the chassis.
    3. Install Interface Baffle: Attach the interface baffle to the rear of the chassis.
    4. Secure the Board: Use the screws provided with the case to secure the Pioneer Board to the chassis.
    5. Install SSD: Mount the SSD into the designated slot.
    6. Connect Front Panel USB: Connect the Pioneer Board using the provided USB cable. The plug features a standard anti-misplug design to ensure correct orientation.
    7. Connect Switch Key: Use the switch key connection cable provided with the chassis to connect to the Pioneer Board.
  6. Cvitek LDC Debugging Guide

  7. Resize the root partition on a microSD card for SG2042 EVB

    After flashing the image, you may need to resize the root partition (typically the 3rd partition) to utilize the full capacity of the microSD card. This involves deleting the existing partition, creating a new one with the same start sector, and resizing the filesystem.
    # 1. Use fdisk to delete and recreate partition 3
    sudo fdisk /dev/sdc
    # Inside fdisk: 
    # 'd' -> partition 3
    # 'n' -> primary -> partition 3 -> default start/end sectors
    # 'N' when asked to remove signature
    # 'w' to save changes
    
    # 2. Force check the filesystem
    sudo e2fsck -f /dev/sdc3
    
    # 3. Resize the filesystem to fill the partition
    sudo resize2fs /dev/sdc3
  8. Configure SG2042 EVB to boot from NVMe SSD

    To move the system from a microSD card to an NVMe SSD while keeping the microSD card for booting, follow these steps:

    1. Copy the ubuntu-sophgo.img to the NVMe disk using the dd command.
    2. Resize the root partition on the NVMe disk.
    3. Critical Step: Use fdisk to delete the root partition on the microSD card. This is necessary because both the microSD card and the NVMe disk share the same root partition label, which causes conflicts.
    4. Reboot the system to access Ubuntu via the NVMe disk.
  9. Build GRUB2 for RISC-V 64-bit EFI

    To build GRUB2 for a RISC-V 64-bit target with EFI support, you must clone the source, install build dependencies, and run a compilation script that configures the target for riscv64-unknown-linux-gnu with the efi platform.
    # 1. Clone source and checkout specific RISC-V development branch
    git clone git://git.savannah.gnu.org/grub.git
    pushd grub
    git remote add github.com_tekkamanninja https://github.com/tekkamanninja/grub.git
    git fetch github.com_tekkamanninja
    git checkout github.com_tekkamanninja/riscv_devel_Nikita_V3
    popd
    
    # 2. Install dependencies
    sudo apt install bison autoconf libopts25-dev flex automake pkg-config gettext autopoint libdevmapper-dev
    
    # 3. Build process (simplified from script)
    pushd grub
    ./bootstrap
    ./autogen.sh
    
    # Ensure RISCV64_LINUX_CROSS_COMPILE is set to your toolchain path
    TARGET_CC="${RISCV64_LINUX_CROSS_COMPILE}gcc"
    TARGET_OBJCOPY="${RISCV64_LINUX_CROSS_COMPILE}objcopy"
    TARGET_STRIP="${RISCV64_LINUX_CROSS_COMPILE}strip"
    TARGET_NM="${RISCV64_LINUX_CROSS_COMPILE}nm"
    TARGET_RANLIB="${RISCV64_LINUX_CROSS_COMPILE}ranlib"
    TARGET_CFLAGS='-Os -march=rv64imac_zicsr_zifencei'
    
    ./configure --target=riscv64-unknown-linux-gnu --with-platform=efi --prefix=/path/to/install
    make install -j$(nproc)
    
    # 4. Create the EFI binary using grub-mkimage
    # Replace MODULES with the required list of modules (e.g., acpi, fat, ext2, etc.)
    /path/to/install/bin/grub-mkimage -v \
                      -o grubriscv64.efi \
                      -O riscv64-efi \
                      -p efi \
                      -c default.cfg MODULES