Basic Guide To Linux Installation with Firemarshal:
Note: This tutorial was written with the needs of the bring-up class in mind and therefore references internals that may need to be adapted to your use case. You may be able to access the original Google Drive version here. It is assumed you have Baremetal IDE setup.
Setup
0.
To ssh into bwrc-amd2, first regularly ssh into username@bwrcrds1.eecs.berkeley.edu or your corresponding machine.
1.
Setup Chipyard while ssh’ed into username@bwrc-amd2.eecs.berkeley.edu
by cloning the Chipyard repo into your /tools/C/\<INSERT USERNAME HERE\>
directory:
- Run to clone:
git clone https://github.com/ucb-bar/chipyard.git
- Checkout correct version of Chipyard:
git checkout 1.13.0
2.
Make sure you have Ethan’s bring up environment sourced (if you have access):
source /tools/C/ee290-fa24-2/ee290-env.sh
- Else
source ./env.sh
, the standard Chipyard environment.
3.
Run in the base Chipyard directory to initialize some of Chipyard’s submodules
./scripts/init-submodules-no-riscv-tools.sh
4.
Navigate to the FireMarshal folder at chipyard/software/firemarshal
.
cd /tools/C/\<INSERT USERNAME HERE\> /chipyard/software/firemarshal
5.
Run to initialize FireMarshal’s submodules.
./init-submodules.sh
6.
Source the Chipyard environment from the base Chipyard directory:
source ./env.sh
7.
“By default, FireMarshal is setup to work with FireSim. Instead, we want to target the prototype platform. This is done by switching the FireMarshal “board” from “firechip” to “chipyard” using marshal-config.yaml”
-
This means adding the line “board-dir : ‘boards/chipyard’“ to your marshal-config.yaml file. This file should be in your fire marshal directory
-
If the file does not exist, feel free to make a new one (although one should already exist) and include the
8.
Since the basic linux image doesn’t have the correct device tree, copy over the device tree from the DSP24 design:
/scratch/eygao/sp24-chips/vlsi/generated-src/chipyard.harness.TestHarness.DSPConfig/chipyard.harness.TestHarness.DSPConfig.dts
9.
Edit this file (chipyard.harness.TestHarness.DSPConfig.dts
).
-
Delete the htif section (this is broken on the chip currently and is not needed)
-
Adjust the frequency to match your desired baud rate for the flag L1 (for the remainder of this guide the frequency 80MHz in L1)
- My basic understanding of this is that currently the unedited device tree is expecting the clock to be at 500MHz with a baudrate of 115200, which is beyond what we are able to run the chip on. To fix this we edit the clock speed down to something the chip is capable of doing, which will update the baudrate divisor to keep our baudrate at 115200.
10.
Use DTC to turn our device tree file into a device tree binary that FireMarshal can use:
dtc < chipyard.harness.TestHarness.DSPConfig.dts > updated_dsp24dt.dtb
-
In this case
chipyard.harness.TestHarness.DSPConfig.dts
was the name of the device tree file andupdated_dsp24dt.dtb
is the name of the destination file, feel free to name your destination file as you wish.- DTC will place your .dtb file in your current location
<
and>
indicate input and output file
11.
Add this flag in the firmware options within the br-base.json
in the chipyard/software/firemarshal/boards/chipyard/base-workloads
:
"opensbi-build-args" : "FW_FDT_PATH=/scratch/eygao/chipyard1-13/spike.dtb"
Should look like this:
12. Disable SemiHosting
From debugging, we found it necessary to disable SemiHosting, steps to do this:
1.
Open this file with your favorite text editor:
chipyard/software/firemarshal/boards/chipyard/firmware/opensbi/platform/generic/configs/defconfig
2.
Change the line containing SERIAL_SEMIHOSTING from y to n:
CONFIG_SERIAL_SEMIHOSTING=y -> CONFIG_SERIAL_SEMIHOSTING=n
3.
Next open this file:
chipyard/software/firemarshal/boards/chipyard/firmware/opensbi/platform/generic/platform.c
4.
Change the if statement containing semihosting to always run fdt_serial_init():
5.
Finally open this file:
chipyard/software/firemarshal/boards/chipyard/firmware/opensbi/lib/utils/serial/semihosting.c
6.
Set both of the booleans relating to semihosting to false:
static bool _semihosting_enabled = false;
static bool try_semihosting = false;
Build Image
13.
Attempt to build a Linux image:
./marshal -d build br-base.json
-
Here the -d indicates --nodisk or initramfs
-
Can add -v to print debug messages while running, can add -v to get verbose debug messages
14.
Attempt to Launch the image in terminal to see if the image works
-
./marshal -d launch br-base.json -s -
Create a new terminal to exit -
Currently with these changes, the simulation should not work! This is fine :^)
15.
Find the built image at:
/scratch/<INSERT_USERNAME>/chipyard/software/firemarshal/images/chipyard/br-base/br-base-bin-nodisk
16.
Since this image is on the amd2 server, we need to copy it over to the local BWRC machines for us to load the binary onto the chips, copy the file over to your bwrcrdsl-1 directory (as one line):
scp /scratch/<INSERT_USERNAME>/chipyard/software/firemarshal/images/chipyard/br-base/br-base-bin-nodisk <INSERT_USERNAME>@bwrcrdsl-1.eecs.berkeley.edu:/tools/C/<Continue Path to your Build Folder>
Credits
Google Drive doc written by Michael McCulloch in Fall 2024.
Content taken from the FireMarshal Chipyard Documentation and Ethan Gao.