mirror of
https://github.com/silenty4ng/k5web
synced 2025-03-29 11:45:07 +00:00
bl24cm2a241fp max write 0x40
This commit is contained in:
parent
9f86780e4a
commit
1b3a67d213
8 changed files with 32 additions and 32 deletions
|
@ -194,8 +194,8 @@ const state : {
|
|||
const backupRange = async (start: any, end: any, name: any = new Date() + '_backup.bin') =>{
|
||||
await eeprom_init(appStore.connectPort);
|
||||
let rawEEPROM = new Uint8Array(end - start);
|
||||
for (let i = start; i < end; i += 0x80) {
|
||||
const data = await eeprom_read(appStore.connectPort, i, 0x80, appStore.configuration?.uart);
|
||||
for (let i = start; i < end; i += 0x40) {
|
||||
const data = await eeprom_read(appStore.connectPort, i, 0x40, appStore.configuration?.uart);
|
||||
rawEEPROM.set(data, i - start);
|
||||
}
|
||||
const blob = new Blob([rawEEPROM], { type: 'application/octet-stream' });
|
||||
|
@ -212,8 +212,8 @@ const backupRange = async (start: any, end: any, name: any = new Date() + '_back
|
|||
|
||||
const restoreRange = async (start: any = 0, uint8Array: any) => {
|
||||
await eeprom_init(appStore.connectPort);
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x80), uint8Array.slice(i - start, i - start + 0x80).length, appStore.configuration?.uart);
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x40), uint8Array.slice(i - start, i - start + 0x40).length, appStore.configuration?.uart);
|
||||
}
|
||||
await eeprom_reboot(appStore.connectPort);
|
||||
}
|
||||
|
|
|
@ -106,12 +106,12 @@
|
|||
}
|
||||
|
||||
const writeRange = async (start: any = 0, uint8Array: any, remark: string = '') => {
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x80), uint8Array.slice(i - start, i - start + 0x80).length, appStore.configuration?.uart);
|
||||
const checkData = await eeprom_read(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x80).length, appStore.configuration?.uart)
|
||||
if(!isEqual(uint8Array.slice(i - start, i - start + 0x80), checkData)) {
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x40), uint8Array.slice(i - start, i - start + 0x40).length, appStore.configuration?.uart);
|
||||
const checkData = await eeprom_read(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x40).length, appStore.configuration?.uart)
|
||||
if(!isEqual(uint8Array.slice(i - start, i - start + 0x40), checkData)) {
|
||||
state.status = state.status + remark + "检测到写入错误!!!" + "<br/>";
|
||||
i -= 0x80;
|
||||
i -= 0x40;
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -105,9 +105,9 @@ const checkEeprom = async () => {
|
|||
const clearEEPROM = async () => {
|
||||
if(appStore.connectState != true){alert(sessionStorage.getItem('noticeConnectK5')); return;};
|
||||
const eepromSize = await check_eeprom(appStore.connectPort, appStore.configuration?.uart);
|
||||
let rawEEPROM = new Uint8Array(0x80).fill(0xff);
|
||||
for (let i = 0; i < eepromSize; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM, 0x80, appStore.configuration?.uart);
|
||||
let rawEEPROM = new Uint8Array(0x40).fill(0xff);
|
||||
for (let i = 0; i < eepromSize; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM, 0x40, appStore.configuration?.uart);
|
||||
state.status = state.status + "清空进度:" + (((i - 0) / eepromSize) * 100).toFixed(1) + "%<br/>";
|
||||
nextTick(()=>{
|
||||
const textarea = document?.getElementById('statusArea');
|
||||
|
@ -120,8 +120,8 @@ const clearEEPROM = async () => {
|
|||
const backupRange = async (start: any, end: any, name: any = new Date() + '_backup.bin') =>{
|
||||
await eeprom_init(appStore.connectPort);
|
||||
let rawEEPROM = new Uint8Array(end - start);
|
||||
for (let i = start; i < end; i += 0x80) {
|
||||
const data = await eeprom_read(appStore.connectPort, i, 0x80, appStore.configuration?.uart);
|
||||
for (let i = start; i < end; i += 0x40) {
|
||||
const data = await eeprom_read(appStore.connectPort, i, 0x40, appStore.configuration?.uart);
|
||||
rawEEPROM.set(data, i - start);
|
||||
state.status = state.status + "备份进度:" + (((i - start) / rawEEPROM.length) * 100).toFixed(1) + "%<br/>";
|
||||
nextTick(()=>{
|
||||
|
@ -154,8 +154,8 @@ const restoreRange = async (start: any = 0) => {
|
|||
input.onchange = async() => {
|
||||
const blob = new Blob([input.files[0]], {type: 'application/octet-stream' });
|
||||
const rawEEPROM = new Uint8Array(await blob.arrayBuffer());
|
||||
for (let i = start; i < input.files[0].size + start; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM.slice(i - start, i - start + 0x80), rawEEPROM.slice(i - start, i - start + 0x80).length, appStore.configuration?.uart);
|
||||
for (let i = start; i < input.files[0].size + start; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM.slice(i - start, i - start + 0x40), rawEEPROM.slice(i - start, i - start + 0x40).length, appStore.configuration?.uart);
|
||||
state.status = state.status + "恢复进度:" + (((i - start) / input.files[0].size) * 100).toFixed(1) + "%<br/>";
|
||||
nextTick(()=>{
|
||||
const textarea = document?.getElementById('statusArea');
|
||||
|
|
|
@ -64,8 +64,8 @@ const state = reactive({
|
|||
|
||||
const restoreRange = async (start: any = 0, uint8Array: any) => {
|
||||
await eeprom_init(appStore.connectPort);
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x80), uint8Array.slice(i - start, i - start + 0x80).length, appStore.configuration?.uart);
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x40), uint8Array.slice(i - start, i - start + 0x40).length, appStore.configuration?.uart);
|
||||
state.status = state.status + "写入进度:" + (((i - start) / uint8Array.length) * 100).toFixed(1) + "%<br/>";
|
||||
nextTick(()=>{
|
||||
const textarea = document?.getElementById('statusArea');
|
||||
|
|
|
@ -215,8 +215,8 @@ const flashIt = async () => {
|
|||
if(appStore.configuration?.charset == "gb2312")position = 0x2080;
|
||||
await eeprom_init(appStore.connectPort);
|
||||
const rawEEPROM = state.binaryFile;
|
||||
for (let i = position; i < rawEEPROM.length + position; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM.slice(i - position, i - position + 0x80), rawEEPROM.slice(i - position, i - position + 0x80).length, appStore.configuration?.uart);
|
||||
for (let i = position; i < rawEEPROM.length + position; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM.slice(i - position, i - position + 0x40), rawEEPROM.slice(i - position, i - position + 0x40).length, appStore.configuration?.uart);
|
||||
}
|
||||
await eeprom_reboot(appStore.connectPort);
|
||||
state.loading = false
|
||||
|
|
|
@ -344,8 +344,8 @@ const handleOk = async () => {
|
|||
|
||||
const restoreRange = async (start: any = 0, uint8Array: any) => {
|
||||
await eeprom_init(appStore.connectPort);
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x80), 0x80, appStore.configuration?.uart);
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x40), 0x40, appStore.configuration?.uart);
|
||||
state.status = state.status + "写入进度:" + (((i - start) / uint8Array.length) * 100).toFixed(1) + "%<br/>";
|
||||
nextTick(() => {
|
||||
const textarea = document?.getElementById('statusArea');
|
||||
|
|
|
@ -420,8 +420,8 @@ const handleOk = async () => {
|
|||
|
||||
const restoreRange = async (start: any = 0, uint8Array: any) => {
|
||||
await eeprom_init(appStore.connectPort);
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x80), 0x80, appStore.configuration?.uart);
|
||||
for (let i = start; i < uint8Array.length + start; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, uint8Array.slice(i - start, i - start + 0x40), 0x40, appStore.configuration?.uart);
|
||||
state.status = state.status + "写入进度:" + (((i - start) / uint8Array.length) * 100).toFixed(1) + "%<br/>";
|
||||
nextTick(() => {
|
||||
const textarea = document?.getElementById('statusArea');
|
||||
|
|
|
@ -603,8 +603,8 @@
|
|||
await eeprom_init(appStore.connectPort);
|
||||
setLoading(true)
|
||||
let rawEEPROM = new Uint8Array(0x0C80);
|
||||
for (let i = 0; i < 0x0C80; i += 0x80) {
|
||||
const _data = await eeprom_read(appStore.connectPort, i, 0x80, appStore.configuration?.uart)
|
||||
for (let i = 0; i < 0x0C80; i += 0x40) {
|
||||
const _data = await eeprom_read(appStore.connectPort, i, 0x40, appStore.configuration?.uart)
|
||||
rawEEPROM.set(_data, i)
|
||||
}
|
||||
let rawEEPROM2 = new Uint8Array(0x0C0);
|
||||
|
@ -613,8 +613,8 @@
|
|||
rawEEPROM2.set(_data, i - 0x0D60)
|
||||
}
|
||||
let rawEEPROM3 = new Uint8Array(0x0C80);
|
||||
for (let i = 0x0F50; i < 0x1BD0; i += 0x80) {
|
||||
const _data = await eeprom_read(appStore.connectPort, i, 0x80, appStore.configuration?.uart)
|
||||
for (let i = 0x0F50; i < 0x1BD0; i += 0x40) {
|
||||
const _data = await eeprom_read(appStore.connectPort, i, 0x40, appStore.configuration?.uart)
|
||||
rawEEPROM3.set(_data, i - 0x0F50)
|
||||
}
|
||||
let x = 0;
|
||||
|
@ -757,12 +757,12 @@
|
|||
}
|
||||
i += 0x10
|
||||
})
|
||||
for (let i = 0; i < 0x0C80; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM.slice(i, i + 0x80), 0x80, appStore.configuration?.uart);
|
||||
for (let i = 0; i < 0x0C80; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM.slice(i, i + 0x40), 0x40, appStore.configuration?.uart);
|
||||
}
|
||||
await eeprom_write(appStore.connectPort, 0x0D60, rawEEPROM2, 0x0C8);
|
||||
for (let i = 0x0F50; i < 0x1BD0; i += 0x80) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM3.slice(i - 0x0F50, i - 0x0F50 + 0x80), 0x80, appStore.configuration?.uart);
|
||||
for (let i = 0x0F50; i < 0x1BD0; i += 0x40) {
|
||||
await eeprom_write(appStore.connectPort, i, rawEEPROM3.slice(i - 0x0F50, i - 0x0F50 + 0x40), 0x40, appStore.configuration?.uart);
|
||||
}
|
||||
await eeprom_reboot(appStore.connectPort);
|
||||
setLoading(false)
|
||||
|
|
Loading…
Add table
Reference in a new issue