Yet another question about the STM32 clones... - Page 1
Forum section: electronics / general

author: Camilo71515
author_rank: Newbie
timestamp: September 06, 2022, 03:11:43 am
content: Hi there!Me and a partner are developing a product and would like it to be based around the GD32F103C8T6, which seems to be a clone of the STM32F103C8T6. We chose this micro controller due to cost, availability and peripherals.Most of our product is based around the blue pill modules that are found very cheap on AliExpress, and the GD32F103C8T6.We'd like to know what are your opinion and experiences with this micro's vs the originals from ST.Is it possible to use them with the CubeIDE and the ST-Link?Do the debug functions of the ST-Link will work with this "clones"?Thanks in advance to y'all!!

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 03:56:13 am
content: Using Cube would violate the licence you accept before the download:QuoteST-Link itself should work, but the IDEs designed for STM32 may not work correctly with GD32 devices.Treat this as a different device that is similar, but no the same.

author: peter-h
author_rank: Super Contributor
timestamp: September 06, 2022, 06:17:34 am
content: This is a potentially interesting thread because my 32F417 project is nearly done and none of the hardware crypto features were used (most are obsolete, and aes256 runs fast enough in software for this job) so I could use a 32F407 which exists in some chinese clones.I would expect the peripherals to have subtle differences.

author: rooppoorali
author_rank: Regular Contributor
timestamp: September 06, 2022, 12:25:21 pm
content: Here is an article about the differences between these two. You may find it helpful:https://www.hackster.io/techmirtz/alternative-to-stm32f103c8t6-by-gigadevice-43e7b2

author: peter-h
author_rank: Super Contributor
timestamp: September 06, 2022, 01:31:00 pm
content: That's unfortunately a very superficial comparison.If you make loop based delays use the system clock value, it should still work the same way. But I would say almost nobody will use a chinese CPU for a faster clock option. For a lower price, or for availability, definitely!A much better way to make delays is to use CCYCNT.I wonder if anyone has reported on things like timers, DMA controllers, etc. In fact are the DMAs a part of the ARM core and not "peripherals" like e.g. SPI are? The peripherals run from the APB clocks and run slowly, so accessing them takes up a lot of clock cycles, whereas AFAIK that is not true for the DMAs.QuoteWhat would be the reason for that? The IDE, AFAICT, is mostly to do with tool (compiler etc + debugger) integration.

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 03:47:43 pm
content: Quote from: peter-h on September 06, 2022, 01:31:00 pmNo, it is not.Quote from: peter-h on September 06, 2022, 01:31:00 pmMostly device ID registers. If clones match them exactly, then it will probably work. But there are also differences in timings, differences in the ARM core revisions. But I doubt IDEs would check that unless they explicitly want to detect the fakes.But keep in mind that the more complex the device is, the more clones deviate from the original. There are a lot of small differences, but it may be annoying, especially if you want to make a firmware that works on both.

author: peter-h
author_rank: Super Contributor
timestamp: September 06, 2022, 04:51:44 pm
content: So the DMAs are slow to access too? That's interesting. No wonder memcpy is used a lot instead of DMA, in ETH codeRe Cube IDE getting confused when configured for one chip but finding another chip, I posted thishttps://www.eevblog.com/forum/microcontrollers/is-st-cube-ide-a-piece-of-buggy-crap/msg4316272/#msg4316272It does work ok but it does funny stuff with displaying the "unexpected" memory, which is probably to be expected.OTOH, nothing stops one developing code with a real ST chip and then programming the code into a chinese fake; if you got it right, it will run and the IDE won't be relevant.

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 05:02:52 pm
content: Quote from: peter-h on September 06, 2022, 04:51:44 pmTo access in what way? DMA controller registers are on the APB bus. The DMA data interfaces are on the AHB bus The bus system is pretty complicated and it is hard to predict what would be slow or fast. There are a lot of factors that go into it.But DMA transfer would be faster regardless. It is just for simple things it makes no sense to complicate the code and software memcpy() works just fine. Not everything needs to be optimized to death.

author: wek
author_rank: Frequent Contributor
timestamp: September 06, 2022, 06:38:52 pm
content: Quote from: ataradov on September 06, 2022, 05:02:52 pmIn which STM32?JW

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 06:44:29 pm
content: Quote from: wek on September 06, 2022, 06:38:52 pmIn all of them. This is a common way to design DMA controllers.

