stm32duino / Arduino_Core_STM32

STM32 core support for Arduino

Home Page:https://github.com/stm32duino/Arduino_Core_STM32/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"blue pill" w/STMF103C8 USB-CDC Serial not reading from host

bmo opened this issue · comments

Describe the bug
With generic blue pill STM32F103C8 boards from multiple vendors, Serial.read and Serial.available do not report characters received from the host.

Setup
Arduino IDE 2.3.2
STM32 support 2.7.1
ST-LINK v2 clone programmer

To Reproduce
Use this sketch:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial) {
    delay(100);
  }
  Serial.println("Connected!");

}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) {  
    char read_ch = Serial.read();
    Serial.println("Got One");
    if (read_ch != -1) {
      Serial.print("Got a uart character ");
      Serial.println(read_ch, HEX);
    }
  }
}

Set the following under Tools:
Board: "Generic STM32F1"
Optimize: "Smallest (-Os default)"
Board part number: "BluePill F103C8"
C Runtime library: "Newlib nano (default)"
Upload Method: "STM32CubeProgrammer (SWD)"
USB Support (if available): "CDC (Generic 'Serial' superceds U(S)ART)"
U(S)ART Support: "Disabled (no Serial support)"

Steps to reproduce the behavior:

  1. Program the target board
  2. Disconnect programmer
  3. Plug the target into a serial port (accept notifications for new hardware if provided)
  4. Select serial port installed in step 3 for Monitor
  5. Show monitor window
  6. Note "Connected!" message
  7. Type characters in send control, hit enter
  8. Note that no characters are displayed.

Expected behavior
After connection, and after typing characters that are sent to the target board, the character codes should be echoed back to the host, like this (this was taken from success STM32F103ZE board):

10:49:45.499 -> Connected!
10:49:51.093 -> Got One
10:49:51.093 -> Got a uart character 6A
10:49:51.093 -> Got One
10:49:51.093 -> Got a uart character 6B
10:49:51.093 -> Got One
10:49:51.093 -> Got a uart character 6A
10:49:51.093 -> Got One
10:49:51.093 -> Got a uart character 6B

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macos
  • Arduino IDE version: 2.3.2
  • STM32 core version: 2.7.1
  • Tools menu settings if not the default: Newlib Nano, USB-CDC Serial, No U(S)ART support
  • Upload method: SWD

Board (please complete the following information):

  • Name: Generic Blue Pill
  • Hardware Revision: unknown
  • Extra hardware used if any:

Additional context
Also tested with the following other boards/processors:

  • "HW-848" board, which has an STM32F401CC - Works
  • STM32F103ZE-based generic board - Works
    IMG_5845