micro-ROS / micro-ROS_crazyflie_demo

Provides a demo of micro-ROS based on a Crazyflie.
Apache License 2.0
18 stars 6 forks source link

M2 LED on the Crazyflie remains on #7

Closed romi2002 closed 4 years ago

romi2002 commented 4 years ago

After flashing the compiled firmware (through the radio as DFU has not worked for me) the M2 led remains on and the crazyflie does not respond to the cfclient. Is there something I could do to debug this?

pablogs9 commented 4 years ago

We have not tested the firmware flashed by radio and we don't know if it can cohabit with the bootloader. Have you disconnected the battery before trying to enter DFU mode?. You can debug using a JTAG with this adapter https://www.bitcraze.io/products/debug-adapter-kit/.

Usually, these kinds of problems (M2 red light) is related to memory issues. This demo is not in a final state, so these kinds of problems can appear. Please check if your app stack is big enough and you have enough heap for dynamic memory allocation.

romi2002 commented 4 years ago

I've finally been able to get a debug adapter, how can I debug this issue? Is there a way to use OpenOCD or GDB with the modified firmware?

pablogs9 commented 4 years ago

We are using the Cortex Debug extension for visual studio code: https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug

It works with the our Segger JLink debug. Here some notes that I took to enable CF debugging, they are not official, just some notes of mine. Debugging may be painful:

  1. Install VSC Cortex-Debug
  2. apt install gdb-multiarch
  3. Set "cortex-debug.armToolchainPath": "/usr/bin" in setting.json
  4. ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb
  5. apt install ./JLink_Linux_V655a_x86_64.deb --fix-missing
  6. set debug flag in build system Makefile
  7. Set the launch.json:
    {
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "jlink",
            "cwd": "/crazyflie_extensions",
            "executable": "./cf2.elf",
            "name": "Debug (J-Link)",
            "device": "STM32F405RG",
            "interface": "swd",
            "svdFile": ""
        }
    ]
    }

Here you can find the .deb and the svd Files: https://drive.google.com/drive/folders/1YP3TEPfddPVxIhgkyxODlBrPYZS0eNVl?usp=sharing

romi2002 commented 4 years ago

Looks like I was flashing the firmware wrong, since the USB port on my crazyflie doesn't work, I was flashing it with a J-Link. However, it appears that using the make flash from crazyflie-firmware (using the compiled firmware from micro-ROS) doesn't work. Flashing it with the Cortex-Debug did work. Maybe in the future there could be a way to specify whether to use DFU, SWD or maybe even the radio for firmware flashing? Thanks for your help.

pablogs9 commented 4 years ago

Hello, currently we only have support for flashing the CF by the USB. Maybe if you can adapt it to flash with the J-Link you could PR the changes to the build system repo: https://github.com/micro-ROS/micro-ros-build