diff --git a/CMakeLists.txt b/CMakeLists.txt index f1c3d964735c..1dd809176940 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 80cdd8bd7a53..4fbd7b3f5055 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 a30f01f80a2a..de16f44165c8 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 4748379aead6..e67d62209644 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 a200e3a639b5..19a96ebe40b8 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 0a54e8eab599..db702078c809 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 807e86715567..a87f0c51c305 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 93fb657702de..81a1b344af91 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 0f25f1f9cdcb..069a32d2da09 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 360e888a5ee3..4a80e72d5bfa 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 fba376cbf4b2..1b98b2577061 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 4505fd107a4f..4e1d54ac1e8c 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 af82f8b5cef0..45b317ea6cec 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 93fb657702de..81a1b344af91 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 4ba03da03576..ad1bf89b8cee 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 c0ca8bf5d640..f1e4250994bd 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 245802a1fbe5..b4ae07bb0a1e 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 6c08faf65a25..c559f9b9adbd 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 c9fbdce894e9..9699f32291af 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 3d8de289cc2c..bf72b7efcd22 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 ec9b87d87b3a..846407ca7358 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 2fe828c7f0a3..f449efe9e068 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 e0fa4070e1ea..f342bd10a6fc 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 5de38c985020..43bb52f15885 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 b55c9aee02b5..da4be3572f78 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 d482115f8edb..5af6af5d81e5 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 4ddf6bf3848c..c61a6467e503 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 d482115f8edb..5af6af5d81e5 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 49c37cc398cb..f39dd09a3e68 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 80cdd8bd7a53..4fbd7b3f5055 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 977b19b6c736..a1c35cc268d6 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 93fb657702de..81a1b344af91 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 33021963fe4c..104f1abc43f3 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 d5321b2ab2ab..517ef77f1b27 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 50220b3d6309..eda68ebda947 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 133cdb561948..12c0db3fc62f 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 f7a0fb79912a..166d048abb1c 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 62234feb41d3..e84b102581eb 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 23cd00ee46bb..ae672f0e5f73 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 e35da860eb79..8f43bd571740 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 a2010e27edd3..bd2575a187ee 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 80d83a748341..aa22cf5074f8 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 00ee547bf98a..0958b13465c7 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 18f2a73c352e..88ca3f698b82 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 d7af383a83cf..df3898dcf85b 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 f78535ba013b..6771b9ba2793 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 000000000000..8be6af0a68ef --- /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 fc32b9125c7b..963c3639bd91 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 000706bc5739..4df54c15453e 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 000000000000..6689420fec05 --- /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 199626b7e9ef..9c1cf6504214 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 c9a4dac89353..892a6e668474 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 000000000000..6689420fec05 --- /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 56515da2b1bb..699f0c9ee506 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 19cce6346174..a81d51ee0bc5 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 c0734c41019d..24d7ec156aec 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 000000000000..a2a39344fc75 --- /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 5639e5b91591..c7547e7be789 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 000000000000..77cebfadf45d --- /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 56425db054f3..3ef6cec84a1e 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 cf816ff1ef57..da92a7bf5a40 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 5db004e76b6b..7f791b80c216 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 :