[Solved] Questions from a newbie about Bluepill.

Working libraries, libraries being ported and related hardware
User avatar
Rick Kimball
Posts: 1400
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: ?Help! Questions from a newbie about Bluepill.

Post by Rick Kimball » Tue Jul 31, 2018 4:47 pm

human890209 wrote:
Tue Jul 31, 2018 4:15 am
Q1. Is there a documentation for Bluepills just like those for Arduino boards on their official website?
viewtopic.php?f=28&t=117

That link isn't documentation, but more a running blog on how the genericSTM32F103 board became the bluepill. As you follow the posts, you can learn as I learned, stumbling, experimenting, sharing my successes, enjoying other's input, breaking things and then fixing them.
human890209 wrote:
Tue Jul 31, 2018 4:15 am
Hi,
Q3. What's the VB used for? Is it not the same as VRAW on Arduino boards? What's its voltage safe range?
This meant to be used with the RTC peripheral so you can power down the device but maintain the RTC settings. Search this site for RTC V Battery and read about the warnings about it. You want to use this only with 3v3. Feeding it anything else will blow your stm32 chip.
human890209 wrote:
Tue Jul 31, 2018 4:15 am
Q4. What's the right way to use 128kb flash? Just open a sketch of 100kb with the STM32F103C8 64kb option selected, then simply click upload?
Just select 128k option and use it. I don't think anyone has a bluepill that doesn't have 128k. Obviously if you were making a commercial product you would buy the stm32f103cb if you needed the 128k, but as a hobbyist obviously you don't care and just want bonus stuff for free. If it doesn't work, you just switch back to 64k. If it does work, Win!
human890209 wrote:
Tue Jul 31, 2018 4:15 am
Q5. What's the internal pull-up resistor's value of the Bluepill and total minimize pull-up resistor for I2C?
You want to use external resistors with a bluepill. On top have having high resistance internal pullups, the 3V3 voltage will round your I2C square waves to become useless. So you want to use a lower values than you would use on a 5V arduino. So if you used to use a 2.2k on a 5v, you want to use ~1k5 on 3v3.
human890209 wrote:
Tue Jul 31, 2018 4:15 am
Q6. Should all pins shared by Serial1/Wire1 be avoided? And does Serial1 conflict with Wire1(share PB6 PB7)?
If you want to use the Serial1 pins as GPIO pins, fine do it. Same with Wire1.
-rick

flyboy74
Posts: 231
Joined: Wed Jun 13, 2018 11:02 am

Re: ?Help! Questions from a newbie about Bluepill.

Post by flyboy74 » Tue Jul 31, 2018 9:42 pm

Rick Kimball wrote:
Tue Jul 31, 2018 1:09 pm
flyboy74 wrote:
Tue Jul 31, 2018 7:51 am
Usually most places sell this board with Ardunio boot loader already installed so you should be able to upload then.
This is not true. The only place offering a pill board preloaded with Roger's USB bootloader is robotdyn.com All other sources provide the board loaded with just a blink program. You might be confusing it with the ROM based uart bootloader that works on USART1 which is built into the chip.
OK something for me to learn here. My understanding was that Ardunio puts a small bit of code(ardunio boot loader) on the chip that when it starts up it checks the status of the boot pin and if selected for boot mode then instead of starting the main program it listens on UART1 for new code to be uploaded.

When I first started to use blue pill I was uploading from Ardunio IDE via PA9 and PA10 with CP2104 serial converter. R u saying this is not using Ardunio boot loader but rather a boot loader that is permanently on the chip and can't be erased and Ardunio boot loader is a second boot loader that sits on top of this 1???

User avatar
Rick Kimball
Posts: 1400
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: ?Help! Questions from a newbie about Bluepill.

Post by Rick Kimball » Tue Jul 31, 2018 11:04 pm

