mirror of
https://github.com/meshtastic/meshtastic.git
synced 2024-11-16 10:34:14 -08:00
b919477f80
SWDIO upload uses hex files, not uf2.
106 lines
3.5 KiB
Plaintext
106 lines
3.5 KiB
Plaintext
---
|
|
id: swdio
|
|
title: SWDIO using a Raspberry Pi
|
|
sidebar_label: SWDIO using a Raspberry Pi
|
|
sidebar_position: 6
|
|
description: Instructions for uploading firmware through SWDIO by using a Raspberry Pi.
|
|
---
|
|
|
|
Most Meshtastic devices can be flashed simply using USB.
|
|
However, some (eg Seeed WM1110 Dev Kit) require the use of an external device that can connect via "SWDIO".
|
|
There are dedicated devices such as the [RAKDAP1](https://store.rakwireless.com/products/daplink-tool)
|
|
that can do this work. However, for many people a Raspberry Pi is more convenient.
|
|
|
|
This article provides instructions on how use a Raspberry Pi as a SWDIO Flash Tool.
|
|
|
|
## Set up Wiring
|
|
The first step is to connect two wires between your Raspberry Pi and the SWDIO ports on your NRF52-based device.
|
|
|
|
Connect GPIO pin 11 on your Raspbery Pi to the CLK pin on the Meshtastic Device.
|
|
Connect GPIO pin 8 on your Raspbery Pi to the DIO pin on the Meshtastic Device.
|
|
|
|
Ensure you get the GPIO numbers correct.
|
|
|
|
Plug in your Raspberry Pi to USB power.
|
|
Plug in the Meshtastic Device to power.
|
|
|
|
## Install OpenOCD
|
|
|
|
You can use OpenOCD to manage the SWDIO connection with the Meshtastic Device.
|
|
Install it on your Raspberry Pi.
|
|
|
|
```
|
|
$ sudo apt update
|
|
$ sudo apt install libtool autoconf automake texinfo telnet gdb-multiarch git
|
|
$ git clone git://repo.or.cz/openocd.git
|
|
$ cd openocd/
|
|
$ ./bootstrap
|
|
$ ./configure --enable-bcm2835gpio
|
|
$ make -j4
|
|
$ sudo make install
|
|
```
|
|
|
|
## Check connection
|
|
Let's try connecting to the NRF52-based device with SWDIO before we do anything with firmware.
|
|
All the configuration you need is in the openocd repository.
|
|
|
|
```
|
|
$ openocd -f ./openocd/tcl/interface/raspberrypi-native.cfg -c "transport select swd" -f openocd/tcl/target/nrf52.cfg -s tcl
|
|
```
|
|
|
|
The first flag selects the Raspberry Pi as your host machine, the transport is SWDIO, and the last flag says you are connecting to a nRF52-based chip.
|
|
You should see something like this:
|
|
|
|
```
|
|
Open On-Chip Debugger 0.12.0+dev-00633-gad87fbd1c
|
|
Licensed under GNU GPL v2
|
|
For bug reports, read
|
|
http://openocd.org/doc/doxygen/bugs.html
|
|
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
|
|
swd
|
|
Info : Listening on port 6666 for tcl connections
|
|
Info : Listening on port 4444 for telnet connections
|
|
Info : BCM2835 GPIO JTAG/SWD bitbang driver
|
|
Info : clock speed 100 kHz
|
|
Info : SWD DPIDR 0x2ba01477
|
|
Info : [nrf52.cpu] Cortex-M4 r0p1 processor detected
|
|
Info : [nrf52.cpu] target has 6 breakpoints, 4 watchpoints
|
|
Info : [nrf52.cpu] Examination succeed
|
|
Info : [nrf52.cpu] starting gdb server on 3333
|
|
Info : Listening on port 3333 for gdb connections
|
|
Info : accepting 'telnet' connection on tcp/4444
|
|
```
|
|
|
|
|
|
If you see “Error connecting DP: cannot read IDR”, then you've probably connected the wires to the wrong place.
|
|
|
|
## Obtaining Firmware
|
|
Check the instructions for your [hardware](/docs/hardware/devices) to find the correct firmware for your device.
|
|
For most devices following this guide, a .hex file is required.
|
|
Then, copy the firmware file to your Raspberry Pi.
|
|
|
|
|
|
## Flashing Firmware
|
|
Once you have openocd running, you can connect to your Meshtastic device using telnet.
|
|
Flashing is as simple as running a few commands inside the telnet session:
|
|
|
|
```
|
|
$ telnet 127.0.0.1 4444
|
|
Trying 127.0.0.1...
|
|
Connected to 127.0.0.1.
|
|
Escape character is '^]'.
|
|
Open On-Chip Debugger
|
|
> init
|
|
> reset init
|
|
> halt
|
|
> nrf5 mass_erase
|
|
> program firmware.hex verify
|
|
> reset
|
|
> exit 0
|
|
```
|
|
|
|
Unplug the power and plug it back in after flashing.
|
|
|
|
## Connecting
|
|
Congratulations, you should now be able to connect to your device through Bluetooth in the Meshtastic app.
|