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

Bring supported STM32F4 configs in line with F4x1 #24413

Merged
merged 9 commits into from
Nov 21, 2024

Conversation

drashna
Copy link
Member

@drashna drashna commented Sep 20, 2024

Description

The F405, F407, and F446 models use the same weird flash page layout as the F4x1 chips (multiple 16k pages at the beginning). This aligns with the other F4 controllers' following suit.

Verified in the reference manuals for the F405/F407 and F446 that these layouts are correct.

Have tested on the F405RG1, F407VE F44612 and G474CE

Types of Changes

  • Core
  • [?] Bugfix
  • Enhancement/optimization

Issues Fixed or Closed by This PR

I created an 870kb firmware for the F405RG (1MB) that soft-bricked. Talking with tzarc, that does run into the currently configured wear leveling area. F4's use a weird layout, which we should take advantage of.

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

Footnotes

  1. long delay for USB enumeration after initial flash 2

  2. F446 officially has no EFL support in chibiOS. A quick hack to enable the same specs as f411 works. Similar with F407xE

@drashna drashna requested a review from a team September 20, 2024 04:25
@github-actions github-actions bot added the core label Sep 20, 2024
@tzarc tzarc requested a review from a team September 20, 2024 04:53
Copy link
Contributor

@sigprof sigprof left a comment

Choose a reason for hiding this comment

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

In general this should be good, but the required LD files are present only for the STM32F405xG case; for other chips we currently don't reserve the second 16K flash sector for the EEPROM backing store, and don't have a proper LD file for the tinyuf2 bootloader.

@drashna drashna changed the title Move wear leveling location to beginning of flash on STM32F4s Bring supported STM32F4 configs in line with F4x1 Sep 20, 2024
@drashna
Copy link
Member Author

drashna commented Sep 20, 2024

gonna have to read up more on the memory usage and locations.

@drashna
Copy link
Member Author

drashna commented Sep 29, 2024

Tested with weact g474ce board. However, the weact f446 has a different config (?) that I'm not sure how to configure for.

@sigprof
Copy link
Contributor

sigprof commented Sep 29, 2024

The major problem with F446 is that there is no EFL support for that chip in ChibiOS.

@sigprof
Copy link
Contributor

sigprof commented Sep 29, 2024

As for the config for the WeAct F446 board, the only change from handwired/onekey/nucleo_f446re is that you need to remove #define STM32_HSE_BYPASS from board.h (Nucleo supplies an external 8 MHz clock signal, for the WeAct board you need to set up HSE with a 8 MHz crystal). The GENERIC_STM32_F446XE board is set up for a 16 MHz HSE crystal, and already defines BOARD_OTG_NOVBUSSENS to make USB work without the VBUS detection circuit on PA9.

@drashna
Copy link
Member Author

drashna commented Sep 29, 2024

Thanks. I figured that it was something simple that I was missing....

And can confirm that these changes work on f446, as well, now.

@drashna drashna requested review from a team and sigprof October 3, 2024 11:08
Copy link
Contributor

@sigprof sigprof left a comment

Choose a reason for hiding this comment

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

This code by itself looks correct, and seems to work. The remaining issues are mostly at the ChibiOS level, so outside of the scope of this PR:

  • EFL support for STM32F446 is not implemented in ChibiOS at all.
  • EFL support for STM32F405/F407 is incomplete (512K chips are supported only in the master branch at the moment, so the firmware will halt on EFL init).
  • During the first startup after flashing the firmware QMK erases the backing store, and the delay caused by that erase triggers some bugs in the USB OTG controller. On F405 (and probably F407) that results in a long delay before the USB enumeration finally goes through; on F446 (and maybe even F405/F407 if using USB HS instead of FS) the USB controller does not seem to recover from that state without a full hardware reset.

@tzarc tzarc merged commit c7a04bd into qmk:develop Nov 21, 2024
4 checks passed
@drashna drashna deleted the wear_leveling_f4 branch November 21, 2024 13:20
ilham-agustiawan pushed a commit to ilham-agustiawan/qmk_firmware that referenced this pull request Nov 30, 2024
smallketchup82 pushed a commit to smallketchup82/qmk_firmware that referenced this pull request Dec 1, 2024
jlaptavi pushed a commit to jlaptavi/qmk_firmware that referenced this pull request Dec 3, 2024
DmNosachev pushed a commit to DmNosachev/qmk_firmware that referenced this pull request Dec 7, 2024
SyrupSplashin pushed a commit to SyrupSplashin/qmk_firmware that referenced this pull request Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants