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!
Video
If you prefer this content in video format, it is 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.shInstall 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”.
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.runLicensing
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.gzGet 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.shCopy and paste:
#!/bin/bash
LMGRD_DIR="/usr/local/microchip/licensing_daemon"
${LMGRD_DIR}/lmgrd -c ${LMGRD_DIR}/license.dat -log /tmp/lmgrd.logAnd then:
sudo chmod a+x start_lmgrd.shI 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.shCopy and paste this:
export LM_LICENSE_FILE=1702@starwaredesign.com
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.shcopy 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.shIf you see no such file or directory, install the missing lsb-core package.
sudo apt install lsb-coreAnd start libero
source /usr/local/microchip/env_libero_2023.2.sh
liberoThe 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_mssBuilding 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_designClone the repository with the FPGA source code:
git clone https://github.com/polarfire-soc/polarfire-soc-video-kit-reference-designAt the time of creating this blog post, 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-tkConfigure 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/fpgenprogUse the default configuration for the video kit:
make BOARD=mpfs-video-kit defconfigHere 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 programBuilding the Yocto image
Let’s build the Yocto image. Install repo if you haven’t done it before.
sudo apt install repoSet 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.xmlSync the repo:
repo sync
repo rebaseMake 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-toolsAnd now initialise the environment
. ./meta-polarfire-soc-yocto-bsp/polarfire-soc_yocto_setup.shNote 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-cliThis 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/rootAnd now write the image:
sudo bmaptool copy tmp-glibc/deploy/images/mpfs-video-kit/mpfs-dev-cli-mpfs-video-kit.wic /dev/sdbNote 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/ttyACM1Disclaimer
All trademarks, logos, and brand names shown on this blog post are the property of their respective owners. The use of these trademarks does not imply any affiliation with, or endorsement by, their owners. This video is intended for educational/entertainment/informational purposes only, and no copyright infringement is intended.


