GitHub

前提

PowerShell で、ubuntu docker run

PS C:/> docker run -it ubuntu:22.04 bash

root@55c2e3code3b7:/#

# Dockerコンテナ起動
docker run -it ubuntu:22.04 bash

# コンテナ内でGitをインストール
apt update
apt install -y git

# GitHubリポジトリをクローン
git clone https://github.com/username/repo.git

  • Git がインストールされている
  • GitHub アカウントを持っている

  • ターミナル(または PowerShell / Git Bash)を使用できる


ACOT-Classroom/
├── README.md
├── README-teachers.md ← 講師用クイックスタートガイド

├── policies/ ← 組織運用・命名ポリシー
│ └── naming.md

├── scripts/ ← 講師向けスクリプト
│ ├── create_classroom.sh ← gh CLI で複数テンプレートリポジトリを自動生成
│ └── README.md

├── templates/ ← 各実習日のテンプレート群
│ └── riscv-lab-template/ ← RISC-V 実習用のテンプレート例
│ ├── README.md
│ ├── Dockerfile ← 実習環境(RISC-V コンパイラ入り)
│ ├── Makefile
│ ├── lab.c ← サンプルプログラム
│ ├── .devcontainer/ ← VS Code DevContainer 設定
│ │ └── devcontainer.json
│ └── .github/ ← 各テンプレート用の CI 設定
│ └── workflows/
│ └── ci.yml

└── .github/ ← 講師用リポジトリ全体の GitHub 設定
├── ISSUE_TEMPLATE/
│ └── question.md ← 受講者の質問テンプレート
└── PULL_REQUEST_TEMPLATE.md ← 提出・採点用PRテンプレート

ACOT-Classroom/
├── README.md
├── README-teachers.md ← 講師用クイックスタートガイド

├── policies/ ← 組織運用・命名ポリシー
│ └── naming.md

├── scripts/ ← 講師向けスクリプト
│ ├── create_classroom.sh ← gh CLI で複数テンプレートリポジトリを自動生成
│ └── README.md

├── templates/ ← 各実習日のテンプレート群
│ └── riscv-lab-template/ ← RISC-V 実習用のテンプレート例
│ ├── README.md
│ ├── Dockerfile ← 実習環境(RISC-V コンパイラ入り)
│ ├── Makefile
│ ├── lab.c ← サンプルプログラム
│ ├── .devcontainer/ ← VS Code DevContainer 設定
│ │ └── devcontainer.json
│ └── .github/ ← 各テンプレート用の CI 設定
│ └── workflows/
│ └── ci.yml

└── .github/ ← 講師用リポジトリ全体の GitHub 設定
├── ISSUE_TEMPLATE/
│ └── question.md ← 受講者の質問テンプレート
└── PULL_REQUEST_TEMPLATE.md ← 提出・採点用PRテンプレート

? 複数回開催前提のGitHub運用設計

1️⃣ Organization(共通管理)

  • 1つのOrganizationを作り、すべてのコースを管理します。

  • 例:ACOT-Classroom

  • Organization内に講師・アシスタントを Owner として登録

  • 学生は Member または招待リンクで参加

メリット

  • 管理者が一元化される

  • 過去の課題やテンプレートを残せる

  • コースの期間ごとにクラス分けが容易


2️⃣ 各期ごとの Classroom を作る

設計方針

  • 1回の開催 → 1 Classroom

  • Classroom名の付け方例:

    ACOT-YYYY-SessionX
    • YYYY:年度

    • SessionX:連番または「Spring/Summer/Winter」など

運用例

Classroom名 開催回 役割
ACOT-2025-01 第1回 10日間コースの管理
ACOT-2025-02 第2回 別期の10日間コース
ACOT-2025-03 第3回 さらに別期
  • 新しい回は既存のテンプレートリポジトリを使ってすぐ作成可能

  • 学生の提出物は各回のClassroomで独立管理


3️⃣ テンプレートリポジトリの活用

  • テンプレートリポジトリ を1つ作っておき、毎回の課題配布に使います

    • 例:riscv-lab-template

  • ClassroomのAssignment作成時に「このテンプレートを使用」するだけで自動で学生用リポジトリが生成されます

  • 日ごとの課題がある場合は、テンプレートを複数用意しても良い

    • Day1〜Day10で別テンプレートでもOK


