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