lophtware

Logo

lophtware projects

GitHub Profile

Core - Store Current Configuration

Report Type: OUT
Report Size: 10 Bytes
Acknowledged By: Command Acknowledgement

Report ID Unlock Key Flags
00001000 8 bytes b 0000000

THIS COMMAND HAS THE POTENTIAL TO DESTROY THE DEVICE AND / OR CONNECTED CIRCUITRY, IE. BY CORRUPTING THE FIRMWARE IF THE POWER IS INTERRUPTED.

Report ID

HID Report ID. Always 0x08.

Unlock Key

An 8-byte key that is used to prevent accidental changes to certain configuration values.

Flags

Bits Direction Meaning
b OUT Whether to make the current configuration the default boot configuration; 1 for yes, 0 for no.
0000000    

Notes

This command stores the configuration settings currently held in memory into the non-volatile flash memory so that they are persisted across power cycles.

There are four device configurations available which can be selected by issuing a standard USB Set_Configuration request with a wValue of 0x0001, 0x0002, 0x0003 or 0x0004, although see quirks about this. The in-memory configuration will be stored in the slot that is currently active, so if that is not the default boot configuration then it will require a subsequent Set Configuration after any power cycles.

This command will reset the microcontroller so the USB connection will be lost and will proceed through enumeration again. This means that if the configuration was not bootable (ie. if b was not 1) then the settings just persisted will not be the active ones and another Set_Configuration request will be necessary.

There are lots of things that can go wrong with this command since the PIC does not allow flash programming in anything less than 2048 byte pages. The device pins will remain unchanged during the store operation and the power should be clean, stable and not interrupted. If the operation does not complete successfully then the configuration and flash will be corrupted and the device will require a re-flash of the firmware; see ICSP.

The success (or otherwise) of the operation can be checked via the Device Status command once the device has been reset. If there was a failure then the device will be in a ‘Safe Mode’, which is a hard-coded factory-default configuration. Devices in ‘Safe Mode’ will not be able to have their configuration stored, although it can be altered.

Device Status is also available via the I2C Device Information Bank.