Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Failure to obtain Bluetooth responses from a CrazyFlie 2.0 running the ravenscar-cf-stable branch #8

@mayeroa

Description

@mayeroa

Hello, AdaCore wizards.

We are trying to establish communication with a CrazyFlie 2.0 running the “ravenscar-cf-stable” branch of your CertyFlie.

To establish a working baseline, we first built the manufacturer’s firmware with CLOAD=0, to include the radio bootloader. We then flashed it to our CrazyFlie with dfu-util, and were able to run the examples/basiclog.py to establish BlueTooth communication with the Flie and get back stabilizer's roll/pitch/yaw values. So both our HW and our development toolchains appear to be properly setup.

Being fans of Ada, we would prefer now to use the CertyFlie code to control the copter; so we installed the GNAT GPL 2016 toolchain, and built the CertyFlie’s “ravenscar-cf-stable” branch:

$ gprbuild -P cf_ada_spark.gpr -p

$ ls -l obj/cflie.elf
-rwxr-xr-x 1 taste taste 1577600 May 19 15:35 obj/cflie.elf

We flashed the result on the CrazyFlie with dfu-util, and a quick “just drop me” test proved that your free-fall functionality is fully operational.

Unfortunately, the BlueTooth part doesn’t seem to communicate with “basiclog.py”… To see exactly what is happening, we placed a breakpoint with GDB on line 70 of crtp.adb ...

task body CRTP_Rx_Task is                                                               
   Packet : CRTP_Packet;                                                                
   Has_Succeed : Boolean;                                                               
begin                                                                                   
   loop                                                                                 
      Link_Receive_Packet_Blocking (Packet);                                            
                                                                                        
      if Callbacks (Packet.Port) /= null then     <========= HERE ======
         Callbacks (Packet.Port) (Packet);                                              
      else                                                                              
         Port_Queues (Packet.Port).Enqueue_Item (Packet, Has_Succeed);                  
      end if;                                                                           
   end loop;                                                            

...to see the CRTP packets coming over BlueTooth:

$ # AND WHEN WE BREAK, WE PRINT THE “Packet” VARIABLE
$ cat gdb_script.cmd
set pagination off
tar extended-remote :2331
monitor reset
file cflie.elf
load cflie.elf
b crtp.adb:70
commands 1
        silent
        echo Just received a CRTP packet
        p Packet
        cont
end
c

Running the firmware under this GDB script, we see this output:

$ arm-eabi-gdb -x gdb_script.cmd cflie.elf

GNU gdb (GDB) 7.10 for GNAT GPL 2016 [rev=gdb-7.10-ref-161-g9bf8eca]
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
See your support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty for this version of GDB.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-eabi".
Type "show configuration" for configuration details.For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from cflie.elf...done.
0x00000000 in ?? ()

Resetting target
Loading section .text, size 0x471b8 lma 0x8000000
Loading section .ARM.extab, size 0x446c lma 0x80471b8
Loading section .ARM.exidx, size 0x3f30 lma 0x804b624
Loading section .rodata, size 0x9a60 lma 0x804f558
Loading section .data, size 0xc80 lma 0x8058fb8
Start address 0x80399fc, load size 367668
Transfer rate: 32640 KB/sec, 3996 bytes/write.
Breakpoint 1 at 0x800e160: file /home/taste/GitHub/Certyflie/modules/crtp.adb, line 70.

Just received a CRTP packet$1 = (size => 0, channel => 3, reserved => 0, port => 
crtp_port_link, data_1 => (11, 248, 172, 59, 12, 128, 184, 58, 0 <repeats 22 times>), 
header => 243, data_2 => (11, 248, 172, 59, 12, 128, 184, 58, 0 <repeats 22 times>), 
raw => (243, 11, 248, 172, 59, 12, 128, 184, 58, 0 <repeats 22 times>))

Just received a CRTP packet$2 = (size => 0, channel => 3, reserved => 0, port => 
crtp_port_link, data_1 => (76, 203, 134, 64, 12, 128, 184, 58, 0 <repeats 22 times>), 
header => 243, data_2 => (76, 203, 134, 64, 12, 128, 184, 58, 0 <repeats 22 times>), 
raw => (243, 76, 203, 134, 64, 12, 128, 184, 58, 0 <repeats 22 times>))

Just received a CRTP packet$3 = (size => 0, channel => 3, reserved => 3, port => 
crtp_port_link, data_1 => (76, 203, 134, 64, 12, 128, 184, 58, 0 <repeats 22 times>), 
header => 255, data_2 => (76, 203, 134, 64, 12, 128, 184, 58, 0 <repeats 22 times>), 
raw => (255, 76, 203, 134, 64, 12, 128, 184, 58, 0 <repeats 22 times>))
...

At this point, lines like the above (“received CRTP packet”) will keep appearing, until basiclog.py stops waiting and aborts. So, BlueTooth communication seems to be working in the direction PC with BT dongle => CrazyFlie,, but apparently not in the reverse direction - that is, there are no responses coming back to the script.

Can you please indicate if you see something wrong with our approach above?

And is the CertyFlie firmware supposed to be able to reply to these requests from “basiclog.py”? If not, is there any other way we can establish bi-directional communication with the CertyFlie firmware?

Thanks in advance for any help/pointers,
Alexander.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions