MAVLINK or ARDUPILOT module

ersky9xr is the port of the er9x firmware to the 9XRPRO radio.
Post Reply
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

MAVLINK or ARDUPILOT module

Post by cxlabs »

Hi Mike, Brent and gang :-)
I got rev B sky9x board (2 years ago) and the new 9xrpro right last week.
I tried to compile ersky9x with ardupilot or mavlink module,
but some dependencies are missed.
I'll try to do it again, but i ask you if you plan to add these modules
like in opentx i am currently using on 9xr...

Great Job, anyway :-) thank a lot

User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: MAVLINK or ARDUPILOT module

Post by MikeB »

I do have the idea of adding these on my "todo" list. The main problem I will have (other than time!) is I don't have either of these available to test. I should be able to get code from er9x for ardupilot, and I know there is mavlink code available.
I just don't know when I will get to these at present.

Any help towards getting these running would be appreciated. What did you do with you compile and what is missing?

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

Hi Mike (and sorry for the long time, i was on holidays),
i'll try to explain my compilation tests hoping to help you and community.
Since you don't have sky9x board or 9xrpro i happily try flashing code on my ones.
But, first, i must compile it :-)

I use the 64bit-linux-slackware distribution and tried several gcc compiler.
The best one was:
gcc version 4.7.3 20130312 (prerelease) (GNU Tools for ARM Embedded Processors / bleeding-edge-toolchain-130503)

Ersky9x-r210 with EXT = STD quits compilation with:
debug.cpp:62:19: fatal error: Audio.h: No such file or directory

Opentx seemed easier to me:
It compiles correctly when makefile has:
PCB = SKY9X
PCBREV = REVB
#EXT = STD
#EXT = MAVLINK
#EXT = ARDUPILOT
EXT = FRSKY
-------> good starting point :-)

Then, to try EXT=MAVLINK, first i changed myeeprom.h file in this way:
-----------------------------------------------------------------------------------------------
//#if defined(FRSKY) || !defined(PCBSTD)
#if defined(FRSKY)
#define TELEMETRY_DATA FrSkyData frsky;
#elif defined(MAVLINK)
#define TELEMETRY_DATA MavlinkData mavlink;
// #define TELEMETRY_DATA MavlinkData mavlink; FrSkyData frsky;
#else
#define TELEMETRY_DATA
#endif
----------------------------------------------------------------------------------------------

but "make" exits with following error

serial.cpp:144:26: fatal error: util/setbaud.h: No such file or directory

I have to investigate how use frsky stile of serial port management:
it seem the source code try always atmega includes...

Thank you Mike and gang for your precious time :-)
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: MAVLINK or ARDUPILOT module

Post by MikeB »

I do have both SKY boards and PXR-PROs, it's ARDUPILOT and MAVLINK I don't have.

Not sure where you got the EXT-STD from for compiling ersky9x or ersky9xr

For the SKY board (ersky9x) use:
make REVB=1 DEBUG=1 STAMP=1 PHASES=1
For the 9XR-PRO (ersky9xr) use:
make REVB=1 DEBUG=1 STAMP=1 PHASES=1 REVX=1

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

Hi, sorry for my mistake :oops:
I have three APM2.5 and a python MAVLINK simulator
and i successful connected 9xr (atmel) with opentx with mavlink module
to a flying apm via openlrs-ng @ 19200 baud.

i just tried make clean, then
----------------------------------------------
root@cxlabs:/usr/local/src/companion9x/ersky9x-r210/src# make REVB=1 DEBUG=1 STAMP=1 PHASES=1
cat: .svn/entries: No such file or directory

Generate Version-stamp:
arm-none-eabi-gcc -c -mcpu=cortex-m3 -Os -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -fverbose-asm -Dat91sam3s4 -DRUN_FROM_FLASH=1 -DPCBSKY -DSTAMP -DREVB -DPHASES -DFRSKY -DCPUARM -DDEBUG -MD -MP -MF skyobj/stamp.o.d -fno-exceptions -I . -I./inc stamp.cpp -o skyobj/stamp.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -Os -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -fverbose-asm -Dat91sam3s4 -DRUN_FROM_FLASH=1 -DPCBSKY -DSTAMP -DREVB -DPHASES -DFRSKY -DCPUARM -DDEBUG -MD -MP -MF skyobj/debug.o.d -fno-exceptions -I . -I./inc debug.cpp -o skyobj/debug.o
In file included from debug.cpp:54:0:
ersky9x.h:32:0: warning: "assert" redefined [enabled by default]
In file included from /usr/local/gcc-arm-none-eabi-4_7-130503/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/include/sys/reent.h:470:0,
from /usr/local/gcc-arm-none-eabi-4_7-130503/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/include/stdlib.h:18,
from debug.cpp:37:
/usr/local/gcc-arm-none-eabi-4_7-130503/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/include/assert.h:16:0: note: this is the location of the previous definition
debug.cpp:62:19: fatal error: Audio.h: No such file or directory
compilation terminated.
make: *** [skyobj/debug.o] Error 1
-----------------------------------------------------------------
but, as you can see, Audio.h is missed
i look into debug.cpp to see include pointings..

Thank you again :)
Last edited by cxlabs on Thu Aug 21, 2014 8:46 pm, edited 1 time in total.

