diff --git a/CMakeLists.txt b/CMakeLists.txt index f1c3d96473..1dd8091769 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -417,7 +417,7 @@ add_library(parameters_interface INTERFACE) include(px4_add_library) add_subdirectory(src/lib EXCLUDE_FROM_ALL) -add_subdirectory(src/platforms/common EXCLUDE_FROM_ALL) +add_subdirectory(src/platforms EXCLUDE_FROM_ALL) add_subdirectory(src/modules/systemlib EXCLUDE_FROM_ALL) # TODO: split into libraries in platform layer add_subdirectory(src/modules/uORB EXCLUDE_FROM_ALL) # TODO: platform layer add_subdirectory(src/drivers/boards EXCLUDE_FROM_ALL) diff --git a/boards/airmind/mindpx-v2/src/CMakeLists.txt b/boards/airmind/mindpx-v2/src/CMakeLists.txt index 80cdd8bd7a..4fbd7b3f50 100644 --- a/boards/airmind/mindpx-v2/src/CMakeLists.txt +++ b/boards/airmind/mindpx-v2/src/CMakeLists.txt @@ -43,8 +43,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/airmind/mindpx-v2/src/init.c b/boards/airmind/mindpx-v2/src/init.c index a30f01f80a..de16f44165 100644 --- a/boards/airmind/mindpx-v2/src/init.c +++ b/boards/airmind/mindpx-v2/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -72,12 +71,7 @@ #include #include -#include -#include -#include - - -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -238,26 +232,7 @@ static struct sdio_dev_s *sdio; __EXPORT int board_app_initialize(uintptr_t arg) { - -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -265,11 +240,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/atmel/same70xplained/src/CMakeLists.txt b/boards/atmel/same70xplained/src/CMakeLists.txt index 4748379aea..e67d622096 100644 --- a/boards/atmel/same70xplained/src/CMakeLists.txt +++ b/boards/atmel/same70xplained/src/CMakeLists.txt @@ -44,8 +44,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/atmel/same70xplained/src/init.c b/boards/atmel/same70xplained/src/init.c index a200e3a639..19a96ebe40 100644 --- a/boards/atmel/same70xplained/src/init.c +++ b/boards/atmel/same70xplained/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -74,11 +73,8 @@ #include #include -#include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -237,24 +233,8 @@ __EXPORT int board_app_initialize(uintptr_t arg) /* configure power supply control/sense pins */ -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -262,11 +242,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* initial LED state */ drv_led_start(); diff --git a/boards/auav/esc35-v1/src/CMakeLists.txt b/boards/auav/esc35-v1/src/CMakeLists.txt index 0a54e8eab5..db702078c8 100644 --- a/boards/auav/esc35-v1/src/CMakeLists.txt +++ b/boards/auav/esc35-v1/src/CMakeLists.txt @@ -42,6 +42,5 @@ px4_add_library(drivers_board ) target_link_libraries(drivers_board PRIVATE - nuttx_apps # up_cxxinitialize - parameters # param_init + px4_layer ) diff --git a/boards/auav/esc35-v1/src/init.c b/boards/auav/esc35-v1/src/init.c index 807e867155..a87f0c51c3 100644 --- a/boards/auav/esc35-v1/src/init.c +++ b/boards/auav/esc35-v1/src/init.c @@ -52,7 +52,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -68,8 +67,7 @@ #include #include -#include -#include +#include #if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) #endif @@ -162,24 +160,8 @@ __EXPORT int board_app_initialize(uintptr_t arg) { int result = OK; -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; diff --git a/boards/auav/x21/src/CMakeLists.txt b/boards/auav/x21/src/CMakeLists.txt index 93fb657702..81a1b344af 100644 --- a/boards/auav/x21/src/CMakeLists.txt +++ b/boards/auav/x21/src/CMakeLists.txt @@ -42,8 +42,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/auav/x21/src/init.c b/boards/auav/x21/src/init.c index 0f25f1f9cd..069a32d2da 100644 --- a/boards/auav/x21/src/init.c +++ b/boards/auav/x21/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -72,11 +71,8 @@ #include #include -#include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -255,24 +251,8 @@ static struct sdio_dev_s *sdio; __EXPORT int board_app_initialize(uintptr_t arg) { -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -280,11 +260,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/av/x-v1/src/CMakeLists.txt b/boards/av/x-v1/src/CMakeLists.txt index 360e888a5e..4a80e72d5b 100644 --- a/boards/av/x-v1/src/CMakeLists.txt +++ b/boards/av/x-v1/src/CMakeLists.txt @@ -41,8 +41,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) \ No newline at end of file diff --git a/boards/av/x-v1/src/init.c b/boards/av/x-v1/src/init.c index fba376cbf4..1b98b25770 100644 --- a/boards/av/x-v1/src/init.c +++ b/boards/av/x-v1/src/init.c @@ -55,7 +55,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -75,11 +74,8 @@ #include #include -#include -#include -#include -#include +#include #include #include "up_internal.h" @@ -209,13 +205,7 @@ stm32_boardinitialize(void) __EXPORT int board_app_initialize(uintptr_t arg) { - /* run C++ ctors before we go any further */ - up_cxxinitialize(); - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -223,11 +213,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) PX4_ERR("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/bitcraze/crazyflie/src/CMakeLists.txt b/boards/bitcraze/crazyflie/src/CMakeLists.txt index 4505fd107a..4e1d54ac1e 100644 --- a/boards/bitcraze/crazyflie/src/CMakeLists.txt +++ b/boards/bitcraze/crazyflie/src/CMakeLists.txt @@ -41,6 +41,5 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize - parameters # param_init + px4_layer ) diff --git a/boards/bitcraze/crazyflie/src/init.c b/boards/bitcraze/crazyflie/src/init.c index af82f8b5ce..45b317ea6c 100644 --- a/boards/bitcraze/crazyflie/src/init.c +++ b/boards/bitcraze/crazyflie/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -68,9 +67,7 @@ #include #include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -149,29 +146,8 @@ stm32_boardinitialize(void) __EXPORT int board_app_initialize(uintptr_t arg) { -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); - - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif + px4_platform_init(); /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; diff --git a/boards/gumstix/aerocore2/src/CMakeLists.txt b/boards/gumstix/aerocore2/src/CMakeLists.txt index 93fb657702..81a1b344af 100644 --- a/boards/gumstix/aerocore2/src/CMakeLists.txt +++ b/boards/gumstix/aerocore2/src/CMakeLists.txt @@ -42,8 +42,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/gumstix/aerocore2/src/init.c b/boards/gumstix/aerocore2/src/init.c index 4ba03da035..ad1bf89b8c 100644 --- a/boards/gumstix/aerocore2/src/init.c +++ b/boards/gumstix/aerocore2/src/init.c @@ -53,7 +53,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -68,11 +67,8 @@ #include #include -#include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -206,24 +202,7 @@ static struct spi_dev_s *spi4; __EXPORT int board_app_initialize(uintptr_t arg) { -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -231,11 +210,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/intel/aerofc-v1/src/CMakeLists.txt b/boards/intel/aerofc-v1/src/CMakeLists.txt index c0ca8bf5d6..f1e4250994 100644 --- a/boards/intel/aerofc-v1/src/CMakeLists.txt +++ b/boards/intel/aerofc-v1/src/CMakeLists.txt @@ -41,7 +41,6 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize - parameters # param_init - modules__dataman # dm_flash_sector_description_set + px4_layer + modules__dataman # dm_flash_sector_description_set # TODO: fix this ) diff --git a/boards/intel/aerofc-v1/src/init.c b/boards/intel/aerofc-v1/src/init.c index 245802a1fb..b4ae07bb0a 100644 --- a/boards/intel/aerofc-v1/src/init.c +++ b/boards/intel/aerofc-v1/src/init.c @@ -55,7 +55,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include @@ -70,9 +69,7 @@ #include #include -#include -#include -#include +#include # if defined(FLASH_BASED_PARAMS) # include @@ -175,29 +172,8 @@ __EXPORT int board_app_initialize(uintptr_t arg) /* the interruption subsystem is not initialized when stm32_boardinitialize() is called */ stm32_gpiosetevent(GPIO_FORCE_BOOTLOADER, true, false, false, _bootloader_force_pin_callback, NULL); -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); - - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif + px4_platform_init(); /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; diff --git a/boards/nxp/fmuk66-v3/src/CMakeLists.txt b/boards/nxp/fmuk66-v3/src/CMakeLists.txt index 6c08faf65a..c559f9b9ad 100644 --- a/boards/nxp/fmuk66-v3/src/CMakeLists.txt +++ b/boards/nxp/fmuk66-v3/src/CMakeLists.txt @@ -45,9 +45,8 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio drivers__led # drv_led_start - parameters # param_init + px4_layer ) \ No newline at end of file diff --git a/boards/nxp/fmuk66-v3/src/init.c b/boards/nxp/fmuk66-v3/src/init.c index c9fbdce894..9699f32291 100644 --- a/boards/nxp/fmuk66-v3/src/init.c +++ b/boards/nxp/fmuk66-v3/src/init.c @@ -53,7 +53,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -73,9 +72,8 @@ #include #include -#include -#include -#include + +#include /**************************************************************************** * Pre-Processor Definitions @@ -278,24 +276,8 @@ __EXPORT int board_app_initialize(uintptr_t arg) VDD_ETH_EN(true); -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - param_init(); - - /* configure the high-resolution time/callout interface */ - hrt_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -303,11 +285,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ #ifdef SERIAL_HAVE_DMA static struct hrt_call serial_dma_call; diff --git a/boards/omnibus/f4sd/src/CMakeLists.txt b/boards/omnibus/f4sd/src/CMakeLists.txt index 3d8de289cc..bf72b7efcd 100644 --- a/boards/omnibus/f4sd/src/CMakeLists.txt +++ b/boards/omnibus/f4sd/src/CMakeLists.txt @@ -42,8 +42,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/omnibus/f4sd/src/init.c b/boards/omnibus/f4sd/src/init.c index ec9b87d87b..846407ca73 100644 --- a/boards/omnibus/f4sd/src/init.c +++ b/boards/omnibus/f4sd/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -72,11 +71,8 @@ #include #include -#include -#include -#include -#include +#include # if defined(FLASH_BASED_PARAMS) # include @@ -260,24 +256,8 @@ static struct spi_dev_s *spi3; __EXPORT int board_app_initialize(uintptr_t arg) { -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -285,11 +265,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/px4/cannode-v1/src/CMakeLists.txt b/boards/px4/cannode-v1/src/CMakeLists.txt index 2fe828c7f0..f449efe9e0 100644 --- a/boards/px4/cannode-v1/src/CMakeLists.txt +++ b/boards/px4/cannode-v1/src/CMakeLists.txt @@ -41,9 +41,8 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio drivers__led # drv_led_start - parameters # param_init + px4_layer ) diff --git a/boards/px4/cannode-v1/src/init.c b/boards/px4/cannode-v1/src/init.c index e0fa4070e1..f342bd10a6 100644 --- a/boards/px4/cannode-v1/src/init.c +++ b/boards/px4/cannode-v1/src/init.c @@ -52,7 +52,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -68,8 +67,7 @@ #include #include -#include -#include +#include #if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) #endif @@ -161,24 +159,8 @@ __EXPORT int board_app_initialize(uintptr_t arg) { int result = OK; -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; diff --git a/boards/px4/esc-v1/src/CMakeLists.txt b/boards/px4/esc-v1/src/CMakeLists.txt index 5de38c9850..43bb52f158 100644 --- a/boards/px4/esc-v1/src/CMakeLists.txt +++ b/boards/px4/esc-v1/src/CMakeLists.txt @@ -39,7 +39,6 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE - nuttx_apps # up_cxxinitialize drivers__led # drv_led_start - parameters # param_init + px4_layer ) diff --git a/boards/px4/esc-v1/src/init.c b/boards/px4/esc-v1/src/init.c index b55c9aee02..da4be3572f 100644 --- a/boards/px4/esc-v1/src/init.c +++ b/boards/px4/esc-v1/src/init.c @@ -52,7 +52,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -68,8 +67,7 @@ #include #include -#include -#include +#include #if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) #endif @@ -156,24 +154,8 @@ __EXPORT int board_app_initialize(uintptr_t arg) int result = OK; -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; diff --git a/boards/px4/fmu-v2/src/CMakeLists.txt b/boards/px4/fmu-v2/src/CMakeLists.txt index d482115f8e..5af6af5d81 100644 --- a/boards/px4/fmu-v2/src/CMakeLists.txt +++ b/boards/px4/fmu-v2/src/CMakeLists.txt @@ -45,8 +45,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/px4/fmu-v2/src/init.c b/boards/px4/fmu-v2/src/init.c index 4ddf6bf384..c61a6467e5 100644 --- a/boards/px4/fmu-v2/src/init.c +++ b/boards/px4/fmu-v2/src/init.c @@ -55,7 +55,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -73,11 +72,8 @@ #include #include -#include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -385,14 +381,6 @@ static struct sdio_dev_s *sdio; __EXPORT int board_app_initialize(uintptr_t arg) { -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - up_cxxinitialize(); - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - /* Ensure the power is on 1 ms before we drive the GPIO pins */ px4_usleep(1000); @@ -454,10 +442,7 @@ __EXPORT int board_app_initialize(uintptr_t arg) /* configure SPI interfaces */ stm32_spiinitialize(); - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -465,11 +450,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/px4/fmu-v3/src/CMakeLists.txt b/boards/px4/fmu-v3/src/CMakeLists.txt index d482115f8e..5af6af5d81 100644 --- a/boards/px4/fmu-v3/src/CMakeLists.txt +++ b/boards/px4/fmu-v3/src/CMakeLists.txt @@ -45,8 +45,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/px4/fmu-v3/src/init.c b/boards/px4/fmu-v3/src/init.c index 49c37cc398..f39dd09a3e 100644 --- a/boards/px4/fmu-v3/src/init.c +++ b/boards/px4/fmu-v3/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -72,11 +71,8 @@ #include #include -#include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -384,14 +380,6 @@ static struct sdio_dev_s *sdio; __EXPORT int board_app_initialize(uintptr_t arg) { -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - up_cxxinitialize(); - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - /* Ensure the power is on 1 ms before we drive the GPIO pins */ usleep(1000); @@ -453,10 +441,7 @@ __EXPORT int board_app_initialize(uintptr_t arg) /* configure SPI interfaces */ stm32_spiinitialize(); - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -464,11 +449,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/px4/fmu-v4/src/CMakeLists.txt b/boards/px4/fmu-v4/src/CMakeLists.txt index 80cdd8bd7a..4fbd7b3f50 100644 --- a/boards/px4/fmu-v4/src/CMakeLists.txt +++ b/boards/px4/fmu-v4/src/CMakeLists.txt @@ -43,8 +43,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/px4/fmu-v4/src/init.c b/boards/px4/fmu-v4/src/init.c index 977b19b6c7..a1c35cc268 100644 --- a/boards/px4/fmu-v4/src/init.c +++ b/boards/px4/fmu-v4/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -73,11 +72,8 @@ #include #include -#include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -271,35 +267,13 @@ static struct sdio_dev_s *sdio; __EXPORT int board_app_initialize(uintptr_t arg) { - -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - - // Run C++ ctors before we go any further. - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - // Configure the high-resolution time/callout interface. - hrt_init(); - - param_init(); + px4_platform_init(); // Configure the DMA allocator. if (board_dma_alloc_init() < 0) { message("DMA alloc FAILED"); } - // Configure CPU load estimation. -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - // Set up the serial DMA polling. static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/px4/fmu-v4pro/src/CMakeLists.txt b/boards/px4/fmu-v4pro/src/CMakeLists.txt index 93fb657702..81a1b344af 100644 --- a/boards/px4/fmu-v4pro/src/CMakeLists.txt +++ b/boards/px4/fmu-v4pro/src/CMakeLists.txt @@ -42,8 +42,7 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/px4/fmu-v4pro/src/init.c b/boards/px4/fmu-v4pro/src/init.c index 33021963fe..104f1abc43 100644 --- a/boards/px4/fmu-v4pro/src/init.c +++ b/boards/px4/fmu-v4pro/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -73,11 +72,8 @@ #include #include -#include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -296,19 +292,6 @@ static struct sdio_dev_s *sdio; __EXPORT int board_app_initialize(uintptr_t arg) { -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif /* Bring up the Sensor power */ @@ -319,10 +302,7 @@ __EXPORT int board_app_initialize(uintptr_t arg) stm32_spiinitialize(); - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -330,11 +310,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/px4/fmu-v5/src/CMakeLists.txt b/boards/px4/fmu-v5/src/CMakeLists.txt index d5321b2ab2..517ef77f1b 100644 --- a/boards/px4/fmu-v5/src/CMakeLists.txt +++ b/boards/px4/fmu-v5/src/CMakeLists.txt @@ -35,17 +35,17 @@ px4_add_library(drivers_board #stm32_can.c # WIP init.c led.c + manifest.c sdio.c spi.c timer_config.c usb.c - manifest.c ) + target_link_libraries(drivers_board PRIVATE drivers__led # drv_led_start - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio - parameters # param_init + px4_layer ) diff --git a/boards/px4/fmu-v5/src/init.c b/boards/px4/fmu-v5/src/init.c index 50220b3d63..eda68ebda9 100644 --- a/boards/px4/fmu-v5/src/init.c +++ b/boards/px4/fmu-v5/src/init.c @@ -55,7 +55,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -75,11 +74,8 @@ #include #include -#include -#include -#include -#include +#include #include "up_internal.h" /**************************************************************************** @@ -273,22 +269,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) VDD_5V_RC_EN(true); VDD_5V_WIFI_EN(true); -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); if (OK == board_determine_hw_info()) { PX4_INFO("Rev 0x%1x : Ver 0x%1x %s", board_get_hw_revision(), board_get_hw_version(), board_get_hw_type_name()); @@ -297,7 +277,7 @@ __EXPORT int board_app_initialize(uintptr_t arg) PX4_ERR("Failed to read HW revision and version"); } - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -305,11 +285,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) PX4_ERR("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/px4/io-v2/src/init.c b/boards/px4/io-v2/src/init.c index 133cdb5619..12c0db3fc6 100644 --- a/boards/px4/io-v2/src/init.c +++ b/boards/px4/io-v2/src/init.c @@ -52,7 +52,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include diff --git a/boards/stm/32f4discovery/src/CMakeLists.txt b/boards/stm/32f4discovery/src/CMakeLists.txt index f7a0fb7991..166d048abb 100644 --- a/boards/stm/32f4discovery/src/CMakeLists.txt +++ b/boards/stm/32f4discovery/src/CMakeLists.txt @@ -40,9 +40,8 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio drivers__led # drv_led_start - parameters # param_init + px4_layer ) diff --git a/boards/stm/32f4discovery/src/init.c b/boards/stm/32f4discovery/src/init.c index 62234feb41..e84b102581 100644 --- a/boards/stm/32f4discovery/src/init.c +++ b/boards/stm/32f4discovery/src/init.c @@ -52,7 +52,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -70,9 +69,7 @@ #include #include -#include -#include -#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -148,30 +145,7 @@ stm32_boardinitialize(void) __EXPORT int board_app_initialize(uintptr_t arg) { - -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); - - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif + px4_platform_init(); /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; diff --git a/boards/stm/nucleo-F767ZI/src/CMakeLists.txt b/boards/stm/nucleo-F767ZI/src/CMakeLists.txt index 23cd00ee46..ae672f0e5f 100644 --- a/boards/stm/nucleo-F767ZI/src/CMakeLists.txt +++ b/boards/stm/nucleo-F767ZI/src/CMakeLists.txt @@ -43,9 +43,8 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE - nuttx_apps # up_cxxinitialize nuttx_arch # sdio nuttx_drivers # sdio drivers__led # drv_led_start - parameters # param_init + px4_layer ) diff --git a/boards/stm/nucleo-F767ZI/src/init.c b/boards/stm/nucleo-F767ZI/src/init.c index e35da860eb..8f43bd5717 100644 --- a/boards/stm/nucleo-F767ZI/src/init.c +++ b/boards/stm/nucleo-F767ZI/src/init.c @@ -54,7 +54,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -73,11 +72,8 @@ #include #include -#include -#include -#include -#include +#include #include "up_internal.h" /**************************************************************************** @@ -236,24 +232,8 @@ stm32_boardinitialize(void) __EXPORT int board_app_initialize(uintptr_t arg) { -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* configure the DMA allocator */ @@ -261,11 +241,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) message("DMA alloc FAILED"); } - /* configure CPU load estimation */ -#ifdef CONFIG_SCHED_INSTRUMENTATION - cpuload_initialize_once(); -#endif - /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; diff --git a/boards/thiemar/s2740vc-v1/src/CMakeLists.txt b/boards/thiemar/s2740vc-v1/src/CMakeLists.txt index a2010e27ed..bd2575a187 100644 --- a/boards/thiemar/s2740vc-v1/src/CMakeLists.txt +++ b/boards/thiemar/s2740vc-v1/src/CMakeLists.txt @@ -42,6 +42,5 @@ px4_add_library(drivers_board target_link_libraries(drivers_board PRIVATE - nuttx_apps # up_cxxinitialize drivers_arch ) diff --git a/boards/thiemar/s2740vc-v1/src/init.c b/boards/thiemar/s2740vc-v1/src/init.c index 80d83a7483..aa22cf5074 100644 --- a/boards/thiemar/s2740vc-v1/src/init.c +++ b/boards/thiemar/s2740vc-v1/src/init.c @@ -52,7 +52,6 @@ #include #include -#include "platform/cxxinitialize.h" #include #include #include @@ -68,8 +67,7 @@ #include #include -#include -#include +#include #if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) #endif @@ -148,24 +146,8 @@ __EXPORT int board_app_initialize(uintptr_t arg) { int result = OK; -#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) - /* run C++ ctors before we go any further */ - - up_cxxinitialize(); - -# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) -# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. -# endif - -#else -# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. -#endif - - /* configure the high-resolution time/callout interface */ - hrt_init(); - - param_init(); + px4_platform_init(); /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; diff --git a/cmake/px4_add_common_flags.cmake b/cmake/px4_add_common_flags.cmake index 00ee547bf9..0958b13465 100644 --- a/cmake/px4_add_common_flags.cmake +++ b/cmake/px4_add_common_flags.cmake @@ -176,6 +176,7 @@ function(px4_add_common_flags) ${PX4_SOURCE_DIR}/src/lib/matrix ${PX4_SOURCE_DIR}/src/modules ${PX4_SOURCE_DIR}/src/platforms + ${PX4_SOURCE_DIR}/src/platforms/common ) add_definitions( diff --git a/cmake/px4_add_module.cmake b/cmake/px4_add_module.cmake index 18f2a73c35..88ca3f698b 100644 --- a/cmake/px4_add_module.cmake +++ b/cmake/px4_add_module.cmake @@ -152,7 +152,7 @@ function(px4_add_module) add_dependencies(${MODULE} uorb_headers) if(NOT DYNAMIC) - target_link_libraries(${MODULE} PRIVATE prebuild_targets parameters_interface platforms__common px4_layer systemlib) + target_link_libraries(${MODULE} PRIVATE prebuild_targets parameters_interface px4_layer px4_platform systemlib) set_property(GLOBAL APPEND PROPERTY PX4_MODULE_LIBRARIES ${MODULE}) set_property(GLOBAL APPEND PROPERTY PX4_MODULE_PATHS ${CMAKE_CURRENT_SOURCE_DIR}) endif() diff --git a/platforms/nuttx/CMakeLists.txt b/platforms/nuttx/CMakeLists.txt index d7af383a83..df3898dcf8 100644 --- a/platforms/nuttx/CMakeLists.txt +++ b/platforms/nuttx/CMakeLists.txt @@ -96,6 +96,7 @@ target_link_libraries(px4 PRIVATE -Wl,--gc-sections -Wl,--start-group + drivers_boards_common_arch ${nuttx_libs} -Wl,--end-group diff --git a/platforms/nuttx/src/px4_layer/CMakeLists.txt b/platforms/nuttx/src/px4_layer/CMakeLists.txt index f78535ba01..6771b9ba27 100644 --- a/platforms/nuttx/src/px4_layer/CMakeLists.txt +++ b/platforms/nuttx/src/px4_layer/CMakeLists.txt @@ -37,8 +37,14 @@ if (NOT ${PX4_BOARD} MATCHES "px4_io") add_library(px4_layer px4_nuttx_tasks.c px4_nuttx_impl.cpp + px4_init.cpp ) - target_link_libraries(px4_layer PRIVATE nuttx_sched drivers_boards_common_arch) + target_link_libraries(px4_layer + PRIVATE + nuttx_apps # up_cxxinitialize + nuttx_sched + drivers_boards_common_arch + ) else() add_library(px4_layer ${PX4_SOURCE_DIR}/src/platforms/empty.c) endif() diff --git a/platforms/nuttx/src/px4_layer/px4_init.cpp b/platforms/nuttx/src/px4_layer/px4_init.cpp new file mode 100644 index 0000000000..8be6af0a68 --- /dev/null +++ b/platforms/nuttx/src/px4_layer/px4_init.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** + * + * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include "px4_init.h" + +#include +#include +#include +#include +#include + +#include "platform/cxxinitialize.h" + +int px4_platform_init(void) +{ + +#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) + /* run C++ ctors before we go any further */ + up_cxxinitialize(); + +# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) +# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. +# endif + +#else +# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. +#endif + + hrt_init(); + + param_init(); + + /* configure CPU load estimation */ +#ifdef CONFIG_SCHED_INSTRUMENTATION + cpuload_initialize_once(); +#endif + + return PX4_OK; +} diff --git a/platforms/posix/CMakeLists.txt b/platforms/posix/CMakeLists.txt index fc32b9125c..963c3639bd 100644 --- a/platforms/posix/CMakeLists.txt +++ b/platforms/posix/CMakeLists.txt @@ -62,6 +62,10 @@ else() ${df_driver_libs} df_driver_framework pthread m + + # horrible circular dependencies that need to be teased apart + px4_layer + px4_platform ) if (NOT APPLE) diff --git a/platforms/posix/src/px4_layer/CMakeLists.txt b/platforms/posix/src/px4_layer/CMakeLists.txt index 000706bc57..4df54c1545 100644 --- a/platforms/posix/src/px4_layer/CMakeLists.txt +++ b/platforms/posix/src/px4_layer/CMakeLists.txt @@ -48,6 +48,7 @@ add_library(px4_layer px4_posix_impl.cpp px4_posix_tasks.cpp px4_sem.cpp + px4_init.cpp lib_crc32.c drv_hrt.cpp ${SHMEM_SRCS} diff --git a/platforms/posix/src/px4_layer/px4_init.cpp b/platforms/posix/src/px4_layer/px4_init.cpp new file mode 100644 index 0000000000..6689420fec --- /dev/null +++ b/platforms/posix/src/px4_layer/px4_init.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** + * + * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include "px4_init.h" + +#include +#include +#include +#include + +int px4_platform_init(void) +{ + hrt_init(); + + param_init(); + + return PX4_OK; +} diff --git a/platforms/posix/src/px4_layer/px4_posix_impl.cpp b/platforms/posix/src/px4_layer/px4_posix_impl.cpp index 199626b7e9..9c1cf65042 100644 --- a/platforms/posix/src/px4_layer/px4_posix_impl.cpp +++ b/platforms/posix/src/px4_layer/px4_posix_impl.cpp @@ -51,6 +51,7 @@ #include #include "px4_time.h" #include +#include extern pthread_t _shell_task_id; @@ -69,10 +70,11 @@ void init_once() { _shell_task_id = pthread_self(); //printf("[init] shell id: %lu\n", (unsigned long)_shell_task_id); + work_queues_init(); hrt_work_queue_init(); - hrt_init(); - param_init(); + + px4_platform_init(); } void init(int argc, char *argv[], const char *app_name) diff --git a/platforms/qurt/src/px4_layer/CMakeLists.txt b/platforms/qurt/src/px4_layer/CMakeLists.txt index c9a4dac893..892a6e6684 100644 --- a/platforms/qurt/src/px4_layer/CMakeLists.txt +++ b/platforms/qurt/src/px4_layer/CMakeLists.txt @@ -44,6 +44,7 @@ set(QURT_LAYER_SRCS qurt_stubs.c main.cpp shmem_qurt.cpp + px4_init.cpp ) if ("${QURT_ENABLE_STUBS}" STREQUAL "1") diff --git a/platforms/qurt/src/px4_layer/px4_init.cpp b/platforms/qurt/src/px4_layer/px4_init.cpp new file mode 100644 index 0000000000..6689420fec --- /dev/null +++ b/platforms/qurt/src/px4_layer/px4_init.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** + * + * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include "px4_init.h" + +#include +#include +#include +#include + +int px4_platform_init(void) +{ + hrt_init(); + + param_init(); + + return PX4_OK; +} diff --git a/platforms/qurt/src/px4_layer/px4_qurt_impl.cpp b/platforms/qurt/src/px4_layer/px4_qurt_impl.cpp index 56515da2b1..699f0c9ee5 100644 --- a/platforms/qurt/src/px4_layer/px4_qurt_impl.cpp +++ b/platforms/qurt/src/px4_layer/px4_qurt_impl.cpp @@ -51,7 +51,7 @@ #include #include "hrt_work.h" #include "px4_log.h" - +#include //extern pthread_t _shell_task_id; @@ -105,8 +105,8 @@ void init_once(void) work_queues_init(); hrt_work_queue_init(); - hrt_init(); - param_init(); + + px4_platform_init(); } void init(int argc, char *argv[], const char *app_name) diff --git a/src/drivers/heater/CMakeLists.txt b/src/drivers/heater/CMakeLists.txt index 19cce63461..a81d51ee0b 100644 --- a/src/drivers/heater/CMakeLists.txt +++ b/src/drivers/heater/CMakeLists.txt @@ -37,7 +37,4 @@ px4_add_module( COMPILE_FLAGS SRCS heater.cpp - DEPENDS - platforms__common - modules__uORB ) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index c0734c4101..24d7ec156a 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -39,6 +39,7 @@ add_subdirectory(battery) add_subdirectory(bezier) add_subdirectory(cdev) add_subdirectory(circuit_breaker) +add_subdirectory(CollisionPrevention) add_subdirectory(controllib) add_subdirectory(conversion) add_subdirectory(drivers) @@ -56,4 +57,3 @@ add_subdirectory(terrain_estimation) add_subdirectory(tunes) add_subdirectory(version) add_subdirectory(WeatherVane) -add_subdirectory(CollisionPrevention) diff --git a/src/platforms/CMakeLists.txt b/src/platforms/CMakeLists.txt new file mode 100644 index 0000000000..a2a39344fc --- /dev/null +++ b/src/platforms/CMakeLists.txt @@ -0,0 +1,34 @@ +############################################################################ +# +# Copyright (c) 2019 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +add_subdirectory(common) diff --git a/src/platforms/common/CMakeLists.txt b/src/platforms/common/CMakeLists.txt index 5639e5b915..c7547e7be7 100644 --- a/src/platforms/common/CMakeLists.txt +++ b/src/platforms/common/CMakeLists.txt @@ -39,12 +39,12 @@ if (NOT "${PX4_PLATFORM}" MATCHES "qurt" AND NOT "${PX4_BOARD}" MATCHES "io-v2") ) endif() -px4_add_library(platforms__common +px4_add_library(px4_platform module.cpp px4_getopt.c px4_cli.cpp shutdown.cpp ${SRCS} ) - + add_subdirectory(work_queue) diff --git a/src/platforms/px4_init.h b/src/platforms/px4_init.h new file mode 100644 index 0000000000..77cebfadf4 --- /dev/null +++ b/src/platforms/px4_init.h @@ -0,0 +1,38 @@ +/**************************************************************************** + * + * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +__BEGIN_DECLS + +int px4_platform_init(void); + +__END_DECLS diff --git a/src/platforms/qurt/fc_addon/rc_receiver/CMakeLists.txt b/src/platforms/qurt/fc_addon/rc_receiver/CMakeLists.txt index 56425db054..3ef6cec84a 100644 --- a/src/platforms/qurt/fc_addon/rc_receiver/CMakeLists.txt +++ b/src/platforms/qurt/fc_addon/rc_receiver/CMakeLists.txt @@ -53,7 +53,5 @@ px4_add_module( SRCS rc_receiver_main.cpp rc_receiver_params.c - DEPENDS - platforms__common ) target_link_libraries(platforms__qurt__fc_addon__rc_receiver PRIVATE rc_receiver) diff --git a/src/systemcmds/motor_ramp/CMakeLists.txt b/src/systemcmds/motor_ramp/CMakeLists.txt index cf816ff1ef..da92a7bf5a 100644 --- a/src/systemcmds/motor_ramp/CMakeLists.txt +++ b/src/systemcmds/motor_ramp/CMakeLists.txt @@ -38,6 +38,4 @@ px4_add_module( -Wno-write-strings SRCS motor_ramp.cpp - DEPENDS - platforms__common ) diff --git a/src/systemcmds/shutdown/CMakeLists.txt b/src/systemcmds/shutdown/CMakeLists.txt index 5db004e76b..7f791b80c2 100644 --- a/src/systemcmds/shutdown/CMakeLists.txt +++ b/src/systemcmds/shutdown/CMakeLists.txt @@ -37,7 +37,4 @@ px4_add_module( COMPILE_FLAGS SRCS shutdown.c - DEPENDS - platforms__common ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix :