/
RCHD-PF - Building HSS and U-Boot

RCHD-PF - Building HSS and U-Boot

Installing prerequisites

Required packages

apt-get install \ build-essentials git gcc-riscv64-linux-gnu flex bison \ kconfig-frontends libyaml-dev libelf-dev libssl-dev

Required Libero SoC version

At the time of writing this page, the following guide assumes that the following Microchip tools are installed:

  • Libero SoC v2023.2

  • SoftConsole v2022.2-RISC-V-747

Building HSS

Clone the sources:

% git clone https://gitlab.conclusive.pl/devices/rchd-pf/hart-software-services.git

Make sure that the SoftConsole toolchain is in the PATH (replace /opt/microchip with your Libero SoC installation prefix):

% export SC_INSTALL_DIR=/opt/microchip/SoftConsole-v2022.2-RISC-V-747 % export FPGENPROG=/opt/microchip/Libero_SoC_v2023.2/Libero/bin64/fpgenprog % export PATH="$SC_INSTALL_DIR/riscv-unknown-elf-gcc/bin:$PATH"

Configure the build for RCHD-PF board (use def_config_2gb for a 2GB board version):

% cp boards/rchd-pf/def_config_4gb ./.config % make -j BOARD=rchd-pf INFO: Linux detected RCHD-PF board selected [...] LD hss-l2scratch.elf NM hss-l2scratch.sym BIN hss-l2scratch.bin text data bss dec hex filename 142836 24080 183104 350020 55744 Default/hss-l2scratch.elf LD hss-envm-wrapper.elf NM hss-envm-wrapper.sym BIN hss-envm-wrapper.bin HEX hss-envm-wrapper.hex 12:25:35 INFO - mpfsBootmodeProgrammer v3.7 started. 12:25:35 INFO - "/home/jakub/git/hart-software-services/Default/bootmode1" is the output folder and the previous contents of this folder will be deleted. 12:25:35 INFO - Selected boot mode "1 - non-secure boot from eNVM" and working in directory "/home/jakub/git/hart-software-services/Default". 12:25:35 INFO - Generating BIN file... 12:25:35 INFO - Generating header... 12:25:35 INFO - Generating HEX file... 12:25:35 INFO - Preparing for bitstream generation... 12:25:35 INFO - Generating bitstream... 12:25:44 INFO - Programming/verifying the target skipped because --dryrun was specified. 12:25:44 INFO - mpfsBootmodeProgrammer completed successfully. text data bss dec hex filename 95444 416 149632 245492 3bef4 Default/hss-envm-wrapper.elf

Building U-Boot

Clone the sources:

% git clone https://gitlab.conclusive.pl/devices/u-boot.git

Configure the build for RCHD-PF board and start the build:

% make rchd_pf_defconfig % make -j CROSS_COMPILE=riscv64-linux-gnu- [...] CC lib/efi_loader/boothart.o CC lib/efi_loader/dtbdump.o CC lib/efi_loader/initrddump.o LD lib/efi_loader/boothart_efi.so OBJCOPY lib/efi_loader/boothart.efi LD lib/efi_loader/initrddump_efi.so OBJCOPY lib/efi_loader/initrddump.efi LD lib/efi_loader/dtbdump_efi.so OBJCOPY lib/efi_loader/dtbdump.efi LD u-boot OBJCOPY u-boot.srec OBJCOPY u-boot-nodtb.bin SYM u-boot.sym CAT u-boot-dtb.bin COPY u-boot.bin OFCHK .config

Building HSS payload image

Build the HSS payload generator:

% cd tools/hss-payload-generator % make

Add hss-payload-generator directory to the system PATH:

export PATH="$PATH:$(realpath .)"

Use the following YAML configuration file for the hss-payload-generator:

set-name: 'RCHD-PF::U-Boot' hart-entry-points: u54_1: '0x1000200000' u54_2: '0x1000200000' u54_3: '0x1000200000' u54_4: '0x1000200000' payloads: u-boot.bin: exec-addr: '0x1000200000' owner-hart: u54_1 secondary-hart: u54_2 secondary-hart: u54_3 secondary-hart: u54_4 priv-mode: prv_s

Run the hss-payload-generator to generate the payload image (assumes the above YAML file is saved as hss.yml in the U-Boot directory):

% hss-payload-generator -c hss.yml payload.bin Hart Software Service formatted boot image generator v0.99.28 Copyright (c) 2021 Microchip FPGA Embedded Systems Solutions. >>u-boot.bin<< is not an ELF object Set-name is >>RCHD-PF::U-Boot<< Output filename is >>payload.bin<<

Flashing image

Flashing HSS

Clone the utilities repository:

% git clone https://gitlab.conclusive.pl/devices/rchd-pf/rchd-pf.git

Flash the HSS using flash-hss.sh shell script - provide HSS ELF file path as an argument:

% ./flashing/flash-hss.sh ~/git/hart-software-services/Default/hss-envm-wrapper.elf 12:43:01 INFO - mpfsBootmodeProgrammer v3.7 started. 12:43:01 INFO - "/tmp/tmp.kksOmSHwlK/bootmode1" is the output folder and the previous contents of this folder will be deleted. 12:43:01 INFO - Selected boot mode "1 - non-secure boot from eNVM" and working in directory "/tmp/tmp.kksOmSHwlK". 12:43:02 INFO - Generating BIN file... 12:43:02 INFO - Generating header... 12:43:02 INFO - Generating HEX file... 12:43:02 INFO - Preparing for bitstream generation... 12:43:02 INFO - Generating bitstream... 12:43:12 INFO - Programming the target... 12:43:23 INFO - mpfsBootmodeProgrammer completed successfully.

Flashing U-Boot

In order to flash U-Boot, GPT partition table needs to be created on the eMMC, as HSS loads its payload directly from a GPT partition.

 

HSS payload must be placed on a partition with the following properties:

Property

Value

Property

Value

Size

1 MB (minimum)

Type

BIOS Boot

Type GUID

21686148-6449-6E6F-744E-656564454649

Flashing of the eMMC can be done via the emulated USB mass storage device available in the HSS. USB mass storage mode can be entered by typing the usbdmsc command in HSS:

[6.35310] >> usbdmsc [7.958546] initialize MMC [7.961220] Attempting to select eMMC ... Passed [8.230091] MMC - 512 byte pages, 512 byte blocks, 30777344 pages Waiting for USB Host to connect... (CTRL-C to quit) . 0 bytes written, 0 bytes readUSB Host connected. Waiting for disconnect... (CTRL-C to quit) / 0 bytes written, 4096 bytes read

A new USB device should show up in the host system:

[868644.911126] cdc_subset 3-3.2.4:1.1 usb0: unregister 'cdc_subset' usb-0000:00:14.0-3.2.4, Linux Device [868653.582585] usb 3-3.2.4: new high-speed USB device number 26 using xhci_hcd [868653.683096] usb 3-3.2.4: New USB device found, idVendor=1514, idProduct=0001, bcdDevice=30.00 [868653.683113] usb 3-3.2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [868653.683120] usb 3-3.2.4: Product: PolarFireSoc-FlashDrive [868653.683125] usb 3-3.2.4: Manufacturer: Microchip Inc [868653.683129] usb 3-3.2.4: SerialNumber: B80E2F68BB7F57077C73AE05 [868653.690050] usb-storage 3-3.2.4:1.0: USB Mass Storage device detected [868653.690292] scsi host6: usb-storage 3-3.2.4:1.0 [868654.715059] scsi 6:0:0:0: Direct-Access MSCC PolarFireSoC_msd 1234 PQ: 0 ANSI: 4 [868654.715829] sd 6:0:0:0: Attached scsi generic sg1 type 0 [868654.722051] sd 6:0:0:0: [sdb] 30777344 512-byte logical blocks: (15.8 GB/14.7 GiB) [868654.722361] sd 6:0:0:0: [sdb] Write Protect is off [868654.722365] sd 6:0:0:0: [sdb] Mode Sense: 00 00 00 00 [868654.722676] sd 6:0:0:0: [sdb] Asking for cache data failed [868654.722681] sd 6:0:0:0: [sdb] Assuming drive cache: write through

Now we can create a GPT partition table and the boot partition:

% sgdisk -Z /dev/sdb % sgdisk -n 0:0:+1M -t 0:ef02 -c 0:boot /dev/sdb % partprobe /dev/sdb

Finally, we can copy the HSS payload to the boot partition:

% dd if=payload.bin of=/dev/sdb1 bs=512

Related content