Skip to content

Commit

Permalink
create jlink gdb upload script and use in Jenkins Hardware pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Feb 27, 2019
1 parent 12d29fd commit 836427d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 118 deletions.
110 changes: 8 additions & 102 deletions .ci/Jenkinsfile-hardware
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,7 @@ pipeline {
sh 'export'
sh 'find /dev/serial'
unstash 'px4_fmu-v2_test'
sh '''gdb-multiarch -nx --batch \
-ex "target remote localhost:2331" \
-ex "monitor reset 0" \
-ex "load" \
-ex "compare-sections" \
-ex "monitor reset 0" \
-ex "monitor sleep 1000" \
-ex "monitor go" \
-ex "kill" \
build/px4_fmu-v2_test/px4_fmu-v2_test.elf
'''
sh 'platforms/nuttx/Debug/jlink_gdb_upload.sh build/px4_fmu-v2_test/px4_fmu-v2_test.elf'
sh './Tools/HIL/monitor_firmware_upload.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*` --baudrate 57600'
//sh './Tools/HIL/run_tests.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*`'
} catch (Exception err) {
Expand All @@ -203,51 +193,7 @@ pipeline {
sh 'export'
sh 'find /dev/serial'
unstash 'px4_fmu-v3_default'
sh '''gdb-multiarch -nx --batch \
-ex "target remote localhost:2331" \
-ex "monitor reset 0" \
-ex "load" \
-ex "compare-sections" \
-ex "monitor reset 0" \
-ex "monitor sleep 1000" \
-ex "monitor go" \
-ex "kill" \
build/px4_fmu-v3_default/px4_fmu-v3_default.elf
'''
sh './Tools/HIL/monitor_firmware_upload.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*` --baudrate 57600'
sh './Tools/HIL/run_tests.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*`'
} catch (Exception err) {
// always report passed for now
currentBuild.result = 'SUCCESS'
}
} // script
}
options {
timeout(time: 600, unit: 'SECONDS')
}
}

