一、配置 Ubuntu 系统国内源
1. 备份原始源文件
sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
2. 编辑系统源配置文件
sudo nano /etc/apt/sources.list.d/ubuntu.sources
将文件内容替换为以下任意一个国内源(以清华源为例):
Types: deb
URIs: http://mirrors.tuna.tsinghua.edu.cn/ubuntu
Suites: noble noble-updates noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
3. 更新系统
sudo apt update && sudo apt upgrade -y
二、安装 Docker 引擎
1. 安装依赖工具
sudo apt install -y ca-certificates curl gnupg
2. 添加 Docker 官方 GPG 密钥(国内镜像源)
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
3. 添加 Docker 国内软件源
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
4. 安装 Docker 引擎及插件
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
5. 配置 Docker 国内镜像加速器
创建 Docker 配置文件
sudo nano /etc/docker/daemon.json
添加以下国内镜像源(推荐组合使用 3-4 个):
{"registry-mirrors": ["https://docker.m.daocloud.io","https://hub-mirror.c.163.com","https://mirror.baidubce.com","https://docker.mirrors.ustc.edu.cn"]
}
6. 配置代理服务器(若有需要)
如果你处于代理环境中,需要配置 Docker 走代理:
# 创建 systemd 配置目录
sudo mkdir -p /etc/systemd/system/docker.service.d# 创建代理配置文件
sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf <<-'EOF'
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:10808/"
Environment="HTTPS_PROXY=http://127.0.0.1:10808/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
EOF
7. 重启 Docker 服务
重新加载配置并重启 Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
8. 验证安装
sudo docker run hello-world
应输出 Hello from Docker!
表示安装成功。
三、部署 Chipyard docker
1. 下载chipyard镜像
从docker hub下载的chipyard镜像所有依赖和工具链都已经安装好了
chipyard镜像需要下载15G数据,解压下来40G+,需要提前做好准备,防止系统资源不足。
sudo docker pull ucbbar/chipyard-image
下载完之后可用通过: sudo docker images 这个条命令进行确认
2. 登入chipyard docker 镜像
注意一定要带上bash参数,要不然tab键会用不了。
sudo docker run -it ucbbar/chipyard-image bash
登入之后 可以看到在/root目录下的,chipyard目录
3. 生成默认配置的rocket core
编译器先修复一个bug,需要在主目录下/root/chipyard/
variables.mk 的文件尾部加一行:
override SBT_OPTS += -DfirrtlVersion=1.4.1
修改后如下:
根据自己的内存大小 调整一下配置参数,可以将其配置在.bashrc 文件中,source ~/.bashrc
export SBT_OPTS="-Xmx6g -XX:+UseG1GC"
或者在 Chipyard 根目录的 build.sbt
或工具脚本中添加 JVM 参数:
// 在build.sbt中添加以下配置
javaOptions in ThisBuild += "-Xmx8g"
javaOptions in ThisBuild += "-XX:+UseG1GC"
生成rocket ,
cd /root/chipyard/sims/verilator
make CONFIG=RocketConfig -j
编译结果如下: