ci: add bare metal ARM Cortex-M4 job (using picolibc, QEMU) #2000

pull theStack wants to merge 3 commits into bitcoin-core:master from theStack:ci-cortex_m4_job changing 7 files +154 −10
  1. theStack commented at 3:03 PM on November 15, 2026: contributor

    libsecp256k1 is designed to also run on bare metal microcontrollers, but CI currently does not cover such a target. This PR adds a job that cross-compiles the tests with arm-none-eabi-gcc and picolibc and runs them on an emulated STM32F405 (Cortex-M4 [1], 1 MiB of flash, 128 KiB of SRAM) using qemu-system-arm. Output, arguments and the exit code are passed between target and host via ARM semihosting, so no target-specific code is needed.

    The first two commits (adding a --exclude option to the unit test framework, more thorough parallel test support detection) are useful independently of the CI job and could each be split out into their own PR if further discussion is needed.

    Limitations: the job uses the smallest precomputed tables (ECMULTWINDOW: 2, ECMULTGENKB: 2), disables the silentpayments module (its test vectors do not fit into the flash), and skips ecmult_multi_tests and the four slowest ellswift tests. The examples, benchmarks, ctime tests and the symbol check are not run.

    [1] The Cortex-M4 was chosen because it is common in hardware wallets that use libsecp256k1 (or the secp256k1-zkp fork), e.g., the BitBox02 (ATSAMD51), the COLDCARD Mk4 (STM32L4S5), the Trezor Model T (STM32F427) and Specter-DIY (STM32F469).

  2. theStack added the label ci on Nov 15, 2026
  3. theStack added the label assurance on Nov 15, 2026
  4. hebasto commented at 4:08 PM on November 15, 2026: member

    libsecp256k1 is designed to also run on bare metal microcontrollers, but CI currently does not cover such a target. This PR adds a job ...

    Concept ACK.

  5. hebasto commented at 4:10 PM on November 15, 2026: member

    For the CI issues with the newest Clang, see #1998.

  6. real-or-random commented at 9:34 AM on November 16, 2026: contributor

    Strong Concept ACK; something like this has been on our unwritten wish list for years, and this looks like a nice start!

  7. tests: add --exclude option to the unit test framework
    Add an --exclude=<name> option that skips a single test or all tests
    of a module. It can be given multiple times and takes the same names
    as --target.
    
    Exclusions are applied after the target selection, independent of the
    order of the arguments. So they can be used on their own to run
    everything except some tests, or to narrow down a --target selection.
    As with --target, an unknown name is an error.
    
    This is useful to skip particularly slow tests on slow platforms, e.g.,
    when running the tests under emulation.
    bbca47dccd
  8. build: check for fork, pipe and waitpid before enabling parallel tests
    So far, configure enabled parallel test execution if the headers
    sys/types.h, sys/wait.h and unistd.h are available. This is not
    sufficient: some C libraries for bare metal targets (e.g., picolibc)
    ship these headers but do not implement the functions, in which case
    the tests fail to link with undefined references to fork, pipe and
    waitpid.
    
    Additionally check that the functions can be linked.
    2cb1fa4bd1
  9. ci: add bare metal ARM Cortex-M4 job
    Build the tests for a target without an operating system and run them
    on an emulated STM32F405 microcontroller (Cortex-M4, 1 MiB of flash
    memory, 128 KiB of SRAM) using qemu-system-arm.
    
    The tests are linked against picolibc, which provides the startup code
    and implements I/O and exit() via ARM semihosting. This way, QEMU
    forwards the output, the command line arguments and the exit code
    between the target and the host, and no target-specific code is needed.
    
    To fit the tests into the flash memory, the smallest precomputed tables
    are used and the silentpayments module is disabled (its test vectors
    alone are larger than the flash memory). Since emulation is slow,
    ecmult_multi_tests and the slowest ellswift tests are skipped. The
    examples and benchmarks are not run because they rely on an OS-provided
    randomness source and on environment variables, respectively.
    
    The new wrapper script ci/qemu-cortex-m4.sh runs a binary in QEMU. As
    "make check" cannot pass arguments to the tests, the script appends
    the contents of QEMU_TESTS_ARGS to the arguments of the tests and
    noverify_tests binaries.
    3004663c68
  10. theStack force-pushed on Nov 16, 2026
  11. theStack commented at 2:06 PM on November 16, 2026: contributor

    For the CI issues with the newest Clang, see #1998.

    Rebased on master, now that #1998 is merged.

  12. Yudis-bit commented at 1:36 PM on November 17, 2026: contributor

    Would splitting vectors.h from basic unit tests make sense later? Since tests_impl.h unconditionally pulls the 540 KiB array into .rodata, runtime --exclude cannot keep silent payments within the 1 MiB flash limit.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-12-02 10:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me