Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimal STM32F103C6 support #17853

Merged
merged 1 commit into from
Aug 11, 2022
Merged

Conversation

sigprof
Copy link
Contributor

@sigprof sigprof commented Jul 30, 2022

Description

Unfortunately, the crippled versions of “Bluepill” boards with STM32F103C6xx chips instead of STM32F103C8xx are now sold all over the place, sometimes advertised in a confusing way to make the difference not noticeable until too late. Add minimal support for these MCUs in the common “Bluepill with stm32duino” configuration, so that it could be possible to make something useful from those boards (although fitting QMK into the available 24 KiB of flash may be rather hard).

(In fact, I'm not sure whether the “STM32” part of the chip name is actually correct for those boards of uncertain origin, so the onekey board name is bluepill_f103c6; another reason for that name is to match the existing blackpill_f401 and blackpill_f411.)

The EEPROM emulation support is not included on purpose, because enabling it without having a working firmware size check would be irresponsible with such flash size (the chance that someone would build a firmware where the EEPROM backing store ends up overlapping some firmware code is really high). Other than that, enabling the EEPROM emulation code is mostly trivial (the wear_leveling driver with the embedded_flash backing store even works without any custom configuration, although its code is significantly larger than the vendor driver, which may also be important for such flash size).

Tested onekey keymaps:

  • default
  • adc (needs changes in halconf.h and mcuconf.h to enable ADC)
  • backlight
  • console
  • digitizer (seems to send some events visible in sudo evtest)
  • eep_rst (with EEPROM_DRIVER=transient this just restarts the firmware)
  • hardware_id
  • oled (needs changes in halconf.h and mcuconf.h to enable I2C)
  • quine
  • reboot (works appropriately with stm32duino — the bootloader does not appear during the reboot)
  • reset (works appropriately with stm32duino — the bootloader starts with the 8s timeout disabled)
  • rgb
  • rgb_matrix (needs -e RGB_MATRIX_DRIVER=WS2812 -e CONSOLE_ENABLE=no)

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Unfortunately, the crippled versions of “Bluepill” boards with
STM32F103C6xx chips instead of STM32F103C8xx are now sold all over the
place, sometimes advertised in a confusing way to make the difference
not noticeable until too late.  Add minimal support for these MCUs in
the common “Bluepill with stm32duino” configuration, so that it could be
possible to make something useful from those boards (although fitting
QMK into the available 24 KiB of flash may be rather hard).

(In fact, I'm not sure whether the “STM32” part of the chip name is
actually correct for those boards of uncertain origin, so the onekey
board name is `bluepill_f103c6`; another reason for that name is to
match the existing `blackpill_f401` and `blackpill_f411`.)

The EEPROM emulation support is not included on purpose, because
enabling it without having a working firmware size check would be
irresponsible with such flash size (the chance that someone would build
a firmware where the EEPROM backing store ends up overlapping some
firmware code is really high).  Other than that, enabling the EEPROM
emulation code is mostly trivial (the `wear_leveling` driver with the
`embedded_flash` backing store even works without any custom
configuration, although its code is significantly larger than the
`vendor` driver, which may also be important for such flash size).
@zvecr zvecr merged commit 9e44362 into qmk:develop Aug 11, 2022
@myst729
Copy link
Contributor

myst729 commented Oct 22, 2022

@sigprof This works as expected. But since there's no EEPRom emulation, it doesn't support VIA either. Is there a way to turn this on? I have an ST-Link on hand so I could give it a try without worrying about bricking.

@sigprof
Copy link
Contributor Author

sigprof commented Oct 22, 2022

You can enable EEPROM in rules.mk:

EEPROM_DRIVER = vendor

and add this configuration to config.h:

#define FEE_MCU_FLASH_SIZE 32
#define FEE_PAGE_COUNT 2
#define FEE_PAGE_SIZE 1024

(Although that vendor driver is now considered to be legacy code, you would probably still want to use it on this hardware instead of EEPROM_DRIVER = wear_leveling, because the older driver is also smaller.)

The major issue is that you effectively decrease the available flash size by 2K, but the build system does not know about that, so you would be able to build a firmware that extends into the EEPROM data area without noticing that.

@myst729
Copy link
Contributor

myst729 commented Oct 23, 2022

@sigprof It works! Though I have to carefully calculate how many bytes each feature takes, and turn off some heavy ones, e.g. RGB matrix. VIA support is the heaviest among them.

@t812206236
Copy link

Where is the use of FEE_PAGE_COUNT and FEE_PAGE_SIZE mentioned? I am confused, is it the default that everyone who adjusts eeprom needs to understand the knowledge in chibios?

@tzarc
Copy link
Member

tzarc commented Dec 3, 2022

It's not mentioned, it's usually best left alone as it can have unintended consequences. Here be dragons.

@myst729
Copy link
Contributor

myst729 commented Jan 22, 2023

Where is the use of FEE_PAGE_COUNT and FEE_PAGE_SIZE mentioned? I am confused, is it the default that everyone who adjusts eeprom needs to understand the knowledge in chibios?

C6T6 is very limited, you can't do much with only 24K flash. C8 and above would be better.

nolanseaton pushed a commit to nolanseaton/qmk_firmware that referenced this pull request Jan 23, 2023
Unfortunately, the crippled versions of “Bluepill” boards with
STM32F103C6xx chips instead of STM32F103C8xx are now sold all over the
place, sometimes advertised in a confusing way to make the difference
not noticeable until too late.  Add minimal support for these MCUs in
the common “Bluepill with stm32duino” configuration, so that it could be
possible to make something useful from those boards (although fitting
QMK into the available 24 KiB of flash may be rather hard).

(In fact, I'm not sure whether the “STM32” part of the chip name is
actually correct for those boards of uncertain origin, so the onekey
board name is `bluepill_f103c6`; another reason for that name is to
match the existing `blackpill_f401` and `blackpill_f411`.)

The EEPROM emulation support is not included on purpose, because
enabling it without having a working firmware size check would be
irresponsible with such flash size (the chance that someone would build
a firmware where the EEPROM backing store ends up overlapping some
firmware code is really high).  Other than that, enabling the EEPROM
emulation code is mostly trivial (the `wear_leveling` driver with the
`embedded_flash` backing store even works without any custom
configuration, although its code is significantly larger than the
`vendor` driver, which may also be important for such flash size).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants