From 0de5868ee248af17d9ebb6a714c9632a93c9c647 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 8 Sep 2015 07:47:09 -0700 Subject: [PATCH 1/7] More qurt support The current approach of distributing submodule inclusion logic makes evert parent dir need to know about all build targets. This approach goes back to the previous way of centralizing the build dirs in a single file. Signed-off-by: Mark Charlebois --- cmake/px4_impl_qurt.cmake | 10 ++-- cmake/qurt/configs/config-qurt-hil.cmake | 2 +- src/CMakeLists.txt | 75 ++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 6 deletions(-) diff --git a/cmake/px4_impl_qurt.cmake b/cmake/px4_impl_qurt.cmake index 5337840727..ebfdc9f45b 100644 --- a/cmake/px4_impl_qurt.cmake +++ b/cmake/px4_impl_qurt.cmake @@ -236,7 +236,7 @@ endfunction() # # Usage: # px4_os_prebuild_targets( -# OUT +# OUT_MODULES # BOARD # ) # @@ -244,16 +244,16 @@ endfunction() # BOARD : board # # Output: -# MODULE_LIST : the updated module list +# OUT_MODULES : the updated module list # # Example: -# px4_qurt_add_modules(MODULE_LIST module_list BOARD hil) +# px4_qurt_add_modules(module_list "hil") # -function(px4_qurt_add_modules out_modules BOARD) +function(px4_qurt_add_modules OUT_MODULES BOARD) include(config-qurt-${BOARD}) set(config_modules) px4_set_config_modules(config_modules) - set(${out_modules} ${out_modules} ${config_modules} PARENT_SCOPE) + set(${OUT_MODULES} ${${OUT_MODULES}} ${config_modules} PARENT_SCOPE) endfunction() # vim: set noet fenc=utf-8 ff=unix nowrap: diff --git a/cmake/qurt/configs/config-qurt-hil.cmake b/cmake/qurt/configs/config-qurt-hil.cmake index 6c68043868..694aa8d0ea 100644 --- a/cmake/qurt/configs/config-qurt-hil.cmake +++ b/cmake/qurt/configs/config-qurt-hil.cmake @@ -77,7 +77,7 @@ function(px4_set_config_modules out_module_list) # # sources for muorb over fastrpc # - modules/muorb/adsp/ + modules/muorb/adsp ) message(STATUS "modules: ${config_module_list}") set(${out_module_list} ${config_module_list} PARENT_SCOPE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e69837558c..1bc4e961fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,6 @@ +#============================================================================= +# module subdirectories, need to include first +# add_subdirectory(./lib) add_subdirectory(./drivers) add_subdirectory(./platforms) @@ -5,5 +8,77 @@ add_subdirectory(./systemcmds) add_subdirectory(./examples) add_subdirectory(./modules) add_subdirectory(./firmware) +#============================================================================= +# executable +# + +if (${OS} STREQUAL "nuttx") + + # a list of modules that will be linked to main + set(module_list) + + if (${LABEL} STREQUAL "simple") + list(APPEND module_list + drivers__led + drivers__device + platforms__common + modules__systemlib + modules__uORB + examples__px4_simple_app + lib__mathlib__math__filter + lib__conversion + ) + endif() + + if (${LABEL} STREQUAL "simple") + list(APPEND module_list ${module_list_simple}) + endif() + + list(APPEND module_list + platforms__nuttx + platforms__nuttx__px4_layer + drivers__boards__px4fmu-v2 + drivers__stm32 + ) + + px4_nuttx_generate_builtin_commands( + OUT builtin_commands.c + MODULE_LIST ${module_list}) + + px4_nuttx_generate_romfs(OUT romfs.o + ROOT ROMFS/px4fmu_common) + + # add executable + add_executable(main builtin_commands.c romfs.o) + set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) + set(main_link_flags + "-T${nuttx_export_dir}/build/ld.script" + "-Wl,-Map=${CMAKE_BINARY_DIR}/main.map" + ) + px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") + set_target_properties(main PROPERTIES LINK_FLAGS ${main_link_flags}) + + target_link_libraries(main + -Wl,--start-group + ${module_list} + apps nuttx nosys m gcc + -Wl,--end-group) + + px4_nuttx_add_firmware(OUT ${CMAKE_CURRENT_BINARY_DIR}/fw_main.px4 + EXE ${CMAKE_CURRENT_BINARY_DIR}/main) + + px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD} + BUNDLE ${CMAKE_CURRENT_BINARY_DIR}/fw_main.px4) + +elseif(${OS} STREQUAL "qurt") + set(module_list) + px4_qurt_add_modules(module_list ${BOARD}) + message(STATUS "module list: ${module_list}") + + foreach(directory ${module_list}) + message(STATUS "directory: ${directory}") + add_subdirectory(${directory} EXCLUDE_FROM_ALL) + endforeach() +endif() # vim: set noet ft=cmake fenc=utf-8 ff=unix : From eb40a6de77a68e749dcb639df7236ef880ecb896 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 8 Sep 2015 13:16:12 -0700 Subject: [PATCH 2/7] cmake: qurt modules now build but do not link Managed to get the deps set up to build the qurt modules using a config file for the list of modules. NuttX link options are being set somewhere that break the qurt build Signed-off-by: Mark Charlebois --- cmake/px4_impl_qurt.cmake | 5 +- cmake/qurt/builtin_commands.cpp_stub | 84 +++++++++++++++++++++++++++ src/CMakeLists.txt | 33 +++++++++-- src/drivers/CMakeLists.txt | 1 + src/modules/muorb/adsp/CMakeLists.txt | 2 + src/modules/muorb/adsp/px4muorb.cpp | 5 +- src/modules/systemlib/perf_counter.c | 11 ++-- src/platforms/px4_log.h | 34 +++++------ 8 files changed, 145 insertions(+), 30 deletions(-) create mode 100644 cmake/qurt/builtin_commands.cpp_stub diff --git a/cmake/px4_impl_qurt.cmake b/cmake/px4_impl_qurt.cmake index ebfdc9f45b..e6df99cd27 100644 --- a/cmake/px4_impl_qurt.cmake +++ b/cmake/px4_impl_qurt.cmake @@ -98,13 +98,13 @@ function(px4_qurt_generate_builtin_commands) endforeach() if (MAIN) set(builtin_apps_string - "${builtin_apps_string}\t{\"${MAIN}\", ${PRIORITY}, ${STACK}, ${MAIN}_main},\n") + "${builtin_apps_string}\tapps[\"${MAIN}\"] = ${MAIN}_main;\n") set(builtin_apps_decl_string "${builtin_apps_decl_string}extern int ${MAIN}_main(int argc, char *argv[]);\n") math(EXPR command_count "${command_count}+1") endif() endforeach() - configure_file(${CMAKE_SOURCE_DIR}/cmake/builtin_commands.c.in + configure_file(${CMAKE_SOURCE_DIR}/cmake/qurt/builtin_commands.cpp_stub ${OUT}) endfunction() @@ -226,6 +226,7 @@ function(px4_os_prebuild_targets) ONE_VALUE OUT BOARD THREADS REQUIRED OUT BOARD ARGN ${ARGN}) + add_custom_target(${OUT}) endfunction() #============================================================================= diff --git a/cmake/qurt/builtin_commands.cpp_stub b/cmake/qurt/builtin_commands.cpp_stub new file mode 100644 index 0000000000..f4d240d529 --- /dev/null +++ b/cmake/qurt/builtin_commands.cpp_stub @@ -0,0 +1,84 @@ +/* builtin command list - automatically generated, do not edit */ +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; + +extern void px4_show_devices(void); + +extern "C" { +${builtin_apps_decl_string} +static int shutdown_main(int argc, char *argv[]); +static int list_tasks_main(int argc, char *argv[]); +static int list_files_main(int argc, char *argv[]); +static int list_devices_main(int argc, char *argv[]); +static int list_topics_main(int argc, char *argv[]); +static int sleep_main(int argc, char *argv[]); +} + + +void init_app_map(map &apps) +{ +${builtin_apps_string} + apps["shutdown"] = shutdown_main; + apps["list_tasks"] = list_tasks_main; + apps["list_files"] = list_files_main; + apps["list_devices"] = list_devices_main; + apps["list_topics"] = list_topics_main; + apps["sleep"] = sleep_main; +} + +void list_builtins(map &apps) +{ + printf("Builtin Commands:\\n"); + for (map::iterator it=apps.begin(); it!=apps.end(); ++it) + printf("\\t%s\\n", (it->first).c_str()); +} + +static int shutdown_main(int argc, char *argv[]) +{ + printf("Shutting down\\n"); + exit(0); +} + +static int list_tasks_main(int argc, char *argv[]) +{ + px4_show_tasks(); + return 0; +} + +static int list_devices_main(int argc, char *argv[]) +{ + px4_show_devices(); + return 0; +} + +static int list_topics_main(int argc, char *argv[]) +{ + px4_show_topics(); + return 0; +} +static int list_files_main(int argc, char *argv[]) +{ + px4_show_files(); + return 0; +} +static int sleep_main(int argc, char *argv[]) +{ + if (argc != 2) { + PX4_WARN( "Usage: sleep " ); + return 1; + } + + unsigned long usecs = ( (unsigned long) atol( argv[1] ) ) * 1000 * 1000; + PX4_WARN("Sleeping for %s, %ld",argv[1],usecs); + usleep( usecs ); + return 0; +} + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1bc4e961fb..c76007edd0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,12 @@ add_subdirectory(./firmware) # executable # +function(px4_mangle_name dirname newname) + set(tmp) + string(REPLACE "/" "__" tmp ${dirname}) + set(${newname} ${tmp} PARENT_SCOPE) +endfunction() + if (${OS} STREQUAL "nuttx") # a list of modules that will be linked to main @@ -71,14 +77,33 @@ if (${OS} STREQUAL "nuttx") BUNDLE ${CMAKE_CURRENT_BINARY_DIR}/fw_main.px4) elseif(${OS} STREQUAL "qurt") + set(module_dir_list) set(module_list) - px4_qurt_add_modules(module_list ${BOARD}) - message(STATUS "module list: ${module_list}") + px4_qurt_add_modules(module_dir_list ${BOARD}) + message(STATUS "module list: ${module_dir_list}") - foreach(directory ${module_list}) + foreach(directory ${module_dir_list}) message(STATUS "directory: ${directory}") - add_subdirectory(${directory} EXCLUDE_FROM_ALL) + px4_mangle_name(${directory} mangled_name) + list(APPEND module_list + ${mangled_name}) endforeach() + px4_qurt_generate_builtin_commands( + OUT builtin_commands.cpp + MODULE_LIST ${module_list}) + + # FIXME @jgoppert - how to work around issues like this? + # Without changing global variables? + # Clear -rdynamic flag which fails for hexagon + set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") + set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + + add_executable(main builtin_commands.cpp) + target_link_libraries(main + -Wl,--start-group + ${module_list} + apps nuttx nosys m gcc + -Wl,--end-group) endif() # vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/CMakeLists.txt b/src/drivers/CMakeLists.txt index 7a504e9326..a435bdc94d 100644 --- a/src/drivers/CMakeLists.txt +++ b/src/drivers/CMakeLists.txt @@ -8,6 +8,7 @@ set(directories ./boards/px4io-v1 ./boards/px4fmu-v1 ./boards/aerocore + ./boards/sitl ./mpu6000 ./gimbal ./camera_trigger diff --git a/src/modules/muorb/adsp/CMakeLists.txt b/src/modules/muorb/adsp/CMakeLists.txt index ade682dbfd..185264a85f 100644 --- a/src/modules/muorb/adsp/CMakeLists.txt +++ b/src/modules/muorb/adsp/CMakeLists.txt @@ -30,6 +30,8 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ +include_directories("../../uORB") + px4_add_module( MODULE modules__muorb__adsp COMPILE_FLAGS diff --git a/src/modules/muorb/adsp/px4muorb.cpp b/src/modules/muorb/adsp/px4muorb.cpp index e6cad0aba3..53318f8e49 100644 --- a/src/modules/muorb/adsp/px4muorb.cpp +++ b/src/modules/muorb/adsp/px4muorb.cpp @@ -31,7 +31,7 @@ * ****************************************************************************/ #include "px4muorb.hpp" -#include "qurt.h" +//#include "qurt.h" #include "uORBFastRpcChannel.hpp" #include "uORBManager.hpp" @@ -44,12 +44,11 @@ #include "uORB/topics/sensor_combined.h" #include "uORB.h" -#include "HAP_power.h" - #define _ENABLE_MUORB 1 extern "C" { int dspal_main(int argc, const char *argv[]); +void HAP_power_request(int a, int b, int c); }; diff --git a/src/modules/systemlib/perf_counter.c b/src/modules/systemlib/perf_counter.c index 8ec9b1a444..105b958898 100644 --- a/src/modules/systemlib/perf_counter.c +++ b/src/modules/systemlib/perf_counter.c @@ -47,6 +47,9 @@ #ifdef __PX4_QURT #define dprintf(...) +#define ddeclare(...) +#else +#define ddeclare(...) __VA_ARGS_ #endif /** @@ -417,8 +420,8 @@ perf_print_counter_fd(int fd, perf_counter_t handle) break; case PC_ELAPSED: { - struct perf_ctr_elapsed *pce = (struct perf_ctr_elapsed *)handle; - float rms = sqrtf(pce->M2 / (pce->event_count - 1)); + ddeclare(struct perf_ctr_elapsed *pce = (struct perf_ctr_elapsed *)handle;) + ddeclare(float rms = sqrtf(pce->M2 / (pce->event_count - 1));) dprintf(fd, "%s: %llu events, %llu overruns, %lluus elapsed, %lluus avg, min %lluus max %lluus %5.3fus rms\n", handle->name, (unsigned long long)pce->event_count, @@ -432,8 +435,8 @@ perf_print_counter_fd(int fd, perf_counter_t handle) } case PC_INTERVAL: { - struct perf_ctr_interval *pci = (struct perf_ctr_interval *)handle; - float rms = sqrtf(pci->M2 / (pci->event_count - 1)); + ddeclare(struct perf_ctr_interval *pci = (struct perf_ctr_interval *)handle;) + ddeclare(float rms = sqrtf(pci->M2 / (pci->event_count - 1));) dprintf(fd, "%s: %llu events, %lluus avg, min %lluus max %lluus %5.3fus rms\n", handle->name, diff --git a/src/platforms/px4_log.h b/src/platforms/px4_log.h index a8208313e6..e6540c20d2 100644 --- a/src/platforms/px4_log.h +++ b/src/platforms/px4_log.h @@ -70,33 +70,33 @@ static inline void do_nothing(int level, ...) /**************************************************************************** * Messages that should never be filtered or compiled out ****************************************************************************/ -#define PX4_LOG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ALWAYS, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_INFO(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ALWAYS, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_LOG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ALWAYS, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_INFO(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ALWAYS, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #if defined(TRACE_BUILD) /**************************************************************************** * Extremely Verbose settings for a Trace build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_DEBUG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_DEBUG, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_DEBUG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_DEBUG, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #elif defined(DEBUG_BUILD) /**************************************************************************** * Verbose settings for a Debug build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_DEBUG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_DEBUG, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_DEBUG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_DEBUG, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #elif defined(RELEASE_BUILD) /**************************************************************************** * Non-verbose settings for a Release build to minimize strings in build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #define PX4_WARN(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_WARN, FMT, ##__VA_ARGS__) #define PX4_DEBUG(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_DEBUG, FMT, ##__VA_ARGS__) @@ -104,14 +104,14 @@ static inline void do_nothing(int level, ...) /**************************************************************************** * Medium verbose settings for a default build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #define PX4_DEBUG(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_DEBUG, FMT, ##__VA_ARGS__) #endif -#define PX4_LOG_NAMED(name, FMT, ...) qurt_log( _PX4_LOG_LEVEL_ALWAYS, __FILENAME__, __LINE__, "%s " FMT, name, ##__VA_ARGS__) -#define PX4_LOG_NAMED_COND(name, cond, FMT, ...) if( cond ) qurt_log( _PX4_LOG_LEVEL_ALWAYS, __FILENAME__, __LINE__, "%s " FMT, name, ##__VA_ARGS__) +#define PX4_LOG_NAMED(name, FMT, ...) qurt_log( _PX4_LOG_LEVEL_ALWAYS, __FILE__, __LINE__, "%s " FMT, name, ##__VA_ARGS__) +#define PX4_LOG_NAMED_COND(name, cond, FMT, ...) if( cond ) qurt_log( _PX4_LOG_LEVEL_ALWAYS, __FILE__, __LINE__, "%s " FMT, name, ##__VA_ARGS__) #else From 29520dc5b14ef50c44ee77bb7c81be464bb9c315 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 8 Sep 2015 13:42:41 -0700 Subject: [PATCH 3/7] Fixed nuttx libs in qurt build Signed-off-by: Mark Charlebois --- src/CMakeLists.txt | 16 +++++++++++----- src/platforms/qurt/px4_layer/qurt_stubs.c | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c76007edd0..470e99aa30 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,6 +77,11 @@ if (${OS} STREQUAL "nuttx") BUNDLE ${CMAKE_CURRENT_BINARY_DIR}/fw_main.px4) elseif(${OS} STREQUAL "qurt") + + set(V_ARCH v5) + set(HEXAGON_TOOLS_ROOT /opt/6.4.03) + set(TOOLSLIB + ${HEXAGON_TOOLS_ROOT}/dinkumware/lib/${V_ARCH}/G0) set(module_dir_list) set(module_list) px4_qurt_add_modules(module_dir_list ${BOARD}) @@ -98,12 +103,13 @@ elseif(${OS} STREQUAL "qurt") set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") - add_executable(main builtin_commands.cpp) - target_link_libraries(main - -Wl,--start-group + add_executable(mainapp builtin_commands.cpp) + target_link_libraries(mainapp + -Wl,--whole-archive ${module_list} - apps nuttx nosys m gcc - -Wl,--end-group) + m + -Wl,--no-whole-archive + -Wl,${TOOLSLIB}/pic/libstdc++.a) endif() # vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/qurt/px4_layer/qurt_stubs.c b/src/platforms/qurt/px4_layer/qurt_stubs.c index 937393bc65..e8c08f2d14 100644 --- a/src/platforms/qurt/px4_layer/qurt_stubs.c +++ b/src/platforms/qurt/px4_layer/qurt_stubs.c @@ -60,6 +60,7 @@ void _Parse_csd( void ) block_indefinite(); } +#if 0 void _Locksyslock( int x ) { PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); @@ -70,7 +71,7 @@ void _Unlocksyslock( int x ) { PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); block_indefinite(); -} +#endif} void _Valbytes( void ) { From c16c6a00e35cb5278dc89fc6e79d4fc3e72ed8ec Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 8 Sep 2015 13:54:43 -0700 Subject: [PATCH 4/7] Clean up location of nuttx specific template Signed-off-by: Mark Charlebois --- CMakeLists.txt | 1 + cmake/{ => nuttx}/builtin_commands.c.in | 0 cmake/{ => nuttx}/px4_impl_nuttx.cmake | 2 +- cmake/{ => qurt}/px4_impl_qurt.cmake | 0 src/modules/systemlib/perf_counter.c | 2 +- 5 files changed, 3 insertions(+), 2 deletions(-) rename cmake/{ => nuttx}/builtin_commands.c.in (100%) rename cmake/{ => nuttx}/px4_impl_nuttx.cmake (99%) rename cmake/{ => qurt}/px4_impl_qurt.cmake (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ca1287d16..cbec24e59f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,6 +111,7 @@ set(package-contact "px4users@googlegroups.com") # set module path list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/${OS}) # prefer board implementation module over os implmementation module set(board_impl_module px4_impl_${OS}_${BOARD}) diff --git a/cmake/builtin_commands.c.in b/cmake/nuttx/builtin_commands.c.in similarity index 100% rename from cmake/builtin_commands.c.in rename to cmake/nuttx/builtin_commands.c.in diff --git a/cmake/px4_impl_nuttx.cmake b/cmake/nuttx/px4_impl_nuttx.cmake similarity index 99% rename from cmake/px4_impl_nuttx.cmake rename to cmake/nuttx/px4_impl_nuttx.cmake index 8f36855bd9..4e4724b184 100644 --- a/cmake/px4_impl_nuttx.cmake +++ b/cmake/nuttx/px4_impl_nuttx.cmake @@ -143,7 +143,7 @@ function(px4_nuttx_generate_builtin_commands) math(EXPR command_count "${command_count}+1") endif() endforeach() - configure_file(${CMAKE_SOURCE_DIR}/cmake/builtin_commands.c.in + configure_file(${CMAKE_SOURCE_DIR}/cmake/nuttx/builtin_commands.c.in ${OUT}) endfunction() diff --git a/cmake/px4_impl_qurt.cmake b/cmake/qurt/px4_impl_qurt.cmake similarity index 100% rename from cmake/px4_impl_qurt.cmake rename to cmake/qurt/px4_impl_qurt.cmake diff --git a/src/modules/systemlib/perf_counter.c b/src/modules/systemlib/perf_counter.c index 105b958898..a9d9db9748 100644 --- a/src/modules/systemlib/perf_counter.c +++ b/src/modules/systemlib/perf_counter.c @@ -49,7 +49,7 @@ #define dprintf(...) #define ddeclare(...) #else -#define ddeclare(...) __VA_ARGS_ +#define ddeclare(...) __VA_ARGS__ #endif /** From d343edaa66881f51c712bfc8aed62adbc1a3c228 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 8 Sep 2015 14:13:54 -0700 Subject: [PATCH 5/7] Moved qurt changes to src/firmware/qurt/CMakeLists.txt The src/CMakeLists.txt are now in src/firmware/${OS}/CMakeLists.txt Signed-off-by: Mark Charlebois --- src/firmware/qurt/CMakeLists.txt | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/firmware/qurt/CMakeLists.txt b/src/firmware/qurt/CMakeLists.txt index b9b3f37101..9a49794627 100644 --- a/src/firmware/qurt/CMakeLists.txt +++ b/src/firmware/qurt/CMakeLists.txt @@ -1,11 +1,34 @@ +set(V_ARCH v5) +set(HEXAGON_TOOLS_ROOT /opt/6.4.03) +set(TOOLSLIB + ${HEXAGON_TOOLS_ROOT}/dinkumware/lib/${V_ARCH}/G0) +set(module_dir_list) set(module_list) -px4_qurt_add_modules(module_list ${BOARD}) -message(STATUS "module list: ${module_list}") +px4_qurt_add_modules(module_dir_list ${BOARD}) +message(STATUS "module list: ${module_dir_list}") +foreach(directory ${module_dir_list}) + message(STATUS "directory: ${directory}") + px4_mangle_name(${directory} mangled_name) + list(APPEND module_list + ${mangled_name}) +endforeach() px4_qurt_generate_builtin_commands( - OUT builtin_commands.c + OUT builtin_commands.cpp MODULE_LIST ${module_list}) -add_executable(firmware_qurt builtin_commands.c) +# FIXME @jgoppert - how to work around issues like this? +# Without changing global variables? +# Clear -rdynamic flag which fails for hexagon +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +add_executable(mainapp builtin_commands.cpp) +target_link_libraries(mainapp + -Wl,--whole-archive + ${module_list} + m + -Wl,--no-whole-archive + -Wl,${TOOLSLIB}/pic/libstdc++.a) # vim: set noet ft=cmake fenc=utf-8 ff=unix : From e82ea34e51c973ef2b1c8b1e0bd9631019b68c80 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 8 Sep 2015 14:19:29 -0700 Subject: [PATCH 6/7] Changed builtin_commands.cpp_stub to builtin_commands.cpp_in Signed-off-by: Mark Charlebois --- .../qurt/{builtin_commands.cpp_stub => builtin_commands.cpp_in} | 0 cmake/qurt/px4_impl_qurt.cmake | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename cmake/qurt/{builtin_commands.cpp_stub => builtin_commands.cpp_in} (100%) diff --git a/cmake/qurt/builtin_commands.cpp_stub b/cmake/qurt/builtin_commands.cpp_in similarity index 100% rename from cmake/qurt/builtin_commands.cpp_stub rename to cmake/qurt/builtin_commands.cpp_in diff --git a/cmake/qurt/px4_impl_qurt.cmake b/cmake/qurt/px4_impl_qurt.cmake index e6df99cd27..1874787f57 100644 --- a/cmake/qurt/px4_impl_qurt.cmake +++ b/cmake/qurt/px4_impl_qurt.cmake @@ -104,7 +104,7 @@ function(px4_qurt_generate_builtin_commands) math(EXPR command_count "${command_count}+1") endif() endforeach() - configure_file(${CMAKE_SOURCE_DIR}/cmake/qurt/builtin_commands.cpp_stub + configure_file(${CMAKE_SOURCE_DIR}/cmake/qurt/builtin_commands.cpp_in ${OUT}) endfunction() From 4885bbbdd18ec13dadb919e9dc15ccdeb28d134e Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 8 Sep 2015 14:36:09 -0700 Subject: [PATCH 7/7] Added px4_mangle_name function to px4_base.cmake Signed-off-by: Mark Charlebois --- cmake/px4_base.cmake | 25 ++++++++ src/CMakeLists.txt | 106 ------------------------------- src/firmware/qurt/CMakeLists.txt | 2 + 3 files changed, 27 insertions(+), 106 deletions(-) diff --git a/cmake/px4_base.cmake b/cmake/px4_base.cmake index cf808a8152..888011fe76 100644 --- a/cmake/px4_base.cmake +++ b/cmake/px4_base.cmake @@ -610,4 +610,29 @@ function(px4_add_common_flags) endfunction() +#============================================================================= +# +# px4_mangle_name +# +# Convert a path name to a module name +# +# Usage: +# px4_mangle_name(dirname newname) +# +# Input: +# dirname : path to module dir +# +# Output: +# newname : module name +# +# Example: +# px4_mangle_name(${dirpath} mangled_name) +# message(STATUS "module name is ${mangled_name}") +# +function(px4_mangle_name dirname newname) + set(tmp) + string(REPLACE "/" "__" tmp ${dirname}) + set(${newname} ${tmp} PARENT_SCOPE) +endfunction() + # vim: set noet fenc=utf-8 ff=unix nowrap: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 470e99aa30..e69837558c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,3 @@ -#============================================================================= -# module subdirectories, need to include first -# add_subdirectory(./lib) add_subdirectory(./drivers) add_subdirectory(./platforms) @@ -8,108 +5,5 @@ add_subdirectory(./systemcmds) add_subdirectory(./examples) add_subdirectory(./modules) add_subdirectory(./firmware) -#============================================================================= -# executable -# - -function(px4_mangle_name dirname newname) - set(tmp) - string(REPLACE "/" "__" tmp ${dirname}) - set(${newname} ${tmp} PARENT_SCOPE) -endfunction() - -if (${OS} STREQUAL "nuttx") - - # a list of modules that will be linked to main - set(module_list) - - if (${LABEL} STREQUAL "simple") - list(APPEND module_list - drivers__led - drivers__device - platforms__common - modules__systemlib - modules__uORB - examples__px4_simple_app - lib__mathlib__math__filter - lib__conversion - ) - endif() - - if (${LABEL} STREQUAL "simple") - list(APPEND module_list ${module_list_simple}) - endif() - - list(APPEND module_list - platforms__nuttx - platforms__nuttx__px4_layer - drivers__boards__px4fmu-v2 - drivers__stm32 - ) - - px4_nuttx_generate_builtin_commands( - OUT builtin_commands.c - MODULE_LIST ${module_list}) - - px4_nuttx_generate_romfs(OUT romfs.o - ROOT ROMFS/px4fmu_common) - - # add executable - add_executable(main builtin_commands.c romfs.o) - set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) - set(main_link_flags - "-T${nuttx_export_dir}/build/ld.script" - "-Wl,-Map=${CMAKE_BINARY_DIR}/main.map" - ) - px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") - set_target_properties(main PROPERTIES LINK_FLAGS ${main_link_flags}) - - target_link_libraries(main - -Wl,--start-group - ${module_list} - apps nuttx nosys m gcc - -Wl,--end-group) - - px4_nuttx_add_firmware(OUT ${CMAKE_CURRENT_BINARY_DIR}/fw_main.px4 - EXE ${CMAKE_CURRENT_BINARY_DIR}/main) - - px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD} - BUNDLE ${CMAKE_CURRENT_BINARY_DIR}/fw_main.px4) - -elseif(${OS} STREQUAL "qurt") - - set(V_ARCH v5) - set(HEXAGON_TOOLS_ROOT /opt/6.4.03) - set(TOOLSLIB - ${HEXAGON_TOOLS_ROOT}/dinkumware/lib/${V_ARCH}/G0) - set(module_dir_list) - set(module_list) - px4_qurt_add_modules(module_dir_list ${BOARD}) - message(STATUS "module list: ${module_dir_list}") - - foreach(directory ${module_dir_list}) - message(STATUS "directory: ${directory}") - px4_mangle_name(${directory} mangled_name) - list(APPEND module_list - ${mangled_name}) - endforeach() - px4_qurt_generate_builtin_commands( - OUT builtin_commands.cpp - MODULE_LIST ${module_list}) - - # FIXME @jgoppert - how to work around issues like this? - # Without changing global variables? - # Clear -rdynamic flag which fails for hexagon - set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") - set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") - - add_executable(mainapp builtin_commands.cpp) - target_link_libraries(mainapp - -Wl,--whole-archive - ${module_list} - m - -Wl,--no-whole-archive - -Wl,${TOOLSLIB}/pic/libstdc++.a) -endif() # vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/firmware/qurt/CMakeLists.txt b/src/firmware/qurt/CMakeLists.txt index 9a49794627..fa0720c743 100644 --- a/src/firmware/qurt/CMakeLists.txt +++ b/src/firmware/qurt/CMakeLists.txt @@ -1,3 +1,5 @@ +include(px4_base) + set(V_ARCH v5) set(HEXAGON_TOOLS_ROOT /opt/6.4.03) set(TOOLSLIB