stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post here all questions related to LibMaple core if you can't find a relevant section!
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond,And I know why the stm32f103C development board can support it normally? Who can help identify the problem or modify the code to support MIDI driver PC sending MIDI information.I want to use this development board to create a Windows 10 system MIDI keyboard
https://github.com/rogerclarkmelbourne/Arduino_STM32 ,I am using files from this library

#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() {
USBComposite.setProductId(0x0031);
midi.begin();
while (!USBComposite);
}

void loop() {
for (int i=0;i<numNotes;i++) {
midi.sendNoteOn(0, notes, 127);
delay(200);
midi.sendNoteOff(0, notes, 127);
}
}
User avatar
Bakisha
Posts: 140
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by Bakisha »

Check in device manager (right click "ThisPC->manage") is there a device named "Maple"
Clipboard01.jpg
Clipboard01.jpg (18.92 KiB) Viewed 5766 times
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

Thank you very much for your support. I did not see any information on the device here. The USB did not respond when plugged into the computer, and the development board indicator light was on. Is it possible that the MIDI driver is incompatible with the STm32f103rct6 development board? Has anyone tested it? How can we solve this problem?
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

And I downloaded the keyboard code. The same issue applies. The PC is unable to recognize the keyboard driver and has no response. I downloaded the WS2812B program and the LED light can run normally, but I don't know why MIDI and keyboard drivers work.

The following keyboard driver program cannot recognize USB keyboard drivers on this development board, but it can be used normally on the stm32f103c development board. Can you help me answer this question?


#include <USBComposite.h>

USBHID HID;
HIDKeyboard BootKeyboard(HID, 0);

void setup()
{
HID.begin(HID_BOOT_KEYBOARD);
BootKeyboard.begin(); // needed just in case you need LED support
}

void loop()
{
BootKeyboard.press(KEY_F12);
delay(100);
BootKeyboard.release(KEY_F12);
delay(1000);
}
User avatar
Bakisha
Posts: 140
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by Bakisha »

I tested it on bluepill ( STM32F103C8 with 128KB of flash). I don't know about STM32F103RC )

See if there is some item in device manager with yellow exclamation mark.
Try different USB port.
Try different USB cable.
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by ag123 »

among the things, have you tried a 'simple' sketch such as

Code: Select all

