Skip to content

Commit 624c9ba

Browse files
committed
sg204x: refactoring pipeline
1 parent 9929b31 commit 624c9ba

File tree

3 files changed

+156
-107
lines changed

3 files changed

+156
-107
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
target_name:
5+
required: true
6+
type: string
7+
opensbi_repo:
8+
required: true
9+
type: string
10+
opensbi_ref:
11+
required: true
12+
type: string
13+
14+
jobs:
15+
build-opensbi:
16+
name: Build OpenSBI
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Cache OpenSBI Build
20+
id: cache-opensbi-build
21+
uses: actions/cache@v5
22+
with:
23+
path: dist
24+
key: cache-opensbi-build-${{ inputs.target_name }}-ref=${{ inputs.opensbi_ref }}-wf=${{ hashFiles('ctx/.github/workflows/.sophgo-sg204x.opensbi-build.yml') }}
25+
- uses: actions/checkout@v5
26+
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
27+
- name: Setup Toolchains
28+
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
29+
id: setup-gcc-toolchain
30+
uses: ./.github/actions/riscv64-gcc-toolchain
31+
- name: Checkout OpenSBI
32+
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
33+
uses: actions/checkout@v6
34+
with:
35+
repository: ${{ inputs.opensbi_repo }}
36+
path: opensbi
37+
ref: ${{ inputs.opensbi_ref }}
38+
fetch-depth: 1
39+
- name: Build OpenSBI
40+
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
41+
run: |
42+
make -j"$(nproc)" -C opensbi O=$(pwd)/build CROSS_COMPILE=${{ steps.setup-gcc-toolchain.outputs.full-prefix }} PLATFORM=generic FW_PIC=y BUILD_INFO=y
43+
- name: Collect OpenSBI Binary
44+
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
45+
run: |
46+
mkdir dist
47+
cp build/platform/generic/firmware/fw_dynamic.bin dist/fw_dynamic.bin
48+
- name: Upload Artifacts
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: "opensbi-${{ inputs.target_name }}"
52+
path: dist
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
target_name:
5+
required: true
6+
type: string
7+
zsbl_repo:
8+
required: true
9+
type: string
10+
zsbl_ref:
11+
required: true
12+
type: string
13+
zsbl_defconfig:
14+
required: true
15+
type: string
16+
17+
jobs:
18+
build-zsbl:
19+
name: Build ZSBL
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v6
23+
with:
24+
path: ctx
25+
- name: Cache ZSBL Build
26+
id: cache-zsbl-build
27+
uses: actions/cache@v5
28+
with:
29+
path: dist
30+
key: cache-zsbl-build-${{ inputs.target_name }}-ref=${{ inputs.zsbl_ref }}-wf=${{ hashFiles('ctx/.github/workflows/.sophgo-sg204x.zsbl-build.yml') }}
31+
- name: Setup Toolchains
32+
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
33+
id: setup-gcc-toolchain
34+
uses: ./ctx/.github/actions/riscv64-gcc-toolchain
35+
- name: Checkout ZSBL
36+
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
37+
uses: actions/checkout@v6
38+
with:
39+
repository: ${{ inputs.zsbl_repo }}
40+
path: zsbl
41+
ref: ${{ inputs.zsbl_ref }}
42+
fetch-depth: 1
43+
- name: Build ZSBL
44+
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
45+
working-directory: zsbl
46+
run: |
47+
make -j"$(nproc)" CROSS_COMPILE=${{ steps.setup-gcc-toolchain.outputs.full-prefix }} "${{ inputs.zsbl_defconfig }}"
48+
make -j"$(nproc)" CROSS_COMPILE=${{ steps.setup-gcc-toolchain.outputs.full-prefix }} USE_LINUX_BOOT=1 zsbl.bin
49+
- name: Collect ZSBL Binary
50+
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
51+
run: |
52+
mkdir dist
53+
cp zsbl/zsbl.bin dist/zsbl.bin
54+
- name: Upload Artifacts
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: "zsbl-${{ inputs.target_name }}"
58+
path: dist

.github/workflows/sophgo-sg204x.yml

Lines changed: 46 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,54 @@ on:
44
push:
55
paths:
66
- '.github/workflows/sophgo-sg204x.yml'
7+
- '.github/workflows/.sophgo-sg204x.*'
78
- 'sophgo-sg204x/**'
89

