USB console sample not working with STM32F070


Martin Jäger
 

Hello,

I am trying to use the USB CDC device driver with an STM32F070. However, the usb console sample fails with the following error message (several similar errors shown, only one of them posted):

In file included from ../../../../../include/arch/arm/cortex_m/irq.h:17:0,
                 from ../../../../../include/arch/arm/arch.h:27,
                 from ../../../../../include/arch/cpu.h:15,
                 from ../../../../../include/syscall.h:15,
                 from ../../../../../include/kernel_includes.h:32,
                 from ../../../../../arch/arm/soc/st_stm32/stm32f0/soc.h:33,
                 from <path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c:47:
<path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c: In function ‘usb_dc_ep_write’:
zephyr/include/generated/generated_dts_board.h:247:27: error: ‘ST_STM32_USB_40005C00_IRQ_USB’ undeclared (first use in this function)
 #define CONFIG_USB_IRQ    ST_STM32_USB_40005C00_IRQ_USB
                           ^
../../../../../include/irq.h:241:44: note: in definition of macro ‘irq_disable’
 #define irq_disable(irq) _arch_irq_disable(irq)
                                            ^~~
<path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c:670:15: note: in expansion of macro ‘CONFIG_USB_IRQ’
   irq_disable(CONFIG_USB_IRQ);
               ^~~~~~~~~~~~~~

Steps to reproduce:

cd zephyr/samples/subsys/usb/console
mkdir build; cd build
cmake -GNinja -DBOARD=nucleo_f070rb ..
ninja

Anyone has an idea what I might have done wrong? If I compile for -DBOARD=arduino_101, everything works fine.

Thanks,

Martin


Yannis Damigos
 

Hi

Hello,

I am trying to use the USB CDC device driver with an STM32F070. However, the usb console sample fails with the following error message (several similar errors shown, only one of them posted):

In file included from ../../../../../include/arch/arm/cortex_m/irq.h:17:0,
                 from ../../../../../include/arch/arm/arch.h:27,
                 from ../../../../../include/arch/cpu.h:15,
                 from ../../../../../include/syscall.h:15,
                 from ../../../../../include/kernel_includes.h:32,
                 from ../../../../../arch/arm/soc/st_stm32/stm32f0/soc.h:33,
                 from <path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c:47:
<path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c: In function ‘usb_dc_ep_write’:
zephyr/include/generated/generated_dts_board.h:247:27: error: ‘ST_STM32_USB_40005C00_IRQ_USB’ undeclared (first use in this function)
 #define CONFIG_USB_IRQ    ST_STM32_USB_40005C00_IRQ_USB
                           ^
../../../../../include/irq.h:241:44: note: in definition of macro ‘irq_disable’
 #define irq_disable(irq) _arch_irq_disable(irq)
                                            ^~~
<path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c:670:15: note: in expansion of macro ‘CONFIG_USB_IRQ’
   irq_disable(CONFIG_USB_IRQ);
               ^~~~~~~~~~~~~~
You need to enable the usb device in boards device tree file:

&usb {
status = "ok";
};

Please consider creating a pull request if it works.

Yannis


Martin Jäger
 

Hi Yannis,

I am trying to use the USB CDC device driver with an STM32F070. However, the usb console sample fails with the following error message (several similar errors shown, only one of them posted):

In file included from ../../../../../include/arch/arm/cortex_m/irq.h:17:0,
                 from ../../../../../include/arch/arm/arch.h:27,
                 from ../../../../../include/arch/cpu.h:15,
                 from ../../../../../include/syscall.h:15,
                 from ../../../../../include/kernel_includes.h:32,
                 from ../../../../../arch/arm/soc/st_stm32/stm32f0/soc.h:33,
                 from <path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c:47:
<path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c: In function ‘usb_dc_ep_write’:
zephyr/include/generated/generated_dts_board.h:247:27: error: ‘ST_STM32_USB_40005C00_IRQ_USB’ undeclared (first use in this function)
 #define CONFIG_USB_IRQ    ST_STM32_USB_40005C00_IRQ_USB
                           ^
../../../../../include/irq.h:241:44: note: in definition of macro ‘irq_disable’
 #define irq_disable(irq) _arch_irq_disable(irq)
                                            ^~~
<path-to-zephyr>/zephyr/drivers/usb/device/usb_dc_stm32.c:670:15: note: in expansion of macro ‘CONFIG_USB_IRQ’
   irq_disable(CONFIG_USB_IRQ);
               ^~~~~~~~~~~~~~
You need to enable the usb device in boards device tree file:

&usb {
status = "ok";
};

Please consider creating a pull request if it works.

Yannis
Great, this compiles for the STM32F070. Thanks!

Now I tried to compile for STM32F072, but without luck. The board configuration is based on the nucleo F070 board (F072 not yet in official board folder). Also added above lines to the dts file.

I found out that cmake/ninja does not generate the generated_dts_board.h correctly.

Output in build folder for F070:

grep -r -i 'ST_STM32_USB_40005C00_IRQ_USB' ./
./zephyr/include/generated/generated_dts_board.h:#define ST_STM32_USB_40005C00_IRQ_USB ST_STM32_USB_40005C00_IRQ_0
./zephyr/include/generated/generated_dts_board.h:#define ST_STM32_USB_40005C00_IRQ_USB_PRIORITY ST_STM32_USB_40005C00_IRQ_0_PRIORITY
./zephyr/include/generated/generated_dts_board.h:#define CONFIG_USB_IRQ                ST_STM32_USB_40005C00_IRQ_USB
./zephyr/include/generated/generated_dts_board.h:#define CONFIG_USB_IRQ_PRI ST_STM32_USB_40005C00_IRQ_USB_PRIORITY
./zephyr/include/generated/generated_dts_board.conf:ST_STM32_USB_40005C00_IRQ_USB=31
./zephyr/include/generated/generated_dts_board.conf:ST_STM32_USB_40005C00_IRQ_USB_PRIORITY=0

Output for F072:

grep -r -i 'ST_STM32_USB_40005C00_IRQ_USB' ./
./zephyr/include/generated/generated_dts_board.h:#define CONFIG_USB_IRQ                ST_STM32_USB_40005C00_IRQ_USB
./zephyr/include/generated/generated_dts_board.h:#define CONFIG_USB_IRQ_PRI ST_STM32_USB_40005C00_IRQ_USB_PRIORITY

The USB-related entries of both SOCs under dts/arm/st are exactly the same. Is there some other location where the USB support has to be configured for the SOC?

I will create a pull request for both boards as soon as it works.

Martin


Yannis Damigos
 

Hi Martin,

Great, this compiles for the STM32F070. Thanks!

Now I tried to compile for STM32F072, but without luck. The board configuration is based on the nucleo F070 board (F072 not yet in official board folder). Also added above lines to the dts file.
The USB-related entries of both SOCs under dts/arm/st are exactly the same. Is there some other location where the USB support has to be configured for the SOC?
I enabled usb node in stm32f072b_disco board device tree file and the generated output was fine. Try to base your board's configuration files on stm32f072b_disco.

Yannis


Martin Jäger
 

Hi Yannis,

now it works, thanks a lot for your support.

I will figure out where the problem with the nucleo f072 board specification was and generate the pull request.

BR
Martin