hrvach / deskhop

Fast Desktop Switching Device
GNU General Public License v3.0
5.97k stars 168 forks source link

Development/debug tips #21

Open mparrett opened 5 months ago

mparrett commented 5 months ago

Hello,

Thank you for sharing your project! I'm building a deskhop this week and I'm curious to see if it solves some of the pain I've been putting up with for years.

I'd love to support and have a handful of Logitech and other devices I can test with. Do you have any suggestions for development setup? Specifically any guidance around debugging would be greatly appreciated! So far I'm able to build and flash the devices but end up with flashing LEDs. I'm guessing this is due to some MacOS idiosyncrasy or the fact that it's all roughly cobbled together on a breadboard until Friday when the PCB arrives, but I am eager to debug. I have a FTDI device, and other pis I could use as serial debuggers... but somewhat uncharted territory at the moment.

Thanks again!

hrvach commented 5 months ago

Try checking if you pico-sdk has a recent tinyusb in the lib folder.

For debugging, SWD works great (you can use another pico as "picoprobe" and that works great!)

USB stdio is tricky when you already have tinyusb doing a device, but you can add a CDC with #define CFG_TUD_CDC 1 in tusb_config.h, you'd need to add a descriptor, something like:

    TUD_CDC_DESCRIPTOR(ITF_NUM_CDC,
                       STRID_CDC_INTERFACE,
                       EPNUM_CDC_NOTIF,
                       8,
                       EPNUM_CDC_OUT,
                       EPNUM_CDC_IN,
                       CFG_TUD_CDC_EP_BUFSIZE),

... check some of the CDC examples for tinyusb, then you can tud_cdc_n_write() to output strings and use a serial device created to receive them... of course, uart1 is available if that's the preferred route (and it's way easier than CDC).

Do binaries in the "release" section work on your breadboard? Don't worry, I'll try to help and we'll get it working for you somehow :)

mparrett commented 5 months ago

Thanks for the quick and helpful response. I'll have some time this weekend to hopefully make progress.

Do binaries in the "release" section work on your breadboard?

I can load the binaries and device A LED is illuminated. Device B LED is not illuminated. When I flash with a .uf2 that I built myself, I get a flashing LED.

mparrett commented 5 months ago

Update: Investigating a possible root cause with the arm toolchain, i.e.gcc-arm-embedded vs gcc-arm-none-eabi (had issues with the latter on macos initially and followed some instructions to use the -embedded package. But I see now that could be causing issues with my builds.

Perhaps something along these lines would be better to fix my environment: https://mynewt.apache.org/v1_5_0/get_started/native_install/cross_tools.html#installing-the-arm-toolchain-for-mac-os-x

mparrett commented 5 months ago

Progress - solid LEDs after flashing with my own build! Uninstalled all eabi packages in homebrew, and reinstalled arm toolchain with brew install --cask gcc-arm-embedded

hrvach commented 5 months ago

Yep, for mac os it seems you need to take the gcc-arm-embedded route, also you need to git pull latest tinyusb in pico-sdk/lib/tinyusb). Fingers crossed! :)

mparrett commented 5 months ago

I appear to have a viable debug setup using a pi zero! For a "hello world" program I'm able to connect to gdb and also read stdio using minicom. Next I'll see if I can do the same with Deskhop!

mparrett commented 5 months ago

Happy to report I've got a foothold on debugging. Thanks for the help! Relevant snippets below:

Relevant snippets:

build.sh

cmake -DCMAKE_BUILD_TYPE=Debug

CMakeLists.txt

# debug setup: enable stdio via uart on board A
pico_enable_stdio_uart(board_A 1)

main.h

#define SERIAL_DEBUG_TX_PIN 4 // GPIO 4 -> pin 6
#define SERIAL_DEBUG_RX_PIN 5 // GPIO 5 -> pin 8

setup.c

stdio_uart_init_full(uart1, 115200, SERIAL_DEBUG_TX_PIN, SERIAL_DEBUG_RX_PIN);
printf("hello from pico\n");