Use the USB port on Parrot Drones

From PaparazziUAV
Revision as of 01:34, 26 February 2019 by Openuas (talk | contribs) (How)

Jump to: navigation, search

USE USB port on Parrot Drones

There are many used for the USB port on a Parrot Drone. The first kickof of the page is about using serial devices via USB, the most common scenario. Ofcourse there are more, feel free to add you solutions on this page

Serial modem on Parrot

Add a external modem Bebop, Bebop 2 or Disco and maybe even others...

Beware

Wherever you read /lib/modules/3.4.11\+/ is for a Bebop /lib/modules/3.4.11/, mind the plus. If you read Bebop it might as well be Disco, althoug on the MTP there are some differences.

Example

A 20Km telemetry connection with the Parrot Bebop by means of a RFD868 modem or some other modem that does the trick

Needs

Somehow send and receive bytes to the RFD868 modem, be it serial or otherwise.

Works for

Tested and works on Disco Firmware 1.7.1, Bebop Firmware 1.98 and 2.0.57, Bebop 2 not tested yet, but very likely works fine. If developer find time, we will validate.

Strategy

Use the USB port on the backside of the AP mainboard. The USB is by default on Bebop hooked to the MTP media transfer protocol server... let's stop this service so it will not interfere with our datastream wishes.

Stop MTP service

Log into your Bebop, make a WiFi connection then

$ telnet 192.168.42.1

So in the Bebop console we are root, yeah...OK stop the service via:

**# /bin/sh /bin/mtp_server.sh stop**

First tryout, USB plug convertor

Plug in a OTG micro converter to USB Serial device [| like this one]

So plugh in a 3v3 FTDI USB cable

# dmesg 

gives:

usb 2-1: new full-speed USB device number 2 using ci_hdrc

Sadly no default FTDI suppoert on the Bebop, lets fix this...


Add serial hardware driver

# find -iname *ko

on the Parrot bebop we find:

./data/ftp/usbserial.ko
./data/ftp/internal_000/usbserial.ko
./data/ftp/internal_000/ftdi_sio.ko

...lucky us ;), let's go and interrogate them, see what we have here via:

If your are not so lucky you have to go to this page to build them

# modinfo usbserial.ko && modinfo ftdi_sio.ko

that is just dandy , let's add them to this file /lib/modules/3.4.11/modules.dep

First we need to be able to Write change on the Drone main storage medium, let make it happen via:

# mount -o remount,rw /

we start up an editor on the device call "VI" via:

# vi /lib/modules/3.4.11\+/modules.dep

VI quick 'n dirty: Go to edit mode with

:e[ENTER]

Then go to a line where you want to insert the lines and press

i+[ENTER]

Sometimes even this works:

[SHIFT]+[ENTER]

Then copy this line below from this text:

/data/ftp/internal_000/usbserial.ko

Paste it via

[CTRL]+[SHIFT]+[V]

and again new empty line via a

[SHIFT]+[ENTER]

Copy this line

/data/ftp/internal_000/ftdi_sio.ko

Paste it again via

 [CTRL]+[SHIFT]+[V]

Press [ESC]

Then let's write the file via:

:w[ENTER]

Now active the driver, manually first, and one can autostart it automate it later after the proof of concept works...

# insmod /data/ftp/internal_000/usbserial.ko 
# insmod /data/ftp/internal_000/ftdi_sio.ko
# cd /data/ftp/internal_000/
# modprobe usbserial.ko
# modprobe ftdi_sio.ko

on to some testing... conect whatever serial devec that outputs stuff to the FTDI cable, e.g. and GPS receiver, then draw in the serial garbage via:

# cat /dev/ttyUSB0

Improvement on the theme

Autostart

Outcome

A serial port on Bebop at startup

Disable MTP autostart

Changed, as dirty as we are, the mtp_server.sh script and renamed the mtp_prog name to use to domthing no existing... thus MTP server program would not be found so not started

Copy modules to system

Where

The /lib/modules/3.4.11/kernel/drivers/usb/serial/ looks like a good spot to us

How

Upload the driver files wia FTP then telnet into an move e.m

# mkdir /lib/modules/3.4.11\+/kernel/drivers/usb/serial

Note: The directory could as well be without a + on your Bebop 1 or even a /lib/modules/2.6.36-102952-g6aedf2e9100/kernel/drivers/usb/serial on a Mambo...

# mv /data/ftp/internal_000/usbserial.ko /lib/modules/3.4.11\+/kernel/drivers/usb/serial
# mv /data/ftp/internal_000/option.ko /lib/modules/3.4.11\+/kernel/drivers/usb/serial
# mv /data/ftp/internal_000/usb_wwan.ko /lib/modules/3.4.11\+/kernel/drivers/usb/serial
# mv /data/ftp/internal_000/ftdi_sio.ko /lib/modules/3.4.11\+/kernel/drivers/usb/serial
# mv /data/ftp/internal_000/cp210x.ko /lib/modules/3.4.11\+/kernel/drivers/usb/serial
# mv /data/ftp/internal_000/pl2303.ko /lib/modules/3.4.11\+/kernel/drivers/usb/serial
# mv /data/ftp/internal_000/ch341.ko /lib/modules/3.4.11\+/kernel/drivers/usb/serial

Add modules to modules.dep

Read a bit about :e :w :q etc. of VI and Busybox, then;

vi /lib/modules/3.4.11\+/modules.dep

Add these lines in between somewhere like so:

...
kernel/drivers/parrot/iio/adc/p7temp.ko: kernel/drivers/iio/industrialio.ko
{STARTHERE}
kernel/drivers/usb/serial/usbserial.ko
kernel/drivers/usb/serial/option.ko
kernel/drivers/usb/serial/usb_wwan.ko
kernel/drivers/usb/serial/ftdi_sio.ko 
kernel/drivers/usb/serial/cp210x.ko
kernel/drivers/usb/serial/pl2303.ko
kernel/drivers/usb/serial/ch341.ko
{ENDHERE}
kernel/arch/arm/oprofile/oprofile.ko
kernel/net/wireless/lib80211.ko:
kernel/net/wireless/lib80211_crypt_wep.ko: kernel/net/wireless/lib80211.ko
...


To save these changes in the file press [ESC] than :w+[ENTER] then :q+[ENTER]

Quicktest ==

Add to system instantly in this order, do this:

# insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/usbserial.ko
# insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/ftdi_sio.ko

Start kernel module USBSerial and FTDI

Add modprobe somewhere e.g /etc/init.d/rcS

# vi /etc/init.d/rcS

Look for other modprobes ones then add these there:

...
#/sbin/sysmon.sh &                                                        
{HERE}                                                                                      
insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/usbserial.ko
insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/option.ko
insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/usb_wwan.ko
insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/ftdi_sio.ko
insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/cp210x.ko
insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/pl2303.ko
insmod /lib/modules/3.4.11\+/kernel/drivers/usb/serial/ch341.ko
{ENDHERE}                                                                     
ulogi "rcS init script done"
                                                                                      
exit 0 

Time to reboot to test via

# reboot now

Make a better custom cable:

  1. Get a 3V# FTDI Real FTDI to USB small PCB
  2. Desolder the USB plug
  3. Get a microUSB cable an cut it and solder to USB side of FTDI PCB

{TODO Photo}


Separate Power

At a 1W setting it is not possible to draw power from the USB so a separate powersource must be found or create. There is none, so one can add a BEC that can give 5V at least 5A continuous and is wel shielded to the drone...

BEC to Bebop Howto and where

  1. At the base where the Power goes to the Bobop Board pull a little on red and black silicone shield
  2. Fux and solder on base of wire a bit
  3. solder CC BEC RED to RED Black to Black on Base

{TODO} Photo

  1. Add a dot of Hotglue to isolate an get mechanical strength for cables not to break off there
  2. Plugh in Bebop Battery, measure voltage from BEC , should be 5V

Alternative idea

Serial Data in and out via the console port, why not...

First there is the serial port used as shell access. see also http://forum.parrot.com/usa/viewtopic.php?id=30330

Disable serial shell

In the /etc/inittab we find:

...
# Put a an on-demand shell on first serial port with outputs redirected to
# zprint. Note: force interactive shell since zprint is not a tty...
ttyPA0::askfirst:-/bin/sh -l
tty1::askfirst:-/bin/sh
...

So let's disable it and start using the serial port for other nifty stuff...

Howza

look for serial console info

$ cat /var/log/messages

Gives

...
Jan  1 00:00:07 (none) user.info broadcom_setup.sh: (insmod) : CURRENT_TTY = /dev/console
Jan  1 00:00:07 (none) user.info broadcom_setup.sh: Load Modules :
Jan  1 00:00:08 (none) user.info broadcom_setup.sh: (create_net_interface) : CURRENT_TTY = /dev/console

Using the serial link

Links