diff options
Diffstat (limited to 'platforms')
18 files changed, 51 insertions, 28 deletions
diff --git a/platforms/avr/drivers/ws2812_bitbang.c b/platforms/avr/drivers/ws2812_bitbang.c index aad10d86b0..116053591f 100644 --- a/platforms/avr/drivers/ws2812_bitbang.c +++ b/platforms/avr/drivers/ws2812_bitbang.c @@ -37,13 +37,13 @@  static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t masklo, uint8_t maskhi); -void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) { +void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds) {      DDRx_ADDRESS(WS2812_DI_PIN) |= pinmask(WS2812_DI_PIN);      uint8_t masklo = ~(pinmask(WS2812_DI_PIN)) & PORTx_ADDRESS(WS2812_DI_PIN);      uint8_t maskhi = pinmask(WS2812_DI_PIN) | PORTx_ADDRESS(WS2812_DI_PIN); -    ws2812_sendarray_mask((uint8_t *)ledarray, number_of_leds * sizeof(LED_TYPE), masklo, maskhi); +    ws2812_sendarray_mask((uint8_t *)ledarray, number_of_leds * sizeof(rgb_led_t), masklo, maskhi);      _delay_us(WS2812_TRST_US);  } diff --git a/platforms/avr/drivers/ws2812_i2c.c b/platforms/avr/drivers/ws2812_i2c.c index f4a2fbe0b3..f52a037b8e 100644 --- a/platforms/avr/drivers/ws2812_i2c.c +++ b/platforms/avr/drivers/ws2812_i2c.c @@ -18,12 +18,12 @@ void ws2812_init(void) {  }  // Setleds for standard RGB -void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { +void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {      static bool s_init = false;      if (!s_init) {          ws2812_init();          s_init = true;      } -    i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_I2C_TIMEOUT); +    i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(rgb_led_t) * leds, WS2812_I2C_TIMEOUT);  } diff --git a/platforms/avr/platform.mk b/platforms/avr/platform.mk index 09028d80af..aef449cadf 100644 --- a/platforms/avr/platform.mk +++ b/platforms/avr/platform.mk @@ -109,6 +109,29 @@ DEBUG_HOST = localhost  #============================================================================ +SIZE_MARGIN = 1024 + +check-size: +	$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(CFLAGS) $(OPT_DEFS) platforms/avr/bootloader_size.c 2> /dev/null | $(SED) -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) +	$(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) +	$(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) +	$(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) +	$(eval PERCENT_SIZE=$(shell expr $(CURRENT_SIZE) \* 100 / $(MAX_SIZE))) +	if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \ +		$(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \ +		if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then \ +			$(REMOVE) $(TARGET).$(FIRMWARE_FORMAT); \ +			$(REMOVE) $(BUILD_DIR)/$(TARGET).{hex,bin,uf2}; \ +		    printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); \ +		else \ +		    if [ $(FREE_SIZE) -lt $(SIZE_MARGIN) ]; then \ +			$(PRINT_WARNING_PLAIN); printf " * $(MSG_FILE_NEAR_LIMIT)"; \ +		    else \ +			$(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; \ +		    fi ; \ +		fi ; \ +	fi +  # Convert hex to bin.  bin: $(BUILD_DIR)/$(TARGET).hex  ifeq ($(BOOTLOADER),lufa-ms) diff --git a/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h index 8621807cbb..4f39793264 100644 --- a/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h +++ b/platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h @@ -54,6 +54,7 @@  #define RP_IRQ_USB0_PRIORITY                3  #define RP_IRQ_I2C0_PRIORITY                2  #define RP_IRQ_I2C1_PRIORITY                2 +#define RP_IRQ_RTC_PRIORITY                 3  /*   * ADC driver system settings. diff --git a/platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h index 902f9b5005..3a10f67727 100644 --- a/platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h +++ b/platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h @@ -54,6 +54,7 @@  #define RP_IRQ_USB0_PRIORITY                3  #define RP_IRQ_I2C0_PRIORITY                2  #define RP_IRQ_I2C1_PRIORITY                2 +#define RP_IRQ_RTC_PRIORITY                 3  /*   * ADC driver system settings. diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c index f74c9e8be7..80472b88f7 100644 --- a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c +++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c @@ -73,6 +73,7 @@ void __early_init(void) {    wb32_clock_init();    wb32_gpio_init();  } +  /**   * @brief   Board-specific initialization code.   * @note    You can add your board-specific code here. @@ -80,7 +81,3 @@ void __early_init(void) {  void boardInit(void) {  } - -void restart_usb_driver(USBDriver *usbp) { -  // Do nothing. Restarting the USB driver on these boards breaks it. -} diff --git a/platforms/chibios/boards/GENERIC_WB32_FQ95XX/board/board.c b/platforms/chibios/boards/GENERIC_WB32_FQ95XX/board/board.c index a99537fc27..5701fd2e0d 100644 --- a/platforms/chibios/boards/GENERIC_WB32_FQ95XX/board/board.c +++ b/platforms/chibios/boards/GENERIC_WB32_FQ95XX/board/board.c @@ -73,6 +73,7 @@ void __early_init(void) {    wb32_clock_init();    wb32_gpio_init();  } +  /**   * @brief   Board-specific initialization code.   * @note    You can add your board-specific code here. @@ -80,7 +81,3 @@ void __early_init(void) {  void boardInit(void) {  } - -void restart_usb_driver(USBDriver *usbp) { -  // Do nothing. Restarting the USB driver on these boards breaks it. -} diff --git a/platforms/chibios/boards/QMK_BLOK/configs/mcuconf.h b/platforms/chibios/boards/QMK_BLOK/configs/mcuconf.h index 0c2ef592d6..d5dec0fcd0 100644 --- a/platforms/chibios/boards/QMK_BLOK/configs/mcuconf.h +++ b/platforms/chibios/boards/QMK_BLOK/configs/mcuconf.h @@ -54,6 +54,7 @@  #define RP_IRQ_USB0_PRIORITY                3  #define RP_IRQ_I2C0_PRIORITY                2  #define RP_IRQ_I2C1_PRIORITY                2 +#define RP_IRQ_RTC_PRIORITY                 3  /*   * ADC driver system settings. diff --git a/platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h b/platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h index 493dcf6434..e3351deb3b 100644 --- a/platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h +++ b/platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h @@ -54,6 +54,7 @@  #define RP_IRQ_USB0_PRIORITY                3  #define RP_IRQ_I2C0_PRIORITY                2  #define RP_IRQ_I2C1_PRIORITY                2 +#define RP_IRQ_RTC_PRIORITY                 3  /*   * ADC driver system settings. diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index 1f8a7842fe..f1636f9da0 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h @@ -37,7 +37,9 @@  #        define BACKLIGHT_PAL_MODE (PAL_MODE_ALTERNATE_PWM | PAL_RP_PAD_DRIVE12 | PAL_RP_GPIO_OE)  #    endif  #    define BACKLIGHT_PWM_COUNTER_FREQUENCY 1000000 -#    define BACKLIGHT_PWM_PERIOD BACKLIGHT_PWM_COUNTER_FREQUENCY / 2048 +#    ifndef BACKLIGHT_PWM_PERIOD +#        define BACKLIGHT_PWM_PERIOD BACKLIGHT_PWM_COUNTER_FREQUENCY / 2048 +#    endif  #    ifndef AUDIO_PWM_PAL_MODE  #        define AUDIO_PWM_PAL_MODE (PAL_MODE_ALTERNATE_PWM | PAL_RP_PAD_DRIVE12 | PAL_RP_GPIO_OE) diff --git a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c index 8d59e13bb2..de317e269a 100644 --- a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c +++ b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c @@ -268,7 +268,7 @@ static inline void sync_ws2812_transfer(void) {      busy_wait_until(LAST_TRANSFER);  } -void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) { +void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {      static bool is_initialized = false;      if (unlikely(!is_initialized)) {          is_initialized = ws2812_init(); diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h index e74cf85efd..0f0fa694e9 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h @@ -50,5 +50,5 @@  // 1kB logical EEPROM  #ifndef WEAR_LEVELING_LOGICAL_SIZE -#    define WEAR_LEVELING_LOGICAL_SIZE 1024 +#    define WEAR_LEVELING_LOGICAL_SIZE ((WEAR_LEVELING_BACKING_SIZE) / 2)  #endif // WEAR_LEVELING_LOGICAL_SIZE diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c index 640628e1e9..6624c30b5b 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c @@ -25,8 +25,8 @@  #define FLASHCMD_READ_STATUS 0x05  #define FLASHCMD_WRITE_ENABLE 0x06 -extern uint8_t  BOOT2_ROM[256]; -static uint32_t BOOT2_ROM_RAM[64]; +extern const uint8_t BOOT2_ROM[256]; +static uint32_t      BOOT2_ROM_RAM[64];  static ssi_hw_t *const ssi = (ssi_hw_t *)XIP_SSI_BASE; diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h index 93a9aa0372..e1e2433601 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash_config.h @@ -18,7 +18,7 @@  // 32kB logical EEPROM  #ifndef WEAR_LEVELING_LOGICAL_SIZE -#    define WEAR_LEVELING_LOGICAL_SIZE 4096 +#    define WEAR_LEVELING_LOGICAL_SIZE ((WEAR_LEVELING_BACKING_SIZE) / 2)  #endif // WEAR_LEVELING_LOGICAL_SIZE  // Define how much flash space we have (defaults to lib/pico-sdk/src/boards/include/boards/***) diff --git a/platforms/chibios/drivers/ws2812_bitbang.c b/platforms/chibios/drivers/ws2812_bitbang.c index c55e0f654c..e3b735a1a6 100644 --- a/platforms/chibios/drivers/ws2812_bitbang.c +++ b/platforms/chibios/drivers/ws2812_bitbang.c @@ -72,7 +72,7 @@ void ws2812_init(void) {  }  // Setleds for standard RGB -void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { +void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {      static bool s_init = false;      if (!s_init) {          ws2812_init(); diff --git a/platforms/chibios/drivers/ws2812_pwm.c b/platforms/chibios/drivers/ws2812_pwm.c index cfee547a82..440687bd72 100644 --- a/platforms/chibios/drivers/ws2812_pwm.c +++ b/platforms/chibios/drivers/ws2812_pwm.c @@ -379,7 +379,7 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b,  }  // Setleds for standard RGB -void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) { +void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {      static bool s_init = false;      if (!s_init) {          ws2812_init(); diff --git a/platforms/chibios/drivers/ws2812_spi.c b/platforms/chibios/drivers/ws2812_spi.c index f188576e04..f56236a8b8 100644 --- a/platforms/chibios/drivers/ws2812_spi.c +++ b/platforms/chibios/drivers/ws2812_spi.c @@ -106,7 +106,7 @@ static uint8_t get_protocol_eq(uint8_t data, int pos) {      return eq;  } -static void set_led_color_rgb(LED_TYPE color, int pos) { +static void set_led_color_rgb(rgb_led_t color, int pos) {      uint8_t* tx_start = &txbuf[PREAMBLE_SIZE];  #if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB) @@ -187,7 +187,7 @@ void ws2812_init(void) {  #endif  } -void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) { +void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {      static bool s_init = false;      if (!s_init) {          ws2812_init(); diff --git a/platforms/chibios/vendors/RP/stage2_bootloaders.c b/platforms/chibios/vendors/RP/stage2_bootloaders.c index e65b0a5802..131fa0ce9e 100644 --- a/platforms/chibios/vendors/RP/stage2_bootloaders.c +++ b/platforms/chibios/vendors/RP/stage2_bootloaders.c @@ -13,7 +13,7 @@  #if defined(RP2040_FLASH_AT25SF128A) -uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = { +const uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {    0x00, 0xb5, 0x31, 0x4b, 0x21, 0x20, 0x58, 0x60, 0x98, 0x68, 0x02, 0x21,    0x88, 0x43, 0x98, 0x60, 0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2d, 0x4b,    0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61, 0x01, 0x21, 0xf0, 0x22, @@ -40,7 +40,7 @@ uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {  #elif defined(RP2040_FLASH_GD25Q64CS) -uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = { +const uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {    0x00, 0xb5, 0x31, 0x4b, 0x21, 0x20, 0x58, 0x60, 0x98, 0x68, 0x02, 0x21,    0x88, 0x43, 0x98, 0x60, 0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2d, 0x4b,    0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61, 0x01, 0x21, 0xf0, 0x22, @@ -67,7 +67,7 @@ uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {  #elif defined(RP2040_FLASH_W25X10CL) -uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = { +const uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {    0x00, 0xb5, 0x14, 0x4b, 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61,    0x12, 0x49, 0x19, 0x60, 0x00, 0x21, 0x59, 0x60, 0x11, 0x49, 0x12, 0x48,    0x01, 0x60, 0x01, 0x21, 0x99, 0x60, 0xbb, 0x21, 0x19, 0x66, 0x02, 0x21, @@ -94,7 +94,7 @@ uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {  #elif defined(RP2040_FLASH_IS25LP080) -uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = { +const uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {    0x00, 0xb5, 0x2b, 0x4b, 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61,    0x29, 0x49, 0x19, 0x60, 0x01, 0x21, 0x99, 0x60, 0x28, 0x48, 0x00, 0xf0,    0x42, 0xf8, 0x28, 0x4a, 0x90, 0x42, 0x12, 0xd0, 0x06, 0x21, 0x19, 0x66, @@ -121,7 +121,7 @@ uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {  #elif defined(RP2040_FLASH_GENERIC_03H) -uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = { +const uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {    0x00, 0xb5, 0x0c, 0x4b, 0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61,    0x0a, 0x49, 0x19, 0x60, 0x0a, 0x49, 0x0b, 0x48, 0x01, 0x60, 0x00, 0x21,    0x59, 0x60, 0x01, 0x21, 0x99, 0x60, 0x01, 0xbc, 0x00, 0x28, 0x00, 0xd0, @@ -148,7 +148,7 @@ uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {  #else -uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = { +const uint8_t BOOTLOADER_SECTION BOOT2_ROM[256] = {    0x00, 0xb5, 0x32, 0x4b, 0x21, 0x20, 0x58, 0x60, 0x98, 0x68, 0x02, 0x21,    0x88, 0x43, 0x98, 0x60, 0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2e, 0x4b,    0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61, 0x01, 0x21, 0xf0, 0x22,  | 
