From 0e9dbfeb8f115424799fed694be30da56293eb30 Mon Sep 17 00:00:00 2001 From: Kristofer Jonsson Date: Mon, 4 Oct 2021 11:39:07 +0000 Subject: Revert "FreeRTOS app bug fix." This reverts commit 43834ab8967d1e8f063533c8c8cbf84be8ccc1b0. Reason for revert: Temporarily backing out change to fix compilation issue for Cortex-M4. Change-Id: I98a4ba8ce44e0ca396b7eb052cec4adecb9fe0ad --- applications/freertos/main.cpp | 71 +++++++-------------------------- cmake/toolchain/arm-none-eabi-gcc.cmake | 6 --- 2 files changed, 14 insertions(+), 63 deletions(-) diff --git a/applications/freertos/main.cpp b/applications/freertos/main.cpp index ae4bc38..1c1821d 100644 --- a/applications/freertos/main.cpp +++ b/applications/freertos/main.cpp @@ -21,7 +21,6 @@ ****************************************************************************/ #include "FreeRTOS.h" -#include "portmacro.h" #include "queue.h" #include "semphr.h" #include "task.h" @@ -121,60 +120,31 @@ struct xInferenceJob : public InferenceJob { extern "C" { void *ethosu_mutex_create(void) { - SemaphoreHandle_t sem = xSemaphoreCreateMutex(); - if (sem == NULL) { - printf("Error: Failed to create mutex.\n"); - } - return (void *)sem; + return xSemaphoreCreateMutex(); } void ethosu_mutex_lock(void *mutex) { SemaphoreHandle_t handle = reinterpret_cast(mutex); - if (xSemaphoreTake(handle, portMAX_DELAY) != pdTRUE) { - printf("Error: Failed to lock mutex.\n"); - } + xSemaphoreTake(handle, portMAX_DELAY); } void ethosu_mutex_unlock(void *mutex) { SemaphoreHandle_t handle = reinterpret_cast(mutex); - if (xSemaphoreGive(handle) != pdTRUE) { - printf("Error: Failed to unlock mutex.\n"); - } + xSemaphoreGive(handle); } void *ethosu_semaphore_create(void) { - SemaphoreHandle_t sem = xSemaphoreCreateBinary(); - if (sem == NULL) { - printf("Error: Failed to create semaphore.\n"); - } - return (void *)sem; + return xSemaphoreCreateBinary(); } void ethosu_semaphore_take(void *sem) { SemaphoreHandle_t handle = reinterpret_cast(sem); - if (xSemaphoreTake(handle, portMAX_DELAY) != pdTRUE) { - printf("Error: Failed to take semaphore.\n"); - } + xSemaphoreTake(handle, portMAX_DELAY); } void ethosu_semaphore_give(void *sem) { SemaphoreHandle_t handle = reinterpret_cast(sem); - BaseType_t ret; - - if (xPortIsInsideInterrupt()) { - ret = xSemaphoreGiveFromISR(handle, NULL); - if (ret != pdTRUE) { - printf("Error: Failed to give semaphore from ISR. ret - 0x%08x\n", ret); - } - } else { - ret = xSemaphoreGive(handle); - if (ret != pdTRUE) { - /* The next line is in comment because xSemaphoreGive returns pdFAIL when - calling it twice in a row during this application run. - This failure doesn't affect the final result of the FreeRTOS application. */ - /* printf("Error: Failed to give semaphore. ret - 0x%08x\n", ret); */ - } - } + xSemaphoreGive(handle); } } @@ -191,17 +161,10 @@ void inferenceProcessTask(void *pvParameters) { for (;;) { xInferenceJob *xJob; - if (xQueueReceive(params.queueHandle, &xJob, portMAX_DELAY) != pdPASS) { - printf("Error: inferenceProcessTask failed in receive from Q.\n"); - exit(1); - } - + xQueueReceive(params.queueHandle, &xJob, portMAX_DELAY); bool status = inferenceProcess.runJob(*xJob); xJob->status = status; - if (xQueueSend(xJob->responseQueue, &xJob, portMAX_DELAY) != pdPASS) { - printf("Error: inferenceProcessTask failed in send to Q.\n"); - exit(1); - } + xQueueSend(xJob->responseQueue, &xJob, portMAX_DELAY); } vTaskDelete(nullptr); } @@ -226,20 +189,14 @@ void inferenceSenderTask(void *pvParameters) { job->expectedOutput.push_back(DataPtr(expectedOutputData, sizeof(expectedOutputData))); job->responseQueue = senderQueue; // Send job - printf("inferenceSenderTask: Sending inference job: job=%p, name=%s\n", job, job->name.c_str()); - if (xQueueSend(inferenceProcessQueue, &job, portMAX_DELAY) != pdPASS) { - printf("Error: inferenceSenderTask failed in send to Q.\n"); - exit(1); - } + printf("Sending inference job: job=%p, name=%s\n", job, job->name.c_str()); + xQueueSend(inferenceProcessQueue, &job, portMAX_DELAY); } // Listen for completion status do { xInferenceJob *pSendJob; - if (xQueueReceive(senderQueue, &pSendJob, portMAX_DELAY) != pdPASS) { - printf("Error: inferenceSenderTask failed in receive from Q.\n"); - exit(1); - } + xQueueReceive(senderQueue, &pSendJob, portMAX_DELAY); printf("inferenceSenderTask: received response for job: %s, status = %u\n", pSendJob->name.c_str(), pSendJob->status); @@ -269,7 +226,7 @@ int main() { for (int n = 0; n < NUM_JOB_TASKS; n++) { ret = xTaskCreate(inferenceSenderTask, "inferenceSenderTask", 2 * 1024, inferenceProcessQueue, 2, nullptr); if (ret != pdPASS) { - printf("Error: Failed to create 'inferenceSenderTask%i'\n", n); + printf("FreeRTOS: Failed to create 'inferenceSenderTask%i'\n", n); exit(1); } } @@ -279,7 +236,7 @@ int main() { taskParams[n] = ProcessTaskParams(inferenceProcessQueue, inferenceProcessTensorArena[n], arenaSize); ret = xTaskCreate(inferenceProcessTask, "inferenceProcessTask", 8 * 1024, &taskParams[n], 3, nullptr); if (ret != pdPASS) { - printf("Error: Failed to create 'inferenceProcessTask%i'\n", n); + printf("FreeRTOS: Failed to create 'inferenceProcessTask%i'\n", n); exit(1); } } @@ -287,7 +244,7 @@ int main() { // Start Scheduler vTaskStartScheduler(); - printf("Error: FreeRTOS application failed to initialise.\n"); + printf("FreeRTOS application failed to initialise \n"); exit(1); return 0; diff --git a/cmake/toolchain/arm-none-eabi-gcc.cmake b/cmake/toolchain/arm-none-eabi-gcc.cmake index fba645d..11a1191 100644 --- a/cmake/toolchain/arm-none-eabi-gcc.cmake +++ b/cmake/toolchain/arm-none-eabi-gcc.cmake @@ -65,12 +65,6 @@ elseif("${TARGET_CPU}" MATCHES "\\+nofp") elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortex-m33" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortex-m55") set(FLOAT hard) -elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortex-m4" OR - "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortex-m7") - set(FLOAT hard) - set(FPU_CONFIG "fpv4-sp-d16") - add_compile_options(-mfpu=${FPU_CONFIG}) - add_link_options(-mfpu=${FPU_CONFIG}) else() set(FLOAT soft) endif() -- cgit v1.2.1