diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 71fde7d..d325329 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -133,6 +133,49 @@ jobs: path: dist + build-riscv: + runs-on: ubuntu-24.04 + env: + MPY_DIR: ./micropython + MICROPYTHON_BIN: ./micropython/ports/unix/build-nomodules/micropython + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Install OS dependencies + run: sudo add-apt-repository universe + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - uses: actions/checkout@v4 + with: + repository: jonnor/micropython + path: micropython + ref: v1.25.0-armv6m-abs-relocations + - name: Install Python dependencies + run: pip install -r requirements.txt + + - name: Setup MicroPython ESP32 + working-directory: micropython + run: | + source tools/ci.sh && ci_esp32_idf_setup && ci_gcc_riscv_setup + make -C mpy-cross + - name: Setup submodules esp32 + working-directory: micropython/ports/esp32 + run: source ../../esp-idf/export.sh && make submodules + - name: Build custom firmware with extmod, ESP32 + run: | + source micropython/esp-idf/export.sh && pip install -r requirements.txt + echo make extmod PORT=esp32 BOARD=ESP32_GENERIC_C6 + - name: Build nadmod xtensawin + run: source micropython/esp-idf/export.sh && pip install -r requirements.txt && make dist ARCH=rv32imc V=1 + - name: Archive dist artifacts + uses: actions/upload-artifact@v4 + with: + name: emlearn-micropython-build-riscv + path: dist + + build-macos: runs-on: macos-latest env: @@ -178,7 +221,7 @@ jobs: deploy-pages: permissions: contents: write - needs: [build-linux, build-arm, build-esp32, build-macos] + needs: [build-linux, build-arm, build-esp32, build-macos, build-riscv] runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index 0237bd2..e809343 100644 --- a/README.md +++ b/README.md @@ -80,16 +80,34 @@ git clone https://github.com/emlearn/emlearn-micropython ``` #### Prerequisites -These come in addition to the prequisites described above. -Make sure you have the dependencies needed to build for your platform. -See [MicroPython: Building native modules](https://docs.micropython.org/en/latest/develop/natmod.html). +You will need to have **Python 3.10+ or later** already installed. -We assume that micropython is installed in the same place as this repository. +We assume that **micropython** git repository available. +It is assumed to be at the same level as this repository in the file system. If using another location, adjust `MPY_DIR` accordingly. - You should be using MicroPython 1.25 (or newer). +Make sure you have the **build toolchain** needed for your platform. +See [MicroPython: Building native modules](https://docs.micropython.org/en/latest/develop/natmod.html), +and the documentation for the MicroPython port/architecture of interest. + +#### Download dependencies + +Fetch git submodules + +``` +git submodule update --init +``` + +Recommend using a Python virtual environment. + +Install Python packages +``` +pip install -r requirements.txt +``` + + #### Build Build the .mpy native module diff --git a/requirements.txt b/requirements.txt index 3a89384..9c11383 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ emlearn>=0.21.2 scikit-learn>=1.0.0 ar>=1.0.0 pyelftools>=0.31 +setuptools>=71.0.0 diff --git a/src/emlearn_iir_q15/iir_filter.c b/src/emlearn_iir_q15/iir_filter.c index a918029..382fa2d 100644 --- a/src/emlearn_iir_q15/iir_filter.c +++ b/src/emlearn_iir_q15/iir_filter.c @@ -5,8 +5,9 @@ #include -// memset is used by some standard C constructs -#if !defined(__linux__) +// memset is used by some standard C constructs. Missing on some platforms, but not all... +// Unfortunately cannot use weak symbols with mpy_ld +#if !(defined(__linux__) || defined(__riscv__) || defined(__riscv)) void *memcpy(void *dst, const void *src, size_t n) { return mp_fun_table.memmove_(dst, src, n); }