STM8s Breakout Board/ ST-Link V2 Connection Failure in Arduino Environment

by marcelo_euler in Circuits > Microcontrollers

2623 Views, 2 Favorites, 0 Comments

STM8s Breakout Board/ ST-Link V2 Connection Failure in Arduino Environment

STM8S_picture.jpg
Untitled.jpg

A 16Mhz, 8bit microcontroller with 16 GPI's and 5 AD 10 bits converter by ~1.5USD sure catch my attention. Its cost is less then a naked ATM328 chip.

But I find get it connect to Arduino IDE environment has its own trick.

Lt's take a look in STM8S103F3P prototype module and understand why some of then get problems upload sketch.

Supplies

- STM8S103P3 module (https://www.aliexpress.com/item/1005001906773540.h...

-ST-Link V2 Debug Tool (https://www.aliexpress.com/item/32887775852.html?s...

-Arduino IDE

-ST Visual Programmer * (https://my.st.com/content/my_st_com/en/products/de...

* needs site login

Preparing Computer Host

ARDUINO2.jpg
lib_install.jpg
tools_menu.jpg

I will not get in to Arduino IDE installation details. There are a full hand of sites out there explain it. But after install it, It would be necessary get libs to work with STM8S.

  1. Install Arduino IDE
  2. Select File > Preferences and at "Additional Boards URLs:", add:
  3. https://github.com/tenbaht/sduino/raw/master/package_sduino_stm8_index.json

    Note: If you already have other URL, click in little "window" icon next text box. It will open a multi-line text box window. EACH line is a URL. just add above link as new line in it.
  4. Go Tools Menu > Boards and select "Boards Manager". It will open a Window of Arduino IDE available boards library. In text box type STM8.
  5. "Sduino STM8 Plain C core (non C++)" option will appear. Click "Install". Close window after install.
  6. Go back to "Tools" Menu >"Boards Manager" and looking for "STM8S103F3 Breakout board". Ports will not matter, BUT you must go Tools > Programmer and select "ST-Link/V2".

Hardware Description and Connection

b oard Pinout.jpg
Untitled.jpg
STM Link Pict.jpg
pinout.jpg

First things first: Despite AliExpress point USB connector as "input", it is just for power purpose. If you take a look in board diagram, notice only Vusb and GND are connect. So, how upload sketch to this fellow?

Basically, will be necessary ST-Link V2 connected to P3 4 pin header.

It is quite strait forward:

ST-Link V2 ---------------------------------------------STM8S modules P3

SWIM (5)------------------------------------------------P3 SWIM (2)

GND (3)--------------------------------------------------P3 GND (3)

RST (1)---------------------------------------------------P3 NRST (4)

I do not recommend power module via ST-Link. May work or may not, depend on Chinese manufacture you acquire it from.

Breakout Board has power LED indicator and LED for test purpose, connected to PB5, which correspond to Arduino D3 pin.

Pinout picture show AD inputs are shared to some of GPIO and perhaps has a special access code (like SRTM32 Blue pill).

Something is very important: Lib is plain C NOT C++ like regular Arduino libs. It will impact how write some instructions in sketch, but I will deal with it in future....

Problems Loading Sketch

Blink_Example.jpg
ST-Link error.jpg
firmware.jpg
ST_visual_Programer.jpg
OptionByte.jpg

All sites described load first sketch as strait process, just select "Blink" example under File > Examples > Exemples for STM8S103F3... Generic_Examples > Basics > Blink and press and press "Upload" button....

Guess what? Did not work.

Arduino IDE raise "missing 'program.params.quiet' configuration parameter" error while upload.

I could not get any specific information about it, but I was pretty sure it was not tiny board problem, once it was originally "blinking" test LED in 1/2 Sec frequency, and after it I check cabling connection to be sure it was right, I start test ST-Link.

  1. Cross my mind use ST-Link Utility test ST-Link, but it returns a target (the board) connection error, so it was not conclusive.
  2. Then I remember ST-Link Menu > Firmware Update get connection only to ST-Link an can tell me ST-Link connection to computer was ok. So click in "Device Connect" will bring firmware version and device type. Close everything and go to next item.
    If nothing pops up, you may have a bad ST-Link.

I double check cabling connection and now I am sure now it is something related to STM8S breakout board, but what? So, I found an article in internet, describing a similar problem and recommended use "ST Visual Programmer" to check STM8S memory and status.

  1. Running it, be sure to configure "Hardware" as ST-LINK, "Port" as USB, "Programming Mode" as SWIM and "Device" as STM8S103F3. This guy is able to reading what ever is inside STM8S memory and more important the option byte. In my case, any time I try read or write garbage to STM8S I get a access protection message....
  2. So, looking in "Option Byte" table I found "Read Out Protection was ON", so I change it to OFF, click in "Program Current Tab" and all good now.

NOTE: Looks Option Byte is same thing as fuses in ATM328, so take care change other itens..

Conclusion

There is not much article out there about this board, so I hot it help one are starting working with it. This is just first step.

I hope issue more articles covering other experiences with this module.