Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 19 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ARG DEBIAN_FRONTEND=noninteractive
# Python virtual environment.
RUN apt-get update && apt-get install -y --no-install-recommends \
openssh-server \
wget \
curl \
gnupg \
git \
Expand All @@ -17,9 +18,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-setuptools \
python3-pip \
python3-venv \
gcc-arm-none-eabi \
&& git config --global --add safe.directory /workspaces/fprime \
python3-venv

RUN wget https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz \
&& mkdir -p /arm-none-eabi \
&& tar -xf arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz -C /arm-none-eabi \
&& rm arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz \
# symlink
&& ln -s /arm-none-eabi/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc \
&& ln -s /arm-none-eabi/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-g++ /usr/bin/arm-none-eabi-g++ \
&& ln -s /arm-none-eabi/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb /usr/bin/arm-none-eabi-gdb \
&& ln -s /arm-none-eabi/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-size /usr/bin/arm-none-eabi-size \
&& ln -s /arm-none-eabi/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-objcopy /usr/bin/arm-none-eabi-objcopy \
# install and link deps
&& apt install -y --no-install-recommends libncurses-dev \
&& ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5 \
&& ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5

RUN git config --global --add safe.directory /workspaces/fprime \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m venv /tmp/fprime-venv \
&& . /tmp/fprime-venv/bin/activate \
Expand Down
7 changes: 1 addition & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/ubuntu
{
"name": "F'",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: hirsute, focal, bionic
// Use hirsute or bionic on local arm64/Apple Silicon.
"args": { "VARIANT": "22.04" }
},
"image": "danieldigby/fprime:v1.1",

// Provides runtime arguments to the container
"runArgs": [
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ coverity.out
*-template

logs
.log

test_harness/.autotools
core
Expand Down
12 changes: 12 additions & 0 deletions Fw/Types/FreeRTOS-stm/StandardTypes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <cstdint>
typedef int TaskIdRepr;
#define FPRIME_OVERRIDE_NATIVE_TYPES
typedef int32_t NATIVE_INT_TYPE;
typedef uint32_t NATIVE_UINT_TYPE;

#define M_PI (22.0/7.0)

#if 0
#define NAME_MAX 255

#endif
19 changes: 0 additions & 19 deletions Fw/Types/VxWorks/StandardTypes.hpp

This file was deleted.

6 changes: 6 additions & 0 deletions Os/Baremetal/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,11 @@ namespace Os {
Status getFileCount (const char* directory, U32& fileCount) {
return OTHER_ERROR;
} //end getFileCount
Status getFreeSpace(const char* path, U64& totalBytes, U64& freeBytes) {
return OTHER_ERROR;
}
Status appendFile(const char* originPath, const char* destPath, bool createMissingDest){
return OTHER_ERROR;
}
} // end FileSystem namespace
} // end Os namespace
33 changes: 33 additions & 0 deletions Os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,39 @@ if (FPRIME_USE_POSIX)
"${CMAKE_CURRENT_LIST_DIR}/Linux/Directory.cpp"
)
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeRTOS-stm")
message(STATUS "Detecting freeRTOS")
# add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/NucleoH7_freeRTOS/")

include_directories("${FPRIME_FRAMEWORK_PATH}/Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/include"
"${FPRIME_FRAMEWORK_PATH}/Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"
"${FPRIME_FRAMEWORK_PATH}/Ref/NucleoH7_freeRTOS/Drivers/CMSIS/Device/ST/STM32H7xx/Include"
"${FPRIME_FRAMEWORK_PATH}/Ref/NucleoH7_freeRTOS/Drivers/STM32H7xx_HAL_Driver/Inc"
"${FPRIME_FRAMEWORK_PATH}/Ref/NucleoH7_freeRTOS/Drivers/CMSIS/Include/"
"${FPRIME_FRAMEWORK_PATH}/Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"
"${FPRIME_FRAMEWORK_PATH}/Ref/NucleoH7_freeRTOS/Core/Inc"
"${FPRIME_FRAMEWORK_PATH}/Ref/NucleoH7_freeRTOS/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy/"
)
list(APPEND SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/LogPrintf.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-stm/InterruptLock.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-stm/IntervalTimer.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-stm/Mutex.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-stm/TaskId.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-stm/Queue.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-stm/Task.cpp"
# Non-VxWorks basic support
"${FPRIME_FRAMEWORK_PATH}/Os/Baremetal/SystemResources.cpp"
"${FPRIME_FRAMEWORK_PATH}/Os/Baremetal/File.cpp"
"${FPRIME_FRAMEWORK_PATH}/Os/Baremetal/FileSystem.cpp"
)
list(APPEND MOD_DEPS
Ref/NucleoH7_freeRTOS
)
# Communication Implementations
endif()

# Darwin IPC queue implementation
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
list(APPEND SOURCE_FILES
Expand Down
20 changes: 20 additions & 0 deletions Os/FreeRTOS-stm/InterruptLock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <Os/InterruptLock.hpp>
#include <Os/Mutex.hpp>
#include <Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h>

STATIC Os::Mutex intLockEmulator;

namespace Os {
InterruptLock::InterruptLock() : m_key(0) {}
InterruptLock::~InterruptLock() {}

void InterruptLock::lock(void) {
intLockEmulator.lock();
}

void InterruptLock::unLock(void) {
intLockEmulator.unLock();
}


}
40 changes: 40 additions & 0 deletions Os/FreeRTOS-stm/IntervalTimer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//Did not use rawinza's implementation
// xTaskGetTickCount() returns 16-bit or 32-bit tick values, and it may overflow.
// see: https://www.freertos.org/FreeRTOS_Support_Forum_Archive/February_2012/freertos_Tick_count_overflow_5005076.html

#include <Os/IntervalTimer.hpp>
#include <Fw/Types/Assert.hpp>
#include <Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h>

namespace Os {

void
IntervalTimer::getRawTime(RawTime& time)
{
TickType_t t = xTaskGetTickCount();
// TOOD(Daniel/Bill): Consider overflow

// This lower rawTime value is representative of miliseconds in freeRTOS
time.lower = t;

//https://www.freertos.org/FreeRTOS-Coding-Standard-and-Style-Guide.html#:~:text=port.%20These%20are%3A-,TickType_t,-If%20configUSE_16_BIT_TICKS%20is
}

U32
IntervalTimer::getDiffUsec(const RawTime& stopTime, const RawTime& startTime)
{
//arithmic involving roll-over is well-defined in c++
//https://stackoverflow.com/questions/28779803/is-subtracting-larger-unsigned-value-from-smaller-in-c-undefined-behaviour
#ifdef configUSE_16_BIT_TICKS
FW_ASSERT (configUSE_16_BIT_TICKS == 0);
#endif

#ifdef configTICK_RATE_HZ
FW_ASSERT (configTICK_RATE_HZ == (TickType_t)1000);
#endif

return 1000*(stopTime.lower - startTime.lower);
}


}
34 changes: 34 additions & 0 deletions Os/FreeRTOS-stm/Mutex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <Os/Mutex.hpp>
#include <Fw/Types/Assert.hpp>
#include <Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h>
#include <Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h>

namespace Os {

Mutex::Mutex(void)
{
SemaphoreHandle_t handle;

handle = xSemaphoreCreateMutex();

this->m_handle = (POINTER_CAST) handle;
}

Mutex::~Mutex(void)
{
vSemaphoreDelete(this->m_handle);
}

void Mutex::lock(void)
{
NATIVE_INT_TYPE stat = xSemaphoreTake( (SemaphoreHandle_t)this->m_handle, ( TickType_t ) 10 );
FW_ASSERT(stat == pdTRUE,stat);
}

void Mutex::unLock(void)
{
NATIVE_INT_TYPE stat = xSemaphoreGive( this->m_handle);
FW_ASSERT(stat == pdTRUE,stat);
}

}
154 changes: 154 additions & 0 deletions Os/FreeRTOS-stm/Queue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#include <Fw/Types/Assert.hpp>
#include <Os/Queue.hpp>
#include <Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h>
#include <Ref/NucleoH7_freeRTOS/Middlewares/Third_Party/FreeRTOS/Source/include/queue.h>
namespace Os
{

Queue::Queue() :
m_handle(NULL)
{}

Queue::~Queue()
{
vQueueDelete((QueueHandle_t)this->m_handle);
}

Queue::QueueStatus
Queue::createInternal(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
{
this->m_name = "/QP_";
this->m_name += name;
QueueHandle_t xQueue;
UBaseType_t uxQueueLength = depth;
UBaseType_t uxItemSize = msgSize;

xQueue = xQueueCreate(uxQueueLength,uxItemSize);

if (NULL == xQueue)
{
return QUEUE_UNINITIALIZED;
}
this->m_handle = (POINTER_CAST)xQueue;

Queue::s_numQueues++;

return QUEUE_OK;
}

Queue::QueueStatus
Queue::send(const U8* buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority, QueueBlocking block)
{

QueueHandle_t queueHandle = (QueueHandle_t) this->m_handle;

if (NULL == queueHandle)
{
return QUEUE_UNINITIALIZED;
}

if (NULL == buffer)
{
return QUEUE_EMPTY_BUFFER;
}

bool keepTrying = true;

while (keepTrying)
{
BaseType_t stat = xQueueSend(queueHandle, buffer, 5);
if (stat == errQUEUE_FULL)
{
return QUEUE_FULL;
}
else if (stat == pdTRUE)
{
keepTrying = false;
}

}

return QUEUE_OK;
}

Queue::QueueStatus
Queue::receive(U8* buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority, QueueBlocking block)
{

QueueHandle_t queueHandle = (QueueHandle_t) this->m_handle;

if (NULL == queueHandle)
{
return QUEUE_UNINITIALIZED;
}

bool notFinished = true;
while (notFinished)
{
BaseType_t stat = xQueueReceive(queueHandle, buffer, 5);

if (stat == pdFALSE)
{
return QUEUE_RECEIVE_ERROR; //rawinza used QUEUE_UNKNOWN_ERROR
}
else
{
notFinished = false;
}
}

actualSize = (NATIVE_INT_TYPE) capacity; //TODO Need a way to find actual size??
return QUEUE_OK;
}

NATIVE_INT_TYPE
Queue::getNumMsgs(void) const
{
QueueHandle_t queueHandle = (QueueHandle_t) this->m_handle;
if (NULL == queueHandle)
{
return QUEUE_UNINITIALIZED;
}

UBaseType_t numMsg;
numMsg = uxQueueMessagesWaiting(queueHandle);

return (U32) numMsg;
}

/**
* The max number of items that has been in the queue, the "high water mark". This is not available in FreeRTOS
*/
NATIVE_INT_TYPE
Queue::getMaxMsgs(void) const
{
//FW_ASSERT(0);
return 0;
}

NATIVE_INT_TYPE
Queue::getQueueSize(void) const
{
QueueHandle_t queueHandle = (QueueHandle_t) this->m_handle;
if (NULL == queueHandle)
{
return QUEUE_UNINITIALIZED;
}

return (U32)(uxQueueMessagesWaiting(queueHandle)+uxQueueSpacesAvailable(queueHandle));
}

NATIVE_INT_TYPE Queue::getMsgSize(void) const
{
QueueHandle_t queueHandle = (QueueHandle_t) this->m_handle;
if (NULL == queueHandle)
{
return QUEUE_UNINITIALIZED;
}

//TODO to get actual msg size, or FreeRTOS doesn't support?

return 0;
}

} // namespace Os
Loading