Make sendKbootCommand() accept various command types, not only reset.
This commit is contained in:
@@ -36,5 +36,5 @@ $blhost flash-erase-all-unsecure
|
||||
$blhost write-memory 0x0 "$firmware_image"
|
||||
$blhost reset
|
||||
sleep 4
|
||||
$usb_dir/send-kboot-reset.js
|
||||
../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d50,0x6121 reset
|
||||
$usb_dir/send-kboot-command.js reset 0x10
|
||||
#../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d50,0x6121 reset
|
||||
|
||||
Submodule lib/agent updated: 1a0fa5b5ba...1b22a2e739
@@ -7,6 +7,7 @@ kboot_driver_state_t KbootDriverState;
|
||||
static uint8_t rxBuffer[MAX_KBOOT_COMMAND_LENGTH];
|
||||
static uint8_t resetCommand[] = {0x5a, 0xa4, 0x04, 0x00, 0x6f, 0x46, 0x0b, 0x00, 0x00, 0x00};
|
||||
static uint8_t ackMessage[] = {0x5a, 0xa1};
|
||||
|
||||
static status_t tx(uint8_t *buffer, uint8_t length)
|
||||
{
|
||||
return I2cAsyncWrite(KbootDriverState.i2cAddress, buffer, length);
|
||||
@@ -25,23 +26,31 @@ status_t KbootSlaveDriver_Update(uint8_t kbootInstanceId)
|
||||
{
|
||||
status_t status = kStatus_Uhk_IdleSlave;
|
||||
|
||||
if (!KbootDriverState.isTransferScheduled) {
|
||||
return status;
|
||||
}
|
||||
|
||||
switch (KbootDriverState.phase++) {
|
||||
switch (KbootDriverState.commandType) {
|
||||
case KbootCommand_Idle:
|
||||
break;
|
||||
case KbootCommand_Ping:
|
||||
break;
|
||||
case KbootCommand_Reset:
|
||||
switch (KbootDriverState.phase) {
|
||||
case 0:
|
||||
status = tx(resetCommand, sizeof(resetCommand));
|
||||
KbootDriverState.phase++;
|
||||
break;
|
||||
case 1:
|
||||
status = rx(2);
|
||||
KbootDriverState.phase++;
|
||||
break;
|
||||
case 2:
|
||||
status = rx(18);
|
||||
KbootDriverState.phase++;
|
||||
break;
|
||||
case 3:
|
||||
status = tx(ackMessage, sizeof(ackMessage));
|
||||
KbootDriverState.isTransferScheduled = false;
|
||||
KbootDriverState.commandType = KbootCommand_Idle;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -15,8 +15,14 @@
|
||||
KbootDriverId_Singleton,
|
||||
} kboot_driver_id_t;
|
||||
|
||||
typedef enum {
|
||||
KbootCommand_Idle,
|
||||
KbootCommand_Ping,
|
||||
KbootCommand_Reset,
|
||||
} kboot_command_t;
|
||||
|
||||
typedef struct {
|
||||
bool isTransferScheduled;
|
||||
kboot_command_t commandType;
|
||||
uint8_t i2cAddress;
|
||||
uint8_t phase;
|
||||
} kboot_driver_state_t;
|
||||
|
||||
@@ -281,9 +281,9 @@ void jumpToSlaveBootloader(void)
|
||||
|
||||
void sendKbootCommand(void)
|
||||
{
|
||||
uint8_t i2cAddress = GenericHidInBuffer[1];
|
||||
KbootDriverState.i2cAddress = i2cAddress;
|
||||
KbootDriverState.isTransferScheduled = true;
|
||||
KbootDriverState.phase = 0;
|
||||
KbootDriverState.i2cAddress = GenericHidInBuffer[2];
|
||||
KbootDriverState.commandType = GenericHidInBuffer[1];
|
||||
}
|
||||
|
||||
// The main protocol handler function
|
||||
|
||||
Reference in New Issue
Block a user