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

Development/debug tips #21

Open
mparrett opened this issue Jan 10, 2024 · 7 comments
Open

Development/debug tips #21

mparrett opened this issue Jan 10, 2024 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@mparrett
Copy link

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
Copy link
Owner

hrvach commented Jan 10, 2024

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
Copy link
Author

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
Copy link
Author

mparrett commented Jan 13, 2024

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
Copy link
Author

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
Copy link
Owner

hrvach commented Jan 13, 2024

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
Copy link
Author

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
Copy link
Author

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");

@hrvach hrvach added the documentation Improvements or additions to documentation label Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants