[SOLVED] Help getting started with the Blue Pill

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
Post Reply
JJJollyjim
Posts: 4
Joined: Sun Nov 26, 2017 6:01 am

[SOLVED] Help getting started with the Blue Pill

Post by JJJollyjim » Sun Nov 26, 2017 6:35 am

Hi all,

I have just received a batch of blue pills. I went through the process to flash the bootloader with a USB Serial converter, and at first glance it seems to work: I now have a /dev/ttyACM0 which continuously outputs

Code: Select all

Congratulations, you have installed the STM32duino bootloader
See https://github.com/rogerclarkmelbourne/STM32duino-bootloader


For more information about Arduino on STM32
and http://www.stm32duino.com
From the Arduino IDE, I can now attempt to upload Blink (with the pin set to PC13, where the LED appears to be):

Code: Select all

dfu-util 0.7

No DFU capable USB device found
Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Filter on vendor = 0x1eaf product = 0x0003
Waiting for /dev/ttyACM0 serial...Done
It claims to be successful, and the LED flashes several times during the upload (note that I uploaded the '_pc13' bootloader version, so I definitely have the right LED pin), however even when pressing the reset or replugging, I see no evidence that the sketch started. Similarly, if I upload a sketch which should be using the serial, I still only see the repeating bootloader output on ttyACM0. Is this perhaps the Perpetual Bootloader mode? With an oscilloscope on PC14 I see no evidence that it is ever pulled high, which I understand means perpetual bootloader shouldn't be entered, plus that would give me a DFU device rather than an ACM, right?

Thanks in advance!
Last edited by JJJollyjim on Sun Nov 26, 2017 9:04 am, edited 1 time in total.

User avatar
RogerClark
Posts: 7680
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Help getting started with the Blue Pill

Post by RogerClark » Sun Nov 26, 2017 6:42 am

Umm

If you can see the message you have successfully flashes the bootloader and installed the drivers and selected the com port

Did you select the Generic STM32F103C board type for upload ?

You need to select the bootloader upload method. Serial method is for using an external USB to Serial converter in the same way you used to load the bootloader (hardly anyone uses this to upload sketches, but some people use it if they want the extra 8 k that the bootloader occupies)

Try writing some code that prints to Serial

e.g. something like

Code: Select all

void setup()
{
}

int c=0;
void loop()
{
Serial.println(c++);
delay(100);
}

Its strange that if you loaded the bootloader for led on PC13 but your code can't flash the LED as it must be on PC13

So my best guess would be that the board selection is wrong

JJJollyjim
Posts: 4
Joined: Sun Nov 26, 2017 6:01 am

Re: Help getting started with the Blue Pill

Post by JJJollyjim » Sun Nov 26, 2017 6:58 am

RogerClark wrote:
Sun Nov 26, 2017 6:42 am
Did you select the Generic STM32F103C board type for upload ?

You need to select the bootloader upload method.
Hi, I believe I have all the settings correct:
Image

The same issue occurs with that sketch, and when set to either 64k/128k flash: the serial port continues to loop printing the bootloader message every ~second rather than the numbers. Am I right in understanding that the serial used by that sketch is the virtual USB one rather than a physical one?

Thanks for the help.

User avatar
RogerClark
Posts: 7680
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Help getting started with the Blue Pill

Post by RogerClark » Sun Nov 26, 2017 7:45 am

Umm.

Settings look OK.

Does it reboot into the bootloader when you hit upload in the IDE. At this point the bootloader enumerates a dfu device on USB

As You are on LInux, it could be udev rules

Or sometimes there is a speed problem with the not enumerating the USB bus fast enough.

JJJollyjim
Posts: 4
Joined: Sun Nov 26, 2017 6:01 am

Re: Help getting started with the Blue Pill

Post by JJJollyjim » Sun Nov 26, 2017 9:02 am

I've managed to flash a blink!

While debugging this, I somehow broke something such that the close system call on ttyACM0 hangs for ages, preventing upload-reset from functioning properly... with that aside, I substituted something based on a different version of maple_upload I found on github:

Code: Select all

if [ -e $dummy_port_fullpath ]; then
	echo "resetting " $dummy_port_fullpath
	stty -F $dummy_port_fullpath 1200
	sleep 0.5
fi
(-f was used in the script but does not exist in my stty).

Playing with the timings, I can get it to work sometimes! :)

User avatar
RogerClark
Posts: 7680
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: [SOLVED] Help getting started with the Blue Pill

Post by RogerClark » Sun Nov 26, 2017 10:06 am

Umm.

OK.

I think this problem may be similar to the one a few other people have had, where the PC is taking longer to re-enumerate the USB and detect the DFU device than the bootloader waits as a DFU device.

The bootloader has 2 ways to hold in DFU mode,

1. For the version of the bootloader you have installed, pull pin PC14 high.

(the bootloader has this code)

Code: Select all

    #define BUTTON_BANK GPIOC
    #define BUTTON_PIN 14
#define BUTTON_PRESSED_STATE 1
Then when the IDE resets the processor and it runs the bootloader it will hold waiting for upload

Alternatively there is a way to get the core to signal to the bootloader to hold in DFU, but this feature is implemented in the bootloader but has never been added to the core because it uses a battery backed RAM location and some people use those for storage when running from battery


Anyway, the PC14 trick first

Post Reply