STM32 advice for newbie - Page 1
Forum section: electronics / beginners

author: medical-nerd
author_rank: Regular Contributor
timestamp: March 06, 2018, 02:02:01 am
content: HiyaI'm contemplating having some fun with STM32 boards - the cheap ones on ebay but am now very confused.There appear to be some compatible with the arduino IDE - these need a USB to TTL interface.Others seem to have a programming interface built-in on board and use a USB connection.Still others may need an interface ? JTAGI'm looking at Atollic TrueSTUDIO as a free IDE and am downloading it - I've also looked at ST-Link interfaces labelled as debuggers.What is not clear to me is whether the ST-Link is the device used to download programs onto a board? I've never used a board with a JTAG interface before - does the ST-Link connect to these?I've searched for an introductory guide and found nothing clear, I'm completely out of my depth as am only used to the Arduino IDE and compatible boards and want to look beyond this - being able to use generic boards and not development boards with all the bells and whistles.This is just too basic a question to put on the microcontrollers forum - can anyone help, or point me to a resource, since I must be searching for the wrong things at the moment.Cheers

author: ataradov
author_rank: Super Contributor
timestamp: March 06, 2018, 02:15:56 am
content: Generally you want to have ST-Link interface. ST-Link has SWD interface (like JTAG, but uses only 2 pins), and will let you debug the board.Boards pre-programmed with Arduino bootloader will still have SWD connector. So if you have ST-Link, you will be fine with those boards (connector may need to be soldered).Arduino-compatible boards that are not Arduino, are a waste of money and attempt to capitalize on the name, IMO.

author: MosherIV
author_rank: Super Contributor
timestamp: March 06, 2018, 07:53:05 am
content: I have not seen any of the ST boards on ebay. ST make their own range of development boards called Nucleo. They are VERY cheap, even cheaper than Ardiuno boards some times, some Nucleo boards are less than £10 from reputable sources like Farnell via their Web site.Nucleo boards have the ST link build on board. Atollic will work but I am not a fan of Eclipse based IDEs. I find the debugger interface to be problematic.There is a steap learning curve if you are coming from Ardiuno. Everything is already done and available as plug in libraries in Ardiuno. This is so that it is easy for beginners. Now with dev boards, you are left to figure out everthing for yourself. Do not panic, ST web site has some example code buried some where, you going to have to really look hard though.The ST forum is a great source of help for beginners. Do not expect thing to be handed on a plate to you (like it was on Ardiuno) you must try to understand what is needed and write sime cide first, then some kind person on the forum will try and help you. If you are lucky 'Clive' may even help you (I do not know where finds the time to work and help)

author: paulca
author_rank: Super Contributor
timestamp: March 06, 2018, 08:00:39 am
content: The Arduino variant OP is asking about the STM32-Arduino.http://www.stm32duino.com/These coupled with the relevant board installed in the Arduino IDE have many Arduino libraries already ported and work from the Arduino IDE.There are boot loaders available to enable the USB, but some of the boards have bugged USB hardware.A standard USB to serial adaptor works.They cost about $3.

author: rstofer
author_rank: Super Contributor
timestamp: March 06, 2018, 02:47:24 pm
content: Some of the STM boards are 'mbed' compatible like the STM32F303RE. In effect, these devices look to the PC as a mass storage device. You simply drag and drop the executable onto the virtual drive and reset.https://os.mbed.com/teams/ST/Over on the right of the web page is a long list of compatible boards.One advantage of the 'mbed' approach is that you don't need to install any toolchain, everything is done via a web page and it isn't the least bit 'clunky'. You can use any computer with a browser to write your code from anywhere in the world.The STM32F303RE is $11 at Digikey.https://www.digikey.com/products/en/development-boards-kits-programmers/evaluation-boards-embedded-mcu-dsp/786?k=stm32f303re

author: Cerebus
author_rank: Super Contributor
timestamp: March 07, 2018, 03:35:26 am
content: Roger Clark, who did the integration work for STM32 boards with the Arduino IDE, hosts a forum athttp://www.stm32duino.com/where all the details, and links to the software, can be found. There's a 'getting started' guide athttps://github.com/rogerclarkmelbourne/Arduino_STM32/wiki.If the OP wants to use the pictured boards (colloquially know as the "blue pill" board) with the Arduino IDE the easiest route is to get one of the STLink clones available for a few doll-hairs and use that to program an Arduino bootloader onto the board. After that, the USB interface can be used for programming in a similar fashion to other 'Arduino' boards.This has the bonus that, if you get bored of the limitations of doing it the 'Arduino' way you're ready equipped with a download/debugging tool that is supported by all the free/open toolchains for the STM32. Personally I find using the STLink quicker and easier than using a serial adaptor and fiddling with the BOOT0/1 jumpers. If I recall correctly there's also an option to use the STLink as programmer for your Arduino sketches once you've got the STM32durino libraries loaded up (if you're unlucky enough to get one of the boards with bollixed USB wiring).

author: westfw
author_rank: Super Contributor
timestamp: March 07, 2018, 07:39:01 am
content: AFAIK, nearly all of the STM32 chips have at least a serial bootloader in ROM ("System Memory"), so if you want to use them with STM32duino (for example), you should be able to load them up with the appropriate bootloader with nothing but a USB/Serial adapter and some awkward manipulation of pin states during reset or power-up. (actually, I don't know if STM32duino uses a separate bootloader (that doesn't rely on awkward pins states), or whether it relies on board hardware to magically manipulate the pins for "auto-reset".)STM32duino "which to buy" is mostly focused on the "really cheap" STM32f103 boards, and they have a list of support status here:http://wiki.stm32duino.com/index.php?title=BoardsI'll second the recommendation for the ST "Nucleo" and "Discovery" Official Evaluation Boards.While they're not in the "$5 from China, including shipping" category, they are really good deals (most under $30, many "about $10"), and they include a debugging interface, full documentation, and support for several "real" development environments.http://www.st.com/en/evaluation-tools/stm32-mcu-discovery-kits.htmlhttp://www.st.com/en/evaluation-tools/stm32-mcu-nucleo.html

author: ealex
author_rank: Frequent Contributor
timestamp: March 07, 2018, 11:18:48 am
content: I'm also for a "Nucleo" or "Discovery" board as well.You'll get the debugger on the same board and it will work properly from the start.These are too complex to debug with just print -> you need to learn some basic low level debugging.For the dev. environment: GCC ( arm-none-eabi-* note the "none part" - it's bare metal, does not expect an OS ), openocd and Eclipse + EmbSysRegView . ( easier to set up in linux ... )It's not great but once you get everything set up it will work.I'll recommend starting the hard way - makefile, linker scripts, start-up code, etc - it will help you long term understanding what's under the hood.Also, stay away from the ST libraries - you'll have to understand the HW before you start debugging those libraries ...I can provide a basic start-up example project for STM32F050 / STM32F030 if you need / maybe get a tutorial thread going, but you can find all of those on the net these days

author: paulca
author_rank: Super Contributor
timestamp: March 07, 2018, 12:56:37 pm
content: Quote from: medical-nerd on March 06, 2018, 02:02:01 amDo you have any software development experience in C/C++ beyond Arduino?Have you used the GNU stack before?If the answer to those is no, then your options are a good STM specific IDE in windows or the Arduino boards.... or the third option, a long, slow disperse, multi-faceted learning curve.I have been a professional C and C++ developer in the past and an amateur builder of custom linux distros but the GNU make, automake, autoconf stuff still throws me challenges, especially when you come to cross compiling for foreign environments. With the raw C/C++ you will find C/C++ is nothing at all like Arduino code which provides global functions designed to be newbie friendly.So while there is good advice above from others, the main question I would ask is...Do you want to get the board into use and doing things with it and pick up things as you go or do you want a long hard learning curve towards mastering bare metal STM uCs?

author: medical-nerd
author_rank: Regular Contributor
timestamp: March 07, 2018, 01:18:11 pm
content: HiyaI was heavily into Linux - but that was nearly 20 years ago - when you basically made your own distribution - I fondly remember changing gradually from a.out to elf and the problems it caused in a mixed system, kernel hacking and porting old programs. I've not touched gcc/makefiles/autoconf etc since. Now I'm slowly getting back to my previous interests.I'd like to use a ST specific IDE but get down to the bare metal. I've previously screwed up functioning gcc setups by trying to cross-compile but I expect things have changed over 20 years!!!I'm sticking with arduino at the moment for working projects to get used to coding again, but feel very restricted, which is why I want to play with STM32 at a lower level - does that make sense?Cheers

author: paulca
author_rank: Super Contributor
timestamp: March 07, 2018, 02:25:49 pm
content: As an interim step you can usually use the bare metal STM code from the Arduino IDE. So you can port your code bit by bit away from Arduino.Cross compiling I agree used to be very scary, trying to compile a gcc for a foreign environment was very difficult, but I recently tried the AVR cross compile tool chain and found packages already set up for compile in Gentoo which made things easier. The like of Ubuntu probably have binaries ready to go, or the various STM communities will have similar.One thing, at least on smaller MCUs is the code back never gets that big to cause major make difficulties. As the board as almost fixed and you will probably only be supporting one or two autoconf is less relevant. So you can probably get by with a single make file.For AVR-gcc builds I managed to succeed with recently I just used a shell script.Getting way off topic, but "SConscript" is a good modern Make alternative.

author: gertux
author_rank: Contributor
timestamp: March 07, 2018, 03:43:18 pm
content: If you want to go bare metal on an STM32F103T8 (and friends) I can recommendlibopencm3.It has numerous examples in a related repolibopencm3-examples.Like others already said, buy an ST-link (or clone for spare change, about 2$) and you're set programmer wise.If you're looking for an IDE, STM recently aquired Atollic and you can download it for free from theAtollic siteI use CLion from JetBrains but that is mainly because I nearly spend all day in their development tools (CLion for Rust and C, IntelliJ for Java and PyCharm for python) that it's hard to switch to an Eclipse like IDE for embedded stuff.

author: lewiss66
author_rank: Newbie
timestamp: April 14, 2018, 05:31:19 pm
content: You can us sloeber arduino for eclipse where you can make your own class and libraries:http://eclipse.baeyens.it/