Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug instructions needed #30

Closed
ricardoquesada opened this issue Nov 11, 2020 · 14 comments
Closed

Debug instructions needed #30

ricardoquesada opened this issue Nov 11, 2020 · 14 comments

Comments

@ricardoquesada
Copy link

Hi,

I've reading the different docs, source code, etc, and I couldn't find any doc that mentions how to debug the nina-fw.

For reference:

  • I have a Matrix Portal M4
  • I need to make some changes to the nina-fw (I want to enable bluetooth-classic)
  • But I don't know how to debug it... I'm not asking for gdb... Just a pure "printf" is enough, but it seems that UART is not exposed?

How do you Adafruit developer debug nina-fw in Matrix Portal M4?
thanks!

If this is not the right place, where should I ask/post these kind of questions?, thanks!!

@ladyada
Copy link
Member

ladyada commented Nov 11, 2020

there is a debug output on the esp32 RX / TX pins - you could use debug printf there
https://github.com/adafruit/nina-fw/blob/master/main/sketch.ino.cpp#L96
note that for BLE, at least, we sorta just jump into the HCI manager that does BLE and it doesnt appear anyone has gotten BT classic going yet
arduino#35
it would be super cool!

@ricardoquesada
Copy link
Author

Ah... GPIO1/GPIO3 (TX/RX) are enabled in runtime. That makes sense.

One more: How can I read from these pins?
Should I attach my serial console to the TX/RX pins that are exposed in the Matrix Portal M4 board?

(Just attaching a console to /dev/ttyACM0 doesn't seem to work).

--

I already have BTClassic working in my own firmware. What I'm doing is adding Nina compatibility to my firmware: it only needs to understand some of the SPI commands, plus some extra ones related to gamepad:
https://gitlab.com/ricardoquesada/bluepad32/blob/master/src/main/uni_platform_airlift.c

I want to convert the Matrix Portal M4 + LED Matrix into a game console by adding gamepad support.
(Any Airlift based product will be supported).

Thanks!

@ladyada
Copy link
Member

ladyada commented Nov 11, 2020

the matrix portal has a UART connected to the ESP32 so you could put it into passthru mode by adapting this sketch

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/Adafruit_ESP32_Arduino_Demos/SerialESPPassthrough/SerialESPPassthrough.ino#L100

might be easier to develop the code on separate board with an ESP32 breakout so you can get to the RX/TX pins

@dglaude
Copy link

dglaude commented Nov 11, 2020

The TX and RX exposed are those of the M4, not of the ESP32. Like the passthrough solution, you could have code running on the M4 that copy that over to those pin (read from one UART and write on the other).

From https://learn.adafruit.com/assets/95095 : ESP_RXD (29) and ESP_TXD (30) are connected to PA12/I12/I2C/SERCOM2.0+4.1 and PA13/I13/I2C/SERCOM2.1+4.0. (I love how openhardware and having the schematics car help).

@ricardoquesada
Copy link
Author

many thanks!

@ricardoquesada
Copy link
Author

Many thanks, I was able to have it running. Source code of the new firmware is here:
https://gitlab.com/ricardoquesada/bluepad32/

I'll publish docs, examples and the modified adafrui_esp32spi later.

@ladyada
Copy link
Member

ladyada commented Nov 21, 2020

thats awesome! congrats. please update this thread when you publish and we'll blog it up

@ladyada ladyada closed this as completed Nov 21, 2020
@ricardoquesada
Copy link
Author

Here are the docs:
https://gitlab.com/ricardoquesada/bluepad32/-/blob/master/docs/plat_airlift.md

Here is a patch for adafruit_esp32spi:
adafruit/Adafruit_CircuitPython_ESP32SPI#118

for reference, video showing it working:
https://www.youtube.com/watch?v=h4na4A5wnJ8

This is the list of supported gamepads:
https://gitlab.com/ricardoquesada/bluepad32/-/blob/master/docs/supported_gamepads.md
(DS5 coming soon™)

There are still a few features in my TODO list like: possibility to delete bluetooth keys, gamepad LEDs/color & rumble,...
I'll be adding them in the coming weeks.

Please, let me know if you have any question / doubt / etc.
If anyone try it, I'd love to get feedback (what would you add, change, etc.).

Thanks!

@ricardoquesada
Copy link
Author

mini update: I've just added DualSense (PS5) gamepad support: https://www.youtube.com/watch?v=dbEbiJZd4n8

@ladyada
Copy link
Member

ladyada commented Nov 23, 2020

cool, please see if there's some way we can merge it into nina :)

@ricardoquesada
Copy link
Author

ha! for sure, that would nice! Although I see some possible issue:

The Bluepad32 project is a medium-sizde project (~8000 LoC) without including BTstack code (external dependency). Not sure whether someone from the Adafruit team would like to review that many LoC.

As of today, Bluepad32 only supports two platforms: Unijoyticle (gamepad for retro-computers) and AirLift. But my plan is keep adding support for other platforms... a goal different from Nina's.

Also, if we copy only the relevant parts of Bluepad32 into Nina (kind of a fork), then the future updates that I'll make to Bluepad32 (let's say adding a new gamepad, fixing bugs, etc.) won't be automatically included in Nina.

It might be easier to merge Nina into Bluepad32 (merge 1000 Loc from CommandHandler.cpp + some Arduino libs I guess). But I rather not have the Arduino-for-ESP32 code in Bluepad32 just to have it as simple as possible.

An alternative would be to create a bluepad32-for-airlift static lib + headers to be used at compile/link time in Nina.

What do you all have in mind? Thanks.

@ladyada
Copy link
Member

ladyada commented Nov 23, 2020

you could create a new esp32 binary for folks to load into their airlift board - we need to keep this repo so we can update from upstream :)

@ricardoquesada
Copy link
Author

done: https://github.com/ricardoquesada/bluepad32/releases/tag/release_v2.0.0-beta0 :)

The .zip includes a README with the steps to flash it.

@bettse
Copy link

bettse commented Nov 7, 2021

For anyone coming along later, using platformIO, the ESP32's uart has been exposed in the variant.cpp (which I believe is just being imported from the arduino version) as SerialESP32. I found success outputting the ESP32 uart using

//top of file:
#include "utility/wifi_drv.h"
//In setup:
SerialESP32.begin(baud);
WiFiDrv::debug(1);
//in loop:
while (SerialESP32.available()) {                                                                                                                                                                                                                                
  Serial.write(SerialESP32.read());                                                                                                                                                                                                                              
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants