Skip to content

Commit

Permalink
tools/ci.sh, .github/workflows: Bring QEMU-RISCV target under CI.
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
  • Loading branch information
agatti committed Jun 1, 2024
1 parent 748fb57 commit e14cccc
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 50 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ports_qemu-riscv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: qemu-riscv port

on:
push:
pull_request:
paths:
- '.github/workflows/*.yml'
- 'tools/**'
- 'py/**'
- 'extmod/**'
- 'shared/**'
- 'lib/**'
- 'drivers/**'
- 'ports/qemu-arm/main.c'
- 'ports/qemu-riscv/**'
- 'tests/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install packages
run: source tools/ci.sh && ci_qemu_riscv_setup
- name: Build and run test suite
run: source tools/ci.sh && ci_qemu_riscv_build
- name: Print failures
if: failure()
run: grep --before-context=100 --text "FAIL" ports/qemu-riscv/build/console.out

23 changes: 2 additions & 21 deletions ports/qemu-riscv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,8 @@ SRC_TEST_C = \
test_main.c \
lib/tinytest/tinytest.c \

LIB_SRC_C += $(addprefix lib/,\
libm/math.c \
libm/fmodf.c \
libm/nearbyintf.c \
libm/ef_sqrt.c \
libm/kf_rem_pio2.c \
libm/kf_sin.c \
libm/kf_cos.c \
libm/kf_tan.c \
libm/ef_rem_pio2.c \
libm/sf_sin.c \
libm/sf_cos.c \
libm/sf_tan.c \
libm/sf_frexp.c \
libm/sf_modf.c \
libm/sf_ldexp.c \
libm/asinfacosf.c \
libm/atanf.c \
libm/atan2f.c \
libm/roundf.c \
)
LIB_SRC_C += $(SRC_LIB_LIBM_C)
LIB_SRC_C += $(SRC_LIB_LIBM_SQRT_SW_C)

OBJ_COMMON =
OBJ_COMMON += $(PY_O)
Expand Down
45 changes: 16 additions & 29 deletions ports/qemu-riscv/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,31 @@

// options to control how MicroPython is built

#define MICROPY_ALLOC_PATH_MAX (512)
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)

#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
#define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (0)
#define MICROPY_ENABLE_GC (1)
#define MICROPY_STACK_CHECK (1)
#define MICROPY_KBD_EXCEPTION (0)
#define MICROPY_HELPER_REPL (0)
#define MICROPY_HELPER_LEXER_UNIX (0)
#define MICROPY_ENABLE_SOURCE_LINE (1)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
#define MICROPY_WARNINGS (1)
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
#define MICROPY_PY_BUILTINS_BYTES_HEX (1)
#define MICROPY_PY_BUILTINS_FROZENSET (1)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
#define MICROPY_PY_BUILTINS_POW3 (1)
#define MICROPY_PY_IO (1)
#define MICROPY_PY_SYS_EXIT (1)
#define MICROPY_PY_SYS_MAXSIZE (1)
#define MICROPY_PY_BUILTINS_INPUT (0)
#define MICROPY_PY_BUILTINS_HELP (0)
#define MICROPY_PY_IO_IOBASE (0)
#define MICROPY_PY_SYS_PLATFORM "qemu-riscv32"
#define MICROPY_PY_ERRNO (1)
#define MICROPY_PY_BINASCII (1)
#define MICROPY_PY_RANDOM (1)
#define MICROPY_PY_UCTYPES (1)
#define MICROPY_PY_DEFLATE (1)
#define MICROPY_PY_JSON (1)
#define MICROPY_PY_OS (1)
#define MICROPY_PY_RE (1)
#define MICROPY_PY_HEAPQ (1)
#define MICROPY_PY_HASHLIB (1)
#define MICROPY_PY_SYS_STDFILES (0)
#define MICROPY_PY_SYS_STDIO_BUFFER (0)
#define MICROPY_PY_SELECT (0)
#define MICROPY_PY_TIME (0)
#define MICROPY_PY_ASYNCIO (0)
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/qemu-arm/modmachine.c"
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
#define MICROPY_USE_INTERNAL_PRINTF (1)
#define MICROPY_VFS (1)
#define MICROPY_PY_MACHINE_PIN_BASE (1)
#define MICROPY_GCREGS_SETJMP (1)
#define MICROPY_NLR_SETJMP (1)
#define MICROPY_VFS (1)

// type definitions for the specific machine

Expand All @@ -55,6 +39,9 @@ typedef int32_t mp_int_t; // must be pointer size
typedef uint32_t mp_uint_t; // must be pointer size
typedef long mp_off_t;

// We need an implementation of the log2 function which is not a macro.
#define MP_NEED_LOG2 (1)

// We need to provide a declaration/definition of alloca()
#include <alloca.h>

Expand Down
24 changes: 24 additions & 0 deletions tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function ci_gcc_arm_setup {
arm-none-eabi-gcc --version
}

function ci_gcc_riscv_setup {
sudo apt-get install gcc-riscv64-unknown-elf picolibc-riscv64-unknown-elf
riscv64-unknown-elf-gcc --version
}

########################################################################################
# c code formatting

Expand Down Expand Up @@ -259,6 +264,25 @@ function ci_qemu_arm_build {
make ${MAKEOPTS} -C ports/qemu-arm -f Makefile.test BOARD=sabrelite test
}

########################################################################################
# ports/qemu-riscv

function ci_qemu_riscv_setup {
ci_gcc_riscv_setup
sudo apt-get update
sudo apt-get install qemu-system
qemu-system-riscv32 --version
}

function ci_qemu_riscv_build {
make ${MAKEOPTS} -C mpy-cross
make ${MAKEOPTS} -C ports/qemu-riscv submodules
make ${MAKEOPTS} -C ports/qemu-riscv
make ${MAKEOPTS} -C ports/qemu-riscv clean
make ${MAKEOPTS} -C ports/qemu-riscv -f Makefile.test submodules
make ${MAKEOPTS} -C ports/qemu-riscv -f Makefile.test test
}

########################################################################################
# ports/renesas-ra

Expand Down

0 comments on commit e14cccc

Please sign in to comment.