Repository navigation
Uploading and Debugging Remotely
This page describes uploading the firmware using a Banana Pi (BPi), running the lnxpps OpenWRT Image, as a remote OpenOCD host. This page only covers the upload step. In this setup, the ST-Link is connected to the BPi over USB. Development happens on a local developer PC. The firmware image is transferred to the BPi over the network. OpenOCD is remotely started and configured to upload the firmware image to the target.
For installing PlatformIO on the local development PC, obtaining the source code, and general ST-Link wiring and upload information, see Build & Upload.
- The BPi is reachable from the development computer using SSH. It is assumed that you have configured an ssh key for non-interactive login to the remote BPi.
- OpenOCD and
ncare installed on the BPi and available on itsPATH. The script is compatible with the BusyBoxnccommonly found on OpenWrt. - The ST-Link is connected to the BPi and wired to the BluePill as described in Build & Upload.
Restrict network access to the BPi to trusted machines on your network. We will later bind OpenOCD to all network interfaces so that a remote debugger can connect; do not expose its ports to the public Internet.
From the c6021light project directory (the directory containing platformio.ini), run:
./scripts/remote-debug-upload.sh <user>@<bpi-host>For a BPi with the lnxpps OpenWRT image reachable as "bpi.local", this command looks as follows:
./scripts/remote-debug-upload.sh root@bpi.localThe script builds the bluepill PlatformIO environment, copies .pio/build/bluepill/firmware.elf to the BPi, and asks OpenOCD to program and verify the firmware before resetting the target. If an OpenOCD GDB server is already listening on port 3333, the script reuses it. Otherwise, it starts OpenOCD in the background. Its log is written to ~/openocd-remote.log on the BPi.
To build with debug symbols, set build_type = debug in the [env:bluepill] section of platformio.ini. Then configure PlatformIO to connect to the OpenOCD server on the BPi. For example:
[env:bluepill]
build_type = debug
debug_tool = custom
debug_port = <bpi-host>:3333
debug_server =Use the BPi's actual hostname or IP address for debug_port, e.g., debug_port = bpi.local:3333. The empty debug_server setting tells PlatformIO not to start a local OpenOCD process; the upload script starts or reuses the remote server. After uploading, start the PlatformIO debugger to connect to the server. Keep the OpenOCD process running while debugging.