flyboy74 wrote:
Tue Jul 31, 2018 9:42 pm
OK something for me to learn here. My understanding was that Ardunio puts a small bit of code(ardunio boot loader) on the chip that when it starts up ...
The Arduino doesn't add any code. It just uses one of the upload methods you select.
flyboy74 wrote:
Tue Jul 31, 2018 9:42 pm
When I first started to use blue pill I was uploading from Ardunio IDE via PA9 and PA10 with CP2104 serial converter. R u saying this is not using Ardunio boot loader but rather a boot loader that is permanently on the chip and can't be erased and Ardunio boot loader is a second boot loader that sits on top of this 1???
Yes, you were using the ROM (system memory) bootloader that is triggered by the settings of the BOOT0/BOOT1 pins when the chip is RESET. When this project first started, bluepill users only had this ROM builtin method to upload. Which at the time we didn't consider a major problem. We had yet to discover why many of use couldn't use USB (it turned out to be the problem with the R10 resistor not being 1k5) Roger's bootloader didn't work with the bluepill at that time. Bluepill users either used the USART1 ROM bootloader or we used an STlink SWD dongle. The only board that had a preloaded USB bootloader was the Maple Mini or the Maple Mini clone from Baite. There is actually no reason to load Roger's bootloader if you are happy manipulating the BOOT0/BOOT1 pins and using a serial dongle. In fact, you get back 8k of flash buy not loading Roger's bootloader.

You can find out about the Bootloader and which devices it will work win in the ST Application Note AN2606
from the AN2606 document wrote:The bootloader is stored in the internal boot ROM memory (system memory) of STM32
devices. It is programmed by ST during production. Its main task is to download the
application program to the internal Flash memory through one of the available serial
peripherals (USART, CAN, USB, I2C, SPI, etc.). A communication protocol is defined for
each serial interface, with a compatible command set and sequences. This document
applies to the products listed in Table 1. They are referred as STM32 throughout the
document.
Our ancient STM32F1 chip only support the USART1 peripheral for ROM bootloading. However, as time went on ST added more and more ways to upload to their chips. Some support USB DFU uploading directly from the ROM bootloader. However, because our chip only supports the USART1, the original LeafLabs people created firmware that is loaded in low flash memory and provides the USB DFU through software in flash.

The ST Application Note AN3155 explains the details of protocol used by the USART bootloader.. The opensource stm32flash application implements this protocol and runs on Windows, Linux and OS/X. In addition, there is an ST windows application (FLASHER-STM32) that does the same thing with a GUI.

In the Arduino AVR world, the atmega328p chip supports a builtin upload method (In the AVR world the builtin in method uses SPI). The Arduino AVR people added a serial bootloader into the flash of the chip and a host program to interface to it (avrdude).

In the stm32 world, the serial upload method already existed on the ROM, Roger improved and added the code to the LeafLabs bootloader that allows the bluepill to upload over the native USB interface using DFU protocol and the dfu-util host application.
-rick

flyboy74
Posts: 231
Joined: Wed Jun 13, 2018 11:02 am

Re: ?Help! Questions from a newbie about Bluepill.

Post by flyboy74 » Wed Aug 01, 2018 12:07 am

I am sorry for hijacking this thread but have another question to ask.

I haven't used DFU boot loader yet. But if I understand what your saying is that the Blue Pill doesn't have DFU native but rather you have to add Roger code to use it but some other STM32 MCUs do have DFU native. Am I right in thinking the STM32F407 does in face have the DFU already on the ROM?

Also just so that I understand everything correctly that upload with st-link via SWD doesn't require a boot loader and has a low level control (can reset/erase and flash) regardless off boot pins??

User avatar
Rick Kimball
Posts: 1400
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: ?Help! Questions from a newbie about Bluepill.

Post by Rick Kimball » Wed Aug 01, 2018 12:20 am

flyboy74 wrote:
Wed Aug 01, 2018 12:07 am
Am I right in thinking the STM32F407 does in face have the DFU already on the ROM?
You should go read the AN2606. I think that chip does, but you would have to check. I'm drawn to the stm32f103cx because of the cost. If I was going to move up to the STM32F4 chips, I'd just buy a Nucleo or Discovery board which comes with an attached STlink and I wouldn't worry about DFU or Serial bootloaders.
flyboy74 wrote:
Wed Aug 01, 2018 12:07 am
Also just so that I understand everything correctly that upload with st-link via SWD doesn't require a boot loader and has a low level control (can reset/erase and flash) regardless off boot pins??
Yes SWD talks to the Debug Access Port using the Coresight protocol. No bootloader used, you can reset/erase and flash, in addition, it provides its main purpose which is debugging. However, unlike the ROM serial bootloader which can't be disabled, the user code can disable the SWD pins. In fact, the stm32duino code will disable the SWD pins if you compile and successfully upload using the "STM32Duino bootloader". However, you can set the BOOT0 pin to 1 to gain control if you ever do that accidentally. Of course, if you never load Roger's bootloader (AKA STM32Duino bootloader), you don't have to worry as you won't be able to upload without it.
-rick

