What's the difference between STM8S003F3P and STM8S103F3P6?

A project log for eForth for cheap STM8S gadgets

Turn cheap modules from AliExpress into interactive development kits!

ThomasThomas 01/06/2017 at 20:2814 Comments

Today I worked a little on a more complete hardware register map. I copied the map data from the STM8S003 datasheet and converted it into a new file with a simple AWK script. Make failed because "PC_IDR" was rendered as "PB_IDR". Great, a human touch! After correcting the typo I got the same results as with my original register map file (that doesn't mean that all the map addresses I didn't use before are correct ;-)).

In my little project I always had difficulties telling the "Value Line" STM8S003F3P6 and the "Access Line" STM8S103F3P6 apart. According to the front page of the datasheets the differences are :

STM8S003F3P6 STM8S103F3P6
Flash 8 Kbyte Flash memory; data retention 20 years at 55 °C after 100 cycles
8 Kbyte Flash; data retention 20 years at 55 °C after 10 kcycle
EEPROM 128 bytes true data EEPROM; endurance up to 100 k write/erase cycles
640 byte true data EEPROM; endurance 300 kcycle
Unique ID - 96-bit unique key for each device

Shouldn't I have a different include file for the STM8S103F3P6 for the sake of consistency?

Besides the wildly different specs for Flash, the different size of the EEPROM, and the guaranteed write cycles (what does "up to" mean in a datasheet?) there is that one "unique selling point" for an "Access Line" device: the "Unique ID".

What's the "Unique ID" anyway? Using the Forth console on a STM8S103F3P6 I made a dump of the "Unique ID" address range :

$4865 $F dump
4865   0  7  0 3A  2 47 36 30 32 35 36 35 1F  0  0 1F  ___:_G602565__ ok

According to the datasheet the numbers mean "xWafer=1792, yWafer=14600, wafer#=2, lot#=higherthanthereareatomsintheuniverse". Quite obviously the datasheet is wrong: ID = [ 7, 58, 2, "G602565" ] is more like it.

Wafer number, lot number, position: all that sounds much more like the data the fab's QA is after. It would be a shame if such critical quality assurance data were not available for "Value Line" devices, wouldn't it?

Let's run the same test on a STM8S003F3P6:

$4865 $F dump
4865   0 1C  0 46  6 47 35 34 37 36 37 37 1F  0  0 1F  ___F_G547677____ ok

This looks familiar. Of course, it makes no sense to tailor QA process just for removing a feature that's not listed!

Now I got curious: what about the 640 vs. 128 bytes EEPROM?

hex ulock ok
4000 &640 + . 4280 ok
77EE 427E ! ok
427E ? 77EE ok

Guess what: the STM8S003F3P6 also has 640 bytes of EEPROM!

Be advised: there is no easy way to tell a STM8S003F3P6 and a STM8S103F3P6 apart, and there is a very high risk that you receive fake STM8S103F3 chips when you source from the gray market!

On the bright side, for hobby use you can put your trust in the outstanding quality record of ST, and simply ignore the intimidating reference to "100 cycles" in the Flash characterization. It's probably more like 10k, and then only if you have data retention requirements of "20 years@55 °C". Otherwise I'm, quite sure, the trusty device on the breadboard will tolerate 20k erase/write cycles (and if not, dump it).

Ah yes, and you can use the additional 512 bytes EEPROM, too. Other than the QA guarantees, the front page of the data sheet, and the missing description of the "Unique ID" the devices are the same. The STM8103F3 datasheet even has the same error as that of it's cheaper twin: the symbol PC_IDR is missing in the port mapping. too ;-)

EDIT: Paul found a STM8S003F3 chip with considerably less EEPROM memory than 640 bytes (but still more than 3x the size specified in the datasheet). So please be aware that you might "get what you paid" for & "YMMV".


Istiak Ahmed wrote 02/06/2019 at 21:33 point

So can we trust that 96 bits unique id ? Can the lot number be same for another stm8s003f3p6?

  Are you sure? yes | no

Thomas wrote 02/06/2019 at 21:49 point

