WSL2(ubuntu) + VS code
RISC-V SoC FPGA Development Environment Setup Guide (Windows + VS Code + WSL2)
This document explains how to set up a complete RISC-V software development environment using VS Code + WSL2 (Ubuntu) on a Windows laptop, along with both the open-source FPGA toolchain and the Gowin IDE required for Tango Nano 9K FPGA development.
During the seminar, participants will obtain the training materials and exercises from a GitHub repository prepared for this course.
1. System Requirements
-
Windows 10 or Windows 11
-
Internet access
-
At least 10 GB free disk space
-
Administrator privileges
2. Development Environment Overview
The seminar uses a two-layer development environment:
Layer 1 — Windows (Application Layer)
| Tool | Purpose |
|---|---|
| Visual Studio Code (VS Code) | Main editor; integrates with WSL2 for Linux-side development |
| Gowin IDE | Commercial FPGA toolchain for the Tango Nano 9K |
| Git for Windows (optional) | Additional Git tools, GUIs, etc. |
Layer 2 — WSL2 Ubuntu (Development/Build Layer)
All FPGA and RISC-V compilation is performed inside WSL2 (Ubuntu).
The following tools will be installed automatically:
| Tool | Purpose |
|---|---|
| riscv64-unknown-elf-gcc | RISC-V cross-compiler (C → ELF) |
| Yosys | RTL synthesis |
| nextpnr-ice40 | FPGA place & route |
| IceStorm (icepack / iceprog) | Bitstream generation & FPGA programming |
| OpenOCD | On-chip debug / SoC bring-up |
A one-command script will install the complete toolchain.
3. GitHub Repository for Training Materials
The seminar uses a GitHub repository that contains:
-
Training slides
-
RTL (Verilog) examples
-
RISC-V sample code (C and Assembly)
-
FPGA projects for each lab
-
Auto-installation scripts for the environment
Participants will clone the repository as follows:
git clone https://github.com/<seminar-org>/<seminar-repo>.git
(The exact URL will be provided during the seminar.)
4. Setting Up WSL2 (Ubuntu)
A detailed setup guide will be provided in a separate document.
Summary:
-
Enable Windows Subsystem for Linux (WSL2)
-
Install Ubuntu from the Microsoft Store
-
Set username and password on first launch
-
Install Remote – WSL extension in VS Code
-
Open a project folder using “Open in WSL”
WSL2 will act as your Linux build environment.
5. Installing the RISC-V + FPGA Toolchain (WSL2)
The seminar GitHub repository provides a one-command installation script:
curl -sSL https://raw.githubusercontent.com/<org>/<repo>/install/install_riscv_soc_fpga_tools.sh | bash
This script automatically installs:
-
Yosys (synthesis)
-
nextpnr-ice40 (place & route)
-
IceStorm (bitstream tools)
-
riscv64-unknown-elf-gcc (compiler)
-
OpenOCD
-
All required dependencies
No manual compilation or PATH setup is required.
6. Installing Gowin IDE (Windows)
-
Download Gowin IDE from the official Gowin Semiconductor website
-
Install the Tango Nano 9K device library
-
Confirm that the USB programmer driver is correctly installed
Gowin IDE will be used for synthesis, P&R, and programming for Gowin FPGAs.
7. What You Will Learn in the Seminar
The seminar covers the complete RISC-V SoC development flow:
Software (C → Assembly → Binary → MMIO)
-
C to Assembly conversion
-
Understanding the RISC-V ISA
-
Bare-metal programming (GPIO / Timer / Interrupts)
Hardware (Verilog → Logic → FPGA)
-
RTL design using Verilog
-
Synthesis and P&R using Yosys + nextpnr
-
Building a Mini SoC (CPU + UART + Timer + GPIO)
-
Implementing custom hardware peripherals
Advanced Topics
-
Pipeline CPU (5-stage RV32I)
-
Comparing PicoRV32 vs. Pipeline architectures
-
Debugging using OpenOCD
-
Running RISC-V software on a real FPGA SoC
All exercises, projects, and templates are provided in the GitHub repository.
_____________________________________________
? picoRISC-V SoC on FPGA (Tango Nano) セミナー
開発環境セットアップ手順書
(Windows + WSL2 + VS Code + Gowin IDE)
? 概要
この手順書では、Windows ノートPC上で
VS Code + WSL2(Ubuntu) を利用した RISC-V ソフトウェア開発環境と、
オープンソース FPGA ツールチェーン + Gowin IDE を構築する方法を説明します。
セミナーでは、GitHub に公開されたリポジトリを利用して設計教材と課題を取得します。
1️⃣ 事前確認
| 項目 | 内容 |
|---|---|
| OS | Windows 10 / 11 (64bit) |
| 管理者権限 | 必須(WSL機能の有効化に必要) |
| ストレージ空き容量 | 約 15GB 以上推奨 |
| インターネット | 初回セットアップに必要 |
| ハードウェア | Tango Nano (Gowin FPGA) ボード |
| アカウント | GitHub アカウント必須 |
2️⃣ 必要ツール一覧
? ソフトウェア設計系(RISC-V)
| ツール | 用途 |
|---|---|
| RARS | RISC-V アセンブリ実行環境(教育用) |
| gcc-riscv64-unknown-elf | クロスコンパイラ(RISC-V向けC開発) |
| Spike | RISC-V 公式 ISA シミュレータ |
| Python3 | スクリプト実行、補助ツール |
| VS Code | 統合エディタ |
| WSL2 + Ubuntu | Linux 開発環境 |
? ハードウェア設計系(Verilog → FPGA)
| ツール | 用途 |
|---|---|
| Icarus Verilog | RTLシミュレーション |
| Yosys | 合成(Verilog → ネットリスト) |
| nextpnr | 配置配線ツール |
| GTKWave | 波形表示 |
| Gowin IDE | FPGA 実機書き込み・デバイス設定 |
3️⃣ WSL2 + Ubuntu の導入
-
管理者権限の PowerShell を開き、以下を実行:
wsl --install -d Ubuntu-22.04
-
再起動後、Ubuntu の初回設定を行う(ユーザ名・パスワード設定)。
4️⃣ Ubuntu 内の基本ツールセットアップ
sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential git make python3 python3-pip curl wget unzip
5️⃣ RISC-V ツールチェーンの導入
(1) RARS
Javaが必要です:
sudo apt install -y openjdk-17-jre
mkdir -p ~/tools && cd ~/tools
wget https://github.com/TheThirdOne/rars/releases/download/v1.6/Rars1_6.jar
起動例(VS Code のターミナルから):
java -jar ~/tools/Rars1_6.jar
(2) RISC-V GCC クロスコンパイラ
Ubuntu 22.04 では次のようにインストール可能:
sudo apt install -y gcc-riscv64-unknown-elf
確認:
riscv64-unknown-elf-gcc --version
(3) Spike (RISC-V シミュレータ)
sudo apt install -y spike pk
または最新版を使用する場合:
sudo apt install -y git autoconf automake autotools-dev libmpc-dev libmpfr-dev libgmp-dev gawk bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
git clone https://github.com/riscv-software-src/riscv-isa-sim.git
cd riscv-isa-sim
mkdir build && cd build
../configure --prefix=/opt/riscv
make -j$(nproc)
sudo make install
6️⃣ FPGA 用ツールチェーン(オープンソース)
sudo apt install -y iverilog gtkwave yosys nextpnr-ice40 icestorm openfpgaloader
確認:
yosys --version
nextpnr-ice40 --version
iverilog -V
7️⃣ FPGA 実機開発(Gowin IDE)
-
Gowin Semiconductor公式サイト から
Gowin IDE 最新版(Windows版) をダウンロード・インストール。 -
ライセンスを「無料(教育向け)」で申請・登録。
-
WSL2 内で生成した bitstream (
.fsなど) を Windows 側にコピーして
Gowin IDE で FPGA へ書き込み。例:
cp build/top.fs /mnt/c/Users/<ユーザ名>/Documents/GowinProjects/
8️⃣ GitHub から教材を取得
cd ~
git clone https://github.com/<seminar-repo>.git
cd <seminar-repo>
code .
VS Code が開いたら、Remote – WSL で Ubuntu に接続された状態で作業します。
9️⃣ サンプルビルド・シミュレーション
make sim
gtkwave dump.vcd
または FPGA 用ビルド:
make synth
make pnr
? トラブルシューティング
| 症状 | 対応策 |
|---|---|
| FPGA 書き込みができない | Windows 側の Gowin Programmer を使用 |
riscv64-unknown-elf-gcc が見つからない |
sudo apt install gcc-riscv64-unknown-elf 再実行 |
| WSL2 が USB にアクセスできない | FPGA 書き込みは Windows 側で実施 |
| Spike 実行でエラー | /opt/riscv/bin を PATH に追加 |
? 参考リンク
? 配布
この手順書は「picoRISC-V SoC on FPGA セミナー」教材の一部です。
受講生は個人の学習目的で自由に使用できます。
? 次の提案
次に以下のいずれかを作成できます:
-
GitHub リポジトリ構成例
(software/,hardware/,fpga/,docs/のフォルダ構成付き) -
自動セットアップスクリプト
(Ubuntu上でsetup_riscv_fpga.shを実行するだけで環境構築) -
Docker 代替版(再現性重視)手順書
どれを次に作成しましょうか?
あなた:
ChatGPT:
とても重要なポイントです。
結論から言うと──
? 設計ツールを完全に一括配布することは「部分的には可能」ですが、いくつか制約があります。
以下で、教育用セミナー(33名・ノートPC使用) という前提で
現実的かつ安全にツールを配布・導入する3つの方法を整理します。
✅ 1️⃣ 部分的に一括配布できるもの(可能)
| 種類 | 配布可否 | 方法 |
|---|---|---|
| WSL2 初期設定スクリプト | ✅ 可 | bashスクリプト (setup_riscv_fpga.sh) で自動構築 |
| RARS, Spike, open-source FPGAツール群 | ✅ 可 | GitHubリポジトリ内に .tar.gz や自動ダウンロードスクリプトを同梱 |
| 教材リポジトリ(課題・サンプル) | ✅ 可 | GitHub Classroom / private repo で配布 |
| 環境設定ファイル (.bashrc, VSCode settings.json) | ✅ 可 | 同梱可能。再現性を高められる |
つまり、「オープンソース系ツール+設定+教材」までは一括配布可能です。
実際には install_tools.sh などのスクリプトを実行すれば、自動で環境構築できます。
⚠️ 2️⃣ 一括配布が難しいもの(制約あり)
| ツール | 理由 |
|---|---|
| Gowin IDE | ライセンス条項により、再配布禁止。各自ダウンロードが必要。 |
| WSL2 本体 / Ubuntu | Windows の機能のため、ユーザーの権限で有効化する必要あり。 |
| riscv64-unknown-elf-gcc (バイナリ配布) | OS依存のため、自動スクリプトで apt 経由が現実的。 |
したがって、Gowin IDE だけは各自が公式サイトからダウンロード
(ライセンス認証あり)する手順を残すのが安全です。
? 3️⃣ 現実的な一括配布構成(おすすめ)
GitHub または USB メモリで以下を配布します:
picoRISCV_FGPA_Training/
├── README.md
├── setup_riscv_fpga.sh ← 一括インストールスクリプト
├── software/
│ ├── rars/ ← RARS jar同梱(MIT配布可)
│ ├── examples/
│ └── Makefile
├── hardware/
│ ├── verilog/
│ ├── sim/
│ └── Makefile
├── fpga/
│ ├── synth/
│ ├── bitstream/
│ └── Makefile
└── docs/
├── setup_manual.md
└── seminar_slides.pdf
setup_riscv_fpga.sh 例
#!/bin/bash
echo "=== picoRISC-V セミナー開発環境セットアップ ==="
sudo apt update && sudo apt install -y \
build-essential git make python3 python3-pip wget curl \
openjdk-17-jre gcc-riscv64-unknown-elf \
iverilog gtkwave yosys nextpnr-ice40 icestorm openfpgaloader
# RARS
mkdir -p ~/tools && cd ~/tools
if [ ! -f Rars1_6.jar ]; then
wget https://github.com/TheThirdOne/rars/releases/download/v1.6/Rars1_6.jar
fi
echo "=== セットアップ完了 ==="
echo "Gowin IDE は別途 Windows 側でインストールしてください。"
これにより、受講者は:
git clone https://github.com/<seminar-repo>.git
cd <seminar-repo>
bash setup_riscv_fpga.sh
と入力するだけで自動構築が可能です。
? 4️⃣ 配布方法の選択肢
| 方法 | 特徴 |
|---|---|
| GitHub Private Repo | 更新・課題配布が容易。要アカウント。 |
| USB メモリ配布 | インターネット制限下でも可。セットアップスクリプト同梱。 |
| ZIPファイル配布 | メール・クラウド配布可(RARSや教材のみ) |
? まとめ
| 要素 | 一括配布可否 | 備考 |
|---|---|---|
| RARS, Spike, ツール類 | ✅ 可能(スクリプト or 同梱) | |
| FPGA OSSツール | ✅ 可能(apt かバイナリ) | |
| Gowin IDE | ❌ 不可(公式サイトから各自DL) | |
| 環境構築の自動化 | ✅ 可能(setup_riscv_fpga.sh) | |
| 教材・課題 | ✅ 可能(GitHub / USB) |
もしよければ、
?「実際に配布できる一括インストールスクリプト(setup_riscv_fpga.sh)完成版」を
私の方で生成します。
-
aptで自動インストール
-
RARS同梱対応
-
インストールログを出力
-
Gowin IDE だけ案内を表示
作成しましょうか?
__________________________________________________________________
? Windows と WSL で共有する共通作業領域の作り方
1️⃣ Windows 側のフォルダを作る
例えば Windows のユーザーディレクトリに作ります:
-
エクスプローラーで:
C:\Users\<あなたのユーザー名>\Projects
-
ここを共通作業領域にします
-
必要ならサブフォルダも作る:
C:\Users\<あなた>\Projects\TestProject
2️⃣ WSL からそのフォルダにアクセス
Ubuntu-22.04 ターミナルで:
# Windows のフォルダに移動
cd /mnt/c/Users/<あなたのユーザー名>/Projects
# フォルダがあるか確認
ls
-
Windows 側で作った
TestProjectが見えれば OK
3️⃣ VS Code で開く
code .
-
左下に
WSL: Ubuntu-22.04と表示 -
これで WSL 内の環境で作業しつつ、Windows 側のファイルに直接アクセス できます
4️⃣ 推奨の運用方法
| 目的 | 場所 |
|---|---|
| 実際の開発(ビルド・パッケージ管理) | WSL 内 (~/projects) |
| ドキュメント・成果物・共有用 | Windows 側 (C:\Users\<あなた>\Projects) |
-
WSL 内でビルドして Windows 側に出力
-
複数の WSL からも同じフォルダにアクセス可能
? ワンポイント
-
Windows 側フォルダは
/mnt/c/...経由でアクセス -
WSL 内フォルダの方がファイル操作は高速
-
でも「複数 WSL や Windows と共有したい場合」は Windows 側フォルダが便利
希望なら、**この共有環境を使った開発テンプレート(プロジェクト作成・VS Code 設定・Python/Node 等の初期環境)**まで整える手順も作れます。
作ってほしいですか?
あなた:
ChatGPT:
もちろんです!ここまでの内容を 安全に分かりやすく整理 します。
作業手順、ポイント、推奨環境までまとめています。
? WSL + VS Code + 共通作業領域まとめ
1️⃣ WSL の確認と整理
WSL ディストリビューション
wsl --list --verbose
-
例:
* Ubuntu-22.04 Stopped 2
Ubuntu Stopped 2
推奨
-
Ubuntu-22.04 をメインで使用
-
長期サポート(2027年まで)
-
最新パッケージ・開発環境が揃いやすい
-
Microsoft 推奨
-
起動方法
wsl -d Ubuntu-22.04
2️⃣ VS Code Remote – WSL の確認
WSL 内で VS Code を起動
code .
左下の表示で確認
-
WSL: Ubuntu-22.04→ 正常 -
WSL: Ubuntu→ WSL 接続は正常だが旧ディストリビューションを使用中
トラブル対策(非破壊)
# VS Code Server を再インストール
rm -rf ~/.vscode-server
-
データは消えません
3️⃣ 共通作業領域の作り方
✅ Windows と WSL で共有する方法(推奨)
-
Windows 側にフォルダ作成
C:\Users\<あなた>\Projects
-
WSL からアクセス
cd /mnt/c/Users/<あなた>/Projects
ls
-
VS Code で開く
code .
-
左下に
WSL: Ubuntu-22.04が表示されれば成功
運用例
| 用途 | 推奨場所 |
|---|---|
| 開発・ビルド | WSL 内(~/projects) |
| 成果物・共有 | Windows 側 (C:\Users\<あなた>\Projects) |
-
メリット:複数 WSL や Windows から同じフォルダにアクセス可能
-
注意点:Windows 側フォルダは WSL 内フォルダより操作はやや遅い
4️⃣ 今後の進め方
-
Ubuntu-22.04 を起動 →
code .で WSL モード確認 -
Windows 側の共通フォルダにアクセスして作業
-
必要に応じて旧 Ubuntu のデータを移動
-
不要な旧 Ubuntu はバックアップ後に削除可能
? ポイントまとめ
-
Remote – WSL は正常に動作
-
Ubuntu-22.04 がメイン推奨
-
Windows 側と共有することで、複数環境から安全にアクセス可能
-
WSL 内での開発は高速、Windows 側は成果物・共有用に最適
__________________________________________________________________
VS Code + WSL2 で Remote‑WSL 拡張を使う手順
-
VS Code を Windows にインストール
-
まず Windows 側に Visual Studio Code をインストールしてください。Microsoft の公式サイトから取得可能。 Microsoft Learn+1
-
インストール時、「Add to PATH (code コマンドを使えるように)」 のオプションを有効にしておくと便利。 Microsoft Learn+1
-
-
Remote Development 拡張 (Remote‑WSL) をインストール
-
VS Code を起動 → 左サイドバーの「拡張機能 (Extensions)」を開く → 検索ボックスに
Remote - WSLと入力。 -
“Remote – WSL” 拡張を見つけて「Install (インストール)」。
-
あるいは、Remote Development 拡張パックをインストールして、WSL や SSH など複数のリモート拡張をまとめて導入する。 Microsoft Learn
-
-
WSL (Ubuntu など) を VS Code から開く
-
拡張が入ったら、VS Code の左下にリモート接続アイコン (>< のようなマーク) が現れます。 OAR CODE
-
そのアイコンをクリック → 「Remote-WSL: New Window」 を選択 → WSL (例:Ubuntu) 環境のウィンドウが立ち上がる。 OAR CODE+1
-
WSL 環境側でターミナルを開くと、ターミナルが WSL 内で動作していることを確認できます。 VSCode ドキュメント
-
-
VS Code 拡張 (Languages / ツール) を WSL 内にもインストール
-
拡張機能ビューで 「Remote – WSL での拡張 (WSL: Ubuntu など)」 タブに切り替えると、WSL 側にインストール可能な拡張が表示されます。 Microsoft Learn
-
例:Python 拡張、C/C++ 拡張、Git 拡張などは WSL 側にも入れておくと、WSL 内での開発が快適になります。 Qiita+1
-
-
WSL 環境でファイルを作成・編集
-
“Remote‑WSL: New Window” で開いた VS Code ウィンドウで、WSL 内 (たとえば
/home/ユーザー名/project/) のフォルダを開きます。 -
以降、VS Code のエディタ、ターミナル、拡張機能はすべて WSL (Ubuntu など) 内で動作。Linux ネイティブなツールチェイン (GCC, Make, Python など) もそのまま使える。 VSCode ドキュメント+1
-
-
終了時・再接続
-
作業が終わったらそのウィンドウを閉じても OK。次回また 「Remote‑WSL: New Window」 から WSL 環境を開けます。
-
WSL 側に入れた拡張がアップデートされると、再読み込み (Reload) を求められることがあります。
-
? メリット (講習環境で特に有用なポイント)
-
Windows の GUI (VS Code) を使いながら、Linux (WSL) 上の Linux ネイティブツールチェイン を使える。 VSCode ドキュメント
-
ファイルのパスやバイナリ互換の心配が減る (WSL 内のツールをそのまま使える)。 TechBizPlusD
-
拡張機能を WSL 内にインストールすることで、補完やデバッグが WSL で動作する環境に最適化される。 Microsoft Learn
もしよければ、講習資料 (スライド) 用に「VS Code + WSL2 環境構築」部分のスライド案を作れます。やりますか?
Ubuntu on Deocker
ChatGPT:
Perfect — you want to give students an Ubuntu-based development environment with hardware design tools (RISC-V toolchain, Yosys, GTKWave, etc.), using Docker Desktop and distributing via GitHub.
Let’s walk through the full workflow ?
? Goal
Students should be able to:
-
Clone your GitHub repo
-
Run
docker buildordocker runfrom Docker Desktop -
Get an Ubuntu environment with:
-
gcc-riscv64 (cross-compiler)
-
Spike (RISC-V simulator)
-
Yosys (synthesis)
-
GTKWave (waveform viewer)
-
? Step 1: Create Your Dockerfile
Create a new GitHub repository, e.g. riscv-lab-docker.
Inside it, add a file named Dockerfile:
# -----------------------------
# Ubuntu-based RISC-V development environment
# -----------------------------
FROM ubuntu:22.04
LABEL maintainer="Your Name <you@example.com>"
LABEL description="Ubuntu environment with RISC-V GCC, Spike, Yosys, GTKWave for educational use"
# Avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Update base system
RUN apt-get update && apt-get install -y \
git wget curl build-essential python3 python3-pip \
cmake ninja-build autoconf automake libtool \
libboost-all-dev libelf-dev pkg-config \
yosys gtkwave \
&& rm -rf /var/lib/apt/lists/*
# -----------------------------
# Install RISC-V toolchain
# -----------------------------
WORKDIR /opt
RUN git clone https://github.com/riscv/riscv-gnu-toolchain.git && \
cd riscv-gnu-toolchain && \
git submodule update --init --recursive && \
./configure --prefix=/opt/riscv --with-arch=rv64gc --with-abi=lp64d && \
make -j$(nproc)
ENV PATH="/opt/riscv/bin:${PATH}"
# -----------------------------
# Install Spike (RISC-V ISA Simulator)
# -----------------------------
RUN git clone https://github.com/riscv-software-src/riscv-isa-sim.git && \
cd riscv-isa-sim && \
mkdir build && cd build && \
../configure --prefix=/opt/riscv && \
make -j$(nproc) && make install
# -----------------------------
# Set working directory for students
# -----------------------------
WORKDIR /home/student
RUN useradd -ms /bin/bash student
USER student
CMD ["/bin/bash"]
? Step 2: Create Supporting Files (Optional)
In your repo, you might include:
-
Example RISC-V C files (
examples/hello.c) -
Example Verilog/Yosys projects
-
A
README.mdexplaining setup and usage
Example README.md:
# RISC-V Development Environment (Docker)
This image provides a ready-to-use Ubuntu environment with:
- RISC-V GCC toolchain
- Spike simulator
- Yosys
- GTKWave
## Requirements
- Docker Desktop (with WSL2 backend on Windows)
- Git
## Usage
### Clone this repository
```bash
git clone https://github.com/<yourusername>/riscv-lab-docker.git
cd riscv-lab-docker
Build the Docker image
docker build -t riscv-lab .
Run the environment
docker run -it --rm riscv-lab
You’ll be inside an Ubuntu shell with all tools ready.
---
## ☁️ Step 3: Push to GitHub
```bash
git init
git add .
git commit -m "Initial RISC-V Docker environment"
git branch -M main
git remote add origin https://github.com/<yourusername>/riscv-lab-docker.git
git push -u origin main
Students can now clone your repository and build the image locally.
? Optional: Publish Prebuilt Image via GitHub Container Registry
If you don’t want students to build from scratch (since it’s large), you can build and push it to GitHub Container Registry (GHCR).
1. Authenticate to GitHub Container Registry
echo YOUR_GITHUB_PAT | docker login ghcr.io -u YOUR_GITHUB_USERNAME --password-stdin
2. Tag and Push
docker tag riscv-lab ghcr.io/YOUR_GITHUB_USERNAME/riscv-lab:latest
docker push ghcr.io/YOUR_GITHUB_USERNAME/riscv-lab:latest
3. Students Pull and Run
docker pull ghcr.io/YOUR_GITHUB_USERNAME/riscv-lab:latest
docker run -it ghcr.io/YOUR_GITHUB_USERNAME/riscv-lab:latest
? Note for Windows Students (WSL2)
If students are on Windows, ensure:
-
Docker Desktop uses WSL2 backend
-
They have Ubuntu on WSL2 installed
-
They can run Docker commands from PowerShell or WSL2 terminal
✅ Summary
| Step | Action | Outcome |
|---|---|---|
| 1 | Create Dockerfile with all tools |
Reproducible environment |
| 2 | Push to GitHub | Students can clone easily |
| 3 | (Optional) Push to GHCR | Students skip building |
| 4 | Students pull/run | Identical setup for everyone |
Would you like me to optimize the Dockerfile (e.g., use prebuilt binaries for RISC-V GCC and Spike to make build time shorter)? It can take 30–60 minutes to compile from source otherwise.
あなた:
ChatGPT:
はい、できます ✅
学生は Docker Desktop 上で問題なく作業可能です。
特に、あなたが配布する Ubuntu ベースの Docker イメージを使えば、学生は自分の PC(Windows / macOS / Linux)上で同じ開発環境をすぐに使えるようになります。
以下で詳しく説明します?
? 1. 学生が使う環境
学生が Docker Desktop をインストールすれば、
どの OS でもあなたの Ubuntu 環境を実行できます:
| OS | 仕組み |
|---|---|
| Windows 10/11 | Docker Desktop が WSL2 (Windows Subsystem for Linux 2) 上で Ubuntu コンテナを動かします。 |
| macOS | Docker Desktop が 軽量な Linux VM を自動で作成して、その中で Ubuntu コンテナを実行します。 |
| Linux | そのまま Docker Engine 上でコンテナを動かせます。 |
つまり、学生のパソコンが Windows/macOS/Linux どれであっても、Ubuntu 環境を同一条件で再現可能です。
? 2. 学生が行う手順(Docker Desktop 使用)
例として、あなたの GitHub リポジトリに Dockerfile がある場合:
? ステップ 1: GitHub リポジトリを clone
git clone https://github.com/<yourusername>/riscv-lab-docker.git
cd riscv-lab-docker
? ステップ 2: Docker イメージをビルド(初回のみ)
docker build -t riscv-lab .
これで「riscv-lab」というイメージがローカルに作成されます。
? ステップ 3: コンテナを起動
docker run -it --rm riscv-lab
→ Ubuntu シェルが開き、
gcc-riscv64, spike, yosys, gtkwave などのツールが使えます。
☁️ 3. もし時間短縮したい場合(おすすめ)
Docker イメージを GitHub Container Registry (GHCR) または Docker Hub にアップロードしておくと、学生はビルドせずに済みます。
学生側の操作はたったこれだけ:
docker pull ghcr.io/<yourusername>/riscv-lab:latest
docker run -it ghcr.io/<yourusername>/riscv-lab:latest
⚙️ 4. Docker Desktop の設定ポイント(特に Windows)
Windows 学生には次の点を注意させてください:
-
Docker Desktop のバックエンドを WSL2 に設定
→ Docker Desktop の「Settings → General → Use WSL2 based engine」にチェック。 -
Ubuntu (WSL2) をインストール
→ Microsoft Store から Ubuntu を入れておくと良いです。 -
PowerShell または WSL2 ターミナルから Docker コマンド実行
これで全員が同じ Ubuntu 環境で作業可能です。
✅ まとめ
| 項目 | 内容 |
|---|---|
| ? 学生環境 | Windows/macOS/Linux + Docker Desktop |
| ? コンテナ内環境 | Ubuntu + RISC-V + Yosys + GTKWave |
| ⚙️ 必要操作 | git clone → docker build or docker pull → docker run |
| ? メリット | 全員が同一ツール環境で作業、インストールトラブルゼロ |
必要なら、
学生用の セットアップ手順書 (README) を日本語で整えたテンプレートも作れます。
希望しますか?(Docker Desktop の導入から実行までを含む PDF or Markdown 形式)
__________________________________________________________________
Ubuntu on Deocker
ChatGPT:
Perfect — you want to give students an Ubuntu-based development environment with hardware design tools (RISC-V toolchain, Yosys, GTKWave, etc.), using Docker Desktop and distributing via GitHub.
Let’s walk through the full workflow ?
? Goal
Students should be able to:
-
Clone your GitHub repo
-
Run
docker buildordocker runfrom Docker Desktop -
Get an Ubuntu environment with:
-
gcc-riscv64 (cross-compiler)
-
Spike (RISC-V simulator)
-
Yosys (synthesis)
-
GTKWave (waveform viewer)
-
? Step 1: Create Your Dockerfile
Create a new GitHub repository, e.g. riscv-lab-docker.
Inside it, add a file named Dockerfile:
# -----------------------------
# Ubuntu-based RISC-V development environment
# -----------------------------
FROM ubuntu:22.04
LABEL maintainer="Your Name <you@example.com>"
LABEL description="Ubuntu environment with RISC-V GCC, Spike, Yosys, GTKWave for educational use"
# Avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Update base system
RUN apt-get update && apt-get install -y \
git wget curl build-essential python3 python3-pip \
cmake ninja-build autoconf automake libtool \
libboost-all-dev libelf-dev pkg-config \
yosys gtkwave \
&& rm -rf /var/lib/apt/lists/*
# -----------------------------
# Install RISC-V toolchain
# -----------------------------
WORKDIR /opt
RUN git clone https://github.com/riscv/riscv-gnu-toolchain.git && \
cd riscv-gnu-toolchain && \
git submodule update --init --recursive && \
./configure --prefix=/opt/riscv --with-arch=rv64gc --with-abi=lp64d && \
make -j$(nproc)
ENV PATH="/opt/riscv/bin:${PATH}"
# -----------------------------
# Install Spike (RISC-V ISA Simulator)
# -----------------------------
RUN git clone https://github.com/riscv-software-src/riscv-isa-sim.git && \
cd riscv-isa-sim && \
mkdir build && cd build && \
../configure --prefix=/opt/riscv && \
make -j$(nproc) && make install
# -----------------------------
# Set working directory for students
# -----------------------------
WORKDIR /home/student
RUN useradd -ms /bin/bash student
USER student
CMD ["/bin/bash"]
? Step 2: Create Supporting Files (Optional)
In your repo, you might include:
-
Example RISC-V C files (
examples/hello.c) -
Example Verilog/Yosys projects
-
A
README.mdexplaining setup and usage
Example README.md:
# RISC-V Development Environment (Docker)
This image provides a ready-to-use Ubuntu environment with:
- RISC-V GCC toolchain
- Spike simulator
- Yosys
- GTKWave
## Requirements
- Docker Desktop (with WSL2 backend on Windows)
- Git
## Usage
### Clone this repository
```bash
git clone https://github.com/<yourusername>/riscv-lab-docker.git
cd riscv-lab-docker
Build the Docker image
docker build -t riscv-lab .
Run the environment
docker run -it --rm riscv-lab
You’ll be inside an Ubuntu shell with all tools ready.
---
## ☁️ Step 3: Push to GitHub
```bash
git init
git add .
git commit -m "Initial RISC-V Docker environment"
git branch -M main
git remote add origin https://github.com/<yourusername>/riscv-lab-docker.git
git push -u origin main
Students can now clone your repository and build the image locally.
? Optional: Publish Prebuilt Image via GitHub Container Registry
If you don’t want students to build from scratch (since it’s large), you can build and push it to GitHub Container Registry (GHCR).
1. Authenticate to GitHub Container Registry
echo YOUR_GITHUB_PAT | docker login ghcr.io -u YOUR_GITHUB_USERNAME --password-stdin
2. Tag and Push
docker tag riscv-lab ghcr.io/YOUR_GITHUB_USERNAME/riscv-lab:latest
docker push ghcr.io/YOUR_GITHUB_USERNAME/riscv-lab:latest
3. Students Pull and Run
docker pull ghcr.io/YOUR_GITHUB_USERNAME/riscv-lab:latest
docker run -it ghcr.io/YOUR_GITHUB_USERNAME/riscv-lab:latest
? Note for Windows Students (WSL2)
If students are on Windows, ensure:
-
Docker Desktop uses WSL2 backend
-
They have Ubuntu on WSL2 installed
-
They can run Docker commands from PowerShell or WSL2 terminal
✅ Summary
| Step | Action | Outcome |
|---|---|---|
| 1 | Create Dockerfile with all tools |
Reproducible environment |
| 2 | Push to GitHub | Students can clone easily |
| 3 | (Optional) Push to GHCR | Students skip building |
| 4 | Students pull/run | Identical setup for everyone |
Would you like me to optimize the Dockerfile (e.g., use prebuilt binaries for RISC-V GCC and Spike to make build time shorter)? It can take 30–60 minutes to compile from source otherwise.
あなた:
ChatGPT:
はい、できます ✅
学生は Docker Desktop 上で問題なく作業可能です。
特に、あなたが配布する Ubuntu ベースの Docker イメージを使えば、学生は自分の PC(Windows / macOS / Linux)上で同じ開発環境をすぐに使えるようになります。
以下で詳しく説明します?
? 1. 学生が使う環境
学生が Docker Desktop をインストールすれば、
どの OS でもあなたの Ubuntu 環境を実行できます:
| OS | 仕組み |
|---|---|
| Windows 10/11 | Docker Desktop が WSL2 (Windows Subsystem for Linux 2) 上で Ubuntu コンテナを動かします。 |
| macOS | Docker Desktop が 軽量な Linux VM を自動で作成して、その中で Ubuntu コンテナを実行します。 |
| Linux | そのまま Docker Engine 上でコンテナを動かせます。 |
つまり、学生のパソコンが Windows/macOS/Linux どれであっても、Ubuntu 環境を同一条件で再現可能です。
? 2. 学生が行う手順(Docker Desktop 使用)
例として、あなたの GitHub リポジトリに Dockerfile がある場合:
? ステップ 1: GitHub リポジトリを clone
git clone https://github.com/<yourusername>/riscv-lab-docker.git
cd riscv-lab-docker
? ステップ 2: Docker イメージをビルド(初回のみ)
docker build -t riscv-lab .
これで「riscv-lab」というイメージがローカルに作成されます。
? ステップ 3: コンテナを起動
docker run -it --rm riscv-lab
→ Ubuntu シェルが開き、
gcc-riscv64, spike, yosys, gtkwave などのツールが使えます。
☁️ 3. もし時間短縮したい場合(おすすめ)
Docker イメージを GitHub Container Registry (GHCR) または Docker Hub にアップロードしておくと、学生はビルドせずに済みます。
学生側の操作はたったこれだけ:
docker pull ghcr.io/<yourusername>/riscv-lab:latest
docker run -it ghcr.io/<yourusername>/riscv-lab:latest
⚙️ 4. Docker Desktop の設定ポイント(特に Windows)
Windows 学生には次の点を注意させてください:
-
Docker Desktop のバックエンドを WSL2 に設定
→ Docker Desktop の「Settings → General → Use WSL2 based engine」にチェック。 -
Ubuntu (WSL2) をインストール
→ Microsoft Store から Ubuntu を入れておくと良いです。 -
PowerShell または WSL2 ターミナルから Docker コマンド実行
これで全員が同じ Ubuntu 環境で作業可能です。
✅ まとめ
| 項目 | 内容 |
|---|---|
| ? 学生環境 | Windows/macOS/Linux + Docker Desktop |
| ? コンテナ内環境 | Ubuntu + RISC-V + Yosys + GTKWave |
| ⚙️ 必要操作 | git clone → docker build or docker pull → docker run |
| ? メリット | 全員が同一ツール環境で作業、インストールトラブルゼロ |
必要なら、
学生用の セットアップ手順書 (README) を日本語で整えたテンプレートも作れます。
希望しますか?(Docker Desktop の導入から実行までを含む PDF or Markdown 形式)
__________________________________________________________________
Ubuntu on Deocker
いいですね — 「」の動作検証手順を分かりやすくまとめます。
以下を順に実行すれば、イメージ/コンテナ/マウント/ツールが正しく動いているか確実に確認できます。
(Windows は PowerShell 表記、macOS は Terminal 表記で示します。)
1) 事前:イメージがあるか確認
PowerShell (Windows)
PS C:\> docker images
macOS Terminal
$ docker images
期待:riscv-edu(または riscv-workshop 等)という名前のイメージが一覧にある。
2) コンテナを起動して中に入る(マウント付き)
注意:PowerShell ではパス全体を引用符で囲むこと。
Windows (PowerShell)
PS C:\> docker run -it --name riscv-container -v "${env:USERPROFILE}\Documents\RISC-V-Workshop:/workspace" riscv-edu:latest /bin/bash
macOS (Terminal)
$ docker run -it --name riscv-container -v ~/Documents/RISC-V-Workshop:/workspace riscv-edu:latest /bin/bash
-
成功するとプロンプトが変わります(例):
root@3b7c5f1e8b2a:/workspace#
3) Ubuntu側での基本確認(コンテナ内で実行)
コンテナ内プロンプト(root@... や dockeruser@...)で実行してください。
-
OS 確認
root@container:/workspace# lsb_release -a
期待:Ubuntu 22.04 等が表示される。
-
カレントフォルダ確認(マウントが有効か)
root@container:/workspace# pwd
/root@container:/workspace# ls -la
期待:ホスト側 RISC-V-Workshop のファイルが見える(samples 等)。
-
インストール済みツール確認(例)
root@container:/workspace# which gcc-riscv64-unknown-elf || echo "riscv gcc not found"
root@container:/workspace# yosys -V || echo "yosys not found"
root@container:/workspace# spike --version || echo "spike not found"
期待:各ツールのバージョンやパスが返る/存在しない場合は not found が出る。
-
サンプルビルド(イメージに sample がある場合)
root@container:/workspace# cd samples
root@container:/workspace# make
root@container:/workspace# ./hello_riscv || echo "execution failed or not executable"
期待:ビルドが成功するか、あるいはクロスコンパイル不可のメッセージが出る(ツールの有無を確認できる)。
4) コンテナをバックグラウンドで起動して再接続する方法
-
バックグラウンド起動(対話不要な場合)
PS C:\> docker run -d --name riscv-container -v "${env:USERPROFILE}\Documents\RISC-V-Workshop:/workspace" riscv-edu:latest
-
後からアタッチ/シェルを開く
PS C:\> docker exec -it riscv-container /bin/bash
5) 使い終わったら停止・削除
停止:
PS C:\> docker stop riscv-container
削除:
PS C:\> docker rm riscv-container
イメージ削除(不要なら):
PS C:\> docker rmi riscv-edu:latest
6) よくあるトラブルと対処(チェックリスト)
-
docker: invalid reference format
→ マウント指定やイメージ名にスペースや不正文字がないか。PowerShellでは-v "${env:USERPROFILE}\Documents\RISC-V-Workshop:/workspace"のように全体を"で囲む。 -
Docker がダウンしている
→ Docker Desktop を起動、docker infoを実行してエラーを確認。 -
イメージがない
→docker imagesに無ければdocker build -t riscv-edu:latest .か、講師が用意したdocker pull username/riscv-edu:latestを使う。 -
マウントしたホストファイルが見えない
→ マウント先パスが正しいか。Windows の場合C:\Users\Name\...を使っているか確認。WSL2 や Docker Desktop のファイル共有設定も確認。 -
ツールが見つからない
→ Dockerfile でツールをインストールしているか確認。docker buildが成功したログ(エラー有無)をチェック。 -
起動が遅い/I/O が遅い
→ マウントフォルダが大きい、WSL2 のリソース不足、イメージサイズが大きい可能性。不要なファイルを除く、Docker Desktop のリソース設定を上げる。
7) 検証用ワンラインコマンド(手短に確認)
イメージがあるか確認
docker images | findstr riscv-edu # PowerShell/Windows
docker images | grep riscv-edu # macOS/Linux
コンテナ起動→簡易チェック→抜ける(ワンライナー)
docker run --rm -v "${env:USERPROFILE}\Documents\RISC-V-Workshop:/workspace" riscv-edu:latest /bin/bash -c "ls -la /workspace && lsb_release -a"
(--rm:終了時に自動削除、-c:複数コマンドを一度に実行)
もし今すぐ検証していてエラーが出ているなら、あなたが実行した正確なコマンドと出力(エラーメッセージ)を教えてください。
こちらで原因を特定して、具体的な修正コマンドを提示します。
acot-org/ ← GitHub Organization
├─ workshops-meta ← 全ワークショップの索引・スケジュール
├─ templates ← 受講者向けテンプレテンプレ(課題・READMEの雛形)
├─ common-labs ← 共通の演習ライブラリ・ユーティリティ(subtree/submodule)
├─ docker-images ← Dockerfile と GH Packages(イメージ)管理
├─ workshop-<name>-2025 ← ワークショップA(例: ACOT-RISC-V-2025)
├─ workshop-<name2>-2025 ← ワークショップB
└─ instructor-solutions-<name> ← 解答保管(private、講師のみアクセス)
workshop-riscv-2025/
├── README.md # 概要・スケジュール・注意事項
├── SCHEDULE.md # 日別スケジュール(Day1..Day10)
├── LICENSE
├── .github/
│ ├── workflows/
│ │ ├── release-daily.yml # 課題自動公開 or Dockerビルド
│ │ └── auto-create-issues.yml
│ └── ISSUE_TEMPLATE.md
├── slides/ # 公開スライド(講師版は別途)
│ ├── day01_intro.pdf
│ └── …
├── docker/ # (optional) Dockerfile, build scripts (講師用)
│ └── Dockerfile
├── day-01-setup/ # Dayごとの課題フォルダ(受講者用)
│ ├── README.md # 課題説明(目的・手順・提出物)
│ ├── starter/ # スタータコード(受講者が編集)
│ ├── tests/ # 自動採点用テスト(ある場合)
│ └── dataset/
├── day-02-…/ # Day02 ~ Day10
├── exercises/ # 追加の演習(全体共通)
└── docs/ # 講師向け補足(運営手順・リハーサルノート)
workshop-riscv-2025/
├── README.md # Overview of the workshop
├── SCHEDULE.md # 10-day schedule
├── .github/
│ └── workflows/
│ ├── release-daily.yml # (Code / Automation) Publish day-specific exercises
│ └── auto-grading.yml # (Code / Automation) Run auto-grading scripts
├── templates/ # (Template) Starter material templates
│ ├── day-01-template/
│ │ ├── README.md # Prompt: “Read instructions here, edit starter code in starter/”
│ │ └── starter/ # Starter code for students to edit
│ └── day-02-template/
│ └── …
├── common-labs/ # (Submodule / shared code) Utilities and libraries
│ └── riscv-lib/ # e.g., cloned as submodule
├── docker-images/ # (Code / Template) Dockerfile and build scripts
│ ├── Dockerfile # Prompt: “Build Docker image with `docker build -t acot/workshop:2025a .`”
│ └── entrypoint.sh
├── day-01/ # Day 1 exercises (actual code students work with)
│ ├── contents/ # (Template / Prompt) Exercise description
│ │ └── README.md # Prompt: “Follow instructions below to complete the exercise”
│ ├── starter/ # (Template / Code) Student editable code
│ │ └── main.c
│ ├── auto-grading/ # (Code / Automation) Scripts to check submissions
│ │ └── test_main.py # Prompt: “Run `python3 test_main.py` to test your code”
│ ├── answer/ # (Private Code / Instructor only)
│ │ └── solution.c # Instructor solution, not pushed to students
│ └── guidance/ # (Template / Optional) Hints
│ └── hints.md # Prompt: “Read only if stuck”
├── day-02/ … day-10/ # Same structure as day-01
└── docs/ # (Template / Instructor) Reference docs, setup guides
? Folder Roles
| Folder | Type | Prompt / Usage |
|---|---|---|
templates/ |
Template | For students to copy when creating their own repos (Use this template) |
common-labs/ |
Submodule / Shared | Shared code and libraries; synced via submodule or subtree |
docker-images/ |
Code / Template | Dockerfiles; students pull prebuilt image or build if needed |
day-XX/contents/ |
Template / Prompt | Exercise instructions; read before starting |
day-XX/starter/ |
Template / Code | Students edit these files |
day-XX/auto-grading/ |
Code / Automation | Scripts for automatic testing |
day-XX/answer/ |
Private / Code | Instructor solutions (not visible to students) |
day-XX/guidance/ |
Template / Optional | Optional hints for students |
.github/workflows/ |
Code / Automation | CI workflows for auto-grading, day release, docker builds |
docs/ |
Template / Instructor | Reference materials, instructor notes |
? Prompts in Practice
-
For students (starter folder):
-
“Edit
main.cto implement the required function.” -
“Use
maketo compile and./mainto run.” -
“Run tests with
python3 ../auto-grading/test_main.py.”
-
-
For auto-grading scripts:
-
“Compare student output against
answer/expected_output.txt.” -
“Return pass/fail status as CI check.”
-
-
For guidance folder:
-
“Optional: Read hints if stuck. Do not copy solutions.”
-
-
For Docker folder:
-
“Build the Docker image:
docker build -t acot/workshop:2025a .“ -
“Run the container:
docker run -it acot/workshop:2025a bash“
-
This structure ensures:
-
Clear separation between student code, instructor solutions, and shared resources.
-
Templates are used to generate student repositories safely.
-
Submodules or shared libraries are managed in one place (
common-labs/). -
Prompts are explicit for students and CI scripts.
ChatGPT:
Excellent — that message means your Ubuntu container is running, but the lsb_release tool (used to show Ubuntu version info) isn’t installed yet.
That’s common — not all minimal Ubuntu Docker images include it.
Let’s fix it inside your container step by step ?
? Step 1: Update the package list
At your container prompt (root@container:/workspace#), run:
apt update
? Step 2: Install lsb-release
Then install the package:
apt install -y lsb-release
This will download and install the tool.
? Step 3: Verify Ubuntu version
After installation, check:
lsb_release -a
You should see something like:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
? (Optional) — Show OS version another way
Even without lsb_release, you can check the version using:
cat /etc/os-release
That command always works and prints similar info:
NAME="Ubuntu"
VERSION="22.04.5 LTS (Jammy Jellyfish)"
✅ Summary
If you see lsb_release: command not found, just do:
apt update && apt install -y lsb-releaseいいですね — 「Ubuntu on Docker」の動作検証手順を分かりやすくまとめます。
以下を順に実行すれば、イメージ/コンテナ/マウント/ツールが正しく動いているか確実に確認できます。
(Windows は PowerShell 表記、macOS は Terminal 表記で示します。)
1) 事前:イメージがあるか確認
PowerShell (Windows)
PS C:\> docker images
macOS Terminal
$ docker images
期待:riscv-edu(または riscv-workshop 等)という名前のイメージが一覧にある。
2) コンテナを起動して中に入る(マウント付き)
注意:PowerShell ではパス全体を引用符で囲むこと。
Windows (PowerShell)
PS C:\> docker run -it --name riscv-container -v "${env:USERPROFILE}\Documents\RISC-V-Workshop:/workspace" riscv-edu:latest /bin/bash
macOS (Terminal)
$ docker run -it --name riscv-container -v ~/Documents/RISC-V-Workshop:/workspace riscv-edu:latest /bin/bash
-
成功するとプロンプトが変わります(例):
root@3b7c5f1e8b2a:/workspace#
3) Ubuntu側での基本確認(コンテナ内で実行)
コンテナ内プロンプト(root@... や dockeruser@...)で実行してください。
-
OS 確認
root@container:/workspace# lsb_release -a
期待:Ubuntu 22.04 等が表示される。
-
カレントフォルダ確認(マウントが有効か)
root@container:/workspace# pwd
/root@container:/workspace# ls -la
期待:ホスト側 RISC-V-Workshop のファイルが見える(samples 等)。
-
インストール済みツール確認(例)
root@container:/workspace# which gcc-riscv64-unknown-elf || echo "riscv gcc not found"
root@container:/workspace# yosys -V || echo "yosys not found"
root@container:/workspace# spike --version || echo "spike not found"
期待:各ツールのバージョンやパスが返る/存在しない場合は not found が出る。
-
サンプルビルド(イメージに sample がある場合)
root@container:/workspace# cd samples
root@container:/workspace# make
root@container:/workspace# ./hello_riscv || echo "execution failed or not executable"
期待:ビルドが成功するか、あるいはクロスコンパイル不可のメッセージが出る(ツールの有無を確認できる)。
4) コンテナをバックグラウンドで起動して再接続する方法
-
バックグラウンド起動(対話不要な場合)
PS C:\> docker run -d --name riscv-container -v "${env:USERPROFILE}\Documents\RISC-V-Workshop:/workspace" riscv-edu:latest
-
後からアタッチ/シェルを開く
PS C:\> docker exec -it riscv-container /bin/bash
5) 使い終わったら停止・削除
停止:
PS C:\> docker stop riscv-container
削除:
PS C:\> docker rm riscv-container
イメージ削除(不要なら):
PS C:\> docker rmi riscv-edu:latest
6) よくあるトラブルと対処(チェックリスト)
-
docker: invalid reference format
→ マウント指定やイメージ名にスペースや不正文字がないか。PowerShellでは-v "${env:USERPROFILE}\Documents\RISC-V-Workshop:/workspace"のように全体を"で囲む。 -
Docker がダウンしている
→ Docker Desktop を起動、docker infoを実行してエラーを確認。 -
イメージがない
→docker imagesに無ければdocker build -t riscv-edu:latest .か、講師が用意したdocker pull username/riscv-edu:latestを使う。 -
マウントしたホストファイルが見えない
→ マウント先パスが正しいか。Windows の場合C:\Users\Name\...を使っているか確認。WSL2 や Docker Desktop のファイル共有設定も確認。 -
ツールが見つからない
→ Dockerfile でツールをインストールしているか確認。docker buildが成功したログ(エラー有無)をチェック。 -
起動が遅い/I/O が遅い
→ マウントフォルダが大きい、WSL2 のリソース不足、イメージサイズが大きい可能性。不要なファイルを除く、Docker Desktop のリソース設定を上げる。
7) 検証用ワンラインコマンド(手短に確認)
イメージがあるか確認
docker images | findstr riscv-edu # PowerShell/Windows
docker images | grep riscv-edu # macOS/Linux
コンテナ起動→簡易チェック→抜ける(ワンライナー)
docker run --rm -v "${env:USERPROFILE}\Documents\RISC-V-Workshop:/workspace" riscv-edu:latest /bin/bash -c "ls -la /workspace && lsb_release -a"
(--rm:終了時に自動削除、-c:複数コマンドを一度に実行)
もし今すぐ検証していてエラーが出ているなら、あなたが実行した正確なコマンドと出力(エラーメッセージ)を教えてください。
こちらで原因を特定して、具体的な修正コマンドを提示します。
sub-
とても良い質問です。
ここでは、教育用ワークショップなどで使いやすいように、
「メインリポジトリ(親)」と「サブリポジトリ(子)」の設定方法」 を、
2通り(submodule と subtree)で具体的に説明します。
? 1. 概要:構成イメージ
例:
RISC-V-Workshop/ ← 親リポジトリ
├── day01-lab/ ← サブリポジトリ(1日目)
├── day02-lab/ ← サブリポジトリ(2日目)
└── docker/ ← 共通ツール
目的:
-
親リポジトリ = コース全体の管理
-
サブリポジトリ = 各日・各課題を独立して管理
? 2. submoduleを使う場合(独立して管理)
✅ 利点
-
各サブリポジトリを個別に開発・更新できる
-
共通教材を複数Workshopで再利用可能
⚙ 設定手順
① 親リポジトリを作成
GitHubでRISC-V-Workshop
というリポジトリを作る。
git clone https://github.com/yourname/RISC-V-Workshop.git
cd RISC-V-Workshop
② サブリポジトリを作成
GitHub上で、たとえば以下を作成:
-
day01-lab -
day02-lab
③ 親にサブリポジトリを追加
git submodule add https://github.com/yourname/day01-lab.git day01-lab
git submodule add https://github.com/yourname/day02-lab.git day02-lab
これで .gitmodules が自動生成されます:
[submodule "day01-lab"]
path = day01-lab
url = https://github.com/yourname/day01-lab.git
[submodule "day02-lab"]
path = day02-lab
url = https://github.com/yourname/day02-lab.git
④ コミット&プッシュ
git add .gitmodules day01-lab day02-lab
git commit -m "Add day01 and day02 as submodules"
git push
⑤ 学生・他講師がクローンする場合
git clone --recurse-submodules https://github.com/yourname/RISC-V-Workshop.git
※
--recurse-submodulesを忘れるとサブリポジトリは空になります。
? 3. subtreeを使う場合(統合して管理)
✅ 利点
-
サブリポジトリの内容が親リポジトリに完全に含まれる
-
git cloneだけで全部取得できる(学生にやさしい) -
操作がシンプル(教育現場向き)
⚙ 設定手順
① サブリポジトリを作成
GitHubで day01-lab を作成。
② 親リポジトリに追加
git remote add -f day01-lab https://github.com/yourname/day01-lab.git
git subtree add --prefix=day01-lab day01-lab main --squash
③ 更新があった場合
git subtree pull --prefix=day01-lab day01-lab main --squash
④ サブリポジトリ側に変更を戻す場合
git subtree push --prefix=day01-lab day01-lab main
? 4. 教育用Workshopでの推奨方針
| 用途 | 推奨 |
|---|---|
| 教師が教材を分担・共有 | submodule |
| 学生に配布・統一環境で利用 | subtree |
| Docker環境や共通ツールの共有 | submodule |
| 日毎の課題・演習をまとめたい | subtree |
? 5. 実践例(RISC-V Workshop構成)
RISC-V-Workshop/
├── docker/ ← 共通イメージ (submodule)
├── day01-lab/ ← subtree (Day 1)
├── day02-lab/ ← subtree (Day 2)
├── guidance/ ← ドキュメント
└── README.md
操作例:
# 共通Docker環境
git submodule add https://github.com/yourorg/riscv-docker.git docker
# 各日課題を統合
git remote add -f day01 https://github.com/yourorg/lab-day01.git
git subtree add --prefix=day01-lab day01 main --squash
必要であれば、上記の操作を自動化する
? 「workshop-setup.sh」スクリプト(自動生成スクリプト)
も作成できます。
作成しましょうか?(サブモジュール型・サブツリー型どちらにしますか?)
RISC-V FPGA Workshop – Ubuntu on Docker Setup Manual (Arty A7-T100 Focused)
0. Beginner’s Guide: What is PowerShell and Prompts?
PowerShell is a command window on Windows (like Terminal on macOS). It allows you to type commands instead of using the mouse. You will use PowerShell to:
- Create folders
- Run Docker commands
- Work with Git and Ubuntu inside Docker
Understanding Prompts
Prompts are automatic indicators that show your current environment. You do not type the prompt itself; you only type the commands after it.
| Environment | Prompt Example | What to Type |
|---|---|---|
| PowerShell (Windows) | PS C:\Users\YourName> |
type mkdir riscv-edu and cd riscv-edu after the prompt |
| macOS Terminal | $ |
type mkdir riscv-edu and cd riscv-edu after $ |
| Ubuntu inside Docker | root@container:/workspace# |
type make or ./hello_riscv after the prompt |
Example Commands:
- PowerShell:
PS C:\Users\YourName> mkdir riscv-edu
PS C:\Users\YourName> cd riscv-edu
- macOS Terminal:
$ mkdir riscv-edu
$ cd riscv-edu
- Ubuntu inside Docker:
root@container:/workspace# make
root@container:/workspace# ./hello_riscv
✅ Remember: Only type the command after the prompt. The prompt itself appears automatically.
How to Open PowerShell (Windows 10 or 11)
Method 1 – From Start Menu
- Click the Start Menu (bottom-left corner).
- Type PowerShell in the search box.
- You will see Windows PowerShell appear.
- Right-click it → select Run as administrator.
- A blue window opens. The title bar should say: Administrator: Windows PowerShell.
Method 2 – Shortcut
- Press Windows key + X, then choose Windows PowerShell (Admin).
1. Key Concept: Ubuntu Inside Docker
- Ubuntu runs inside Docker, not directly on Windows/macOS.
- All RISC-V/FPGA tools are installed inside Ubuntu during the Docker build.
- FPGA board used in this workshop: Arty A7-T100
- Simple RISC-V exercises can be tested in software simulation only, without the FPGA board.
Visual:
Host (Windows/macOS)
└── Docker
└── Ubuntu
└── RISC-V & FPGA Tools
2. Lecturer Workflow: Preparing Ubuntu + Tools
? On Host (PowerShell for Windows / Terminal for macOS)
- Create project folder:
PS C:\Users\YourName> mkdir riscv-edu
PS C:\Users\YourName> cd riscv-edu
- Create Dockerfile (with tools installation) — use a text editor. Include all necessary RISC-V and FPGA tools for Arty A7-T100:
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Utilities
RUN apt update && apt install -y build-essential git make python3 python3-pip wget curl
# RISC-V compiler & simulator
RUN apt install -y gcc-riscv64-unknown-elf gdb-multiarch spike
# Optional RTL simulation tool
RUN apt install -y yosys gtkwave
WORKDIR /workspace
COPY samples/ /workspace/samples/
Note: iCE40-specific tools (nextpnr-ice40, icestorm) are removed because Arty A7-T100 uses Vivado for bitstream generation.
- Build Docker image (tools installed inside Ubuntu automatically):
PS C:\Users\YourName\riscv-edu> docker build -t riscv-edu:latest .
? Inside Ubuntu on Docker
- Run container:
root@container:/workspace# docker run -it riscv-edu:latest /bin/bash
- Test RISC-V and simulation tools:
root@container:/workspace# cd /workspace/samples
root@container:/workspace# make
root@container:/workspace# ./hello_riscv
root@container:/workspace# yosys -V # check Yosys installation
Tools are pre-installed; students do not install them manually.
? Back on Host (PowerShell / Terminal)
- Push to GitHub:
PS C:\Users\YourName\riscv-edu> git init
PS C:\Users\YourName\riscv-edu> git add .
PS C:\Users\YourName\riscv-edu> git commit -m "RISC-V FPGA environment"
PS C:\Users\YourName\riscv-edu> git remote add origin https://github.com/lecturer-repo/riscv-edu.git
PS C:\Users\YourName\riscv-edu> git push -u origin main
3. Student Workflow: Using Ubuntu on Docker
? On Host Terminal / PowerShell
- Clone repository:
PS C:\Users\YourName> git clone https://github.com/lecturer-repo/riscv-edu.git
PS C:\Users\YourName> cd riscv-edu
- Build Docker image (Ubuntu + tools):
PS C:\Users\YourName\riscv-edu> docker build -t riscv-edu:latest .
- Run Ubuntu container:
PS C:\Users\YourName\riscv-edu> docker run -it --name riscv-container -v "$PWD":/workspace riscv-edu:latest /bin/bash
? Inside Ubuntu on Docker
- Work on projects and test tools:
root@container:/workspace# cd /workspace/samples
root@container:/workspace# make
root@container:/workspace# ./hello_riscv
root@container:/workspace# yosys -V
- FPGA Bitstream Workflow for Arty A7-T100
Option 1 – Pre-generated Bitstream (Backup)
- Lecturer provides pre-generated
.bitfiles. - Students load
.bitfile to FPGA to test their RISC-V design.
root@container:/workspace# vivado -mode batch -source load_prebuilt_bitstream.tcl
Option 2 – Student-Generated Bitstream (Advanced)
- Students modify RISC-V cores or peripherals and generate a new bitstream using Vivado WebPACK.
Flow Steps:
- Launch Vivado GUI
root@container:/workspace# vivado &
- GUI opens via X11 forwarding or VNC in Docker.
- Open Project / Design
- Load RISC-V project folder and make modifications.
- Synthesis & Implementation
- Run synthesis → check for errors.
- Run implementation → verify timing constraints.
- Generate Bitstream
- Vivado creates
.bitfile inimpl_1directory.
- Load Bitstream to FPGA
root@container:/workspace# vivado -mode batch -source load_new_bitstream.tcl
- Verify LEDs, switches, or other peripherals.
- Backup Option
- If synthesis fails, revert to pre-generated
.bitfrom Option 1.
- Save & Commit Changes
root@container:/workspace# git add .
root@container:/workspace# git commit -m "Modified RISC-V core"
root@container:/workspace# git push
- Exit:
root@container:/workspace# exit
- Resume later:
PS C:\Users\YourName\riscv-edu> docker start -ai riscv-container
Notes
- All tools are now fully Arty A7-T100 focused.
- iCE40-specific tools are removed to avoid confusion.
- Students can still do full simulation and modification inside Ubuntu on Docker.
RISC-V FPGA Workshop – Ubuntu on Docker Setup Manual (Arty A7-T100 Focused)
——————————————————————–
0. Beginner’s Guide: What is PowerShell and Prompts?
PowerShell is a command window on Windows (like Terminal on macOS). It allows you to type commands instead of using the mouse. You will use PowerShell to:
- Create folders
- Run Docker commands
- Work with Git and Ubuntu inside Docker
Understanding Prompts
Prompts are automatic indicators that show your current environment. You do not type the prompt itself; you only type the commands after it.
| Environment | Prompt Example | What to Type |
|---|---|---|
| PowerShell (Windows) | PS C:\Users\YourName> |
type mkdir riscv-edu and cd riscv-edu after the prompt |
| macOS Terminal | $ |
type mkdir riscv-edu and cd riscv-edu after $ |
| Ubuntu inside Docker | root@container:/workspace# |
type make or ./hello_riscv after the prompt |
Example Commands:
- PowerShell:
PS C:\Users\YourName> mkdir riscv-edu
PS C:\Users\YourName> cd riscv-edu
- macOS Terminal:
$ mkdir riscv-edu
$ cd riscv-edu
- Ubuntu inside Docker:
root@container:/workspace# make
root@container:/workspace# ./hello_riscv
Remember: Only type the command after the prompt. The prompt itself appears automatically.
How to Open PowerShell (Windows 10 or 11)
Method 1 – From Start Menu
- Click the Start Menu (bottom-left corner).
- Type PowerShell in the search box.
- You will see Windows PowerShell appear.
- Right-click it → select Run as administrator.
- A blue window opens. The title bar should say: Administrator: Windows PowerShell.
Method 2 – Shortcut
- Press Windows key + X, then choose Windows PowerShell (Admin).
1. Key Concept: Ubuntu Inside Docker
- Ubuntu runs inside Docker, not directly on Windows/macOS.
- All RISC-V/FPGA tools are installed inside Ubuntu during the Docker build.
- FPGA board used in this workshop: Arty A7-T100
- Simple RISC-V exercises can be tested in software simulation only, without the FPGA board.
Visual:
Host (Windows/macOS)
└── Docker
└── Ubuntu
└── RISC-V & FPGA Tools
2. Lecturer Workflow: Preparing Ubuntu + Tools
On Host (PowerShell for Windows / Terminal for macOS)
- Create project folder:
PS C:\Users\YourName> mkdir riscv-edu
PS C:\Users\YourName> cd riscv-edu
- Create Dockerfile (with tools installation) — use a text editor. Include all necessary RISC-V and FPGA tools for Arty A7-T100:
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Utilities
RUN apt update && apt install -y build-essential git make python3 python3-pip wget curl
# RISC-V compiler & simulator
RUN apt install -y gcc-riscv64-unknown-elf gdb-multiarch spike
# Optional RTL simulation tool
RUN apt install -y yosys gtkwave
WORKDIR /workspace
COPY samples/ /workspace/samples/
Note: iCE40-specific tools (nextpnr-ice40, icestorm) are removed because Arty A7-T100 uses Vivado for bitstream generation.
- Build Docker image (tools installed inside Ubuntu automatically):
PS C:\Users\YourName\riscv-edu> docker build -t riscv-edu:latest .
Inside Ubuntu on Docker
- Run container:
root@container:/workspace# docker run -it riscv-edu:latest /bin/bash
- Test RISC-V and simulation tools:
root@container:/workspace# cd /workspace/samples
root@container:/workspace# make
root@container:/workspace# ./hello_riscv
root@container:/workspace# yosys -V # check Yosys installation
Tools are pre-installed; students do not install them manually.
Back on Host (PowerShell / Terminal)
- Push to GitHub:
PS C:\Users\YourName\riscv-edu> git init
PS C:\Users\YourName\riscv-edu> git add .
PS C:\Users\YourName\riscv-edu> git commit -m "RISC-V FPGA environment"
PS C:\Users\YourName\riscv-edu> git remote add origin https://github.com/lecturer-repo/riscv-edu.git
PS C:\Users\YourName\riscv-edu> git push -u origin main
3. Student Workflow: Using Ubuntu on Docker
On Host Terminal / PowerShell
- Clone repository:
PS C:\Users\YourName> git clone https://github.com/lecturer-repo/riscv-edu.git
PS C:\Users\YourName> cd riscv-edu
- Build Docker image (Ubuntu + tools):
PS C:\Users\YourName\riscv-edu> docker build -t riscv-edu:latest .
- Run Ubuntu container:
PS C:\Users\YourName\riscv-edu> docker run -it --name riscv-container -v "$PWD":/workspace riscv-edu:latest /bin/bash
Inside Ubuntu on Docker
- Work on projects and test tools:
root@container:/workspace# cd /workspace/samples
root@container:/workspace# make
root@container:/workspace# ./hello_riscv
root@container:/workspace# yosys -V
- FPGA Bitstream Workflow for Arty A7-T100
Option 1 – Pre-generated Bitstream (Backup)
- Lecturer provides pre-generated
.bitfiles. - Students load
.bitfile to FPGA to test their RISC-V design.
root@container:/workspace# vivado -mode batch -source load_prebuilt_bitstream.tcl
Option 2 – Student-Generated Bitstream (Advanced)
- Students modify RISC-V cores or peripherals and generate a new bitstream using Vivado WebPACK.
Flow Steps:
- Launch Vivado GUI
root@container:/workspace# vivado &
- GUI opens via X11 forwarding or VNC in Docker.
- Open Project / Design
- Load RISC-V project folder and make modifications.
- Synthesis & Implementation
- Run synthesis → check for errors.
- Run implementation → verify timing constraints.
- Generate Bitstream
- Vivado creates
.bitfile inimpl_1directory.
- Load Bitstream to FPGA
root@container:/workspace# vivado -mode batch -source load_new_bitstream.tcl
- Verify LEDs, switches, or other peripherals.
- Backup Option
- If synthesis fails, revert to pre-generated
.bitfrom Option 1.
- Save & Commit Changes
root@container:/workspace# git add .
root@container:/workspace# git commit -m "Modified RISC-V core"
root@container:/workspace# git push
- Exit:
root@container:/workspace# exit
- Resume later:
PS C:\Users\YourName\riscv-edu> docker start -ai riscv-container
Notes
- All tools are now fully Arty A7-T100 focused.
- iCE40-specific tools are removed to avoid confusion.
- Students can still do full simulation and modification inside Ubuntu on Docker.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Comprehensive Seminar Environment Setup Manual (English Edition)
Overview
This manual provides a step-by-step guide for instructors to prepare and manage a complete RISC-V SoC FPGA seminar environment using Docker. It integrates all prior feedback and corrections for smooth setup, testing, and distribution across participant PCs.
Seminar System Overview
Objective
To ensure all seminar participants can work in a uniform, reproducible, and isolated environment that includes all necessary tools for RISC-V SoC FPGA design, simulation, and HW/SW co-design.
Key Technologies
- Ubuntu or Windows 11 host environment
- Docker Desktop or Docker Engine
- VSCode with Remote Containers plugin (optional but recommended)
- RISC-V toolchain, FPGA synthesis tools, and supporting scripts
Folder and File Structure
Base Directory Example
C:\Seminar\RISC-V-Workshop\
├─ Dockerfile
├─ setup.sh
├─ tools\
├─ examples\
├─ scripts\
├─ docs\
└─ vscode\
Folder Description
| Folder | Contents | Purpose |
|---|---|---|
tools/ |
Compilers, SDKs, and precompiled binaries | For offline setup |
examples/ |
Example Verilog/C projects | For student exercises |
scripts/ |
Automation scripts and shell utilities | For quick setup and cleanup |
docs/ |
Manuals, lecture slides, and PDFs | For both instructors and students |
vscode/ |
Configurations for VSCode container development | To enable code editing within Docker |
File Description
| File | Description |
|---|---|
Dockerfile |
Defines the environment configuration and installed tools |
setup.sh |
Optional script for post-build customization |
riscv-seminar.tar |
Exported Docker image for distribution |
Dockerfile and Image Relationship
| Concept | Description |
|---|---|
| Dockerfile | A text file that defines how to build a Docker image. It contains installation commands, file copies, and environment settings. |
| Docker Image | The result of building a Dockerfile. It acts as a reusable, shareable environment template. |
| Container | A running instance of a Docker image, used by each student. |
Example Command Sequence
# 1. Navigate to the seminar folder
cd C:\Seminar\RISC-V-Workshop
# 2. Build Docker image
docker build -t riscv-seminar:latest .
# 3. Run and test the environment
docker run -it riscv-seminar:latest /bin/bash
# 4. Export the image for student distribution
docker save -o riscv-seminar.tar riscv-seminar:latest
Student-Side Import and Use
# Load the seminar image
docker load -i riscv-seminar.tar
# Create a container from the image
docker run -it --name student01 -v C:\Users\Student01\work:/work riscv-seminar:latest
Tip: The folder mounted to
/workallows persistence between container runs.
Example Dockerfile
# Base Ubuntu image
FROM ubuntu:22.04
# Set working directory
WORKDIR /workspace
# Install essential packages
RUN apt-get update && apt-get install -y \
git make gcc g++ wget vim python3 curl && \
rm -rf /var/lib/apt/lists/*
# Install RISC-V toolchain
RUN git clone https://github.com/riscv/riscv-gnu-toolchain.git && \
cd riscv-gnu-toolchain && \
./configure --prefix=/opt/riscv && make
# Copy seminar materials
COPY tools/ /opt/tools/
COPY examples/ /workspace/examples/
COPY scripts/ /workspace/scripts/
# Set environment variables
ENV PATH="/opt/riscv/bin:$PATH"
# Default shell
CMD ["/bin/bash"]
Note: The above example may require several hours to build depending on host performance.
Workflow Summary for Instructors
| Step | Responsible | Action |
|---|---|---|
| 1 | Instructor | Prepare folders and scripts |
| 2 | Instructor | Write and verify Dockerfile |
| 3 | Instructor | Build Docker image (docker build) |
| 4 | Instructor | Test tools and workflow inside container |
| 5 | Instructor | Export Docker image to .tar |
| 6 | Student | Import image and start container |
| 7 | Student | Complete assigned exercises |
| 8 | Instructor | Collect project outputs via shared folder or Git |
PowerShell ISE and Docker Integration
Using PowerShell ISE
- Open PowerShell ISE as Administrator.
- Use
cdto navigate to the seminar folder. - Execute build or run commands, for example:
docker build -t riscv-seminar:latest . docker run -it riscv-seminar:latest - If the context menu does not show Run as Administrator, manually open PowerShell (Start → type PowerShell → right-click → Run as Administrator).
Troubleshooting
- If
Administratorprompt changes unexpectedly, confirm user privileges. - Check Docker Desktop is running and WSL2 backend is enabled.
- Use
docker psto list running containers.
Recommended Lecture Schedule
| Day | Topic | Main Activity |
|---|---|---|
| 1 | Setup & Overview | Install Docker, verify environment |
| 2 | RISC-V Basics | Compile and simulate simple programs |
| 3 | Toolchain Hands-on | Test GCC and assembler |
| 4 | FPGA Intro | Synthesis overview and bitstream explanation |
| 5–6 | SoC Integration | Work on PicoRV32 or VexRiscv project |
| 7 | HW/SW Co-design | Debugging and interface testing |
| 8 | Optimization | Tuning and resource monitoring |
| 9 | Group Project | Final integration testing |
| 10 | Presentation | Student demonstrations and evaluation |
Best Practices
- Pre-test your Docker image on both Windows and Ubuntu hosts.
- Keep the Dockerfile modular for easy updates.
- Use version tags for each iteration (e.g.,
riscv-seminar:v1.1). - Store large tool archives in
tools/and copy them locally to speed up build time. - Encourage students to use VSCode Remote Containers for seamless access.
Conclusion
By following this detailed workflow, all seminar participants will have a consistent, reliable, and reproducible environment. Docker ensures that software versions remain synchronized across systems, minimizing setup difficulties and maximizing productive learning time.
Prepared by: RISC-V SoC FPGA Training Team
Author: Prof. Hiroaki Kunieda (EICOT Electronic Co., Tokyo Institute of Technology, Japan)
Version: October 2025
Language: English
Great! Here’s a step-by-step “fast Docker run setup” guide for Windows and macOS for your RISC-V FPGA workshop. This setup minimizes docker run delays for students.
1️⃣ Pre-download the Docker Image
Before the workshop, the lecturer can prepare the full Ubuntu + RISC-V + FPGA tools image.
Lecturer Steps:
# Pull base Ubuntu image
docker pull ubuntu:22.04
# Build the custom workshop image
docker build -t riscv-edu:latest /path/to/Dockerfile
This ensures students don’t have to download large layers during class.
2️⃣ Distribute the Image to Students
Option A: Docker Hub (simplest)
-
Push the image to a private GitHub Docker registry or Docker Hub:
docker tag riscv-edu:latest username/riscv-edu:latest
docker push username/riscv-edu:latest
-
Students pull:
docker pull username/riscv-edu:latest
Option B: Save as TAR file (offline)
-
Lecturer saves:
docker save -o riscv-edu.tar riscv-edu:latest
-
Students load:
docker load -i riscv-edu.tar
This avoids long download times during class.
3️⃣ Pre-build Binaries and Bitstreams
-
Compile RISC-V programs and FPGA bitstreams inside the image.
-
Store them in
/workspace/prebuilt:
/workspace/prebuilt/hello_riscv.elf
/workspace/prebuilt/arty_a7_t100.bit
-
Students can use these files immediately if they cannot generate their own.
4️⃣ Mount Only the Workshop Folder
-
Keep mounted folders small to reduce I/O overhead:
docker run -it -v "$env:USERPROFILE\Documents\RISC-V-Workshop":/workspace riscv-edu
-
Avoid mounting entire drives like
C:\.
5️⃣ Use Detached Mode (Optional)
-
If students don’t need interactive shell immediately:
docker run -d -v "$env:USERPROFILE\Documents\RISC-V-Workshop":/workspace riscv-edu
-
Attach later:
docker exec -it <container_id> /bin/bash
6️⃣ Increase Docker Resources (Windows WSL2)
-
Docker Desktop → Settings → Resources:
-
CPU: at least 2 cores
-
Memory: 4–8 GB
-
Swap: 1–2 GB
-
This helps speed up compilation and FPGA tool execution inside the container.
7️⃣ Start Container Fast (Summary for Students)
-
Pull or load prebuilt image:
docker pull username/riscv-edu:latest
# OR
docker load -i riscv-edu.tar
-
Run container:
docker run -it -v "$env:USERPROFILE\Documents\RISC-V-Workshop":/workspace riscv-edu
-
Optional: Use prebuilt binaries or bitstreams from
/workspace/prebuiltto start exercises immediately.
8️⃣ Notes for macOS Students
-
The same commands work in macOS Terminal.
-
Docker Desktop for Mac uses hyperkit instead of WSL2.
-
Mounting large folders may still be slower; keep
/workspacefolder small.
✅ Benefits of this approach
-
Students don’t wait for large downloads.
-
They can start exercises immediately using prebuilt binaries and bitstreams.
-
System I/O is minimized to reduce startup time.
-
Keeps Docker setup consistent for all participants.
If you want, I can make a diagram flow showing Lecturer image creation → Student pull/load → Container start → Prebuilt vs Custom build, which is perfect for your workshop manual.
Do you want me to make that diagram?
あなた:
ChatGPT:
Ah — you want a clear explanation of how students actually get into Ubuntu running inside Docker, and where to execute commands inside the container. Here’s a beginner-friendly guide:
1️⃣ Run the Ubuntu-on-Docker Container
Assuming the Docker image is already available (riscv-edu:latest):
Windows PowerShell
docker run -it -v "$env:USERPROFILE\Documents\RISC-V-Workshop":/workspace riscv-edu:latest
macOS Terminal
docker run -it -v ~/Documents/RISC-V-Workshop:/workspace riscv-edu:latest
Explanation of options:
-
-it→ interactive terminal (so you can type commands) -
-v ...:/workspace→ mounts the local workshop folder into the container -
riscv-edu:latest→ the name of the Docker image
2️⃣ What the Prompt Looks Like
After running the command, you should see something like:
dockeruser@container:/workspace$
-
This is Ubuntu inside Docker.
-
Anything you type here runs inside the container, not on your Windows or Mac host.
3️⃣ Check Ubuntu Version (inside container)
lsb_release -a
Output example:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
4️⃣ Run Workshop Commands Inside Container
Examples:
-
Update package list:
sudo apt update
-
Compile RISC-V programs:
cd /workspace/samples
make
./hello_riscv
-
Launch FPGA simulation (e.g., Yosys/GTKWave):
cd /workspace/fpga
yosys top_module.v
gtkwave top_module.vcd
5️⃣ Exit Container
-
To exit without stopping the container:
Ctrl + P, Ctrl + Q
-
To stop and exit:
exit
-
To re-attach to a running container:
docker ps # lists running containers
docker exec -it <container_id> /bin/bash
✅ Summary
| Action | Command | Notes |
|---|---|---|
| Start container | docker run -it -v <host>:/workspace riscv-edu:latest |
Mounts your folder, opens interactive terminal |
| Inside Ubuntu | Any Linux commands | E.g., ls, cd, make, apt install |
| Exit safely | Ctrl+P Ctrl+Q |
Leaves container running |
| Stop container | exit |
Stops container |
| Re-attach | docker exec -it <container_id> /bin/bash |
Continue work inside the container |
If you want, I can make a step-by-step illustrated guide for students showing Windows/macOS → Docker → Ubuntu terminal → commands inside container, including prompts and directory structure.
Do you want me to make that guide?
識別子
Ah — I understand your issue clearly: you want to automatically generate a correctly named Dockerfile using PowerShell or another editor (like VS Code / ISE / Notepad), without accidentally creating a file with a “wrong” extension or encoding, which causes Docker to report “no identifier” or cannot find Dockerfile.
Here’s a beginner-friendly explanation and method.
? Problem
Common mistakes that make Docker unable to recognize the Dockerfile:
| Mistake | Why it fails |
|---|---|
| Dockerfile.txt | Windows hides extensions; Docker cannot read .txt |
| Dockerfile.ps1 | PowerShell script, not a Dockerfile |
| dockerfile (lowercase) | Some Docker setups are case-sensitive |
| BOM/UTF-16 encoding | Docker only reads UTF-8 without BOM |
✅ Correct Method 1: PowerShell Out-File (Automatic)
This method guarantees a correctly named Dockerfile.
-
Open PowerShell
-
Go to your project folder:
PS> cd $env:USERPROFILE\Documents\RISC-V-Workshop
-
Create the Dockerfile with correct encoding:
$dockerfileContent = @"
# Dockerfile for RISC-V FPGA Workshop
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y build-essential git make python3 python3-pip wget curl
WORKDIR /workspace
"@
$dockerfilePath = Join-Path (Get-Location) "Dockerfile"
# Write UTF-8 without BOM
$dockerfileContent | Out-File -FilePath $dockerfilePath -Encoding utf8 -NoByteOrderMark
Write-Host "Dockerfile created at: $dockerfilePath"
✅ This produces a plain Dockerfile that Docker can read.
-
No
.txt -
UTF-8 without BOM
-
Exactly the name
Dockerfile
✅ Correct Method 2: Notepad / VS Code (Manual)
-
Open Notepad:
PS> notepad Dockerfile
-
Paste your Dockerfile content.
-
Save As:
-
File name:
Dockerfile -
Save as type:
All Files -
Encoding:
UTF-8 -
Folder:
C:\Users\<yourname>\Documents\RISC-V-Workshop\
-
If you see
.txtadded automatically, rename the file and remove.txtextension.
✅ Correct Method 3: VS Code / ISE
-
Open VS Code or PowerShell ISE
-
Create a new file
-
Paste the Dockerfile content
-
Save As → Dockerfile → All Files → UTF-8
Avoid saving as
.ps1(PowerShell script) — Docker will ignore it.
? Verify File
After creation, run in PowerShell:
PS> dir
Expected output:
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2025/10/13 11:22 312 Dockerfile
-
If the file is exactly
Dockerfileand not.txtor.ps1, Docker will recognize it.
? Build Docker Image
Finally, to test:
PS> docker build -t riscv-edu:latest .
-
The dot
.at the end tells Docker to look in the current folder forDockerfile.
If you want, I can create a one-click PowerShell script that:
-
Checks your folder
-
Generates the Dockerfile
-
Automatically builds the Docker image
This guarantees no “identifier missing” errors even for beginners.
Do you want me to make that?
folder
RISC-V SoC FPGA Workshop — Instructor Guide (English Edition)
Overview
This guide provides instructors and assistants with a detailed workflow for setting up and managing the RISC-V SoC FPGA Workshop environment. It covers safe folder setup, Docker usage, and guidance for assisting students.
1️⃣ Objectives
- Ensure all instructors can prepare and verify the workshop environment.
- Provide clear steps to guide students in building, testing, and running exercises.
- Include detailed explanations of PowerShell prompts and safe folder locations.
2️⃣ System Requirements
- Windows 11 or Ubuntu 22.04 host
- Docker Desktop or Docker Engine
- Optional: VSCode with Remote Containers plugin
- Hardware: ≥16GB RAM, ≥50GB free disk space
3️⃣ Understanding PowerShell Prompts and Safe Folder Locations
3.1 Default Prompt in Administrator PowerShell
- When opening PowerShell as administrator, the default prompt is:
PS C:\WINDOWS\system32>
- This is the Windows system folder. Avoid using this location for workshop files to prevent accidental system changes.
3.2 Recommended Folder for Workshop Files
- Safe and accessible locations for instructors and students:
- User Documents folder:
C:\Users\<Username>\Documents\RISC-V-Workshop - Directly under C: drive (shorter path):
C:\RISC-V-Workshop
- User Documents folder:
- Documents folder is standard for user files and safe to write to without admin permissions.
3.3 Creating the Workshop Folder
# Navigate to user's Documents folder
cd $env:USERPROFILE\Documents
# Create the main workshop folder
mkdir RISC-V-Workshop
cd RISC-V-Workshop
# Create subfolders
mkdir tools examples scripts docs workspace
- Resulting folder structure:
C:\Users\<Username>\Documents\RISC-V-Workshop\
├─ tools\
├─ examples\
├─ scripts\
├─ docs\
└─ workspace\
3.4 Moving to the Workshop Folder
cd $env:USERPROFILE\Documents\RISC-V-Workshop
- PowerShell prompt becomes:
PS C:\Users\<Username>\Documents\RISC-V-Workshop>
- All Docker commands should be run from this location.
3.5 Docker Volume Mount Example
docker run -it -v C:\Users\<Username>\Documents\RISC-V-Workshop\workspace:/workspace riscv-workshop:latest
- Maps the host’s workspace folder to the container’s
/workspacedirectory - Work done in the container persists on the host
3.6 Key Points for Instructors
- Do not use
C:\WINDOWS\system32for workshop files. - Safe folder should be under user account.
- The Documents folder is recommended for ease and safety.
- Docker volume mounts should point to this folder to persist files.
- Instructors should ensure students understand this mapping before exercises.
4️⃣ Folder Structure for Workshop
C:\RISC-V-Workshop\
├─ Dockerfile
├─ tools\
├─ examples\
├─ scripts\
├─ docs\
└─ workspace\
tools/: pre-installed binaries and toolchain filesexamples/: sample projects for exercisesscripts/: helper scripts for building and runningdocs/: manuals and lecture notesworkspace/: student working folder mapped to Docker container
5️⃣ Docker Workflow for Instructors
Build Docker Image
cd C:\RISC-V-Workshop
docker build -t riscv-workshop:latest .
Run Container
docker run -it --name instructor01 -v C:\RISC-V-Workshop\workspace:/workspace riscv-workshop:latest
- All work in
/workspacepersists between sessions
Verify Setup
Inside container:
riscv64-unknown-elf-gcc --version
ls /workspace/examples
- Ensure all tools are accessible and examples are correctly mounted
6️⃣ Tips for Supporting Students
- Keep each student’s workspace organized and isolated using Docker container names
- Verify students are using the correct folder and Docker volume mapping
- Assist with troubleshooting Docker images, builds, or container errors
- Encourage students to work inside the mounted
/workspaceto avoid data loss
7️⃣ Daily Workshop Schedule for Instructors
| Day | Activity |
|---|---|
| 1 | Setup environment & verify Docker images |
| 2 | Guide students through RISC-V basics & simulation |
| 3 | Supervise toolchain exercises |
| 4 | Assist FPGA synthesis exercises |
| 5–6 | Monitor SoC integration projects |
| 7 | Support HW/SW co-design exercises |
| 8 | Debugging assistance |
| 9 | Performance optimization guidance |
| 10 | Final project review and demo |
8️⃣ Summary
By following this guide, instructors will:
- Prepare and verify a safe, reproducible environment
- Guide students effectively through Docker, toolchain, and FPGA exercises
- Ensure students understand safe folder usage and volume mapping
Instructor support is critical during all sessions to help students with environment or build issues.
download
Great — I’ll give you a ready-to-use, instructor-friendly Dockerfile that:
-
downloads (via configurable URLs) a prebuilt RISC-V toolchain and Spike if you provide URLs (so it’s reproducible),
-
installs Yosys and GTKWave (via apt where available, with fallback notes),
-
creates a non-root
workuser, sets up/workspace/samples, and -
includes a small smoke-test script (
check_env.sh) to verify the tools after the image is built.
I’ll also include exact build & run commands, plus troubleshooting notes (what to change if your environment blocks direct downloads).
⚠️ Note: prebuilt toolchain and spike binaries are large. If your network or firewall blocks downloads, copy the tarballs next to the Dockerfile and use the
ADDalternative shown below.
1 — Dockerfile (drop into your workshop folder — same level as samples/)
Save this as Dockerfile:
# ------------------------------------------------------------
# RISC-V Workshop image (Ubuntu 22.04)
# - Downloads prebuilt toolchain & spike (via build ARGs)
# - Installs yosys and gtkwave if available in apt
# - Creates unprivileged user 'work'
# - Copies samples/ -> /workspace/samples
# - Adds a simple check_env.sh smoke-test
# ------------------------------------------------------------
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=Etc/UTC
# Build-time args to provide prebuilt tarball URLs (optional)
# If you don't want to download, pass empty or use local files + build-time ADD.
ARG TOOLCHAIN_URL=""
ARG SPIKE_URL=""
# Basic utilities + build tools for optional compilation
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl wget git build-essential python3 python3-pip \
gnupg software-properties-common unzip bzip2 \
pkg-config libboost-dev autoconf automake libtool \
&& rm -rf /var/lib/apt/lists/*
# ----- Install RISC-V prebuilt toolchain (if TOOLCHAIN_URL provided) -----
# We download into /opt/tmp and install to /opt/riscv
RUN set -eux; \
mkdir -p /opt/tmp; \
if [ -n "$TOOLCHAIN_URL" ]; then \
echo "Downloading prebuilt RISC-V toolchain from $TOOLCHAIN_URL"; \
wget -qO /opt/tmp/riscv-toolchain.tar.gz "$TOOLCHAIN_URL"; \
tar -xzf /opt/tmp/riscv-toolchain.tar.gz -C /opt; \
# assume tarball expands to riscv64-*/bin under /opt, adjust if needed
if [ -d /opt/riscv64-*/ ]; then mv /opt/riscv64-* /opt/riscv; fi; \
rm -rf /opt/tmp/riscv-toolchain.tar.gz; \
else \
echo "No TOOLCHAIN_URL provided — skip prebuilt download. You can build from source or add tarball."; \
fi
# ----- Install Spike (if SPIKE_URL provided) -----
RUN set -eux; \
if [ -n "$SPIKE_URL" ]; then \
echo "Downloading spike from $SPIKE_URL"; \
wget -qO /opt/tmp/spike.tar.gz "$SPIKE_URL"; \
tar -xzf /opt/tmp/spike.tar.gz -C /opt; \
# assume spike binaries are inside /opt/spike/bin ; adjust as needed
rm -rf /opt/tmp/spike.tar.gz; \
else \
echo "No SPIKE_URL provided — spike may be missing"; \
fi
# ----- Install yosys & gtkwave if available in apt -----
RUN apt-get update && apt-get install -y --no-install-recommends \
yosys gtkwave \
|| echo "yosys/gtkwave not available in apt; consider building from source" \
&& rm -rf /var/lib/apt/lists/*
# ----- Create non-root user -----
ARG USER=work
ARG UID=1000
ARG GID=1000
RUN groupadd -g ${GID} ${USER} || true \
&& useradd -m -u ${UID} -g ${GID} -s /bin/bash ${USER} || true
# ----- Workspace and samples -----
WORKDIR /workspace
COPY samples/ /workspace/samples/
RUN chown -R ${USER}:${USER} /workspace
# ----- Add a simple environment check script (smoke test) -----
COPY --chown=${USER}:${USER} <<'CHECK' /workspace/check_env.sh
#!/bin/bash
set -e
echo "=== RISC-V Workshop environment smoke test ==="
echo "User: $(whoami)"
echo "Workspace: $(pwd)"
echo
echo "Check riscv gcc:"
if command -v riscv64-unknown-elf-gcc >/dev/null 2>&1; then
riscv64-unknown-elf-gcc --version | head -n1
else
echo "riscv compiler not found in PATH"
fi
echo
echo "Check spike:"
if command -v spike >/dev/null 2>&1; then
spike --version || echo "spike present but --version failed"
else
echo "spike not found"
fi
echo
echo "Check yosys:"
if command -v yosys >/dev/null 2>&1; then
yosys -V | head -n1
else
echo "yosys not found"
fi
echo
echo "Check gtkwave:"
if command -v gtkwave >/dev/null 2>&1; then
gtkwave --version || echo "gtkwave present"
else
echo "gtkwave not found"
fi
echo "=== End of smoke test ==="
CHECK
RUN chmod +x /workspace/check_env.sh && chown ${USER}:${USER} /workspace/check_env.sh
# Expose standard environment variables for toolchain if installed to /opt/riscv
ENV PATH="/opt/riscv/bin:${PATH}"
ENV HOME=/home/${USER}
# Switch to non-root user
USER ${USER}
# Default command => gives interactive shell; instructors can override
CMD ["/bin/bash"]
2 — How to build (two common options)
Option A — You have valid direct download URLs (recommended)
If you have direct URLs to prebuilt tarballs (TOOLCHAIN_URL and SPIKE_URL), build with:
docker build \
--build-arg TOOLCHAIN_URL="https://example/path/to/riscv-toolchain-ubuntu22.04.tar.gz" \
--build-arg SPIKE_URL="https://example/path/to/spike-ubuntu22.04.tar.gz" \
-t eicot/riscv-workshop:202510 .
Replace the https://example/... with the real release tarball URLs you trust.
Option B — You have downloaded tarballs locally (no network in build)
Place the tarballs beside the Dockerfile (same directory), name them e.g. riscv-toolchain.tar.gz and spike.tar.gz, and edit the Dockerfile lines where it wget and instead use ADD or COPY:
Example snippet to replace the wget step:
# If using local tarballs, copy them into image and extract
COPY riscv-toolchain.tar.gz /opt/tmp/riscv-toolchain.tar.gz
RUN tar -xzf /opt/tmp/riscv-toolchain.tar.gz -C /opt && rm /opt/tmp/riscv-toolchain.tar.gz
Then build normally:
docker build -t eicot/riscv-workshop:202510 .
3 — How to run (students / instructors)
Mount the host workspace so student work persists:
Windows PowerShell (example):
docker run --rm -it `
-v "C:\Users\<YourUsername>\Documents\RISC-V-Workshop\workspace:/workspace" `
--name riscv-workshop-shell `
eicot/riscv-workshop:202510
Linux / WSL:
docker run --rm -it \
-v "/home/<youruser>/RISC-V-Workshop/workspace:/workspace" \
--name riscv-workshop-shell \
eicot/riscv-workshop:202510
Once in container, run the smoke test:
/workspace/check_env.sh
4 — If something doesn’t appear after build
-
If
riscv64-unknown-elf-gccis missing:-
Check whether the prebuilt toolchain actually put binaries under
/opt/riscv/bin. You can inspect the image by running:docker run --rm -it eicot/riscv-workshop:202510 bash -c "ls -la /opt || true; ls -la /opt/riscv || true"
-
If absent, either the tarball had a different layout (adjust Dockerfile to
mvthe extracted folder to/opt/riscv) or you need to use another tarball.
-
-
If
spikemissing or broken:-
Inspect
/optand/usr/local/binsimilarly. Use logs from the build (docker buildoutput) to find extraction paths.
-
5 — Tips & recommended resources (quick)
-
Where to find prebuilt toolchains & spike: official RISC-V repos/releases on GitHub, SiFive releases, or trusted mirror providers. If you want, I can search (and paste) the current recommended release URLs — say “please find prebuilt URLs” and I’ll fetch them for you.
-
For reliable workshop images: prepare an image on a fast host,
docker save→ produceriscv-workshop.tarand distribute the tar to participants (avoids per-machine building).
6 — Want me to do one of these next?
Tell me which you want next and I’ll produce it immediately:
-
Provide a Dockerfile variant that includes explicit extraction logic for a known prebuilt release (I can fetch the current release URL if you want — say “fetch URLs”).
-
Create a
check_env.shexpanded version that runs compile+simulate sample. -
Produce a short build & distribution checklist for instructors (step-by-step, copy-paste commands).
Which one shall I prepare now?
Dokerfile命令
? Dockerfileの基本構造
Dockerfile は、「どんな環境を持つコンテナを作るか」を指示する**レシピ(設計図)**のようなものです。
1行ずつ、上から順に命令を実行してイメージを構築します。
? 各命令の説明
1️⃣ FROM
-
意味: ベースとなるイメージ(親イメージ)を指定する。
-
使い方:
FROM ubuntu:22.04
→ Ubuntu 22.04 をベースにする。
2️⃣ LABEL
-
意味: イメージにメタ情報(作成者やバージョンなど)を付ける。
-
使い方:
LABEL maintainer="kunieda@example.com"
LABEL version="1.0"
3️⃣ ENV
-
意味: 環境変数を設定する(以降の命令でも利用可)。
-
使い方:
ENV DEBIAN_FRONTEND=noninteractive
→ 対話的入力を不要にして自動インストールを可能に。
4️⃣ RUN
-
意味: コンテナ内でコマンドを実行する(主にインストールや設定)。
-
使い方:
RUN apt update && apt install -y build-essential git
→ パッケージ更新と必要ツールのインストールを行う。
-
ポイント:
-
RUNはイメージ作成時に実行され、結果がイメージに保存される。 -
&&を使って1行にまとめると、レイヤー数が減り軽量化できる。
-
5️⃣ COPY
-
意味: ホストPC(自分のパソコン)のファイルをコンテナにコピーする。
-
使い方:
COPY ./app /usr/src/app
→ ローカルの
appフォルダをコンテナ内/usr/src/appにコピー。
6️⃣ ADD
-
意味:
COPYと似ているが、圧縮ファイルの自動展開やURL指定が可能。 -
使い方:
ADD app.tar.gz /usr/src/app/
→ 自動で展開してコピー。
-
注意: 特殊な機能が不要なら、基本的には
COPYを使う方が推奨。
7️⃣ WORKDIR
-
意味: 作業ディレクトリ(カレントディレクトリ)を設定。
-
使い方:
WORKDIR /usr/src/app
→ 以降の命令(RUN, CMDなど)はこの場所で実行される。
8️⃣ CMD
-
意味: コンテナ起動時に実行するコマンドを指定。
-
使い方:
CMD ["python3", "app.py"]→ コンテナ起動時に自動で
python3 app.pyを実行。 -
注意:
-
CMDは最後の1つだけ有効。 -
コンテナ起動時にコマンドを指定すると上書きされる。
-
9️⃣ ENTRYPOINT
-
意味: コンテナの「固定起動コマンド」を指定する。
CMDと違い、実行時に上書きされにくい。 -
使い方:
ENTRYPOINT ["python3"] CMD ["app.py"]→ 実行時は
python3 app.pyが起動。
? EXPOSE
-
意味: コンテナが使用するポート番号を指定(ドキュメント的な意味が強い)。
-
使い方:
EXPOSE 8080
11️⃣ VOLUME
-
意味: コンテナとホスト間で共有するディレクトリを指定。
-
使い方:
VOLUME ["/data"]→
/dataはホストと共有できるようになる。
12️⃣ USER
-
意味: コンテナ内で実行するユーザーを変更。
-
使い方:
USER developer
13️⃣ ARG
-
意味: ビルド時に設定できる変数を定義。
-
使い方:
ARG VERSION=1.0
RUN echo "Version: $VERSION"
→
docker build --build-arg VERSION=2.0で上書き可能。
14️⃣ HEALTHCHECK
-
意味: コンテナが正常に動作しているかを定期チェック。
-
使い方:
HEALTHCHECK CMD curl -f http://localhost/ || exit 1
15️⃣ SHELL
-
意味:
RUNなどで使うシェルを指定。 -
使い方:
SHELL ["/bin/bash", "-c"]
? まとめ:典型的な例
FROM ubuntu:22.04
LABEL maintainer="kunieda@example.com"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y python3 python3-pip git
WORKDIR /usr/src/app
COPY . .
EXPOSE 8080
CMD ["python3", "app.py"]
もし希望があれば、
?「RISC-V 用ツールを含む Dockerfile」の各行をこのように一行ずつ解説することもできます。
やりますか?
Dokerfile命令 完全版
? Dockerfile 全体
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Utilities
RUN apt update && apt install -y build-essential git make python3 python3-pip wget curl
# RISC-V compiler & simulator
RUN apt install -y gcc-riscv64-unknown-elf gdb-multiarch spike
# Optional RTL simulation tool
RUN apt install -y yosys gtkwave
? 各行の説明
FROM ubuntu:22.04
意味:
このコンテナのベース(親)となる OS イメージを指定。
ここでは Ubuntu 22.04 をベースにしています。
ポイント:
-
Docker Hub から自動的に Ubuntu 22.04 のイメージを取得。
-
これがコンテナ内の基本環境になります。
(例:ファイル構成、Linuxコマンド、パッケージ管理など)
ENV DEBIAN_FRONTEND=noninteractive
意味:
APT(Ubuntu のパッケージ管理ツール)の動作を非対話モードに設定。
つまり、「yes/no を聞かれずに自動で進む」ようにします。
理由:
Docker のビルドは自動処理なので、
途中で「設定を選んでください」と止まると失敗するため。
# Utilities
意味:
コメント(# 以降は実行されません)。
ここでは「ユーティリティツールのインストール開始」という目印。
RUN apt update && apt install -y build-essential git make python3 python3-pip wget curl
意味:
Ubuntu のパッケージを更新し、開発に必要な基本ツールを一括インストール。
各コマンドの意味:
-
apt update
→ パッケージリストを最新化。 -
apt install -y ...
→ 各ツールをインストール(-yは自動「Yes」回答)。 -
build-essential: C/C++開発に必要な基本コンパイラとライブラリ群。 -
git: ソースコード管理ツール。 -
make: ビルド自動化ツール。 -
python3: Python3 言語環境。 -
python3-pip: Python パッケージ管理。 -
wget/curl: 外部ファイルのダウンロード用。
# RISC-V compiler & simulator
意味:
コメント:ここから RISC-V のツールチェーンをインストールします。
RUN apt install -y gcc-riscv64-unknown-elf gdb-multiarch spike
意味:
RISC-V 開発に必要なコンパイラとシミュレータをインストール。
各ツールの意味:
-
gcc-riscv64-unknown-elf
→ RISC-V 64bit 用のクロスコンパイラ。
C言語などで書いたプログラムを RISC-V 向けにコンパイルできます。 -
gdb-multiarch
→ 複数アーキテクチャに対応したデバッガ(RISC-V含む)。 -
spike
→ RISC-V の公式シミュレータ(命令セットシミュレータ)。
実機がなくてもプログラムを動作確認できます。
# Optional RTL simulation tool
意味:
コメント:「オプションの論理シミュレーションツール」をインストール。
RUN apt install -y yosys gtkwave
意味:
FPGA設計やハードウェア検証に使うツールをインストール。
各ツールの意味:
-
yosys:
オープンソースの論理合成ツール。
Verilog HDLを読み取り、FPGA用のネットリストに変換します。 -
gtkwave:
波形表示ツール。
シミュレーション結果の信号変化を可視化できます。
? この Dockerfile を使うと…
構築後のコンテナ環境には次のものが揃います:
| 分類 | 主なツール | 用途 |
|---|---|---|
| 開発ツール | gcc, make, git, python3 | ソフトウェア開発 |
| RISC-V | gcc-riscv64, spike, gdb | コンパイル・デバッグ・シミュレーション |
| FPGA/RTL | yosys, gtkwave | 論理設計・波形解析 |
✅ ビルド手順
docker build -t riscv-dev .
✅ 実行
docker run -it riscv-dev /bin/bash
→ Ubuntu 環境の中に入り、RISC-V 開発がすぐに可能になります。
もし希望があれば、
次はこのDockerfileに「VSCodeリモート開発」「RARS」「Verilator」などを追加した完全版も解説付きで作れます。
作りますか?
あなた:
ChatGPT:
できました — Dockerfile と補足(devcontainer.json の例など)をキャンバスに作成しました。
内容を確認してほしい点や、追加したいツール(例:openocd、qemu-system-riscv64、特定バージョンの toolchain、code-server など)があれば教えてください。
Dokerfile命令 完全版
# — 設定: 作業ディレクトリを指定(必要なら変更) —
$workDir = “C:\RISC-V-Workshop”
if (-not (Test-Path $workDir)) { New-Item -ItemType Directory -Path $workDir | Out-Null }
Set-Location $workDir
# — 既存 Dockerfile を削除(存在する場合) —
if (Test-Path Dockerfile) {
Write-Host “既存の Dockerfile を削除します…”
Remove-Item -Force Dockerfile
}
# — Dockerfile の中身(ここを必要に応じて編集) —
$dockerfileContent = @”
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y \
build-essential \
git \
make \
python3 \
python3-pip \
wget \
curl
WORKDIR /workspace
“@
# — BOMなし UTF-8 で書き出す(識別子を付けない) —
Write-Host “Dockerfile を作成しています(UTF-8 no BOM)…”
$utf8NoBom = New-Object System.Text.UTF8Encoding($false) # $false = emitIdentifier (BOM) を出さない
[System.IO.File]::WriteAllText((Join-Path $workDir “Dockerfile”), $dockerfileContent, $utf8NoBom)
# — 作成ファイルの存在確認と先頭行表示 —
Write-Host “`n=== ファイル一覧 ===”
Get-ChildItem -Force -Name
Write-Host “`n=== Dockerfile 先頭(1行目) ===”
Get-Content Dockerfile -TotalCount 1 | ForEach-Object { Write-Host $_ }
# — バイナリ先頭のチェック: BOM (EF BB BF) が無いことを確認 —
$bytes = [System.IO.File]::ReadAllBytes((Join-Path $workDir “Dockerfile”))
if ($bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF) {
Write-Host “`n警告: ファイル先頭に UTF-8 BOM (EF BB BF) が検出されました。” -ForegroundColor Red
} else {
Write-Host “`nOK: UTF-8 BOM は付属していません(no BOM)。” -ForegroundColor Green
}
# — (任意)ファイルサイズ表示 —
Write-Host (“Dockerfile サイズ: {0} bytes” -f $bytes.Length)
# — Docker ビルド実行 —
Write-Host “`n=== docker build を実行します ===” -ForegroundColor Cyan
# イメージ名は小文字にすること
$imageTag = “risc-v-workshop:latest”
try {
docker build -t $imageTag . 2>&1 | ForEach-Object { Write-Host $_ }
Write-Host “`nビルドが終了しました。イメージ一覧を表示します:” -ForegroundColor Green
docker images –format “table {{.Repository}}\t{{.Tag}}\t{{.Size}}”
} catch {
Write-Host “`ndocker ビルド中にエラーが発生しました:” -ForegroundColor Red
Write-Host $_.Exception.Message
}