mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-19 02:23:58 +08:00
Jenkins px4fmu-v2 hardware test
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
pipeline {
|
||||
agent none
|
||||
stages {
|
||||
|
||||
stage('Build') {
|
||||
agent {
|
||||
docker {
|
||||
image 'px4io/px4-dev-nuttx:2018-08-05'
|
||||
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'export'
|
||||
sh 'make distclean'
|
||||
sh 'ccache -z'
|
||||
sh 'git fetch --tags'
|
||||
sh 'make nuttx_px4fmu-v2_test'
|
||||
sh 'make sizes'
|
||||
sh 'ccache -s'
|
||||
stash includes: 'build/nuttx_px4fmu-v2_test/nuttx_px4fmu-v2_test.elf', name: 'px4fmu-v2_test'
|
||||
stash includes: 'Tools/HIL/monitor_firmware_upload.py, Tools/HIL/run_tests.py', name: 'scripts'
|
||||
sh 'make distclean'
|
||||
}
|
||||
} // stage Build
|
||||
|
||||
stage('Flash and Run') {
|
||||
agent {
|
||||
label 'px4fmu-v2'
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh 'export'
|
||||
sh 'find /dev/serial'
|
||||
unstash 'px4fmu-v2_test'
|
||||
sh ''' gdb -nx --batch \
|
||||
-ex "target extended-remote `find /dev/serial -name *Black_Magic_Probe_*-if00`" \
|
||||
-ex "monitor version" \
|
||||
-ex "monitor connect_srst enable" \
|
||||
-ex "monitor swdp_scan" \
|
||||
-ex "attach 1" \
|
||||
-ex "load" \
|
||||
-ex "kill" \
|
||||
build/nuttx_px4fmu-v2_test/nuttx_px4fmu-v2_test.elf
|
||||
'''
|
||||
unstash 'scripts'
|
||||
sh './Tools/HIL/monitor_firmware_upload.py --device `find /dev/serial -name *Black_Magic_Probe_*-if02` --baudrate 57600'
|
||||
sh './Tools/HIL/run_tests.py --device `find /dev/serial -name *Black_Magic_Probe_*-if02`'
|
||||
} catch (Exception err) {
|
||||
// always report passed for now
|
||||
currentBuild.result = 'SUCCESS'
|
||||
}
|
||||
} // script
|
||||
}
|
||||
options {
|
||||
timeout(time: 300, unit: 'SECONDS')
|
||||
}
|
||||
|
||||
} // stage Flash
|
||||
|
||||
} // stages
|
||||
environment {
|
||||
CCACHE_DIR = '/tmp/ccache'
|
||||
CI = true
|
||||
}
|
||||
options {
|
||||
buildDiscarder(logRotator(numToKeepStr: '10', artifactDaysToKeepStr: '30'))
|
||||
timeout(time: 60, unit: 'MINUTES')
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -139,8 +139,6 @@ list(GET config_args 0 OS)
|
||||
list(GET config_args 1 BOARD)
|
||||
list(GET config_args 2 LABEL)
|
||||
|
||||
set(THREADS "4" CACHE STRING "number of threads to use for external build processes")
|
||||
set(DEBUG_PORT "/dev/ttyACM0" CACHE STRING "debugging port")
|
||||
set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location")
|
||||
|
||||
if (NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
|
||||
@@ -301,9 +299,7 @@ message(STATUS "C++ compiler: ${cxx_compiler_version_short}")
|
||||
#=============================================================================
|
||||
# external libraries
|
||||
#
|
||||
px4_os_prebuild_targets(OUT prebuild_targets
|
||||
BOARD ${BOARD}
|
||||
THREADS ${THREADS})
|
||||
px4_os_prebuild_targets(OUT prebuild_targets BOARD ${BOARD})
|
||||
|
||||
#=============================================================================
|
||||
# build flags
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ pipeline {
|
||||
agent none
|
||||
stages {
|
||||
|
||||
stage('Analysis') {
|
||||
stage('Analysis') {
|
||||
|
||||
parallel {
|
||||
|
||||
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#! /usr/bin/python
|
||||
|
||||
import serial, time
|
||||
import subprocess
|
||||
from subprocess import call, Popen
|
||||
from argparse import ArgumentParser
|
||||
import re
|
||||
|
||||
def monitor_firmware_upload(port, baudrate):
|
||||
databits = serial.EIGHTBITS
|
||||
stopbits = serial.STOPBITS_ONE
|
||||
parity = serial.PARITY_NONE
|
||||
ser = serial.Serial(port, baudrate, databits, parity, stopbits, 100)
|
||||
|
||||
finished = 0
|
||||
|
||||
while finished == 0:
|
||||
serial_line = ser.readline()
|
||||
print(serial_line.replace('\n',''))
|
||||
|
||||
if "NuttShell (NSH)" in serial_line:
|
||||
finished = 1
|
||||
time.sleep(0.05)
|
||||
ser.close()
|
||||
|
||||
def main():
|
||||
parser = ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--device', "-d", nargs='?', default = None, help='')
|
||||
parser.add_argument("--baudrate", "-b", dest="baudrate", type=int, help="Mavlink port baud rate (default=57600)", default=57600)
|
||||
args = parser.parse_args()
|
||||
|
||||
monitor_firmware_upload(args.device, args.baudrate)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#! /usr/bin/python
|
||||
|
||||
import serial, time
|
||||
import subprocess
|
||||
from subprocess import call, Popen
|
||||
from argparse import ArgumentParser
|
||||
import re
|
||||
|
||||
def do_tests(port, baudrate):
|
||||
databits = serial.EIGHTBITS
|
||||
stopbits = serial.STOPBITS_ONE
|
||||
parity = serial.PARITY_NONE
|
||||
ser = serial.Serial(port, baudrate, databits, parity, stopbits, 100)
|
||||
ser.write('\n\n')
|
||||
|
||||
finished = 0
|
||||
while finished == 0:
|
||||
serial_line = ser.readline()
|
||||
print(serial_line.replace('\n',''))
|
||||
|
||||
if "nsh>" in serial_line:
|
||||
finished = 1
|
||||
time.sleep(0.05)
|
||||
|
||||
ser.write('tests perf\n')
|
||||
|
||||
finished = 0
|
||||
while finished == 0:
|
||||
serial_line = ser.readline()
|
||||
print(serial_line.replace('\n',''))
|
||||
|
||||
if "perf PASSED" in serial_line:
|
||||
finished = 1
|
||||
ser.close()
|
||||
|
||||
time.sleep(0.05)
|
||||
|
||||
ser.close()
|
||||
|
||||
def main():
|
||||
parser = ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--device', "-d", nargs='?', default = None, help='')
|
||||
parser.add_argument("--baudrate", "-b", dest="baudrate", type=int, help="Mavlink port baud rate (default=57600)", default=57600)
|
||||
args = parser.parse_args()
|
||||
|
||||
do_tests(args.device, args.baudrate)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -298,11 +298,92 @@ if (BLOATY_PROGRAM)
|
||||
endif()
|
||||
|
||||
# debugger helpers
|
||||
configure_file(gdbinit.in .gdbinit)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/gdbinit.in ${PX4_BINARY_DIR}/.gdbinit)
|
||||
|
||||
add_custom_target(debug
|
||||
COMMAND ${GDB} $<TARGET_FILE:${FW_NAME}>
|
||||
DEPENDS ${FW_NAME} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
||||
COMMAND ${GDB} -iex 'set auto-load safe-path ${PX4_BINARY_DIR}' $<TARGET_FILE:${FW_NAME}>
|
||||
DEPENDS ${FW_NAME} ${PX4_BINARY_DIR}/.gdbinit
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE black_magic_probe_path
|
||||
FOLLOW_SYMLINKS
|
||||
/dev/serial/by-id/usb-Black_Sphere_Technologies_Black_Magic_Probe_*-if00
|
||||
)
|
||||
file(GLOB_RECURSE black_magic_probe_console_path
|
||||
FOLLOW_SYMLINKS
|
||||
/dev/serial/by-id/usb-Black_Sphere_Technologies_Black_Magic_Probe_*-if02
|
||||
)
|
||||
|
||||
if(black_magic_probe_path)
|
||||
|
||||
add_custom_target(blackmagic_debug
|
||||
COMMAND ${GDB} --nh
|
||||
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
|
||||
-ex 'target extended-remote ${black_magic_probe_path}'
|
||||
-ex 'monitor version'
|
||||
-ex 'monitor connect_srst enable'
|
||||
-ex 'monitor swdp_scan'
|
||||
-ex 'attach 1'
|
||||
-ex 'load'
|
||||
-ex 'run'
|
||||
$<TARGET_FILE:${FW_NAME}>
|
||||
DEPENDS ${FW_NAME} ${PX4_BINARY_DIR}/.gdbinit
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
add_custom_target(blackmagic_upload
|
||||
COMMAND ${GDB} --nx --batch
|
||||
-ex 'target extended-remote ${black_magic_probe_path}'
|
||||
-ex 'monitor version'
|
||||
-ex 'monitor connect_srst enable'
|
||||
-ex 'monitor swdp_scan'
|
||||
-ex 'attach 1'
|
||||
-ex 'load'
|
||||
-ex 'kill'
|
||||
$<TARGET_FILE:${FW_NAME}>
|
||||
DEPENDS ${FW_NAME}
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
COMMENT "Uploading with Black Magic Probe"
|
||||
)
|
||||
|
||||
add_custom_target(blackmagic_console
|
||||
COMMAND screen -t "${BOARD} console" ${black_magic_probe_console_path} 57600 8N1
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
add_custom_target(jlink_upload
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink.sh
|
||||
COMMAND ${GDB} --nx --batch
|
||||
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
|
||||
-ex 'target remote localhost:2331'
|
||||
-ex 'monitor reset'
|
||||
-ex 'load'
|
||||
-ex 'kill'
|
||||
$<TARGET_FILE:${FW_NAME}>
|
||||
DEPENDS ${FW_NAME} ${PX4_BINARY_DIR}/.gdbinit
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
add_custom_target(jlink_debug
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink.sh
|
||||
COMMAND ${GDB} --nh
|
||||
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
|
||||
-ex 'target remote localhost:2331'
|
||||
-ex 'monitor reset'
|
||||
-ex 'load'
|
||||
-ex 'monitor reset'
|
||||
-ex 'continue'
|
||||
$<TARGET_FILE:${FW_NAME}>
|
||||
DEPENDS ${FW_NAME} ${PX4_BINARY_DIR}/.gdbinit
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
@@ -319,7 +400,9 @@ ExternalProject_Add(FlameGraph
|
||||
)
|
||||
|
||||
add_custom_target(profile
|
||||
COMMAND ${CMAKE_COMMAND} -E env PATH="${PX4_BINARY_DIR}/external/Source/FlameGraph:$ENV{PATH}" ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/poor-mans-profiler.sh --elf=$<TARGET_FILE:${FW_NAME}> --nsamples=10000
|
||||
COMMAND ${CMAKE_COMMAND} -E env PATH="${PX4_BINARY_DIR}/external/Source/FlameGraph:$ENV{PATH}"
|
||||
${PX4_SOURCE_DIR}/platforms/nuttx/Debug/poor-mans-profiler.sh --elf=$<TARGET_FILE:${FW_NAME}> --nsamples=10000
|
||||
DEPENDS ${FW_NAME} ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/poor-mans-profiler.sh FlameGraph
|
||||
USES_TERMINAL
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#
|
||||
# Various PX4-specific macros
|
||||
#
|
||||
source platforms/nuttx/Debug/NuttX
|
||||
source platforms/nuttx/Debug/ARMv7M
|
||||
|
||||
echo Loading PX4 GDB macros. Use 'help px4' for more information.\n
|
||||
|
||||
|
||||
@@ -2,9 +2,13 @@ source ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/PX4
|
||||
source ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/NuttX
|
||||
source ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/ARMv7M
|
||||
|
||||
target extended-remote ${DEBUG_PORT}
|
||||
monitor swdp_scan
|
||||
attach 1
|
||||
monitor vector_catch disable hard
|
||||
set mem inaccessible-by-default off
|
||||
|
||||
set print pretty
|
||||
|
||||
set pagination off
|
||||
|
||||
set history save on
|
||||
set history size unlimited
|
||||
|
||||
set logging on
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#! /bin/sh
|
||||
|
||||
JLinkGDBServerCLExe -startserver -USB -device Cortex-M4 -if SWD -speed auto > jlink.log &
|
||||
@@ -1,22 +0,0 @@
|
||||
# program a bootable device load on a mavstation
|
||||
# To run type openocd -f mavprogram.cfg
|
||||
|
||||
source [find interface/olimex-arm-usb-ocd-h.cfg]
|
||||
source [find px4fmu-board.cfg]
|
||||
|
||||
init
|
||||
halt
|
||||
|
||||
# Find the flash inside this CPU
|
||||
flash probe 0
|
||||
|
||||
# erase it (128 pages) then program and exit
|
||||
|
||||
#flash erase_sector 0 0 127
|
||||
# stm32f1x mass_erase 0
|
||||
|
||||
# It seems that Pat's image has a start address offset of 0x1000 but the vectors need to be at zero, so fixbin.sh moves things around
|
||||
#flash write_bank 0 fixed.bin 0
|
||||
#flash write_image firmware.elf
|
||||
#shutdown
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
target remote :3333
|
||||
|
||||
# Don't let GDB get confused while stepping
|
||||
define hook-step
|
||||
mon cortex_m maskisr on
|
||||
end
|
||||
define hookpost-step
|
||||
mon cortex_m maskisr off
|
||||
end
|
||||
|
||||
mon init
|
||||
mon stm32_init
|
||||
# mon reset halt
|
||||
mon poll
|
||||
mon cortex_m maskisr auto
|
||||
set mem inaccessible-by-default off
|
||||
set print pretty
|
||||
source platforms/nuttx/Debug/PX4
|
||||
|
||||
echo PX4 resumed, press ctrl-c to interrupt\n
|
||||
continue
|
||||
@@ -18,7 +18,7 @@
|
||||
#
|
||||
|
||||
set -e
|
||||
root=$(dirname $0)/..
|
||||
root=$(dirname $0)
|
||||
|
||||
function die()
|
||||
{
|
||||
@@ -77,7 +77,7 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
[[ -z "$elf" ]] && die "Please specify the ELF file location, e.g.: build/px4fmu-v4_default/src/firmware/nuttx/firmware_nuttx"
|
||||
[[ -z "$elf" ]] && die "Please specify the ELF file location, e.g.: build/nuttx_px4fmu-v4_default/nuttx_px4fmu-v4_default.elf"
|
||||
|
||||
#
|
||||
# Temporary files
|
||||
@@ -102,7 +102,8 @@ then
|
||||
do
|
||||
if [[ "$taskname" = "" ]]
|
||||
then
|
||||
arm-none-eabi-gdb $elf --batch -ex "set print asm-demangle on" \
|
||||
arm-none-eabi-gdb $elf --nx --quiet --batch \
|
||||
-ex "set print asm-demangle on" \
|
||||
-ex "target extended /dev/ttyACM0" \
|
||||
-ex "monitor swdp_scan" \
|
||||
-ex "attach 1" \
|
||||
@@ -111,11 +112,12 @@ then
|
||||
| sed -n 's/\(#.*\)/\1/p' \
|
||||
>> $stacksfile
|
||||
else
|
||||
arm-none-eabi-gdb $elf --batch -ex "set print asm-demangle on" \
|
||||
arm-none-eabi-gdb $elf --nx --quiet --batch \
|
||||
-ex "set print asm-demangle on" \
|
||||
-ex "target extended /dev/ttyACM0" \
|
||||
-ex "monitor swdp_scan" \
|
||||
-ex "attach 1" \
|
||||
-ex "source $root/platforms/nuttx/Debug/Nuttx.py" \
|
||||
-ex "source $root/Nuttx.py" \
|
||||
-ex "show mybt $taskname" \
|
||||
2> $gdberrfile \
|
||||
| sed -n 's/0\.0:\(#.*\)/\1/p' \
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# The latest defaults in OpenOCD 0.7.0 are actually prettymuch correct for the px4fmu
|
||||
|
||||
# increase working area to 32KB for faster flash programming
|
||||
set WORKAREASIZE 0x8000
|
||||
|
||||
source [find target/stm32f4x.cfg]
|
||||
|
||||
# needed for px4
|
||||
reset_config trst_only
|
||||
|
||||
proc stm32_reset {} {
|
||||
reset halt
|
||||
# FIXME - needed to init periphs on reset
|
||||
# 0x40023800 RCC base
|
||||
# 0x24 RCC_APB2 0x75933
|
||||
# RCC_APB2 0
|
||||
}
|
||||
|
||||
# perform init that is required on each connection to the target
|
||||
proc stm32_init {} {
|
||||
|
||||
# force jtag to not shutdown during sleep
|
||||
#uint32_t cr = getreg32(STM32_DBGMCU_CR);
|
||||
#cr |= DBGMCU_CR_STANDBY | DBGMCU_CR_STOP | DBGMCU_CR_SLEEP;
|
||||
#putreg32(cr, STM32_DBGMCU_CR);
|
||||
mww 0xe0042004 00000007
|
||||
}
|
||||
|
||||
# if srst is not fitted use SYSRESETREQ to
|
||||
# perform a soft reset
|
||||
cortex_m reset_config sysresetreq
|
||||
|
||||
# Let GDB directly program elf binaries
|
||||
gdb_memory_map enable
|
||||
|
||||
# doesn't work yet
|
||||
gdb_flash_program disable
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
openocd -f interface/olimex-arm-usb-ocd-h.cfg -f $DIR/px4fmu-board.cfg
|
||||
@@ -226,7 +226,6 @@ endfunction()
|
||||
#
|
||||
# Input:
|
||||
# BOARD : board
|
||||
# THREADS : number of threads for building
|
||||
#
|
||||
# Output:
|
||||
# OUT : the target list
|
||||
@@ -237,7 +236,7 @@ endfunction()
|
||||
function(px4_os_prebuild_targets)
|
||||
px4_parse_function_args(
|
||||
NAME px4_os_prebuild_targets
|
||||
ONE_VALUE OUT BOARD THREADS
|
||||
ONE_VALUE OUT BOARD
|
||||
REQUIRED OUT BOARD
|
||||
ARGN ${ARGN})
|
||||
|
||||
|
||||
@@ -429,7 +429,6 @@ endfunction()
|
||||
#
|
||||
# Input:
|
||||
# BOARD : board
|
||||
# THREADS : number of threads for building
|
||||
#
|
||||
# Output:
|
||||
# OUT : the target list
|
||||
@@ -440,7 +439,7 @@ endfunction()
|
||||
function(px4_os_prebuild_targets)
|
||||
px4_parse_function_args(
|
||||
NAME px4_os_prebuild_targets
|
||||
ONE_VALUE OUT BOARD THREADS
|
||||
ONE_VALUE OUT BOARD
|
||||
REQUIRED OUT BOARD
|
||||
ARGN ${ARGN})
|
||||
|
||||
|
||||
@@ -224,7 +224,6 @@ endfunction()
|
||||
#
|
||||
# Input:
|
||||
# BOARD : board
|
||||
# THREADS : number of threads for building
|
||||
#
|
||||
# Output:
|
||||
# OUT : the target list
|
||||
@@ -235,7 +234,7 @@ endfunction()
|
||||
function(px4_os_prebuild_targets)
|
||||
px4_parse_function_args(
|
||||
NAME px4_os_prebuild_targets
|
||||
ONE_VALUE OUT BOARD THREADS
|
||||
ONE_VALUE OUT BOARD
|
||||
REQUIRED OUT BOARD
|
||||
ARGN ${ARGN})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user