Skip to main content

HiFive Premier P550

The HiFive Premier P550 is a quad-core board from SifFive featuring the ESWIN EIC7700X SoC. The documentation from Sifive is centralized on their website. The user guide provide a high level overview of the board, while the software reference manual provides instruction for building the P550 software from source, including firmware images.

Before trying to load a Miralis image on the board, double check that the board is properly booting with the vendor-provided firmware and has a functionning Linux image installed.

Building a Miralis image

In the following we details the procedure for building a Miralis image. The instructions assume you run all commands from the artifact directory of the miralis repository.

Firmware Images

Creating an image for the Premier P550 requires 3 firmware images:

  • second_boot_fw
  • ddr_fw
  • and fw_payload

SiFive provides images for the first two firmware in the p550 tools reposity. However, SiFive does not provide a fw_payload image, which is the firmware containing OpenSBI and U-boot proper. For convenience, we provide a pre-build fw_payload image for the Premier P550 in this repository, along with the procedure to build the image if you prefer to built it yourself.

To download the three images, run:

curl -L -o p550_fw_payload.bin https://github.com/CharlyCst/premierp550-opensbi/releases/download/v0.1.2/fw_payload.bin
curl -L -o p550_ddr_fw.bin https://github.com/sifiveinc/hifive-premier-p550-tools/raw/a53157562a6df2cee64aff8b49be13c42d900192/ddr-fw/ddr_fw.bin
curl -L -o p550_second_boot_fw.bin https://github.com/sifiveinc/hifive-premier-p550-tools/raw/a53157562a6df2cee64aff8b49be13c42d900192/second_boot_fw/second_boot_fw.bin

Building miralis

Miralis comes with a configuration for the Premier P550. Simply run:

just build config/premierp550.toml

Combining the images

The next step is to combine all the firmware images into a single image that can be flashed on the board.

First, we need to insert Miralis in memory. On the Premier P550 we put Miralis in between OpenSBI and U-boot, at 0x80008000. Both OpenSBI and U-boot are combined in a single Binary, with zeroes in between. To insert Miralis, we simply fill the zeroes in the middle:

# Copy the OpenSBI + U-boot image
cp p550_fw_payload.bin p550_combined_fw.bin

# Then fill the zeroes in the middle
dd if=../target/riscv-unknown-miralis/release/miralis.img of=p550_combined_fw.bin bs=4096 seek=128 conv=notrunc

This creates a new p550_combined_fw.bin image with Miralis, OpenSBI, and U-boot. To combine that image with the other firmware (p550_second_boot_fw.bin and p550_ddr_fw.bin) the Premier P550 relies on a tool from Eswin called nsign, which needs to be built from source.

To build nsign, run:

git clone https://github.com/eswincomputing/Esbd-77serial-nsign
cd Esbd-77serial-nsign
./build.sh
cp nsign ..
cd ..

Then, nsign takes a configuration as input with the layout of the firmware images. Copy the following configuration as p550.cfg:

p550.cfg
cmd=chief_sign
out=p550_miralis.bin
{
in=p550_second_boot_fw.bin
boot_flags=SCPU
payload_type=FIRMWARE
sign_algorithm=plaintext
keyid=00
version=00000001
link_addr=00000000
load_addr=59000000
entry_addr=59000000
payload_flags=plaintext
digest_mthd=SHA
encrypted_mthd=plaintext
devid=0000000000000000
vid=00
lang=656e67
mid=0000000000000000
params=00000000000000000000000000000000
dl_load_addr=00000000
dl_init_ofs=00000000
dl_destory_ofs=00000000
dl_ioctl_ofs=00000000
dl_load_flags=00000000
dl_irq_num=00000000
dl_irq_ofs=00000000
}
{
in=p550_ddr_fw.bin
boot_flags=SCPU
payload_type=DDR
sign_algorithm=plaintext
keyid=00
version=00000001
link_addr=00000000
load_addr=59000000
entry_addr=59000000
payload_flags=plaintext
digest_mthd=SHA
encrypted_mthd=plaintext
devid=0000000000000000
vid=00
lang=656e67
mid=0000000000000000
params=00000000000000000000000000000000
dl_load_addr=00000000
dl_init_ofs=00000000
dl_destory_ofs=00000000
dl_ioctl_ofs=00000000
dl_load_flags=00000000
dl_irq_num=00000000
dl_irq_ofs=00000000
}
{
in=p550_combined_fw.bin
boot_flags=MCPU
payload_type=BOOTLOADER
sign_algorithm=plaintext
keyid=00
version=00000001
link_addr=00000000
load_addr=80000000
entry_addr=80080000
payload_flags=plaintext
digest_mthd=SHA
encrypted_mthd=plaintext
devid=0000000000000000
vid=00
lang=656e67
mid=0000000000000000
params=00000000000000000000000000000000
dl_load_addr=00000000
dl_init_ofs=00000000
dl_destory_ofs=00000000
dl_ioctl_ofs=00000000
dl_load_flags=00000000
dl_irq_num=00000000
dl_irq_ofs=00000000
}

The only two modifications compared to the official configuration are the names of the binaries, and the entry point to transfer control to Miralis rather than to OpenSBI.

Then, simply run:

./nsign p550.cfg

To build the final image.

Flashing the Board

Before starting, ensure the boot can be booted with the vendor images. Refer to the user guide and the software reference manual if you encounter any issue.

First, set the boot pins to 0011, as in the image below:

This corresponds to the USB boot mode. Then connect the USB cables as depicted below:

Connect both cables to a host Linux machine (we could not flash the image from macOS). Power the board on, two devices should show up:

  • ttyUSB3: the serial port of the microcontroler.
  • ttyUSB2: the serial port of the main CPU.

In addition, the host machine should detect a new drive: this is where we will upload the image. To flash the image, copy p550_mliralis.bin created with nsign earlier in the ESWIN-2030 drive (exact path may vary):

 cp p550_miralis.bin /run/media/username/ESWIN-2030/

You should see the boot sequence starting on ttyUSB2, with the full boot taking a few minutes. Miralis is now running on the P550, virtualizing OpenSBI.

To reset the board programatically, run reboot cold on ttyUSB3, then copy a new image to the board.