Skip to content
Snippets Groups Projects
Commit 3203f9ac authored by James Goppert's avatar James Goppert
Browse files

Improvements to make support, added debug target.

parent 2ab9f0ba
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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 packag 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~\..*~~")
......
......@@ -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
......
......@@ -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
......
......@@ -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})
......
......@@ -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})
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment