From 33ebe8bb10c644a4c6251911ac1ddb628ed10d72 Mon Sep 17 00:00:00 2001 From: maksyuki Date: Thu, 18 Dec 2025 09:49:33 +0800 Subject: [PATCH] feat: modify app setup and sys setup python script --- .github/workflows/test.yml | 9 ++++++--- app/setup.py | 39 +++++++++++++++++++++++++++++++++----- setup.py | 3 +-- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b34817af..0ee9f6e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Download and extract RISC-V toolchain + - name: Download and Extract RISC-V Toolchain run: | wget https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2025.05.01/riscv32-elf-ubuntu-22.04-gcc-nightly-2025.05.01-nightly.tar.xz tar -xvf riscv32-elf-ubuntu-22.04-gcc-nightly-2025.05.01-nightly.tar.xz -C /tmp @@ -22,14 +22,17 @@ jobs: echo "RISCV_TOOLCHAIN_BIN=$toolchain_bin" >> $GITHUB_ENV echo "$toolchain_bin" >> $GITHUB_PATH - - name: Use the toolchain in a subsequent step + - name: Test RISC-V Toolchain run: | echo "The toolchain path is $RISCV_TOOLCHAIN_BIN" riscv32-unknown-elf-gcc --version - - name: Setup Environment + - name: Setup Verilator and MPW Repo run: python3 setup.py + - name: Config FatFs and Coremark Repo + run: python3 app/setup.py + - name: Compile Firmware run: make CORE=MDD IP=MDD SIMU=VERILATOR HAVE_SRAM_IF=NO HAVE_SRAM_MACRO=NO HAVE_PLL=NO ISA=RV32IM EXEC_TYPE=ld2_psram firmware diff --git a/app/setup.py b/app/setup.py index 3c909e6d..1369b1bd 100644 --- a/app/setup.py +++ b/app/setup.py @@ -5,13 +5,42 @@ import os # Always use the script directory as the base to avoid failures in different working directories SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) APP_DIR = SCRIPT_DIR -SRC_DIR = os.path.join(APP_DIR, 'src') -FATFS_DIR = os.path.join(SRC_DIR, 'fatfs') -LVGL_DIR = os.path.join(SRC_DIR, 'lvgl') +FATFS_DIR = os.path.join(APP_DIR, 'fatfs') +COREMARK_DIR = os.path.join(APP_DIR, 'coremark') +LVGL_DIR = os.path.join(APP_DIR, 'lvgl') +LVGL_NAME = 'v9.4.0.tar.gz' + +print(APP_DIR) +print(FATFS_DIR) +print(COREMARK_DIR) + + +def prepend_line(filename, line): + with open(filename, 'r') as f: + content = f.read() + with open(filename, 'w') as f: + f.write(line + '\n' + content) + +def replace_line(filename, old, new): + with open(filename, 'r', encoding='utf-8') as fp: + for v in fp: + if old in v: + lines += v.replace(old, new) + else: + lines += v + + with open(filename, 'w', encoding='utf-8') as fp: + fp.writelines(lines) -lvgl_name = 'v9.4.0.tar.gz' os.system(f'mkdir -p "{FATFS_DIR}"/ff16 && cd "{FATFS_DIR}"/ff16 && if [ -d source ]; then echo "[fatfs] already exists, skip"; else wget https://elm-chan.org/fsw/ff/arc/ff16.zip && unzip -q ff16.zip && echo "[fatfs] downloaded and extracted"; fi') os.system(f'cd "{FATFS_DIR}" && cp -rf ffconf.h diskio.c ff16/source/') -os.system(f'cd "{LVGL_DIR}" && if ls -1d lvgl-* >/dev/null 2>&1; then echo "[lvgl] already exists, skip"; else wget https://github.com/lvgl/lvgl/archive/refs/tags/{lvgl_name} && tar -xf {lvgl_name} && echo "[lvgl] downloaded and extracted"; fi') \ No newline at end of file +os.system(f'git clone https://github.com/eembc/coremark.git {COREMARK_DIR}/coremark-main') +os.system(f'cd {COREMARK_DIR}/coremark-main && git checkout 1f483d5b8316753a742cbf5590caf5bd0a4e4777') +os.chdir(f'{COREMARK_DIR}/coremark-main') +prepend_line('coremark.h', '#include ') +replace_line('core_main.c', 'main', 'core_main') + + +# os.system(f'cd "{LVGL_DIR}" && if ls -1d lvgl-* >/dev/null 2>&1; then echo "[lvgl] already exists, skip"; else wget https://github.com/lvgl/lvgl/archive/refs/tags/{LVGL_NAME} && tar -xf {LVGL_NAME} && echo "[lvgl] downloaded and extracted"; fi') \ No newline at end of file diff --git a/setup.py b/setup.py index c82fbcf4..b126d291 100644 --- a/setup.py +++ b/setup.py @@ -328,10 +328,9 @@ def main(): # check_software_toolchain_installed() - # TODO: git clone mpw + # TODO: git clone mpw, add some stdout output os.chdir(project_path) run_command("git clone https://github.com/retroSoC/mini-ver-mpw.git rtl/mini/mpw") - if __name__ == "__main__": main() \ No newline at end of file