4️⃣ 年間運用フロー(複数回開催)

  1. 年度初め

    • Organizationとテンプレートリポジトリを作成

  2. 各回開催前

    • Classroomを新規作成

    • Assignmentをテンプレートから生成

  3. 開催中

    • 午前:講義資料を配布

    • 午後:学生はAssignmentをクローン/Codespacesで実習

  4. 開催後

    • Classroomをアーカイブ

    • 提出物やコードはOrganization内で保持

  5. 次回開催

    • 既存テンプレートを流用

    • Classroom名を更新して新規作成

    • 学生招待リンクを配布


5️⃣ ベストプラクティス

項目 ポイント
Classroom命名 ACOT-YYYY-SessionX の形式で整理
テンプレート Docker/Codespaces含む再現環境を用意
Assignment 1日ごとに課題として分ける(Day1〜Day10)
学生管理 期ごとに独立したClassroomで管理
自動化 GitHub Actionsでビルド/採点を組み込むと効率化

? まとめ

  • 1 Organization = 全年間の管理

  • 1 Classroom = 1回の開催

  • 1 Assignment = 1日分の課題

  • テンプレートリポジトリ = 課題配布用の共通ベース

この構造により、年3回でも5回でも、任意の回数の開催に対応可能です。


希望であれば、次のステップとして
「複数回開催用に、1つのOrganizationでClassroomとAssignmentを自動生成する手順書」 を作成してお渡しできます。

作りますか?

 

GitHubワークショップの流れ(図解)

 

テンプレートリポジトリ (template)
└─ Use this template → 自分のリポジトリを作成

├─ mainブランチ(安定版)

└─ featureブランチ / 課題ブランチ
├─ 作業: 課題解答や実装
├─ コミットで進捗記録
└─ Pull Request (PR) で報告
└─ 教師がレビュー・フィードバック

流れをステップでまとめると

  1. テンプレート指定

    • 教師が用意した「雛形リポジトリ」を基に自分のリポジトリを作る

    • 独立した作業環境が作れる

  2. ブランチ作成

    • 課題ごとや機能ごとにブランチを作成

    • mainは安定版として残す

  3. 作業 & コミット

    • 課題や機能を実装し、コミットで記録

    • 例: git commit -m "Solve exercise 1"

  4. 報告 (Pull Request)

    • ブランチの作業内容をPRで提出

    • 教師やチームに「ここまでやりました」と通知

  5. レビュー & マージ

    • 教師がレビュー → 問題なければ main に統合

    • 必要なら修正後に再PR


? 補足

  • forkは他人のリポジトリをコピーする場合

  • templateは教育用の雛形リポジトリとして独立コピー

  • branchは同じリポジトリ内で作業を分けるための枝

  • 報告はPRやIssueで進捗や成果を伝えること

? Using Git and GitHub in the RISC-V SoC FPGA Seminar

(From the participant’s perspective)


✅ 1. Preparation

  1. Create a GitHub account

    • Each student should have their own GitHub account (free plan is fine).

    • You can apply for GitHub Education for extra features if you have a student ID.
      ? Apply for GitHub Education

  2. Install and configure Git (on your local PC or Docker container):

    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
  3. Clone the seminar’s starter repository

    • The seminar instructor will prepare a GitHub repository that includes initial source files, scripts, and documentation.

    • You will clone it to your own environment before starting your work.


⚙️ 2. Typical Workflow for Participants

  1. Clone the repository

    git clone <repository_url>
    cd <repository_name>

    → You now have the seminar project on your local machine.

  2. Work locally (HDL / C code development)

    • Edit source files under src/ or software/ folders.

    • Save changes and commit them:

      git add <file>
      git commit -m "Describe what you changed"
  3. Push your updates to GitHub

    git push origin main

    → Your work is now saved remotely and visible to instructors or teammates.

  4. Collaborate using branches and pull requests

    • For team projects, create separate branches:

      git checkout -b feature/<branch_name>
    • After finishing a task, open a Pull Request (PR) to merge your branch into main.

    • Instructors or teammates can review and comment before merging.

  5. Submit your assignment

    • The instructor might ask you to push to a specific branch or create a tag for submission:

      git tag v1.0
      git push origin v1.0
  6. Review your progress

    • View commit history:

      git log
    • Compare versions:

      git diff
    • Revert changes if needed:

      git revert <commit_id>

