Author Topic: STM32 advice for newbie  (Read 2810 times)

0 Members and 1 Guest are viewing this topic.

Offline medical-nerdTopic starter

  • Regular Contributor
  • *
  • Posts: 198
  • Country: gb
  • What's that coming over the hill?
STM32 advice for newbie
« on: March 06, 2018, 02:02:01 am »
Hiya

I'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 ? JTAG

I'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
'better to burn out than fade away'
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: STM32 advice for newbie
« Reply #1 on: March 06, 2018, 02:15:56 am »
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.
« Last Edit: March 06, 2018, 02:17:32 am by ataradov »
Alex
 
The following users thanked this post: medical-nerd

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: STM32 advice for newbie
« Reply #2 on: March 06, 2018, 07:53:05 am »
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)
 
The following users thanked this post: medical-nerd

Online paulca

  • Super Contributor
  • ***
  • Posts: 4053
  • Country: gb
Re: STM32 advice for newbie
« Reply #3 on: March 06, 2018, 08:00:39 am »
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.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 
The following users thanked this post: medical-nerd

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: STM32 advice for newbie
« Reply #4 on: March 06, 2018, 02:47:24 pm »
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
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: STM32 advice for newbie
« Reply #5 on: March 07, 2018, 03:35:26 am »
Roger Clark, who did the integration work for STM32 boards with the Arduino IDE, hosts a forum at http://www.stm32duino.com/ where all the details, and links to the software, can be found. There's a 'getting started' guide at https://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).

Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: STM32 advice for newbie
« Reply #6 on: March 07, 2018, 07:39:01 am »
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=Boards

I'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.html
http://www.st.com/en/evaluation-tools/stm32-mcu-nucleo.html
 

Offline ealex

  • Frequent Contributor
  • **
  • Posts: 313
  • Country: ro
Re: STM32 advice for newbie
« Reply #7 on: March 07, 2018, 11:18:48 am »
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
 

Online paulca

  • Super Contributor
  • ***
  • Posts: 4053
  • Country: gb
Re: STM32 advice for newbie
« Reply #8 on: March 07, 2018, 12:56:37 pm »
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.

Do 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?
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline medical-nerdTopic starter

  • Regular Contributor
  • *
  • Posts: 198
  • Country: gb
  • What's that coming over the hill?
Re: STM32 advice for newbie
« Reply #9 on: March 07, 2018, 01:18:11 pm »
Hiya

I 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
'better to burn out than fade away'
 

Online paulca

  • Super Contributor
  • ***
  • Posts: 4053
  • Country: gb
Re: STM32 advice for newbie
« Reply #10 on: March 07, 2018, 02:25:49 pm »
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.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline gertux

  • Contributor
  • Posts: 27
  • Country: be
Re: STM32 advice for newbie
« Reply #11 on: March 07, 2018, 03:43:18 pm »
If you want to go bare metal on an STM32F103T8 (and friends) I can recommend libopencm3.
It has numerous examples in a related repo libopencm3-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 the Atollic site

I 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.
 

Offline lewiss66

  • Newbie
  • Posts: 7
  • Country: fr
Re: STM32 advice for newbie
« Reply #12 on: April 14, 2018, 05:31:19 pm »
You can us sloeber arduino for eclipse where you can make your own class and libraries:
http://eclipse.baeyens.it/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf