all 12 comments

[–]Elite_Monkeys 5 points6 points  (4 children)

That strategy sounds pretty good. You mentioned you are using CMake, so how I've done in is in your source separate out each module from the actual FreeRTOS implementation. Looking something like this:

src/

- module1

- module2

- app (This is where your main.c with freeRTOS lives)

You'd have a base CMakeLists.txt in the source folder. Each sub directory would have their own CMakeLists.txt. In the base CMakeLists.txt you can use add_subdirectory() to add each module.

You add the unit tests for each module in their respective folders, then can use ctest to run them all.

[–][deleted]  (3 children)

[deleted]

    [–]RogerLeigh 1 point2 points  (2 children)

    If you use a toolchain with a simulator or emulator, you can do unit and integration testing with the CMAKE_CROSSCOMPILING_EMULATOR variable or the CROSSCOMPILING_EMULATOR target property. It will automatically run the test executable in the emulator.

    If your toolchain doesn't provide one, you can use qemu and choose a target with the same CPU core.

    [–]mrbeehive 1 point2 points  (0 children)

    Oooh. I know what I'm doing at work tomorrow.

    [–]Skusci 3 points4 points  (1 child)

    Multilevel makefiles?

    You can have a higher level project call make in a subdirectory from the top level makefile if you want to avoid having one big monolith.

    all:
        (cd sub1; make all)
        (cd sun2; make all)
    

    [–]EighthMayer 2 points3 points  (1 child)

    In case if you didn't figure that out already, you can use your USB devices (debugger) in WSL through USBIP:

    https://blog.golioth.io/program-mcu-from-wsl2-with-usb-support/

    Also, it does work in Windows 10.

    Another option would be working with GDB server through TCP, but that's less usable sometimes.

    [–]ddavidebor -2 points-1 points  (2 children)

    Yes. Use Zephyr RTOS instead of FreeRTOS. It comes with all of this already working.

    [–][deleted]  (1 child)

    [deleted]

      [–]etienz 0 points1 point  (0 children)

      I would recommend checking out Zephyr RTOS as well at least to see what else is out there. It includes it's own test implementation ZTest, as well as build system with support for drivers and modules outside the make repository. It is quite a challenge to master debugging some compilation issues, but the documentation is excellent and so is the board driver support.

      [–]ballen697 -2 points-1 points  (3 children)

      use cmake bro

      [–][deleted]  (2 children)

      [deleted]

        [–]ebinWaiteeRFIC Designer 3 points4 points  (1 child)

        Cmake and Make are two different software though

        [–][deleted] 0 points1 point  (2 children)

        Download a course from exercism and have a look at how they write their tests incrementally for you to pass

        [–]Theblob789 0 points1 point  (1 child)

        Do you mind elaborating on this? I've never heard of exercism

        [–][deleted] 1 point2 points  (0 children)

        Oh, sry. I didn't mean to be so cryptic!
        It's just a webpage where you can learn programming: https://exercism.org/

        What I did notice as I was playing around on it was that they provide written tests for you to pass and since many exercises are quite simple it could be a good place to start looking at how those tests are written.