Implement KbootCommand_Ping and set set left BOOTLOADER_TIMEOUT_MS back to 100 ms.

This commit is contained in:
László Monda
2017-10-23 21:33:08 +02:00
parent c46dcad490
commit 85b1a65ea7
6 changed files with 38 additions and 9 deletions

View File

@@ -35,7 +35,8 @@ case "$(uname -s)" in
;;
esac
blhost="../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d50,0x6121 --buspal i2c,0x10,100k"
blhost_usb="../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d50,0x6121"
blhost_buspal="$blhost_usb --buspal i2c,0x10,100k"
set -x # echo on
@@ -44,12 +45,12 @@ set -x # echo on
# npm install
#fi
$usb_dir/send-kboot-command.js ping 0x10
$usb_dir/jump-to-slave-bootloader.js
$usb_dir/reenumerate.js buspal
$blhost get-property 1
$blhost flash-erase-all-unsecure
$blhost write-memory 0x0 "$firmware_image"
$blhost reset
sleep 4
#$usb_dir/send-kboot-command.js reset 0x10
#../../../lib/bootloader/bin/Tools/blhost/$blhost_path/blhost --usb 0x1d50,0x6121 reset
$blhost_buspal get-property 1
$blhost_buspal flash-erase-all-unsecure
$blhost_buspal write-memory 0x0 "$firmware_image"
$blhost_usb reset
$usb_dir/reenumerate.js normalKeyboard
$usb_dir/send-kboot-command.js reset 0x10

View File

@@ -5,6 +5,7 @@
kboot_driver_state_t KbootDriverState;
static uint8_t rxBuffer[MAX_KBOOT_COMMAND_LENGTH];
static uint8_t pingCommand[] = {0x5a, 0xa6};
static uint8_t resetCommand[] = {0x5a, 0xa4, 0x04, 0x00, 0x6f, 0x46, 0x0b, 0x00, 0x00, 0x00};
static uint8_t ackMessage[] = {0x5a, 0xa1};
@@ -30,6 +31,28 @@ status_t KbootSlaveDriver_Update(uint8_t kbootInstanceId)
case KbootCommand_Idle:
break;
case KbootCommand_Ping:
switch (KbootDriverState.phase) {
case 0:
status = tx(pingCommand, sizeof(pingCommand));
KbootDriverState.phase++;
break;
case 1:
KbootDriverState.status = Slaves[SlaveId_KbootDriver].previousStatus;
KbootDriverState.phase = KbootDriverState.status == kStatus_Success ? 2 : 0;
return kStatus_Uhk_NoTransfer;
case 2:
status = rx(10);
KbootDriverState.phase++;
break;
case 3:
KbootDriverState.status = Slaves[SlaveId_KbootDriver].previousStatus;
if (KbootDriverState.status == kStatus_Success) {
KbootDriverState.commandType = KbootCommand_Idle;
} else {
KbootDriverState.phase = 0;
return kStatus_Uhk_NoTransfer;
}
}
break;
case KbootCommand_Reset:
switch (KbootDriverState.phase) {

View File

@@ -25,6 +25,7 @@
kboot_command_t commandType;
uint8_t i2cAddress;
uint8_t phase;
uint32_t status;
} kboot_driver_state_t;
// Variables:

View File

@@ -57,6 +57,8 @@ static void slaveSchedulerCallback(I2C_Type *base, i2c_master_handle_t *handle,
uhk_slave_t *previousSlave = Slaves + previousSlaveId;
uhk_slave_t *currentSlave = Slaves + currentSlaveId;
previousSlave->previousStatus = previousStatus;
if (isFirstIteration) {
bool wasPreviousSlaveConnected = previousSlave->isConnected;
previousSlave->isConnected = previousStatus == kStatus_Success;

View File

@@ -13,6 +13,7 @@
SlaveId_RightAddon,
SlaveId_RightLedDriver,
SlaveId_LeftLedDriver,
SlaveId_KbootDriver,
} slave_id_t;
typedef void (slave_init_t)(uint8_t);
@@ -25,6 +26,7 @@
slave_update_t *update;
slave_disconnect_t *disconnect;
bool isConnected;
status_t previousStatus;
} uhk_slave_t;
typedef enum {

View File

@@ -11,7 +11,7 @@
// Macros:
#define BOOTLOADER_TAG 0x6766636B
#define BOOTLOADER_TIMEOUT_MS 3000
#define BOOTLOADER_TIMEOUT_MS 100
#define CLOCK_FLAG_HIGH_SPEED_MODE 0x01
#define DEFINE_BOOTLOADER_CONFIG_AREA(address) \