#353 How to use STM32 boards with Arduino IDE and how fast are they? (incl. surprise)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in video number 345 i asked the question whether the esp32 or the stm32 blue pill is the better choice the video created quite some controversy mainly because i compared the weakest stm32 f-103 chip with a quite powerful esp32 some viewers thought i was unfair and suggested to do a test with more powerful chips this is what we will do and we will learn quite a few things about the chances and weaknesses of the stm32 duino project for example its capability to do inline debugging at the end of the video you will have a good overview and know some tricks to save you a lot of time and hassle and of course you will know which board you need for speed gritty youtubers here is the guy with the swiss accent with a new episode and fresh ideas around sensors and microcontrollers remember if you subscribe you will always sit in the first row stm32 processors are used in many more commercially available products than the esp8266 or the esp32 this must have a reason maybe we makers can profit if we know it this is why this video will cover the following topics we will get an overview of the stm32 chips and an overview of the available development boards we will speed test the typical representatives here we will see words like fortran and wax mips the older guys amongst us know what i'm talking about we will program different stm32 ports with the arduino ide here we will learn some tricks we will see how easy it is to do in-line debugging with platform io and surprise us with the board also mentioned by viewers let's start with the overview st microelectronics is headquartered in switzerland they create a lot of stuff today we are only interested in their 32-bit microprocessor units starting with the five letters stm32 all of them are faster and more capable than the arduino uno or the mega by the way they segment their range in ultra low power mainstream high performance and wireless here you already see a difference to expressive while they only have four mcus st microsystems has 1090 of them all based on arm cores and this might be the first reason why they are so successful in commercial applications we will later see if this also transfers to us makers because i did not see any boards with wireless chips readily available for makers except for a lora module from rack wireless i will concentrate on the rest of the offering a closer look at the naming shows that all low power chips have an l after the stm32 most others have an f it seems that the next number has to do with a core but here you have to pay attention f4 chips really use m4 cores but f1 chips use m3 cores so check before you decide a rule of thumb tells us that the higher the core number the more speed and other functions this is good to know for us makers when we have to decide which board to use another interesting fact if we for example start our development with a cheap f-103 c8t6 chip with 64 kilobyte flash and later discover that we need more we can select the chip with a similar pin out with more memory of speed or we start with a powerful mcu for development and when finished search for the cheapest possible chip which has enough memory for our product a few cents saved is this important for makers not too much because we usually buy boards and not chips and do not need to shave off every cent one thing however is significant we can program quite a few of those chips with our arduino ide you find a list on the stm32duino project github and the number crew from release to release stm itself supports the stmduino project the initial project of roger clark is no more maintained the next question for us is what kind of boards are available on the market here we have to distinguish between two very different sources the chinese and stm let's start with the chinese most of the recent discussions on this channel are around blue pills and black pills because they are relatively cheap if you search for other boards you also get them but check first if the arduino ide supports the chip before you order the blue pills use the c8t6 chip mentioned before they run on 72 megahertz have 64 kilobyte of flash and 20 kilobyte ram which is ridiculously small compared with a four megabyte flash of the esps the black pills come in two versions both use f4 chips and a floating point coprocessor to speed up calculations the f401 ccu runs on 84 megahertz has 256 kb flash and 64 kb ram the one with an f 411 ceu chip runs at 100 megahertz has 512 kilobyte flash and 128 kilobyte ram is this flash sufficient here i compiled one of the benchmarks for an stm32f432 it uses 27 kilobyte or 10 flash and 1 of ram the esp32 needs much more 17 and 4 percent maybe this has to do with the underlying rtos and wi-fi code of the esp32 we makers see that the stm32 memories are smaller but we also can build big sketches like with the esp32 at least with the f4 chips if we compare prices we see that we get a blue pill for around three dollars including shipping in single quantities the black pills are 3.83 respectively 4.96 a typical esp32 development board costs around five dollars similar to the most expensive pill as said before st microelectronics also sells development boards they are called nucleo and coming 3 versions with 32 64 and 144 pins the 32 pin versions are slightly bigger than an arduino nano the 64 pin versions are slightly bigger than the uno and the 144 pin versions are similar to the mega also here you get a lot of different versions pay attention the arduino ide supports not all of them this f722 board would have been nice for a test ride but it is not supported i ordered an f-746 and my supplier returned the money because it was his fault he said that the f-746 could not be exported to switzerland because it is dual use this means that it can be used for civil as well as for military applications i'm sure it would have improved the capabilities of our swiss army together with its famous swiss army knives it would be unbeatable i think now this board with a big chip waits till it is supported in the future version or maybe i will learn how to tweak the boards.txt file i would not mention those boards if they were expensive they are not sourced in switzerland the big ones are below 30 dollars including shipping the small ones are around 20 dollars maybe prices vary in your country the main difference between the chinese and the boards from st microelectronics is this part all boards come with a built-in so-called st link and now we are already in the next topic how do we program our boards here things are straightforward with the arduinos and esps all are programmed via serial connection most boards have a usb to serial adapter on board some of them not then you need a usb to serial adapter sometimes also called ftdi adapter the stm32s are different some of them can be programmed by a usb right of the box others need a bootloader which you have to install when you get them and if you prick them if you use an st-link adapter you are offered additional programming possibilities the original adapter is not extremely expensive but we also get cheap clones and here comes a trick st-link is available in version 2 and 2-1 my arduino ide did not accept these small st-link b2 adapters the bigger ones look very similar to the original and they can be upgraded to the newest release using this stm32 cube programmer a software which has to be installed before you can use stm32 chips with the arduino you just press this button then this one and lastly upgrade now it's on the newest version and can be used with the arduino ide so i would spend a little more and not buy one of those as usual we have to install the stm32 programming environment for the arduino ide i leave a link in the description on how to do it it is similar to the esp32 the first way of programming offered by these adapters is swd serial wire debug its connector only has four pins and all pills offer this connection swd always works even if you bricked your chip somehow and it can be used for inline debugging the next way of programming is the hid boot loader this is the way for blue pills caleb martick made a video on how to flash the bootloader and how to upload your sketch you find a link in the description the hid bootloader is only needed for the blue pills but i did not like this process i only would program them with an st-link this bootloader thing was not very stable in my case and pay attention for the test i also bought clones with cks 103 chips instead of stm32 i was able to program them with swd but my pc never recognized usb you can avoid this hassle by not buying blue pills maybe you have a different experience with them please comment next we go to the black pills they already have a bootloader on the chip and i did not hear of clones with different chips very good you get two versions according to your needs both behave the same first you plug the board into usb and select these parameters according to the chip on board now you have to do a similar procedures as on some esp boards press the boot 0 and nrst buttons together wait for the usb disconnected tone let the reset button go and wait for the usb connected tone now you should see stm bootloader in the device manager and can hit upload after uploading you should see the virtual com port your blackpill created this is the chinese way to program the boards now we go to the swiss way as said all nucleo boards have an st link on board as before you connect the board via usb and select the parameters like that currently i use a small nucleo32 f432 for the upload you can choose whatever method you want even the mass storage works because the chips create a disk drive on your pc hit upload and make sure you connect to the right com port if you want to use serial by the way if you do not choose these two parameters serial will not work simple and efficient no button pressing no bootloader flashing but i should not show off with these swiss features why after a few days of perfect working all my boards refused to show anything on serial anymore i tried nearly everything i even installed the environment on a different computer maybe you have an idea of how to correct this flaw anyway i found out that the serial 2 pins internally are connected to the st-link when i used serial 2 i got serial output via usb by the way the serial 2 pins are also connected to the pins labeled rxtx on the arduino connector of the nucleo64 boards the serial one pins are on d6 and d8 another trick if you use serial on pins not via usb you have to use different parameters in the board menu now i was able to go on with my speed tests in my last video these tests also gave cause for complaint so this time i use the official stm benchmark it consists of three parts a dry stone and two redstone sketches one with single and the other with double precision the tristone is an integer benchmark and the whetstone uses floating point numbers looking at the sketches you see copyright 1988 more than 30 years old then a little further down you find the word fortran fortran was the de facto standard for scientific calculations in the 60s and 70s and was also used afterward for that purpose it was the first programming language i learned in the 1970s when we were allowed to use the extremely expensive ibm 360 mainframe of our government during the daytime it calculated taxes but it was common back then to switch the computers off when people went home our professor knew the right people and got the key to the computer room like that we had a computer just for us the knights were short but we had a lot of fun and we learned fast the other interesting thing here is the output wax mips what does this mean wax was the most successful departmental computer in the 1980s built by digital equipment corporation ken olsen was something like elon musk today back then he beat the incredibly big and powerful ibm in many ways and was named america's most successful entrepreneur by fortune magazine and i was one of his proud employees anyway i deviate the wax 11 780 was the first model of a long row it was a big machine cost a million dollars quickly and produced precisely one wax mips and now we are in the middle of the performance test i used these sports for stm32f4 ports with three different processors two different stm32f1 boards with different processors and one stm32 low power port of course i compared them with the esp8266 and the esp32 i also tried to compare it with an arduino uno unfortunately the sketch was too big so we do not get an arduino mips for comparison the double precision redstone did not run on my l031 board if we compare the integer performance we see that even the low power chip for a few dollars beats the wax of 1978 by a factor of 17 but the top of the row still is the esp32 with nearly 200 wax mips the three of the four f4 chips are very similar the f446 is much faster this proves that the chinese pills have comparable performance as the nucleo boards with similar processors astonishingly the low power f4 is also quite fast the esp8266 is slower than the f-103 chips and comparable with a low-power l031 but how do they compare if they can use their co-processors to crunch floating point numbers the king in single precision definitely is the f446 it is more than two times faster than the esp32 again the other f4 chips are similar in performance and the f-103 and the esp8266 are much much slower because they have no co-processor but what about double precision here the esp32 has a similar performance as the f446 the low power l432 loses a little but interestingly the slow f103 chips are not slow in this benchmark but if we have a closer look we see that the single and the double precision mips are the same for these two processors also for the esp8266 the difference between the two benchmarks is tiny maybe the compiler cheats and uses the same precision for both benchmarks please comment if you know more the last point i wanted to show you is cool if you use platform io instead of the arduino ide you can debug all stm32 boards as shown in video number 274. you can do that with esp32 too but the arduinos and the esp8266 do not have this feature or at least not in a usable fashion here we only connect the st-link to the swd port and add these lines in platformio.ini because the nucleo boards already have the st-link built in we only have to plug them into a usb port very handy and by the way here the small and cheap st-link v2 adapters work strange i have to say i like inline debugging with break points and variable inspection a lot it simplifies my work and i'm very productive summarized the stm32 family is vast and has around 1 000 members compared with this choice the expressive family with four members is small but the espressif chips have a lot of features especially wi-fi this is why we love them the stm32 chips are available with several arm cores with very different properties and speeds the chip numbering is somehow intuitive generally bigger numbers are more powerful chips unfortunately not always they also have a low power line which is interesting enough to look at in the future we can either buy chinese or nuclear boards from st microelectronics the most famous chinese stm32 boards are the blue and the black pill i do not recommend to buy blue pills they have no native food loader their clones do not work correctly and they are hard to handle the black pills are the better choice they have a built-in bootloader are much faster have more memory and the f401 is not much more expensive than a bluepill the nucleo boards especially the bigger ones are not very expensive and a good choice mainly because of the built-in st-link which also works with only a usb cable the arduino ide works nearly flawlessly with the supported boards however pay attention that you do not buy unsupported ports the parameters in the boards menu have to be adjusted especially if you want to use serial print you have to use the right combination otherwise serial print will not work in my environment zero print suddenly stopped working so far i did not find a solution not good buy the right st-link otherwise you will not be able to program the chinese port with the arduino ide nor with the stm32 core programmer by the way the speed comparison reveals that my viewers were right the f4 chips are much faster than the f-103 chips used in video number 345. the fastest f446 used in my comparison is as fast as an esp32 but do not forget the esp32 has a second core if needed all stm32 chips can be debugged using platform i o and an st link one last thing some viewers might have missed the tnc 4.1 board presented in my last mailbag it is tiny costs around 30 dollars and has an m7 core its clock speed of 600 megahertz promises quite some power i did not want to include it in the comparison because it has no sem32 core and it is extremely fast the curves would have been useless to compare the rest of the chips but we can assume that the fastest stm32 chips are comparable in speed for integers it has nearly 10 times more wax mips than the fastest f446 and for double precision it is unbelievable 60 times faster than the f446 or the esp32 what a surprise ken olsen would be pleased to see such a small bugger if he would still be alive and now you probably understand why i do not want to sell hardware anymore the most expensive wax 9000 i sold cost 10 million swiss francs and was much slower than this tnc for 30 dollars the only remaining question is what is the application for such a beast as always you find the relevant links in the description i want to thank all my supporters on patreon and viewers using my links for their purchases for supporting the channel without you it would be difficult for me to make such quite expensive comparisons bye
Info
Channel: Andreas Spiess
Views: 116,355
Rating: undefined out of 5
Keywords: STM32duino, teensy, teensy 4.1, arduino, arduino project, beginners, diy, do-it-yourself, eevblog, electronics, esp32, esp32 datasheet, esp32 project, esp32 tutorial, esp32 weather station, esp8266, esp8266 datasheet, esp8266 project, greatscott, guide, hack, hobby, how to, iot, lorawan, nodemcu, project, simple, smart home, ttgo, wemos, wifi, stm32, bluepill, blackpill, Arduino IDE, nucleo, stm32f103c8t6, stm32f103, programming tutorial, tutorial, How-to
Id: 337rDuCGeYs
Channel Id: undefined
Length: 25min 8sec (1508 seconds)
Published: Sun Sep 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.