Merge remote-tracking branch 'qmk/master' into merge-2024-09-07

This commit is contained in:
Ilya Zhuravlev 2024-09-07 19:49:19 -06:00
commit a780dd1cb1
7600 changed files with 37202 additions and 168275 deletions

View file

@ -3,7 +3,7 @@
#include "hardware_id.h"
hardware_id_t get_hardware_id(void) {
__attribute__((weak)) hardware_id_t get_hardware_id(void) {
hardware_id_t id = {0};
return id;
}

View file

@ -10,7 +10,7 @@
#include <avr/boot.h>
#include "hardware_id.h"
hardware_id_t get_hardware_id(void) {
__attribute__((weak)) hardware_id_t get_hardware_id(void) {
hardware_id_t id = {0};
for (uint8_t i = 0; i < 10; i += 1) {
((uint8_t*)&id)[i] = boot_signature_byte_get(i + 0x0E);

View file

@ -0,0 +1,89 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* STM32F405xG memory setup.
* Note: Use of ram1 and ram2 is mutually exclusive with use of ram0.
*/
MEMORY
{
flash0 (rx) : org = 0x08000000 + 64k, len = 1M - 64k /* tinyuf2 bootloader requires app to be located at 64k offset for this MCU */
flash1 (rx) : org = 0x00000000, len = 0
flash2 (rx) : org = 0x00000000, len = 0
flash3 (rx) : org = 0x00000000, len = 0
flash4 (rx) : org = 0x00000000, len = 0
flash5 (rx) : org = 0x00000000, len = 0
flash6 (rx) : org = 0x00000000, len = 0
flash7 (rx) : org = 0x00000000, len = 0
ram0 (wx) : org = 0x20000000, len = 128k /* SRAM1 + SRAM2 */
ram1 (wx) : org = 0x20000000, len = 112k /* SRAM1 */
ram2 (wx) : org = 0x2001C000, len = 16k /* SRAM2 */
ram3 (wx) : org = 0x00000000, len = 0
ram4 (wx) : org = 0x10000000, len = 64k /* CCM SRAM */
ram5 (wx) : org = 0x40024000, len = 4k /* BCKP SRAM */
ram6 (wx) : org = 0x00000000, len = 0
ram7 (wx) : org = 0x00000000, len = 0
}
/* For each data/text section two region are defined, a virtual region
and a load region (_LMA suffix).*/
/* Flash region to be used for exception vectors.*/
REGION_ALIAS("VECTORS_FLASH", flash0);
REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
/* Flash region to be used for constructors and destructors.*/
REGION_ALIAS("XTORS_FLASH", flash0);
REGION_ALIAS("XTORS_FLASH_LMA", flash0);
/* Flash region to be used for code text.*/
REGION_ALIAS("TEXT_FLASH", flash0);
REGION_ALIAS("TEXT_FLASH_LMA", flash0);
/* Flash region to be used for read only data.*/
REGION_ALIAS("RODATA_FLASH", flash0);
REGION_ALIAS("RODATA_FLASH_LMA", flash0);
/* Flash region to be used for various.*/
REGION_ALIAS("VARIOUS_FLASH", flash0);
REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
/* Flash region to be used for RAM(n) initialization data.*/
REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
/* RAM region to be used for Main stack. This stack accommodates the processing
of all exceptions and interrupts.*/
REGION_ALIAS("MAIN_STACK_RAM", ram0);
/* RAM region to be used for the process stack. This is the stack used by
the main() function.*/
REGION_ALIAS("PROCESS_STACK_RAM", ram0);
/* RAM region to be used for data segment.*/
REGION_ALIAS("DATA_RAM", ram0);
REGION_ALIAS("DATA_RAM_LMA", flash0);
/* RAM region to be used for BSS segment.*/
REGION_ALIAS("BSS_RAM", ram0);
/* RAM region to be used for the default heap.*/
REGION_ALIAS("HEAP_RAM", ram0);
/* Generic rules inclusion.*/
INCLUDE rules.ld
/* TinyUF2 bootloader reset support */
_board_dfu_dbl_tap = ORIGIN(ram0) + 64k - 4; /* this is based off the linker file for tinyuf2 */

View file

@ -0,0 +1,2 @@
CONVERTER:=platforms/chibios/converters/promicro_to_sparkfun_pm2040
ACTIVE_CONVERTER:=sparkfun_pm2040

View file

@ -24,6 +24,7 @@
#include "debug.h"
#include "eeprom_legacy_emulated_flash.h"
#include "legacy_flash_ops.h"
#include "eeprom_driver.h"
/*
* We emulate eeprom by writing a snapshot compacted view of eeprom contents,
@ -564,6 +565,12 @@ void eeprom_driver_init(void) {
EEPROM_Init();
}
void eeprom_driver_format(bool erase) {
/* emulated eepron requires the write log data structures to be erased before use. */
(void)erase;
eeprom_driver_erase();
}
void eeprom_driver_erase(void) {
EEPROM_Erase();
}

View file

@ -52,6 +52,12 @@ static inline void STM32_L0_L1_EEPROM_Lock(void) {
void eeprom_driver_init(void) {}
void eeprom_driver_format(bool erase) {
if (erase) {
eeprom_driver_erase();
}
}
void eeprom_driver_erase(void) {
STM32_L0_L1_EEPROM_Unlock();

View file

@ -20,7 +20,7 @@
The size used by the STM32 L0/L1 EEPROM driver.
*/
#ifndef STM32_ONBOARD_EEPROM_SIZE
# ifdef VIA_ENABLE
# ifdef DYNAMIC_KEYMAP_ENABLE
# define STM32_ONBOARD_EEPROM_SIZE 1024
# else
# include "eeconfig.h"

View file

@ -64,9 +64,14 @@ __attribute__((weak)) void spi_init(void) {
}
bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
spiAcquireBus(&SPI_DRIVER);
#endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
if (spiStarted) {
return false;
}
#if SPI_SELECT_MODE != SPI_SELECT_MODE_NONE
if (slavePin == NO_PIN) {
return false;
@ -326,4 +331,8 @@ void spi_stop(void) {
spiStop(&SPI_DRIVER);
spiStarted = false;
}
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
spiReleaseBus(&SPI_DRIVER);
#endif // (SPI_USE_MUTUAL_EXCLUSION == TRUE)
}

View file

@ -14,11 +14,15 @@ static flash_sector_t first_sector = WEAR_LEVELING_EFL_FIRST_SECTOR;
static flash_sector_t first_sector = UINT16_MAX;
#endif // defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
#if !defined(WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT)
# define WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT 0
#endif // WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT
static flash_sector_t sector_count = UINT16_MAX;
static BaseFlash * flash;
static volatile bool is_issuing_read = false;
static volatile bool ecc_error_occurred = false;
static bool flash_erased_is_one;
static volatile bool is_issuing_read = false;
static volatile bool ecc_error_occurred = false;
// "Automatic" detection of the flash size -- ideally ChibiOS would have this already, but alas, it doesn't.
static inline uint32_t detect_flash_size(void) {
@ -51,10 +55,19 @@ bool backing_store_init(void) {
uint32_t counter = 0;
uint32_t flash_size = detect_flash_size();
// Check if the hardware erase is logic 1
flash_erased_is_one = (desc->attributes & FLASH_ATTR_ERASED_IS_ONE) ? true : false;
if (WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT >= desc->sectors_count) {
// Last sector defined is greater than available number of sectors. Can't do anything here. Fault.
chSysHalt("Last sector intended to be used with wear_leveling is beyond available flash descriptor range");
}
#if defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
// Work out how many sectors we want to use, working forwards from the first sector specified
for (flash_sector_t i = 0; i < desc->sectors_count - first_sector; ++i) {
flash_sector_t last_sector = desc->sectors_count - WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT;
for (flash_sector_t i = 0; i < last_sector - first_sector; ++i) {
counter += flashGetSectorSize(flash, first_sector + i);
if (counter >= (WEAR_LEVELING_BACKING_SIZE)) {
sector_count = i + 1;
@ -70,9 +83,9 @@ bool backing_store_init(void) {
#else // defined(WEAR_LEVELING_EFL_FIRST_SECTOR)
// Work out how many sectors we want to use, working backwards from the end of the flash
flash_sector_t last_sector = desc->sectors_count;
for (flash_sector_t i = 0; i < desc->sectors_count; ++i) {
first_sector = desc->sectors_count - i - 1;
flash_sector_t last_sector = desc->sectors_count - WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT;
for (flash_sector_t i = 0; i < last_sector; ++i) {
first_sector = last_sector - i - 1;
if (flashGetSectorOffset(flash, first_sector) >= flash_size) {
last_sector = first_sector;
continue;
@ -124,7 +137,9 @@ bool backing_store_write(uint32_t address, backing_store_int_t value) {
uint32_t offset = (base_offset + address);
bs_dprintf("Write ");
wl_dump(offset, &value, sizeof(value));
value = ~value;
if (flash_erased_is_one) {
value = ~value;
}
return flashProgram(flash, offset, sizeof(value), (const uint8_t *)&value) == FLASH_NO_ERROR;
}
@ -138,7 +153,7 @@ static backing_store_int_t backing_store_safe_read_from_location(backing_store_i
backing_store_int_t value;
is_issuing_read = true;
ecc_error_occurred = false;
value = ~(*loc);
value = flash_erased_is_one ? ~(*loc) : (*loc);
is_issuing_read = false;
return value;
}

View file

@ -133,7 +133,7 @@ static void set_led_color_rgb(rgb_led_t color, int pos) {
#endif
#ifdef WS2812_RGBW
for (int j = 0; j < 4; j++)
tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 4 + j] = get_protocol_eq(color.w, j);
tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 3 + j] = get_protocol_eq(color.w, j);
#endif
}

View file

@ -4,7 +4,7 @@
#include <ch.h>
#include "hardware_id.h"
hardware_id_t get_hardware_id(void) {
__attribute__((weak)) hardware_id_t get_hardware_id(void) {
hardware_id_t id = {0};
#if defined(RP2040)
// Forward declare as including "hardware/flash.h" here causes more issues...

View file

@ -546,9 +546,6 @@ ifneq ($(findstring STM32G431, $(MCU)),)
# Bootloader address for STM32 DFU
STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000
# Default to transient driver as ChibiOS EFL is currently broken for single-bank G4xx devices
EEPROM_DRIVER ?= transient
endif
ifneq ($(findstring STM32G474, $(MCU)),)