? 3. Basic Command Reference

Action Command Example
Clone repository git clone <URL>
Stage changes git add <file>
Commit changes git commit -m "message"
Push to remote git push origin <branch>
Pull from remote git pull origin <branch>
Create new branch git checkout -b <branch>
View history git log
Check differences git diff
Undo changes git revert <commit_id> / git checkout <file>

? GitHub Cheat Sheet (official PDF): education.github.com/git-cheat-sheet-education.pdf


? 4. Best Practices for RISC-V / FPGA Projects

  • Use a clear folder structure, for example:

    /hardware → Verilog / VHDL sources
    /software → C / assembly code for RISC-V
    /scripts → build, synthesis, and programming scripts
    /docs → lab reports, simulation results
  • Commit frequently with meaningful messages (“Add UART driver”, “Fix memory map”).

  • Use branches to separate hardware, software, and test work.

  • Use Pull Requests for instructor reviews.

  • Save logs (simulation waveforms, UART outputs, etc.) as Markdown files in /docs for traceability.

  • GitHub Issues and Discussions can be used to track bugs and questions.


? 5. What You’ll Learn by Using GitHub

  • Real-world version control skills used in professional FPGA and SoC design workflows.

  • Collaboration and review workflow (just like in open-source RISC-V projects).

  • How to document and manage both hardware and software design progress.

目的

受講者がUbuntu PCで簡単に「RISC-V SoC設計」環境を使えるように、
開発ツール+VSCode+サンプルデータをあらかじめ入れたDockerイメージを作ります。


手順一覧

① Ubuntuの準備

まず、Ubuntu(22.04推奨)をインストールしておきます。
すでにUbuntuが入っている人は、そのままでOKです。

② Dockerのインストール

端末を開いて以下を実行します。

sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release

Docker公式キーを登録します:

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

リポジトリを登録:

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Docker本体をインストール:

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

テスト:

sudo docker run hello-world

→ “Hello from Docker!” が出れば成功です。


③ Dockerfile の作成

次に、ツールをまとめたDockerイメージの設計図「Dockerfile」を作ります。
例えば、次のようなファイルを作ります。

ファイル名: Dockerfile

# ベースとなるUbuntu
FROM ubuntu:22.04

# 環境変数(自動で対話モードをスキップ)
ENV DEBIAN_FRONTEND=noninteractive

# 基本ツールのインストール
RUN apt update && apt install -y \
build-essential git wget curl vim \
python3 python3-pip \
sudo

# RISC-V ツールチェーンのインストール
RUN apt install -y gcc-riscv64-unknown-elf gdb-multiarch

# VSCodeサーバーをインストール(リモート接続用)
RUN apt install -y wget
RUN wget https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64 -O vscode.deb && \
apt install -y ./vscode.deb

# FPGAツール(例: yosys, nextpnr, verilatorなど)
RUN apt install -y yosys nextpnr-ice40 verilator gtkwave

# 作業ディレクトリを設定
WORKDIR /workspace

# サンプルプロジェクトをコピー(同じフォルダに sample/ を用意しておく)
COPY sample/ /workspace/sample/

# デフォルトユーザ
RUN useradd -ms /bin/bash student
USER student


④ サンプルデータを用意

同じフォルダに sample/ ディレクトリを作り、
中に以下のようなものを入れます。

sample/
├── hello_riscv.c
├── Makefile
└── README.md

例: hello_riscv.c

#include <stdio.h>
int main() {
printf("Hello RISC-V World!\n");
return 0;
}

⑤ イメージをビルドする

ターミナルで Dockerfile のあるフォルダに移動して:

sudo docker build -t riscv-edu:latest .

完了すると、イメージ一覧に表示されます:

sudo docker images

出力例:

REPOSITORY TAG IMAGE ID CREATED SIZE
riscv-edu latest a1b2c3d4e5f6 10 seconds ago 2.1GB

⑥ コンテナとして起動

sudo docker run -it --name riscv-container riscv-edu:latest

コンテナに入ると、/workspace/sample にサンプルが入っています。


⑦ イメージを配布する(受講者用)

講師のPCで作ったイメージを保存:

sudo docker save -o riscv-edu.tar riscv-edu:latest