flyboy74
Posts: 231
Joined: Wed Jun 13, 2018 11:02 am

Re: ?Help! Questions from a newbie about Bluepill.

Post by flyboy74 » Wed Aug 01, 2018 6:33 am

I'm drawn to the stm32f103cx because of the cost
Yes at $2US for a blue pill the price to performance ratio can't be beat.

The black STM32F407VE at $7US is also very hard to beat for price to performance ratio with: more pins, RTC crystal and battery, SD card slot,QSPI flash storage along with more flash and RAM and processing power.

User avatar
mrburnette
Posts: 3001
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: ?Help! Questions from a newbie about Bluepill.

Post by mrburnette » Thu Aug 02, 2018 1:47 am

flyboy74 wrote:
Wed Aug 01, 2018 6:33 am
I'm drawn to the stm32f103cx because of the cost
Yes at $2US for a blue pill the price to performance ratio can't be beat.

The black STM32F407VE at $7US is also very hard to beat for price to performance ratio with: more pins, RTC crystal and battery, SD card slot,QSPI flash storage along with more flash and RAM and processing power.
I disagree.
At a delivered price (qty==1), the $2.77 ESP8266 offers superior performance and capability (analog excepted.)
At a delivered price (qty==1), the $4.74 ESP32 blows the blue pill and ESP3266 out of the price-performance chart.

That being said, the Blue Pill is a go-to for sensor integration, protocol conversion, datagram parsing and formatting and many other places where discrete TTL/CMOS logic was used many years ago. In many circumstances, the Blue Pill is all that is needed.

Increasingly, I am finding that larger design efforts, while possibly distilled into the space of a Blue Pill are better put into an ESP32... huge SRAM, large 4M eeprom, dual-core, 3rd support processor, easily to utilize SPIFFS, low-power sleep, etc. Even the ESP8266 has a completely different power consumption personality when the RF section is disabled.

At ~ $2, the STM32 F103 boards are within the price of a few 4000 CMOS chips and I often use it that way.

For lifting heavier than the ESP32, I have fallen in love with the $5 rPi Zero. Just not for realtime data collection although my experience has been that near-realtime is often adequate.


Ray

human890209
Posts: 34
Joined: Mon Jul 30, 2018 12:19 pm

Re: ?Help! Questions from a newbie about Bluepill.

Post by human890209 » Thu Aug 02, 2018 2:19 am

Is there ESPduino or rPIduino for a Arduino user like me?
I like ??duino because I can easily switch hardware without changing bunch of my codes.
For now, I'm looking for a best price-SRAM ratio hardware. Of course, faster and more functions are also welcomed.
Yesterday I just found STM32F407 got 192k SRAM which is nearly 10x Bluepill and the price is just 3.5x. So I ordered one.
And just ordered an ESP8266... The datasheet says it has about 50k SRAM, which is cool. And there seems an Arduino Core for it.
------------3 minutes later-------
ESP32 got 520k SRAM!, and also an Arduino Core for it, keep ordering.....

flyboy74
Posts: 231
Joined: Wed Jun 13, 2018 11:02 am

Re: ?Help! Questions from a newbie about Bluepill.

Post by flyboy74 » Thu Aug 02, 2018 5:13 am

I disagree.
At a delivered price (qty==1), the $2.77 ESP8266 offers superior performance and capability (analog excepted.)
At a delivered price (qty==1), the $4.74 ESP32 blows the blue pill and ESP3266 out of the price-performance chart.
I am certainly a lover of the ESP32 and I use it a lot mainly due WiFi enabled and bang for buck is crazy great.
Here is a robot that I built with a ESP32 that runs provides a WiFi access point and runs a web server with web sockets so that you can control the robot with a web broswer https://www.youtube.com/watch?v=-MyodFHwfTU the PCB with the ESP wrover module I designed and built myself

The only main downside that I have found with ESP32 is low pin count. I am always struggling for enough pins on my projects. My play with STM32 atm is because I am playing with a camera running 8 bit parallel and a LCD in 16 bit parallel.

stevestrong
Posts: 3053
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: ?Help! Questions from a newbie about Bluepill.

Post by stevestrong » Thu Aug 02, 2018 8:22 am

I am with @flyboy74.
ESP gives wireless connectivity and STMFx gives pins and real-time processing.

Btw, can you share some of the code from that video? Special interested in MicroWebSockets.
I have myself ported WebSockets to blue pill. Is MicroWebSockets different from that? Just trying to reduce the RAM usage.

Post Reply