adafruit / nina-fw

Firmware for u-blox NINA W102 WiFi/BT module
85 stars 43 forks source link

Debug instructions needed #30

Closed ricardoquesada closed 4 years ago

ricardoquesada commented 4 years ago

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:

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 commented 4 years ago

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 https://github.com/arduino/nina-fw/issues/35 it would be super cool!

ricardoquesada commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

many thanks!

ricardoquesada commented 4 years ago

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 commented 4 years ago

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

ricardoquesada commented 4 years ago

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

Here is a patch for adafruit_esp32spi: https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/pull/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 commented 4 years ago

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

ladyada commented 4 years ago

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

ricardoquesada commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

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());                                                                                                                                                                                                                              
}