stage('px4_fmu-v3_default (pixhack-v3)') {
agent {
label 'pixhack-v3'
}
steps {
script {
try {
sh 'export'
sh 'find /dev/serial'
unstash 'px4_fmu-v3_default'
sh '''gdb-multiarch -nx --batch \
-ex "target remote localhost:2331" \
-ex "monitor reset 0" \
-ex "load" \
-ex "compare-sections" \
-ex "monitor reset 0" \
-ex "monitor sleep 1000" \
-ex "monitor go" \
-ex "kill" \
build/px4_fmu-v3_default/px4_fmu-v3_default.elf
'''
sh 'platforms/nuttx/Debug/jlink_gdb_upload.sh build/px4_fmu-v3_default/px4_fmu-v3_default.elf'
sh './Tools/HIL/monitor_firmware_upload.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*` --baudrate 57600'
sh './Tools/HIL/run_tests.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*`'
} catch (Exception err) {
Expand All @@ -271,17 +217,7 @@ pipeline {
sh 'export'
sh 'find /dev/serial'
unstash 'px4_fmu-v4_default'
sh ''' gdb-multiarch -nx --batch \
-ex "target remote localhost:2331" \
-ex "monitor reset 0" \
-ex "load" \
-ex "compare-sections" \
-ex "monitor reset 0" \
-ex "monitor sleep 1000" \
-ex "monitor go" \
-ex "kill" \
build/px4_fmu-v4_default/px4_fmu-v4_default.elf
'''
sh 'platforms/nuttx/Debug/jlink_gdb_upload.sh build/px4_fmu-v4_default/px4_fmu-v4_default.elf'
sh './Tools/HIL/monitor_firmware_upload.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*` --baudrate 57600'
sh './Tools/HIL/run_tests.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*`'
} catch (Exception err) {
Expand All @@ -305,17 +241,7 @@ pipeline {
sh 'export'
sh 'find /dev/serial'
unstash 'px4_fmu-v4pro_default'
sh '''gdb-multiarch -nx --batch \
-ex "target remote localhost:2331" \
-ex "monitor reset 0" \
-ex "load" \
-ex "compare-sections" \
-ex "monitor reset 0" \
-ex "monitor sleep 1000" \
-ex "monitor go" \
-ex "kill" \
build/px4_fmu-v4pro_default/px4_fmu-v4pro_default.elf
'''
sh 'platforms/nuttx/Debug/jlink_gdb_upload.sh build/px4_fmu-v4pro_default/px4_fmu-v4pro_default.elf'
sh './Tools/HIL/monitor_firmware_upload.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*` --baudrate 57600'
sh './Tools/HIL/run_tests.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*`'
} catch (Exception err) {
Expand All @@ -339,17 +265,7 @@ pipeline {
sh 'export'
sh 'find /dev/serial'
unstash 'px4_fmu-v5_default'
sh '''gdb-multiarch -nx --batch \
-ex "target remote localhost:2331" \
-ex "monitor reset 0" \
-ex "load" \
-ex "compare-sections" \
-ex "monitor reset 0" \
-ex "monitor sleep 1000" \
-ex "monitor go" \
-ex "kill" \
build/px4_fmu-v5_default/px4_fmu-v5_default.elf
'''
sh './platforms/nuttx/Debug/jlink_gdb_upload.sh build/px4_fmu-v5_default/px4_fmu-v5_default.elf'
sh './Tools/HIL/monitor_firmware_upload.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*` --baudrate 57600'
sh './Tools/HIL/run_tests.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*`'
} catch (Exception err) {
Expand All @@ -359,7 +275,7 @@ pipeline {
} // script
}
options {
timeout(time: 600, unit: 'SECONDS')
timeout(time: 1800, unit: 'SECONDS')
}
}

Expand All @@ -373,17 +289,7 @@ pipeline {
sh 'export'
sh 'find /dev/serial'
unstash 'px4_fmu-v5_stackcheck'
sh '''gdb-multiarch -nx --batch \
-ex "target remote localhost:2331" \
-ex "monitor reset 0" \
-ex "load" \
-ex "compare-sections" \
-ex "monitor reset 0" \
-ex "monitor sleep 1000" \
-ex "monitor go" \
-ex "kill" \
build/px4_fmu-v5_stackcheck/px4_fmu-v5_stackcheck.elf
'''
sh './platforms/nuttx/Debug/jlink_gdb_upload.sh build/px4_fmu-v5_stackcheck/px4_fmu-v5_stackcheck.elf'
sh './Tools/HIL/monitor_firmware_upload.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*` --baudrate 57600'
sh './Tools/HIL/run_tests.py --device `find /dev/serial -name *usb-FTDI_TTL232R-3V3_*`'
} catch (Exception err) {
Expand All @@ -393,7 +299,7 @@ pipeline {
} // script
}
options {
timeout(time: 600, unit: 'SECONDS')
timeout(time: 1800, unit: 'SECONDS')
}
}

Expand Down
23 changes: 10 additions & 13 deletions platforms/nuttx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -349,27 +349,24 @@ if(black_magic_probe_path)
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:px4>
DEPENDS px4 ${PX4_BINARY_DIR}/.gdbinit
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink_gdb_start.sh
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink_gdb_upload.sh $<TARGET_FILE:px4>
DEPENDS px4
WORKING_DIRECTORY ${PX4_BINARY_DIR}
USES_TERMINAL
)

add_custom_target(jlink_debug
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink.sh
COMMAND ${GDB} --nh
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink_gdb_start.sh
COMMAND ${GDB} -nh
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
-ex 'target remote localhost:2331'
-ex 'monitor reset'
-ex 'monitor reset 0'
-ex 'load'
-ex 'monitor reset'
-ex 'compare-sections'
-ex 'monitor reset 0'
-ex 'monitor sleep 1000'
-ex 'monitor go'
-ex 'continue'
$<TARGET_FILE:px4>
DEPENDS px4 ${PX4_BINARY_DIR}/.gdbinit
Expand Down
5 changes: 5 additions & 0 deletions platforms/nuttx/Debug/gdbinit.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
source ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/PX4
help px4

source ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/NuttX
help nuttx

source ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/ARMv7M
help armv7m

set mem inaccessible-by-default off

Expand Down
3 changes: 0 additions & 3 deletions platforms/nuttx/Debug/jlink.sh

This file was deleted.

7 changes: 7 additions & 0 deletions platforms/nuttx/Debug/jlink_gdb_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/sh

killall JLinkGDBServerCLExe

# TODO: set device from nuttx config
# eg CONFIG_ARCH_CHIP_STM32F427V or CONFIG_STM32_STM32F427
JLinkGDBServerCLExe -device STM32F427II -select usb -silent -endian little -if SWD -speed auto -ir -LocalhostOnly 1 -strict -vd -singlerun &
12 changes: 12 additions & 0 deletions platforms/nuttx/Debug/jlink_gdb_upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/sh

gdb-multiarch -nx -batch \
-ex "target remote localhost:2331" \
-ex "monitor reset 0" \
-ex "load" \
-ex "compare-sections" \
-ex "monitor reset 0" \
-ex "monitor sleep 1000" \
-ex "monitor go" \
-ex "kill" \
${1}

0 comments on commit 836427d

Please sign in to comment.