author: wek
author_rank: Frequent Contributor
timestamp: September 06, 2022, 06:52:31 pm
content: Quote from: ataradov on September 06, 2022, 06:44:29 pmProbably in none of them.Both the single-port and dual-port DMA registers are accessed through a slave AHB port.I don't know the MDMA in 'H7 nor the new DMA modules in 'U5, and I don't know the 'Wx at all, and I may have overlooked some.JW

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 06:59:13 pm
content: My bad, they indeed put the control register on the AHB bus. This seems strange to me.I looked at a few other vendors and it looks like placing DMA registers on the APB bus is not as common as I thought.

author: wek
author_rank: Frequent Contributor
timestamp: September 06, 2022, 07:06:52 pm
content: Quote from: ataradov on September 06, 2022, 06:59:13 pmWhy?All "fast" peripherals in STM32 (ETH, USB, DMA, GPIO except in the ancient 'F1 and CM0+-based, LCD, crypto, CRC - heck even the FLASH control interface :-) ) are setup/controlled through slave AHB bus.Other manufacturers may have different approach. I am very un-knowledgeable of other 32-bitters. APB is there to offload load from long buses at the cost of speed (latency).JW

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 07:24:41 pm
content: Quote from: wek on September 06, 2022, 07:06:52 pmThere is no reason for DMA configuration to be fast. You don't really access it much after the initial setup. And adding more peripherals on the fast bus can't be good for the bus performance. But it looks like they manage to get the necessary performance, so it is fine.But it also appears that they wrap both master and slave into a single interface, so it does not need additional real ports on the bus matrix. I need to look into how exactly they are doing that.

author: dietert1
author_rank: Super Contributor
timestamp: September 06, 2022, 07:35:05 pm
content: Recently i happened to get a bluepill with a cloned or bad STM32F103. It responds a CM4 signature, while CM3 was expected. I found a way to debug it, pretending it is a GD32E103 (CM4 core expected). But i put it aside after verifying it isn't a GD32E103. Some peripheral registers did not respond where expected.I think clones are difficult for business. The meaning of clone in this context is betrayal, so you may always get a clone of a clone or a different revision - different enough to make your product fail. As far as i know this even happened with original STM32 products, when they changed the MCU ID code in later revisions.One would need a tool to verify all functions mentioned in the reference manual. Like automatic detection of memory ranges and peripheral registers (producing lots of hard faults). Then, in order to check it, one would need an interpreter to extract the info from a reference manual.Regards, Dieter

author: wek
author_rank: Frequent Contributor
timestamp: September 06, 2022, 07:36:48 pm
content: Quote from: ataradov on September 06, 2022, 07:24:41 pmWell, not quite, it depends.Can you please give me a "reference/typical" ATSAM number (you're Atmel guy, right?) so that we understand each other in what's reasonable and what not?Thanks,JW

author: wek
author_rank: Frequent Contributor
timestamp: September 06, 2022, 07:42:56 pm
content: Quote from: dietert1 on September 06, 2022, 07:35:05 pmWell, an outright counterfeit (i.e. if the chip is marked STM32 and inside is a clone) is IMO not worth consideration at all.IMO most of the cloners made considerable effort to make sure that typical STM32 programs - i.e. those clicked in CubeMX for a bluepill - will mostly work out of the box. It's only those cases where timing, pins' leakage/drive, etc. matters, where things are more likely to go astray.JW

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 07:45:22 pm
content: Quote from: wek on September 06, 2022, 07:36:48 pmRepresentative Cortex-M0+ is SAM D21. Representative Cortex-M7 is SAM V71. Both have DMA configuration in the APB space.I looked at a bunch of devices for which I had documentation handy. The only devices I could find with registers on the APB are MAX32660 and i.MX series. i.MX have proprietary bus (AIPS), which seems to be similar to APB in function.ARM PL330 IP also uses APB for configuration, but I don't even know if anyone uses this in practice.

author: wek
author_rank: Frequent Contributor
timestamp: September 06, 2022, 08:05:11 pm
content: > SAM D21/ SAM V71Thanks. I'll have a look. It is probably not surprising that SAM D21 came up as first with the simplest possible google request (ATSAM)...> I looked at a bunch of devicesInteresting. Does this mean that most DMA (or DMA-capable-peripherals') registers appear to quite regularly be connected through AHB rather than APB?I had a look at Nuvoton's NUC505 (although it's an outlier in Nuvoton's offering). It does not appear to have a general-purpose DMA, but quite a couple of peripherals embed its own DMA (USB Host, USB Device, SPI (they call it SPIM), SD controller, I2S), i.e. they are AHB masters (and there's also a somewhat intriguing arbitration scheme for them), and almost all of them have also registers connected as AHB slaves, except I2S, which is on APB (yes, that's the one which is typically configured only once or seldom).JW

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 08:17:24 pm
content: Quote from: wek on September 06, 2022, 08:05:11 pmI also looked at GD/WCH devices, but those are clones of the STM, so they are designed the same as STM32.Nuvoton M480 series uses AHB interface. Interestingly on the drawing it shows one AHB interface and "Master / Slave Wrapper" attached to it. So, I guess they manage to change the role on the fly.Also, on a second thought, all those AHB peripherals are obviously not direct slaves on the main matrix. They all are represented by one AHB slave interface on the main matrix. So, it is not all that different from the APB. So, I guess I was overthinking the potential overhead.It looks like EFM32 devices use direct AHB too.I have not looked at anything else.

author: dietert1
author_rank: Super Contributor
timestamp: September 06, 2022, 08:51:43 pm
content: Quote from: wek on September 06, 2022, 07:42:56 pmIn my case the chip is marked to be a STM32F103C8T6. But it reports 128K flash with 64K expected and the wrong core id. So it's not a glitch of an original chip, but a clone. So i would need to characterize that chip in all detail, which is a major effort. It won't happen.Regards, Dieter

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 09:02:16 pm
content: That's just a fake, I would not consider using that at all. "Cloned" devices released under their own name with their own datasheet are fine.

author: peter-h
author_rank: Super Contributor
timestamp: September 06, 2022, 09:16:55 pm
content: It would be good to see photos.I have posted some in the past, here.Most chinese fakers are not particularly clever; much of china now runs as a gangster economy, full of opportunists, and looking for whichever devices are in demand, and they quickly set up a production line, often making empty packages (I've had H8 CPUs like that).

author: up8051
author_rank: Frequent Contributor
timestamp: September 06, 2022, 09:21:13 pm
content: Quote from: dietert1 on September 06, 2022, 07:35:05 pmProbably Artery AT32F403

author: wek
author_rank: Frequent Contributor
timestamp: September 06, 2022, 09:21:31 pm
content: > Nuvoton M480 series ... EFM32 devices...Thanks for doing this research. It would be interesting to talk to the designers about these design choices.I looked at the "smallest CM4F", that MAX32660 you've mentioned above. Similarly to the SAM-D21, all peripherals are behind an AHB-APB bridge, but here's only a single bridge and the only other AHB slave on the S-port of processor is the SRAM. Here it may something to do with being the "smallest" perhaps, brutally simplifying any address decoding.Sorry all for hijacking this thread.JW

author: ataradov
author_rank: Super Contributor
timestamp: September 06, 2022, 09:34:42 pm
content: Quote from: wek on September 06, 2022, 09:21:31 pmThat device is really weird. It probably does not have mass appeal, but I assume there are applications where it fits precisely. I've used it as a test debug target because it is indeed very small and reasonably cheap. But I see no actual uses for it.Quote from: wek on September 06, 2022, 09:21:31 pmThere is distinction between the way main matrix is designed on the D21 vs STM32. D21 has all 3 AHB-APB bridges as individual slaves, so in theory CPU can access PORT registers while DMA does SPI transfer, since they are on two different bridges. On STM32 DMA access would preempt any other APB access. But then there split transfers and other complex stuff like this, so how much this matters in practice is hard to tell. My guess would be - not at all, except in some pathological cases.

author: wek
author_rank: Frequent Contributor
timestamp: September 06, 2022, 09:57:21 pm
content: QuoteNo Maxim IC has mass appeal. Well, maybe except MAX232... :-) It's most likely a custom product offered to public.QuoteReplace "pathological" for "extreme/exceptional" and I fully agree. :-)Jan

author: thm_w
author_rank: Super Contributor
timestamp: September 06, 2022, 11:56:05 pm
content: We were just discussing this, you'll want to put some effort in and read a bit for yourself:https://www.eevblog.com/forum/microcontrollers/which-of-the-many-stm32f103-clones-are-actually-usable/https://www.eevblog.com/forum/microcontrollers/stm32f103-the-security-of-drop-in-replacement-and-counterfeit-microcontrollers/https://www.richis-lab.de/STM32.htmhttps://www.eevblog.com/forum/other-blog-specific/*32f103-comparison/msg2830314/#msg2830314

author: dietert1
author_rank: Super Contributor
timestamp: September 07, 2022, 05:15:57 am
content: Quote from: up8051 on September 06, 2022, 09:21:13 pmBut those have 256K flash or more. My clone doesn't have the FPU either.The two images show clone and original for comparison, assuming ST don't use clones for the STLink.Third image is an "honest" clone in a STLink USB stick.Regards, Dieter

author: peter-h
author_rank: Super Contributor
timestamp: September 07, 2022, 06:20:31 am
content: The 1st image has bad marking.The 2nd image looks like ST marking I see on the 32F4.And why the extra "F"?If I had even half a brain I would make the fakelookright.

author: ataradov
author_rank: Super Contributor
timestamp: September 07, 2022, 06:34:27 am
content: Quote from: peter-h on September 07, 2022, 06:20:31 amI've seen quite a few fakes and they all seem to not have access to a decent laser or they don't know how to setup it correctly. Even if they change the font (9 is especially non-ST-like), and figured out where the "F" in the name goes, there width of the line would be too wide and too wobbly. Or may be it has something to do with the type of plastic.Fakes also seem to use raster scan for bold elements and most real ICs use vector mode. You can see it in the ST logo. Legit devices draw the outline and then fill it as a CNC mill would. This probably also contributes to the visuals. Thin lines are essentially made out of dots, which makes them look thicker.

author: peter-h
author_rank: Super Contributor
timestamp: September 07, 2022, 06:38:24 am
content: Firms should have a contact which can be used to verify fakes.I have just got 3k x 28C256 TSOP-28, Atmel (now Microchip), from a US based "opportunist excess stock dealer" but can't find a contact. The chips do work (tested functionally and over temperature) and the marking looks exactly right, but one can never be 100% sure.And these dealers are vulnerable; I got a few k fake H8/300s a few years ago - fortunately the package didn't quite fit the programmer

author: ataradov
author_rank: Super Contributor
timestamp: September 07, 2022, 06:44:24 am
content: Quote from: peter-h on September 07, 2022, 06:38:24 amI do that for Microchip ARM MCUs. But you would need to get though the support ticket. Requests to verify happen from time to time.But most of the time all we can do is check that the lot code is in the database and belongs to the claimed device. But if you are creating a fake, you can just use the data from a real device. But I've seen faker even fail to do that. This is inexcusable.And I do compare visual quality with the reference devices, of course.For MCUs specifically, having Unique ID values from the device also helps, as they encode potentially useful information, which may not be copied correctly by the fake. It would be actually interesting to see what UID values are programmed into the fakes.

author: dietert1
author_rank: Super Contributor
timestamp: September 07, 2022, 07:17:03 am
content: Meanwhile i found that in other places this fake is labeled CKS CS32F103C8T6 and the package label "991KA 93 MYS 807" has been confirmed by STM to be fake. The chip is said to report 128K flash and the unexpected CM4 core id. And one finds reports about problems with DMA controller and USB connection of that chip. There is chinese datasheet, yet no reference manual.Regards, Dieter

author: peter-h
author_rank: Super Contributor
timestamp: September 07, 2022, 07:52:37 am
content: I am expecting more fakes now, because distis are imposing price increases,afterthe order was placed. The customer is supposedly contractually bound to pay the higher price -without limit. It is a disgusting development, done totally without regard for a future business relationship. I've had a barrister's opinion on a current case (where, notably, the Ts and Cs were not supplied until the order confirmation) and it is that we can't get the price back to the contracted price (short of suing them for a breach of contract, once the goods fail to arrive) but we can return the goods (which they shipped despite correspondence making it clear we do not accept the price increase). It is a very big order and I will probably just return the items.Another disti, for ST actually, had to climb down because they could not prove the price increase email was sent out. In fact an employee mistakenly emailed me saying it failed to go outAnd returning items for credit/refund to a disti isthefavoured way of injecting fake stock into the franchised disti pipeline, which most people would regard as secure.This totally unethical behaviour by Western companies is going to drive business to chinese clones. China never claimed any ethics, indeed doesn't have any, and everybody knows and accepts that, as the cost of getting a lower price

author: hans
author_rank: Super Contributor
timestamp: September 07, 2022, 08:01:11 am
content: Quote from: ataradov on September 06, 2022, 09:02:16 pmIn theory yes. Even though it's ethetically-questionable that GD copies all part numbers, peripherals and documentation of ST, they're building their own brand. Clones do not build their own brand. Only e-wasteI do wonder if some clones will, at some point in future as I've no indication it happens right now, will re-badge themselves as GD devices? Or maybe there is too little margin to be had on an already copied design. Or can chinese companies murder each other for copyright infringement?I mean, how reliably are you going to source these parts. These are plenty of enough reasons for me to source as much as possible from western big name companies. I rarely even order PCBs from Asia anymore because there are plenty of local alternatives that are slightly more expensive, but at least keeps someone in my home country/EU in a job. (But I digress, that's a different topic)