3. U-boot Transplant

3.1. U-boot Hardware Environment

The peripheral processors on cv180x/cv181x EVB include DDR, eMMC, SPI NAND Flash and SPI NOR Flash. Please refer to CV181x/CV180xB/C Hardware Design User Guide V1.0 for all models.

3.2. Pin Configuration (Pinmux)

For different EVBs and different peripherals, the initialization settings can be done in cvi_board_init.c.

$ cat build/boards/cv180x/cv1800b_wevb_0008a_spinor/u-boot/cvi_board_init.c
int cvi_board_init(void)
{
      PINMUX_CONFIG(PAD_MIPIRX1P, IIC1_SDA);
      PINMUX_CONFIG(PAD_MIPIRX0N, IIC1_SCL);
      PINMUX_CONFIG(PAD_MIPIRX1N, XGPIOC_8);
      PINMUX_CONFIG(PAD_MIPIRX0P, CAM_MCLK0);
      return 0;
}

3.3. Compile U-boot

The operation of compiling U-boot is as follows:

  • Read compilation environment variables (take cv1800b_wevb_0008a_spinor as an example)

$ source build/cvisetup.sh
  -------------------------------------------------------------------------
    Usage:
    (1) menuconfig - Use menu to configure your board.
        ex: $ menuconfig

    (2) defconfig $CHIP_ARCH - List EVB boards($BOARD) by CHIP_ARCH.
       ** cv183x ** -> ['cv1829', 'cv1832', 'cv1835', 'cv1838', 'cv9520', 'cv7581']
       ** cv182x ** -> ['cv1820', 'cv1821', 'cv1822', 'cv1823', 'cv1825', 'cv1826', 'cv7327', 'cv7357']
       **   cv181x ** -> ['cv181x', 'cv1823a', 'cv1821a', 'cv1820a', 'cv1811h', 'cv1811c', 'cv1810c', 'cv1812h']
       ** cv180x ** -> ['cv180x', 'cv1800b', 'cv1800c', 'cv1801b', 'cv1801c']
        ex: $ defconfig cv183x

    (3) defconfig $BOARD - Choose EVB board settings.
        ex: $ defconfig cv1835_wevb_0002a
        ex: $ defconfig cv1826_wevb_0005a_spinand
        ex: $ defconfig cv181x_fpga_c906
  --------------------------------------------------------------------------
  • Select EVB cv1800b_wevb_0008a_spinor

$ defconfig cv1800b_wevb_0008a_spinor
Run defconfig function
Loaded configuration '/workspace/build/boards/cv180x/cv1800b_wevb_0008a_spinor/cv1800b_wevb_0008a_spinor_defconfig'
No change to configuration in '.config'
Loaded configuration '.config'
====== Environment Variables =======
  PROJECT: cv1800b_wevb_0008a_spinor, DDR_CFG=ddr2_1333_x16
  CHIP_ARCH: cv180x, DEBUG=0
  SDK VERSION: musl_riscv64, RPC=0
  ATF options: ATF_KEY_SEL=default, BL32=1
  Linux source folder: linux_5.10, Uboot source folder: u-boot-2021.10
  CROSS_COMPILE_PREFIX: riscv64-unknown-linux-musl-
  ENABLE_BOOTLOGO: 0
  Flash layout xml: /workspace/build/boards/cv180x/ cv1800b_wevb_0008a_spinor/partition/partition_spinor.xml
  Sensor tuning bin: gcore_gc4653
  Output path: /workspace/master/install/ soc_cv1800b_wevb_0008a_spinor
  • Compile U-boot

$ build_uboot
[TARGET] u-boot-dts
......
[TARGET] u-boot-build
......
  • Get fip_spl.bin adn fip.bin (with bootloader+uboot inside)

$ ls install/soc_cv1800b_wevb_0008a_spinor/fip.bin
install/soc_cv1800b_wevb_0008a_spinor/fip.bin
$ ls install/soc_cv1800b_wevb_0008a_spinor/fip_spl.bin
install/soc_cv1800b_wevb_0008a_spinor/fip_spl.bin

Since the native u-boot compiled u-boot.bin cannot be burned directly into FLASH, we adopt the Firmware Image Package (FIP) method in ARM Trusted Firmware Design to encapsulate uboot.bin in fip.bin. fip_spl.bin contains several images that need to be loaded during the fast boot process.