nasa / fprime

F´ - A flight software and embedded systems framework
https://fprime.jpl.nasa.gov
Apache License 2.0
10.05k stars 1.3k forks source link

Overriding Baremetal Os Abstraction #2330

Open ethancheez opened 11 months ago

ethancheez commented 11 months ago
F´ Version 3.3.2
Affected Component Os/Baremetal/

Problem Description

The fprime/Os/Baremetal/CMakeLists.txt file always adds the Baremetal Os abstractions of File, FileSystem, IntervalTimer, Mutex, Queue, SystemResources, Task when defining the FPRIME_USE_BAREMETAL_SCHEDULER flag. So even if an external package that attempts to create a specific Os abstraction (i.e. File), the Os/Baremetal/___.cpp versions will always be used instead of the external package.

Reproduce Bug

We can use the existing IntervalTimer.cpp file in fprime-arduino as an example, as that is expected to override the Os/Baremetal/IntervalTimer.cpp within fprime.

  1. Simply call the IntervalTimer getRawTime() function. It will call the function inside of the fprime Os/Baremetal version instead of fprime-arduino's version.

Suggestion

The FPRIME_USE_BAREMETAL_SCHEDULER flag should only replace the Task Scheduler to use the Baremetal implementation, not add all of the other Baremetal Os abstractions. The baremetal package(s) should be the ones adding those baremetal abstractions (see how fprime-arduino is doing it here.

Why

A File.cpp abstraction for the fprime-arduino package is currently in development as it is needed for fprime-artemis-cubesat to replace the Baremetal implementation, which currently does nothing.

Temporary Solution

The following lines were commented out in the CMake file:

# list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/File.cpp")
# list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/FileSystem.cpp")
# list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/IntervalTimer.cpp")
# list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/Mutex.cpp")
# list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/Queue.cpp")
# list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/SystemResources.cpp")
# list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/Task.cpp")

Instead, these are linked within the Os abstraction of fprime-arduino here.

For example, if I choose to override the Baremetal File.cpp version, I simply replace:

"${FPRIME_FRAMEWORK_PATH}/Os/Baremetal/File.cpp"

with:

"${CMAKE_CURRENT_LIST_DIR}/File.cpp"
LeStarch commented 11 months ago

Agreed. This is one of the many drivers behind #1685. The intent there is to allow selection of implementations for each thing in Os