Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 30 additions & 86 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262

- name: Install dependencies
run: |
Expand All @@ -34,110 +34,54 @@ jobs:
gcc-riscv64-unknown-elf \
make \
python3 \
python3-yaml \
verilator
python3-yaml

- name: Install Verilator 5.050
run: bash scripts/ci/install_verilator.sh

- name: Prepare minimal ECOS SDK headers
run: |
mkdir -p "$ECOS_SDK/include" \
"$ECOS_SDK/components/libc/include" \
"$ECOS_SDK/components/libgcc/include" \
"$ECOS_SDK/lib"

cat > "$ECOS_SDK/include/hal_sys_uart.h" <<'EOF'
#ifndef HAL_SYS_UART_H
#define HAL_SYS_UART_H
#include <stdint.h>
void hal_sys_uart_init(void);
void hal_sys_putchar(char c);
void hal_sys_putstr(char *str);
uint8_t hal_sys_getchar(void);
#endif
EOF

cat > "$ECOS_SDK/include/hal_gpio.h" <<'EOF'
#ifndef HAL_GPIO_H
#define HAL_GPIO_H
#include <stdint.h>
#define GPIO_LEVEL_LOW 0u
#define GPIO_LEVEL_HIGH 1u
void hal_gpio_set_dir(uint32_t value);
uint32_t hal_gpio_get_dir(void);
uint32_t hal_gpio_get_input(void);
uint32_t hal_gpio_get_output(void);
void hal_gpio_set_output(uint32_t value);
void hal_gpio_set_level(uint32_t pin, uint32_t level);
uint32_t hal_gpio_get_level(uint32_t pin);
#endif
EOF

cat > "$ECOS_SDK/include/hal_timer.h" <<'EOF'
#ifndef HAL_TIMER_H
#define HAL_TIMER_H
#include <stdint.h>
void hal_timer_stop(void);
void hal_timer_set_prescale(uint32_t value);
void hal_timer_set_cmp(uint32_t value);
void hal_timer_set_ctrl(uint32_t value);
uint32_t hal_timer_get_stat(void);
void hal_timer_clear(void);
void delay_ms(uint32_t value);
#endif
EOF

cat > "$ECOS_SDK/include/hal_uart.h" <<'EOF'
#ifndef HAL_UART_H
#define HAL_UART_H
#include <stdint.h>
void hal_uart_init(uint32_t baud);
void hal_uart_putchar(char c);
void hal_uart_putstr(const char *str);
int hal_uart_getchar(void);
#endif
EOF

cat > "$ECOS_SDK/components/libc/include/string.h" <<'EOF'
#ifndef STRING_H
#define STRING_H
#include <stddef.h>
void *memcpy(void *dest, const void *src, size_t n);
void *memset(void *s, int c, size_t n);
size_t strlen(const char *s);
int strcmp(const char *s1, const char *s2);
#endif
EOF

cat > "$ECOS_SDK/components/libc/include/stdio.h" <<'EOF'
#ifndef STDIO_H
#define STDIO_H
int printf(const char *format, ...);
int puts(const char *s);
#endif
EOF

cat > "$ECOS_SDK/components/libgcc/include/libgcc.h" <<'EOF'
#ifndef LIBGCC_H
#define LIBGCC_H
#endif
EOF
run: bash scripts/ci/prepare_minimal_ecos_sdk.sh "$ECOS_SDK"

- name: Check Python scripts
run: python3 -m py_compile scripts/*.py

- name: Run unit tests
run: python3 -m unittest discover -s tests -v

- name: Check bilingual documentation
run: make -f Makefile.dev docs-check

- name: Check generated SoC package is current
run: |
make gen-soc-pkg
make -f Makefile.dev gen-soc-pkg
git diff --exit-code hw/include/soc_pkg.sv

- name: Check fixed 50 MHz configuration
run: make -f Makefile.dev config-check

- name: Build software from source
run: make -C sw BOARD=mpc-soc APP=hello

- name: Check software configuration rebuilds
run: |
make -C sw BOARD=mpc-soc APP=hello LINK_TARGET=mem
grep -q '^#define CONFIG_LINK_TARGET_MEM 1$' build/sw/mpc-soc/hello/generated/autoconf.h
test "$(riscv64-unknown-elf-readelf -h build/sw/mpc-soc/hello/hello.elf | awk '/Entry point address:/ {print $4}')" = "0xc0000000"
make -C sw BOARD=mpc-soc APP=hello LINK_TARGET=xip
grep -q '^#define CONFIG_LINK_TARGET_XIP 1$' build/sw/mpc-soc/hello/generated/autoconf.h
test "$(riscv64-unknown-elf-readelf -h build/sw/mpc-soc/hello/hello.elf | awk '/Entry point address:/ {print $4}')" = "0x30000000"

- name: Build Verilator simulator
run: make verilate TRACE=0

- name: Run source-built hello smoke
run: |
make -C dv/verilator sim \
BOOTROM_IMAGE="$PWD/build/sw/mpc-soc/hello/hello.bin" \
UART_STOP_TEXT='done!' \
ALLOW_TIMEOUT=0 \
TRACE=0

- name: Run bootrom regression
run: make -f Makefile.dev regress OUTPUT=list STOP_ON_FAIL=1 TRACE=0

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ jobs:
timeout-minutes: 10
steps:
- name: Check out source
uses: actions/checkout@v5
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@v6
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with:
node-version: 24
cache: npm
cache-dependency-path: dev/site/package-lock.json
- name: Set up Pages
uses: actions/configure-pages@v5
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b
- name: Install dependencies
run: npm --prefix dev/site ci
- name: Validate and build documentation
run: make -f Makefile.dev docs-site-check
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b
with:
path: build/docs-site/.vitepress/dist

Expand All @@ -79,4 +79,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
179 changes: 179 additions & 0 deletions .github/workflows/user-kit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: User Kit

'on':
pull_request:
branches: [main]
workflow_dispatch: {}
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]

permissions:
contents: read

concurrency:
group: user-kit-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
export_and_test:
if: >-
github.event_name != 'workflow_run' ||
(
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.head_repository.full_name == github.repository
)
runs-on: ubuntu-24.04
timeout-minutes: 45
outputs:
soc_version: ${{ steps.release.outputs.version }}
env:
SOURCE_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
steps:
- name: Check out tested source
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
fetch-depth: 0
ref: ${{ env.SOURCE_SHA }}

- name: Read release version
id: release
shell: bash
run: |
set -euo pipefail
version="$(tr -d '[:space:]' < VERSION)"
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
echo "Invalid VERSION: $version" >&2
exit 2
}
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
make \
python3 \
python3-yaml

- name: Install Verilator 5.050
run: bash scripts/ci/install_verilator.sh

- name: Export user kit
run: make -f Makefile.dev export-user-kit

- name: Verify user and maintainer boundaries
run: |
test ! -e build/user-kit/.github
test ! -e build/user-kit/dev
test ! -e build/user-kit/Makefile.dev
test ! -e build/user-kit/mk/dev.mk
test ! -e build/user-kit/tests
test ! -e build/user-kit/sw/Makefile
test ! -e build/user-kit/sw/ecos
test ! -e build/user-kit/sw/ecos.mk
test -f build/user-kit/SOC_KIT_VERSION
test -f build/user-kit/sw/bootrom/hello/test.yml
test -f build/user-kit/sw/bootrom/hello/retrosoc_fw.bin
test "$(find build/user-kit/sw/bootrom -mindepth 1 -maxdepth 1 -type d -printf '%f\n')" = "hello"

- name: Test fixed-image user workflow
run: |
make -C build/user-kit doctor
make -C build/user-kit sim TRACE=0
make -C build/user-kit check CASE=hello TRACE=0

- name: Clean tested user kit
run: |
rm -rf build/user-kit/build
test ! -e build/user-kit/build
test ! -e build/user-kit/Makefile.dev
test ! -e build/user-kit/dev

- name: Upload versioned user kit
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: mpc-soc-user-kit-${{ steps.release.outputs.version }}
path: build/user-kit/
if-no-files-found: error
include-hidden-files: true
retention-days: 14

publish:
if: >-
github.event_name == 'workflow_run' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.head_repository.full_name == github.repository
needs: export_and_test
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
env:
SOC_VERSION: ${{ needs.export_and_test.outputs.soc_version }}
SOURCE_SHA: ${{ github.event.workflow_run.head_sha }}
GH_TOKEN: ${{ github.token }}
steps:
- name: Check out tested source
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_sha }}

- name: Download tested user kit
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: mpc-soc-user-kit-${{ needs.export_and_test.outputs.soc_version }}
path: build/user-kit

- name: Publish new User Kit version
shell: bash
run: |
set -euo pipefail
tag="user-kit-v${SOC_VERSION}"
if git ls-remote --exit-code --tags origin "refs/tags/${tag}" >/dev/null 2>&1; then
echo "${tag} already exists; keeping the published version unchanged."
exit 0
fi

export_dir="$PWD/build/user-kit"
staging_dir="$(mktemp -d)"
cp -a "$export_dir/." "$staging_dir/"

git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git switch --orphan release-user-kit-work
git rm -rf --ignore-unmatch .
cp -a "$staging_dir/." .
git add -A
git commit -m "user-kit: release ${SOC_VERSION} from ${SOURCE_SHA}"
git tag -a "$tag" -m "mpc-soc User Kit ${SOC_VERSION}"
git push --atomic origin \
+HEAD:refs/heads/release/user-kit \
"refs/tags/${tag}"

- name: Publish immutable release archive
shell: bash
run: |
set -euo pipefail
tag="user-kit-v${SOC_VERSION}"
if gh release view "$tag" >/dev/null 2>&1; then
echo "GitHub Release ${tag} already exists."
exit 0
fi

git fetch --force origin "+refs/tags/${tag}:refs/tags/${tag}"
archive="$RUNNER_TEMP/mpc-soc-user-kit-${SOC_VERSION}.tar.gz"
git archive --format=tar.gz \
--prefix="mpc-soc-user-kit-${SOC_VERSION}/" \
--output="$archive" "$tag"
gh release create "$tag" "$archive" \
--verify-tag \
--title "mpc-soc User Kit ${SOC_VERSION}" \
--notes "Fixed-image core integration User Kit for mpc-soc ${SOC_VERSION}."
Loading
Loading