この riscv-edu.tar ファイルをUSBやクラウドで配布し、
受講者は以下でロードします:

sudo docker load -i riscv-edu.tar

その後、同様に起動できます:

sudo docker run -it riscv-edu:latest

これで完成!

受講者はワンクリックで同じ環境を再現できます。
(Docker Desktopを使えばGUIでも起動可能)


次に進めるなら、

  • クラウド配布方法(例:Docker Hubや自社サーバ)

  • VSCode Remote接続での使用法

  • FPGAボードと連携する設定

のいずれかを詳しく説明できます。
どれに進めますか?

あなた:
講師はGithub上に作成、受講者はGithubからダウンロードの方式
ChatGPT:

とても良い方法です!
DockerイメージやサンプルデータをGitHubで一元管理すれば、
受講者は「GitHubからクローンしてビルド」するだけで、
全員が同じ環境を再現できます。

以下に、**講師側(GitHubに登録する側)受講者側(GitHubから使う側)**の
両方の手順を詳しく説明します。


講師側:GitHubでDocker環境を公開する手順

① GitHubリポジトリを作成

  1. GitHubにログイン

  2. 「New repository」 →
    例:

    • Repository name: riscv-edu-docker

    • Description: RISC-V SoC Education Docker Environment

    • Public(またはPrivate)を選択

  3. 「Create repository」をクリック


② リポジトリ構成例

ローカルPCで以下のような構成を作ります:

riscv-edu-docker/
├── Dockerfile
├── sample/
│ ├── hello_riscv.c
│ ├── Makefile
│ └── README.md
└── README.md

例:Dockerfile

FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y \
build-essential git wget curl vim \
python3 python3-pip sudo

# RISC-V コンパイラとツール群
RUN apt install -y gcc-riscv64-unknown-elf gdb-multiarch

# FPGAツール
RUN apt install -y yosys nextpnr-ice40 verilator gtkwave

# 作業ディレクトリ
WORKDIR /workspace
COPY sample/ /workspace/sample/

RUN useradd -ms /bin/bash student
USER student


例:sample/hello_riscv.c

#include <stdio.h>
int main() {
printf("Hello RISC-V World!\n");
return 0;
}

例:sample/Makefile

CC = riscv64-unknown-elf-gcc
CFLAGS = -O2
TARGET = hello_riscv
SRC = hello_riscv.c

all:
$(CC) $(CFLAGS) -o $(TARGET) $(SRC)


例:README.md

# RISC-V Education Docker Environment

This repository provides a pre-configured Docker image for RISC-V SoC design education.

## Build the Docker Image

```bash
git clone https://github.com/<yourname>/riscv-edu-docker.git
cd riscv-edu-docker
sudo docker build -t riscv-edu:latest .

Run the Container

sudo docker run -it --name riscv-container riscv-edu:latest

Inside the container, you can find sample files in /workspace/sample.


---

## ③ GitHubへアップロード

端末で以下を実行:

```bash
cd riscv-edu-docker
git init
git add .
git commit -m "Initial RISC-V Docker education environment"
git branch -M main
git remote add origin https://github.com/<yourname>/riscv-edu-docker.git
git push -u origin main

これでGitHub上に公開されます。


オプション:GitHub Container Registryに直接イメージを公開

DockerイメージそのものをGitHubにホストすることも可能です。
(受講者は「docker pull」で即取得可能)

  1. GitHubにログイン → [Personal Access Token] を作成

  2. ターミナルでログイン:

    echo <TOKEN> | docker login ghcr.io -u <USERNAME> --password-stdin
  3. イメージをタグ付けしてプッシュ:

    docker tag riscv-edu ghcr.io/<USERNAME>/riscv-edu:latest
    docker push ghcr.io/<USERNAME>/riscv-edu:latest

受講者は:

docker pull ghcr.io/<USERNAME>/riscv-edu:latest

で入手できます。


受講者側:GitHubから環境をセットアップする手順

① GitHubから取得

git clone https://github.com/<講師のアカウント>/riscv-edu-docker.git
cd riscv-edu-docker

② Dockerイメージをビルド

sudo docker build -t riscv-edu:latest .

③ コンテナを起動

sudo docker run -it --name riscv-container riscv-edu:latest

④ サンプルを実行

コンテナの中で:

