Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running doctest on embedded ARM Cortex µCs #506

Closed
jcw opened this issue May 18, 2021 · 1 comment
Closed

Running doctest on embedded ARM Cortex µCs #506

jcw opened this issue May 18, 2021 · 1 comment

Comments

@jcw
Copy link

jcw commented May 18, 2021

(this is not a bug report or feature request, I just wanted to document the results of a brief exploration)

Having started using DocTest recently (impressive!), I wanted to try and see if it could be used for embedded µC development as well, and for starters I'm focusing on STM32 µCs. The larger chips have 512 kB flash + 128 kB RAM, or more. For a first test, I'm using their low-cost 32F723EDISCOVERY board, with PlatformIO as build tool to manage all the arm-none-eabi-* details.

The first experiment was simply to try and compile a main app with one CHECK in it. Results:

  • as is, no special options, the compiler complains about issues in signal.h and about mutex
  • with DOCTEST_CONFIG_NO_POSIX_SIGNALS defined, the list narrows down to basically this:
doctest.h: error: 'mutex' in namespace 'std' does not name a type
doctest.h: error: 'mutex' is not a member of 'std'
doctest.h: error: 'mutex' was not declared in this scope
doctest.h: error: template argument 1 is invalid
doctest.h: note: suggested alternative: 'quoted'
doctest.h: warning: unused variable 'lock' [-Wunused-variable]

I removed the XML & JUnit reporters and commented out a few remaining references to mutex in the console reporter:

$ pio run
Processing embed (platform: ststm32; framework: cmsis; board: disco_f723ie)
-------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/disco_f723ie.html
PLATFORM: ST STM32 (13.0.0) > 32F723EDISCOVERY
HARDWARE: STM32F723IEK6 216MHz, 192KB RAM, 512KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-cmsis 2.50501.200527 (5.5.1)
 - framework-cmsis-stm32f7 1.2.5
 - tool-dfuutil 1.9.200310
 - tool-ldscripts-ststm32 0.1.0
 - tool-openocd 2.1000.200630 (10.0)
 - tool-stm32duino 1.0.1
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ strict
Found 11 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/embed/src/main.o
Linking .pio/build/embed/firmware.elf
Checking size .pio/build/embed/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.6% (used 7056 bytes from 196608 bytes)
Flash: [====      ]  36.5% (used 191348 bytes from 524288 bytes)
Configuring upload protocol...

As you can see, the result compiles and uploads.

This is the source setup I'm using:

$ tree
.
├── platformio.ini
└── src
    ├── doctestx.h
    └── main.cpp

This is main.cpp:

#define DOCTEST_CONFIG_COLORS_NONE
#define DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS
#define DOCTEST_CONFIG_NO_POSIX_SIGNALS
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctestx.h"

TEST_CASE("smoke test") {
    CHECK(42 == 40 + 2);
}

And this is the platformio.ini configuration:

[env:embed]
platform = ststm32
framework = cmsis
board = disco_f723ie
build_unflags = -std=c++11
build_flags = -std=c++17 -Wall -Wextra -DSTM32 -DSTM32F7

That's just a first step, as the output needs to be directed to a h/w UART for this to be of use. But it looks promising to me.

FWIW, the Unity test framework supports embedded builds via a very simple API, see this documentation, for example.

IMO, it would be really nice if doctest can be made to run on such embedded systems as well. It definitely seems very doable.

@jcw jcw changed the title Running DocTest on embedded ARM Cortex µCs Running doctest on embedded ARM Cortex µCs May 18, 2021
@jcw jcw closed this as completed Jul 10, 2021
@onqtam
Copy link
Member

onqtam commented Nov 5, 2021

Appreciate the effort!

IMO, it would be really nice if doctest can be made to run on such embedded systems as well. It definitely seems very doable.

Perhaps some day :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants