Skip to content

Please help with tinyUSB cmake minimum sample #3354

@Matthias32

Description

@Matthias32

Operating System

Others

Commit SHA

3af1bec

Board

STM32C071

Firmware

CDC Sample

What happened ?

HI,

Im trying now for days to make a very simple tinyUSB USB CDC sample with a STM32 Nucelo C071 board. I have searched the whole internet but found no explanation to my problem. Im failing to integrate the tinyUSB lib into my project. Can someone explain a minimal cmake example how to implement the tinyUSB lib?

BR
Matthias

How to reproduce ?

My cmake so far:

cmake_minimum_required(VERSION 3.22)

This file is generated only once and is not re-generated if the converter is called multiple times.

The user is free to modify the file as much as necessary.

Setup compiler settings

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)

Define the build type

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()

Set the project name

set(CMAKE_PROJECT_NAME STM32F746DISCO-TinyUSB-MSC)

Include toolchain file for ARM GCC

include("cmake/gcc-arm-none-eabi.cmake")

Enable compile commands to ease indexing with tools like clangd

set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

Enable CMake support for ASM and C languages

enable_language(C ASM)

Core project settings

project(${CMAKE_PROJECT_NAME})
message("Build type: ${CMAKE_BUILD_TYPE}")

Create an executable object type

add_executable(${CMAKE_PROJECT_NAME})

Add STM32CubeMX generated sources

add_subdirectory(cmake/stm32cubemx)

Define the TinyUSB configuration target as an INTERFACE library

add_library(tinyusb_config INTERFACE)

Add TinyUSB include paths

target_include_directories(tinyusb_config INTERFACE
Core/Inc
tinyusb/src
tinyusb/hw
)

Add TinyUSB directory

add_subdirectory(tinyusb/src)

Link directories setup (if needed, add user-defined library search paths)

target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user-defined library search paths
)

Add sources to executable

target_sources(${CMAKE_PROJECT_NAME} PRIVATE
# TinyUSB Example (CDC-MSC) source files
Core/Src/msc_disk.c
Core/Src/usb_descriptors.c
tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c
)

Add include paths to the main executable

target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user-defined include paths
)

Add project symbols (macros)

target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
# Add user-defined symbols
)

Add linked libraries

target_link_libraries(${CMAKE_PROJECT_NAME}
stm32cubemx
# TinyUSB Library Stack
tinyusb_config
tinyusb
)

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

FAILED: STM32F746DISCO-TinyUSB-MSC.elf
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\ST\STM32CubeCLT_1.18.0\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -Wall -Wextra -Wpedantic -fdata-sections -ffunction-sections -O0 -g3 -g -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -T "C:/Users/M.Zeleny/Downloads/STM32F746DISCO-TinyUSB-MSC-master/STM32F746DISCO-TinyUSB-MSC-master/STM32F746NGHx_FLASH.ld" --specs=nano.specs -Wl,-Map=STM32F746DISCO-TinyUSB-MSC.map -Wl,--gc-sections -Wl,--start-group -lc -lm -Wl,--end-group -Wl,--print-memory-usage CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Core/Src/msc_disk.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Core/Src/usb_descriptors.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Core/Src/main.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Core/Src/stm32f7xx_it.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Core/Src/stm32f7xx_hal_msp.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd_ex.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_exti.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Core/Src/system_stm32f7xx.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Core/Src/sysmem.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/Core/Src/syscalls.c.obj CMakeFiles/STM32F746DISCO-TinyUSB-MSC.dir/startup_stm32f746xx.s.obj -o STM32F746DISCO-TinyUSB-MSC.elf -ltinyusb && cd ."
C:/ST/STM32CubeCLT_1.18.0/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -ltinyusb: No such file or directory

Screenshots

No response

I have checked existing issues, discussion and documentation

  • I confirm I have checked existing issues, discussion and documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions