support global and local chip erase
parent
af15110fa6
commit
aaacf6cea8
93
js/stm32.js
93
js/stm32.js
|
@ -396,58 +396,57 @@ STM32_protocol.prototype.upload_procedure = function(step) {
|
|||
break;
|
||||
case 4:
|
||||
// erase memory
|
||||
// EXPERIMENTAL
|
||||
console.log('Executing local erase (only needed pages)');
|
||||
STM32.GUI_status('Erasing');
|
||||
if (!$('input.erase_chip').is(':checked')) {
|
||||
// EXPERIMENTAL
|
||||
console.log('Executing local erase (only needed pages)');
|
||||
STM32.GUI_status('Erasing');
|
||||
|
||||
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
|
||||
if (self.verify_response(self.status.ACK, reply)) {
|
||||
// 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 erase_pages_n = Math.ceil(max_address / self.page_size);
|
||||
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
|
||||
if (self.verify_response(self.status.ACK, reply)) {
|
||||
// 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 erase_pages_n = Math.ceil(max_address / self.page_size);
|
||||
|
||||
var buff = [];
|
||||
buff.push(erase_pages_n - 1);
|
||||
var checksum = buff[0];
|
||||
for (var i = 0; i < erase_pages_n; i++) {
|
||||
buff.push(i);
|
||||
checksum ^= i;
|
||||
var buff = [];
|
||||
buff.push(erase_pages_n - 1);
|
||||
var checksum = buff[0];
|
||||
for (var i = 0; i < erase_pages_n; i++) {
|
||||
buff.push(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) {
|
||||
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>');
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
// proceed to next step
|
||||
self.upload_procedure(5);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// upload
|
||||
|
|
|
@ -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 />
|
||||
</p>
|
||||
<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 class="clear-both"></div>
|
||||
<div class="buttons">
|
||||
|
|
|
@ -200,6 +200,26 @@ function tab_initialize_firmware_flasher() {
|
|||
}).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) {
|
||||
if (typeof result.dev_mode !== 'undefined') {
|
||||
|
|
Loading…
Reference in New Issue