Dear all,
I like to use the RP2040 Raspi Pico, with RT-Thread standard and tinyUSB. I use scons --menuconfig to enable tinyUSB, set it to CDC, and select the "build example" item.
Compile, flash, but no USB-Uart or any serial device on the computer. Try it on Windows 10 and Ubuntu 22.
Is tinyUSB and RT-Thread and RP2040 working together? Did I forgot something?
scons: Reading SConscript files ...
Newlib version: 2.4.0
Enter /home/hansd/rt_thread/rt-thread/bsp/raspberry-pico/packages/raspberrypi-pico-sdk-latest
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
CC build/applications/main.o
CC build/board/board.o
CC build/drivers/drv_gpio.o
CC build/drivers/drv_uart.o
CC build/kernel/components/drivers/core/device.o
CC build/kernel/components/drivers/ipc/completion.o
CC build/kernel/components/drivers/ipc/dataqueue.o
CC build/kernel/components/drivers/ipc/pipe.o
CC build/kernel/components/drivers/ipc/ringblk_buf.o
CC build/kernel/components/drivers/ipc/ringbuffer.o
CC build/kernel/components/drivers/ipc/waitqueue.o
CC build/kernel/components/drivers/ipc/workqueue.o
CC build/kernel/components/drivers/misc/pin.o
CC build/kernel/components/drivers/serial/serial.o
CC build/kernel/components/finsh/cmd.o
CC build/kernel/components/finsh/msh.o
CC build/kernel/components/finsh/msh_parse.o
CC build/kernel/components/finsh/shell.o
CC build/kernel/components/libc/compilers/common/cstdlib.o
CC build/kernel/components/libc/compilers/common/cstring.o
CC build/kernel/components/libc/compilers/common/ctime.o
CC build/kernel/components/libc/compilers/common/cunistd.o
CC build/kernel/components/libc/compilers/newlib/syscalls.o
CC build/kernel/libcpu/arm/common/showmem.o
CC build/kernel/src/clock.o
CC build/kernel/src/components.o
CC build/kernel/src/idle.o
CC build/kernel/src/ipc.o
CC build/kernel/src/irq.o
CC build/kernel/src/kservice.o
CC build/kernel/src/mem.o
CC build/kernel/src/mempool.o
CC build/kernel/src/object.o
CC build/kernel/src/scheduler_up.o
CC build/kernel/src/thread.o
CC build/kernel/src/timer.o
AS build/libcpu/context_gcc.o
CC build/libcpu/cpuport.o
CC build/packages/raspberrypi-pico-sdk-latest/src/rp2_common/pico_runtime/runtime.o
LINK rtthread-pico.elf
arm-none-eabi-objcopy -O binary rtthread-pico.elf rtthread.bin
arm-none-eabi-size rtthread-pico.elf
text data bss dec hex filename
104336 0 4432 108768 1a8e0 rtthread-pico.elf
/home/hansd/rt_thread/rt-thread/bsp/raspberry-pico/tools/elf2uf2 rtthread-pico.elf rtthread-pico.uf2
scons: done building targets.
Thanks for any help.
Dear rbbbb,
I downloaded the latest version from https://github.com/RT-Thread/rt-thread 2 days ago.
In the rt_thread/rt-thread/ChangeLog.md, it says V5.0.2
I am still very new to RT-Thread. It seems, I forgot "pkgs --update" after selecting tinyUSB in menuconfig. So I did the update, then start scons again.
Give a lot of error messages:
scons: Reading SConscript files ...
Newlib version: 2.4.0
Enter /home/micha/rt_thread/rt-thread/bsp/raspberry-pico/packages/raspberrypi-pico-sdk-latest
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
CC packages/TinyUSB-v0.14.1/rt-thread/bsp/rp2040/drv_tinyusb.o
CC packages/TinyUSB-v0.14.1/rt-thread/tinyusb_port.o
CC packages/TinyUSB-v0.14.1/rt-thread/usb_descriptor.o
CC packages/TinyUSB-v0.14.1/src/class/cdc/cdc_device.o
CC packages/TinyUSB-v0.14.1/src/common/tusb_fifo.o
CC packages/TinyUSB-v0.14.1/src/device/usbd.o
CC packages/TinyUSB-v0.14.1/src/device/usbd_control.o
CC packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.o
In file included from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/rp2040_usb.h:11:0,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:32:
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:91:15: error: expected declaration specifiers or '...' before 'sizeof'
static_assert(sizeof(usb_device_dpram_t) == USB_DPRAM_MAX, "");
^~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:91:60: error: expected declaration specifiers or '...' before string constant
static_assert(sizeof(usb_device_dpram_t) == USB_DPRAM_MAX, "");
^~
In file included from /opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/stdio.h:36:0,
from packages/TinyUSB-v0.14.1/src/common/tusb_common.h:67,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/rp2040_usb.h:8,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:32:
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:92:15: error: expected declaration specifiers or '...' before '__builtin_offsetof'
static_assert(offsetof(usb_device_dpram_t, epx_data) == 0x180, "");
^
In file included from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/rp2040_usb.h:11:0,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:32:
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:92:64: error: expected declaration specifiers or '...' before string constant
static_assert(offsetof(usb_device_dpram_t, epx_data) == 0x180, "");
^~
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:121:15: error: expected declaration specifiers or '...' before 'sizeof'
static_assert(sizeof(usb_host_dpram_t) == USB_DPRAM_MAX, "");
^~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:121:58: error: expected declaration specifiers or '...' before string constant
static_assert(sizeof(usb_host_dpram_t) == USB_DPRAM_MAX, "");
^~
In file included from /opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/stdio.h:36:0,
from packages/TinyUSB-v0.14.1/src/common/tusb_common.h:67,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/rp2040_usb.h:8,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:32:
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:122:15: error: expected declaration specifiers or '...' before '__builtin_offsetof'
static_assert(offsetof(usb_host_dpram_t, epx_data) == 0x180, "");
^
In file included from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/rp2040_usb.h:11:0,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:32:
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:122:62: error: expected declaration specifiers or '...' before string constant
static_assert(offsetof(usb_host_dpram_t, epx_data) == 0x180, "");
^~
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:32:38: error: expected declaration specifiers or '...' before '(' token
#define USB_HOST_INTERRUPT_ENDPOINTS (USB_NUM_ENDPOINTS - 1)
^
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:576:16: note: in expansion of macro 'USB_HOST_INTERRUPT_ENDPOINTS'
static_assert( USB_HOST_INTERRUPT_ENDPOINTS == 15, "");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:576:52: error: expected declaration specifiers or '...' before string constant
static_assert( USB_HOST_INTERRUPT_ENDPOINTS == 15, "");
^~
In file included from packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h:12:0,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/rp2040_usb.h:11,
from packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:32:
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c: In function 'hw_handle_buff_status':
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: warning: implicit declaration of function 'typeof' [-Wimplicit-function-declaration]
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
^
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:201:13: note: in expansion of macro 'usb_hw_clear'
usb_hw_clear->buf_status = bit;
^~~~~~~~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: error: called object is not a function or function pointer
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:201:13: note: in expansion of macro 'usb_hw_clear'
usb_hw_clear->buf_status = bit;
^~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c: In function 'dcd_rp2040_irq':
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: error: called object is not a function or function pointer
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:258:25: note: in expansion of macro 'usb_hw_clear'
if (!_sof_enable) usb_hw_clear->inte = USB_INTS_DEV_SOF_BITS;
^~~~~~~~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: error: called object is not a function or function pointer
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:281:9: note: in expansion of macro 'usb_hw_clear'
usb_hw_clear->sie_status = USB_SIE_STATUS_SETUP_REC_BITS;
^~~~~~~~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: error: called object is not a function or function pointer
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:314:9: note: in expansion of macro 'usb_hw_clear'
usb_hw_clear->sie_status = USB_SIE_STATUS_BUS_RESET_BITS;
^~~~~~~~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: error: called object is not a function or function pointer
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:334:9: note: in expansion of macro 'usb_hw_clear'
usb_hw_clear->sie_status = USB_SIE_STATUS_SUSPENDED_BITS;
^~~~~~~~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: error: called object is not a function or function pointer
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:341:9: note: in expansion of macro 'usb_hw_clear'
usb_hw_clear->sie_status = USB_SIE_STATUS_RESUME_BITS;
^~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c: In function 'dcd_remote_wakeup':
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:108:27: error: called object is not a function or function pointer
#define hw_set_alias(p) ((typeof(p))hw_set_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:49:20: note: in expansion of macro 'hw_set_alias'
#define usb_hw_set hw_set_alias(usb_hw)
^~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:426:3: note: in expansion of macro 'usb_hw_set'
usb_hw_set->inte = USB_INTS_DEV_SOF_BITS;
^~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:108:27: error: called object is not a function or function pointer
#define hw_set_alias(p) ((typeof(p))hw_set_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:49:20: note: in expansion of macro 'hw_set_alias'
#define usb_hw_set hw_set_alias(usb_hw)
^~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:427:3: note: in expansion of macro 'usb_hw_set'
usb_hw_set->sie_ctrl = USB_SIE_CTRL_RESUME_BITS;
^~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c: In function 'dcd_disconnect':
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: error: called object is not a function or function pointer
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:434:3: note: in expansion of macro 'usb_hw_clear'
usb_hw_clear->sie_ctrl = USB_SIE_CTRL_PULLUP_EN_BITS;
^~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c: In function 'dcd_connect':
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:108:27: error: called object is not a function or function pointer
#define hw_set_alias(p) ((typeof(p))hw_set_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:49:20: note: in expansion of macro 'hw_set_alias'
#define usb_hw_set hw_set_alias(usb_hw)
^~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:441:3: note: in expansion of macro 'usb_hw_set'
usb_hw_set->sie_ctrl = USB_SIE_CTRL_PULLUP_EN_BITS;
^~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c: In function 'dcd_sof_enable':
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:108:27: error: called object is not a function or function pointer
#define hw_set_alias(p) ((typeof(p))hw_set_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:49:20: note: in expansion of macro 'hw_set_alias'
#define usb_hw_set hw_set_alias(usb_hw)
^~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:452:5: note: in expansion of macro 'usb_hw_set'
usb_hw_set->inte = USB_INTS_DEV_SOF_BITS;
^~~~~~~~~~
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:109:29: error: called object is not a function or function pointer
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:50:22: note: in expansion of macro 'hw_clear_alias'
#define usb_hw_clear hw_clear_alias(usb_hw)
^~~~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:455:5: note: in expansion of macro 'usb_hw_clear'
usb_hw_clear->inte = USB_INTS_DEV_SOF_BITS;
^~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c: In function 'dcd_edpt_stall':
packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h:108:27: error: called object is not a function or function pointer
#define hw_set_alias(p) ((typeof(p))hw_set_alias_untyped(p))
~^~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:49:20: note: in expansion of macro 'hw_set_alias'
#define usb_hw_set hw_set_alias(usb_hw)
^~~~~~~~~~~~
packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.c:504:5: note: in expansion of macro 'usb_hw_set'
usb_hw_set->ep_stall_arm = (tu_edpt_dir(ep_addr) == TUSB_DIR_IN) ? USB_EP_STALL_ARM_EP0_IN_BITS : USB_EP_STALL_ARM_EP0_OUT_BITS;
^~~~~~~~~~
scons: * [packages/TinyUSB-v0.14.1/src/portable/raspberrypi/rp2040/dcd_rp2040.o] Error 1
scons: building terminated because of errors
I got some progress. There seem to be some gcc or/and C99 problems with the TinyUSB package. I am now able to compile, after doing the following hacks:
/home/micha/rt_thread/rt-thread/bsp/raspberry-pico/packages/raspberrypi-pico-sdk-latest/src/rp2040/hardware_structs/include/hardware/structs/usb.h
(see also here: https://github.com/raspberrypi/pico-sdk/issues/339)
Handle GCC different from other compilers:
rt-thread/bsp/raspberry-pico/packages/raspberrypi-pico-sdk-latest/src/rp2_common/hardware_base/include/hardware/address_mapped.h
#define hw_set_alias(p) ((__typeof__(p))hw_set_alias_untyped(p))
#define hw_clear_alias(p) ((__typeof__(p))hw_clear_alias_untyped(p))
#define hw_xor_alias(p) ((__typeof__(p))hw_xor_alias_untyped(p))
#define xip_noalloc_alias(p) ((__typeof__(p))xip_noalloc_alias_untyped(p))
#define xip_nocache_alias(p) ((__typeof__(p))xip_nocache_alias_untyped(p))
#define xip_nocache_noalloc_alias(p) ((__typeof__(p))xip_nocache_noalloc_alias_untyped(p))
#define hw_set_alias(p) ((typeof(p))hw_set_alias_untyped(p))
#define hw_clear_alias(p) ((typeof(p))hw_clear_alias_untyped(p))
#define hw_xor_alias(p) ((typeof(p))hw_xor_alias_untyped(p))
#define xip_noalloc_alias(p) ((typeof(p))xip_noalloc_alias_untyped(p))
#define xip_nocache_alias(p) ((typeof(p))xip_nocache_alias_untyped(p))
#define xip_nocache_noalloc_alias(p) ((typeof(p))xip_nocache_noalloc_alias_untyped(p))
This is just a dirty hack, but at least, it compiles. Maybe the TinyUSB package maintainer set some flags, that the GCC/C99 problem with Pico(RP2040) get fixed.