Microchip Polarfire SoC series - #1 Installing the tools and building the video kit reference design
Welcome to the first blog post in the Microchip PolarFire SoC series! I am going to show you how to set up the tools, build the reference design, and program the board.
More blog posts are coming, diving deeper into the tools, device features, and much more!
Full disclaimer: this video is not sponsored by Microchip and the video kit has been bought by Starware Design.
Video
You can find this blog post in video format on YouTube (embedded below).
Installing the tools
Download the 2023.2 version of Libero SoC since the reference design currently supports this version. Also download SoftConsole to build the HSS firmware. We’re going to use SoftConsole 2022.2.
Uncompress the zip file and start the Libero installer.
unzip Libero_SoC_v2023.2_lin.zip
cd Libero_SoC_v2023.2
sudo ./launch_installer.sh
Install it in /usr/local/microchip. The installer will install all the required dependencies.
Just be mindful that:
- You can’t move the installation directory after the software has been installed
- To uninstall the software you can’t simply delete the directory. You will not be able to re-install the software in the same directory again. You have to edit “.com.zerog.registry.xml” this file either in your home directory or in /var if you installed the software as root
If you need further information there is a very good document called “Libero SoC Linux Setup User Guide” link.
Install SoftConsole
cd ..
chmod a+x Microchip-SoftConsole-v2022.2-RISC-V-747-linux-x64-installer.run
sudo ./Microchip-SoftConsole-v2022.2-RISC-V-747-linux-x64-installer.run
Licensing
Download the licencing daemons from the microchip website
Create a directory for the licensing daemons and extract the archive
sudo mkdir /usr/local/microchip/licensing_daemon
cd /usr/local/microchip/licensing_daemon
sudo tar xzf /home/matteo/work/tools/Linux_Licensing_Daemon_11.19.6.0_64-bit.tar.gz
Get the licence from Microchip Direct. For the Polarfire video kit, get the 1 year silver floating free licence.
Get the MAC address using ifconfig. Remove the colons from the MAC address and send the license request. It will take a few minutes for the licence to be generated.
Edit the license file to add the hostname and the path of the license daemons.
Configuring the environment
Let’s create a script to run the license daemons:
sudo vi start_lmgrd.sh
Copy and paste
#!/bin/bash
LMGRD_DIR="/usr/local/microchip/licensing_daemon"
${LMGRD_DIR}/lmgrd -c ${LMGRD_DIR}/license.dat -log /tmp/lmgrd.log
And then
sudo chmod a+x start_lmgrd.sh
I like to create scripts to start the licence daemons since I have multiple FPGA environments on the same PC. Otherwise you can create a script to run the daemons at startup using systemd.
Let’s create a script with all the environment variables like port and file name for the licence server, paths, etc. You could add these to your bashrc file, but it is easier to have multiple versions of the tools if you have a script to configure the environment for each tool.
sudo vi /usr/local/microchip/env_libero_2023.2.sh
Copy and paste this
export LM_LICENSE_FILE=1702@localhost
export LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH}
export DISPLAY=:0
export LINUX_HTMLREADER=/usr/bin/firefox
export PATH=/usr/local/microchip/Libero_SoC_v2023.2/Libero/bin:/usr/local/microchip/Libero_SoC_v2023.2/Libero/bin64:${PATH}
then
sudo vi /usr/local/microchip/env_softconsole_2022.2.sh
copy and paste
export LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH}
export DISPLAY=:0
export LINUX_HTMLREADER=/usr/bin/firefox
export PATH=/usr/local/microchip/SoftConsole-v2022.2-RISC-V-747:${PATH}
Now let’s start the license daemons
/usr/local/microchip/start_lmgrd.sh
If you see no such file or directory, install the missing lsb-core package.
sudo apt install lsb-core
And start libero
source /usr/local/microchip/env_libero_2023.2.sh
libero
The vault is where Libero stores all the IP cores. Since Libero was installed in /usr/local, the default vault path is not writable by a normal user.
So change it to a sub directory inside our home directory.
Now that we have installed Libero SoC let’s build the FPGA image for the video kit reference design.
The MSS configuration
The Microprocessor Subsystem (MSS) is configured using the PolarFire SoC MSS Configurator. This software tool takes user inputs and generates an MSS configuration file (.xml) along with an MSS component file (.cxz). The XML file is used by the PolarFire SoC Configuration Generator to generate configuration header files for bare metal applications or for the HSS. The MSS component file can be imported into a Libero SoC design and used in the FPGA design flow.
You can configure:
• Peripherals
• DDR Memory
• L2 Cache
• Crypto
• MSS to/from Fabric Interface Controllers
• Clocks
• MSS I/O Attributes
• Memory Partition and Protection
The repository for the FPGA bitstream already has the MSS configuration file for the video kit.
You can launch the configurator with:
pfsoc_mss
Building the FPGA bitstream
Let’s create a directory for the video kit reference design
mkdir -p projects/video_kit_reference_design
cd projects/video_kit_reference_design
Clone the repository with the FPGA source code
git clone https://github.com/polarfire-soc/polarfire-soc-video-kit-reference-design
At the time of creating this video, the latest version of the reference design supports Libero SoC 2023.2.
Make sure to check the Libero SoC version supported when you download the reference design.
Start libero.
To build the FPGA bistream:
- Open the execute script dialog (CTRL + U)
- Execute the "MPFS_VIDEO_KIT_REFERENCE_DESIGN.tcl" script
- Generate the bitstream clicking on “Generate FPGA Array data”
- Make sure the board is powered up and the JTAG programmer USB port is connected to your PC
- Double click on “Run Program Action” to build the bitstream and program the board
Building the HSS
Clone the HSS repository
git clone https://github.com/polarfire-soc/hart-software-services.git
cd hart-software-services/
Install python tk if you haven’t done already
sudo apt install python3-tk
Configure the environment
export SC_INSTALL_DIR=/usr/local/microchip/SoftConsole-v2022.2-RISC-V-747/
export PATH=$PATH:$SC_INSTALL_DIR/python3/bin:$SC_INSTALL_DIR/riscv-unknown-elf-gcc/bin
export FPGENPROG=/usr/local/microchip/Libero_SoC_v2023.2/Libero/bin64/fpgenprog
Use the default configuration for the video kit
make BOARD=mpfs-video-kit defconfig
Here is where you can change the XML file generated by the Polarfire SoC MSS configurator.
For the video kit, the repository already has the correct XML file.
Build and program the HSS
make BOARD=mpfs-video-kit -j8
make BOARD=mpfs-video-kit program
Building the Yocto image
Let’s build the Yocto image.
Install repo if you haven’t done it before.
sudo apt install repo
Set email address and name for the git repo if you haven’t done it before. Clone the repository with the repo manifest:
mkdir yocto
cd yocto
repo init -u
https://github.com/polarfire-soc/polarfire-soc-yocto-manifests.git -b main -m default.xml
Sync the repo:
repo sync
repo rebase
Make sure you have all the packages required by yocto:
sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint xterm python3-subunit mesa-common-dev zstd liblz4-tool python3-distutils bmap-tools
And now initialise the environment
. ./meta-polarfire-soc-yocto-bsp/polarfire-soc_yocto_setup.sh
Note the dot at the beginning of the command line. We have a few options for target board and image types. Let’s build the development image for the video kit.
MACHINE=mpfs-video-kit bitbake mpfs-dev-cli
This will create an image with a root file system. It will take some time based on your Internet connectivity speed and the number of cores of your PC.
Let’s use bmap to write the image to the micro SD card. Note that this will erase the entire card. Insert the micro SD card in your PC and check the device name with dmesg. Unmount the SD card. In this case, I have written the SD card previously so I unmount the boot and root partitions
cd build
umount /media/matteo/boot
umount /media/matteo/root
And now write the image
sudo bmaptool copy tmp-glibc/deploy/images/mpfs-video-kit/mpfs-dev-cli-mpfs-video-kit.wic /dev/sdb
Note that I used sdb and not sdb1, which means the entire sd card.
First boot
Connect your PC to the UART-to-USB port on the board. Open the first two serial ports: the first one is the HSS (Hart software services) and the second one is Yocto/Linux.
Get the ports device name from dmesg and use picocom to open the serial ports.
picocom -b 115200 /dev/ttyACM0
picocom -b 115200 /dev/ttyACM1