Can't open serial monitor using ST Link and STM32F103C8

Post here all questions related to LibMaple core if you can't find a relevant section!
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by ag123 »

before doing a 'reset' , a few more things to try:
after following the instructions, connect usb - press reset on the pill board
in device manager did windows find a usb dfu device ? you can try the next steps nevertheless
if it did in the (arduino) IDE
make a sketch e.g.

Code: Select all

uint8_t led = 0;

void setup() {
   // Serial.begin(); //this isn't needed, it is pre-initialised , otherwise you could uncomment it to test
   pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  if(Serial.available()) {
    char c = Serial.read();
    Serial.print("hello ");
    Serial.print(c);
    Serial.println();
  }
  led = ~ led & 1;
  digitalWrite(LED_BUILTIN, led);
  delay(100);
}
- select the board 'Generic STM32F103C Series'
- variant select 'STM32F103C8 20k ram 64k flash'
- select upload method "STM32duino bootloader"
- cpu speed: normal 72mhz
- optimise method: smallest default

build and install the sketch
then press reset (on the pill board)
it should blink
open a serial terminal, you can use that in the arduino ide if you are using it
send some characters

if you are hitting some issues installing the sketch, you can try to set the BOOT1 jumper on the board, press reset (on pill board)
with the stm32duino boot loader alone, it should keep blinking
then try to install the sketch from the IDE again
after installing, revert BOOT1 jumper to original, press reset, this time round the sketch should be running i.e. it is blinking
open a serial terminal and send some characters.
to proof that it is the sketch that is running, you can change the delay(100) statement in loop(), to a different value e.g. delay(1000),
that would make it blink on and off every second

in terms of 'resetting' the pill board to 'original', here is what it is:
when you install firmware using st-link e.g. the boot loader, that is the firmware / sketch that runs on the pill board (chip)
it replaces what is there and is the only thing that runs. normally the install location is 0x8000000 - start of flash
and if you install a firmware / sketch or bootloader there using st-link, that is the thing that runs

but if you are installing using a usb cable and the boot loader above, the boot loader places you sketch after itself (normally 0x8002000 for STM32duino bootloader) so that it won't over write itself. but that means you need to select the 'upload method STM32duino bootloader' when you build your sketch. This is because, it would build the sketch for the offset location of 0x8002000
walla121
Posts: 6
Joined: Wed Jan 08, 2020 7:17 pm

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by walla121 »

ag123 wrote: Fri Jan 10, 2020 4:57 pm before doing a 'reset' , a few more things to try:
after following the instructions, connect usb - press reset on the pill board
in device manager did windows find a usb dfu device ? you can try the next steps nevertheless
if it did in the (arduino) IDE
make a sketch e.g.

Code: Select all

uint8_t led = 0;

void setup() {
   // Serial.begin(); //this isn't needed, it is pre-initialised , otherwise you could uncomment it to test
   pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  if(Serial.available()) {
    char c = Serial.read();
    Serial.print("hello ");
    Serial.print(c);
    Serial.println();
  }
  led = ~ led & 1;
  digitalWrite(LED_BUILTIN, led);
  delay(100);
}
- select the board 'Generic STM32F103C Series'
- variant select 'STM32F103C8 20k ram 64k flash'
- select upload method "STM32duino bootloader"
- cpu speed: normal 72mhz
- optimise method: smallest default

build and install the sketch
then press reset (on the pill board)
it should blink
open a serial terminal, you can use that in the arduino ide if you are using it
send some characters

if you are hitting some issues installing the sketch, you can try to set the BOOT1 jumper on the board, press reset (on pill board)
with the stm32duino boot loader alone, it should keep blinking
then try to install the sketch from the IDE again
after installing, revert BOOT1 jumper to original, press reset, this time round the sketch should be running i.e. it is blinking
open a serial terminal and send some characters.
to proof that it is the sketch that is running, you can change the delay(100) statement in loop(), to a different value e.g. delay(1000),
that would make it blink on and off every second

in terms of 'resetting' the pill board to 'original', here is what it is:
when you install firmware using st-link e.g. the boot loader, that is the firmware / sketch that runs on the pill board (chip)
it replaces what is there and is the only thing that runs. normally the install location is 0x8000000 - start of flash
and if you install a firmware / sketch or bootloader there using st-link, that is the thing that runs

but if you are installing using a usb cable and the boot loader above, the boot loader places you sketch after itself (normally 0x8002000 for STM32duino bootloader) so that it won't over write itself. but that means you need to select the 'upload method STM32duino bootloader' when you build your sketch. This is because, it would build the sketch for the offset location of 0x8002000
I did everything as you described but it won't upload on board...

here are the settings:
Image

And here is the error when I try to upload
Image

I have board conneceted to COM3 but it's not detected, I installed drivers from the tutorial you gave me but still the same problem.
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by ag123 »

the images you uploaded are not displayed,
perhaps try to host them on https://imgur.com/
and insert the pictures here, referencing the url to imgur

in addition copy the console log messages (the black section) from the arduino ide during install and post them here would provide more information about the install itself

i'm using a blue pill and my board has roger's stm32duino bootloader successfully installed
make sure that the boot loader you are installing on the pill board (using st-link v2) is the generic_boot20_pc13.bin
https://github.com/rogerclarkmelbourne/ ... bootloader
https://github.com/rogerclarkmelbourne/ ... 0_pc13.bin
apparently i found some video in youtube featuring the install of stm32duino boot loader using st-link in windows
https://www.youtube.com/watch?v=saolJ_7E7hc
in fact, there are many videos
https://www.youtube.com/results?search_ ... bootloader

if roger's boot loader is successfully installed, when you press reset, there would be a series of fast blinks on the blue pill board. even without any sketches installed.

those fast blinks has its origins here:
http://docs.leaflabs.com/static.leaflab ... oader-mode
Perpetual Bootloader Mode

In this mode, Maple stays a DFU device and does not jump to user code until the next reset. This is useful for guaranteeing that your Maple will be available for reprogramming.

To put your Maple (or other Maple board) into perpetual bootloader mode:

Plug your board into the USB port.
Hit the reset button (it’s the button labeled RESET). Notice that your board blinks quickly 6 times, then blinks slowly a few more times.
Hit reset again, and this time push and hold the other button during the 6 fast blinks (the normal button is labeled BUT). You can release it once the slow blinks start.
what that means is that if you press reset and concurrently run the install just in time in the initial few (6) seconds, the sketch gets installed otherwise no.

if you are using libmaple core and after you succeeded in installing and running the first libmaple sketch using stm32duino bootloader. you would notice an apparent difference. u'd just click install and the sketch gets installed.and you don't even need to fiddle with any jumpers or touch reset.

that is because there is an escape sequence in the core + sketch (DTR + 'LEAF') which gets triggered by a utility in tools when you click install in the Arduino IDE, But this is provided you have stm32duino boot loader installed and your 1st libmaple sketch installed and successfully running with stm32duino boot loader

if you are starting totally raw, i.e. there is totally no sketch, actually it should just drop into perpetual mode and keep blinking

but for the rest of 'unusual' cases, e.g. that there is a non-libmaple sketch or firmware:

the original maple mini (and clones) has this finger dance that beginners couldn't grapse
https://www.youtube.com/watch?v=rvNIeKuXsxM
and blue pills don't have that button at all

roger did something to help the bluepill users, if you set boot1, it would drop into perpetual mode and wait for you to upload your sketch.

next i tried with this sketch

Code: Select all

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_BUILTIN, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(LED_BUILTIN, 1);
  delay(100);
  digitalWrite(LED_BUILTIN, 0);
  delay(100);

}
the config is what i posted earlier,

Code: Select all

