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

How to properly include tinyusb in the examples #35

Closed
barbiani opened this issue Dec 2, 2022 · 0 comments
Closed

How to properly include tinyusb in the examples #35

barbiani opened this issue Dec 2, 2022 · 0 comments

Comments

@barbiani
Copy link

barbiani commented Dec 2, 2022

Hi,

I am expanding the flash_stream example with usb functionality can the build is failing with:

/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/flash_stream.dir/flash_stream.c.obj: in function `render_loop':
flash_stream.c:(.time_critical.render_loop+0x8a): undefined reference to `tud_task'
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/flash_stream.dir/flash_stream.c.obj: in function `vga_main':
flash_stream.c:(.text.vga_main+0x3a): undefined reference to `tud_init'
collect2: error: ld returned 1 exit status
make[2]: *** [scanvideo/flash_stream/CMakeFiles/flash_stream.dir/build.make:1129: scanvideo/flash_stream/flash_stream.elf] Error 1
make[1]: *** [CMakeFiles/Makefile2:2439: scanvideo/flash_stream/CMakeFiles/flash_stream.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Something is not going right with the library include I suspect.

I have modified the example cmakelists.txt to be:

if (PICO_ON_DEVICE AND TARGET pico_scanvideo_dpi)
    include(${PICO_SDK_PATH}/lib/tinyusb/hw/bsp/family_support.cmake)

    family_initialize_project(flash_stream ${CMAKE_CURRENT_LIST_DIR})

    add_executable(flash_stream
            flash_stream.c
            usb_descriptors.c
            )
    target_link_libraries(flash_stream PRIVATE
            pico_multicore
            pico_stdlib
            pico_scanvideo_dpi
            hardware_dma
            tinyusb_board
            tinyusb_device
            )
    target_compile_definitions(flash_stream PRIVATE
            PICO_SCANVIDEO_MAX_SCANLINE_BUFFER_WORDS=500
            )
    target_include_directories(flash_stream PUBLIC
        ${CMAKE_CURRENT_LIST_DIR})
    pico_add_extra_outputs(flash_stream)
    pico_enable_stdio_usb(flash_stream 0)
    pico_enable_stdio_uart(flash_stream 0)
    # Uncomment this line to enable fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
    #target_compile_definitions(flash_stream PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)
    pico_add_extra_outputs(flash_stream)
    family_configure_device_example(flash_stream)
endif ()

And flash_stream.c includes:

#include "tusb_config.h"
#include "bsp/board.h"
#include "device/usbd.h"
#include "class/hid/hid_device.h"
#include "tusb.h"

It does compile the file containing the missing functions:

[ 80%] Building C object scanvideo/flash_stream/CMakeFiles/flash_stream.dir/home/barbiani/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c.obj
[ 81%] Building C object scanvideo/flash_stream/CMakeFiles/flash_stream.dir/home/barbiani/pico-sdk/lib/tinyusb/src/device/usbd.c.obj
[ 82%] Building C object scanvideo/flash_stream/CMakeFiles/flash_stream.dir/home/barbiani/pico-sdk/lib/tinyusb/src/device/usbd_control.c.obj

I have followed other tinyusb examples and included what I found to be necessary, but the linking step is still failing.

Any clues?

Thank you.

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

1 participant