void setup() {
	Serial.begin();
	pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {

	Serial.println("hello world");
	
	digitalWrite(LED_BUILTIN, ! digitalRead(LED_BUILTIN));
	delay(1000);
}
a blinky is customary 'hello world' in the Arduino world.
the led should at least blink. if your led is not the same as the 'customary' e.g. blue pill (PC13) or maple mini (PB1), replace that LED_BUILTIN macro with the appropriate pin for your board.

In libmaple core SERIAL_USB is defined by default in boards.txt.
Hence, in the above example, you should at least see a device connected with id '1eaf:0004', that is a USB CDC ACM device, i.e. USB Serial.
In Windows, it may be necessary to work through the install steps to have the virtual com port properly recognized.
https://github.com/rogerclarkmelbourne/ ... stallation
I'm not too sure if things could have changed as that is written back then when Windows 7 is the most common OS.
And after you connect in your serial monitor/terminal e.g. the Arduino serial monitor you should see at least the "hello world" being printed repeatedly.
I prefer to use putty for the serial monitor
https://www.chiark.greenend.org.uk/~sgtatham/putty/

As in libmaple core SERIAL_USB is defined by default in boards.txt.
If you are playing with USB composite, it may help to look in your boards.txt copy and comment the line that sets SERIAL_USB and use a line without the SERIAL_USB flag. e.g.

Code: Select all

#genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.upload_flags=-DGENERIC_BOOTLOADER
and there is another thing, if you use that maple DFU loader, you need to install the bootloader
https://github.com/rogerclarkmelbourne/ ... bootloader
first hand using st-link or the serial uart upload method
viewtopic.php?t=1642

Otherwise, you would need an st-link or usb-uart dongle (and setting boot0) to update your sketch each time as your sketch is the only firmware on board
viewtopic.php?t=1642
this way using an st-link or ( usb-uart and setting boot0 ) is probably preferred if you are testing out usb codes.
As the usb dfu boot loader would first enumerate the port e.g. with id 1eaf:0003 and later jump to your sketch and your sketch needs to enumerate the port again. Often, you need to do a *usb reset* by pulling D+ and D- low for like 10ms.
so called single ended zero
https://www.usbmadesimple.co.uk/ums_3.htm
this is so that the host would enumerate the ports again and register your new midi device.
if you do without the USB DFU boot loader, this is simplier as you won't land in this situation.

there are actually (many) other things, you need to select a board that is a close match to your board preferably exact or 'compatible'
e.g. STM32F103RC (48k RAM. 256k Flash) etc
that is not all, the old 'maple mini' and 'blue pill' boards use a 'default' crystal frequency of 8 Mhz
if you used anything different, you may need to dig into setting up the clocks
https://github.com/rogerclarkmelbourne/ ... e/rcc_f1.c
and in addition for each different variant / board / chip
the memory size
https://github.com/rogerclarkmelbourne/ ... 2f103rc.ld
and layout (e.g. start address is different), e.g. with a maple DFU bootloader it would offset away from 0x8000000
https://github.com/rogerclarkmelbourne/ ... tloader.ld
this need to match if you are after all using e.g. the maple DFU bootloader (e.g. roger's version)
https://github.com/rogerclarkmelbourne/ ... ader_20.ld

there are also alternative ways to build a sketch such as using a Makefile
viewtopic.php?t=37
this could be a deeper dive for beginners, but that I use it only because I work in Eclipse rather than Arduino IDE.
It is also probably different from Arduino IDE in terms of the flags. Very often, for starters you may need to edit the Makefile to define where is your arm-gcc-none compiler etc and that it probably works mainly in Linux.
on Windows, try using WSL if you want to work it that way
https://learn.microsoft.com/en-us/windows/wsl/install
Last edited by ag123 on Wed Jul 12, 2023 7:12 am, edited 3 times in total.
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by ag123 »

playing with USB including HID (e.g. midi) is considered 'advanced'
as practically all the 'stock' setup for boards that is in common use need to work in order first hand. e.g. as like the 'blue pill' , 'maple mini' etc.
those boards are actually still available these days
https://www.aliexpress.com/w/wholesale-maple-mini.html
https://www.aliexpress.com/w/wholesale- ... 3c8t6.html

just be wary that the stm32f103c8 boards there were (are still ?) 'clone' boards, and even 'fake' boards (that won't work)

and of course these days there are many other (better) boards and chips e.g.
https://www.adafruit.com/product/4382
https://store.micropython.org/product/PYBLITEv1.0
https://www.olimex.com/Products/ARM/ST/STM32-H405/
https://stm32-base.org/boards/STM32F401 ... -V1.2.html

and the originals from ST
https://www.st.com/en/evaluation-tools/ ... 411re.html

those are better supported with the 'official' core
https://github.com/stm32duino/Arduino_Core_STM32
517002650
Posts: 12
Joined: Mon Jul 10, 2023 10:37 pm

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by 517002650 »

I downloaded the program using ST Link, and the LDE light blinked normally. However, after downloading the MIDI program, I was unable to recognize the MIDI driver. I replaced the development board stm32f103ZET6, but the problem remained. I was unable to recognize the MIDI driver and downloaded the LED flashing program, which blinked normally. I found that only the stm32f103c series board could use the MIDI driver and keyboard driver normally.
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by ag123 »

another thing, can you add some codes in your MIDI sketch to keep the LED blinking in

Code: Select all

loop() 
?

if the LED doesn't blink with the MIDI sketch, it points to some other problem, e.g. that your sketch / firmware 'crashed'.
and quite often, sketch can 'hang' or stall for instance if you are doing a spinlock checking for a variable to change state. e.g.

Code: Select all

while( digitalRead(PIN) == 0 );
if the PIN never read '1', it would forever 'hang' there.
And there can be 'hard faults' and such stuff happening, and unless you are willing to go in with st-link and debug things, the 'simplier' way is to simply keep a LED blinking to see that it is 'alive'.
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: stm32f103rct6 Midi driver cannot be recognized, PC cannot recognize and does not respond

Post by ag123 »

oh and in addition
have you checked / tried these sketches?
https://github.com/rogerclarkmelbourne/ ... idiout.ino
^ this one may be relevant
https://github.com/rogerclarkmelbourne/ ... midiin.ino

In addition, if you are using a STM32F103RBxx or STM32F103RCxx
use the variant
generic_stm32f103r
e.g.
STM32F103RB (20k RAM. 128k Flash)
or
STM32F103RC (48k RAM. 256k Flash)
instead
but that it needs to be a STM32F103Rxxx board.

and for upload method select st-link
then search for where your core is installed, locate the file boards.txt
in STM32F1 folder
line 595
https://github.com/rogerclarkmelbourne/ ... 2-L595C142

Code: Select all

genericSTM32F103R.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER
copy and comment the original with a hash (#) infront
in your new line remove the -DSERIAL_USB

Code: Select all

#genericSTM32F103R.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER
genericSTM32F103R.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DGENERIC_BOOTLOADER
you would need to restart the IDE to reload the configs.

with this ST-Link upload method, you need to use the ST-link dongle to upload the sketch.
that -DSERIAL_USB would enable the USB (CDC ACM) Serial usb device, it is normally enabled as most users want that

Code: Select all

Serial.Println("bla bla bla");
without this, Serial.Print() goes to uart, usually UART1, so if you need that, you'd need a separate USB UART dongle to connect to PA9 TX, PA10 RX, and GND.

I've not played with USB Composite, it is actually a separate library contributed by someone in this forum, it is a lot of effort to have done that. But that it may conflict with SERIAL_USB, I'm not sure though. Hence, by not building your sketch with the SERIAL_USB define, you won't get the USB (CDC ACM) Serial, and you can have USB Composite that does HID (and MIDI) without possible conflicts.
Post Reply

Return to “General discussion”