- select the board 'Generic STM32F103C Series'
- variant select 'STM32F103C8 20k ram 64k flash'
- select upload method "STM32duino bootloader"
- cpu speed: normal 72mhz
- optimise method: smallest default
as i worked in linux, an install from the Arduino IDE looked like this.

Code: Select all

Sketch uses 14104 bytes (21%) of program storage space. Maximum is 65536 bytes.
Global variables use 3136 bytes (15%) of dynamic memory, leaving 17344 bytes for local variables. Maximum is 20480 bytes.
dfu-util 0.8
dfu-util: Invalid DFU suffix signature

dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
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 dfu-util@lists.gnumonks.org

Opening DFU capable USB device...
ID 1eaf:0003
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #2 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
Copying data from PC to DFU device

Download	[                         ]   0%            0 bytes
Download	[=                        ]   6%         1024 bytes
Download	[===                      ]  13%         2048 bytes
Download	[=====                    ]  20%         3072 bytes
Download	[======                   ]  27%         4096 bytes
Download	[========                 ]  33%         5120 bytes
Download	[==========               ]  40%         6144 bytes
Download	[===========              ]  47%         7168 bytes
Download	[=============            ]  54%         8192 bytes
Download	[===============          ]  60%         9216 bytes
Download	[================         ]  67%        10240 bytes
Download	[==================       ]  74%        11264 bytes
Download	[====================     ]  81%        12288 bytes
Download	[=====================    ]  87%        13312 bytes
Download	[=======================  ]  94%        14104 bytes
Download	[=========================] 100%        14104 bytes
Download done.
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
Waiting for /dev/ttyACM0 serial...Done
posting that console log with your sketch install here could help diagnose the problem
Last edited by ag123 on Sun Jan 12, 2020 8:02 pm, edited 2 times in total.
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by ag123 »

note that libmaple core has its origins here
http://docs.leaflabs.com/static.leaflab ... start.html
it is really fine core for those willing to venture beyond the 'com' ports
i actually played with the original maple arduino ide and literally used it

in tools folder you would find a utility dfu-util
the command line to install a binary (compiled from a sketch) with roger's stm32duino boot loader
https://github.com/rogerclarkmelbourne/ ... bootloader
is

Code: Select all

dfu-util -a 2 -RD sketch.bin
and you can actually list the DFU capable devices using

Code: Select all

dfu-util -l
to use this, get your command line

Code: Select all

dfu-util -l
ready to press enter

press reset and press enter

Code: Select all

dfu-util -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2019 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1eaf:0003] ver=0201, devnum=33, cfg=1, intf=0, path="3-9", alt=2, name="STM32duino bootloader v1.0  Upload to Flash 0x8002000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=33, cfg=1, intf=0, path="3-9", alt=1, name="STM32duino bootloader v1.0  Upload to Flash 0x8005000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=33, cfg=1, intf=0, path="3-9", alt=0, name="STM32duino bootloader v1.0  ERROR. Upload to RAM not supported.", serial="LLM 003"
the outputs are in linux, and this isn't the dfu-util in the core, this one is build from source
http://dfu-util.sourceforge.net/
but that in the core works the same way

you will only see the above dfu-util -l outputs if the stm32duino boot loader is in DFU mode and ready to load the sketch.
you will also note that the USB VID is 1EAF, PID is 0003

this is the first few (6) seconds once you press reset.

once it jumps to your sketch, and unless your sketch does anything special, normally you would just see a 'COM' port.
that 'COM' port is USB-Serial it is the Serial in the sketch that you can read and send response in the sketch.

and the USB VID become 1EAF, PID become 0004 USB Serial

following up on DFU install, it means, after you've experimented with dfu-util -l and noted the timing between pressing reset and hitting enter for dfu-util -l
you can do the same to install a sketch, press reset, next you have 6 seconds to run

Code: Select all

dfu-util -a 2 -RD sketch.bin
i hardly use the arduino ide to install my sketches, this simple command line trick does it each time every time
and no dongles, it is just a usb cable
walla121
Posts: 6
Joined: Wed Jan 08, 2020 7:17 pm

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by walla121 »

ag123 wrote: Sun Jan 12, 2020 6:45 pm note that libmaple core has its origins here
http://docs.leaflabs.com/static.leaflab ... start.html
it is really fine core for those willing to venture beyond the 'com' ports
i actually played with the original maple arduino ide and literally used it

in tools folder you would find a utility dfu-util
the command line to install a binary (compiled from a sketch) with roger's stm32duino boot loader
https://github.com/rogerclarkmelbourne/ ... bootloader
is

Code: Select all

dfu-util -a 2 -RD sketch.bin
and you can actually list the DFU capable devices using

Code: Select all

dfu-util -l
to use this, get your command line

Code: Select all

dfu-util -l
ready to press enter

press reset and press enter

Code: Select all

dfu-util -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2019 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [1eaf:0003] ver=0201, devnum=33, cfg=1, intf=0, path="3-9", alt=2, name="STM32duino bootloader v1.0  Upload to Flash 0x8002000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=33, cfg=1, intf=0, path="3-9", alt=1, name="STM32duino bootloader v1.0  Upload to Flash 0x8005000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=33, cfg=1, intf=0, path="3-9", alt=0, name="STM32duino bootloader v1.0  ERROR. Upload to RAM not supported.", serial="LLM 003"
the outputs are in linux, and this isn't the dfu-util in the core, this one is build from source
http://dfu-util.sourceforge.net/
but that in the core works the same way

you will only see the above dfu-util -l outputs if the stm32duino boot loader is in DFU mode and ready to load the sketch.
you will also note that the USB VID is 1EAF, PID is 0003

this is the first few (6) seconds once you press reset.

once it jumps to your sketch, and unless your sketch does anything special, normally you would just see a 'COM' port.
that 'COM' port is USB-Serial it is the Serial in the sketch that you can read and send response in the sketch.

and the USB VID become 1EAF, PID become 0004 USB Serial

following up on DFU install, it means, after you've experimented with dfu-util -l and noted the timing between pressing reset and hitting enter for dfu-util -l
you can do the same to install a sketch, press reset, next you have 6 seconds to run

Code: Select all

dfu-util -a 2 -RD sketch.bin
i hardly use the arduino ide to install my sketches, this simple command line trick does it each time every time
and no dongles, it is just a usb cable
I tried connecting it on 2 different computers, but the device is still not recognized so I think the bluepill is faulty and i will order a new one and then try all this steps.
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by ag123 »

if you do hit issues, one way is to use st-link to program and connect a separate usb cable, that one should show up as a com port once you installed a sketch that reads and write to Serial. but in this case you need to select upload method as st-link and i think you can install the sketch directly from arduino ide.
just that it take 2 separate cables, one for the st-link, the other goes directly to the usb port, no boot loader is needed
and after you have installed the sketch, actually you can unplug st-link from the board and just use the usb cable for comms on Serial() (e.g. Serial.read() or Serial.write() in the sketch)

try to get from the more reliable ones such as robotdyn if you are buying only a (less than) handful, the price difference is rather moderate
and robotdyn is a manufacturer, and according to some members here, they do respond if you contact them about the boards
https://robotdyn.com/catalog/developmen ... ields.html
r1s8k
Posts: 15
Joined: Tue Mar 10, 2020 7:14 pm
Answers: 1

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by r1s8k »

Juraj wrote: Thu Jan 09, 2020 3:59 pm ST-Link is not a Serial adapter, it is a programmer. You can't open a Serial Monitor over ST-Link.
to see the Serial prints connect the Blue Pill with USB cable. without bootloader listening on USB you can't upload over USB but it works as Serial (or Serial1?) with Serial Monitor or other terminal program
Thanks for the information, now I understand these boards more.
Post Reply

Return to “General discussion”