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 KPrepublic BM16A v2 #19194

Merged
merged 5 commits into from
Dec 9, 2022
Merged

Add KPrepublic BM16A v2 #19194

merged 5 commits into from
Dec 9, 2022

Conversation

fauxpark
Copy link
Member

Description

New version of BM16A with an F103 clone and RGB matrix. Comes with VIAL preinstalled.

Maybe should split up kprepublic/bm16a instead?

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).

@fauxpark fauxpark requested a review from a team November 29, 2022 12:04
Enter the bootloader in 3 ways:

* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does just pressing RESET actually work if the firmware is corrupted? It may seem to work when some version of QMK is running because of this code in boardInit(); but the unmodified stm32duino code does not set up the BKP->DR10 register to enter the bootloader on a single or double reset.

Apparently the PCB has two pairs of pads that can be shorted that control the BOOT0 and BOOT1 (PB2) inputs (as far as I was able to infer from looking at the PCB photos in the shop — the bottom side photo has lower quality):
image
BOOT0 is mostly useless on F103, but BOOT1 may be used as the “force bootloader” input (generic_boot20_pc13_fastboot.bin behaves like that). But that should be tested on a real PCB.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this board is using fastboot as it doesn't immediately appear as Maple 003 when plugged in like my Bluepill does.

I've got no clue on the other stuff.

"cols": ["B1", "A3", "B0", "B4"],
"rows": ["A8", "A9", "B5", "B3"]
},
"processor": "STM32F103", // GD32F303CCT6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this configuration limits the usable flash size for the firmware to 56K due to the default MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader; although I'm not sure that KPrepublic won't “optimize” the hardware in some further revision to use a smaller chip.

Also did you check that the EEPROM emulation behaves properly with this configuration? F103x8/xB chips have 1K flash sectors, but F103xC and larger chips have 2K flash sectors. Apparently the default EEPROM driver for STM32F1xx is now wear_leveling/embedded_flash, and the EFL code in lib/chibios/os/hal/ports/STM32/STM32F1xx/hal_efl_lld.c does not perform any autodetection for the flash page size, therefore it probably does not work correctly when the real chip does not match the compile-time configuration. (This problem does not affect the stm32duino bootloader, because it reads the flash size register and detects the flash sector size from that info, so it should work with all F103 chips with single bank flash.)

Adding board.h with

#pragma once
#include_next <board.h>
#undef STM32F103xB
#define STM32F103xE

may be enough to fix the problem (assuming that KPrepublic would stick to using the GD32F303CCT6 chips on this board and won't downgrade to GD32F103CBT6 or something like that).

(Specifying STM32F103xE should be safe, because the code in platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c support flash size detection for STM32F1xx to determine the backing store location; but that code relies on the ChibiOS EFL driver to get the flash sector size, and that part can be configured only during compile time on STM32F1xx.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EEPROM does seem to work; the RGB Matrix settings persist and it boots up with the correct effect and HSV after changing it.

keyboards/kprepublic/bm16v2/config.h Outdated Show resolved Hide resolved
@drashna drashna requested a review from a team December 4, 2022 02:56
@github-actions github-actions bot added the via Adds via keymap and/or updates keyboard for via support label Dec 9, 2022
@fauxpark fauxpark changed the base branch from master to develop December 9, 2022 02:00
@fauxpark fauxpark merged commit 8c12559 into qmk:develop Dec 9, 2022
@fauxpark fauxpark deleted the bm16v2 branch December 9, 2022 04:31
omikronik pushed a commit to omikronik/qmk_firmware that referenced this pull request Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keyboard keymap via Adds via keymap and/or updates keyboard for via support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants