zedboard working

This commit is contained in:
Ulrich Mohr 2023-09-15 17:37:58 +02:00
parent fb8f4a68e7
commit 5a61af053b
13 changed files with 149 additions and 183 deletions

View File

@ -60,6 +60,7 @@ set(FSFW_ADDITIONAL_INC_PATHS
set(FSFW_ADD_MONITORING ON)
add_subdirectory(fsfw)
add_subdirectory(common)
add_subdirectory(${MISSION_PATH})
@ -68,10 +69,11 @@ add_subdirectory(${MISSION_PATH})
# ##############################################################################
# Add libraries for all sources.
target_link_libraries(${TARGET_NAME} PUBLIC freertos_kernel fsfw)
target_link_libraries(fsfw PUBLIC freertos_kernel)
target_link_libraries(${TARGET_NAME} PUBLIC fsfw)
# target_include_directories(
# ${TARGET_NAME} PUBLIC ${COMMON_DIR}/include)
target_include_directories(
${TARGET_NAME} PUBLIC ${BSP_PATH})
target_link_options(${TARGET_NAME} PRIVATE -Wl,--start-group,-lgcc,-lc,--end-group -Wl,-Map=${TARGET_NAME}.map -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none -T${CMAKE_SOURCE_DIR}/${FreeRTOS_CONFIG_PATH}/lscript.ld -specs=${CMAKE_SOURCE_DIR}/${FreeRTOS_CONFIG_PATH}/Xilinx.spec)

View File

@ -1,2 +1,3 @@
add_subdirectory(freeRTOS)
add_subdirectory(ps7_cortexa9_0)
add_subdirectory(ps7_cortexa9_0)
add_subdirectory(objects)

View File

@ -77,7 +77,7 @@
#define configUSE_TICK_HOOK 1
#define configMAX_PRIORITIES ( 7 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 250 ) /* Large in case configUSE_TASK_FPU_SUPPORT is 2 in which case all tasks have an FPU context. */
#define configTOTAL_HEAP_SIZE ( 125 * 1024 )
#define configTOTAL_HEAP_SIZE ( 20 * 1024 * 1024 )
#define configMAX_TASK_NAME_LEN ( 10 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
@ -90,7 +90,7 @@
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_QUEUE_SETS 1
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_STATIC_ALLOCATION 0
/* Include the query-heap CLI command to query the free heap space. */
#define configINCLUDE_QUERY_HEAP_COMMAND 1

View File

@ -11,7 +11,7 @@
/*******************************************************************/
_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x2000;
_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x2000;
_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x01400000;
_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024;
_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048;
@ -23,7 +23,7 @@ _UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024;
MEMORY
{
ps7_ddr_0_S_AXI_BASEADDR : ORIGIN = 0x00100000, LENGTH = 0x01000000
ps7_ddr_0_S_AXI_BASEADDR : ORIGIN = 0x00100000, LENGTH = 0x20000000
ps7_qspi_linear_0_S_AXI_BASEADDR : ORIGIN = 0xFC000000, LENGTH = 0x1000000
ps7_ram_0_S_AXI_BASEADDR : ORIGIN = 0x0, LENGTH = 0x30000
ps7_ram_1_S_AXI_BASEADDR : ORIGIN = 0xFFFF0000, LENGTH = 0xFE00

View File

@ -1,5 +1,3 @@
add_subdirectory(communication)
target_sources(
${TARGET_NAME} PRIVATE
ObjectFactory.cpp)

View File

@ -3,16 +3,11 @@
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw/storagemanager/PoolManager.h>
#include <fsfw/tmtc/TmManager.h>
#include <fsfw/tmtc/UdpTmTcBridge.h>
#include <mission/controllers/SteeringController.h>
#include <mission/devicehandlers/RoboclawHandler.h>
#include <mission/devicehandlers/ServoHandler.h>
#include <mission/controller/PrintController.h>
#include "fsfw/events/EventManager.h"
#include "fsfw/health/HealthTable.h"
#include "fsfw/internalerror/InternalErrorReporter.h"
#include "objects/communication/SerialTCPCookie.h"
#include "objects/communication/ServoCommInterface.h"
#include "systemObjects.h"
namespace objects {
@ -29,32 +24,26 @@ enum commonObjects : object_id_t {
};
}
namespace ObjectFactory {
uint16_t listeningPort = 0;
socklen_t defaultDestinationLen = 0;
const sockaddr *defaultDestination = nullptr;
const char *simString = nullptr;
} // namespace ObjectFactory
void Factory::setStaticFrameworkObjectIds() {
// MonitoringReportContent<float>::timeStamperId = objects::TIME_STAMPER;
// MonitoringReportContent<double>::timeStamperId = objects::TIME_STAMPER;
// MonitoringReportContent<uint32_t>::timeStamperId = objects::TIME_STAMPER;
// MonitoringReportContent<int32_t>::timeStamperId = objects::TIME_STAMPER;
// MonitoringReportContent<int16_t>::timeStamperId = objects::TIME_STAMPER;
// MonitoringReportContent<uint16_t>::timeStamperId = objects::TIME_STAMPER;
// void Factory::setStaticFrameworkObjectIds() {
// // MonitoringReportContent<float>::timeStamperId = objects::TIME_STAMPER;
// // MonitoringReportContent<double>::timeStamperId = objects::TIME_STAMPER;
// // MonitoringReportContent<uint32_t>::timeStamperId = objects::TIME_STAMPER;
// // MonitoringReportContent<int32_t>::timeStamperId = objects::TIME_STAMPER;
// // MonitoringReportContent<int16_t>::timeStamperId = objects::TIME_STAMPER;
// // MonitoringReportContent<uint16_t>::timeStamperId = objects::TIME_STAMPER;
// PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_DISTRIBUTOR;
// PusServiceBase::PACKET_DESTINATION = objects::PUS_TM_FUNNEL;
// // PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_DISTRIBUTOR;
// // PusServiceBase::PACKET_DESTINATION = objects::PUS_TM_FUNNEL;
// CommandingServiceBase::defaultPacketSource = objects::PUS_DISTRIBUTOR;
// CommandingServiceBase::defaultPacketDestination = objects::PUS_TM_FUNNEL;
// // CommandingServiceBase::defaultPacketSource = objects::PUS_DISTRIBUTOR;
// // CommandingServiceBase::defaultPacketDestination = objects::PUS_TM_FUNNEL;
// VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION;
}
// // VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION;
// }
void ObjectFactory::produce(void *args) {
Factory::setStaticFrameworkObjectIds();
//Factory::setStaticFrameworkObjectIds();
@ -69,4 +58,6 @@ void ObjectFactory::produce(void *args) {
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
new TmManager(objects::TM_MANAGER);
new PrintController(123);
}

View File

@ -1,13 +1,8 @@
#pragma once
#include <cstdint>
#include <sys/socket.h>
namespace ObjectFactory {
extern uint16_t listeningPort;
extern socklen_t defaultDestinationLen ;
extern const sockaddr * defaultDestination ;
extern const char * simString;
void produce(void* args);
} // namespace ObjectFactory

View File

@ -23,8 +23,8 @@
#include "xparameters_ps.h"
#define STDIN_BASEADDRESS 0xE0000000
#define STDOUT_BASEADDRESS 0xE0000000
#define STDIN_BASEADDRESS 0xE0001000
#define STDOUT_BASEADDRESS 0xE0001000
/******************************************************************/

View File

@ -204,6 +204,7 @@ OKToRun:
/* set VBAR to the _vector_table address in linker script */
ldr r0, =vector_base
mcr p15, 0, r0, c12, c0, 0
MRC p15, 0, r1, c12, c0, 0
/*invalidate scu*/
#if USE_AMP!=1

View File

@ -1 +1 @@
target_sources(${TARGET_NAME} PRIVATE main.cpp)
target_sources(${TARGET_NAME} PRIVATE main.cpp controller/PrintController.cpp)

View File

@ -0,0 +1,19 @@
#include "PrintController.h"
#include <cstdio>
PrintController::PrintController(object_id_t setObjectId)
: SystemObject(setObjectId) {}
ReturnValue_t PrintController::initialize() {
ReturnValue_t result = SystemObject::initialize();
if (result != returnvalue::OK) {
return result;
}
return returnvalue::OK;
}
ReturnValue_t PrintController::performOperation(uint8_t operationCode) {
printf("running\n");
return returnvalue::OK;
}

View File

@ -0,0 +1,15 @@
#pragma once
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
class PrintController: public SystemObject, public ExecutableObjectIF {
public:
PrintController(object_id_t setObjectId);
virtual ~PrintController() = default;
ReturnValue_t initialize() override;
ReturnValue_t performOperation(uint8_t operationCode) override;
};

View File

@ -90,19 +90,29 @@ extern "C" {
#include "xscugic.h"
#include "xscutimer.h"
#include "xuartps_hw.h"
// TODO why? is in bsp
void _exit(sint32 status);
// (void)status;
// while (1) {
// ;
// }
// }
sint32 _write(sint32 fd, char8 *buf, sint32 nbytes);
}
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/ipc/CommandMessageCleaner.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tasks/TaskFactory.h>
#include <objects/systemObjects.h>
#include <cstdio>
void messagetypes::clearMissionMessage(CommandMessage* message){};
#include <objects/ObjectFactory.h>
#if FSFW_CPP_OSTREAM_ENABLED == 1
ServiceInterfaceStream sif::debug("DEBUG", false);
ServiceInterfaceStream sif::info("INFO", false);
ServiceInterfaceStream sif::warning("WARNING", false);
ServiceInterfaceStream sif::error("ERROR", false, true, true);
#endif
/*
* Configure the hardware as necessary to run this demo.
*/
@ -133,145 +143,29 @@ XScuWdt xWatchDogInstance;
other modules. */
XScuGic xInterruptController;
/*-----------------------------------------------------------*/
#define XPS_UART0_BASEADDR 0xE0000000U
#define UART_BASE XPS_UART0_BASEADDR
#define XUARTPS_SR_TNFUL 0x00004000U /**< TX FIFO Nearly Full Status */
#define XUARTPS_SR_TACTIVE 0x00000800U /**< TX active */
#define XUARTPS_SR_RXEMPTY 0x00000002U /**< RX FIFO empty */
#define POINTER_TO_REGISTER(REG) (*((volatile uint32_t *)(REG)))
#define UART_FIFO POINTER_TO_REGISTER(UART_BASE + XUARTPS_FIFO_OFFSET) // FIFO
#define UART_STATUS \
POINTER_TO_REGISTER(UART_BASE + XUARTPS_SR_OFFSET) // Channel Status
void uart_send(char c) {
while (UART_STATUS & XUARTPS_SR_TNFUL)
;
UART_FIFO = c;
while (UART_STATUS & XUARTPS_SR_TACTIVE)
;
}
/* Priorities at which the tasks are created. */
#define mainQUEUE_RECEIVE_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
#define mainQUEUE_SEND_TASK_PRIORITY (tskIDLE_PRIORITY + 1)
/* The rate at which data is sent to the queue. The 200ms value is converted
to ticks using the portTICK_PERIOD_MS constant. */
#define mainQUEUE_SEND_FREQUENCY_MS (1000 / portTICK_PERIOD_MS)
/* The number of items the queue can hold. This is 1 as the receive task
will remove items as they are added, meaning the send task should always find
the queue empty. */
#define mainQUEUE_LENGTH (1)
/* The LED toggled by the Rx task. */
#define mainTASK_LED (0)
/*-----------------------------------------------------------*/
/*
* The tasks as described in the comments at the top of this file.
*/
static void prvQueueReceiveTask(void *pvParameters);
static void prvQueueSendTask(void *pvParameters);
/*-----------------------------------------------------------*/
/* The queue used by both tasks. */
static QueueHandle_t xQueue = NULL;
/*-----------------------------------------------------------*/
void uart_send(char c);
static void prvQueueSendTask(void *pvParameters) {
TickType_t xNextWakeTime;
const unsigned long ulValueToSend = 100UL;
/* Remove compiler warning about unused parameter. */
(void)pvParameters;
/* Initialise xNextWakeTime - this only needs to be done once. */
xNextWakeTime = xTaskGetTickCount();
// vTaskDelayUntil(&xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS / 2);
for (;;) {
/* Place this task in the blocked state until it is time to run again. */
vTaskDelayUntil(&xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS);
uart_send('C');
/* Send to the queue - causing the queue receive task to unblock and
toggle the LED. 0 is used as the block time so the sending operation
will not block - it shouldn't need to block as the queue should always
be empty at this point in the code. */
xQueueSend(xQueue, &ulValueToSend, 0U);
}
}
/*-----------------------------------------------------------*/
static void prvQueueReceiveTask(void *pvParameters) {
unsigned long ulReceivedValue;
const unsigned long ulExpectedValue = 100UL;
/* Remove compiler warning about unused parameter. */
(void)pvParameters;
for (;;) {
/* Wait until something arrives in the queue - this task will block
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
FreeRTOSConfig.h. */
xQueueReceive(xQueue, &ulReceivedValue, portMAX_DELAY);
uart_send('0');
/* To get here something must have been received from the queue, but
is it the expected value? If it is, toggle the LED. */
if (ulReceivedValue == ulExpectedValue) {
// vParTestToggleLED(mainTASK_LED);
ulReceivedValue = 0U;
}
}
}
/*-----------------------------------------------------------*/
void mission(void *);
int main(void) {
/* Configure the hardware ready to run the demo. */
prvSetupHardware();
printf("Booting Software\n");
/* Create the queue. */
xQueue = xQueueCreate(mainQUEUE_LENGTH, sizeof(uint32_t));
int taskParameters =0;
if (xQueue != NULL) {
/* Start the two tasks as described in the comments at the top of this
file. */
xTaskCreate(
prvQueueReceiveTask, /* The function that implements the task. */
"Rx", /* The text name assigned to the task - for debug only as it is
not used by the kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the
task. */
NULL, /* The parameter passed to the task - not used in this case. */
mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task.
*/
NULL); /* The task handle is not required, so NULL is passed. */
xTaskCreate(prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL,
mainQUEUE_SEND_TASK_PRIORITY, NULL);
/* Start the tasks and timer running. */
vTaskStartScheduler();
}
xTaskCreate(
mission, /* The function that implements the task. */
"init", /* The text name assigned to the task - for debug only as it is not used by the
kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
&taskParameters, /* The parameter passed to the task - not used in this simple case. */
1, /* The priority assigned to the task. */
nullptr); /* The task handle is not required, so NULL is passed. */
vTaskStartScheduler();
/* If all is well, the scheduler will now be running, and the following
line will never be reached. If the following line does execute, then
there was either insufficient FreeRTOS heap memory available for the idle
@ -285,6 +179,56 @@ int main(void) {
/* Don't expect to reach here. */
return 0;
}
#define sev() __asm__("sev")
#define CPU1STARTADR 0xfffffff0
void mission(void *){
printf("Starting Mission\n");
printf("CPU0: writing startaddress for cpu1\n\r");
Xil_Out32(CPU1STARTADR, 0x00200000);
dmb(); //waits until write has finished
printf("CPU0: sending the SEV to wake up CPU1\n\r");
sev();
sif::debug << "OStreams working" << std::endl;
ObjectManager* objManager = ObjectManager::instance();
objManager->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
printf("Created Objects\n");
objManager->initialize();
printf("Initialized Objects\n");
TaskFactory* taskFactory = TaskFactory::instance();
if (taskFactory == nullptr) {
printf("Ooopsie\n");
return;
}
TaskPriority currPrio;
TaskDeadlineMissedFunction deadlineMissedFunc = nullptr;
currPrio = 2;
PeriodicTaskIF* controllerTask = taskFactory->createPeriodicTask(
"controller", currPrio, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, nullptr);
controllerTask->addComponent(123);
printf("Created Tasks\n");
controllerTask->startTask();
printf("Started Tasks, deleting init task\n");
vTaskDelete(nullptr);
}
/*-----------------------------------------------------------*/
static void prvSetupHardware(void) {