cd /workspace/sample
make
./hello_riscv

出力例:

Hello RISC-V World!

まとめ

項目 講師 受講者
リポジトリ作成 GitHubで作成 git clone
イメージ作成 docker build 同じ
配布方式 GitHub経由(コード or イメージ) GitHubから取得
実行方法 docker run 同じ
更新 GitHubでgit push git pullで反映

次に説明できます:

? 1. GitHubを使った進捗管理(最も推奨)

? 方法概要

受講者ごとに GitHubリポジトリを割り当てし、
自分の作業内容(ソースコード・レポート)をプッシュさせる方式です。

これにより、講師はGitHub上で全員の進捗を可視化できます。


✅ 導入手順

① 講師側の準備

  1. GitHub Classroom(教育向け無料サービス)を利用します。
    https://classroom.github.com

  2. 「New Classroom」を作成
    例:

    • Name: RISC-V_Seminar_2025

  3. 「Create new assignment」を選択

    • Assignment name: Day1_Setup

    • Repository template: riscv-edu-docker(前回の教材用リポジトリを指定)

    • Type: Individual assignment

② 受講者の参加

  1. 講師が発行したURLを共有
    例:

    https://classroom.github.com/a/xyz123
  2. 受講者はGitHubでログインし、
    自分用のリポジトリが自動生成されます。
    例:
    https://github.com/riscv-seminar/student001-Day1_Setup

③ 提出と進捗確認

  • 受講者は作業をGitで記録:

    git add .
    git commit -m "Day1 finished: built RISC-V toolchain"
    git push
  • 講師はClassroomの管理画面で:

    • 各学生の進捗(push日時、ファイル変更)

    • 提出状況(完了・未提出)
      を一覧表示で確認できます。


? メリット

  • 自動で個別リポジトリを作成・整理

  • 進捗がリアルタイムに可視化

  • GitHub上でソースコードのレビューやコメントも可能

  • 課題提出・採点が簡単


? 2. Docker + ログ提出方式(オフライン併用)

概要

ネットが不安定な会場では、Dockerコンテナ内部での作業ログを保存し、
終了時にUSBやクラウドで回収する方法も使えます。


手順

① 受講者のコンテナにログ記録設定

講師が配布するDockerfileに次を追加:

RUN apt install -y script

セミナー開始時に:

script /workspace/worklog.txt

→ すべての端末操作が /workspace/worklog.txt に自動記録されます。

終了時に:

exit

② ログを提出

受講者は:

docker cp riscv-container:/workspace/worklog.txt .

→ ファイルを講師へ提出(USBやメール)


? メリット

  • ネット接続不要

  • コマンド履歴がそのまま残る

  • 短期セミナーでのバックアップ確認に有効


☁️ 3. クラウドモニタリング方式(上級)

もし会場に安定したネット環境がある場合、
Dockerコンテナの作業状況をクラウドサーバで監視することもできます。


構成例

役割 内容
講師サーバ GitHubまたは自社クラウド(例:AWS, Azure, GCP)
受講者PC Dockerコンテナ上で実行
通信 Git push / VSCode Remote / SSH over VPN

例:進捗確認スクリプト

受講者のコンテナで以下を定期実行:

git add progress.log
git commit -m "auto progress update"
git push origin main

progress.log に自動で時間・作業ステップを記録させます。
講師側はGitHubのcommit履歴を見て進捗を確認できます。


? メリット

  • 全員の活動をリアルタイムに把握

  • 作業の記録がクラウドに残る

  • 遠隔セミナーにも対応可


? まとめ比較表

管理方式 特徴 ネット接続 導入難易度 推奨用途
GitHub Classroom 自動でリポジトリ管理・進捗可視化 必要 ★★ 大学・研修セミナー
Dockerログ提出 ログ保存で後日確認可能 不要 短期オフライン研修
クラウド監視(Git push) リアルタイム進捗追跡 必要 ★★★ オンライン・上級講座

教員資格なしで、GitHubを教育・セミナー用途に使う

? 目的

教員資格なしで、GitHubを教育・セミナー用途に使う
(受講者に課題を配布・提出・レビューできるようにする)


? 全体構成イメージ

GitHub Organization(例:riscv-seminar)
├── template-lab1/ ← 課題テンプレート(共通)
├── student-A-lab1/ ← 受講者Aの提出
├── student-B-lab1/ ← 受講者Bの提出
└── README.md ← セミナー全体案内

受講者はテンプレートから自分の課題リポジトリを作成します。
講師はその内容をレビューできます。


? 手順(ステップごと)

Step 1. Organization(組織)を作成

  1. GitHubにログイン

  2. https://github.com/account/organizations/new を開く

  3. 「Free plan」を選択

  4. 名前例:riscv-seminar

  5. 説明:RISC-V Training Workshop 2025

? これが「クラスルームの代わり」となる教育グループです。


Step 2. 課題テンプレートリポジトリを作成

  1. Organization内で新しいリポジトリを作成

    • 名前例:riscv-lab1-template

    • 公開設定:Private

    • README.mdを追加

  2. Dockerfile や RISC-Vの教材ファイルを入れる

例:

.
├── README.md
├── Dockerfile
├── lab1.c
└── instructions.md
  1. Settings → Template repository にチェックを入れる
    (これで学生が「Use this template」でコピー可能になります)


Step 3. 受講者(学生)を招待

  1. Organization ページの
    ?「People」→「Invite member」

  2. 各学生のGitHubアカウント名を入力して招待

? Organization内の権限を「Member」に設定すれば安全です。


Step 4. 課題の配布(テンプレート利用)

受講者に伝えるだけです:

  1. riscv-lab1-template リポジトリを開く

  2. 「Use this template」→「Create a new repository」

  3. 名前を lab1-<username> にする

  4. 自分のアカウントまたはOrganization配下に作成

? これで自動的に各学生の個別リポジトリが作られます。


Step 5. 提出・レビュー

受講者:

git add .
git commit -m "Submit Lab1"
git push

講師:

  • 各学生のリポジトリにアクセスし、Pull Requestを作成してレビュー

  • コメントや添削もGitHub上で実施可能


Step 6. (任意)Codespacesでの即時開発環境

テンプレートに .devcontainer/devcontainer.json を追加しておくと、
受講者はブラウザから即開発できます(ローカル環境不要)。

例:

{
"name": "RISC-V Dev",
"image": "ubuntu:22.04",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"postCreateCommand": "apt update && apt install -y gcc-riscv64-unknown-elf"
}

→ 各学生は
「Code → Open with Codespaces」クリックだけでRISC-V環境を起動できます。


✅ メリット

項目 内容
教員資格不要 GitHub FreeだけでOK
個別リポジトリ自動作成 テンプレート機能で代用可能
成績管理 IssueやPRを使って評価記録
環境統一 CodespacesまたはDockerで全員同じ環境
チーム対応 Organizationで一括管理

? 応用例

  • lab2-template, lab3-template など複数課題を分ける

  • READMEに「課題提出手順」や「評価基準」を書く

  • Actions を使って自動採点(スクリプトテスト)も可能


もし希望があれば、

「RISC-V Lab1」の実例テンプレート(Dockerfile付き)を
GitHub Classroom代替用に作成
することもできます。

作成しましょうか?

あなた:
はい
ChatGPT:
Riscv-lab1-template (git Hub Template)

riscv-lab1-template

このリポジトリは GitHub Classroom を使わずに配布できる RISC‑V 実習(Lab1)テンプレート のサンプルです。 受講者が「Use this template」で自分のリポジトリを作れるように設計されています。


ファイル構成(このテンプレートに含まれます)

  • README.md – このリポジトリの説明(使い方)。
  • Dockerfile – 開発/ビルド環境(Ubuntu 22.04 + RISC‑V クロスコンパイラ)
  • Makefile – ビルド手順(make でコンパイル)
  • lab1.c – サンプル課題ソース(非常に簡単な C プログラム)
  • instructions.md – 受講者向け提出手順・チェックリスト
  • .devcontainer/devcontainer.json – Codespaces / VS Code Remote 用設定
  • .github/workflows/ci.yml – GitHub Actions の簡易 CI(ビルド確認)

利用方法(講師)

  1. Organization を作成(例: riscv-seminar)。
  2. このテンプレートを Organization 内に配置し、Settings → Template repository を有効化する。
  3. 受講者に「Use this template」で個別リポジトリを作成するよう案内する。
  4. 受講者は Code → Open with Codespaces または Docker を使ってビルド/実行できる。

