diff --git a/CMakeLists.txt b/CMakeLists.txt index e547333c87..9f04b1fdd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,7 @@ file(GLOB_RECURSE configs RELATIVE cmake/configs "cmake/configs/*.cmake") set_property(CACHE CONFIG PROPERTY STRINGS ${configs}) set(THREADS "4" CACHE STRING "number of threads to use for external build processes") +set(DEBUG_PORT "/dev/ttyACM0" CACHE STRING "debugging port") #============================================================================= # configuration diff --git a/Makefile b/Makefile index 4f60d249fb..b1dd099eb6 100644 --- a/Makefile +++ b/Makefile @@ -54,16 +54,22 @@ # rest are arguments to pass to the makefile generated # by cmake in the subdirectory ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) -j ?= 1 +j ?= 4 # Functions # -------------------------------------------------------------------- -# define a make function to describe how to build a cmake config +# describe how to build a cmake config define cmake-build +mkdir -p $(PWD)/build_$@ && cd $(PWD)/build_$@ && cmake .. -DCONFIG=$(1) -+make -C $(PWD)/build_$@ --no-print-directory $(ARGS) ++make -j$(j) -C $(PWD)/build_$@ --no-print-directory $(ARGS) endef +# create empty targets to avoid msgs for targets passed to cmake +define cmake-targ +$(1): + @# +.PHONY: $(1) +endef # ADD CONFIGS HERE # -------------------------------------------------------------------- @@ -104,12 +110,10 @@ clean: rm -rf build_*/ # targets handled by cmake -test: ; -upload: ; -package: ; -package_source: ; +cmake_targets = test upload package package_source debug check_weak +$(foreach targ,$(cmake_targets),$(eval $(call cmake-targ,$(targ)))) -.PHONY: clean test upload package package_source +.PHONY: clean CONFIGS:=$(shell ls cmake/configs | sed -e "s~.*/~~" | sed -e "s~\..*~~") diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index be3d449710..7e8ddabee0 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -551,6 +551,7 @@ function(px4_add_common_flags) endif() set(c_compile_flags + -g3 -std=gnu99 -fno-common ) @@ -559,6 +560,7 @@ function(px4_add_common_flags) -Wno-missing-field-initializers ) set(cxx_compile_flags + -g3 -fno-exceptions -fno-rtti -std=gnu++0x diff --git a/cmake/nuttx/bin_to_obj.py b/cmake/nuttx/bin_to_obj.py index 07c81edcde..a4ad3d94df 100755 --- a/cmake/nuttx/bin_to_obj.py +++ b/cmake/nuttx/bin_to_obj.py @@ -55,10 +55,19 @@ run_cmd("{ld:s} -r -o {obj:s}.bin.o {obj:s}.c.o -b binary {in_bin:s}", # get size of image stdout = run_cmd("{nm:s} -p --radix=x {obj:s}.bin.o", locals()) -re_size = re.compile("(^[0-9A-Fa-f]*) .*{sym:s}_size".format( - **locals())) -size_match = re.match(re_size, stdout) -size = size_match.group(1) +re_string = r"^([0-9A-F-a-f]+) .*{sym:s}_size\n".format(**locals()) +re_size = re.compile(re_string, re.MULTILINE) +size_match = re.search(re_size, stdout) +try: + size = size_match.group(1) +except AttributeError as e: + raise RuntimeError("{:s}\nre:{:s}\n{:s}".format( + e, re_string, stdout)) +except IndexError as e: + group0 = size_match.group(0) + raise RuntimeError("{:s}\ngroup 0:{:s}\n{:s}".format( + e, group0, stdout)) + #print("romfs size: ", size) # write size to file diff --git a/cmake/toolchains/Toolchain-arm-none-eabi.cmake b/cmake/toolchains/Toolchain-arm-none-eabi.cmake index 13514080ad..5fab42f3c2 100644 --- a/cmake/toolchains/Toolchain-arm-none-eabi.cmake +++ b/cmake/toolchains/Toolchain-arm-none-eabi.cmake @@ -37,7 +37,7 @@ endif() cmake_force_cxx_compiler(${CXX_COMPILER} GNU) # compiler tools -foreach(tool objcopy nm ld) +foreach(tool objcopy nm ld gdb) string(TOUPPER ${tool} TOOL) find_program(${TOOL} arm-none-eabi-${tool}) if(NOT ${TOOL}) diff --git a/src/drivers/boards/aerocore/aerocore_spi.c b/src/drivers/boards/aerocore/aerocore_spi.c index 5a4dd15b26..1ce3f35f88 100644 --- a/src/drivers/boards/aerocore/aerocore_spi.c +++ b/src/drivers/boards/aerocore/aerocore_spi.c @@ -67,7 +67,7 @@ * ************************************************************************************/ -__EXPORT void weak_function stm32_spiinitialize(void) +__EXPORT void stm32_spiinitialize(void) { #ifdef CONFIG_STM32_SPI1 stm32_configgpio(GPIO_SPI1_NSS); diff --git a/src/drivers/boards/px4fmu-v1/px4fmu_spi.c b/src/drivers/boards/px4fmu-v1/px4fmu_spi.c index 8ef17c36ed..2a444796ff 100644 --- a/src/drivers/boards/px4fmu-v1/px4fmu_spi.c +++ b/src/drivers/boards/px4fmu-v1/px4fmu_spi.c @@ -67,7 +67,7 @@ * ************************************************************************************/ -__EXPORT void weak_function stm32_spiinitialize(void) +__EXPORT void stm32_spiinitialize(void) { stm32_configgpio(GPIO_SPI_CS_GYRO); stm32_configgpio(GPIO_SPI_CS_ACCEL); diff --git a/src/drivers/boards/px4fmu-v2/px4fmu_spi.c b/src/drivers/boards/px4fmu-v2/px4fmu_spi.c index 64b9926b8d..a380e05bd5 100644 --- a/src/drivers/boards/px4fmu-v2/px4fmu_spi.c +++ b/src/drivers/boards/px4fmu-v2/px4fmu_spi.c @@ -67,7 +67,7 @@ * ************************************************************************************/ -__EXPORT void weak_function stm32_spiinitialize(void) +__EXPORT void stm32_spiinitialize(void) { #ifdef CONFIG_STM32_SPI1 stm32_configgpio(GPIO_SPI_CS_GYRO); diff --git a/src/drivers/hmc5883/hmc5883.h b/src/drivers/hmc5883/hmc5883.h index 9607fe6149..4cef0aa8cf 100644 --- a/src/drivers/hmc5883/hmc5883.h +++ b/src/drivers/hmc5883/hmc5883.h @@ -48,6 +48,6 @@ #define ID_C_WHO_AM_I '3' /* interface factories */ -extern device::Device *HMC5883_SPI_interface(int bus) weak_function; -extern device::Device *HMC5883_I2C_interface(int bus) weak_function; +extern device::Device *HMC5883_SPI_interface(int bus); +extern device::Device *HMC5883_I2C_interface(int bus); typedef device::Device *(*HMC5883_constructor)(int); diff --git a/src/drivers/ms5611/ms5611.h b/src/drivers/ms5611/ms5611.h index a7e305b2aa..cc3e4c5920 100644 --- a/src/drivers/ms5611/ms5611.h +++ b/src/drivers/ms5611/ms5611.h @@ -80,7 +80,7 @@ extern bool crc4(uint16_t *n_prom); } /* namespace */ /* interface factories */ -extern device::Device *MS5611_spi_interface(ms5611::prom_u &prom_buf, uint8_t busnum) __attribute__((weak)); -extern device::Device *MS5611_i2c_interface(ms5611::prom_u &prom_buf, uint8_t busnum) __attribute__((weak)); -extern device::Device *MS5611_sim_interface(ms5611::prom_u &prom_buf, uint8_t busnum) __attribute__((weak)); +extern device::Device *MS5611_spi_interface(ms5611::prom_u &prom_buf, uint8_t busnum); +extern device::Device *MS5611_i2c_interface(ms5611::prom_u &prom_buf, uint8_t busnum); +extern device::Device *MS5611_sim_interface(ms5611::prom_u &prom_buf, uint8_t busnum); typedef device::Device *(*MS5611_constructor)(ms5611::prom_u &prom_buf, uint8_t busnum); diff --git a/src/firmware/nuttx/CMakeLists.txt b/src/firmware/nuttx/CMakeLists.txt index 83d4a8ea14..8cf5e64b3b 100644 --- a/src/firmware/nuttx/CMakeLists.txt +++ b/src/firmware/nuttx/CMakeLists.txt @@ -31,11 +31,24 @@ target_link_libraries(firmware_nuttx set(fw_file ${CMAKE_CURRENT_BINARY_DIR}/${OS}-${BOARD}-${LABEL}.px4) +add_custom_target(check_weak + COMMAND ${NM} firmware_nuttx | grep " w " + DEPENDS firmware_nuttx + ) + px4_nuttx_add_firmware(OUT ${fw_file} - EXE ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx + EXE firmware_nuttx ${config_firmware_options} ) +configure_file(gdbinit.in .gdbinit) + +add_custom_target(debug + COMMAND ${GDB} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx + DEPENDS firmware_nuttx + ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) + px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD} BUNDLE ${fw_file}) diff --git a/src/firmware/nuttx/gdbinit.in b/src/firmware/nuttx/gdbinit.in new file mode 100644 index 0000000000..a927caeed0 --- /dev/null +++ b/src/firmware/nuttx/gdbinit.in @@ -0,0 +1,7 @@ +target extended ${DEBUG_PORT} +monitor swdp_scan +attach 1 +monitor vector_catch disable hard +set mem inaccessible-by-default off +set print pretty +source Debug/PX4 diff --git a/src/modules/uORB/uORB.h b/src/modules/uORB/uORB.h index c887925fcf..6ead26186b 100644 --- a/src/modules/uORB/uORB.h +++ b/src/modules/uORB/uORB.h @@ -89,20 +89,14 @@ enum ORB_PRIO { /** * Declare (prototype) the uORB metadata for a topic. * - * Note that optional topics are declared weak; this allows a potential - * subscriber to attempt to subscribe to a topic that is not known to the - * system at runtime. The ORB_ID() macro will return NULL/nullptr for - * such a topic, and attempts to advertise or subscribe to it will - * return -1/ENOENT (see below). - * * @param _name The name of the topic. */ #if defined(__cplusplus) # define ORB_DECLARE(_name) extern "C" const struct orb_metadata __orb_##_name __EXPORT -# define ORB_DECLARE_OPTIONAL(_name) extern "C" const struct orb_metadata __orb_##_name __EXPORT __attribute__((weak)) +# define ORB_DECLARE_OPTIONAL(_name) extern "C" const struct orb_metadata __orb_##_name __EXPORT #else # define ORB_DECLARE(_name) extern const struct orb_metadata __orb_##_name __EXPORT -# define ORB_DECLARE_OPTIONAL(_name) extern const struct orb_metadata __orb_##_name __EXPORT __attribute__((weak)) +# define ORB_DECLARE_OPTIONAL(_name) extern const struct orb_metadata __orb_##_name __EXPORT #endif /**