From 3eaf1ef3c3407a72460fe99f71a33d89c07ca490 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Mon, 17 Aug 2015 16:29:44 +0200 Subject: [PATCH 1/6] LP-96 - Implement CPU idle counters and calibration functions --- flight/modules/System/systemmod.c | 7 ++- flight/pios/common/pios_task_monitor.c | 67 ++++++++++++++-------- flight/pios/inc/pios_task_monitor.h | 35 +++++++++-- shared/uavobjectdefinition/systemstats.xml | 2 + 4 files changed, 79 insertions(+), 32 deletions(-) diff --git a/flight/modules/System/systemmod.c b/flight/modules/System/systemmod.c index 8c94ec1b1..a4706235f 100644 --- a/flight/modules/System/systemmod.c +++ b/flight/modules/System/systemmod.c @@ -59,6 +59,7 @@ #include #include #include +#include #ifdef PIOS_INCLUDE_INSTRUMENTATION #include @@ -528,7 +529,6 @@ static uint16_t GetFreeIrqStackSize(void) static void updateStats() { SystemStatsData stats; - // Get stats and update SystemStatsGet(&stats); stats.FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; @@ -558,7 +558,9 @@ static void updateStats() stats.UsrSlotsActive = fsStats.num_active_slots; } #endif - stats.CPULoad = 100 - PIOS_TASK_MONITOR_GetIdlePercentage(); + stats.CPUIdleTicks = PIOS_TASK_MONITOR_GetIdleTicksCount(); + stats.CPUZeroLoadTicks = PIOS_TASK_MONITOR_GetZeroLoadTicksCount(); + stats.CPULoad = 100 - (uint8_t)((100 * stats.CPUIdleTicks) / stats.CPUZeroLoadTicks); #if defined(PIOS_INCLUDE_ADC) && defined(PIOS_ADC_USE_TEMP_SENSOR) float temp_voltage = PIOS_ADC_PinGetVolt(PIOS_ADC_TEMPERATURE_PIN); @@ -642,6 +644,7 @@ static void updateSystemAlarms() */ void vApplicationIdleHook(void) { + PIOS_TASK_MONITOR_IdleHook(); NotificationOnboardLedsRun(); #ifdef PIOS_INCLUDE_WS2811 LedNotificationExtLedsRun(); diff --git a/flight/pios/common/pios_task_monitor.c b/flight/pios/common/pios_task_monitor.c index 958a744a6..c6616b503 100644 --- a/flight/pios/common/pios_task_monitor.c +++ b/flight/pios/common/pios_task_monitor.c @@ -1,11 +1,12 @@ /** ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System + * @addtogroup LibrePilotSystem LibrePilot System * @{ - * @addtogroup OpenPilotLibraries OpenPilot System Libraries + * @addtogroup LibrePilotLibraries LibrePilot System Libraries * @{ - * @file pios_task_monitor.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @file pios_task_monitor.c + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015. * @brief Task monitoring functions * @see The GNU Public License (GPL) Version 3 * @@ -36,6 +37,9 @@ static uint32_t mLastMonitorTime; static uint32_t mLastIdleMonitorTime; static uint16_t mMaxTasks; +volatile uint32_t idleCounter; +uint32_t zeroLoadIdleCounterPerSec = UINT32_MAX; +volatile bool idleCounterClear; /** * Initialize the Task Monitor */ @@ -149,31 +153,44 @@ void PIOS_TASK_MONITOR_ForEachTask(TaskMonitorTaskInfoCallback callback, void *c xSemaphoreGiveRecursive(mLock); } + uint8_t PIOS_TASK_MONITOR_GetIdlePercentage() { -#if defined(ARCH_POSIX) || defined(ARCH_WIN32) - return 50; + uint32_t ticks = PIOS_TASK_MONITOR_GetIdleTicksCount(); -#elif (configGENERATE_RUN_TIME_STATS == 1) - xSemaphoreTakeRecursive(mLock, portMAX_DELAY); - - uint32_t currentTime = portGET_RUN_TIME_COUNTER_VALUE(); - - /* avoid divide-by-zero if the interval is too small */ - uint32_t deltaTime = ((currentTime - mLastIdleMonitorTime) / 100) ? : 1; - mLastIdleMonitorTime = currentTime; - uint8_t running_time_percentage = 0; - - /* Generate idle time percentage stats */ - running_time_percentage = uxTaskGetRunTime(xTaskGetIdleTaskHandle()) / deltaTime; - xSemaphoreGiveRecursive(mLock); - return running_time_percentage; - -#else - return 0; - -#endif + return (uint8_t)((100 * ticks) / zeroLoadIdleCounterPerSec); } +uint32_t PIOS_TASK_MONITOR_GetIdleTicksCount() +{ + static portTickType lastTickCount = 0; + uint32_t ticks = 0; + portTickType now = xTaskGetTickCount(); + + if (idleCounterClear) { + idleCounter = 0; + } + + if (now > lastTickCount) { + uint32_t dT = (xTaskGetTickCount() - lastTickCount) * portTICK_RATE_MS; // in ms + ticks = (1000 * idleCounter) / dT; + } // else: TickCount has wrapped, do not calc now + lastTickCount = now; + idleCounterClear = true; + return ticks; +} + +void PIOS_TASK_MONITOR_CalibrateIdleCounter() +{ + idleCounterClear = true; + PIOS_TASK_MONITOR_GetIdleTicksCount(); + vTaskDelay(20); + zeroLoadIdleCounterPerSec = PIOS_TASK_MONITOR_GetIdleTicksCount(); +} + +uint32_t PIOS_TASK_MONITOR_GetZeroLoadTicksCount() +{ + return zeroLoadIdleCounterPerSec; +} #endif // PIOS_INCLUDE_TASK_MONITOR diff --git a/flight/pios/inc/pios_task_monitor.h b/flight/pios/inc/pios_task_monitor.h index 42edc104f..17306ba5f 100644 --- a/flight/pios/inc/pios_task_monitor.h +++ b/flight/pios/inc/pios_task_monitor.h @@ -1,15 +1,17 @@ /** ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System + * @addtogroup LibrePilotSystem LibrePilot System * @{ - * @addtogroup OpenPilotLibraries OpenPilot System Libraries + * @addtogroup LibrePilotLibraries LibrePilot System Libraries * @{ - * @file task_monitor.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * @file pios_task_monitor.h + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015. * @brief Task monitoring functions * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ + /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +31,8 @@ #define PIOS_TASK_MONITOR_H #include - +extern volatile uint32_t idleCounter; +extern volatile bool idleCounterClear; /** * Initializes the Task Monitor. * @@ -109,4 +112,26 @@ extern void PIOS_TASK_MONITOR_ForEachTask(TaskMonitorTaskInfoCallback callback, */ extern uint8_t PIOS_TASK_MONITOR_GetIdlePercentage(); +static inline void PIOS_TASK_MONITOR_IdleHook() +{ + if (!idleCounterClear) { + ++idleCounter; + } else { + idleCounter = 0; + idleCounterClear = false; + } +} + +/** + * Calibrate the idle counter. it should be run with a single task (caller) created + */ +extern void PIOS_TASK_MONITOR_CalibrateIdleCounter(); +/** + * return the number of idle hook execution per second + * @return number of idle hook execution per second + */ +extern uint32_t PIOS_TASK_MONITOR_GetIdleTicksCount(); + +extern uint32_t PIOS_TASK_MONITOR_GetZeroLoadTicksCount(); + #endif // PIOS_TASK_MONITOR_H diff --git a/shared/uavobjectdefinition/systemstats.xml b/shared/uavobjectdefinition/systemstats.xml index 4de866eb2..8d4163a99 100644 --- a/shared/uavobjectdefinition/systemstats.xml +++ b/shared/uavobjectdefinition/systemstats.xml @@ -6,6 +6,8 @@ + + From b88681c69f29382e591f618242d03adfb9bbcd67 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Tue, 18 Aug 2015 15:25:33 +0200 Subject: [PATCH 2/6] LP-97 - Move the common Init process within the System module (coptercontrol/revolution) --- flight/modules/System/inc/systemmod.h | 7 +- flight/modules/System/systemmod.c | 22 +++-- flight/pios/inc/pios_initcall.h | 4 +- .../coptercontrol/bootloader/pios_board.c | 3 - .../coptercontrol/firmware/coptercontrol.c | 45 +++------- .../coptercontrol/firmware/pios_board.c | 7 +- .../boards/revolution/firmware/revolution.cpp | 79 +++-------------- .../boards/revonano/firmware/revolution.cpp | 62 +++---------- .../boards/revoproto/firmware/revolution.cpp | 79 +++-------------- .../targets/boards/simposix/firmware/Makefile | 1 + .../boards/simposix/firmware/simposix.cpp | 88 +++---------------- 11 files changed, 85 insertions(+), 312 deletions(-) diff --git a/flight/modules/System/inc/systemmod.h b/flight/modules/System/inc/systemmod.h index bd709f404..5abf10d05 100644 --- a/flight/modules/System/inc/systemmod.h +++ b/flight/modules/System/inc/systemmod.h @@ -1,12 +1,13 @@ /** ****************************************************************************** - * @addtogroup OpenPilotModules OpenPilot Modules + * @addtogroup LibrePilotModules LibrePilot Modules * @{ * @addtogroup SystemModule System Module * @{ * * @file systemmod.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @brief System module * * @see The GNU Public License (GPL) Version 3 @@ -30,6 +31,6 @@ #ifndef SYSTEMMOD_H #define SYSTEMMOD_H -int32_t SystemModInitialize(void); +int32_t SystemModStart(void); #endif // SYSTEMMOD_H diff --git a/flight/modules/System/systemmod.c b/flight/modules/System/systemmod.c index a4706235f..e62aa982e 100644 --- a/flight/modules/System/systemmod.c +++ b/flight/modules/System/systemmod.c @@ -1,7 +1,7 @@ /** ****************************************************************************** - * @addtogroup OpenPilotModules OpenPilot Modules - * @brief The OpenPilot Modules do the majority of the control in OpenPilot. The + * @addtogroup LibrePilotModules LibrePilot Modules + * @brief The LibrePilot Modules do the majority of the control in LibrePilot. The * @ref SystemModule "System Module" starts all the other modules that then take care * of all the telemetry and control algorithms and such. This is done through the @ref PIOS * "PIOS Hardware abstraction layer" which then contains hardware specific implementations @@ -16,7 +16,8 @@ * @{ * * @file systemmod.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015. * @brief System module * * @see The GNU Public License (GPL) Version 3 @@ -119,6 +120,7 @@ static void systemTask(void *parameters); static void updateI2Cstats(); static void updateWDGstats(); #endif +extern void PIOS_Board_Init(void); extern uintptr_t pios_uavo_settings_fs_id; extern uintptr_t pios_user_fs_id; @@ -134,8 +136,6 @@ int32_t SystemModStart(void) mallocFailed = false; // Create system task xTaskCreate(systemTask, "System", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY, &systemTaskHandle); - // Register task - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SYSTEM, systemTaskHandle); return 0; } @@ -169,8 +169,6 @@ int32_t SystemModInitialize(void) return -1; } - SystemModStart(); - return 0; } @@ -180,6 +178,12 @@ MODULE_INITCALL(SystemModInitialize, 0); */ static void systemTask(__attribute__((unused)) void *parameters) { + /* board driver init */ + PIOS_Board_Init(); + + /* Initialize all modules */ + MODULE_INITIALISE_ALL; + while (!initTaskDone) { vTaskDelay(10); } @@ -190,6 +194,9 @@ static void systemTask(__attribute__((unused)) void *parameters) /* start the delayed callback scheduler */ PIOS_CALLBACKSCHEDULER_Start(); + // Register task + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SYSTEM, systemTaskHandle); + if (mallocFailed) { /* We failed to malloc during task creation, * system behaviour is undefined. Reset and let @@ -529,6 +536,7 @@ static uint16_t GetFreeIrqStackSize(void) static void updateStats() { SystemStatsData stats; + // Get stats and update SystemStatsGet(&stats); stats.FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; diff --git a/flight/pios/inc/pios_initcall.h b/flight/pios/inc/pios_initcall.h index 55b3e15f9..16f5106cd 100644 --- a/flight/pios/inc/pios_initcall.h +++ b/flight/pios/inc/pios_initcall.h @@ -7,7 +7,8 @@ * @{ * * @file pios_initcall.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015 * @brief Initcall header * @see The GNU Public License (GPL) Version 3 * @@ -55,6 +56,7 @@ extern volatile int initTaskDone; extern void InitModules(); extern void StartModules(); +extern int32_t SystemModInitialize(void); #define MODULE_INITCALL(ifn, sfn) diff --git a/flight/targets/boards/coptercontrol/bootloader/pios_board.c b/flight/targets/boards/coptercontrol/bootloader/pios_board.c index e0a63193a..4fd27d5ee 100644 --- a/flight/targets/boards/coptercontrol/bootloader/pios_board.c +++ b/flight/targets/boards/coptercontrol/bootloader/pios_board.c @@ -56,9 +56,6 @@ void PIOS_Board_Init(void) /* Flash 2 wait state */ FLASH_SetLatency(FLASH_Latency_2); - /* Delay system */ - PIOS_DELAY_Init(); - const struct pios_board_info *bdinfo = &pios_board_info_blob; #if defined(PIOS_INCLUDE_LED) diff --git a/flight/targets/boards/coptercontrol/firmware/coptercontrol.c b/flight/targets/boards/coptercontrol/firmware/coptercontrol.c index e748f6317..5e82464f5 100644 --- a/flight/targets/boards/coptercontrol/firmware/coptercontrol.c +++ b/flight/targets/boards/coptercontrol/firmware/coptercontrol.c @@ -1,17 +1,18 @@ /** ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @brief These files are the core system files of OpenPilot. - * They are the ground layer just above PiOS. In practice, OpenPilot actually starts - * in the main() function of openpilot.c + * @addtogroup LibrePilotSystem LibrePilot System + * @brief These files are the core system files for CopterControl. + * They are the ground layer just above PiOS. In practice, CopterControl actually starts + * in the main() function of coptercontrol.c * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @brief This is where the OP firmware starts. Those files also define the compile-time + * @addtogroup LibrePilotCore LibrePilot Core + * @brief This is where the LP firmware starts. Those files also define the compile-time * options of the firmware. * @{ - * @file openpilot.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Sets up and runs main OpenPilot tasks. + * @file coptercontrol.c + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015 + * @brief Sets up and runs main tasks. * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ @@ -32,18 +33,11 @@ */ #include "inc/openpilot.h" -#include -#include - +#include /* Task Priorities */ -#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) /* Global Variables */ - -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void Stack_Change(void); - /** * OpenPilot Main function: * @@ -61,24 +55,9 @@ int main() /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); - /* Architecture dependant Hardware and - * core subsystem initialisation - * (see pios_board.c for your arch) - * */ - PIOS_Board_Init(); -#ifdef ERASE_FLASH - PIOS_Flash_Jedec_EraseChip(); -#if defined(PIOS_LED_HEARTBEAT) - PIOS_LED_Off(PIOS_LED_HEARTBEAT); -#endif /* PIOS_LED_HEARTBEAT */ - while (1) { - ; - } -#endif + SystemModStart(); - /* Initialize modules */ - MODULE_INITIALISE_ALL /* swap the stack to use the IRQ stack */ Stack_Change(); diff --git a/flight/targets/boards/coptercontrol/firmware/pios_board.c b/flight/targets/boards/coptercontrol/firmware/pios_board.c index 659980639..bda24996b 100644 --- a/flight/targets/boards/coptercontrol/firmware/pios_board.c +++ b/flight/targets/boards/coptercontrol/firmware/pios_board.c @@ -4,10 +4,9 @@ * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 - * - * @addtogroup OpenPilotSystem OpenPilot System + * @addtogroup LibrePilotSystem LibrePilot System * @{ - * @addtogroup OpenPilotCore OpenPilot Core + * @addtogroup LibrePilotCore LibrePilot Core * @{ * @brief Defines board specific static initializers for hardware for the CopterControl board. *****************************************************************************/ @@ -156,8 +155,6 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { int32_t init_test; void PIOS_Board_Init(void) { - /* Delay system */ - PIOS_DELAY_Init(); const struct pios_board_info *bdinfo = &pios_board_info_blob; diff --git a/flight/targets/boards/revolution/firmware/revolution.cpp b/flight/targets/boards/revolution/firmware/revolution.cpp index 268325b26..0fd335f60 100644 --- a/flight/targets/boards/revolution/firmware/revolution.cpp +++ b/flight/targets/boards/revolution/firmware/revolution.cpp @@ -1,17 +1,18 @@ /** ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @brief These files are the core system files of OpenPilot. - * They are the ground layer just above PiOS. In practice, OpenPilot actually starts - * in the main() function of openpilot.c + * @addtogroup LibrePilotSystem LibrePilot System + * @brief These files are the core system files for Revolution. + * They are the ground layer just above PiOS. In practice, Revolution actually starts + * in the main() function of revolution.c * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @brief This is where the OP firmware starts. Those files also define the compile-time + * @addtogroup LibrePilotCore LibrePilot Core + * @brief This is where the LP firmware starts. Those files also define the compile-time * options of the firmware. * @{ - * @file openpilot.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Sets up and runs main OpenPilot tasks. + * @file revolution.cpp + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015 + * @brief Sets up and runs main tasks. * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ @@ -34,46 +35,12 @@ extern "C" { #include "inc/openpilot.h" #include +#include -/* Task Priorities */ -#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) /* Global Variables */ /* Local Variables */ -#define INCLUDE_TEST_TASKS 0 -#if INCLUDE_TEST_TASKS -static uint8_t sdcard_available; -#endif -char Buffer[1024]; -uint32_t Cache; - -/* Function Prototypes */ -#if INCLUDE_TEST_TASKS -static void TaskTick(void *pvParameters); -static void TaskTesting(void *pvParameters); -static void TaskHIDTest(void *pvParameters); -static void TaskServos(void *pvParameters); -static void TaskSDCard(void *pvParameters); -#endif -int32_t CONSOLE_Parse(uint8_t port, char c); -void OP_ADC_NotifyChange(uint32_t pin, uint32_t pin_value); - -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); -extern void Stack_Change(void); -static void Stack_Change_Weak() __attribute__((weakref("Stack_Change"))); - -/* Local Variables */ -#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority -#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive -static xTaskHandle initTaskHandle; - -/* Function Prototypes */ -static void initTask(void *parameters); - -/* Prototype of generated InitModules() function */ -extern void InitModules(void); } /** @@ -87,8 +54,6 @@ extern void InitModules(void); */ int main() { - int result; - /* NOTE: Do NOT modify the following start-up sequence */ /* Any new initialization functions should be added in OpenPilotInit() */ vPortInitialiseBlocks(); @@ -96,12 +61,7 @@ int main() /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); - /* For Revolution we use a FreeRTOS task to bring up the system so we can */ - /* always rely on FreeRTOS primitive */ - result = xTaskCreate(initTask, "init", - INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY, - &initTaskHandle); - PIOS_Assert(result == pdPASS); + SystemModStart(); /* Start the FreeRTOS scheduler */ vTaskStartScheduler(); @@ -117,22 +77,7 @@ int main() return 0; } -/** - * Initialisation task. - * - * Runs board and module initialisation, then terminates. - */ -void initTask(__attribute__((unused)) void *parameters) -{ - /* board driver init */ - PIOS_Board_Init(); - /* Initialize modules */ - MODULE_INITIALISE_ALL; - - /* terminate this task */ - vTaskDelete(NULL); -} /** * @} diff --git a/flight/targets/boards/revonano/firmware/revolution.cpp b/flight/targets/boards/revonano/firmware/revolution.cpp index 70d0b2245..0fd335f60 100644 --- a/flight/targets/boards/revonano/firmware/revolution.cpp +++ b/flight/targets/boards/revonano/firmware/revolution.cpp @@ -1,17 +1,18 @@ /** ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @brief These files are the core system files of OpenPilot. - * They are the ground layer just above PiOS. In practice, OpenPilot actually starts - * in the main() function of openpilot.c + * @addtogroup LibrePilotSystem LibrePilot System + * @brief These files are the core system files for Revolution. + * They are the ground layer just above PiOS. In practice, Revolution actually starts + * in the main() function of revolution.c * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @brief This is where the OP firmware starts. Those files also define the compile-time + * @addtogroup LibrePilotCore LibrePilot Core + * @brief This is where the LP firmware starts. Those files also define the compile-time * options of the firmware. * @{ - * @file openpilot.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Sets up and runs main OpenPilot tasks. + * @file revolution.cpp + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015 + * @brief Sets up and runs main tasks. * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ @@ -34,29 +35,12 @@ extern "C" { #include "inc/openpilot.h" #include +#include -/* Task Priorities */ -#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) /* Global Variables */ /* Local Variables */ - -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); -extern void Stack_Change(void); -static void Stack_Change_Weak() __attribute__((weakref("Stack_Change"))); - -/* Local Variables */ -#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority -#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive -static xTaskHandle initTaskHandle; - -/* Function Prototypes */ -static void initTask(void *parameters); - -/* Prototype of generated InitModules() function */ -extern void InitModules(void); } /** @@ -70,8 +54,6 @@ extern void InitModules(void); */ int main() { - int result; - /* NOTE: Do NOT modify the following start-up sequence */ /* Any new initialization functions should be added in OpenPilotInit() */ vPortInitialiseBlocks(); @@ -79,12 +61,7 @@ int main() /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); - /* For Revolution we use a FreeRTOS task to bring up the system so we can */ - /* always rely on FreeRTOS primitive */ - result = xTaskCreate(initTask, "init", - INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY, - &initTaskHandle); - PIOS_Assert(result == pdPASS); + SystemModStart(); /* Start the FreeRTOS scheduler */ vTaskStartScheduler(); @@ -100,22 +77,7 @@ int main() return 0; } -/** - * Initialisation task. - * - * Runs board and module initialisation, then terminates. - */ -void initTask(__attribute__((unused)) void *parameters) -{ - /* board driver init */ - PIOS_Board_Init(); - /* Initialize modules */ - MODULE_INITIALISE_ALL; - - /* terminate this task */ - vTaskDelete(NULL); -} /** * @} diff --git a/flight/targets/boards/revoproto/firmware/revolution.cpp b/flight/targets/boards/revoproto/firmware/revolution.cpp index 268325b26..0fd335f60 100644 --- a/flight/targets/boards/revoproto/firmware/revolution.cpp +++ b/flight/targets/boards/revoproto/firmware/revolution.cpp @@ -1,17 +1,18 @@ /** ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @brief These files are the core system files of OpenPilot. - * They are the ground layer just above PiOS. In practice, OpenPilot actually starts - * in the main() function of openpilot.c + * @addtogroup LibrePilotSystem LibrePilot System + * @brief These files are the core system files for Revolution. + * They are the ground layer just above PiOS. In practice, Revolution actually starts + * in the main() function of revolution.c * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @brief This is where the OP firmware starts. Those files also define the compile-time + * @addtogroup LibrePilotCore LibrePilot Core + * @brief This is where the LP firmware starts. Those files also define the compile-time * options of the firmware. * @{ - * @file openpilot.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Sets up and runs main OpenPilot tasks. + * @file revolution.cpp + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015 + * @brief Sets up and runs main tasks. * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ @@ -34,46 +35,12 @@ extern "C" { #include "inc/openpilot.h" #include +#include -/* Task Priorities */ -#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) /* Global Variables */ /* Local Variables */ -#define INCLUDE_TEST_TASKS 0 -#if INCLUDE_TEST_TASKS -static uint8_t sdcard_available; -#endif -char Buffer[1024]; -uint32_t Cache; - -/* Function Prototypes */ -#if INCLUDE_TEST_TASKS -static void TaskTick(void *pvParameters); -static void TaskTesting(void *pvParameters); -static void TaskHIDTest(void *pvParameters); -static void TaskServos(void *pvParameters); -static void TaskSDCard(void *pvParameters); -#endif -int32_t CONSOLE_Parse(uint8_t port, char c); -void OP_ADC_NotifyChange(uint32_t pin, uint32_t pin_value); - -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); -extern void Stack_Change(void); -static void Stack_Change_Weak() __attribute__((weakref("Stack_Change"))); - -/* Local Variables */ -#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority -#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive -static xTaskHandle initTaskHandle; - -/* Function Prototypes */ -static void initTask(void *parameters); - -/* Prototype of generated InitModules() function */ -extern void InitModules(void); } /** @@ -87,8 +54,6 @@ extern void InitModules(void); */ int main() { - int result; - /* NOTE: Do NOT modify the following start-up sequence */ /* Any new initialization functions should be added in OpenPilotInit() */ vPortInitialiseBlocks(); @@ -96,12 +61,7 @@ int main() /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); - /* For Revolution we use a FreeRTOS task to bring up the system so we can */ - /* always rely on FreeRTOS primitive */ - result = xTaskCreate(initTask, "init", - INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY, - &initTaskHandle); - PIOS_Assert(result == pdPASS); + SystemModStart(); /* Start the FreeRTOS scheduler */ vTaskStartScheduler(); @@ -117,22 +77,7 @@ int main() return 0; } -/** - * Initialisation task. - * - * Runs board and module initialisation, then terminates. - */ -void initTask(__attribute__((unused)) void *parameters) -{ - /* board driver init */ - PIOS_Board_Init(); - /* Initialize modules */ - MODULE_INITIALISE_ALL; - - /* terminate this task */ - vTaskDelete(NULL); -} /** * @} diff --git a/flight/targets/boards/simposix/firmware/Makefile b/flight/targets/boards/simposix/firmware/Makefile index 7d1f30ff4..646cec458 100644 --- a/flight/targets/boards/simposix/firmware/Makefile +++ b/flight/targets/boards/simposix/firmware/Makefile @@ -2,6 +2,7 @@ # # TODO: This file should be reworked. It will be done as a part of sim target refactoring. # +# Copyright (c) 2015 The LibrePilot Project, http://www.librepilot.org # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. # # diff --git a/flight/targets/boards/simposix/firmware/simposix.cpp b/flight/targets/boards/simposix/firmware/simposix.cpp index 69e53de79..f050ca317 100644 --- a/flight/targets/boards/simposix/firmware/simposix.cpp +++ b/flight/targets/boards/simposix/firmware/simposix.cpp @@ -1,17 +1,18 @@ /** ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @brief These files are the core system files of OpenPilot. - * They are the ground layer just above PiOS. In practice, OpenPilot actually starts - * in the main() function of openpilot.c + * @addtogroup LibrePilotSystem LibrePilot System + * @brief These files are the core system files for Simposix. + * They are the ground layer just above PiOS. In practice, Simposix actually starts + * in the main() function of simposix.c * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @brief This is where the OP firmware starts. Those files also define the compile-time + * @addtogroup LibrePilotCore LibrePilot Core + * @brief This is where the LP firmware starts. Those files also define the compile-time * options of the firmware. * @{ - * @file openpilot.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Sets up and runs main OpenPilot tasks. + * @file simposix.cpp + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015 + * @brief Sets up and runs main tasks. * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ @@ -35,46 +36,7 @@ extern "C" { #include "inc/openpilot.h" #include #include - -/* Task Priorities */ -#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) - -/* Global Variables */ - -/* Local Variables */ -#define INCLUDE_TEST_TASKS 0 -#if INCLUDE_TEST_TASKS -static uint8_t sdcard_available; -#endif -char Buffer[1024]; -uint32_t Cache; - -/* Function Prototypes */ -#if INCLUDE_TEST_TASKS -static void TaskTick(void *pvParameters); -static void TaskTesting(void *pvParameters); -static void TaskHIDTest(void *pvParameters); -static void TaskServos(void *pvParameters); -static void TaskSDCard(void *pvParameters); -#endif -int32_t CONSOLE_Parse(uint8_t port, char c); -void OP_ADC_NotifyChange(uint32_t pin, uint32_t pin_value); - -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); -extern void Stack_Change(void); -static void Stack_Change_Weak() __attribute__((weakref("Stack_Change"))); - -/* Local Variables */ -#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority -#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive -static xTaskHandle initTaskHandle; - -/* Function Prototypes */ -static void initTask(void *parameters); - -/* Prototype of generated InitModules() function */ -extern void InitModules(void); +#include } /** @@ -88,20 +50,10 @@ extern void InitModules(void); */ int main() { - int result; - - /* NOTE: Do NOT modify the following start-up sequence */ - /* Any new initialization functions should be added in OpenPilotInit() */ - /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); - /* For Revolution we use a FreeRTOS task to bring up the system so we can */ - /* always rely on FreeRTOS primitive */ - result = xTaskCreate(initTask, "init", - INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY, - &initTaskHandle); - PIOS_Assert(result == pdPASS); + SystemModStart(); /* Start the FreeRTOS scheduler */ vTaskStartScheduler(); @@ -117,22 +69,6 @@ int main() return 0; } -/** - * Initialisation task. - * - * Runs board and module initialisation, then terminates. - */ -void initTask(__attribute__((unused)) void *parameters) -{ - /* board driver init */ - PIOS_Board_Init(); - - /* Initialize modules */ - MODULE_INITIALISE_ALL; - - /* terminate this task */ - vTaskDelete(NULL); -} /** * @} From 4c2557c29ade55787ad3f8af40c2287bf353f8e8 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Tue, 18 Aug 2015 15:26:22 +0200 Subject: [PATCH 3/6] LP-96 - remove unused files --- .../stm32f10x/link_STM3210E_OP_BL_sections.ld | 356 ------------ .../pios/stm32f10x/link_STM3210E_OP_memory.ld | 12 - .../stm32f10x/link_STM3210E_OP_sections.ld | 383 ------------- flight/pios/stm32f10x/startup_stm32f10x_HD.S | 477 --------------- .../pios/stm32f10x/startup_stm32f10x_HD_OP.S | 541 ------------------ flight/pios/stm32f10x/startup_stm32f10x_MD.S | 355 ------------ 6 files changed, 2124 deletions(-) delete mode 100644 flight/pios/stm32f10x/link_STM3210E_OP_BL_sections.ld delete mode 100644 flight/pios/stm32f10x/link_STM3210E_OP_memory.ld delete mode 100644 flight/pios/stm32f10x/link_STM3210E_OP_sections.ld delete mode 100644 flight/pios/stm32f10x/startup_stm32f10x_HD.S delete mode 100644 flight/pios/stm32f10x/startup_stm32f10x_HD_OP.S delete mode 100644 flight/pios/stm32f10x/startup_stm32f10x_MD.S diff --git a/flight/pios/stm32f10x/link_STM3210E_OP_BL_sections.ld b/flight/pios/stm32f10x/link_STM3210E_OP_BL_sections.ld deleted file mode 100644 index eabe17a83..000000000 --- a/flight/pios/stm32f10x/link_STM3210E_OP_BL_sections.ld +++ /dev/null @@ -1,356 +0,0 @@ -/* This is the size of the stack for early init and for all FreeRTOS IRQs */ -_irq_stack_size = 0x800; - -/* Check valid alignment for VTOR */ -ASSERT(ORIGIN(BL_FLASH) == ALIGN(ORIGIN(BL_FLASH), 0x80), "Start of memory region flash not aligned for startup vector table"); - -/* -this sends all unreferenced IRQHandlers to reset -*/ - - -PROVIDE ( Undefined_Handler = 0 ) ; -PROVIDE ( SWI_Handler = 0 ) ; -PROVIDE ( IRQ_Handler = 0 ) ; -PROVIDE ( Prefetch_Handler = 0 ) ; -PROVIDE ( Abort_Handler = 0 ) ; -PROVIDE ( FIQ_Handler = 0 ) ; - -PROVIDE ( NMI_Handler = 0 ) ; -PROVIDE ( HardFault_Handler = 0 ) ; -PROVIDE ( MemManage_Handler = 0 ) ; -PROVIDE ( BusFault_Handler = 0 ) ; -PROVIDE ( UsageFault_Handler = 0 ) ; -PROVIDE ( vPortSVCHandler = 0 ) ; -PROVIDE ( DebugMon_Handler = 0 ) ; -PROVIDE ( xPortPendSVHandler = 0 ) ; -PROVIDE ( xPortSysTickHandler = 0 ) ; - -PROVIDE ( WWDG_IRQHandler = 0 ) ; -PROVIDE ( PVD_IRQHandler = 0 ) ; -PROVIDE ( TAMPER_IRQHandler = 0 ) ; -PROVIDE ( RTC_IRQHandler = 0 ) ; -PROVIDE ( FLASH_IRQHandler = 0 ) ; -PROVIDE ( RCC_IRQHandler = 0 ) ; -PROVIDE ( EXTI0_IRQHandler = 0 ) ; -PROVIDE ( EXTI1_IRQHandler = 0 ) ; -PROVIDE ( EXTI2_IRQHandler = 0 ) ; -PROVIDE ( EXTI3_IRQHandler = 0 ) ; -PROVIDE ( EXTI4_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel1_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel2_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel3_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel4_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel5_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel6_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel7_IRQHandler = 0 ) ; -PROVIDE ( ADC_IRQHandler = 0 ) ; -PROVIDE ( USB_HP_CAN1_TX_IRQHandler = 0 ) ; -PROVIDE ( USB_LP_CAN1_RX0_IRQHandler = 0 ) ; -PROVIDE ( CAN1_RX1_IRQHandler = 0 ) ; -PROVIDE ( CAN1_SCE_IRQHandler = 0 ) ; -PROVIDE ( EXTI9_5_IRQHandler = 0 ) ; -PROVIDE ( TIM1_BRK_IRQHandler = 0 ) ; -PROVIDE ( TIM1_UP_IRQHandler = 0 ) ; -PROVIDE ( TIM1_TRG_COM_IRQHandler = 0 ) ; -PROVIDE ( TIM1_CC_IRQHandler = 0 ) ; -PROVIDE ( TIM2_IRQHandler = 0 ) ; -PROVIDE ( TIM3_IRQHandler = 0 ) ; -PROVIDE ( TIM4_IRQHandler = 0 ) ; -PROVIDE ( I2C1_EV_IRQHandler = 0 ) ; -PROVIDE ( I2C1_ER_IRQHandler = 0 ) ; -PROVIDE ( I2C2_EV_IRQHandler = 0 ) ; -PROVIDE ( I2C2_ER_IRQHandler = 0 ) ; -PROVIDE ( SPI1_IRQHandler = 0 ) ; -PROVIDE ( SPI2_IRQHandler = 0 ) ; -PROVIDE ( USART1_IRQHandler = 0 ) ; -PROVIDE ( USART2_IRQHandler = 0 ) ; -PROVIDE ( USART3_IRQHandler = 0 ) ; -PROVIDE ( EXTI15_10_IRQHandler = 0 ) ; -PROVIDE ( RTCAlarm_IRQHandler = 0 ) ; -PROVIDE ( USBWakeUp_IRQHandler = 0 ) ; -PROVIDE ( TIM8_BRK_IRQHandler = 0 ) ; -PROVIDE ( TIM8_UP_IRQHandler = 0 ) ; -PROVIDE ( TIM8_TRG_COM_IRQHandler = 0 ) ; -PROVIDE ( TIM8_CC_IRQHandler = 0 ) ; -PROVIDE ( ADC3_IRQHandler = 0 ) ; -PROVIDE ( FSMC_IRQHandler = 0 ) ; -PROVIDE ( SDIO_IRQHandler = 0 ) ; -PROVIDE ( TIM5_IRQHandler = 0 ) ; -PROVIDE ( SPI3_IRQHandler = 0 ) ; -PROVIDE ( UART4_IRQHandler = 0 ) ; -PROVIDE ( UART5_IRQHandler = 0 ) ; -PROVIDE ( TIM6_IRQHandler = 0 ) ; -PROVIDE ( TIM7_IRQHandler = 0 ) ; -PROVIDE ( DMA2_Channel1_IRQHandler = 0 ) ; -PROVIDE ( DMA2_Channel2_IRQHandler = 0 ) ; -PROVIDE ( DMA2_Channel3_IRQHandler = 0 ) ; -PROVIDE ( DMA2_Channel4_5_IRQHandler = 0 ) ; - - - -/******************************************************************************/ -/* Peripheral memory map */ -/******************************************************************************/ -/*this allows to compile the ST lib in "non-debug" mode*/ - - -/* Peripheral and SRAM base address in the alias region */ -PERIPH_BB_BASE = 0x42000000; -SRAM_BB_BASE = 0x22000000; - -/* Peripheral and SRAM base address in the bit-band region */ -SRAM_BASE = 0x20000000; -PERIPH_BASE = 0x40000000; - -/* Flash registers base address */ -PROVIDE ( FLASH_BASE = 0x40022000); -/* Flash Option Bytes base address */ -PROVIDE ( OB_BASE = 0x1FFFF800); - -/* Peripheral memory map */ -APB1PERIPH_BASE = PERIPH_BASE ; -APB2PERIPH_BASE = (PERIPH_BASE + 0x10000) ; -AHBPERIPH_BASE = (PERIPH_BASE + 0x20000) ; - -PROVIDE ( TIM2 = (APB1PERIPH_BASE + 0x0000) ) ; -PROVIDE ( TIM3 = (APB1PERIPH_BASE + 0x0400) ) ; -PROVIDE ( TIM4 = (APB1PERIPH_BASE + 0x0800) ) ; -PROVIDE ( RTC = (APB1PERIPH_BASE + 0x2800) ) ; -PROVIDE ( WWDG = (APB1PERIPH_BASE + 0x2C00) ) ; -PROVIDE ( IWDG = (APB1PERIPH_BASE + 0x3000) ) ; -PROVIDE ( SPI2 = (APB1PERIPH_BASE + 0x3800) ) ; -PROVIDE ( USART2 = (APB1PERIPH_BASE + 0x4400) ) ; -PROVIDE ( USART3 = (APB1PERIPH_BASE + 0x4800) ) ; -PROVIDE ( I2C1 = (APB1PERIPH_BASE + 0x5400) ) ; -PROVIDE ( I2C2 = (APB1PERIPH_BASE + 0x5800) ) ; -PROVIDE ( CAN = (APB1PERIPH_BASE + 0x6400) ) ; -PROVIDE ( BKP = (APB1PERIPH_BASE + 0x6C00) ) ; -PROVIDE ( PWR = (APB1PERIPH_BASE + 0x7000) ) ; - -PROVIDE ( AFIO = (APB2PERIPH_BASE + 0x0000) ) ; -PROVIDE ( EXTI = (APB2PERIPH_BASE + 0x0400) ) ; -PROVIDE ( GPIOA = (APB2PERIPH_BASE + 0x0800) ) ; -PROVIDE ( GPIOB = (APB2PERIPH_BASE + 0x0C00) ) ; -PROVIDE ( GPIOC = (APB2PERIPH_BASE + 0x1000) ) ; -PROVIDE ( GPIOD = (APB2PERIPH_BASE + 0x1400) ) ; -PROVIDE ( GPIOE = (APB2PERIPH_BASE + 0x1800) ) ; -PROVIDE ( ADC1 = (APB2PERIPH_BASE + 0x2400) ) ; -PROVIDE ( ADC2 = (APB2PERIPH_BASE + 0x2800) ) ; -PROVIDE ( TIM1 = (APB2PERIPH_BASE + 0x2C00) ) ; -PROVIDE ( SPI1 = (APB2PERIPH_BASE + 0x3000) ) ; -PROVIDE ( USART1 = (APB2PERIPH_BASE + 0x3800) ) ; - -PROVIDE ( DMA = (AHBPERIPH_BASE + 0x0000) ) ; -PROVIDE ( DMA_Channel1 = (AHBPERIPH_BASE + 0x0008) ) ; -PROVIDE ( DMA_Channel2 = (AHBPERIPH_BASE + 0x001C) ) ; -PROVIDE ( DMA_Channel3 = (AHBPERIPH_BASE + 0x0030) ) ; -PROVIDE ( DMA_Channel4 = (AHBPERIPH_BASE + 0x0044) ) ; -PROVIDE ( DMA_Channel5 = (AHBPERIPH_BASE + 0x0058) ) ; -PROVIDE ( DMA_Channel6 = (AHBPERIPH_BASE + 0x006C) ) ; -PROVIDE ( DMA_Channel7 = (AHBPERIPH_BASE + 0x0080) ) ; -PROVIDE ( RCC = (AHBPERIPH_BASE + 0x1000) ) ; - -/* System Control Space memory map */ -SCS_BASE = 0xE000E000; - -PROVIDE ( SysTick = (SCS_BASE + 0x0010) ) ; -PROVIDE ( NVIC = (SCS_BASE + 0x0100) ) ; -PROVIDE ( SCB = (SCS_BASE + 0x0D00) ) ; - - -/* Sections Definitions */ - -SECTIONS -{ - /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ - .isr_vector : - { - PROVIDE (pios_isr_vector_table_base = .); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } > BL_FLASH - - /* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */ - .flashtext : - { - . = ALIGN(4); - *(.flashtext) /* Startup code */ - . = ALIGN(4); - } > BL_FLASH - - /* the program code is stored in the .text section, which goes to Flash */ - .text : - { - . = ALIGN(4); - - *(.text) /* remaining code */ - *(.text.*) /* remaining code */ - *(.rodata) /* read-only data (constants) */ - *(.rodata*) - *(.glue_7) - *(.glue_7t) - - . = ALIGN(4); - _etext = .; - /* This is used by the startup in order to initialize the .data secion */ - _sidata = _etext; - } > BL_FLASH - - - /* - * This stack is used both as the initial sp during early init as well as ultimately - * being used as the STM32's MSP (Main Stack Pointer) which is the same stack that - * is used for _all_ interrupt handlers. The end of this stack should be placed - * against the lowest address in RAM so that a stack overrun results in a hard fault - * at the first access beyond the end of the stack. - */ - .irq_stack : - { - . = ALIGN(4); - _irq_stack_end = . ; - . = . + _irq_stack_size ; - . = ALIGN(4); - _irq_stack_top = . - 4 ; - _init_stack_top = _irq_stack_top; - . = ALIGN(4); - } >RAM - - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - /* This is used by the startup in order to initialize the .data secion */ - _sdata = . ; - - *(.data) - *(.data.*) - . = ALIGN(4); - /* This is used by the startup in order to initialize the .data secion */ - _edata = . ; - } >RAM - - - - /* This is the uninitialized data section */ - .bss : - { - . = ALIGN(4); - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; - - *(.bss) - *(COMMON) - - . = ALIGN(4); - /* This is used by the startup in order to initialize the .bss secion */ - _ebss = . ; - } >RAM - - PROVIDE ( end = _ebss ); - PROVIDE ( _end = _ebss ); - - /* this is the FLASH Bank1 */ - /* the C or assembly source must explicitly place the code or data there - using the "section" attribute */ - .b1text : - { - *(.b1text) /* remaining code */ - *(.b1rodata) /* read-only data (constants) */ - *(.b1rodata*) - } >FLASHB1 - - /* this is the EXTMEM */ - /* the C or assembly source must explicitly place the code or data there - using the "section" attribute */ - - /* EXTMEM Bank0 */ - .eb0text : - { - *(.eb0text) /* remaining code */ - *(.eb0rodata) /* read-only data (constants) */ - *(.eb0rodata*) - } >EXTMEMB0 - - /* EXTMEM Bank1 */ - .eb1text : - { - *(.eb1text) /* remaining code */ - *(.eb1rodata) /* read-only data (constants) */ - *(.eb1rodata*) - } >EXTMEMB1 - - /* EXTMEM Bank2 */ - .eb2text : - { - *(.eb2text) /* remaining code */ - *(.eb2rodata) /* read-only data (constants) */ - *(.eb2rodata*) - } >EXTMEMB2 - - /* EXTMEM Bank0 */ - .eb3text : - { - *(.eb3text) /* remaining code */ - *(.eb3rodata) /* read-only data (constants) */ - *(.eb3rodata*) - } >EXTMEMB3 - - __exidx_start = .; - __exidx_end = .; - - .boardinfo : - { - . = ALIGN(4); - KEEP(*(.boardinfo)) - . = ALIGN(4); - } > BD_INFO - - /* after that it's only debugging information. */ - - /* remove the debugging information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } -} diff --git a/flight/pios/stm32f10x/link_STM3210E_OP_memory.ld b/flight/pios/stm32f10x/link_STM3210E_OP_memory.ld deleted file mode 100644 index 3aa69dc5e..000000000 --- a/flight/pios/stm32f10x/link_STM3210E_OP_memory.ld +++ /dev/null @@ -1,12 +0,0 @@ -MEMORY -{ - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x10000 - BL_FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x05000 - 0x00080 - BD_INFO (r) : ORIGIN = 0x08005000 - 0x80, LENGTH = 0x00080 - FLASH (rx) : ORIGIN = 0x08005000, LENGTH = 0x80000 - 0x05000 - FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0 - EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0 -} diff --git a/flight/pios/stm32f10x/link_STM3210E_OP_sections.ld b/flight/pios/stm32f10x/link_STM3210E_OP_sections.ld deleted file mode 100644 index a71ed73c8..000000000 --- a/flight/pios/stm32f10x/link_STM3210E_OP_sections.ld +++ /dev/null @@ -1,383 +0,0 @@ -/* This is the size of the stack for early init and for all FreeRTOS IRQs */ -_irq_stack_size = 0x800; -/* This is the size of the stack for early init: life span is until scheduler starts */ -_init_stack_size = 0x800; - -/* Check valid alignment for VTOR */ -ASSERT(ORIGIN(FLASH) == ALIGN(ORIGIN(FLASH), 0x80), "Start of memory region flash not aligned for startup vector table"); - -/* -this sends all unreferenced IRQHandlers to reset -*/ - - -PROVIDE ( Undefined_Handler = 0 ) ; -PROVIDE ( SWI_Handler = 0 ) ; -PROVIDE ( IRQ_Handler = 0 ) ; -PROVIDE ( Prefetch_Handler = 0 ) ; -PROVIDE ( Abort_Handler = 0 ) ; -PROVIDE ( FIQ_Handler = 0 ) ; - -PROVIDE ( NMI_Handler = 0 ) ; -PROVIDE ( HardFault_Handler = 0 ) ; -PROVIDE ( MemManage_Handler = 0 ) ; -PROVIDE ( BusFault_Handler = 0 ) ; -PROVIDE ( UsageFault_Handler = 0 ) ; -PROVIDE ( vPortSVCHandler = 0 ) ; -PROVIDE ( DebugMon_Handler = 0 ) ; -PROVIDE ( xPortPendSVHandler = 0 ) ; -PROVIDE ( xPortSysTickHandler = 0 ) ; - -PROVIDE ( WWDG_IRQHandler = 0 ) ; -PROVIDE ( PVD_IRQHandler = 0 ) ; -PROVIDE ( TAMPER_IRQHandler = 0 ) ; -PROVIDE ( RTC_IRQHandler = 0 ) ; -PROVIDE ( FLASH_IRQHandler = 0 ) ; -PROVIDE ( RCC_IRQHandler = 0 ) ; -PROVIDE ( EXTI0_IRQHandler = 0 ) ; -PROVIDE ( EXTI1_IRQHandler = 0 ) ; -PROVIDE ( EXTI2_IRQHandler = 0 ) ; -PROVIDE ( EXTI3_IRQHandler = 0 ) ; -PROVIDE ( EXTI4_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel1_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel2_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel3_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel4_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel5_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel6_IRQHandler = 0 ) ; -PROVIDE ( DMAChannel7_IRQHandler = 0 ) ; -PROVIDE ( ADC_IRQHandler = 0 ) ; -PROVIDE ( USB_HP_CAN1_TX_IRQHandler = 0 ) ; -PROVIDE ( USB_LP_CAN1_RX0_IRQHandler = 0 ) ; -PROVIDE ( CAN1_RX1_IRQHandler = 0 ) ; -PROVIDE ( CAN1_SCE_IRQHandler = 0 ) ; -PROVIDE ( EXTI9_5_IRQHandler = 0 ) ; -PROVIDE ( TIM1_BRK_IRQHandler = 0 ) ; -PROVIDE ( TIM1_UP_IRQHandler = 0 ) ; -PROVIDE ( TIM1_TRG_COM_IRQHandler = 0 ) ; -PROVIDE ( TIM1_CC_IRQHandler = 0 ) ; -PROVIDE ( TIM2_IRQHandler = 0 ) ; -PROVIDE ( TIM3_IRQHandler = 0 ) ; -PROVIDE ( TIM4_IRQHandler = 0 ) ; -PROVIDE ( I2C1_EV_IRQHandler = 0 ) ; -PROVIDE ( I2C1_ER_IRQHandler = 0 ) ; -PROVIDE ( I2C2_EV_IRQHandler = 0 ) ; -PROVIDE ( I2C2_ER_IRQHandler = 0 ) ; -PROVIDE ( SPI1_IRQHandler = 0 ) ; -PROVIDE ( SPI2_IRQHandler = 0 ) ; -PROVIDE ( USART1_IRQHandler = 0 ) ; -PROVIDE ( USART2_IRQHandler = 0 ) ; -PROVIDE ( USART3_IRQHandler = 0 ) ; -PROVIDE ( EXTI15_10_IRQHandler = 0 ) ; -PROVIDE ( RTCAlarm_IRQHandler = 0 ) ; -PROVIDE ( USBWakeUp_IRQHandler = 0 ) ; -PROVIDE ( TIM8_BRK_IRQHandler = 0 ) ; -PROVIDE ( TIM8_UP_IRQHandler = 0 ) ; -PROVIDE ( TIM8_TRG_COM_IRQHandler = 0 ) ; -PROVIDE ( TIM8_CC_IRQHandler = 0 ) ; -PROVIDE ( ADC3_IRQHandler = 0 ) ; -PROVIDE ( FSMC_IRQHandler = 0 ) ; -PROVIDE ( SDIO_IRQHandler = 0 ) ; -PROVIDE ( TIM5_IRQHandler = 0 ) ; -PROVIDE ( SPI3_IRQHandler = 0 ) ; -PROVIDE ( UART4_IRQHandler = 0 ) ; -PROVIDE ( UART5_IRQHandler = 0 ) ; -PROVIDE ( TIM6_IRQHandler = 0 ) ; -PROVIDE ( TIM7_IRQHandler = 0 ) ; -PROVIDE ( DMA2_Channel1_IRQHandler = 0 ) ; -PROVIDE ( DMA2_Channel2_IRQHandler = 0 ) ; -PROVIDE ( DMA2_Channel3_IRQHandler = 0 ) ; -PROVIDE ( DMA2_Channel4_5_IRQHandler = 0 ) ; - - - -/******************************************************************************/ -/* Peripheral memory map */ -/******************************************************************************/ -/*this allows to compile the ST lib in "non-debug" mode*/ - - -/* Peripheral and SRAM base address in the alias region */ -PERIPH_BB_BASE = 0x42000000; -SRAM_BB_BASE = 0x22000000; - -/* Peripheral and SRAM base address in the bit-band region */ -SRAM_BASE = 0x20000000; -PERIPH_BASE = 0x40000000; - -/* Flash registers base address */ -PROVIDE ( FLASH_BASE = 0x40022000); -/* Flash Option Bytes base address */ -PROVIDE ( OB_BASE = 0x1FFFF800); - -/* Peripheral memory map */ -APB1PERIPH_BASE = PERIPH_BASE ; -APB2PERIPH_BASE = (PERIPH_BASE + 0x10000) ; -AHBPERIPH_BASE = (PERIPH_BASE + 0x20000) ; - -PROVIDE ( TIM2 = (APB1PERIPH_BASE + 0x0000) ) ; -PROVIDE ( TIM3 = (APB1PERIPH_BASE + 0x0400) ) ; -PROVIDE ( TIM4 = (APB1PERIPH_BASE + 0x0800) ) ; -PROVIDE ( RTC = (APB1PERIPH_BASE + 0x2800) ) ; -PROVIDE ( WWDG = (APB1PERIPH_BASE + 0x2C00) ) ; -PROVIDE ( IWDG = (APB1PERIPH_BASE + 0x3000) ) ; -PROVIDE ( SPI2 = (APB1PERIPH_BASE + 0x3800) ) ; -PROVIDE ( USART2 = (APB1PERIPH_BASE + 0x4400) ) ; -PROVIDE ( USART3 = (APB1PERIPH_BASE + 0x4800) ) ; -PROVIDE ( I2C1 = (APB1PERIPH_BASE + 0x5400) ) ; -PROVIDE ( I2C2 = (APB1PERIPH_BASE + 0x5800) ) ; -PROVIDE ( CAN = (APB1PERIPH_BASE + 0x6400) ) ; -PROVIDE ( BKP = (APB1PERIPH_BASE + 0x6C00) ) ; -PROVIDE ( PWR = (APB1PERIPH_BASE + 0x7000) ) ; - -PROVIDE ( AFIO = (APB2PERIPH_BASE + 0x0000) ) ; -PROVIDE ( EXTI = (APB2PERIPH_BASE + 0x0400) ) ; -PROVIDE ( GPIOA = (APB2PERIPH_BASE + 0x0800) ) ; -PROVIDE ( GPIOB = (APB2PERIPH_BASE + 0x0C00) ) ; -PROVIDE ( GPIOC = (APB2PERIPH_BASE + 0x1000) ) ; -PROVIDE ( GPIOD = (APB2PERIPH_BASE + 0x1400) ) ; -PROVIDE ( GPIOE = (APB2PERIPH_BASE + 0x1800) ) ; -PROVIDE ( ADC1 = (APB2PERIPH_BASE + 0x2400) ) ; -PROVIDE ( ADC2 = (APB2PERIPH_BASE + 0x2800) ) ; -PROVIDE ( TIM1 = (APB2PERIPH_BASE + 0x2C00) ) ; -PROVIDE ( SPI1 = (APB2PERIPH_BASE + 0x3000) ) ; -PROVIDE ( USART1 = (APB2PERIPH_BASE + 0x3800) ) ; - -PROVIDE ( DMA = (AHBPERIPH_BASE + 0x0000) ) ; -PROVIDE ( DMA_Channel1 = (AHBPERIPH_BASE + 0x0008) ) ; -PROVIDE ( DMA_Channel2 = (AHBPERIPH_BASE + 0x001C) ) ; -PROVIDE ( DMA_Channel3 = (AHBPERIPH_BASE + 0x0030) ) ; -PROVIDE ( DMA_Channel4 = (AHBPERIPH_BASE + 0x0044) ) ; -PROVIDE ( DMA_Channel5 = (AHBPERIPH_BASE + 0x0058) ) ; -PROVIDE ( DMA_Channel6 = (AHBPERIPH_BASE + 0x006C) ) ; -PROVIDE ( DMA_Channel7 = (AHBPERIPH_BASE + 0x0080) ) ; -PROVIDE ( RCC = (AHBPERIPH_BASE + 0x1000) ) ; - -/* System Control Space memory map */ -SCS_BASE = 0xE000E000; - -PROVIDE ( SysTick = (SCS_BASE + 0x0010) ) ; -PROVIDE ( NVIC = (SCS_BASE + 0x0100) ) ; -PROVIDE ( SCB = (SCS_BASE + 0x0D00) ) ; - -PROVIDE(pios_board_info_blob = ORIGIN(BD_INFO)); - -/* Sections Definitions */ - -SECTIONS -{ - /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ - .isr_vector : - { - PROVIDE (pios_isr_vector_table_base = .); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */ - .flashtext : - { - . = ALIGN(4); - *(.flashtext) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* module sections */ - .initcallmodule.init : - { - . = ALIGN(4); - __module_initcall_start = .; - KEEP(*(.initcallmodule.init)) - . = ALIGN(4); - __module_initcall_end = .; - } >FLASH - - /* the program code is stored in the .text section, which goes to Flash */ - .text : - { - . = ALIGN(4); - - *(.text) /* remaining code */ - *(.text.*) /* remaining code */ - *(.rodata) /* read-only data (constants) */ - *(.rodata*) - *(.glue_7) - *(.glue_7t) - - . = ALIGN(4); - _etext = .; - /* This is used by the startup in order to initialize the .data secion */ - _sidata = _etext; - } >FLASH - - /* - * This stack is used both as the initial sp during early init as well as ultimately - * being used as the STM32's MSP (Main Stack Pointer) which is the same stack that - * is used for _all_ interrupt handlers. The end of this stack should be placed - * against the lowest address in RAM so that a stack overrun results in a hard fault - * at the first access beyond the end of the stack. - */ - .irq_stack : - { - . = ALIGN(4); - _irq_stack_end = . ; - . = . + _irq_stack_size ; - . = ALIGN(4); - _irq_stack_top = . - 4 ; - . = ALIGN(4); - } >RAM - - - /* This is the initialized data section - The program executes knowing that the data is in the RAM - but the loader puts the initial values in the FLASH (inidata). - It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - /* This is used by the startup in order to initialize the .data secion */ - _sdata = . ; - - *(.data) - *(.data.*) - . = ALIGN(4); - /* This is used by the startup in order to initialize the .data secion */ - _edata = . ; - } >RAM - - - - /* This is the uninitialized data section */ - .bss : - { - . = ALIGN(4); - /* This is used by the startup in order to initialize the .bss section */ - _sbss = .; - - *(.bss) - *(COMMON) - } >RAM - - .heap (NOLOAD) : - { - . = ALIGN(4); - _sheap = . ; - _sheap_pre_rtos = . ; - *(.heap) - . = ALIGN(4); - _eheap = . ; - _eheap_pre_rtos = . ; - _init_stack_end = . ; - _sheap_post_rtos = . ; - . = . + _init_stack_size ; - . = ALIGN(4); - _eheap_post_rtos = . ; - _init_stack_top = . - 4 ; - } > RAM - - _eram = ORIGIN(RAM) + LENGTH(RAM) ; - _ebss = _eram ; - - /* keep the heap section at the end of the SRAM - * this will allow to claim the remaining bytes not used - * at run time! (done by the reset vector). - */ - - PROVIDE ( end = _ebss ); - PROVIDE ( _end = _ebss ); - - /* this is the FLASH Bank1 */ - /* the C or assembly source must explicitly place the code or data there - using the "section" attribute */ - .b1text : - { - *(.b1text) /* remaining code */ - *(.b1rodata) /* read-only data (constants) */ - *(.b1rodata*) - } >FLASHB1 - - /* this is the EXTMEM */ - /* the C or assembly source must explicitly place the code or data there - using the "section" attribute */ - - /* EXTMEM Bank0 */ - .eb0text : - { - *(.eb0text) /* remaining code */ - *(.eb0rodata) /* read-only data (constants) */ - *(.eb0rodata*) - } >EXTMEMB0 - - /* EXTMEM Bank1 */ - .eb1text : - { - *(.eb1text) /* remaining code */ - *(.eb1rodata) /* read-only data (constants) */ - *(.eb1rodata*) - } >EXTMEMB1 - - /* EXTMEM Bank2 */ - .eb2text : - { - *(.eb2text) /* remaining code */ - *(.eb2rodata) /* read-only data (constants) */ - *(.eb2rodata*) - } >EXTMEMB2 - - /* EXTMEM Bank0 */ - .eb3text : - { - *(.eb3text) /* remaining code */ - *(.eb3rodata) /* read-only data (constants) */ - *(.eb3rodata*) - } >EXTMEMB3 - - __exidx_start = .; - __exidx_end = .; - - /* after that it's only debugging information. */ - - /* remove the debugging information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } -} - - diff --git a/flight/pios/stm32f10x/startup_stm32f10x_HD.S b/flight/pios/stm32f10x/startup_stm32f10x_HD.S deleted file mode 100644 index afb4b5b0b..000000000 --- a/flight/pios/stm32f10x/startup_stm32f10x_HD.S +++ /dev/null @@ -1,477 +0,0 @@ -/** - ****************************************************************************** - * @file startup_stm32f10x_hd.s - * @author MCD Application Team / David Ankers: Vector table for FreeRTOS - * @version V3.1.2 - * @date 09/28/2009 - * @brief STM32F10x High Density Devices vector table for RIDE7 toolchain. - * This module performs: - * - Set the initial SP - * - Set the initial PC == Reset_Handler, - * - Set the vector table entries with the exceptions ISR address, - * - Configure external SRAM mounted on STM3210E-EVAL board - * to be used as data memory (optional, to be enabled by user) - * - Branches to main in the C library (which eventually - * calls main()). - * After Reset the Cortex-M3 processor is in Thread mode, - * priority is Privileged, and the Stack is set to Main. - ****************************************************************************** - * @copy - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- */ - - .syntax unified - .cpu cortex-m3 - .fpu softvfp - .thumb - -.global g_pfnVectors -.global SystemInit_ExtMemCtl_Dummy -.global Default_Handler - -/* start address for the initialization values of the .data section. -defined in linker script */ -.word _sidata -/* start address for the .data section. defined in linker script */ -.word _sdata -/* end address for the .data section. defined in linker script */ -.word _edata -/* start address for the .bss section. defined in linker script */ -.word _sbss -/* end address for the .bss section. defined in linker script */ -.word _ebss -/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ - -.equ Initial_spTop, 0x20000400 -.equ BootRAM, 0xF1E0F85F -/** - * @brief This is the code that gets called when the processor first - * starts execution following a reset event. Only the absolutely - * necessary set is performed, after which the application - * supplied main() routine is called. - * @param None - * @retval : None -*/ - - .section .text.Reset_Handler - .weak Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - -/* Copy the data segment initializers from flash to SRAM */ - movs r1, #0 - b LoopCopyDataInit - -CopyDataInit: - ldr r3, =_sidata - ldr r3, [r3, r1] - str r3, [r0, r1] - adds r1, r1, #4 - -LoopCopyDataInit: - ldr r0, =_sdata - ldr r3, =_edata - adds r2, r0, r1 - cmp r2, r3 - bcc CopyDataInit - ldr r2, =_sbss - b LoopFillZerobss -/* Zero fill the bss segment. */ -FillZerobss: - movs r3, #0 - str r3, [r2], #4 - -LoopFillZerobss: - ldr r3, = _ebss - cmp r2, r3 - bcc FillZerobss -/* Call the application's entry point.*/ - bl main - bx lr -.size Reset_Handler, .-Reset_Handler - -/** - * @brief Dummy SystemInit_ExtMemCtl function - * @param None - * @retval : None -*/ - .section .text.SystemInit_ExtMemCtl_Dummy,"ax",%progbits -SystemInit_ExtMemCtl_Dummy: - bx lr - .size SystemInit_ExtMemCtl_Dummy, .-SystemInit_ExtMemCtl_Dummy - -/** - * @brief This is the code that gets called when the processor receives an - * unexpected interrupt. This simply enters an infinite loop, preserving - * the system state for examination by a debugger. - * - * @param None - * @retval : None -*/ - .section .text.Default_Handler,"ax",%progbits -Default_Handler: -Infinite_Loop: - b Infinite_Loop - .size Default_Handler, .-Default_Handler -/****************************************************************************** -* -* The minimal vector table for a Cortex M3. Note that the proper constructs -* must be placed on this to ensure that it ends up at physical address -* 0x0000.0000. -* -******************************************************************************/ - .section .isr_vector,"a",%progbits - .type g_pfnVectors, %object - .size g_pfnVectors, .-g_pfnVectors - - -g_pfnVectors: - .word _estack - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemManage_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 - .word 0 - .word 0 - .word 0 - .word SVC_Handler - .word DebugMon_Handler - .word 0 - .word PendSV_Handler - .word SysTick_Handler - .word WWDG_IRQHandler - .word PVD_IRQHandler - .word TAMPER_IRQHandler - .word RTC_IRQHandler - .word FLASH_IRQHandler - .word RCC_IRQHandler - .word EXTI0_IRQHandler - .word EXTI1_IRQHandler - .word EXTI2_IRQHandler - .word EXTI3_IRQHandler - .word EXTI4_IRQHandler - .word DMA1_Channel1_IRQHandler - .word DMA1_Channel2_IRQHandler - .word DMA1_Channel3_IRQHandler - .word DMA1_Channel4_IRQHandler - .word DMA1_Channel5_IRQHandler - .word DMA1_Channel6_IRQHandler - .word DMA1_Channel7_IRQHandler - .word ADC1_2_IRQHandler - .word USB_HP_CAN1_TX_IRQHandler - .word USB_LP_CAN1_RX0_IRQHandler - .word CAN1_RX1_IRQHandler - .word CAN1_SCE_IRQHandler - .word EXTI9_5_IRQHandler - .word TIM1_BRK_IRQHandler - .word TIM1_UP_IRQHandler - .word TIM1_TRG_COM_IRQHandler - .word TIM1_CC_IRQHandler - .word TIM2_IRQHandler - .word TIM3_IRQHandler - .word TIM4_IRQHandler - .word I2C1_EV_IRQHandler - .word I2C1_ER_IRQHandler - .word I2C2_EV_IRQHandler - .word I2C2_ER_IRQHandler - .word SPI1_IRQHandler - .word SPI2_IRQHandler - .word USART1_IRQHandler - .word USART2_IRQHandler - .word USART3_IRQHandler - .word EXTI15_10_IRQHandler - .word RTCAlarm_IRQHandler - .word USBWakeUp_IRQHandler - .word TIM8_BRK_IRQHandler - .word TIM8_UP_IRQHandler - .word TIM8_TRG_COM_IRQHandler - .word TIM8_CC_IRQHandler - .word ADC3_IRQHandler - .word FSMC_IRQHandler - .word SDIO_IRQHandler - .word TIM5_IRQHandler - .word SPI3_IRQHandler - .word UART4_IRQHandler - .word UART5_IRQHandler - .word TIM6_IRQHandler - .word TIM7_IRQHandler - .word DMA2_Channel1_IRQHandler - .word DMA2_Channel2_IRQHandler - .word DMA2_Channel3_IRQHandler - .word DMA2_Channel4_5_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word BootRAM /* @0x1E0. This is for boot in RAM mode for - STM32F10x High Density devices. */ - -/******************************************************************************* -* -* Provide weak aliases for each Exception handler to the Default_Handler. -* As they are weak aliases, any function with the same name will override -* this definition. -* -*******************************************************************************/ - - .weak NMI_Handler - .thumb_set NMI_Handler,Default_Handler - - .weak HardFault_Handler - .thumb_set HardFault_Handler,Default_Handler - - .weak MemManage_Handler - .thumb_set MemManage_Handler,Default_Handler - - .weak BusFault_Handler - .thumb_set BusFault_Handler,Default_Handler - - .weak UsageFault_Handler - .thumb_set UsageFault_Handler,Default_Handler - - .weak SVC_Handler - .thumb_set SVC_Handler,Default_Handler - - .weak DebugMon_Handler - .thumb_set DebugMon_Handler,Default_Handler - - .weak PendSV_Handler - .thumb_set PendSV_Handler,Default_Handler - - .weak SysTick_Handler - .thumb_set SysTick_Handler,Default_Handler - - .weak WWDG_IRQHandler - .thumb_set WWDG_IRQHandler,Default_Handler - - .weak PVD_IRQHandler - .thumb_set PVD_IRQHandler,Default_Handler - - .weak TAMPER_IRQHandler - .thumb_set TAMPER_IRQHandler,Default_Handler - - .weak RTC_IRQHandler - .thumb_set RTC_IRQHandler,Default_Handler - - .weak FLASH_IRQHandler - .thumb_set FLASH_IRQHandler,Default_Handler - - .weak RCC_IRQHandler - .thumb_set RCC_IRQHandler,Default_Handler - - .weak EXTI0_IRQHandler - .thumb_set EXTI0_IRQHandler,Default_Handler - - .weak EXTI1_IRQHandler - .thumb_set EXTI1_IRQHandler,Default_Handler - - .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler - - .weak EXTI3_IRQHandler - .thumb_set EXTI3_IRQHandler,Default_Handler - - .weak EXTI4_IRQHandler - .thumb_set EXTI4_IRQHandler,Default_Handler - - .weak DMA1_Channel1_IRQHandler - .thumb_set DMA1_Channel1_IRQHandler,Default_Handler - - .weak DMA1_Channel2_IRQHandler - .thumb_set DMA1_Channel2_IRQHandler,Default_Handler - - .weak DMA1_Channel3_IRQHandler - .thumb_set DMA1_Channel3_IRQHandler,Default_Handler - - .weak DMA1_Channel4_IRQHandler - .thumb_set DMA1_Channel4_IRQHandler,Default_Handler - - .weak DMA1_Channel5_IRQHandler - .thumb_set DMA1_Channel5_IRQHandler,Default_Handler - - .weak DMA1_Channel6_IRQHandler - .thumb_set DMA1_Channel6_IRQHandler,Default_Handler - - .weak DMA1_Channel7_IRQHandler - .thumb_set DMA1_Channel7_IRQHandler,Default_Handler - - .weak ADC1_2_IRQHandler - .thumb_set ADC1_2_IRQHandler,Default_Handler - - .weak USB_HP_CAN1_TX_IRQHandler - .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler - - .weak USB_LP_CAN1_RX0_IRQHandler - .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler - - .weak CAN1_RX1_IRQHandler - .thumb_set CAN1_RX1_IRQHandler,Default_Handler - - .weak CAN1_SCE_IRQHandler - .thumb_set CAN1_SCE_IRQHandler,Default_Handler - - .weak EXTI9_5_IRQHandler - .thumb_set EXTI9_5_IRQHandler,Default_Handler - - .weak TIM1_BRK_IRQHandler - .thumb_set TIM1_BRK_IRQHandler,Default_Handler - - .weak TIM1_UP_IRQHandler - .thumb_set TIM1_UP_IRQHandler,Default_Handler - - .weak TIM1_TRG_COM_IRQHandler - .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler - - .weak TIM1_CC_IRQHandler - .thumb_set TIM1_CC_IRQHandler,Default_Handler - - .weak TIM2_IRQHandler - .thumb_set TIM2_IRQHandler,Default_Handler - - .weak TIM3_IRQHandler - .thumb_set TIM3_IRQHandler,Default_Handler - - .weak TIM4_IRQHandler - .thumb_set TIM4_IRQHandler,Default_Handler - - .weak I2C1_EV_IRQHandler - .thumb_set I2C1_EV_IRQHandler,Default_Handler - - .weak I2C1_ER_IRQHandler - .thumb_set I2C1_ER_IRQHandler,Default_Handler - - .weak I2C2_EV_IRQHandler - .thumb_set I2C2_EV_IRQHandler,Default_Handler - - .weak I2C2_ER_IRQHandler - .thumb_set I2C2_ER_IRQHandler,Default_Handler - - .weak SPI1_IRQHandler - .thumb_set SPI1_IRQHandler,Default_Handler - - .weak SPI2_IRQHandler - .thumb_set SPI2_IRQHandler,Default_Handler - - .weak USART1_IRQHandler - .thumb_set USART1_IRQHandler,Default_Handler - - .weak USART2_IRQHandler - .thumb_set USART2_IRQHandler,Default_Handler - - .weak USART3_IRQHandler - .thumb_set USART3_IRQHandler,Default_Handler - - .weak EXTI15_10_IRQHandler - .thumb_set EXTI15_10_IRQHandler,Default_Handler - - .weak RTCAlarm_IRQHandler - .thumb_set RTCAlarm_IRQHandler,Default_Handler - - .weak USBWakeUp_IRQHandler - .thumb_set USBWakeUp_IRQHandler,Default_Handler - - .weak TIM8_BRK_IRQHandler - .thumb_set TIM8_BRK_IRQHandler,Default_Handler - - .weak TIM8_UP_IRQHandler - .thumb_set TIM8_UP_IRQHandler,Default_Handler - - .weak TIM8_TRG_COM_IRQHandler - .thumb_set TIM8_TRG_COM_IRQHandler,Default_Handler - - .weak TIM8_CC_IRQHandler - .thumb_set TIM8_CC_IRQHandler,Default_Handler - - .weak ADC3_IRQHandler - .thumb_set ADC3_IRQHandler,Default_Handler - - .weak FSMC_IRQHandler - .thumb_set FSMC_IRQHandler,Default_Handler - - .weak SDIO_IRQHandler - .thumb_set SDIO_IRQHandler,Default_Handler - - .weak TIM5_IRQHandler - .thumb_set TIM5_IRQHandler,Default_Handler - - .weak SPI3_IRQHandler - .thumb_set SPI3_IRQHandler,Default_Handler - - .weak UART4_IRQHandler - .thumb_set UART4_IRQHandler,Default_Handler - - .weak UART5_IRQHandler - .thumb_set UART5_IRQHandler,Default_Handler - - .weak TIM6_IRQHandler - .thumb_set TIM6_IRQHandler,Default_Handler - - .weak TIM7_IRQHandler - .thumb_set TIM7_IRQHandler,Default_Handler - - .weak DMA2_Channel1_IRQHandler - .thumb_set DMA2_Channel1_IRQHandler,Default_Handler - - .weak DMA2_Channel2_IRQHandler - .thumb_set DMA2_Channel2_IRQHandler,Default_Handler - - .weak DMA2_Channel3_IRQHandler - .thumb_set DMA2_Channel3_IRQHandler,Default_Handler - - .weak DMA2_Channel4_5_IRQHandler - .thumb_set DMA2_Channel4_5_IRQHandler,Default_Handler - - .weak SystemInit_ExtMemCtl - .thumb_set SystemInit_ExtMemCtl,SystemInit_ExtMemCtl_Dummy - diff --git a/flight/pios/stm32f10x/startup_stm32f10x_HD_OP.S b/flight/pios/stm32f10x/startup_stm32f10x_HD_OP.S deleted file mode 100644 index a0826115e..000000000 --- a/flight/pios/stm32f10x/startup_stm32f10x_HD_OP.S +++ /dev/null @@ -1,541 +0,0 @@ -/** - ****************************************************************************** - * @file startup_stm32f10x_hd.s - * @author MCD Application Team / David Ankers: Vector table for FreeRTOS - * @version V3.1.2 - * @date 09/28/2009 - * @brief STM32F10x High Density Devices vector table for RIDE7 toolchain. - * This module performs: - * - Set the initial SP - * - Set the initial PC == Reset_Handler, - * - Set the vector table entries with the exceptions ISR address, - * - Configure external SRAM mounted on STM3210E-EVAL board - * to be used as data memory (optional, to be enabled by user) - * - Branches to main in the C library (which eventually - * calls main()). - * After Reset the Cortex-M3 processor is in Thread mode, - * priority is Privileged, and the Stack is set to Main. - ****************************************************************************** - * @copy - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- */ - - .syntax unified - .cpu cortex-m3 - .fpu softvfp - .thumb - -.global g_pfnVectors -.global SystemInit_ExtMemCtl_Dummy -.global Default_Handler -.global xPortIncreaseHeapSize -.global Stack_Change - -/* start address for the initialization values of the .data section. -defined in linker script */ -.word _sidata -/* start address for the .data section. defined in linker script */ -.word _sdata -/* end address for the .data section. defined in linker script */ -.word _edata -/* start address for the .bss section. defined in linker script */ -.word _sbss -/* end address for the .bss section. defined in linker script */ -.word _ebss -/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ - -.equ BootRAM, 0xF1E0F85F -/** - * @brief This is the code that gets called when the processor first - * starts execution following a reset event. Only the absolutely - * necessary set is performed, after which the application - * supplied main() routine is called. - * @param None - * @retval : None -*/ - - .section .text.Reset_Handler - .weak Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - -/* FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is - required, then adjust the Register Addresses */ - bl SystemInit_ExtMemCtl -/* restore original stack pointer */ - LDR r0, =_irq_stack_top - MSR msp, r0 - LDR r2, =_init_stack_top - MSR psp, r2 - /* check if irq and init stack are the same */ - /* if they are, we don't do stack swap */ - /* and lets bypass the monitoring as well for now */ - cmp r0, r2 - beq SectionBssInit -/* DO - * - stay in thread process mode - * - stay in privilege level - * - use process stack - */ - movs r0, #2 - MSR control, r0 - ISB -/* Fill IRQ stack for watermark monitoring */ - ldr r2, =_irq_stack_end - b LoopFillIRQStack - -FillIRQStack: - movw r3, #0xA5A5 - str r3, [r2], #4 - -LoopFillIRQStack: - ldr r3, = _irq_stack_top - cmp r2, r3 - bcc FillIRQStack - -SectionBssInit: -/* Copy the data segment initializers from flash to SRAM */ - movs r1, #0 - b LoopCopyDataInit - -CopyDataInit: - ldr r3, =_sidata - ldr r3, [r3, r1] - str r3, [r0, r1] - adds r1, r1, #4 - -LoopCopyDataInit: - ldr r0, =_sdata - ldr r3, =_edata - adds r2, r0, r1 - cmp r2, r3 - bcc CopyDataInit - ldr r2, =_sbss - b LoopFillZerobss -/* Zero fill the bss segment. */ -FillZerobss: - movs r3, #0 - str r3, [r2], #4 - -LoopFillZerobss: - ldr r3, = _ebss - cmp r2, r3 - bcc FillZerobss -/* Call the application's entry point.*/ - bl main -/* will never return here */ - bx lr -.size Reset_Handler, .-Reset_Handler - -/** - * @brief This is the code that swaps stack (from end of heap to irq_stack). - * Also reclaim the heap that was used as a stack. - * @param None - * @retval : None -*/ - .section .text.Stack_Change - .weak Stack_Change - .type Stack_Change, %function -Stack_Change: - mov r4, lr -/* Switches stack back momentarily to MSP */ - movs r0, #0 - msr control, r0 -Heap_Reclaim: -/* add heap_post_rtos to the heap (if the capability/function exist) */ -/* Also claim the unused memory (between end of heap to end of memory */ -/* CAREFULL: the heap section must be the last section in RAM in order this to work */ - ldr r0, = _init_stack_size - ldr r1, = _eheap_post_rtos - ldr r2, = _eram - subs r2, r2, r1 - adds r0, r0, r2 - bl xPortIncreaseHeapSize - bx r4 - .size Stack_Change, .-Stack_Change - -/** - * @brief Dummy SystemInit_ExtMemCtl function - * @param None - * @retval : None -*/ - .section .text.SystemInit_ExtMemCtl_Dummy,"ax",%progbits -SystemInit_ExtMemCtl_Dummy: - bx lr - .size SystemInit_ExtMemCtl_Dummy, .-SystemInit_ExtMemCtl_Dummy - -/** - * @brief This is the code that gets called when the processor receives an - * unexpected interrupt. This simply enters an infinite loop, preserving - * the system state for examination by a debugger. - * - * @param None - * @retval : None -*/ - .section .text.Default_Handler,"ax",%progbits -Default_Handler: -Infinite_Loop: - b Infinite_Loop - .size Default_Handler, .-Default_Handler -/****************************************************************************** -* -* The minimal vector table for a Cortex M3. Note that the proper constructs -* must be placed on this to ensure that it ends up at physical address -* 0x0000.0000. -* -******************************************************************************/ - .section .isr_vector,"a",%progbits - .type g_pfnVectors, %object - .size g_pfnVectors, .-g_pfnVectors - - -g_pfnVectors: - .word _irq_stack_top - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemManage_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 - .word 0 - .word 0 - .word 0 - .word vPortSVCHandler - .word DebugMon_Handler - .word 0 - .word xPortPendSVHandler - .word xPortSysTickHandler - .word WWDG_IRQHandler - .word PVD_IRQHandler - .word TAMPER_IRQHandler - .word RTC_IRQHandler - .word FLASH_IRQHandler - .word RCC_IRQHandler - .word EXTI0_IRQHandler - .word EXTI1_IRQHandler - .word EXTI2_IRQHandler - .word EXTI3_IRQHandler - .word EXTI4_IRQHandler - .word DMA1_Channel1_IRQHandler - .word DMA1_Channel2_IRQHandler - .word DMA1_Channel3_IRQHandler - .word DMA1_Channel4_IRQHandler - .word DMA1_Channel5_IRQHandler - .word DMA1_Channel6_IRQHandler - .word DMA1_Channel7_IRQHandler - .word ADC1_2_IRQHandler - .word USB_HP_CAN1_TX_IRQHandler - .word USB_LP_CAN1_RX0_IRQHandler - .word CAN1_RX1_IRQHandler - .word CAN1_SCE_IRQHandler - .word EXTI9_5_IRQHandler - .word TIM1_BRK_IRQHandler - .word TIM1_UP_IRQHandler - .word TIM1_TRG_COM_IRQHandler - .word TIM1_CC_IRQHandler - .word TIM2_IRQHandler - .word TIM3_IRQHandler - .word TIM4_IRQHandler - .word I2C1_EV_IRQHandler - .word I2C1_ER_IRQHandler - .word I2C2_EV_IRQHandler - .word I2C2_ER_IRQHandler - .word SPI1_IRQHandler - .word SPI2_IRQHandler - .word USART1_IRQHandler - .word USART2_IRQHandler - .word USART3_IRQHandler - .word EXTI15_10_IRQHandler - .word RTCAlarm_IRQHandler - .word USBWakeUp_IRQHandler - .word TIM8_BRK_IRQHandler - .word TIM8_UP_IRQHandler - .word TIM8_TRG_COM_IRQHandler - .word TIM8_CC_IRQHandler - .word ADC3_IRQHandler - .word FSMC_IRQHandler - .word SDIO_IRQHandler - .word TIM5_IRQHandler - .word SPI3_IRQHandler - .word UART4_IRQHandler - .word UART5_IRQHandler - .word TIM6_IRQHandler - .word TIM7_IRQHandler - .word DMA2_Channel1_IRQHandler - .word DMA2_Channel2_IRQHandler - .word DMA2_Channel3_IRQHandler - .word DMA2_Channel4_5_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word BootRAM /* @0x1E0. This is for boot in RAM mode for - STM32F10x High Density devices. */ - -/******************************************************************************* -* -* Provide weak aliases for each Exception handler to the Default_Handler. -* As they are weak aliases, any function with the same name will override -* this definition. -* -*******************************************************************************/ - - .weak NMI_Handler - .thumb_set NMI_Handler,Default_Handler - - .weak HardFault_Handler - .thumb_set HardFault_Handler,Default_Handler - - .weak MemManage_Handler - .thumb_set MemManage_Handler,Default_Handler - - .weak BusFault_Handler - .thumb_set BusFault_Handler,Default_Handler - - .weak UsageFault_Handler - .thumb_set UsageFault_Handler,Default_Handler - - .weak SVC_Handler - .thumb_set SVC_Handler,Default_Handler - - .weak DebugMon_Handler - .thumb_set DebugMon_Handler,Default_Handler - - .weak PendSV_Handler - .thumb_set PendSV_Handler,Default_Handler - - .weak SysTick_Handler - .thumb_set SysTick_Handler,Default_Handler - - .weak WWDG_IRQHandler - .thumb_set WWDG_IRQHandler,Default_Handler - - .weak PVD_IRQHandler - .thumb_set PVD_IRQHandler,Default_Handler - - .weak TAMPER_IRQHandler - .thumb_set TAMPER_IRQHandler,Default_Handler - - .weak RTC_IRQHandler - .thumb_set RTC_IRQHandler,Default_Handler - - .weak FLASH_IRQHandler - .thumb_set FLASH_IRQHandler,Default_Handler - - .weak RCC_IRQHandler - .thumb_set RCC_IRQHandler,Default_Handler - - .weak EXTI0_IRQHandler - .thumb_set EXTI0_IRQHandler,Default_Handler - - .weak EXTI1_IRQHandler - .thumb_set EXTI1_IRQHandler,Default_Handler - - .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler - - .weak EXTI3_IRQHandler - .thumb_set EXTI3_IRQHandler,Default_Handler - - .weak EXTI4_IRQHandler - .thumb_set EXTI4_IRQHandler,Default_Handler - - .weak DMA1_Channel1_IRQHandler - .thumb_set DMA1_Channel1_IRQHandler,Default_Handler - - .weak DMA1_Channel2_IRQHandler - .thumb_set DMA1_Channel2_IRQHandler,Default_Handler - - .weak DMA1_Channel3_IRQHandler - .thumb_set DMA1_Channel3_IRQHandler,Default_Handler - - .weak DMA1_Channel4_IRQHandler - .thumb_set DMA1_Channel4_IRQHandler,Default_Handler - - .weak DMA1_Channel5_IRQHandler - .thumb_set DMA1_Channel5_IRQHandler,Default_Handler - - .weak DMA1_Channel6_IRQHandler - .thumb_set DMA1_Channel6_IRQHandler,Default_Handler - - .weak DMA1_Channel7_IRQHandler - .thumb_set DMA1_Channel7_IRQHandler,Default_Handler - - .weak ADC1_2_IRQHandler - .thumb_set ADC1_2_IRQHandler,Default_Handler - - .weak USB_HP_CAN1_TX_IRQHandler - .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler - - .weak USB_LP_CAN1_RX0_IRQHandler - .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler - - .weak CAN1_RX1_IRQHandler - .thumb_set CAN1_RX1_IRQHandler,Default_Handler - - .weak CAN1_SCE_IRQHandler - .thumb_set CAN1_SCE_IRQHandler,Default_Handler - - .weak EXTI9_5_IRQHandler - .thumb_set EXTI9_5_IRQHandler,Default_Handler - - .weak TIM1_BRK_IRQHandler - .thumb_set TIM1_BRK_IRQHandler,Default_Handler - - .weak TIM1_UP_IRQHandler - .thumb_set TIM1_UP_IRQHandler,Default_Handler - - .weak TIM1_TRG_COM_IRQHandler - .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler - - .weak TIM1_CC_IRQHandler - .thumb_set TIM1_CC_IRQHandler,Default_Handler - - .weak TIM2_IRQHandler - .thumb_set TIM2_IRQHandler,Default_Handler - - .weak TIM3_IRQHandler - .thumb_set TIM3_IRQHandler,Default_Handler - - .weak TIM4_IRQHandler - .thumb_set TIM4_IRQHandler,Default_Handler - - .weak I2C1_EV_IRQHandler - .thumb_set I2C1_EV_IRQHandler,Default_Handler - - .weak I2C1_ER_IRQHandler - .thumb_set I2C1_ER_IRQHandler,Default_Handler - - .weak I2C2_EV_IRQHandler - .thumb_set I2C2_EV_IRQHandler,Default_Handler - - .weak I2C2_ER_IRQHandler - .thumb_set I2C2_ER_IRQHandler,Default_Handler - - .weak SPI1_IRQHandler - .thumb_set SPI1_IRQHandler,Default_Handler - - .weak SPI2_IRQHandler - .thumb_set SPI2_IRQHandler,Default_Handler - - .weak USART1_IRQHandler - .thumb_set USART1_IRQHandler,Default_Handler - - .weak USART2_IRQHandler - .thumb_set USART2_IRQHandler,Default_Handler - - .weak USART3_IRQHandler - .thumb_set USART3_IRQHandler,Default_Handler - - .weak EXTI15_10_IRQHandler - .thumb_set EXTI15_10_IRQHandler,Default_Handler - - .weak RTCAlarm_IRQHandler - .thumb_set RTCAlarm_IRQHandler,Default_Handler - - .weak USBWakeUp_IRQHandler - .thumb_set USBWakeUp_IRQHandler,Default_Handler - - .weak TIM8_BRK_IRQHandler - .thumb_set TIM8_BRK_IRQHandler,Default_Handler - - .weak TIM8_UP_IRQHandler - .thumb_set TIM8_UP_IRQHandler,Default_Handler - - .weak TIM8_TRG_COM_IRQHandler - .thumb_set TIM8_TRG_COM_IRQHandler,Default_Handler - - .weak TIM8_CC_IRQHandler - .thumb_set TIM8_CC_IRQHandler,Default_Handler - - .weak ADC3_IRQHandler - .thumb_set ADC3_IRQHandler,Default_Handler - - .weak FSMC_IRQHandler - .thumb_set FSMC_IRQHandler,Default_Handler - - .weak SDIO_IRQHandler - .thumb_set SDIO_IRQHandler,Default_Handler - - .weak TIM5_IRQHandler - .thumb_set TIM5_IRQHandler,Default_Handler - - .weak SPI3_IRQHandler - .thumb_set SPI3_IRQHandler,Default_Handler - - .weak UART4_IRQHandler - .thumb_set UART4_IRQHandler,Default_Handler - - .weak UART5_IRQHandler - .thumb_set UART5_IRQHandler,Default_Handler - - .weak TIM6_IRQHandler - .thumb_set TIM6_IRQHandler,Default_Handler - - .weak TIM7_IRQHandler - .thumb_set TIM7_IRQHandler,Default_Handler - - .weak DMA2_Channel1_IRQHandler - .thumb_set DMA2_Channel1_IRQHandler,Default_Handler - - .weak DMA2_Channel2_IRQHandler - .thumb_set DMA2_Channel2_IRQHandler,Default_Handler - - .weak DMA2_Channel3_IRQHandler - .thumb_set DMA2_Channel3_IRQHandler,Default_Handler - - .weak DMA2_Channel4_5_IRQHandler - .thumb_set DMA2_Channel4_5_IRQHandler,Default_Handler - - .weak SystemInit_ExtMemCtl - .thumb_set SystemInit_ExtMemCtl,SystemInit_ExtMemCtl_Dummy - diff --git a/flight/pios/stm32f10x/startup_stm32f10x_MD.S b/flight/pios/stm32f10x/startup_stm32f10x_MD.S deleted file mode 100644 index 101499ca5..000000000 --- a/flight/pios/stm32f10x/startup_stm32f10x_MD.S +++ /dev/null @@ -1,355 +0,0 @@ -/** - ****************************************************************************** - * @file startup_stm32f10x_md.s - * @author MCD Application Team / Angus Peart - * @version V3.1.2 - * @date 09/28/2009 - * @brief STM32F10x Medium Density Devices vector table for RIDE7 toolchain. - * This module performs: - * - Set the initial SP - * - Set the initial PC == Reset_Handler, - * - Set the vector table entries with the exceptions ISR address - * - Branches to main in the C library (which eventually - * calls main()). - * After Reset the Cortex-M3 processor is in Thread mode, - * priority is Privileged, and the Stack is set to Main. - ******************************************************************************* - * @copy - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- */ - - .syntax unified - .cpu cortex-m3 - .fpu softvfp - .thumb - -.global g_pfnVectors -.global Default_Handler - -/* start address for the initialization values of the .data section. -defined in linker script */ -.word _sidata -/* start address for the .data section. defined in linker script */ -.word _sdata -/* end address for the .data section. defined in linker script */ -.word _edata -/* start address for the .bss section. defined in linker script */ -.word _sbss -/* end address for the .bss section. defined in linker script */ -.word _ebss - -.equ BootRAM, 0xF108F85F -/** - * @brief This is the code that gets called when the processor first - * starts execution following a reset event. Only the absolutely - * necessary set is performed, after which the application - * supplied main() routine is called. - * @param None - * @retval : None -*/ - - .section .text.Reset_Handler - .weak Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - -/* Copy the data segment initializers from flash to SRAM */ - movs r1, #0 - b LoopCopyDataInit - -CopyDataInit: - ldr r3, =_sidata - ldr r3, [r3, r1] - str r3, [r0, r1] - adds r1, r1, #4 - -LoopCopyDataInit: - ldr r0, =_sdata - ldr r3, =_edata - adds r2, r0, r1 - cmp r2, r3 - bcc CopyDataInit - ldr r2, =_sbss - b LoopFillZerobss -/* Zero fill the bss segment. */ -FillZerobss: - movs r3, #0 - str r3, [r2], #4 - -LoopFillZerobss: - ldr r3, = _ebss - cmp r2, r3 - bcc FillZerobss -/* Call the application's entry point.*/ - bl main - bx lr -.size Reset_Handler, .-Reset_Handler - -/** - * @brief This is the code that gets called when the processor receives an - * unexpected interrupt. This simply enters an infinite loop, preserving - * the system state for examination by a debugger. - * - * @param None - * @retval : None -*/ - .section .text.Default_Handler,"ax",%progbits -Default_Handler: -Infinite_Loop: - b Infinite_Loop - .size Default_Handler, .-Default_Handler -/****************************************************************************** -* -* The minimal vector table for a Cortex M3. Note that the proper constructs -* must be placed on this to ensure that it ends up at physical address -* 0x0000.0000. -* -******************************************************************************/ - .section .isr_vector,"a",%progbits - .type g_pfnVectors, %object - .size g_pfnVectors, .-g_pfnVectors - - -g_pfnVectors: - .word _estack - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemManage_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 - .word 0 - .word 0 - .word 0 - .word SVC_Handler - .word DebugMon_Handler - .word 0 - .word PendSV_Handler - .word SysTick_Handler - .word WWDG_IRQHandler - .word PVD_IRQHandler - .word TAMPER_IRQHandler - .word RTC_IRQHandler - .word FLASH_IRQHandler - .word RCC_IRQHandler - .word EXTI0_IRQHandler - .word EXTI1_IRQHandler - .word EXTI2_IRQHandler - .word EXTI3_IRQHandler - .word EXTI4_IRQHandler - .word DMA1_Channel1_IRQHandler - .word DMA1_Channel2_IRQHandler - .word DMA1_Channel3_IRQHandler - .word DMA1_Channel4_IRQHandler - .word DMA1_Channel5_IRQHandler - .word DMA1_Channel6_IRQHandler - .word DMA1_Channel7_IRQHandler - .word ADC1_2_IRQHandler - .word USB_HP_CAN1_TX_IRQHandler - .word USB_LP_CAN1_RX0_IRQHandler - .word CAN1_RX1_IRQHandler - .word CAN1_SCE_IRQHandler - .word EXTI9_5_IRQHandler - .word TIM1_BRK_IRQHandler - .word TIM1_UP_IRQHandler - .word TIM1_TRG_COM_IRQHandler - .word TIM1_CC_IRQHandler - .word TIM2_IRQHandler - .word TIM3_IRQHandler - .word TIM4_IRQHandler - .word I2C1_EV_IRQHandler - .word I2C1_ER_IRQHandler - .word I2C2_EV_IRQHandler - .word I2C2_ER_IRQHandler - .word SPI1_IRQHandler - .word SPI2_IRQHandler - .word USART1_IRQHandler - .word USART2_IRQHandler - .word USART3_IRQHandler - .word EXTI15_10_IRQHandler - .word RTCAlarm_IRQHandler - .word USBWakeUp_IRQHandler - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - .word BootRAM /* @0x108. This is for boot in RAM mode for - STM32F10x Medium Density devices. */ - -/******************************************************************************* -* -* Provide weak aliases for each Exception handler to the Default_Handler. -* As they are weak aliases, any function with the same name will override -* this definition. -* -*******************************************************************************/ - - .weak NMI_Handler - .thumb_set NMI_Handler,Default_Handler - - .weak HardFault_Handler - .thumb_set HardFault_Handler,Default_Handler - - .weak MemManage_Handler - .thumb_set MemManage_Handler,Default_Handler - - .weak BusFault_Handler - .thumb_set BusFault_Handler,Default_Handler - - .weak UsageFault_Handler - .thumb_set UsageFault_Handler,Default_Handler - - .weak SVC_Handler - .thumb_set SVC_Handler,Default_Handler - - .weak DebugMon_Handler - .thumb_set DebugMon_Handler,Default_Handler - - .weak PendSV_Handler - .thumb_set PendSV_Handler,Default_Handler - - .weak SysTick_Handler - .thumb_set SysTick_Handler,Default_Handler - - .weak WWDG_IRQHandler - .thumb_set WWDG_IRQHandler,Default_Handler - - .weak PVD_IRQHandler - .thumb_set PVD_IRQHandler,Default_Handler - - .weak TAMPER_IRQHandler - .thumb_set TAMPER_IRQHandler,Default_Handler - - .weak RTC_IRQHandler - .thumb_set RTC_IRQHandler,Default_Handler - - .weak FLASH_IRQHandler - .thumb_set FLASH_IRQHandler,Default_Handler - - .weak RCC_IRQHandler - .thumb_set RCC_IRQHandler,Default_Handler - - .weak EXTI0_IRQHandler - .thumb_set EXTI0_IRQHandler,Default_Handler - - .weak EXTI1_IRQHandler - .thumb_set EXTI1_IRQHandler,Default_Handler - - .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler - - .weak EXTI3_IRQHandler - .thumb_set EXTI3_IRQHandler,Default_Handler - - .weak EXTI4_IRQHandler - .thumb_set EXTI4_IRQHandler,Default_Handler - - .weak DMA1_Channel1_IRQHandler - .thumb_set DMA1_Channel1_IRQHandler,Default_Handler - - .weak DMA1_Channel2_IRQHandler - .thumb_set DMA1_Channel2_IRQHandler,Default_Handler - - .weak DMA1_Channel3_IRQHandler - .thumb_set DMA1_Channel3_IRQHandler,Default_Handler - - .weak DMA1_Channel4_IRQHandler - .thumb_set DMA1_Channel4_IRQHandler,Default_Handler - - .weak DMA1_Channel5_IRQHandler - .thumb_set DMA1_Channel5_IRQHandler,Default_Handler - - .weak DMA1_Channel6_IRQHandler - .thumb_set DMA1_Channel6_IRQHandler,Default_Handler - - .weak DMA1_Channel7_IRQHandler - .thumb_set DMA1_Channel7_IRQHandler,Default_Handler - - .weak ADC1_2_IRQHandler - .thumb_set ADC1_2_IRQHandler,Default_Handler - - .weak USB_HP_CAN1_TX_IRQHandler - .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler - - .weak USB_LP_CAN1_RX0_IRQHandler - .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler - - .weak CAN1_RX1_IRQHandler - .thumb_set CAN1_RX1_IRQHandler,Default_Handler - - .weak CAN1_SCE_IRQHandler - .thumb_set CAN1_SCE_IRQHandler,Default_Handler - - .weak EXTI9_5_IRQHandler - .thumb_set EXTI9_5_IRQHandler,Default_Handler - - .weak TIM1_BRK_IRQHandler - .thumb_set TIM1_BRK_IRQHandler,Default_Handler - - .weak TIM1_UP_IRQHandler - .thumb_set TIM1_UP_IRQHandler,Default_Handler - - .weak TIM1_TRG_COM_IRQHandler - .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler - - .weak TIM1_CC_IRQHandler - .thumb_set TIM1_CC_IRQHandler,Default_Handler - - .weak TIM2_IRQHandler - .thumb_set TIM2_IRQHandler,Default_Handler - - .weak TIM3_IRQHandler - .thumb_set TIM3_IRQHandler,Default_Handler - - .weak TIM4_IRQHandler - .thumb_set TIM4_IRQHandler,Default_Handler - - .weak I2C1_EV_IRQHandler - .thumb_set I2C1_EV_IRQHandler,Default_Handler - - .weak I2C1_ER_IRQHandler - .thumb_set I2C1_ER_IRQHandler,Default_Handler - - .weak I2C2_EV_IRQHandler - .thumb_set I2C2_EV_IRQHandler,Default_Handler - - .weak I2C2_ER_IRQHandler - .thumb_set I2C2_ER_IRQHandler,Default_Handler - - .weak SPI1_IRQHandler - .thumb_set SPI1_IRQHandler,Default_Handler - - .weak SPI2_IRQHandler - .thumb_set SPI2_IRQHandler,Default_Handler - - .weak USART1_IRQHandler - .thumb_set USART1_IRQHandler,Default_Handler - - .weak USART2_IRQHandler - .thumb_set USART2_IRQHandler,Default_Handler - - .weak USART3_IRQHandler - .thumb_set USART3_IRQHandler,Default_Handler - - .weak EXTI15_10_IRQHandler - .thumb_set EXTI15_10_IRQHandler,Default_Handler - - .weak RTCAlarm_IRQHandler - .thumb_set RTCAlarm_IRQHandler,Default_Handler - - .weak USBWakeUp_IRQHandler - .thumb_set USBWakeUp_IRQHandler,Default_Handler - - From 06f59d2c40b617d0d342d9ed43477394059295fa Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Tue, 18 Aug 2015 15:27:01 +0200 Subject: [PATCH 4/6] LP-96 - Call CPU idle calibration function from SystemMod --- flight/modules/System/systemmod.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flight/modules/System/systemmod.c b/flight/modules/System/systemmod.c index e62aa982e..11c4a2b69 100644 --- a/flight/modules/System/systemmod.c +++ b/flight/modules/System/systemmod.c @@ -178,6 +178,8 @@ MODULE_INITCALL(SystemModInitialize, 0); */ static void systemTask(__attribute__((unused)) void *parameters) { + /* calibrate the cpu usage monitor */ + PIOS_TASK_MONITOR_CalibrateIdleCounter(); /* board driver init */ PIOS_Board_Init(); From 970ae3df00036df40300bb2233426d2e86ddc2dd Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Wed, 19 Aug 2015 14:56:59 +0200 Subject: [PATCH 5/6] LP-97 - Fixes for Osd and discoveryf4bare --- .../firmware/discoveryf4bare.cpp | 60 +---- flight/targets/boards/osd/firmware/Makefile | 5 +- flight/targets/boards/osd/firmware/osd.c | 229 ------------------ flight/targets/boards/osd/firmware/osd.cpp | 85 +++++++ 4 files changed, 91 insertions(+), 288 deletions(-) delete mode 100644 flight/targets/boards/osd/firmware/osd.c create mode 100644 flight/targets/boards/osd/firmware/osd.cpp diff --git a/flight/targets/boards/discoveryf4bare/firmware/discoveryf4bare.cpp b/flight/targets/boards/discoveryf4bare/firmware/discoveryf4bare.cpp index 268325b26..9ba92a137 100644 --- a/flight/targets/boards/discoveryf4bare/firmware/discoveryf4bare.cpp +++ b/flight/targets/boards/discoveryf4bare/firmware/discoveryf4bare.cpp @@ -34,46 +34,12 @@ extern "C" { #include "inc/openpilot.h" #include +#include -/* Task Priorities */ -#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) /* Global Variables */ /* Local Variables */ -#define INCLUDE_TEST_TASKS 0 -#if INCLUDE_TEST_TASKS -static uint8_t sdcard_available; -#endif -char Buffer[1024]; -uint32_t Cache; - -/* Function Prototypes */ -#if INCLUDE_TEST_TASKS -static void TaskTick(void *pvParameters); -static void TaskTesting(void *pvParameters); -static void TaskHIDTest(void *pvParameters); -static void TaskServos(void *pvParameters); -static void TaskSDCard(void *pvParameters); -#endif -int32_t CONSOLE_Parse(uint8_t port, char c); -void OP_ADC_NotifyChange(uint32_t pin, uint32_t pin_value); - -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); -extern void Stack_Change(void); -static void Stack_Change_Weak() __attribute__((weakref("Stack_Change"))); - -/* Local Variables */ -#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority -#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive -static xTaskHandle initTaskHandle; - -/* Function Prototypes */ -static void initTask(void *parameters); - -/* Prototype of generated InitModules() function */ -extern void InitModules(void); } /** @@ -87,8 +53,6 @@ extern void InitModules(void); */ int main() { - int result; - /* NOTE: Do NOT modify the following start-up sequence */ /* Any new initialization functions should be added in OpenPilotInit() */ vPortInitialiseBlocks(); @@ -96,12 +60,7 @@ int main() /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); - /* For Revolution we use a FreeRTOS task to bring up the system so we can */ - /* always rely on FreeRTOS primitive */ - result = xTaskCreate(initTask, "init", - INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY, - &initTaskHandle); - PIOS_Assert(result == pdPASS); + SystemModStart(); /* Start the FreeRTOS scheduler */ vTaskStartScheduler(); @@ -117,22 +76,7 @@ int main() return 0; } -/** - * Initialisation task. - * - * Runs board and module initialisation, then terminates. - */ -void initTask(__attribute__((unused)) void *parameters) -{ - /* board driver init */ - PIOS_Board_Init(); - /* Initialize modules */ - MODULE_INITIALISE_ALL; - - /* terminate this task */ - vTaskDelete(NULL); -} /** * @} diff --git a/flight/targets/boards/osd/firmware/Makefile b/flight/targets/boards/osd/firmware/Makefile index 4cb48b945..f5acb8158 100644 --- a/flight/targets/boards/osd/firmware/Makefile +++ b/flight/targets/boards/osd/firmware/Makefile @@ -24,6 +24,9 @@ endif include ../board-info.mk include $(ROOT_DIR)/make/firmware-defs.mk +# REVO C++ support +USE_CXX = YES + # ARM DSP library override USE_DSP_LIB := NO @@ -52,7 +55,7 @@ ifndef TESTAPP ## Application Core SRC += ../pios_usb_board_data.c SRC += $(OPMODULEDIR)/System/systemmod.c - SRC += $(OPSYSTEM)/osd.c + CPPSRC += $(OPSYSTEM)/osd.cpp SRC += $(OPSYSTEM)/pios_board.c SRC += $(FLIGHTLIB)/alarms.c SRC += $(OPUAVTALK)/uavtalk.c diff --git a/flight/targets/boards/osd/firmware/osd.c b/flight/targets/boards/osd/firmware/osd.c deleted file mode 100644 index 041b42c00..000000000 --- a/flight/targets/boards/osd/firmware/osd.c +++ /dev/null @@ -1,229 +0,0 @@ -/** - ****************************************************************************** - * - * @file main.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Main modem functions - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -// ***************************************************************************** - -// #define USE_WATCHDOG // comment this out if you don't want to use the watchdog - -// ***************************************************************************** - -#include "inc/openpilot.h" -#include - -/* Task Priorities */ -#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) - -/* Global Variables */ - -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); -extern void Stack_Change(void); -static void Stack_Change_Weak() __attribute__((weakref("Stack_Change"))); - - -/* Function Prototypes */ -static void initTask(void *parameters); -/* Local Variables */ -#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority -#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive -static xTaskHandle initTaskHandle; - -// ***************************************************************************** -// Global Variables - -// ***************************************************************************** -// Local Variables - -#if defined(USE_WATCHDOG) -volatile uint16_t watchdog_timer; -uint16_t watchdog_delay; -#endif - -// ***************************************************************************** - -#if defined(USE_WATCHDOG) - -void processWatchdog(void) -{ - // random32 = UpdateCRC32(random32, IWDG->SR); - - if (watchdog_timer < watchdog_delay) { - return; - } - - // the watchdog needs resetting - - watchdog_timer = 0; - - watchdog_Clear(); -} - -void enableWatchdog(void) -{ // enable a watchdog - watchdog_timer = 0; - watchdog_delay = watchdog_Init(1000); // 1 second watchdog timeout -} - -#endif /* if defined(USE_WATCHDOG) */ - -// ***************************************************************************** - -void sequenceLEDs(void) -{ - for (int i = 0; i < 2; i++) { - // USB_LED_ON; - PIOS_DELAY_WaitmS(100); - // USB_LED_OFF; - PIOS_DELAY_WaitmS(100); - - #if defined(USE_WATCHDOG) - processWatchdog(); // process the watchdog - #endif - } -} - -// ***************************************************************************** -// find out what caused our reset and act on it - -void processReset(void) -{ - if (RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET) { // Independant Watchdog Reset - #if defined(PIOS_COM_DEBUG_CONSOLE) - DEBUG_PRINTF(0, "\r\nINDEPENDANT WATCHDOG CAUSED A RESET\r\n"); - #endif - - // all led's ON - // USB_LED_ON; - - - PIOS_DELAY_WaitmS(500); // delay a bit - - // all led's OFF - // USB_LED_OFF; - } -/* - if (RCC_GetFlagStatus(RCC_FLAG_WWDGRST) != RESET) - { // Window Watchdog Reset - - DEBUG_PRINTF(0, "\r\nWINDOW WATCHDOG CAUSED A REBOOT\r\n"); - - // all led's ON - USB_LED_ON; - LINK_LED_ON; - RX_LED_ON; - TX_LED_ON; - - PIOS_DELAY_WaitmS(500); // delay a bit - - // all led's OFF - USB_LED_OFF; - LINK_LED_OFF; - RX_LED_OFF; - TX_LED_OFF; - } - */ - if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) { // Power-On Reset - #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF(0, "\r\nPOWER-ON-RESET\r\n"); - #endif - } - - if (RCC_GetFlagStatus(RCC_FLAG_SFTRST) != RESET) { // Software Reset - #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF(0, "\r\nSOFTWARE RESET\r\n"); - #endif - } - - if (RCC_GetFlagStatus(RCC_FLAG_LPWRRST) != RESET) { // Low-Power Reset - #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF(0, "\r\nLOW POWER RESET\r\n"); - #endif - } - - if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) { // Pin Reset - #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF("0, \r\nPIN RESET\r\n"); - #endif - } - - // Clear reset flags - // RCC_ClearFlag(); -} - -int main() -{ - int result; - - // ************* - // init various variables - // ************* - /* NOTE: Do NOT modify the following start-up sequence */ - /* Any new initialization functions should be added in OpenPilotInit() */ - vPortInitialiseBlocks(); - - // Bring up System using CMSIS functions, enables the LEDs. - PIOS_SYS_Init(); - - /* For Revolution we use a FreeRTOS task to bring up the system so we can */ - /* always rely on FreeRTOS primitive */ - result = xTaskCreate(initTask, "init", - INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY, - &initTaskHandle); - PIOS_Assert(result == pdPASS); - - /* Start the FreeRTOS scheduler which should never returns.*/ - vTaskStartScheduler(); - - /* If all is well we will never reach here as the scheduler will now be running. */ - /* Do some indication to user that something bad just happened */ - PIOS_LED_Off(PIOS_LED_HEARTBEAT); \ - for (;;) { \ - PIOS_LED_Toggle(PIOS_LED_HEARTBEAT); \ - PIOS_DELAY_WaitmS(100); \ - } - ; - - return 0; -} - -/** - * Initialisation task. - * - * Runs board and module initialisation, then terminates. - */ -void initTask(__attribute__((unused)) void *parameters) -{ - /* board driver init */ - PIOS_Board_Init(); - - /* Initialize modules */ - MODULE_INITIALISE_ALL; - - /* terminate this task */ - vTaskDelete(NULL); -} - -// ***************************************************************************** diff --git a/flight/targets/boards/osd/firmware/osd.cpp b/flight/targets/boards/osd/firmware/osd.cpp new file mode 100644 index 000000000..c35669129 --- /dev/null +++ b/flight/targets/boards/osd/firmware/osd.cpp @@ -0,0 +1,85 @@ +/** + ****************************************************************************** + * @addtogroup LibrePilotSystem LibrePilot System + * @brief These files are the core system files for Revolution. + * They are the ground layer just above PiOS. In practice, OSD actually starts + * in the main() function of osd.c + * @{ + * @addtogroup LibrePilotCore LibrePilot Core + * @brief This is where the LP firmware starts. Those files also define the compile-time + * options of the firmware. + * @{ + * @file osd.c + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015 + * @brief Sets up and runs main tasks. + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +extern "C" { +#include "inc/openpilot.h" +#include +#include + + +/* Global Variables */ + +/* Local Variables */ +} + +/** + * OpenPilot Main function: + * + * Initialize PiOS
+ * Create the "System" task (SystemModInitializein Modules/System/systemmod.c)
+ * Start FreeRTOS Scheduler (vTaskStartScheduler)
+ * If something goes wrong, blink LED1 and LED2 every 100ms + * + */ +int main() +{ + /* NOTE: Do NOT modify the following start-up sequence */ + /* Any new initialization functions should be added in OpenPilotInit() */ + vPortInitialiseBlocks(); + + /* Brings up System using CMSIS functions, enables the LEDs. */ + PIOS_SYS_Init(); + + SystemModStart(); + + /* Start the FreeRTOS scheduler */ + vTaskStartScheduler(); + + /* If all is well we will never reach here as the scheduler will now be running. */ + /* Do some PIOS_LED_HEARTBEAT to user that something bad just happened */ + PIOS_LED_Off(PIOS_LED_HEARTBEAT); \ + for (;;) { \ + PIOS_LED_Toggle(PIOS_LED_HEARTBEAT); \ + PIOS_DELAY_WaitmS(100); \ + } + ; + + return 0; +} + + +/** + * @} + * @} + */ From 70faa04b0afd099af9f023d09de1d1eb0798851c Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sun, 8 Nov 2015 18:44:10 +0100 Subject: [PATCH 6/6] LP-97 - Move board init function declarations to a pios_board_init.h, fix some headers --- flight/modules/System/systemmod.c | 3 +- flight/pios/inc/pios_board_init.h | 31 +++++++++++++++++++ .../boards/coptercontrol/bootloader/main.c | 3 +- .../coptercontrol/firmware/pios_board.c | 1 - .../boards/discoveryf4bare/bootloader/main.c | 3 +- .../boards/gpsplatinum/bootloader/main.c | 3 +- .../boards/gpsplatinum/firmware/gpsp.c | 3 +- .../boards/oplinkmini/bootloader/main.c | 3 +- .../boards/oplinkmini/firmware/oplink.c | 3 +- flight/targets/boards/osd/bootloader/main.c | 3 +- flight/targets/boards/osd/firmware/osd.cpp | 2 +- .../boards/revolution/bootloader/main.c | 3 +- .../boards/revolution/firmware/revolution.cpp | 2 +- .../targets/boards/revonano/bootloader/main.c | 3 +- .../boards/revonano/firmware/revolution.cpp | 2 +- .../boards/revoproto/bootloader/main.c | 3 +- .../boards/revoproto/firmware/revolution.cpp | 2 +- .../targets/common/bootloader_updater/main.c | 4 +-- 18 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 flight/pios/inc/pios_board_init.h diff --git a/flight/modules/System/systemmod.c b/flight/modules/System/systemmod.c index 11c4a2b69..aec2af33c 100644 --- a/flight/modules/System/systemmod.c +++ b/flight/modules/System/systemmod.c @@ -61,6 +61,8 @@ #include #include #include +#include + #ifdef PIOS_INCLUDE_INSTRUMENTATION #include @@ -120,7 +122,6 @@ static void systemTask(void *parameters); static void updateI2Cstats(); static void updateWDGstats(); #endif -extern void PIOS_Board_Init(void); extern uintptr_t pios_uavo_settings_fs_id; extern uintptr_t pios_user_fs_id; diff --git a/flight/pios/inc/pios_board_init.h b/flight/pios/inc/pios_board_init.h new file mode 100644 index 000000000..27b26a23a --- /dev/null +++ b/flight/pios/inc/pios_board_init.h @@ -0,0 +1,31 @@ +/** + ****************************************************************************** + * + * @file pios_board_init.h + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * @brief board initialization prototypes + * -- + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef PIOS_BOARD_INIT_H +#define PIOS_BOARD_INIT_H + +extern void PIOS_Board_Init(void); + +#endif /* PIOS_BOARD_INIT_H */ diff --git a/flight/targets/boards/coptercontrol/bootloader/main.c b/flight/targets/boards/coptercontrol/bootloader/main.c index 15068627c..20549d1fa 100644 --- a/flight/targets/boards/coptercontrol/bootloader/main.c +++ b/flight/targets/boards/coptercontrol/bootloader/main.c @@ -33,9 +33,8 @@ #include #include #include +#include -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void FLASH_Download(); #define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1) diff --git a/flight/targets/boards/coptercontrol/firmware/pios_board.c b/flight/targets/boards/coptercontrol/firmware/pios_board.c index bda24996b..baa17c0b3 100644 --- a/flight/targets/boards/coptercontrol/firmware/pios_board.c +++ b/flight/targets/boards/coptercontrol/firmware/pios_board.c @@ -155,7 +155,6 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { int32_t init_test; void PIOS_Board_Init(void) { - const struct pios_board_info *bdinfo = &pios_board_info_blob; #if defined(PIOS_INCLUDE_LED) diff --git a/flight/targets/boards/discoveryf4bare/bootloader/main.c b/flight/targets/boards/discoveryf4bare/bootloader/main.c index 5c6e08db7..09a54a094 100644 --- a/flight/targets/boards/discoveryf4bare/bootloader/main.c +++ b/flight/targets/boards/discoveryf4bare/bootloader/main.c @@ -34,9 +34,8 @@ #include #include /* PIOS_USBHOOK_* */ #include +#include -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void FLASH_Download(); void check_bor(); #define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1) diff --git a/flight/targets/boards/gpsplatinum/bootloader/main.c b/flight/targets/boards/gpsplatinum/bootloader/main.c index 2e2230847..a11fa2f3d 100644 --- a/flight/targets/boards/gpsplatinum/bootloader/main.c +++ b/flight/targets/boards/gpsplatinum/bootloader/main.c @@ -36,9 +36,8 @@ #include #include #include +#include -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void FLASH_Download(); int32_t platform_senddata(const uint8_t *msg, uint16_t msg_len); /* Private typedef -----------------------------------------------------------*/ diff --git a/flight/targets/boards/gpsplatinum/firmware/gpsp.c b/flight/targets/boards/gpsplatinum/firmware/gpsp.c index b240febb2..0768c2a55 100644 --- a/flight/targets/boards/gpsplatinum/firmware/gpsp.c +++ b/flight/targets/boards/gpsplatinum/firmware/gpsp.c @@ -34,14 +34,13 @@ #include "inc/openpilot.h" #include #include +#include /* Task Priorities */ #define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) /* Global Variables */ -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void Stack_Change(void); /** diff --git a/flight/targets/boards/oplinkmini/bootloader/main.c b/flight/targets/boards/oplinkmini/bootloader/main.c index 9135341af..28cfcc30b 100644 --- a/flight/targets/boards/oplinkmini/bootloader/main.c +++ b/flight/targets/boards/oplinkmini/bootloader/main.c @@ -33,9 +33,8 @@ #include #include #include +#include -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void FLASH_Download(); #define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1) diff --git a/flight/targets/boards/oplinkmini/firmware/oplink.c b/flight/targets/boards/oplinkmini/firmware/oplink.c index 07d4fa551..13b5e44b3 100644 --- a/flight/targets/boards/oplinkmini/firmware/oplink.c +++ b/flight/targets/boards/oplinkmini/firmware/oplink.c @@ -34,14 +34,13 @@ #include "inc/openpilot.h" #include #include +#include /* Task Priorities */ #define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3) /* Global Variables */ -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void Stack_Change(void); /** diff --git a/flight/targets/boards/osd/bootloader/main.c b/flight/targets/boards/osd/bootloader/main.c index 12f2a4c39..c333ab9af 100644 --- a/flight/targets/boards/osd/bootloader/main.c +++ b/flight/targets/boards/osd/bootloader/main.c @@ -34,9 +34,8 @@ #include #include /* PIOS_USBHOOK_* */ #include +#include -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void FLASH_Download(); #define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1) diff --git a/flight/targets/boards/osd/firmware/osd.cpp b/flight/targets/boards/osd/firmware/osd.cpp index c35669129..417b6d7b2 100644 --- a/flight/targets/boards/osd/firmware/osd.cpp +++ b/flight/targets/boards/osd/firmware/osd.cpp @@ -3,7 +3,7 @@ * @addtogroup LibrePilotSystem LibrePilot System * @brief These files are the core system files for Revolution. * They are the ground layer just above PiOS. In practice, OSD actually starts - * in the main() function of osd.c + * in the main() function of osd.cpp * @{ * @addtogroup LibrePilotCore LibrePilot Core * @brief This is where the LP firmware starts. Those files also define the compile-time diff --git a/flight/targets/boards/revolution/bootloader/main.c b/flight/targets/boards/revolution/bootloader/main.c index 5c6e08db7..09a54a094 100644 --- a/flight/targets/boards/revolution/bootloader/main.c +++ b/flight/targets/boards/revolution/bootloader/main.c @@ -34,9 +34,8 @@ #include #include /* PIOS_USBHOOK_* */ #include +#include -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void FLASH_Download(); void check_bor(); #define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1) diff --git a/flight/targets/boards/revolution/firmware/revolution.cpp b/flight/targets/boards/revolution/firmware/revolution.cpp index 0fd335f60..8c5bbf28c 100644 --- a/flight/targets/boards/revolution/firmware/revolution.cpp +++ b/flight/targets/boards/revolution/firmware/revolution.cpp @@ -3,7 +3,7 @@ * @addtogroup LibrePilotSystem LibrePilot System * @brief These files are the core system files for Revolution. * They are the ground layer just above PiOS. In practice, Revolution actually starts - * in the main() function of revolution.c + * in the main() function of revolution.cpp * @{ * @addtogroup LibrePilotCore LibrePilot Core * @brief This is where the LP firmware starts. Those files also define the compile-time diff --git a/flight/targets/boards/revonano/bootloader/main.c b/flight/targets/boards/revonano/bootloader/main.c index 5c6e08db7..09a54a094 100644 --- a/flight/targets/boards/revonano/bootloader/main.c +++ b/flight/targets/boards/revonano/bootloader/main.c @@ -34,9 +34,8 @@ #include #include /* PIOS_USBHOOK_* */ #include +#include -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void FLASH_Download(); void check_bor(); #define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1) diff --git a/flight/targets/boards/revonano/firmware/revolution.cpp b/flight/targets/boards/revonano/firmware/revolution.cpp index 0fd335f60..8c5bbf28c 100644 --- a/flight/targets/boards/revonano/firmware/revolution.cpp +++ b/flight/targets/boards/revonano/firmware/revolution.cpp @@ -3,7 +3,7 @@ * @addtogroup LibrePilotSystem LibrePilot System * @brief These files are the core system files for Revolution. * They are the ground layer just above PiOS. In practice, Revolution actually starts - * in the main() function of revolution.c + * in the main() function of revolution.cpp * @{ * @addtogroup LibrePilotCore LibrePilot Core * @brief This is where the LP firmware starts. Those files also define the compile-time diff --git a/flight/targets/boards/revoproto/bootloader/main.c b/flight/targets/boards/revoproto/bootloader/main.c index 5c6e08db7..09a54a094 100644 --- a/flight/targets/boards/revoproto/bootloader/main.c +++ b/flight/targets/boards/revoproto/bootloader/main.c @@ -34,9 +34,8 @@ #include #include /* PIOS_USBHOOK_* */ #include +#include -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); extern void FLASH_Download(); void check_bor(); #define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1) diff --git a/flight/targets/boards/revoproto/firmware/revolution.cpp b/flight/targets/boards/revoproto/firmware/revolution.cpp index 0fd335f60..8c5bbf28c 100644 --- a/flight/targets/boards/revoproto/firmware/revolution.cpp +++ b/flight/targets/boards/revoproto/firmware/revolution.cpp @@ -3,7 +3,7 @@ * @addtogroup LibrePilotSystem LibrePilot System * @brief These files are the core system files for Revolution. * They are the ground layer just above PiOS. In practice, Revolution actually starts - * in the main() function of revolution.c + * in the main() function of revolution.cpp * @{ * @addtogroup LibrePilotCore LibrePilot Core * @brief This is where the LP firmware starts. Those files also define the compile-time diff --git a/flight/targets/common/bootloader_updater/main.c b/flight/targets/common/bootloader_updater/main.c index 385bbdd3d..1a480afa5 100644 --- a/flight/targets/common/bootloader_updater/main.c +++ b/flight/targets/common/bootloader_updater/main.c @@ -30,10 +30,10 @@ #include #include #include +#include #define MAX_WRI_RETRYS 3 -/* Prototype of PIOS_Board_Init() function */ -extern void PIOS_Board_Init(void); + extern void FLASH_Download(); void error(int, int);