Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USBComposite never loaded #100

Open
epson121 opened this issue Aug 24, 2021 · 2 comments
Open

USBComposite never loaded #100

epson121 opened this issue Aug 24, 2021 · 2 comments

Comments

@epson121
Copy link

epson121 commented Aug 24, 2021

Hey, I'm having an issue with setting up midiout.ino sketch to work properly.

It gets uploaded to the STM board (black pill, STM32F103C Generic), but USBComposite never gets ready, and program is not functioning correctly.

I've slightly modified the midiout.ino to show the issue:

#include <USBComposite.h>

const uint8_t notes[] = {60, 62, 64, 65, 67, 69, 71, 72, 61, 63, 66, 68, 70};
const int numNotes = sizeof(notes)/sizeof(*notes);

USBMIDI midi;

void setup() {
    Serial.begin(9600);
    USBComposite.setProductId(0x0031);
    midi.begin();
    while (!Serial);
    while (!USBComposite) {
      Serial.println("Waiting for USBComposite");
    }
}

void loop() {
  for (int i=0;i<numNotes;i++) {
    midi.sendNoteOn(0, notes[i], 127);
    delay(200);
    midi.sendNoteOff(0, notes[i], 127);
  }
}

And the console output is:

16:22:04.644 -> Waiting for USBComposite
16:22:04.677 -> Waiting for USBComposite
16:22:04.677 -> Waiting for USBComposite
16:22:04.710 -> Waiting for USBComposite
16:22:04.743 -> Waiting for USBComposite
16:22:04.777 -> Waiting for USBComposite
16:22:04.810 -> Waiting for USBComposite
16:22:04.810 -> Waiting for USBComposite
16:22:04.843 -> Waiting for USBComposite
16:22:04.876 -> Waiting for USBComposite
16:22:04.909 -> Waiting for USBComposite
16:22:04.943 -> Waiting for USBComposite
16:22:04.976 -> Waiting for USBComposite
16:22:04.976 -> Waiting for USBComposite
16:22:05.009 -> Waiting for USBComposite
16:22:05.042 -> Waiting for USBComposite
16:22:05.075 -> Waiting for USBComposite
16:22:05.108 -> Waiting for USBComposite
16:22:05.108 -> Waiting for USBComposite
16:22:05.142 -> Waiting for USBComposite
16:22:05.175 -> Waiting for USBComposite
16:22:05.208 -> Waiting for USBComposite
16:22:05.241 -> Waiting for USBComposite
16:22:05.274 -> Waiting for USBComposite
16:22:05.274 -> Waiting for USBComposite
16:22:05.307 -> Waiting for USBComposite
16:22:05.341 -> Waiting for USBComposite
16:22:05.374 -> Waiting for USBComposite
16:22:05.407 -> Waiting for USBComposite
16:22:05.407 -> Waiting for USBComposite
16:22:05.441 -> Waiting for USBComposite
16:22:05.474 -> Waiting for USBComposite
16:22:05.507 -> Waiting for USBComposite
16:22:05.540 -> Waiting for USBComposite
16:22:05.540 -> Waiting for USBComposite
16:22:05.573 -> Waiting for USBComposite
16:22:05.606 -> Waiting for USBComposite
16:22:05.640 -> Waiting for USBComposite
16:22:05.673 -> Waiting for USBComposite
16:22:05.706 -> Waiting for USBComposite
16:22:05.706 -> Waiting for USBComposite
16:22:05.739 -> Waiting for USBComposite
16:22:05.772 -> Waiting for USBComposite
16:22:05.805 -> Waiting for USBComposite

Any ideas what might be causing this? STM is connected via USB to computer (not directly, but using an UART).

I've tested this on linux and windows, same result.

EDIT: also, I'm having to use Upload method: Serial (in Arduino IDE), because STM32Duino bootloader is throwing DFU issues:

Can't open /dev/ttyUSB0: Input/output error
Can't open serial /dev/ttyUSB0
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to [email protected]

the selected serial port 
 does not exist or your board is not connected

*** autoreset failed; you need to use RESET button
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
dfu-util: No DFU capable USB device available

Upload failed :(
processing.app.SerialException: Error opening serial port '/dev/ttyUSB0'.
	at processing.app.Serial.<init>(Serial.java:152)
	at processing.app.Serial.<init>(Serial.java:82)
	at processing.app.SerialMonitor$2.<init>(SerialMonitor.java:132)
	at processing.app.SerialMonitor.open(SerialMonitor.java:132)
	at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)
	at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2120)
	at processing.app.Editor.access$1300(Editor.java:117)
	at processing.app.Editor$UploadHandler.run(Editor.java:2089)
	at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - /dev/ttyUSB0; Method name - openPort(); Exception type - Port not found.
	at jssc.SerialPort.openPort(SerialPort.java:167)
	at processing.app.Serial.<init>(Serial.java:141)
	... 8 more
Error opening serial port '/dev/ttyUSB0'.
@W3AXL
Copy link

W3AXL commented Sep 10, 2024

Seeing the same issue, USBComposite never returns true and USB does not function. This is using an STM32F103C8 blue pill and the latest arduino/Arduino_STM32 libraries.

#include <USBComposite.h>

// USB HID device
USBHID HID;

// Keyboard
HIDKeyboard Kbd(HID);

// USB Serial Device
USBCompositeSerial Vcp;

void setup() {
  pinMode(PC13, OUTPUT);
  digitalWrite(PC13, HIGH);
  HID.begin(Vcp, HID_KEYBOARD);
  while (!USBComposite);
  Kbd.begin();
}

void loop() {
  Vcp.println("Ping!");
  digitalWrite(PC13, LOW);
  delay(100);
  digitalWrite(PC13, HIGH);
  delay(900);
}

@W3AXL
Copy link

W3AXL commented Sep 10, 2024

Aha!

I think it may be a fake STM32F1 issue - I switched to the Generic STM32F103C/fake STM32F103C8 board in Arduino and now the above code works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants