update firmware on 3DR/RFD900 radio via MAVLink over USB

2,063 views
Skip to first unread message

Andrew Tridgell

unread,
Apr 4, 2014, 5:02:04 PM4/4/14
to drones-...@googlegroups.com, Luke Hovington, saa...@rfdesign.com.au
Hi All,

After some discussions with Philip Rowse yesterday I've pushed in a new
SERIAL_CONTROL MAVLink packet which allows for updating and control of
serial ports via MAVLink over USB.

This makes it possible to update the firmware on a 3DR radio (or RFD900)
embedded in an aircraft without removing it, by plugging into the USB
port on the board and running an updater that is able to use
SERIAL_CONTROL packets instead of normal serial operations.

I've also updated the uploader.py script that comes with SiK to support
mavlink updates of SiK firmware if you pass the --mavlink option. The
way it works is it instantiates a new MavlinkSerialPort object from
pymavlink, which behaves the same as a normal python Serial object, but
communicates via SERIAL_CONTROL mavlink packets. See the following
changes:

https://github.com/mavlink/mavlink/commit/81e75915856ace07989af8511f46b1e63848b075
https://github.com/tridge/SiK/commit/64071b935504ee09626e30e87708566f56cab97d

To use it, run something like this:

tools/uploader.py --port /dev/ttyACM3 new-firmware.ihx --mavlink --mavport=0

that would update the firmware on a radio attached to TELEM1 on a
Pixhawk. It takes about 1 minute to do the update (about 3x as long as
when you are directly attached to the radio). To stop users getting
bored I added a progress bar.

I've also added an example 'serial' command module to MAVProxy that
allows you to run AT commands on a radio attached to a PX4/Pixhawk so
you can change or reset settings on a radio without removing it from an
aircraft:

https://github.com/tridge/MAVProxy/commit/4cd4e0596f1736e64b1120a098809c5149c990cd

The idea behind that is to allow users to solve tricky situations where
their air radio is not able to talk to their ground radio, so they
couldn't previously change its settings without removing it from the
aircraft. Now they will be able to change the air radio settings using a
GCS connected to the USB port of their board.

I'm hoping that APMPlanner and MissionPlanner will implement this new
protocol. Michael? Bill?

The SiK changes also include updates from Luke Hovington to support
uploading firmware to the new RFD900u radios from RFDesign. The RFD900u
needs to use banked programming with 24 bit addresses.

Luke, I also tried to bring in some more of your changes from your SiK
branch to support the RFD900u fully in the master SiK tree, but ran
across the problem of the changed CRC. Can we make a time to discuss how
to bring RFD900u support into upstream?

The new SERIAL_CONTROL protocol also allows for remote manipulation of
GPS serial ports via MAVLink, which in principle will make it possible
to use GPS manipulation/config tools via MAVLink, or to update GPS
firmware via MAVLink. I think it would be possible to write a virtual
serial driver for Windows to make it possible to use u-Blox uCenter on a
remote GPS. It should also make it possible to update a Piksi firmware
via MAVLink. I haven't tested this though, so it will need someone to
write the interface code, test and document it.

Cheers, Tridge

Marco Robustini

unread,
Apr 4, 2014, 5:11:27 PM4/4/14
to drones-...@googlegroups.com, Luke Hovington, saa...@rfdesign.com.au, and...@tridgell.net
This is something I've been waiting a long time, thanks Tridge!
I wait the Planner implementation.

Marco

Josh Welsh

unread,
Apr 4, 2014, 6:38:35 PM4/4/14
to drones-...@googlegroups.com, Luke Hovington, saa...@rfdesign.com.au
This is way awesome, thanks Tridge!
--
You received this message because you are subscribed to the Google Groups
"drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philip Rowse

unread,
Apr 4, 2014, 8:33:33 PM4/4/14
to drones-...@googlegroups.com, Luke Hovington, saa...@rfdesign.com.au, and...@tridgell.net
Thanks Tridge :)  so fast :)

This will make the future soooooo much easier, no need to wory about FTDI on the UAV end.

Thanks
Phil

Andrew Chapman

unread,
Apr 4, 2014, 11:03:05 PM4/4/14
to drones-...@googlegroups.com, Luke Hovington, saa...@rfdesign.com.au, and...@tridgell.net
Nice! 

I've been resisting upgrading because I want all my radios to be the same and one is buried deep in the guts of a skywalker that I didn't want to go fishing for ;)

AC.

Kevin Hester

unread,
Apr 5, 2014, 12:36:44 AM4/5/14
to drones-discuss
great idea!  Remote raw serial tunneled over mavlink can eventually have lots of cool applications... 




Nick Sargeant

unread,
Apr 7, 2014, 5:40:28 AM4/7/14
to drones-...@googlegroups.com

Thank you Tridge. This patch certainly opens up a raft of useful features and as others have mentioned, a modem will be far more convenient to update if you don’t have to dig it out the of an airframe.
On a slight tangent, are there any builds of MK SiK that are compatible with standard 3DR modems?

Kind regards,

mlloyd

unread,
Apr 7, 2014, 12:50:24 PM4/7/14
to drones-...@googlegroups.com, Luke Hovington, saa...@rfdesign.com.au, and...@tridgell.net
Great stuff. Accessing the GPS via u-Center won't even require a virtual serial port driver, I think! u-Center has the ability to connect by TCP (see 'Network connection' in the Receiver menu) so all we need do is write a trivial Python script to export MavlinkSerialPort via a TCP socket. I'd like to try it - have you added serial control to the PX4Firmware yet, and if so can you point me to the commits on github?

Andrew Tridgell

unread,
Apr 7, 2014, 5:23:11 PM4/7/14
to mlloyd, drones-...@googlegroups.com, Luke Hovington, saa...@rfdesign.com.au
Hi Matthew,

> Great stuff. Accessing the GPS via u-Center won't even require a virtual
> serial port driver, I think! u-Center has the ability to connect by TCP
> (see 'Network connection' in the Receiver menu) so all we need do is write
> a trivial Python script to export MavlinkSerialPort via a TCP socket.

ahh, nice!

> I'd like to try it - have you added serial control to the PX4Firmware
> yet, and if so can you point me to the commits on github?

It isn't in the PX4Firmware native stack, but it works fine with the
latest copter/plane/rover firmware for Pixhawk/PX4 from
firmware.diydrones.com. It is probably easiest to test the TCP
capability by extending the mavproxy_serial.py MAVProxy module to add a
"serial listen" command that starts a TCP listen socket which routes
packets through.

Cheers, Tridge

mlloyd

unread,
Apr 7, 2014, 8:16:29 PM4/7/14
to drones-...@googlegroups.com, mlloyd, Luke Hovington, saa...@rfdesign.com.au, and...@tridgell.net
Cool, turns out to work nicely. Running u-Center over the 3DR Radio is a bit slow, but it does work. This little Python script does the trick. Just connect u-Center to tcp://127.0.0.1:1001. Change COM25 to your Mavlink port.

Are the changes going to get pushed to diydrones/PX4Firmware soon? I use my own custom build, but it's based on the master branch.

import mavutil
import socket
import sys

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('127.0.0.1', 1001))
s.listen(1)

conn, addr = s.accept()
conn.setblocking(0)

sp = mavutil.MavlinkSerialPort('COM25', 38400, devnum=2, debug=1)
while True:
	try:
		data = conn.recv(128)
		if data:
			print '>', len(data)
			sp.write(data)
	except socket.error:
		pass

	data = sp.read(128)
	if data:
		print '<', len(data)
		conn.send(data)

Andrew Tridgell

unread,
Apr 7, 2014, 8:26:02 PM4/7/14
to mlloyd, drones-...@googlegroups.com, Luke Hovington, saa...@rfdesign.com.au
Hi Matthew,

> Cool, turns out to work nicely. Running u-Center over the 3DR Radio is
> a bit slow, but it does work. This little Python script does the
> trick. Just connect u-Center to tcp://127.0.0.1:1001. Change COM25 to
> your Mavlink port.

great, thanks for testing that! Do you want to submit this as a sample
script in mavlink/pymavlink/examples ?

> Are the changes going to get pushed to diydrones/PX4Firmware soon? I use my
> own custom build, but it's based on the master branch.

It didn't need any changes to diydrones/PX4Firmware. It would only need
a change in that if you wanted to use the PX4 native stack instead of
APM.

I don't know if Lorenz or anyone else in the PX4 dev team is interested
in adding support for this to the native stack.

Support for SERIAL_CONTROL is in the recent APM:Plane 3.0.0 release, and
I expect it will be in future copter and rover releases as well.

Cheers, Tridge

mlloyd

unread,
Apr 7, 2014, 11:14:09 PM4/7/14
to drones-...@googlegroups.com, mlloyd, Luke Hovington, saa...@rfdesign.com.au, and...@tridgell.net
Hey Tridge,

On Monday, April 7, 2014 8:26:02 PM UTC-4, Andrew Tridgell wrote:
great, thanks for testing that! Do you want to submit this as a sample
script in mavlink/pymavlink/examples ?

Sure thing, here's a pull req: https://github.com/mavlink/mavlink/pull/176
 
It didn't need any changes to diydrones/PX4Firmware. It would only need
a change in that if you wanted to use the PX4 native stack instead of
APM.

Oops, my misunderstanding - I'd looked in the ardupilot tree and found nothing, so I assumed the changes must not be on github and thought they'd be lower level in the PX4 stack itself - but it turns out my tree was just a little bit too out of date. I fetched master and merged, and now I see the serial control addition to ArduCopter in the ardupilot tree.

Awesome! This is going to save me a bunch of time as I debug a couple of GPS issues I'm working through, and I can finally shelve my 'GPS passthrough' CLI patch :)

Cheers,
Matthew
 
Reply all
Reply to author
Forward
0 new messages