After all that I understand the ID is guaranteed to be unique (based on the assumption that wafers are unique and they won't use any wafer number twice).

  Are you sure? yes | no

Istiak Ahmed wrote 02/06/2019 at 22:59 point

Did you get any fake stm8s003 ? Why are they so cheap in China and more expensive in mouser? Are they quality rejected?

  Are you sure? yes | no

Thomas wrote 02/07/2019 at 05:58 point

So far I have no reason to believe that I've ever seen a fake STM8S003F3P6. However, one can't be a sure that there aren't re-marked STM8 chips around (e.g. a chip with 4K Flash marked as 8K). It would make much more sense to buy STM8S103F2 and sell them as STM8S103F3 than as STM8S003F3.

Lower specs isn't about what chips can do but about what ST promises what the chips will do. STM8S003F3 is the lower specs version of the STM8S103F3 (just as the STM8S001J3 is a low-spec STM8S903F3). The chips are so much cheaper in China because some company buys e.g. 3 million chips, then uses 2.6 to make their products, and sells the rest to the spot market.

At one point I could buy STM8S903K3T6C for $0.26 a piece. They were cheap because people didn't immediately realize that they can be used as a STM8S103K3T6C replacement.

  Are you sure? yes | no

DJ Mystic wrote 10/24/2018 at 01:00 point


I've got some miniboards from an Aliexpress seller with the stm8s103F2p6 instead of the STM8S103F3P6. I got refunded for these because the F2 has a 4KB flash rom while the F3 has 8KB as we all know. Today, after i read this post about the 003, I wrote and ran my 7KB code succesfully into one of these F2 modules. I just treated the module as if it was an F3 instead. I used the ST Visual Programmer. No errors, verified the whole 8KB fine. And then when fitted into the socket of my appliance, it worked flawless. I think F2s are exactly F3s.

Now i'm thinking about the STM8S105S4T6 that i've been sent, if they are really STM8S105S6T6 and have 32kB instead of 16kB. 

  Are you sure? yes | no

Paul wrote 05/28/2017 at 20:15 point

Tested my stm8s003s3f3p6, and it only had 416Bytes of 'eeprom'.  Not the 640 advertised here, but still better than 128 advertised in the datasheet.  Perhaps some portion of my chip's eeprom failed in testing and a section was disabled in hardware and the die was downgraded from 103 to 003..?  I'll have to test some more chips and see what I find with those.

I was also able to read the chip's fuse ID just fine as well.

  Are you sure? yes | no

Thomas wrote 05/28/2017 at 20:42 point

I guess that STM8S003 chips are not tested to meet higher specs, or shown not to meet STM8S103 specs during testing. For anybody but the ST QA there is almost certainly no way to tell how much more besides what's described in the datasheet one will get. It's good if it works, and bad luck if it doesn't :-)
By the way, based on the assumption that the EEPROM is organized in units of 64 bytes 416 bytes is an odd number (it suggests that there are units of 32 bytes). How did you test it?

  Are you sure? yes | no

Paul wrote 05/28/2017 at 22:23 point

I simply used stm8flash tool to read/write from eeprom with a file.  Only the first 416 bytes of my 640 byte file were able to be written and read back.  Bytes 417-640 read back as zero.  The datasheet explains the memory as erase granularity is 4 bytes.  Having previously worked in memory industry, it seems reasonable they can disable portions of flash/eeprom as small as 32Bytes.

  Are you sure? yes | no

Thomas wrote 05/29/2017 at 05:37 point

You're right to call for careful statements. Getting more memory than the advertised 128 bytes is always "complementary", or a "free gift" for the hobby or development use case. Even selecting chips is out of the question for commercial use. It looks like a good idea to include a "memory survey" test in the STM8EF makefile.

  Are you sure? yes | no

jaromir.sukuba wrote 01/07/2017 at 16:39 point

The same goes for 64 vs 128kB variants of STM32F103. All the 64kB versions do actually hold 128kB worth of FLASH and I ran more than 64kB programs on it, with no problems at all. But manufacturer guarantees only first 64kB - this is the amount of FLASH that is actually tested.  Testing is expensive, by not testing some features they can sell it cheaper, what more, it increases manufacturing yield.

  Are you sure? yes | no

Thomas wrote 01/07/2017 at 18:05 point

This makes sense & good to know (STM32S103CBT6 boards cost much more than the 64K variant).

Depending on how stable a manufacturers process is they may also have some way to switch off a defective partition of some kind of memory (the same goes for EEPROM, complex timers etc). I reckon that for most testing and hobby usage taking advantage of such "free resources" is a good thing, but I'm concerned about cases where re-labeled cheap components (virtually indistinguishable from the real thing) appear on the gray market. If one is responsible for the reliability of a product such fake devices turn out to be very, very expensive.

  Are you sure? yes | no

Thomas wrote 01/07/2017 at 12:13 point

I checked the datatsheet of the Automotive STM8 variants STM8AF6213/23/23A/26: the STM8A6223 is rather similar to the STM8S103F3. The number of guaranteed Flash cycles is at 1k, there is a "LINUART" UART4 device instead of the UART1. The Timer2 is replaced with a Timer5 (which is about as capable as Timer1), and Timer4 is replaced with a Timer6 (which can be chained with other timers).

How different are the devices exactly? I played a bit with as the reserved registers of Timer2 and Timer4 to test the hypothesis that these are in fact Timer4 and Timer6. There are indications that this is the case, but I'll have to write proper test code. On the other side, the register set of UART2 isn't a subset of a LINUART. If it's the same UART someone must have spent some effort to hide it (the register address differs at one point).

  Are you sure? yes | no

Thomas wrote 01/06/2017 at 22:45 point

That goes in the same direction, thanks!

I guess that these guys use all the tricks in the books to please the automotive industry customers (with a cutthroat "business margin"/"quality requirements" ratio) *and* still make money. Most likely, the wafers that are used to calibrate the fab process for the automotive chips can still be dumped on the Chinese market. 

Some people with not-too-expensive ties must be thinking really hard what to write in  product line-ups, and some people must even sit down and doctor the tables in datasheets for devices with reduced specs (like you, I also compared the datasheets - most of the values in the tables and diagrams are identical, even if the arrangement was changed ;-) ).

  Are you sure? yes | no

K.C. Lee wrote 01/06/2017 at 21:56 point

I saw the same thing on my couple of batches of STM32F030.  They are actually 32K chips from STM32F050 line instead of 16K.

  Are you sure? yes | no