Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/notecard-binary-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ jobs:

- name: Generate MD5 Server Token
run: |
[ -n "$MD5SRV_TOKEN" ] || echo "MD5SRV_TOKEN=`uuidgen`" >> $GITHUB_ENV
[ -n "$MD5SRV_TOKEN" ] || MD5SRV_TOKEN=`uuidgen`
# Mask the token before it goes into GITHUB_ENV. Otherwise, GitHub
# prints it in plain text in the env block of every later step.
echo "::add-mask::$MD5SRV_TOKEN"
echo "MD5SRV_TOKEN=$MD5SRV_TOKEN" >> $GITHUB_ENV

# gdb-multiarch: We used gdb to remotely flash the test firmware onto the
# Swan attached to the Notestation. Apparently "regular" gdb (i.e.
Expand Down Expand Up @@ -148,13 +152,15 @@ jobs:
- name: Create Notehub accesss token
if: env.CREATE_NOTEHUB_ROUTES!='false'
run: |
# Mask the token before it goes into GITHUB_ENV. Otherwise, GitHub
# prints it in plain text in the env block of every later step.
curl -f -X POST \
-L 'https://${{ env.NOTEHUB }}/oauth2/token' \
-H 'content-type: application/x-www-form-urlencoded' \
-d grant_type=client_credentials \
-d client_id=${{ secrets.NOTEHUB_HIL_CLIENT_ID }} \
-d client_secret=${{ secrets.NOTEHUB_HIL_CLIENT_SECRET }} | \
{ token=$(jq -r .access_token); echo "NOTEHUB_ACCESS_TOKEN=$token" >> $GITHUB_ENV; }
{ token=$(jq -r .access_token); echo "::add-mask::$token"; echo "NOTEHUB_ACCESS_TOKEN=$token" >> $GITHUB_ENV; }

- name: Create Notehub HTTP route
if: env.CREATE_NOTEHUB_ROUTES!='false'
Expand Down
3 changes: 1 addition & 2 deletions test/hitl/card.binary/lib/notecard_binary/NotecardComms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ size_t readDataUntilTimeout(Stream& serial, size_t timeout, uint8_t* buf, size_t
}


HardwareSerial Serial2(A0,A3);
HardwareSerial Serial3(A5,A4); // A5 is RX, A4 is TX
UartSerial notecardSerial(A5,A4); // A5 is RX, A4 is TX


14 changes: 13 additions & 1 deletion test/hitl/card.binary/lib/notecard_binary/NotecardComms.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum NotecardInterface {
};

#ifndef NOTECARD_IF_SERIAL_PORT
#define NOTECARD_IF_SERIAL_PORT Serial3
#define NOTECARD_IF_SERIAL_PORT notecardSerial
#endif

#ifndef NOTECARD_IF_SERIAL_BAUDRATE
Expand All @@ -36,6 +36,18 @@ HardwareSerial stlinkSerial(PIN_VCP_RX, PIN_VCP_TX);
#define dbgSerial Serial
#endif

// In STM32 Arduino core 3.x, HardwareSerial is an abstract base class and Uart
// is the concrete UART class. Core 2.x has no Uart class.
#if STM32_CORE_VERSION_MAJOR >= 3
typedef Uart UartSerial;
#else
typedef HardwareSerial UartSerial;
#endif

// Don't name this Serial2 or Serial3. Core 3.x declares those itself, and a
// second declaration with a different type won't compile.
extern UartSerial notecardSerial;

bool initialize_notecard_interface(NotecardInterface iface);
size_t readDataUntilTimeout(Stream& serial, size_t timeout, uint8_t* buf, size_t bufLen, size_t dataLen, size_t& duration);

Expand Down
5 changes: 4 additions & 1 deletion test/hitl/card.binary/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ extra_scripts = post:after_upload.py
build_type = debug
debug_test = *
upload_protocol = custom
upload_command = ${sysenv.GDB_CMD} -ex "set confirm off" -ex "set pagination off" -ex "file .pio/build/debug/firmware.elf" -ex "target extended-remote ${sysenv.MCU_GDB_SERVER_IP}:${sysenv.MCU_GDB_SERVER_PORT}" -ex "monitor reset halt" -ex "load" -ex "monitor reset" -ex "quit"
; -batch and upload.gdb make GDB exit non-zero when the connect, reset, or
; load fails. See upload.gdb. "pio test" hides the upload command's stdout, so
; 1>&2 sends GDB's output to stderr, where it shows in the CI log.
upload_command = ${sysenv.GDB_CMD} -batch -ex "set confirm off" -ex "set pagination off" -ex "file .pio/build/debug/firmware.elf" -ex "target extended-remote ${sysenv.MCU_GDB_SERVER_IP}:${sysenv.MCU_GDB_SERVER_PORT}" -x upload.gdb 1>&2
test_port = ${sysenv.TEST_PORT}
8 changes: 8 additions & 0 deletions test/hitl/card.binary/test/test_card_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,14 @@ TEST(test_max_length_aux_serial)

void waitForNotecardConnected()
{
// Set the product and mode before waiting. The Notestation is shared, so
// the previous user can leave a different product UID on the Notecard. If
// that product has no Notehub project, the Notecard delays its connect
// attempts ("connect delayed", the penalty box) for several minutes. A
// hub.set that changes the product also clears that delay.
assert_initialize_notecard(NOTECARD_IF_I2C);
TEST_ASSERT_TRUE_MESSAGE(cardBinary.notecardConnectionMode(), "Unable to set Notecard connection mode");

// TODO: waitForNotecardConnected takes timeout in milliseconds, so 5*60 seems wrong?
TEST_ASSERT_TRUE_MESSAGE(NotecardBinary::waitForNotecardConnected(NOT_CONNECTED_TIMEOUT), "Notecard not connected");
}
Expand Down
21 changes: 21 additions & 0 deletions test/hitl/card.binary/upload.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Flash commands for the custom upload_command in platformio.ini.
#
# These commands live in a sourced file, not in -ex options, so that a failure
# stops the upload. GDB aborts a sourced file at the first command that fails,
# and with -batch it then exits non-zero. With -ex options, GDB runs the later
# commands anyway and exits 0 (or, with -batch, reports only the last command),
# so a failed connect or load looked like a successful upload.
#
# If the "target extended-remote" -ex before this file fails, the first
# "monitor" command here fails too, so that case also exits non-zero.
#
# GDB prints load progress only for interactive commands, so the echo lines
# and compare-sections show in the CI log what was flashed. compare-sections
# reports a mismatch as a warning, not an error.
monitor reset halt
echo Loading firmware...\n
load
echo Comparing flash with the ELF...\n
compare-sections
monitor reset
echo Upload done.\n
Loading