1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 11:59:51 +03:00

support global and local chip erase

This commit is contained in:
cTn 2014-05-07 08:07:49 +02:00
parent af15110fa6
commit aaacf6cea8
3 changed files with 68 additions and 48 deletions

View file

@ -396,58 +396,57 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break; break;
case 4: case 4:
// erase memory // erase memory
// EXPERIMENTAL if (!$('input.erase_chip').is(':checked')) {
console.log('Executing local erase (only needed pages)'); // EXPERIMENTAL
STM32.GUI_status('Erasing'); console.log('Executing local erase (only needed pages)');
STM32.GUI_status('Erasing');
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
// the bootloader receives one byte that contains N, the number of pages to be erased 1 // the bootloader receives one byte that contains N, the number of pages to be erased 1
var max_address = self.hex.data[self.hex.data.length - 1].address + self.hex.data[self.hex.data.length - 1].bytes - 0x8000000; var max_address = self.hex.data[self.hex.data.length - 1].address + self.hex.data[self.hex.data.length - 1].bytes - 0x8000000;
var erase_pages_n = Math.ceil(max_address / self.page_size); var erase_pages_n = Math.ceil(max_address / self.page_size);
var buff = []; var buff = [];
buff.push(erase_pages_n - 1); buff.push(erase_pages_n - 1);
var checksum = buff[0]; var checksum = buff[0];
for (var i = 0; i < erase_pages_n; i++) { for (var i = 0; i < erase_pages_n; i++) {
buff.push(i); buff.push(i);
checksum ^= i; checksum ^= i;
}
buff.push(checksum);
self.send(buff, 1, function(reply) {
if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done');
console.log('Writing data ...');
STM32.GUI_status('<span style="color: green">Flashing ...</span>');
// proceed to next step
self.upload_procedure(5);
}
});
} }
buff.push(checksum); });
} else {
console.log('Executing global chip erase');
STM32.GUI_status('Erasing');
self.send(buff, 1, function(reply) { self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done'); self.send([0xFF, 0x00], 1, function(reply) {
console.log('Writing data ...'); if (self.verify_response(self.status.ACK, reply)) {
STM32.GUI_status('<span style="color: green">Flashing ...</span>'); console.log('Erasing: done');
console.log('Writing data ...');
STM32.GUI_status('<span style="color: green">Flashing ...</span>');
// proceed to next step // proceed to next step
self.upload_procedure(5); self.upload_procedure(5);
} }
}); });
} }
}); });
}
// OLD BUT GOLD
/*
console.log('Executing global chip erase');
STM32.GUI_status('Erasing');
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
self.send([0xFF, 0x00], 1, function(reply) {
if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done');
console.log('Writing data ...');
STM32.GUI_status('<span style="color: green">Flashing ...</span>');
// proceed to next step
self.upload_procedure(5);
}
});
}
});
*/
break; break;
case 5: case 5:
// upload // upload

View file

@ -11,7 +11,8 @@
If you are flashing "<strong>bare</strong>" board with no firmware preloaded or you have bootloader pins <strong>shorted</strong>, check this box.<br /> If you are flashing "<strong>bare</strong>" board with no firmware preloaded or you have bootloader pins <strong>shorted</strong>, check this box.<br />
</p> </p>
<label><input class="updating" type="checkbox" /><span style="font-weight: bold; margin-left: 6px;">No reboot sequence</span></label><br /> <label><input class="updating" type="checkbox" /><span style="font-weight: bold; margin-left: 6px;">No reboot sequence</span></label><br />
<label class="flash_on_connect_wrapper"><input class="flash_on_connect" type="checkbox" /><span style="font-weight: bold; margin-left: 6px;">Flash on connect</span></label> <label class="flash_on_connect_wrapper"><input class="flash_on_connect" type="checkbox" /><span style="font-weight: bold; margin-left: 6px;">Flash on connect</span><br /></label>
<label><input class="erase_chip" type="checkbox" /><span style="font-weight: bold; margin-left: 6px;">Full Chip Erase</span></label><br />
</div> </div>
<div class="clear-both"></div> <div class="clear-both"></div>
<div class="buttons"> <div class="buttons">

View file

@ -200,6 +200,26 @@ function tab_initialize_firmware_flasher() {
}).change(); }).change();
}); });
chrome.storage.local.get('erase_chip', function(result) {
if (typeof result.erase_chip === 'undefined') {
// wasn't saved yet
$('input.updating').prop('checked', false);
} else {
if (result.erase_chip) {
$('input.erase_chip').prop('checked', true);
} else {
$('input.erase_chip').prop('checked', false);
}
}
// bind UI hook so the status is saved on change
$('input.erase_chip').change(function() {
var status = $(this).is(':checked');
chrome.storage.local.set({'erase_chip': status});
});
});
/* /*
chrome.storage.local.get('dev_mode', function(result) { chrome.storage.local.get('dev_mode', function(result) {
if (typeof result.dev_mode !== 'undefined') { if (typeof result.dev_mode !== 'undefined') {