ファイル内容(各ファイルは以下のとおり)


README.md

# RISC-V Lab1 (Template)
This repository is a template for RISC-V Lab1 exercises.
## Quick start (local Docker)
1. Build the dev image:
“`bash
docker build -t riscv-dev .
  1. Start a container (mount current dir):
    docker run –rm -it -v $PWD:/workspace -w /workspace riscv-dev bash
  2. Inside container, build:
    make

Quick start (Codespaces)

  • Click Code → Open with Codespaces (or open in VS Code Remote – Containers). The repository contains a .devcontainer so Codespaces will set up the environment automatically.

What to submit

  • Push your working tree to the repository created from this template.
  • Create a Pull Request (PR) to the instructor or open an Issue with a link to your repo when you finish.

Dockerfile

FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Basic tools + riscv cross toolchain
RUN apt-get update \
&& apt-get install -y –no-install-recommends \
build-essential \
git \
wget \
ca-certificates \
make \
python3 \
pkg-config \
gcc-riscv64-unknown-elf \
gdb-multiarch \
&& rm -rf /var/lib/apt/lists/*
# Create a workspace user
RUN useradd -m coder || true
USER coder
WORKDIR /workspace
CMD [“/bin/bash”]

Makefile

# Simple Makefile to build a RISC-V ELF using the cross-compiler
CC := riscv64-unknown-elf-gcc
CFLAGS := -march=rv64imac -mabi=lp64 -O0 -g
TARGET := lab1.elf
SRC := lab1.c
all: $(TARGET)
$(TARGET): $(SRC)
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f $(TARGET)
.PHONY: all clean

lab1.c

// Simple Lab1 sample: performs a small computation and returns a value
// Note: this is intentionally minimal to avoid depending on libc for runtime.
int main(void) {
volatile int sum = 0;
for (int i = 0; i < 10; ++i) {
sum += i;
}
// Return the computed value (on many toolchains, return value is visible to simulator)
return sum;
}

instructions.md

# Lab1: 提出手順(受講者向け)
1. このリポジトリをテンプレートからコピーして、自分のリポジトリを作成する。
2. (推奨) Codespaces を使うか、ローカルで Docker を使ってビルドする。
## ローカル Docker での手順
“`bash
# リポジトリを clone
git clone <your-repo-url>
cd <your-repo>
# イメージをビルド
docker build -t riscv-dev .
# コンテナを起動してビルド
docker run –rm -it -v “$PWD”:/workspace -w /workspace riscv-dev bash -c “make”

ビルドに成功すると lab1.elf が生成されます。


提出方法

  • 生成物(elf)を push する必要はありません。ソースを push してください。
  • PR を作成し、レビューを依頼するか、Instructor に Issue で提出してください。

.devcontainer/devcontainer.json

{
“name”: “RISC-V Devcontainer”,
“build”: {
“dockerfile”: “Dockerfile”,
“context”: “.”
},
“workspaceFolder”: “/workspace”,
“remoteUser”: “coder”,
“postCreateCommand”: “make || true”,
“overrideCommand”: false
}

.github/workflows/ci.yml

name: CI – build
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
uses: actions/checkout@v4
name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-riscv64-unknown-elf make
name: Build
run: make

追加の提案・拡張

  • 自動採点: .github/workflows とスクリプトで出力の自動テストを行う(例: expect スクリプトや QEMU/Spike を用いた実行テスト)。
  • テンプレートの README に評価基準や提出期限を明記。
  • Codespaces の利用を促すために、postCreateCommand で追加セットアップを行う。

必要なら、これを実際の GitHub リポジトリとして作成(ZIP 生成・リポジトリ初期化)する手順も作成します。どちらにしますか?

テンプレートを作成しました ✅(表示ファイルはキャンバスにあります:riscv-lab1-template

次にできること(選んでください):

  1. 私に このテンプレートで GitHub リポジトリを実際に作成 してほしい(あなたのOrganization名・リポジトリ名を教えてください)。

  2. 私に テンプレートを ZIP にしてダウンロード用ファイルを作ってほしい(その場で作成してダウンロードリンクをお渡しします)。

  3. 今のままテンプレート内容を修正・拡張したい(自動採点スクリプトや QEMU 実行テストなどを追加)。

どれを進めますか? (番号で教えてください)