Giter Club home page Giter Club logo

stm32-usb-cdc1's Introduction

STM32 NUCLEO-F767ZI USB CDC Example

It finally connects to Host and provides Virtual COM port (for User USB connector on Nucleo board).

NOTE: There are two Virtual COM ports:

  1. CN1-USB PWR - this is ST-Link connector. It provides always Virtual port named STMicroelectronics STLink Virtual COM Port (COMx) under Windows.

    Under Linux it is visible like (output from dmesg):

    usb 2-1: new full-speed USB device number 2 using ohci-pci
    usb 2-1: New USB device found, idVendor=0483, idProduct=374b
    usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 2-1: Product: STM32 STLink
    usb 2-1: Manufacturer: STMicroelectronics
    usb 2-1: SerialNumber: xxxxxxxxxxxxxxxxxxxxxxxx
    cdc_acm 2-1:1.2: ttyACM0: USB ACM device
    usbcore: registered new interface driver cdc_acm
    cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
    

    Please notice idVendor=0483, idProduct=374b

    This port is connected to USART3 of MCU. If you want to use this serial port you can look into example in:

    ~/STM32Cube/Repository/STM32Cube_FW_F7_V1.15.0/Projects/STM32F767ZI-Nucleo/Examples/UART/`
    

    provided by vendor.

  2. CN13-User USB - it is USB directly attached to MCU. It is visible under Windows as STMicroelectronics Virtual COM Port (COMx). (Notice "missing" STLink word). This port is used in this project.

    Please also notice different "idProduct" ("idVendor" is same as above): idVendor=0483, idProduct=5740

Current function:

  • red LED D3 lights on fatal error

  • blue LED D2 is blinking (to signal that CPU is running)

  • green LED D1 - you can control it by sending 1 or 0 character to Virtual COM port on CN13-User USB. All other characters are currently silently ignored. This code is implemented in file Src/usbd_cdc_if.c function:

    static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len);

Required/used software

  • OS: Debian Linux 9.9/amd64
  • CubeMX 5.3.0, installer: en.STM32CubeMX_v5-3-0.zip
  • Firmware: STM32Cube_FW_F7_V1.15.0
  • IDE: SW4STM32 v2.9 for Linux/64-bit, installer: install_sw4stm32_linux_64bits-v2.9.run

Important build notes

WARNING! The Code Generated by CubeMX 5.3.0 is buggy (at least for firmware STM32Cube_FW_F7_V1.15.0) - you must apply this fix to generated code:

--- a/Src/usbd_conf.c
+++ b/Src/usbd_conf.c
@@ -206,11 +206,11 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
 { 
   USBD_SpeedTypeDef speed = USBD_SPEED_FULL;
 
-  if ( hpcd->Init.speed == PCD_SPEED_HIGH)
+  if ( hpcd->Init.speed == USB_OTG_SPEED_HIGH)
   {
     speed = USBD_SPEED_HIGH;
   }
-  else if ( hpcd->Init.speed == PCD_SPEED_FULL)
+  else if ( hpcd->Init.speed == USB_OTG_SPEED_FULL)
   {
     speed = USBD_SPEED_FULL;
   }

Also in my case I need to replace:

  • __packed="__attribute__((__packed__))" with
  • __packed="__attribute__((packed))" to avoid build errors (in C/C++ Build -> Settings -> MCU GCC Compiler -> Preprocessor).

NOTE: To avoid problems please use this directory structure:

  • /home/ansible/projects/stm32-usb-cdc1/ - path of this project
  • /home/ansible/STM32Cube/Repository/STM32Cube_FW_F7_V1.15.0/ - path of firmware package STM32Cube_FW_F7_V1.15.0

NOTES

If you plan to connect CN13-User USB to Windows 7 or Windows 8.x you may need to install STM32 Virtual COM Port Driver.

Important note: The Nucleo board MUST be powered on (for example connected to PC using CN1-USB PWR) - before connecting CN13-User USB to Host. Doing otherwise may damage Nucleo board!

--hp

stm32-usb-cdc1's People

Contributors

hpaluch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

thomasvnl andy-ss

stm32-usb-cdc1's Issues

Unknow device

Hi, I use this project to config my NUCLEO-F767ZI board, after doing the code job, the user-USB can‘t be recognized by windows, and the board become dead ( the blue LD2 won't blink ).
Do you have any ideas about how to solove this problem? thanks very much.

OS: windows 10 64bit
STM32CubeMX + STM32CubeIDE + STM32CubeProgramer
STM32Cube_FW_F7_V1.16.0
I have installed the STM32 Virtual COM Port Driver from ST.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.