Merge pull request #895 from McGiverGim/bf-i18n_stm32driver

i18n stm32 driver
10.3.x-maintenance
Michael Keller 2018-01-30 00:55:43 +13:00 committed by GitHub
commit 3b59f397f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 120 additions and 47 deletions

View File

@ -237,6 +237,78 @@
"usbDeviceUdevNotice": {
"message": "Are <strong>udev rules</strong> installed correctly? See docs for instructions"
},
"stm32UsbDfuNotFound": {
"message": "USB DFU not found"
},
"stm32TimedOut": {
"message": "STM32 - timed out, programming: FAILED"
},
"stm32WrongResponse": {
"message": "STM32 Communication failed, wrong response, expected: $1 (0x$2) received: $3 (0x$4)"
},
"stm32ContactingBootloader": {
"message": "Contacting bootloader ..."
},
"stm32ContactingBootloaderFailed": {
"message": "Communication with bootloader failed"
},
"stm32ResponseBootloaderFailed": {
"message": "No response from the bootloader, programming: FAILED"
},
"stm32GlobalEraseExtended": {
"message": "Executing global chip erase (via extended erase) ..."
},
"stm32LocalEraseExtended": {
"message": "Executing local erase (via extended erase) ..."
},
"stm32GlobalErase": {
"message": "Executing global chip erase ..."
},
"stm32LocalErase": {
"message": "Executing local erase ..."
},
"stm32Erase": {
"message": "Erasing ..."
},
"stm32Flashing": {
"message": "Flashing ..."
},
"stm32Verifying": {
"message": "Verifying ..."
},
"stm32ProgrammingSuccessful": {
"message": "Programming: SUCCESSFUL"
},
"stm32ProgrammingFailed": {
"message": "Programming: FAILED"
},
"stm32AddressLoadFailed": {
"message": "Address load for option bytes sector failed. Very likely due to read protection."
},
"stm32AddressLoadSuccess": {
"message": "Address load for option bytes sector succeeded."
},
"stm32AddressLoadUnknown": {
"message": "Address load for option bytes sector failed with unknown error. Aborting."
},
"stm32NotReadProtected": {
"message": "Read protection not active"
},
"stm32ReadProtected": {
"message": "Board seems read protected. Unprotecting. Do not disconnect/unplug!"
},
"stm32UnprotectSuccessful": {
"message": "Unprotect successful."
},
"stm32UnprotectUnplug": {
"message": "ACTION REQUIRED: Unplug and re-connect flight controller in DFU mode to try flashing again!"
},
"stm32UnprotectFailed": {
"message": "Failed to unprotect board"
},
"stm32UnprotectInitFailed": {
"message": "Failed to initiate unprotect routine"
},
"noConfigurationReceived": {
"message": "No configuration received within <span class=\"message-negative\">10 seconds</span>, communication <span class=\"message-negative\">failed</span>"

View File

@ -81,7 +81,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
self.initialize();
} else {
GUI.log('<span style="color: red">Failed</span> to open serial port');
GUI.log(i18n.getMessage('serialPortOpenFail'));
}
});
} else {
@ -113,7 +113,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
self.initialize();
} else {
GUI.connect_lock = false;
GUI.log('<span style="color: red">Failed</span> to open serial port');
GUI.log(i18n.getMessage('serialPortOpenFail'));
}
});
}
@ -125,7 +125,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
});
});
} else {
GUI.log('<span style="color: red">Failed</span> to open serial port');
GUI.log(i18n.getMessage('serialPortOpenFail'));
}
});
}
@ -160,7 +160,7 @@ STM32_protocol.prototype.initialize = function () {
} else {
console.log('STM32 - timed out, programming failed ...');
$('span.progressLabel').text('STM32 - timed out, programming: FAILED');
$('span.progressLabel').text(i18n.getMessage('stm32TimedOut'));
self.progress_bar_e.addClass('invalid');
// protocol got stuck, clear timer and disconnect
@ -243,7 +243,7 @@ STM32_protocol.prototype.verify_response = function (val, data) {
if (val != data[0]) {
var message = 'STM32 Communication failed, wrong response, expected: ' + val + ' (0x' + val.toString(16) + ') received: ' + data[0] + ' (0x' + data[0].toString(16) + ')';
console.error(message);
$('span.progressLabel').text(message);
$('span.progressLabel').text(i18n.getMessage('stm32WrongResponse',[val, val.toString(16), data[0], data[0].toString(16)]));
self.progress_bar_e.addClass('invalid');
// disconnect
@ -356,7 +356,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
switch (step) {
case 1:
// initialize serial interface on the MCU side, auto baud rate settings
$('span.progressLabel').text('Contacting bootloader ...');
$('span.progressLabel').text(i18n.getMessage('stm32ContactingBootloader'));
var send_counter = 0;
GUI.interval_add('stm32_initialize_mcu', function () { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement
@ -368,7 +368,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
// proceed to next step
self.upload_procedure(2);
} else {
$('span.progressLabel').text('Communication with bootloader failed');
$('span.progressLabel').text(i18n.getMessage('stm32ContactingBootloaderFailed'));
self.progress_bar_e.addClass('invalid');
GUI.interval_remove('stm32_initialize_mcu');
@ -382,7 +382,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
// stop retrying, its too late to get any response from MCU
console.log('STM32 - no response from bootloader, disconnecting');
$('span.progressLabel').text('No response from the bootloader, programming: FAILED');
$('span.progressLabel').text(i18n.getMessage('stm32ResponseBootloaderFailed'));
self.progress_bar_e.addClass('invalid');
GUI.interval_remove('stm32_initialize_mcu');
@ -435,7 +435,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
var message = 'Executing global chip erase (via extended erase)';
console.log(message);
$('span.progressLabel').text(message + ' ...');
$('span.progressLabel').text(i18n.getMessage('stm32GlobalEraseExtended'));
self.send([self.command.extended_erase, 0xBB], 1, function (reply) {
if (self.verify_response(self.status.ACK, reply)) {
@ -451,7 +451,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
} else {
var message = 'Executing local erase (via extended erase)';
console.log(message);
$('span.progressLabel').text(message + ' ...');
$('span.progressLabel').text(i18n.getMessage('stm32LocalEraseExtended'));
self.send([self.command.extended_erase, 0xBB], 1, function (reply) {
if (self.verify_response(self.status.ACK, reply)) {
@ -503,7 +503,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
if (self.options.erase_chip) {
var message = 'Executing global chip erase' ;
console.log(message);
$('span.progressLabel').text(message + ' ...');
$('span.progressLabel').text(i18n.getMessage('stm32GlobalErase'));
self.send([self.command.erase, 0xBC], 1, function (reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
@ -519,7 +519,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
} else {
var message = 'Executing local erase';
console.log(message);
$('span.progressLabel').text(message + ' ...');
$('span.progressLabel').text(i18n.getMessage('stm32LocalErase'));
self.send([self.command.erase, 0xBC], 1, function (reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
@ -552,7 +552,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
case 5:
// upload
console.log('Writing data ...');
$('span.progressLabel').text('Flashing ...');
$('span.progressLabel').text(i18n.getMessage('stm32Flashing'));
var blocks = self.hex.data.length - 1,
flashing_block = 0,
@ -627,7 +627,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
case 6:
// verify
console.log('Verifying data ...');
$('span.progressLabel').text('Verifying ...');
$('span.progressLabel').text(i18n.getMessage('stm32Verifying'));
var blocks = self.hex.data.length - 1,
reading_block = 0,
@ -699,7 +699,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
if (verify) {
console.log('Programming: SUCCESSFUL');
$('span.progressLabel').text('Programming: SUCCESSFUL');
$('span.progressLabel').text(i18n.getMessage('stm32ProgrammingSuccessful'));
// update progress bar
self.progress_bar_e.addClass('valid');
@ -708,7 +708,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
self.upload_procedure(7);
} else {
console.log('Programming: FAILED');
$('span.progressLabel').text('Programming: FAILED');
$('span.progressLabel').text(i18n.getMessage('stm32ProgrammingFailed'));
// update progress bar
self.progress_bar_e.addClass('invalid');

View File

@ -95,7 +95,7 @@ STM32DFU_protocol.prototype.connect = function (device, hex, options, callback)
self.openDevice(result[0]);
} else {
console.log('USB DFU not found');
GUI.log('USB DFU not found');
GUI.log(i18n.getMessage('stm32UsbDfuNotFound'));
}
});
};
@ -541,8 +541,8 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
var unprotect = function() {
console.log('Initiate read unprotect');
GUI.log('Chip seems read protected. Initiating read unprotect');
$('span.progressLabel').text('Board seems read protected. Unprotecting. Do not disconnect/unplug!');
GUI.log(i18n.getMessage('stm32ReadProtected'));
$('span.progressLabel').text(i18n.getMessage('stm32ReadProtected'));
self.progress_bar_e.addClass('actionRequired');
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x92], function () { // 0x92 initiates read unprotect
@ -563,14 +563,15 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data, error) { // should stall/disconnect
if(error) { // we encounter an error, but this is expected. should be a stall.
console.log('Unprotect memory command ran successfully. Unplug flight controller. Connect again in DFU mode and try flashing again.');
GUI.log('Unprotect successful. ACTION REQUIRED: Unplug and re-connect flight controller in DFU mode to try flashing again!');
$('span.progressLabel').text('ACTION REQUIRED: Unplug and re-connect flight controller in DFU mode to try flashing again!');
GUI.log(i18n.getMessage('stm32UnprotectSuccessful'));
GUI.log(i18n.getMessage('stm32UnprotectUnplug'));
$('span.progressLabel').text(i18n.getMessage('stm32UnprotectUnplug'));
self.progress_bar_e.val(0);
self.progress_bar_e.addClass('actionRequired');
} else { // unprotecting the flight controller did not work. It did not reboot.
console.log('Failed to execute unprotect memory command');
GUI.log('Failed to unprotect chip');
$('span.progressLabel').text('Failed to unprotect board');
GUI.log(i18n.getMessage('stm32UnprotectFailed'));
$('span.progressLabel').text(i18n.getMessage('stm32UnprotectFailed'));
self.progress_bar_e.addClass('invalid');
console.log(data);
self.upload_procedure(99);
@ -579,8 +580,8 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
}, incr);
} else {
console.log('Failed to initiate unprotect memory command');
GUI.log('Failed to initiate unprotect routine');
$('span.progressLabel').text('Failed to initate unprotect');
GUI.log(i18n.getMessage('stm32UnprotectInitFailed'));
$('span.progressLabel').text(i18n.getMessage('stm32UnprotectInitFailed'));
self.progress_bar_e.addClass('invalid');
self.upload_procedure(99);
}
@ -601,7 +602,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if (data[4] == self.state.dfuUPLOAD_IDLE && ob_data.length == self.chipInfo.option_bytes.total_size) {
console.log('Option bytes read successfully');
console.log('Chip does not appear read protected');
GUI.log('Read protection not active');
GUI.log(i18n.getMessage('stm32NotReadProtected'));
// it is pretty safe to continue to erase flash
self.clearStatus(function() {
self.upload_procedure(2);
@ -645,22 +646,22 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
});
}
var initReadOB = function (loadAddressResponse) {
// contrary to what is in the docs. Address load should in theory work even if read protection is active
// if address load fails with this specific error though, it is very likely bc of read protection
if(loadAddressResponse[4] == self.state.dfuERROR && loadAddressResponse[0] == self.status.errVENDOR) {
// read protected
GUI.log('Address load for option bytes sector failed. Very likely due to read protection.');
self.clearStatus(unprotect);
return;
} else if(loadAddressResponse[4] == self.state.dfuDNLOAD_IDLE) {
console.log('Address load for option bytes sector succeeded.');
self.clearStatus(tryReadOB);
} else {
GUI.log('Address load for option bytes sector failed with unknown error. Aborting.');
self.upload_procedure(99);
}
}
var initReadOB = function (loadAddressResponse) {
// contrary to what is in the docs. Address load should in theory work even if read protection is active
// if address load fails with this specific error though, it is very likely bc of read protection
if(loadAddressResponse[4] == self.state.dfuERROR && loadAddressResponse[0] == self.status.errVENDOR) {
// read protected
GUI.log(i18n.getMessage('stm32AddressLoadFailed'));
self.clearStatus(unprotect);
return;
} else if(loadAddressResponse[4] == self.state.dfuDNLOAD_IDLE) {
console.log('Address load for option bytes sector succeeded.');
self.clearStatus(tryReadOB);
} else {
GUI.log(i18n.getMessage('stm32AddressLoadUnknown'));
self.upload_procedure(99);
}
}
self.clearStatus(function () {
// load address fails if read protection is active unlike as stated in the docs
@ -696,7 +697,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
}
}
}
$('span.progressLabel').text('Erasing ...');
$('span.progressLabel').text(i18n.getMessage('stm32Erase'));
console.log('Executing local chip erase');
var page = 0;
@ -751,7 +752,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
// upload
// we dont need to clear the state as we are already using DFU_DNLOAD
console.log('Writing data ...');
$('span.progressLabel').text('Flashing ...');
$('span.progressLabel').text(i18n.getMessage('stm32Flashing'));
var blocks = self.hex.data.length - 1;
var flashing_block = 0;
@ -823,7 +824,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
case 5:
// verify
console.log('Verifying data ...');
$('span.progressLabel').text('Verifying ...');
$('span.progressLabel').text(i18n.getMessage('stm32Verifying'));
var blocks = self.hex.data.length - 1;
var reading_block = 0;
@ -890,7 +891,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if (verify) {
console.log('Programming: SUCCESSFUL');
$('span.progressLabel').text('Programming: SUCCESSFUL');
$('span.progressLabel').text(i18n.getMessage('stm32ProgrammingSuccessful'));
// update progress bar
self.progress_bar_e.addClass('valid');
@ -899,7 +900,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
self.upload_procedure(6);
} else {
console.log('Programming: FAILED');
$('span.progressLabel').text('Programming: FAILED');
$('span.progressLabel').text(i18n.getMessage('stm32ProgrammingFailed'));
// update progress bar
self.progress_bar_e.addClass('invalid');