Skip to content
Open
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
100 changes: 100 additions & 0 deletions .github/workflows/compile-mlibc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Mlibc Compilation

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]
paths-ignore:
- '**/README.md'
- '**/README_zh.md'
pull_request:
branches: [ main ]
paths-ignore:
- '**/README.md'
- '**/README_zh.md'

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
build:
runs-on: ubuntu-22.04
name: ${{ matrix.legs.MLIBC_COMPILE }}
strategy:
fail-fast: false
matrix:
legs:
- MLIBC_COMPILE: "Mlibc Arm Compilation On Linux"
ARCH: "arm"
QEMU_BOARD: "qemu-vexpress-a9"

- MLIBC_COMPILE: "Mlibc AArch64 Compilation On Linux"
ARCH: "aarch64"
QEMU_BOARD: "qemu-virt-aarch64"

- MLIBC_COMPILE: "Mlibc RISCV32 Compilation On Linux"
ARCH: "riscv32"
QEMU_BOARD: "qemu-virt-riscv32"

- MLIBC_COMPILE: "Mlibc RISCV64 Compilation On Linux"
ARCH: "riscv64"
QEMU_BOARD: "qemu-virt-riscv64"

steps:
- uses: actions/checkout@v4
- name: Install Arm ToolChains
if: ${{ matrix.legs.ARCH == 'arm'}}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.3/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt
/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version
echo "MLIBC_TOOLCHAIN_CC=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc" >> $GITHUB_ENV
echo "MLIBC_TOOLCHAIN_AR=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc-ar" >> $GITHUB_ENV

- name: Install AArch64 ToolChains
if: ${{ matrix.legs.ARCH == 'aarch64'}}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.6/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz
sudo tar -xf gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz -C /opt
/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc --version
echo "MLIBC_TOOLCHAIN_CC=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc" >> $GITHUB_ENV
echo "MLIBC_TOOLCHAIN_AR=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-ar" >> $GITHUB_ENV

- name: Install RV32 ToolChains
if: ${{ matrix.legs.ARCH == 'riscv32'}}
shell: bash
run: |
wget -q https://github.com/hpmicro/riscv-gnu-toolchain/releases/download/2022.05.15/riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz
sudo tar zxf riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz -C /opt
/opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-gcc --version
echo "MLIBC_TOOLCHAIN_CC=/opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-gcc" >> $GITHUB_ENV
echo "MLIBC_TOOLCHAIN_AR=/opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-ar" >> $GITHUB_ENV

- name: Install RV64 ToolChains
if: ${{ matrix.legs.ARCH == 'riscv64'}}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.4/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
sudo tar zxf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
echo "MLIBC_TOOLCHAIN_CC=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc" >> $GITHUB_ENV
echo "MLIBC_TOOLCHAIN_AR=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-ar" >> $GITHUB_ENV

- name: Mlibc Make Compile
shell: bash
env:
ARCH : ${{ matrix.legs.ARCH }}
QEMU_BOARD : ${{ matrix.legs.QEMU_BOARD }}
run: |
make mlibc

- name: Upload Mlibc Compilation
uses: actions/upload-artifact@v4
with:
name: mlibc-${{ matrix.legs.ARCH }}.a
path: ./build/${{ matrix.legs.ARCH }}/libmlibc.a
if-no-files-found: error
retention-days: 7
157 changes: 157 additions & 0 deletions .github/workflows/qemu-hello.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Qemu-hello RUN

on:
push:
branches: [ main ]
paths-ignore:
- '**/README.md'
- '**/README_zh.md'
pull_request:
branches: [ main ]
paths-ignore:
- '**/README.md'
- '**/README_zh.md'

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-22.04
name: ${{ matrix.platform.QEMU_HELLO }}
strategy:
fail-fast: false
matrix:
platform:
- { QEMU_BOARD: "qemu-mps3-an536" , ARCH: "arm" , QEMU_HELLO: "qemu-hello run on qemu-mps3-an536"}
- { QEMU_BOARD: "qemu-vexpress-a9" , ARCH: "arm" , QEMU_HELLO: "qemu-hello run on qemu-vexpress-a9"}
- { QEMU_BOARD: "qemu-virt-aarch64", ARCH: "aarch64" , QEMU_HELLO: "qemu-hello run on qemu-virt-aarch64"}
- { QEMU_BOARD: "qemu-virt-riscv32", ARCH: "riscv32" , QEMU_HELLO: "qemu-hello run on qemu-virt-riscv32"}
- { QEMU_BOARD: "qemu-virt-riscv64", ARCH: "riscv64" , QEMU_HELLO: "qemu-hello run on qemu-virt-riscv64"}
steps:
- uses: actions/checkout@v4
- name: Install Qemu
shell: bash
run: |
wget -q https://github.com/Chris-godz/mlibc/releases/download/CI/qemu-9.2.2.tar.zst
cat *.tar.zst | zstd -d -T0 | tar -xf - > /dev/null 2>&1
chmod +x ./qemu-9.2.2/qemu_install.sh
sudo ./qemu-9.2.2/qemu_install.sh
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是应该放到 https://github.com/plctlab/mlibc/ 上去,而不是 https://github.com/Chris-godz/mlibc/

另外 qemu_install.sh 干了什么?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是我编译后的qemu-9.2.2,删掉了不必要的部分, qemu_install.sh是我根据qemu安装的日志,把编译后的部分mov到系统对应的位置

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是应该放到 https://github.com/plctlab/mlibc/ 上去,而不是 https://github.com/Chris-godz/mlibc/

另外 qemu_install.sh 干了什么?

是的,需不需要也把用到的 rtt release 的工具链部分也一起放到mlibc的仓库里面

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得像 gcc 那样统一放 https://github.com/RT-Thread/toolchains-ci/releases 就挺好的,@BernardXiong 熊大给个建议?

@Chris-godz 另外我发现 rv32 的toolchain 你是从一个非官方的地方下载的,其实我记得 riscv64 的 gcc 也是可以编译 rv32 的,就是用 -march 和 -mabi 控制好就好了的。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得像 gcc 那样统一放 https://github.com/RT-Thread/toolchains-ci/releases 就挺好的,@BernardXiong 熊大给个建议?

问题是,放哪个仓库呢?


- name: Verify QEMU installation
shell: bash
run: |
qemu-system-arm --version

- name: Install Arm ToolChains
if: ${{ matrix.platform.ARCH == 'arm'}}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.3/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt
/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version
echo "MLIBC_TOOLCHAIN_CC=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc" >> $GITHUB_ENV
echo "MLIBC_TOOLCHAIN_AR=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc-ar" >> $GITHUB_ENV

- name: Install AArch64 ToolChains
if: ${{ matrix.platform.ARCH == 'aarch64'}}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.6/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz
sudo tar -xf gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz -C /opt
/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc --version
echo "MLIBC_TOOLCHAIN_CC=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc" >> $GITHUB_ENV
echo "MLIBC_TOOLCHAIN_AR=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-ar" >> $GITHUB_ENV

- name: Install RV32 ToolChains
if: ${{ matrix.platform.ARCH == 'riscv32'}}
shell: bash
run: |
wget -q https://github.com/hpmicro/riscv-gnu-toolchain/releases/download/2022.05.15/riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz
sudo tar zxf riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz -C /opt
/opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-gcc --version
echo "MLIBC_TOOLCHAIN_CC=/opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-gcc" >> $GITHUB_ENV
echo "MLIBC_TOOLCHAIN_AR=/opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-ar" >> $GITHUB_ENV

- name: Install RV64 ToolChains
if: ${{ matrix.platform.ARCH == 'riscv64'}}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.4/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
sudo tar zxf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
echo "MLIBC_TOOLCHAIN_CC=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc" >> $GITHUB_ENV
echo "MLIBC_TOOLCHAIN_AR=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-ar" >> $GITHUB_ENV

- name: qemu-hello test
shell: bash
if: ${{ env.MLIBC_TOOLCHAIN_AR != '' && success() }}
env:
ARCH : ${{ matrix.platform.ARCH }}
QEMU_BOARD : ${{ matrix.platform.QEMU_BOARD }}
run: |
if [[ "${{ matrix.platform.QEMU_BOARD }}" == "qemu-mps3-an536" ]]; then
make qemu-hello
qemu-system-arm -M mps3-an536 \
-kernel ./helloworld/qemu/${{ matrix.platform.QEMU_BOARD }}/${{ matrix.platform.QEMU_BOARD }}.elf \
-nographic -m 512 \
> qemu_output_$QEMU_BOARD.log 2>&1 &

elif [[ "${{ matrix.platform.QEMU_BOARD }}" == "qemu-vexpress-a9" ]]; then
make qemu-hello
qemu-system-arm -M vexpress-a9 \
-kernel ./helloworld/qemu/${{ matrix.platform.QEMU_BOARD }}/${{ matrix.platform.QEMU_BOARD }}.elf \
-nographic -m 512 \
> qemu_output_$QEMU_BOARD.log 2>&1 &

elif [[ "${{ matrix.platform.QEMU_BOARD }}" == "qemu-virt-aarch64" ]]; then
make qemu-hello
qemu-system-aarch64 -M virt \
-cpu cortex-a53 \
-kernel ./helloworld/qemu/${{ matrix.platform.QEMU_BOARD }}/${{ matrix.platform.QEMU_BOARD }}.elf \
-nographic -m 512 \
> qemu_output_$QEMU_BOARD.log 2>&1 &

elif [[ "${{ matrix.platform.QEMU_BOARD }}" == "qemu-virt-riscv32" ]]; then
make qemu-hello
qemu-system-riscv32 -machine virt \
-nographic -m 256M \
-kernel ./helloworld/qemu/${{ matrix.platform.QEMU_BOARD }}/${{ matrix.platform.QEMU_BOARD }}.elf \
> qemu_output_$QEMU_BOARD.log 2>&1 &

elif [[ "${{ matrix.platform.QEMU_BOARD }}" == "qemu-virt-riscv64" ]]; then
make qemu-hello
qemu-system-riscv64 -machine virt \
-nographic -m 512M \
-kernel ./helloworld/qemu/${{ matrix.platform.QEMU_BOARD }}/${{ matrix.platform.QEMU_BOARD }}.elf \
> qemu_output_$QEMU_BOARD.log 2>&1 &
fi

QEMU_PID=$!
disown $QEMU_PID
echo "QEMU_SETUP_READY=true" >> $GITHUB_ENV

- name: Monitor qemu log
if: ${{ env.QEMU_SETUP_READY == 'true' && success() }}
shell: bash
run: |
# wait for qemu finish
sleep 10
echo "=========================================================================================="
echo " || || "
echo " || Start automatic running of qemu-hello || "
echo " VV VV "
echo "=========================================================================================="
LAST_TWO_LINES=$(tail -n 2 qemu_output_${{ matrix.platform.QEMU_BOARD }}.log)
echo "$LAST_TWO_LINES"

if grep -q "Uart Test" qemu_output_${{ matrix.platform.QEMU_BOARD }}.log && grep -q "Hello mlibc" qemu_output_${{ matrix.platform.QEMU_BOARD }}.log; then
echo "=========================================================================================="
echo " Successed: qemu-hello run completed. Exiting log monitoring "
echo "=========================================================================================="
else
echo "=========================================================================================="
echo " Failed: qemu-hello run not completed. Exiting log monitoring "
echo "=========================================================================================="
exit 1
fi
6 changes: 3 additions & 3 deletions mkconfigs/qemu/qemu-hello.mk
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是一个 bugfix,应该单独提一个 pr。不建议和这个 pr 一起提交。
我已经提了一个 issue:#57

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否应该移除这个文件的修改?

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ QCFLAGS := $(QCFLAGS) $(DEVICE) $(DEFINE) $(DEBUG)
ASFLAGS := $(ASFLAGS) $(DEVICE) $(DEFINE) $(DEBUG)
LDFLAGS := -T $(BOARD_PATH)/qemu/$(QEMU_BOARD)/link.ld $(LDFLAGS)

TARGET := $(QEMU_BOARD).elf
QEMU_TARGET := $(QEMU_BOARD).elf

$(QEMU_CRTOBJ_DIR)/%.o: $(PROJECT_PATH)/crt/$(ARCH)/%.c
$(CC) -c $(QEMU_INC) $(QCFLAGS) -o $@ $<
Expand All @@ -45,7 +45,7 @@ $(QEMU_OBJ_DIR)/%.o: $(BOARD_PATH)/%.c
$(CC) -c $(QEMU_INC) $(QCFLAGS) -o $@ $<

.PHONY:qemu-hello
qemu-hello: creat_qdir $(BOARD_PATH)/qemu/$(QEMU_BOARD)/$(TARGET)
qemu-hello: creat_qdir $(BOARD_PATH)/qemu/$(QEMU_BOARD)/$(QEMU_TARGET)

.PHONY: creat_qdir
creat_qdir:
Expand All @@ -57,5 +57,5 @@ else
@mkdir -p $(QEMU_OBJ_DIR)
endif

$(BOARD_PATH)/qemu/$(QEMU_BOARD)/$(TARGET): $(QEMU_CRTOBJ_FILES) $(QEMU_OBJ_FILES)
$(BOARD_PATH)/qemu/$(QEMU_BOARD)/$(QEMU_TARGET): $(QEMU_CRTOBJ_FILES) $(QEMU_OBJ_FILES)
$(CC) -o $@ $(QEMU_OBJ_FILES) $(QEMU_CRTOBJ_FILES) $(LDFLAGS)