|
| 1 | +name: "Nuvoton M2354 port" |
| 2 | + |
| 3 | +# Keeps the Nuvoton NuMicro M2354 crypto callback port compiling against the |
| 4 | +# real vendor BSP. The port has no autotools option and is not built by any |
| 5 | +# other job: an application compiles wolfcrypt/src/port/nuvoton/*.c into its own |
| 6 | +# project, the same way wolfcrypt/src/port/st/stm32.c is carried. Without this |
| 7 | +# guard a header rename in the BSP, or a refactor in aes.c, ecc.c or cryptocb.h, |
| 8 | +# would break the port silently until someone next built for the board. |
| 9 | +# |
| 10 | +# Nothing is faked. arm-none-eabi-gcc is a plain apt package and the BSP is a |
| 11 | +# public GitHub repository, so both legs compile against the genuine Nuvoton |
| 12 | +# StdDriver headers at a pinned commit. |
| 13 | +# |
| 14 | +# secure WOLFSSL_NUVOTON_SECURE, the whole port including nuvoton_hw.c |
| 15 | +# nonsecure WOLFSSL_NUVOTON_NSC, where nuvoton_hw.c compiles to nothing |
| 16 | +# and the cmse_nonsecure_entry veneers supply the symbols |
| 17 | +# |
| 18 | +# The runnable example, including those veneers, lives in wolfssl-examples |
| 19 | +# under embedded/nuvoton_m2354. Functional correctness is validated on a |
| 20 | +# NuMaker-M2354, not here; see wolfcrypt/src/port/nuvoton/README.md. |
| 21 | + |
| 22 | +# START OF COMMON SECTION |
| 23 | +on: |
| 24 | + push: |
| 25 | + branches: [ 'master', 'main', 'release/**' ] |
| 26 | + paths: |
| 27 | + - 'wolfcrypt/src/port/nuvoton/**' |
| 28 | + - 'wolfssl/wolfcrypt/port/nuvoton/**' |
| 29 | + - '.github/workflows/nuvoton-m2354-compile.yml' |
| 30 | + pull_request: |
| 31 | + types: [opened, synchronize, reopened, ready_for_review] |
| 32 | + branches: [ '**' ] |
| 33 | + paths: |
| 34 | + - 'wolfcrypt/src/**' |
| 35 | + - 'wolfssl/wolfcrypt/**' |
| 36 | + - '.github/workflows/nuvoton-m2354-compile.yml' |
| 37 | + workflow_dispatch: |
| 38 | + |
| 39 | +concurrency: |
| 40 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 41 | + cancel-in-progress: true |
| 42 | + |
| 43 | +permissions: |
| 44 | + contents: read |
| 45 | +# END OF COMMON SECTION |
| 46 | + |
| 47 | +env: |
| 48 | + # Pinned so a BSP change cannot break a PR that did not touch the port. Bump |
| 49 | + # it deliberately. |
| 50 | + BSP_REF: 3d423be763edabe1d8b3f27dea363b69e787f8f9 |
| 51 | + |
| 52 | +jobs: |
| 53 | + compile: |
| 54 | + name: ${{ matrix.leg }} (Cortex-M23) |
| 55 | + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} |
| 56 | + runs-on: ubuntu-24.04 |
| 57 | + timeout-minutes: 20 |
| 58 | + strategy: |
| 59 | + fail-fast: false |
| 60 | + matrix: |
| 61 | + include: |
| 62 | + - leg: secure |
| 63 | + world: WOLFSSL_NUVOTON_SECURE |
| 64 | + - leg: nonsecure |
| 65 | + world: WOLFSSL_NUVOTON_NSC |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4 |
| 68 | + name: Checkout wolfSSL |
| 69 | + |
| 70 | + - name: Install the toolchain |
| 71 | + run: | |
| 72 | + sudo apt-get update |
| 73 | + sudo apt-get install -y gcc-arm-none-eabi |
| 74 | +
|
| 75 | + - name: Checkout the Nuvoton M2354 BSP |
| 76 | + run: | |
| 77 | + set -e |
| 78 | + # The full repository is around 256 MB and almost none of it is |
| 79 | + # needed, so take one commit and only the driver tree. |
| 80 | + git clone --filter=blob:none --no-checkout --sparse \ |
| 81 | + https://github.com/OpenNuvoton/M2354BSP "$GITHUB_WORKSPACE/M2354BSP" |
| 82 | + cd "$GITHUB_WORKSPACE/M2354BSP" |
| 83 | + git sparse-checkout set \ |
| 84 | + Library/StdDriver/inc Library/Device Library/CMSIS |
| 85 | + git fetch --depth 1 origin "$BSP_REF" |
| 86 | + git checkout "$BSP_REF" |
| 87 | +
|
| 88 | + - name: Compile the port |
| 89 | + run: | |
| 90 | + set -e |
| 91 | + BSP="$GITHUB_WORKSPACE/M2354BSP" |
| 92 | + mkdir -p "$GITHUB_WORKSPACE/cfg" |
| 93 | +
|
| 94 | + # Minimal configuration: enough to reach every engine in the port. |
| 95 | + # The example in wolfssl-examples carries a realistic one. |
| 96 | + cat > "$GITHUB_WORKSPACE/cfg/user_settings.h" <<'EOF' |
| 97 | + #ifndef CI_USER_SETTINGS_H |
| 98 | + #define CI_USER_SETTINGS_H |
| 99 | + #define WOLFSSL_NUVOTON_M2354 |
| 100 | + #define SINGLE_THREADED |
| 101 | + #define NO_FILESYSTEM |
| 102 | + #define WOLFSSL_SMALL_STACK |
| 103 | + #define WOLFSSL_SHA224 |
| 104 | + #define WOLFSSL_SHA384 |
| 105 | + #define WOLFSSL_SHA512 |
| 106 | + #define HAVE_HASHDRBG |
| 107 | + #define HAVE_AES_CBC |
| 108 | + #define HAVE_AES_ECB |
| 109 | + #define WOLFSSL_AES_DIRECT |
| 110 | + #define WOLFSSL_AES_COUNTER |
| 111 | + #define HAVE_AESGCM |
| 112 | + #define HAVE_ECC |
| 113 | + #define HAVE_ECC_DHE |
| 114 | + #define HAVE_ECC_SIGN |
| 115 | + #define HAVE_ECC_VERIFY |
| 116 | + #define HAVE_ECC384 |
| 117 | + #define WOLFSSL_KEY_GEN |
| 118 | + #define TFM_TIMING_RESISTANT |
| 119 | + #define ECC_TIMING_RESISTANT |
| 120 | + #define WC_RSA_BLINDING |
| 121 | + #endif |
| 122 | + EOF |
| 123 | +
|
| 124 | + CFLAGS="-mcpu=cortex-m23 -mthumb -Os -Wall -Wextra -Werror -c" |
| 125 | + CFLAGS="$CFLAGS -I. -I$GITHUB_WORKSPACE/cfg -DWOLFSSL_USER_SETTINGS" |
| 126 | + CFLAGS="$CFLAGS -D${{ matrix.world }}" |
| 127 | + CFLAGS="$CFLAGS -I$BSP/Library/StdDriver/inc" |
| 128 | + CFLAGS="$CFLAGS -I$BSP/Library/Device/Nuvoton/M2354/Include" |
| 129 | + CFLAGS="$CFLAGS -I$BSP/Library/CMSIS/Include" |
| 130 | +
|
| 131 | + for f in wolfcrypt/src/port/nuvoton/*.c wolfcrypt/src/random.c; do |
| 132 | + echo " $f" |
| 133 | + # shellcheck disable=SC2086 |
| 134 | + arm-none-eabi-gcc $CFLAGS -o /dev/null "$f" |
| 135 | + done |
0 commit comments