Closed pcsquirrel closed 2 years ago
This one is pretty tough. These chips actually masquerade as a STM parts. Even the stlink software doesn't attempt to deal with these correctly, they reverted a patch which would have added support for them. Not really sure what QMK could do about this? If you're using a fake part you sort of have to do the overrides in your keymap directory, which we do allow you to do.
One potential approach would be to add a a specific MCU that specifies CS32F103, instead of pretending these are STM32.
After struggling with qmk on this devices i googled a lot and couldn´t find anything helpful. So I dug into the problem and found a solution I would have been glad if some else had figured it out and shared this information. So this bug-report is mainly to be found by others struggling with the same issue. As the patch is working for me I could provide this patch as a pull request. I would introduce an additional MCU:
I personally would prefer using the CS32F103
, especially as I have two of these knockoff BluePills on my desk right now (though interestingly, the chips are branded "CKS").
As for the chip name, the stlink
package uses CKS32F103
instead of CS32F103
for those chips — see the compatible devices list and changelog.
Even the stlink software doesn't attempt to deal with these correctly, they reverted a patch which would have added support for them.
Since that time the patch was fixed and applied again (the problem with the original patch was that it attempted to use the core ID to detect CKS chips, but the core ID in them turned out to collide with the core ID of a completely different real STM chip, therefore the initial patch adding CKS support broke the support for those STM chips and got reverted).
It turned out that I have the CKS32F103C8T6
chip inside my ST-LINK V2 programmer from AliExpress (bought together with a BluePill board, which seems to have a real STM32F103C8T6), but I can't use it for testing without getting another ST-LINK programmer first.
This issue has been automatically closed because it has not had any recent activity. If this issue is still valid, re-open the issue and let us know.
Describe the Bug
Newer bluepill boards from ebay seem to have a counterfeit STM32F103 (aka CS32F103C8T6). Most times detected while trying to program them, which fails by mismatching chipid. (STMF103 id: 0x1ba01477 / CS32F103 id: 0x2ba01477)
As per specification the STM device has 64kb Flash, but community has proved that al of them have 128kb in reality. The counterfeit CS32F103 devices have "only" the announced 64kb.
In "tmk_core/common/chibios/eeprom_stm32.h" a flash size of 128kb is assumed (for MCU_STM32F103RB and derivates) which leads to unexpected results when emulated eeprom is read. This happens while USB enumeration which leads to failing USB enumeration.
After changing flash size (FEE_MCU_FLASH_SIZE) to 64 qmk firmware is working flawlessly on CS32F103 cpus.
System Information