WeAct stm32f103 usb c

Nik
Posts: 2
Joined: Wed Aug 26, 2020 2:52 pm

WeAct stm32f103 usb c

Post by Nik »

Does anyone have experience with usb c we act stm32f1 board?

Wanna make sure that usb works after buying some blue pills without usb support.

https://www.aliexpress.com/item/3298184 ... hweb201603_
mrburnette
Posts: 352
Joined: Thu Dec 19, 2019 1:23 am
Answers: 1

Re: WeAct stm32f103 usb c

Post by mrburnette »

I am confused ...
Blue Pills have USB, some have the wrong resistors, sometimes the connector pull off because of poor soldering. USB hardware is in the STM32F103xx uC, but a USB enabled bootloader must be used for DFU programming OR if no bootloader, you must load a sketch that gets the USB support loaded with the sketch... this is different by core used.

This is a Blue Pill:
https://stm32duinoforum.com/forum/wiki_ ... _Pill.html

This is how you search about USB serial:
https://www.google.com/search?q=%22usb+ ... 2duino.com
ag123
Posts: 584
Joined: Thu Dec 19, 2019 5:30 am
Answers: 2

Re: WeAct stm32f103 usb c

Post by ag123 »

the usb c is just the connector, it works as ordinary usb full speed, check the spec sheets for the stm32 chip
Nik
Posts: 2
Joined: Wed Aug 26, 2020 2:52 pm

Re: WeAct stm32f103 usb c

Post by Nik »

Not all blue pills have a working usb peripheral, at least from my experience.
I have some code for hid device and use it to test every board after unpacking. The code is written from St HAL library.

Had two stm32f1 smart v2.1 boards before and they were working fine.
One blue pill had wrong resistors. Soldered resistors to correct pins and no luck even after that.
Had two other blue pills which worked with usb out of the box, no changes needed.

Now smarts and blue pills which worked may just be gd32 knockoffs and one blue pill that didn't work may be cks32, dunno. What's interesting is that seller states in bold that they are using original st parts for usb c version. That version of the board is WeAct like black pill f401/411 so it may have a good chance of actually being an original (and it's more expensive).
ag123
Posts: 584
Joined: Thu Dec 19, 2019 5:30 am
Answers: 2

Re: WeAct stm32f103 usb c

Post by ag123 »

for the WeAct board, one way is to ask WeAct to confirm if you are dealing with them, as opposed to 'generic' blue pills which apparently seemed to come from a different source. ideally if you are dealing direct with the manufacturer, it is less likely to get 'fakes' as they have more stakes than the average drop shipper. more commonly a specific manufacturer's boards tend to be priced higher than the 'generic' blue pill boards
User avatar
sergio
Posts: 5
Joined: Fri Sep 04, 2020 5:06 am
Location: Earth ⨁

Re: WeAct stm32f103 usb c

Post by sergio »

I bought looks like the same board from Ali. This is my first stm32 and I have a lot of questions.

stm32flash says:

Code: Select all

stm32flash 0.5

http://stm32flash.sourceforge.net/

Interface serial_posix: 57600 8E1
Version      : 0x22
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0410 (STM32F10xxx Medium-density)
- RAM        : 20KiB  (512b reserved by bootloader)
- Flash      : 128KiB (size first sector: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
The onboard LED is connected to PB2 (this is specified on board and I've checked with multimeter).


1. The board was pre-flashed so it showed up as a mass storgage (/dev/sdX) but I couldn't mount it.
https://github.com/stm32duino/wiki/wiki/Upload-methods also says there is a way to copy firmware just like to USB flash.
Could you point me to a such bootloader?

2. I've successfully flashed https://github.com/Serasidis/STM32_HID_Bootloader: board is shown as "Generic serasidis.gr STM32 HID Bootloader" after this. Moreover, arduino IDE detects it and uploads firmware. But after upload I got "unable to enumerate USB device": looks like upload corrupts bootloader.

I've tried all pre-compiled binaries from F103/low_and_medium_density with the same result.

3. I "Exported compiled binary" for the following code:

Code: Select all

#define LED PB2

void setup() {
  pinMode(LED, OUTPUT);
}

void loop() {
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
  delay(1000);
}
and tried to flash it directly with stm32flash. But LED doesn't flash. I tried different pins without success.
Also I tried all F103CB boards from "Board part numbers" without success.
board photo
board photo
stm32-small.jpg (40.97 KiB) Viewed 1650 times
ag123
Posts: 584
Joined: Thu Dec 19, 2019 5:30 am
Answers: 2

Re: WeAct stm32f103 usb c

Post by ag123 »

if you are using Arduino IDE, when you build your sketch, you need to select the correct boot loader. it is because, the boot loader sits in front at 0x8000000 start of flash, and your sketch will sit offset at an address after the boot loader. the vector interrupt table will change because of that.

if you have got an st-link etc, try flashing as st-link or selecting st-link as the 'boot loader' or 'install method', then it will install your sketch at 0x8000000 which is the start of flash. i.e. there is no usb based boot loader sitting 'in front' of it, it is just your sketch as firmware.

you can always try a usb based bootloader later which is a firmware in front of your sketch/firmware

if you are using the official STM core and using windows the recommended flash program is STM32 Cube programmer
https://www.st.com/en/development-tools ... eprog.html

accordingly STM32 Cube programmer works in linux as well
the alternatives are like
https://github.com/stlink-org/stlink
and stm32flash like you are using

if you are using the serial (uart) upload method i.e. PA9, PA10, you need to press and hold BOOT0, then press and release RESET, then release BOOT0 after a couple of seconds. then go back to your flasher and upload that via serial.
User avatar
sergio
Posts: 5
Joined: Fri Sep 04, 2020 5:06 am
Location: Earth ⨁

Re: WeAct stm32f103 usb c

Post by sergio »

Can I start without bootloader at all? Just compile from Arduino IDE and flash with stm32flash.

I have no ST-LINK device and not going to use Cube.
ag123
Posts: 584
Joined: Thu Dec 19, 2019 5:30 am
Answers: 2

Re: WeAct stm32f103 usb c

Post by ag123 »

yes, choose the correct 'boot loader' for the build e.g. st-link, or uart, the main thing is doing this selects the ld script with the correct start of flash address and the correct flash and ram size. start of flash with st-link or uart is at 0x8000000, this is where all customer firmware start running, including your sketch or an alternative boot loader

the bin file to flash is normally found in the Arduino temporary build folder or you can set the build path
https://www.kanda.com/blog/microcontrol ... -binaries/
you can use stm32-flash for that, note normally it is just a bin file no hex file, not all flashers support hex file

if you use STM32 Cube programmer as the flasher
https://www.st.com/en/development-tools ... eprog.html
i think the official core may support that from within the Arduino ide

selecting a usb bootloader e.g. rogers maple DFU boot loader, or HID boot loader would offset your sketch away from 0x8000000 as the boot loader needs to sit there

for uart boot loader i.e. PA9 TX, PA10 RX, that BOOT0 and RESET button dance detailed earlier is necessary
https://stm32.eu/wp-content/uploads/201 ... 2606-1.pdf
on blue pill and other boards it is simply to set the BOOT0 jumper and press RESET
some flashers can control that BOOT0 and RESET pins over 2 additional wires and using the DTR/RTS control signals, that makes things somewhat easier, but you'd need to find out separately as it seemed different between the different open sourced flashers

the main use of those additional usb (DFU or HID, etc) boot loader is so that you can install a sketch over simply a usb cable, no additional dongles used and no twiddling with BOOT0 settings
User avatar
sergio
Posts: 5
Joined: Fri Sep 04, 2020 5:06 am
Location: Earth ⨁

Re: WeAct stm32f103 usb c

Post by sergio »

I set `STM32CubeProgrammer (Serial)` and uploaded compiled binary with stm32flash: it blinks now, great!

The next step is HID:

1. I got pre-compiled binaries from https://github.com/Serasidis/STM32_HID_Bootloader and flashed it:

Code: Select all

% stm32flash -g 0x8000000 -b 115200 -w stm32_binaries/F103/low_and_medium_density/hid_generic_pc13.bin /dev/ttyUSB0
2. I set upload method `HID Bootloader 2.2`

3. Arduino successfully uploads the blink sketch above and board starts blinking!

But this works only once: uploading corrupts bootloader, dmesg says `unable to enumerate USB device`. What's wrong here?
Post Reply

Return to “STM32F1 based boards”