Merge pull request #2858 from jgoppert/cmake-weak

Removed weak attributes.
This commit is contained in:
Lorenz Meier
2015-09-13 21:38:59 +02:00
13 changed files with 60 additions and 30 deletions

View File

@@ -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

View File

@@ -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~\..*~~")

View File

@@ -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

View File

@@ -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

View File

@@ -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})

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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})

View File

@@ -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

View File

@@ -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
/**