Add eeprom init route

This commit is contained in:
zvecr 2022-10-01 04:16:15 +01:00
parent ac96f59249
commit 7ee5347485
7 changed files with 44 additions and 4 deletions

View File

@ -321,7 +321,7 @@
'''
Jump to bootloader
May not be present if QMK capabilities query returns “true”, then jump to bootloader is supported
May not be present - if QMK capabilities query returns “true”, then jump to bootloader is supported
* 0 means secure routes are disabled, and should be considered as a failure
* 1 means successful, board will jump to bootloader
@ -337,6 +337,24 @@
return_type: u32[4]
return_execute: get_hardware_id
}
0x09: {
type: command
name: Reinitialize EEPROM
define: EEPROM_RESET
permissions: secure
enable_if_preprocessor: !defined(NO_RESET)
description:
'''
Reinitializes the keyboard's EEPROM (persistent memory)
May not be present - if QMK capabilities query returns “true”, then reinitialize is supported
* 0 means secure routes are disabled, and should be considered as a failure
* 1 means successful, board will reinitialize and then reboot
'''
return_type: u8
return_execute: request_eeprom_reset
}
}
},

View File

@ -111,8 +111,9 @@ This subsystem is always present, and provides the ability to address QMK-specif
| Product Name | `0x01 0x04` | |__Response:__ `string`| Retrieves the product name|
| Config Blob Length | `0x01 0x05` | |__Response:__ `u16`| Retrieves the length of the configuration data bundled within the firmware|
| Config Blob Chunk | `0x01 0x06` | |__Request:__ `u16`<br><br>__Response:__ `u8[32]`| Retrieves a chunk of the configuration data bundled within the firmware|
| Jump to bootloader | `0x01 0x07` | __Secure__ |__Response:__ `u8`| Jump to bootloader<br><br>May not be present if QMK capabilities query returns “true”, then jump to bootloader is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will jump to bootloader|
| Jump to bootloader | `0x01 0x07` | __Secure__ |__Response:__ `u8`| Jump to bootloader<br><br>May not be present - if QMK capabilities query returns “true”, then jump to bootloader is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will jump to bootloader|
| Hardware Identifier | `0x01 0x08` | |__Response:__ `u32[4]`| Retrieves a unique identifier for the board.|
| Reinitialize EEPROM | `0x01 0x09` | __Secure__ |__Response:__ `u8`| Reinitializes the keyboard's EEPROM (persistent memory)<br><br>May not be present - if QMK capabilities query returns “true”, then reinitialize is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will reinitialize and then reboot|
### Keyboard - `0x02`
This subsystem is always present, and reserved for vendor-specific functionality. No routes are defined by XAP.

View File

@ -111,8 +111,9 @@ This subsystem is always present, and provides the ability to address QMK-specif
| Product Name | `0x01 0x04` | |__Response:__ `string`| Retrieves the product name|
| Config Blob Length | `0x01 0x05` | |__Response:__ `u16`| Retrieves the length of the configuration data bundled within the firmware|
| Config Blob Chunk | `0x01 0x06` | |__Request:__ `u16`<br><br>__Response:__ `u8[32]`| Retrieves a chunk of the configuration data bundled within the firmware|
| Jump to bootloader | `0x01 0x07` | __Secure__ |__Response:__ `u8`| Jump to bootloader<br><br>May not be present if QMK capabilities query returns “true”, then jump to bootloader is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will jump to bootloader|
| Jump to bootloader | `0x01 0x07` | __Secure__ |__Response:__ `u8`| Jump to bootloader<br><br>May not be present - if QMK capabilities query returns “true”, then jump to bootloader is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will jump to bootloader|
| Hardware Identifier | `0x01 0x08` | |__Response:__ `u32[4]`| Retrieves a unique identifier for the board.|
| Reinitialize EEPROM | `0x01 0x09` | __Secure__ |__Response:__ `u8`| Reinitializes the keyboard's EEPROM (persistent memory)<br><br>May not be present - if QMK capabilities query returns “true”, then reinitialize is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will reinitialize and then reboot|
### Keyboard - `0x02`
This subsystem is always present, and reserved for vendor-specific functionality. No routes are defined by XAP.

View File

@ -111,8 +111,9 @@ This subsystem is always present, and provides the ability to address QMK-specif
| Product Name | `0x01 0x04` | |__Response:__ `string`| Retrieves the product name|
| Config Blob Length | `0x01 0x05` | |__Response:__ `u16`| Retrieves the length of the configuration data bundled within the firmware|
| Config Blob Chunk | `0x01 0x06` | |__Request:__ `u16`<br><br>__Response:__ `u8[32]`| Retrieves a chunk of the configuration data bundled within the firmware|
| Jump to bootloader | `0x01 0x07` | __Secure__ |__Response:__ `u8`| Jump to bootloader<br><br>May not be present if QMK capabilities query returns “true”, then jump to bootloader is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will jump to bootloader|
| Jump to bootloader | `0x01 0x07` | __Secure__ |__Response:__ `u8`| Jump to bootloader<br><br>May not be present - if QMK capabilities query returns “true”, then jump to bootloader is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will jump to bootloader|
| Hardware Identifier | `0x01 0x08` | |__Response:__ `u32[4]`| Retrieves a unique identifier for the board.|
| Reinitialize EEPROM | `0x01 0x09` | __Secure__ |__Response:__ `u8`| Reinitializes the keyboard's EEPROM (persistent memory)<br><br>May not be present - if QMK capabilities query returns “true”, then reinitialize is supported<br><br>* 0 means secure routes are disabled, and should be considered as a failure<br>* 1 means successful, board will reinitialize and then reboot|
### Keyboard - `0x02`
This subsystem is always present, and reserved for vendor-specific functionality. No routes are defined by XAP.

View File

@ -225,3 +225,9 @@ class XAPDevice(XAPDeviceBase):
"""
status = self.int_transaction(XAPRoutes.QMK_BOOTLOADER_JUMP)
return status == 1
def reinit(self):
"""Request device reset EEPROM - Requires previous unlock
"""
status = self.int_transaction(XAPRoutes.QMK_EEPROM_RESET)
return status == 1

View File

@ -49,6 +49,7 @@ class XAPRoutes():
QMK_CONFIG_BLOB_CHUNK = b'\x01\x06'
QMK_BOOTLOADER_JUMP = b'\x01\x07'
QMK_HARDWARE_ID = b'\x01\x08'
QMK_EEPROM_RESET = b'\x01\x09'
# KEYMAP
KEYMAP_CAPABILITIES_QUERY = b'\x04\x01'
KEYMAP_GET_LAYER_COUNT = b'\x04\x02'

View File

@ -100,6 +100,18 @@ bool xap_respond_request_bootloader_jump(xap_token_t token, const void *data, si
}
#endif
#ifndef NO_RESET
bool xap_respond_request_eeprom_reset(xap_token_t token, const void *data, size_t length) {
uint8_t ret = secure_is_unlocked();
// TODO: post to deferred queue so this request can return?
bool res = xap_respond_data(token, &ret, sizeof(ret));
eeconfig_disable();
soft_reset_keyboard();
return res;
}
#endif
bool xap_respond_get_hardware_id(xap_token_t token, const void *data, size_t length) {
hardware_id_t ret = get_hardware_id();
return xap_respond_data(token, &ret, sizeof(ret));