HansDampf
HansDampf

Registered on 11月前

Answers
6
Article
0
Follower
0

I got the uSart10 working, dont know why its not working with uart4. The USART10 is ok for me, so I close these question.

by debugging further, I found out, that the UART4_IRQHandler is called only once, when the UART ist setup:
rt_thread/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/drv_usart.c:244
stm32_control()

Shoulnd this UART4_IRQHandler called each time, when msh or finsh print something?

I forgot, this is the code I copy from CubeMX to board.c. It is called direct after SystemClock_Config:

void HAL_UART_MspInit(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};

/** Initializes the peripherals clock
*/

PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART4;
PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
  Error_Handler();
}

/* Peripheral clock enable */
__HAL_RCC_UART4_CLK_ENABLE();

__HAL_RCC_GPIOC_CLK_ENABLE();
/**UART4 GPIO Configuration
PC10     ------> UART4_TX
PC11     ------> UART4_RX
*/
GPIO_InitStruct.Pin = U4TX_Pin|U4RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/* UART4 interrupt Init */
HAL_NVIC_SetPriority(UART4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(UART4_IRQn);

}

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:

  • Disable the static_assert() calls in

/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

ifdef GNUC

#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))

else

#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))

endif

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.

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

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

Create
Post