How to compile

Pre-lab: Install the arm-none-eabi-gcc compiler: https://developer.arm.com/downloads/-/gnu-rm

<aside> ⚠️ MacOS: Change your path to include the arm-none-eabi-gcc compiler:

export PATH=$PATH:/Applications/ARM/bin

</aside>

<aside> ⚠️ Windows: You will need to install WSL→ Ubuntu, to install the arm compiler, run: →sudo apt update →sudo apt upgrade →sudo apt install gcc-arm-none-eabi

IT WILL NOT WORK WITHOUT WSL ON WINDOWS

</aside>

  1. Import CSP into project. Your file tree should look something like this:

Untitled

  1. In libcsp-develop, turn on printing for libcsp:
  2. Set CFLAGS envrionment variable:
# Setup CFLAGS
    if (len(ctx.stack_path) <= 1) and (len(ctx.env.CFLAGS) == 0):
        # ctx.env.prepend_value('CFLAGS', ["-std=gnu11", "-g", "-Os", "-Wall", "-Wextra", "-Wshadow", "-Wcast-align",
        #                                  "-Wwrite-strings", "-Wno-unused-parameter", "-Werror"])
        
        ctx.env.prepend_value('CFLAGS', ["-Wall", "-mcpu=cortex-m7", "-std=gnu11",
                              "-g3", "-mfpu=fpv5-d16", "-mfloat-abi=softfp", "-mthumb"])

<aside> ⚠️ MacOS users: Change all occurrences of #include <endian.h> to #include <machine/endian.h> NB: This sometimes applies to Windows, do this only if an error appears while compiling.

</aside>

<aside> ⚠️ Windows + WSL users: You may need to change the below commands to:

→python3 waf configure ... →python3 waf build install

</aside>

  1. In terminal:
cd [your-project-directory]/libcsp-develop

./waf configure --toolchain=arm-none-eabi- --with-os=freertos --prefix=install --includes=[your-project-directory]/Middlewares/Third_Party/FreeRTOS/Source/include/,[your-project-directory]/Core/Inc,[your-project-directory]/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F

./waf build install

./waf configure --toolchain=arm-none-eabi- --with-os=freertos --prefix=install --includes=/home/luwai/Projects/UTAT/FINCH-CommandDataHandling/3-FreeRTOS_SAFETY/Base_FreeTROS_CSP_Safety_Mode/Middlewares/Third_Party/FreeRTOS/Source/include/,/home/luwai/Projects/UTAT/FINCH-CommandDataHandling/3-FreeRTOS_SAFETY/Base_FreeTROS_CSP_Safety_Mode/Core/Inc,/home/luwai/Projects/UTAT/FINCH-CommandDataHandling/3-FreeRTOS_SAFETY/Base_FreeTROS_CSP_Safety_Mode/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F

Adding Paths to Your Project

If you get an error saying that a file or function cannot be found, but you are sure it is in the files, the include path might be missing.

This can be fixed by right clicking on the project → properties → C/C++ General → Paths and Symbols:

Include these paths with the purple icons to start with:

Screenshot 2023-09-16 at 2.54.07 PM.png