diff options
| author | QMK Bot <hello@qmk.fm> | 2021-12-27 02:20:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-27 21:20:52 +1100 |
| commit | be2265d0d173ac347f0ee9ed809c2a689bf835a2 (patch) | |
| tree | 97c03e4d12b12e4d2e902efe8a7ab98174dfee5c /platforms | |
| parent | 1127e0da6b9b88b52a5d4ca33489f5ea5343b00f (diff) | |
Format code according to conventions (#15593)
Diffstat (limited to 'platforms')
| -rw-r--r-- | platforms/arm_atsam/bootloaders/md_boot.c | 22 | ||||
| -rw-r--r-- | platforms/avr/bootloaders/bootloadhid.c | 3 | ||||
| -rw-r--r-- | platforms/avr/bootloaders/caterina.c | 6 | ||||
| -rw-r--r-- | platforms/avr/bootloaders/dfu.c | 3 | ||||
| -rw-r--r-- | platforms/avr/bootloaders/halfkay.c | 3 | ||||
| -rw-r--r-- | platforms/avr/bootloaders/none.c | 3 | ||||
| -rw-r--r-- | platforms/avr/bootloaders/usbasploader.c | 3 | ||||
| -rw-r--r-- | platforms/chibios/bootloaders/gd32v_dfu.c | 5 | ||||
| -rw-r--r-- | platforms/chibios/bootloaders/halfkay.c | 3 | ||||
| -rw-r--r-- | platforms/chibios/bootloaders/kiibohd.c | 3 | ||||
| -rw-r--r-- | platforms/chibios/bootloaders/none.c | 3 | ||||
| -rw-r--r-- | platforms/chibios/bootloaders/stm32_dfu.c | 14 | ||||
| -rw-r--r-- | platforms/chibios/bootloaders/stm32duino.c | 5 | ||||
| -rw-r--r-- | platforms/chibios/bootloaders/tinyuf2.c | 5 | ||||
| -rw-r--r-- | platforms/test/bootloaders/none.c | 2 |
15 files changed, 37 insertions, 46 deletions
diff --git a/platforms/arm_atsam/bootloaders/md_boot.c b/platforms/arm_atsam/bootloaders/md_boot.c index fe07389487..e7508ffe51 100644 --- a/platforms/arm_atsam/bootloaders/md_boot.c +++ b/platforms/arm_atsam/bootloaders/md_boot.c | |||
| @@ -22,8 +22,8 @@ | |||
| 22 | // WARNING: These are only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support | 22 | // WARNING: These are only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support |
| 23 | extern uint32_t _eram; | 23 | extern uint32_t _eram; |
| 24 | 24 | ||
| 25 | #define BOOTLOADER_MAGIC 0x3B9ACA00 | 25 | # define BOOTLOADER_MAGIC 0x3B9ACA00 |
| 26 | #define MAGIC_ADDR (uint32_t *)((intptr_t)(&_eram) - 4) | 26 | # define MAGIC_ADDR (uint32_t *)((intptr_t)(&_eram) - 4) |
| 27 | 27 | ||
| 28 | // CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method. | 28 | // CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method. |
| 29 | void bootloader_jump(void) { | 29 | void bootloader_jump(void) { |
| @@ -40,7 +40,8 @@ void bootloader_jump(void) { | |||
| 40 | *MAGIC_ADDR = BOOTLOADER_MAGIC; // Set magic number into RAM | 40 | *MAGIC_ADDR = BOOTLOADER_MAGIC; // Set magic number into RAM |
| 41 | NVIC_SystemReset(); // Perform system reset | 41 | NVIC_SystemReset(); // Perform system reset |
| 42 | 42 | ||
| 43 | while (1); // Won't get here | 43 | while (1) |
| 44 | ; // Won't get here | ||
| 44 | } | 45 | } |
| 45 | } | 46 | } |
| 46 | 47 | ||
| @@ -50,17 +51,22 @@ void bootloader_jump(void) { | |||
| 50 | void bootloader_jump(void) { | 51 | void bootloader_jump(void) { |
| 51 | WDT->CTRLA.bit.ENABLE = 0; | 52 | WDT->CTRLA.bit.ENABLE = 0; |
| 52 | 53 | ||
| 53 | while (WDT->SYNCBUSY.bit.ENABLE); | 54 | while (WDT->SYNCBUSY.bit.ENABLE) |
| 54 | while (WDT->CTRLA.bit.ENABLE); | 55 | ; |
| 56 | while (WDT->CTRLA.bit.ENABLE) | ||
| 57 | ; | ||
| 55 | 58 | ||
| 56 | WDT->CONFIG.bit.WINDOW = 0; | 59 | WDT->CONFIG.bit.WINDOW = 0; |
| 57 | WDT->CONFIG.bit.PER = 0; | 60 | WDT->CONFIG.bit.PER = 0; |
| 58 | WDT->EWCTRL.bit.EWOFFSET = 0; | 61 | WDT->EWCTRL.bit.EWOFFSET = 0; |
| 59 | WDT->CTRLA.bit.ENABLE = 1; | 62 | WDT->CTRLA.bit.ENABLE = 1; |
| 60 | 63 | ||
| 61 | while (WDT->SYNCBUSY.bit.ENABLE); | 64 | while (WDT->SYNCBUSY.bit.ENABLE) |
| 62 | while (!WDT->CTRLA.bit.ENABLE); | 65 | ; |
| 66 | while (!WDT->CTRLA.bit.ENABLE) | ||
| 67 | ; | ||
| 63 | 68 | ||
| 64 | while (1); // Wait on timeout | 69 | while (1) |
| 70 | ; // Wait on timeout | ||
| 65 | } | 71 | } |
| 66 | #endif | 72 | #endif |
diff --git a/platforms/avr/bootloaders/bootloadhid.c b/platforms/avr/bootloaders/bootloadhid.c index 8d18114613..ae58760d7d 100644 --- a/platforms/avr/bootloaders/bootloadhid.c +++ b/platforms/avr/bootloaders/bootloadhid.c | |||
| @@ -19,8 +19,7 @@ | |||
| 19 | #include <avr/eeprom.h> | 19 | #include <avr/eeprom.h> |
| 20 | #include <avr/wdt.h> | 20 | #include <avr/wdt.h> |
| 21 | 21 | ||
| 22 | __attribute__((weak)) | 22 | __attribute__((weak)) void bootloader_jump(void) { |
| 23 | void bootloader_jump(void) { | ||
| 24 | // force bootloadHID to stay in bootloader mode, so that it waits | 23 | // force bootloadHID to stay in bootloader mode, so that it waits |
| 25 | // for a new firmware to be flashed | 24 | // for a new firmware to be flashed |
| 26 | // NOTE: this byte is part of QMK's "magic number" - changing it causes the EEPROM to be re-initialized | 25 | // NOTE: this byte is part of QMK's "magic number" - changing it causes the EEPROM to be re-initialized |
diff --git a/platforms/avr/bootloaders/caterina.c b/platforms/avr/bootloaders/caterina.c index 1b43ed4e44..82a16a3765 100644 --- a/platforms/avr/bootloaders/caterina.c +++ b/platforms/avr/bootloaders/caterina.c | |||
| @@ -18,8 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | #include <avr/wdt.h> | 19 | #include <avr/wdt.h> |
| 20 | 20 | ||
| 21 | __attribute__((weak)) | 21 | __attribute__((weak)) void bootloader_jump(void) { |
| 22 | void bootloader_jump(void) { | ||
| 23 | // this block may be optional | 22 | // this block may be optional |
| 24 | // TODO: figure it out | 23 | // TODO: figure it out |
| 25 | 24 | ||
| @@ -35,5 +34,6 @@ void bootloader_jump(void) { | |||
| 35 | wdt_enable(WDTO_60MS); | 34 | wdt_enable(WDTO_60MS); |
| 36 | 35 | ||
| 37 | // wait for watchdog timer to trigger | 36 | // wait for watchdog timer to trigger |
| 38 | while (1) { } | 37 | while (1) { |
| 38 | } | ||
| 39 | } | 39 | } |
diff --git a/platforms/avr/bootloaders/dfu.c b/platforms/avr/bootloaders/dfu.c index bdf5908934..cb42821a93 100644 --- a/platforms/avr/bootloaders/dfu.c +++ b/platforms/avr/bootloaders/dfu.c | |||
| @@ -28,8 +28,7 @@ | |||
| 28 | #define BOOTLOADER_RESET_KEY 0xB007B007 | 28 | #define BOOTLOADER_RESET_KEY 0xB007B007 |
| 29 | uint32_t reset_key __attribute__((section(".noinit,\"aw\",@nobits;"))); | 29 | uint32_t reset_key __attribute__((section(".noinit,\"aw\",@nobits;"))); |
| 30 | 30 | ||
| 31 | __attribute__((weak)) | 31 | __attribute__((weak)) void bootloader_jump(void) { |
| 32 | void bootloader_jump(void) { | ||
| 33 | UDCON = 1; | 32 | UDCON = 1; |
| 34 | USBCON = (1 << FRZCLK); // disable USB | 33 | USBCON = (1 << FRZCLK); // disable USB |
| 35 | UCSR1B = 0; | 34 | UCSR1B = 0; |
diff --git a/platforms/avr/bootloaders/halfkay.c b/platforms/avr/bootloaders/halfkay.c index abef86980b..6ce2e19114 100644 --- a/platforms/avr/bootloaders/halfkay.c +++ b/platforms/avr/bootloaders/halfkay.c | |||
| @@ -19,8 +19,7 @@ | |||
| 19 | #include <avr/interrupt.h> | 19 | #include <avr/interrupt.h> |
| 20 | #include <util/delay.h> | 20 | #include <util/delay.h> |
| 21 | 21 | ||
| 22 | __attribute__((weak)) | 22 | __attribute__((weak)) void bootloader_jump(void) { |
| 23 | void bootloader_jump(void) { | ||
| 24 | // http://www.pjrc.com/teensy/jump_to_bootloader.html | 23 | // http://www.pjrc.com/teensy/jump_to_bootloader.html |
| 25 | 24 | ||
| 26 | cli(); | 25 | cli(); |
diff --git a/platforms/avr/bootloaders/none.c b/platforms/avr/bootloaders/none.c index 8af151c04d..624fbe242a 100644 --- a/platforms/avr/bootloaders/none.c +++ b/platforms/avr/bootloaders/none.c | |||
| @@ -16,5 +16,4 @@ | |||
| 16 | 16 | ||
| 17 | #include "bootloader.h" | 17 | #include "bootloader.h" |
| 18 | 18 | ||
| 19 | __attribute__((weak)) | 19 | __attribute__((weak)) void bootloader_jump(void) {} |
| 20 | void bootloader_jump(void) { } | ||
diff --git a/platforms/avr/bootloaders/usbasploader.c b/platforms/avr/bootloaders/usbasploader.c index b3e9b2d72d..008bd16069 100644 --- a/platforms/avr/bootloaders/usbasploader.c +++ b/platforms/avr/bootloaders/usbasploader.c | |||
| @@ -26,8 +26,7 @@ | |||
| 26 | # endif | 26 | # endif |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | __attribute__((weak)) | 29 | __attribute__((weak)) void bootloader_jump(void) { |
| 30 | void bootloader_jump(void) { | ||
| 31 | // Taken with permission of Stephan Baerwolf from https://github.com/tinyusbboard/API/blob/master/apipage.c | 30 | // Taken with permission of Stephan Baerwolf from https://github.com/tinyusbboard/API/blob/master/apipage.c |
| 32 | 31 | ||
| 33 | wdt_enable(WDTO_15MS); | 32 | wdt_enable(WDTO_15MS); |
diff --git a/platforms/chibios/bootloaders/gd32v_dfu.c b/platforms/chibios/bootloaders/gd32v_dfu.c index 1ab0882084..7a979638e3 100644 --- a/platforms/chibios/bootloaders/gd32v_dfu.c +++ b/platforms/chibios/bootloaders/gd32v_dfu.c | |||
| @@ -24,8 +24,7 @@ | |||
| 24 | __IO uint32_t *DBGMCU_KEY = (uint32_t *)DBGMCU_BASE + 0x0CU; | 24 | __IO uint32_t *DBGMCU_KEY = (uint32_t *)DBGMCU_BASE + 0x0CU; |
| 25 | __IO uint32_t *DBGMCU_CMD = (uint32_t *)DBGMCU_BASE + 0x08U; | 25 | __IO uint32_t *DBGMCU_CMD = (uint32_t *)DBGMCU_BASE + 0x08U; |
| 26 | 26 | ||
| 27 | __attribute__((weak)) | 27 | __attribute__((weak)) void bootloader_jump(void) { |
| 28 | void bootloader_jump(void) { | ||
| 29 | /* The MTIMER unit of the GD32VF103 doesn't have the MSFRST | 28 | /* The MTIMER unit of the GD32VF103 doesn't have the MSFRST |
| 30 | * register to generate a software reset request. | 29 | * register to generate a software reset request. |
| 31 | * BUT instead two undocumented registers in the debug peripheral | 30 | * BUT instead two undocumented registers in the debug peripheral |
| @@ -37,4 +36,4 @@ void bootloader_jump(void) { | |||
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | /* Jumping to bootloader is not possible from user code. */ | 38 | /* Jumping to bootloader is not possible from user code. */ |
| 40 | void enter_bootloader_mode_if_requested(void) { } | 39 | void enter_bootloader_mode_if_requested(void) {} |
diff --git a/platforms/chibios/bootloaders/halfkay.c b/platforms/chibios/bootloaders/halfkay.c index fb9b73dfb3..168c2abc23 100644 --- a/platforms/chibios/bootloaders/halfkay.c +++ b/platforms/chibios/bootloaders/halfkay.c | |||
| @@ -19,8 +19,7 @@ | |||
| 19 | #include <ch.h> | 19 | #include <ch.h> |
| 20 | #include "wait.h" | 20 | #include "wait.h" |
| 21 | 21 | ||
| 22 | __attribute__((weak)) | 22 | __attribute__((weak)) void bootloader_jump(void) { |
| 23 | void bootloader_jump(void) { | ||
| 24 | wait_ms(100); | 23 | wait_ms(100); |
| 25 | __BKPT(0); | 24 | __BKPT(0); |
| 26 | } | 25 | } |
diff --git a/platforms/chibios/bootloaders/kiibohd.c b/platforms/chibios/bootloaders/kiibohd.c index f4bb18f058..911e807092 100644 --- a/platforms/chibios/bootloaders/kiibohd.c +++ b/platforms/chibios/bootloaders/kiibohd.c | |||
| @@ -23,8 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; | 24 | const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; |
| 25 | 25 | ||
| 26 | __attribute__((weak)) | 26 | __attribute__((weak)) void bootloader_jump(void) { |
| 27 | void bootloader_jump(void) { | ||
| 28 | void *volatile vbat = (void *)VBAT; | 27 | void *volatile vbat = (void *)VBAT; |
| 29 | __builtin_memcpy(vbat, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic)); | 28 | __builtin_memcpy(vbat, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic)); |
| 30 | 29 | ||
diff --git a/platforms/chibios/bootloaders/none.c b/platforms/chibios/bootloaders/none.c index 8af151c04d..624fbe242a 100644 --- a/platforms/chibios/bootloaders/none.c +++ b/platforms/chibios/bootloaders/none.c | |||
| @@ -16,5 +16,4 @@ | |||
| 16 | 16 | ||
| 17 | #include "bootloader.h" | 17 | #include "bootloader.h" |
| 18 | 18 | ||
| 19 | __attribute__((weak)) | 19 | __attribute__((weak)) void bootloader_jump(void) {} |
| 20 | void bootloader_jump(void) { } | ||
diff --git a/platforms/chibios/bootloaders/stm32_dfu.c b/platforms/chibios/bootloaders/stm32_dfu.c index f4bd8554bf..0a113570f7 100644 --- a/platforms/chibios/bootloaders/stm32_dfu.c +++ b/platforms/chibios/bootloaders/stm32_dfu.c | |||
| @@ -41,8 +41,7 @@ extern uint32_t __ram0_end__; | |||
| 41 | # define STM32_BOOTLOADER_DUAL_BANK_DELAY 100000 | 41 | # define STM32_BOOTLOADER_DUAL_BANK_DELAY 100000 |
| 42 | # endif | 42 | # endif |
| 43 | 43 | ||
| 44 | __attribute__((weak)) | 44 | __attribute__((weak)) void bootloader_jump(void) { |
| 45 | void bootloader_jump(void) { | ||
| 46 | // For STM32 MCUs with dual-bank flash, and we're incapable of jumping to the bootloader. The first valid flash | 45 | // For STM32 MCUs with dual-bank flash, and we're incapable of jumping to the bootloader. The first valid flash |
| 47 | // bank is executed unconditionally after a reset, so it doesn't enter DFU unless BOOT0 is high. Instead, we do | 46 | // bank is executed unconditionally after a reset, so it doesn't enter DFU unless BOOT0 is high. Instead, we do |
| 48 | // it with hardware...in this case, we pull a GPIO high/low depending on the configuration, connects 3.3V to | 47 | // it with hardware...in this case, we pull a GPIO high/low depending on the configuration, connects 3.3V to |
| @@ -63,17 +62,16 @@ void bootloader_jump(void) { | |||
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | // not needed at all, but if anybody attempts to invoke it.... | 64 | // not needed at all, but if anybody attempts to invoke it.... |
| 66 | void enter_bootloader_mode_if_requested(void) { } | 65 | void enter_bootloader_mode_if_requested(void) {} |
| 67 | 66 | ||
| 68 | #else | 67 | #else |
| 69 | 68 | ||
| 70 | /* This code should be checked whether it runs correctly on platforms */ | 69 | /* This code should be checked whether it runs correctly on platforms */ |
| 71 | #define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0)) | 70 | # define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0)) |
| 72 | #define BOOTLOADER_MAGIC 0xDEADBEEF | 71 | # define BOOTLOADER_MAGIC 0xDEADBEEF |
| 73 | #define MAGIC_ADDR (unsigned long *)(SYMVAL(__ram0_end__) - 4) | 72 | # define MAGIC_ADDR (unsigned long *)(SYMVAL(__ram0_end__) - 4) |
| 74 | 73 | ||
| 75 | __attribute__((weak)) | 74 | __attribute__((weak)) void bootloader_jump(void) { |
| 76 | void bootloader_jump(void) { | ||
| 77 | *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader | 75 | *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader |
| 78 | NVIC_SystemReset(); | 76 | NVIC_SystemReset(); |
| 79 | } | 77 | } |
diff --git a/platforms/chibios/bootloaders/stm32duino.c b/platforms/chibios/bootloaders/stm32duino.c index 6ff9e28b4d..dd1d551fa9 100644 --- a/platforms/chibios/bootloaders/stm32duino.c +++ b/platforms/chibios/bootloaders/stm32duino.c | |||
| @@ -18,7 +18,4 @@ | |||
| 18 | 18 | ||
| 19 | #include <ch.h> | 19 | #include <ch.h> |
| 20 | 20 | ||
| 21 | __attribute__((weak)) | 21 | __attribute__((weak)) void bootloader_jump(void) { NVIC_SystemReset(); } |
| 22 | void bootloader_jump(void) { | ||
| 23 | NVIC_SystemReset(); | ||
| 24 | } | ||
diff --git a/platforms/chibios/bootloaders/tinyuf2.c b/platforms/chibios/bootloaders/tinyuf2.c index ce82fa0c49..9ffca5dec8 100644 --- a/platforms/chibios/bootloaders/tinyuf2.c +++ b/platforms/chibios/bootloaders/tinyuf2.c | |||
| @@ -25,11 +25,10 @@ | |||
| 25 | extern uint32_t _board_dfu_dbl_tap[]; | 25 | extern uint32_t _board_dfu_dbl_tap[]; |
| 26 | #define DBL_TAP_REG _board_dfu_dbl_tap[0] | 26 | #define DBL_TAP_REG _board_dfu_dbl_tap[0] |
| 27 | 27 | ||
| 28 | __attribute__((weak)) | 28 | __attribute__((weak)) void bootloader_jump(void) { |
| 29 | void bootloader_jump(void) { | ||
| 30 | DBL_TAP_REG = DBL_TAP_MAGIC; | 29 | DBL_TAP_REG = DBL_TAP_MAGIC; |
| 31 | NVIC_SystemReset(); | 30 | NVIC_SystemReset(); |
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | /* not needed, no two-stage reset */ | 33 | /* not needed, no two-stage reset */ |
| 35 | void enter_bootloader_mode_if_requested(void) { } | 34 | void enter_bootloader_mode_if_requested(void) {} |
diff --git a/platforms/test/bootloaders/none.c b/platforms/test/bootloaders/none.c index 2920c68f18..5155d9ff04 100644 --- a/platforms/test/bootloaders/none.c +++ b/platforms/test/bootloaders/none.c | |||
| @@ -16,4 +16,4 @@ | |||
| 16 | 16 | ||
| 17 | #include "bootloader.h" | 17 | #include "bootloader.h" |
| 18 | 18 | ||
| 19 | void bootloader_jump(void) { } | 19 | void bootloader_jump(void) {} |