910
jobs:
1011

11-
build-zsbl:
12-
name: Build ZSBL
13-
runs-on: ubuntu-latest
14-
strategy:
15-
matrix:
16-
include:
17-
- target_name: sophgo-sg2044-srd3-10
18-
zsbl_defconfig: sg2044_defconfig
19-
- target_name: sophgo-sg2042-milkv-pioneer
20-
zsbl_defconfig: sg2042_defconfig
21-
env:
22-
ZSBL_COMMIT_ID: 45054e711d81fbfa1c2167829402d26795199ae7
23-
steps:
24-
- name: Cache ZSBL Build
25-
id: cache-zsbl-build
26-
uses: actions/cache@v5
27-
with:
28-
path: dist
29-
key: cache-zsbl-build-${{ matrix.target_name }}-${{ env.ZSBL_COMMIT_ID }}
30-
- uses: actions/checkout@v5
31-
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
32-
- name: Setup Toolchains
33-
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
34-
id: setup-gcc-toolchain
35-
uses: ./.github/actions/riscv64-gcc-toolchain
36-
- name: Checkout ZSBL
37-
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
38-
uses: actions/checkout@v6
39-
with:
40-
repository: revyos/zsbl
41-
path: zsbl
42-
# Branch sg204x as of 20260224
43-
ref: ${{ env.ZSBL_COMMIT_ID }}
44-
fetch-depth: 1
45-
- name: Build ZSBL
46-
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
47-
working-directory: zsbl
48-
run: |
49-
make -j"$(nproc)" CROSS_COMPILE=${{ steps.setup-gcc-toolchain.outputs.full-prefix }} "${{ matrix.zsbl_defconfig }}"
50-
make -j"$(nproc)" CROSS_COMPILE=${{ steps.setup-gcc-toolchain.outputs.full-prefix }} USE_LINUX_BOOT=1 zsbl.bin
51-
- name: Collect ZSBL Binary
52-
if: ${{ steps.cache-zsbl-build.outputs.cache-hit != 'true' }}
53-
run: |
54-
mkdir dist
55-
cp zsbl/zsbl.bin dist/zsbl.bin
56-
- name: Upload Artifacts
57-
uses: actions/upload-artifact@v4
58-
with:
59-
name: "zsbl-${{ matrix.target_name }}"
60-
path: dist
12+
build-zsbl-sg2042:
13+
name: Build ZSBL for SG2042
14+
uses: ./.github/workflows/.sophgo-sg204x.zsbl-build.yml
15+
with:
16+
target_name: sophgo-sg2042
17+
zsbl_repo: revyos/zsbl
18+
# Branch sg204x as of 20260227
19+
zsbl_ref: 45054e711d81fbfa1c2167829402d26795199ae7
20+
zsbl_defconfig: sg2042_defconfig
21+
build-zsbl-sg2044:
22+
name: Build ZSBL for SG2044
23+
uses: ./.github/workflows/.sophgo-sg204x.zsbl-build.yml
24+
with:
25+
target_name: sophgo-sg2044
26+
zsbl_repo: revyos/zsbl
27+
# Branch sg204x as of 20260227
28+
zsbl_ref: 45054e711d81fbfa1c2167829402d26795199ae7
29+
zsbl_defconfig: sg2044_defconfig
6130

62-
build-opensbi:
63-
name: Build OpenSBI
64-
runs-on: ubuntu-latest
65-
strategy:
66-
matrix:
67-
include:
68-
- target_name: sophgo-sg2044-rva23
69-
opensbi_repo: revyos/opensbi
70-
# Branch sg204x-v1.8.1-rva23 as of 20260225
71-
opensbi_ref: 1a59a37c667dde717c26abf02c9a54c7c5d9212a
72-
- target_name: sophgo-sg2044
73-
opensbi_repo: revyos/opensbi
74-
# Branch sg204x-v1.8.1 as of 20260225
75-
opensbi_ref: 175cafd0ca69534c5a6943e1e427150e65fbec23
76-
- target_name: sophgo-sg2042
77-
opensbi_repo: sophgo/opensbi
78-
# Branch sg2042-dev as of 20260225
79-
opensbi_ref: adc7ba17f3726aee599bc6fc879fbc569fbbba71
80-
steps:
81-
- name: Cache OpenSBI Build
82-
id: cache-opensbi-build
83-
uses: actions/cache@v5
84-
with:
85-
path: dist
86-
key: cache-opensbi-build-${{ matrix.target_name }}-${{ matrix.opensbi_ref }}
87-
- uses: actions/checkout@v5
88-
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
89-
- name: Setup Toolchains
90-
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
91-
id: setup-gcc-toolchain
92-
uses: ./.github/actions/riscv64-gcc-toolchain
93-
- name: Checkout OpenSBI
94-
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
95-
uses: actions/checkout@v6
96-
with:
97-
repository: ${{ matrix.opensbi_repo }}
98-
path: opensbi
99-
# Branch sg204x as of 20260224
100-
ref: ${{ matrix.opensbi_ref }}
101-
fetch-depth: 1
102-
- name: Build OpenSBI
103-
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
104-
run: |
105-
make -j"$(nproc)" -C opensbi O=$(pwd)/build CROSS_COMPILE=${{ steps.setup-gcc-toolchain.outputs.full-prefix }} PLATFORM=generic FW_PIC=y BUILD_INFO=y
106-
- name: Collect OpenSBI Binary
107-
if: ${{ steps.cache-opensbi-build.outputs.cache-hit != 'true' }}
108-
run: |
109-
mkdir dist
110-
cp build/platform/generic/firmware/fw_dynamic.bin dist/fw_dynamic.bin
111-
- name: Upload Artifacts
112-
uses: actions/upload-artifact@v4
113-
with:
114-
name: "opensbi-${{ matrix.target_name }}"
115-
path: dist
31+
build-opensbi-sg2042:
32+
name: Build OpenSBI for SG2042
33+
uses: ./.github/workflows/.sophgo-sg204x.opensbi-build.yml
34+
with:
35+
target_name: sophgo-sg2042
36+
opensbi_repo: sophgo/opensbi
37+
# Branch sg2042-dev as of 20260225
38+
opensbi_ref: adc7ba17f3726aee599bc6fc879fbc569fbbba71
39+
build-opensbi-sg2044:
40+
name: Build OpenSBI for SG2044
41+
uses: ./.github/workflows/.sophgo-sg204x.opensbi-build.yml
42+
with:
43+
target_name: sophgo-sg2044
44+
opensbi_repo: revyos/opensbi
45+
# Branch sg204x-v1.8.1 as of 20260225
46+
opensbi_ref: 175cafd0ca69534c5a6943e1e427150e65fbec23
47+
build-opensbi-sg2044-rva23:
48+
name: Build OpenSBI for SG2044 with RVA23 Emu
49+
uses: ./.github/workflows/.sophgo-sg204x.opensbi-build.yml
50+
with:
51+
target_name: sophgo-sg2044-rva23
52+
opensbi_repo: revyos/opensbi
53+
# Branch sg204x-v1.8.1-rva23 as of 20260225
54+
opensbi_ref: 1a59a37c667dde717c26abf02c9a54c7c5d9212a
11655

11756
build-u-root:
11857
name: Build u-root for LinuxBoot
@@ -216,8 +155,8 @@ jobs:
216155
pack-sdimage-sg2042:
217156
name: Pack SD Card Boot Image for SG2042
218157
needs:
219-
- build-zsbl
220-
- build-opensbi
158+
- build-zsbl-sg2042
159+
- build-opensbi-sg2042
221160
- build-u-root
222161
- build-kernel
223162
runs-on: ubuntu-latest
@@ -230,7 +169,7 @@ jobs:
230169
# - zsbl_target_name: sophgo-sg2044-srd3-10
231170
# opensbi_target_name: sophgo-sg2044
232171
# kernel_target_name: sophgo-sg2044
233-
- zsbl_target_name: sophgo-sg2042-milkv-pioneer
172+
- zsbl_target_name: sophgo-sg2042
234173
opensbi_target_name: sophgo-sg2042
235174
kernel_target_name: sophgo-sg2042
236175
output_filename: firmware-linuxboot-sophgo-sg2042.img

0 commit comments

Comments
 (0)