Estou construindo um ambiente de integração contínua para uma base de código de firmware, programando um ARM Cortex M0 usando um dispositivo Segger JLink e executando testes no destino usando o gdb e a ferramenta RTT da Segger.
Eu tenho três processos que preciso começar com "esperar":
- O servidor gdb. Isso escuta uma conexão de ...
- O cliente do gdb.
- O cliente RTT do Segger registra a saída do destino para o terminal do host para que eu possa ver como os testes estão ocorrendo.
Eu tenho "fazer" metas para cada um deles. Quando executo os testes como humanos, tenho uma guia de terminal aberta para cada um. Executar um por um no terminal, todos eles funcionam bem. No entanto, quando executado pelo seguinte script "esperar", o cliente gdb irá parar no ponto em que deveria estar enviando dados para o servidor gdb. Por quê?
#!/usr/bin/expect
# Bike Tracker firmware/hardware test. For syntax, see "man expect".
# gdb server
spawn /Applications/SEGGER/JLink/JLinkGDBServer -device nrf51822 -if swd -speed 4000 -port 2331
expect {
-ex "Waiting for GDB connection..."
}
sleep 1
send_user "\nexpect: gdb server running OK\n"
# gdb client
spawn ~/dev/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-gdb -x ./_build/.gdbinit ./_build/biketracker_app_s130.elf
sleep 2
set timeout 10
expect {
-ex "(gdb)" {
send "cont"
send "cont"
}
-ex "Operation timed out" {
send_user "expect: Timed out on gdb client. Did the server start OK?\n"
exit 1
}
timeout {
send_user "\nexpect: Timed out on gdb client output.\n"
exit 1
}
}
send_user "\nexpect: gdb client running OK\n"
# Segger RTT client
spawn /Applications/SEGGER/JLink/JLinkRTTClient -device nrf51822 -if swd -speed 4000
# If we do an RX operation on the modem, that takes 6s for the TX and about 30s for the RX.
set timeout 40
expect {
-ex "END_OF_TEST" { exit 0 }
eof { exit 0 }
-ex "ASSERT" {
send_user "\nexpect: A test failed. See RTT output for details.\n"
exit 1
}
timeout {
send_user "\nexpect: Timed out on RTT output.\n"
exit 1
}
}
Saída do terminal:
expect test.expect
spawn /Applications/SEGGER/JLink/JLinkGDBServer -device nrf51822 -if swd -speed 4000 -port 2331
SEGGER J-Link GDB Server V5.12f Command Line Version
JLinkARM.dll V5.12f (DLL compiled May 17 2016 16:04:43)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: nrf51822
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware: V8.00
S/N: 268006243
OEM: SEGGER-EDU
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.04 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...
expect: gdb server running OK
spawn ~/dev/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-gdb -x ./_build/.gdbinit ./_build/biketracker_app_s130.elf
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150304-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin10 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./_build/biketracker_app_s130.elf...done.
0x0002ecf2 in rx_done_event (bytes=1 '#!/usr/bin/expect
# Bike Tracker firmware/hardware test. For syntax, see "man expect".
# gdb server
spawn /Applications/SEGGER/JLink/JLinkGDBServer -device nrf51822 -if swd -speed 4000 -port 2331
expect {
-ex "Waiting for GDB connection..."
}
sleep 1
send_user "\nexpect: gdb server running OK\n"
# gdb client
spawn ~/dev/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-gdb -x ./_build/.gdbinit ./_build/biketracker_app_s130.elf
sleep 2
set timeout 10
expect {
-ex "(gdb)" {
send "cont"
send "cont"
}
-ex "Operation timed out" {
send_user "expect: Timed out on gdb client. Did the server start OK?\n"
exit 1
}
timeout {
send_user "\nexpect: Timed out on gdb client output.\n"
exit 1
}
}
send_user "\nexpect: gdb client running OK\n"
# Segger RTT client
spawn /Applications/SEGGER/JLink/JLinkRTTClient -device nrf51822 -if swd -speed 4000
# If we do an RX operation on the modem, that takes 6s for the TX and about 30s for the RX.
set timeout 40
expect {
-ex "END_OF_TEST" { exit 0 }
eof { exit 0 }
-ex "ASSERT" {
send_user "\nexpect: A test failed. See RTT output for details.\n"
exit 1
}
timeout {
send_user "\nexpect: Timed out on RTT output.\n"
exit 1
}
}
1', p_data=0x20002cec <rx_buffer> ",") at /Users/Eliot/dev/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/uart/nrf_drv_uart.c:631
631 m_cb.handler(&event,m_cb.p_context);
Loading section .text, size 0x1fbec lma 0x1b000
expect: Timed out on gdb client output.