User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

little step forward:
some files (like debug.cpp) refers to Audio.h NOT to audio.h and, you know, UNIX
is particulary sensible to letter case ;)

Then was the turn of Stringidx.h, same as above

Then -- maintenance.cpp:42:21: fatal error: x9d\hal.h: No such file or directory --
little more tricky: linux wants "slash" NOT "backslash" and dir name is to be changed in lowercase

then --> make clean!

SUCCESS!
...
arm-none-eabi-objdump -h -S ersky9x_rom.elf > ersky9x_rom.lss
text data bss dec hex filename
173896 468 24068 198432 30720 ersky9x_rom.elf

.. but now the difficulties starts
i'll try to adapt the opentx-MAVLINK module..
Nice day :D
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: MAVLINK or ARDUPILOT module

Post by MikeB »

I'll see if I can fix those case problems. Does the X9D sub-directory have to be lower case? I actually have it in uppercase both on my local disk and on googlecode.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: MAVLINK or ARDUPILOT module

Post by Kilrah »

MikeB wrote:Does the X9D sub-directory have to be lower case? I actually have it in uppercase both on my local disk and on googlecode.
Well, either you change the directory names to lower case, or you change the include paths to upper case ;)
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

i changed X9D subdir to lowercase and it compiled on my slackware...
Lowercase is preferable from a linux point of view..
Anyway is your code and i am the last arrived :-)

In debug.cpp i see
---
#ifdef PCBX9D
#include "x9d/stm32f2xx.h"
#include "x9d/stm32f2xx_gpio.h"
#include "X9D/i2c_ee.h"
#include "X9D/hal.h"
#endif
---
probably in my compilation switches they never includes...

...same in ersky9x.cpp and others
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

hi Mike,
is there a guide/readme to quickly understand modules (like frsky) in ersky9x structure ?

I started study code but modules general structure will be a time-consuming task..

Thank you in advance :D
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: MAVLINK or ARDUPILOT module

Post by MikeB »

Not really I'm afraid. The code has just 'grown' over time.

I'll help all I can.
Would I be correct in thinking what you need is a serial port and you need to receive all the bytes on it to a MAVLINK specific routine and to be able to send a buffer of bytes out to the serial port?
If so, what baudrate do you need it set to?

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

Hi,
you are right. Basically MAVLINK protocol comes from APM autopilot on plane
and reach ersky9x via 433Mhz-Openlrs-ng serial link.
I experiment 9600 and 19200 baud trimming down MAVLINK packets to
essential informations (GPS fix and battery Voltage level)
Mavlink is a binary protocol (CRC'ed) and we can choose which packet send
and repetition rate.
For me 19200 baud was a good compromise between refresh rate and 433Mhz-RTX range.
Kari Hautio (openlrs-ng creator) claims to reach 57200 baud, but i can't succeded with opentx+mavlink
Maybe too many packet loss due to bad CRC (or my inexperience :-)

If can be useful, i'll send a binary capture file with initial couple of minutes of data
received by openlrs-ng TX module on my 9xr..

Here is a link to mavlink menus i currently use
viewtopic.php?f=45&t=4012

Thank you!!
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

Hi Mike and gang,
i am trying to understand frsky module of ersy9x and it seems
and all serial interface and protocol decoding is contained
in frsky.cpp
Data exchange is obtained by global vars.

If i'm not wrong, this file could be the starting point to adapt
MAVLINK decoding.
Display them will be another story..

All standard #defines/structures for mavlink should be included
from APM:Plane sources like opentx do.

Am I pointed in correct direction ?

Thank you a lot
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: MAVLINK or ARDUPILOT module

Post by MikeB »

I'm working on some changes to make this easier to add.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

To avoid efforts duplication, i think it's better
waiting your mods.

Tell me if i can help somehow
in linux-compiling or mavlink radio test.

Here is a suggestion (even if it is difficult to reach):
I use both frsky and mavlink telemetry.
Since skynorth board and 9xrpro have a lot
of flash, It will be great having two protocol
selectable on model basis.

Have a good day :-)
Adriano.
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

Hi Mike,
did you progress in MAVLINK adaptation?
Can i help in some way ?

Thank you!
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: MAVLINK or ARDUPILOT module

Post by MikeB »

I've started a new thread to help me get extra telemetry protocols operating:
viewtopic.php?f=123&t=6167.

This will help me keep track of all the requirements, and report progress.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: MAVLINK or ARDUPILOT module

Post by MikeB »

Just committed the source files. The 9XR-PRO now the start of support of MAVLINK. There is an option in the TELEMETRY menu to select MAVLINK (instead of FrHub).
There is a new file "mavlink.h" that includes a define for tha baudrate.
There is a new file "mavlink.cpp" that just has a single procedure "void mavlinkReceive( uint8_t data )". This is called with every received telemetry data byte when MAVLINK telemetry is selected.

Mike.

Edit: Further progress and comments will now be on the 'other' thread.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
cxlabs
Posts: 31
Joined: Thu Jun 28, 2012 3:08 pm
Country: -

Re: MAVLINK or ARDUPILOT module

Post by cxlabs »

I will flash my 9xrpro and Skynorth-9x ASAP!

Thank you!

Post Reply

Return to “ersky9xr”