“线程:BQSTUDIO”中讨论的其它部件
您好,
我正在创建一些在嵌入式 Linux 系统上运行的软件,以更新电池化学特性以及现场设备上的一些其他参数,而无需硬件访问。 我一直在关注 SLUA801,我已经了解到似乎正在发生的事情,但一旦我通过程序员运行闪存流文件,量表似乎就卡在 ROM 模式下,我似乎无法恢复它。 此外,该程序的执行速度似乎太快,完全忽略了睡眠定时器。
我使用 BQ-studio 获得了 FS 文件,只是下载了我正在测试的芯片的 DFFS 文件。也就是说,没有任何参数的实际变化-我只是想看看我是否可以读写它。
FS 文件:
;-------------------------------------------------------- ;Verify Existing Firmware Version ;-------------------------------------------------------- W: AA 00 01 00 C: AA 00 20 05 W: AA 00 02 00 C: AA 00 29 03 ;-------------------------------------------------------- ;Unseal device ;-------------------------------------------------------- W: AA 00 14 04 W: AA 00 72 36 W: AA 00 FF FF W: AA 00 FF FF X: 1000 ;-------------------------------------------------------- ;Go To ROM Mode ;-------------------------------------------------------- W: AA 00 00 0F X: 1000 ;-------------------------------------------------------- ;Data Block ;-------------------------------------------------------- W: 16 00 03 00 00 W: 16 64 03 00 X: 20 C: 16 66 00 W: 16 00 02 00 00 00 EA FF 33 06 FA 33 8C FA 33 39 FE 33 41 FE 33 FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F 29 03 3F 58 CB 33 C1 00 08 00 00 00 00 00 00 FF AA 0E FB A7 0E FF A6 0E FF A1 0E FF A0 0E FE A3 0E 6C A2 0E D2 FF 3A FF A1 0E 63 A0 0E FF A3 0E W: 16 64 C9 34 X: 2 C: 16 66 00 W: 16 00 02 01 00 00 61 A2 0E BD A5 0E 13 A4 0E CA FF 3A FE A1 0E 6C A0 0E FE A3 0E 6C A2 0E CA FF 3A C2 FF 3A D6 FF 33 FF AF 0E 01 4F 03 3F 11 0C CD FF 30 D4 FF 35 2F 10 0C D4 FF 35 FF FF 23 01 AF 14 01 4F 03 3F 11 0C C5 FF 30 CC FF 35 2F 10 0C CC FF 35 FF FF 23 FF DF 0B C4 FF 33 A4 F6 39 FE AF 16 C1 AB 0E W: 16 64 89 2E X: 2 C: 16 66 00 W: 16 00 05 W: 16 64 05 00 X: 170 C: 16 66 00 C: 16 04 36 FC 4F 9F W: 16 00 0C 00 00 00 83 DE W: 16 64 6D 01 X: 400 C: 16 66 00 W: 16 00 0A 00 00 00 7F 74 1F 21 94 0A 9C 08 FA B8 00 4C 00 00 00 00 0B B8 10 68 0B A4 03 E8 00 20 03 E8 00 20 00 20 W: 16 64 9D 08 X: 2 C: 16 66 00 W: 16 00 0A 01 00 00 10 96 00 D4 86 4A C6 B4 C2 6E 2B 03 7C 01 48 FD A3 F6 75 12 58 2D B7 2C 4A 00 00 00 00 CF DC 17 W: 16 64 83 0C X: 2 C: 16 66 00 W: 16 00 0A 02 00 00 F3 00 00 17 F3 00 00 3A 36 FD 91 00 25 30 01 00 EF 05 11 05 01 00 00 10 01 00 3C 00 50 3C 00 64 W: 16 64 A5 06 X: 2 C: 16 66 00 W: 16 00 0A 03 00 00 3C 00 20 01 00 03 E8 00 05 00 03 E8 00 00 00 FE D5 FB 95 00 02 02 BC 00 14 03 E8 10 62 10 68 01 W: 16 64 52 08 X: 2 C: 16 66 00 W: 16 00 0A 04 00 00 01 02 BC 01 2C 00 1E 00 C8 C8 14 10 00 3C 0E 10 00 0A 46 05 0F 07 0F 03 20 00 64 46 50 0A 0F F0 W: 16 64 C6 05 X: 2 C: 16 66 00 W: 16 00 0A 05 00 00 0F D0 01 90 00 64 19 DC 5C 60 00 7D 00 04 03 19 25 5A 0F 14 60 6E 0C 80 00 C8 28 01 F4 00 00 00 W: 16 64 12 08 X: 2 C: 16 66 00 W: 16 00 0A 06 00 00 00 00 00 00 00 00 00 43 80 04 00 00 01 14 00 2C 05 00 0A 13 88 00 C8 0A 23 61 03 E8 00 10 60 C9 W: 16 64 3C 05 X: 2 C: 16 66 00 W: 16 00 0A 07 00 00 D7 F6 F5 F8 F6 DE EA D7 E8 E9 EA F0 E2 E3 E5 E3 E6 E7 E9 E9 F0 EB ED E9 E7 E5 E3 DF EC EF E2 BC W: 16 64 EF 1C X: 2 C: 16 66 00 W: 16 00 0A 08 00 00 9F B1 B7 E9 DD A4 00 F3 CD 04 0E 0A 92 CB 24 D6 1D 74 DA 4D 92 D7 DD 50 D1 BE 13 EB FE F9 FC 0F W: 16 64 93 12 X: 2 C: 16 66 00 W: 16 00 0A 09 00 00 FF F7 AD 09 C5 BC A0 D3 FD 6B DD 3E 3B DC 7D D1 C9 CB 53 AA BA AA 98 29 3F 9E 78 C2 10 B0 00 7B W: 16 64 A3 12 X: 2 C: 16 66 00 W: 16 00 0A 0A 00 00 2D 5D D2 4F 1E D3 60 F0 FF 55 00 14 01 01 03 05 F8 03 FF 03 10 24 28 1E 2C 77 7F 00 00 FF D0 00 W: 16 64 DA 0A X: 2 C: 16 66 00 W: 16 00 0A 0B 00 00 FA EF ED 2A F2 00 3D 03 12 EF EE FE 05 DA 00 00 FE E9 00 03 1D 33 B1 19 F7 00 43 2D FA 9E 88 11 W: 16 64 AF 0E X: 2 C: 16 66 00 W: 16 00 0A 0C 00 00 6D 23 61 03 E8 00 10 60 C9 D7 F6 F5 F8 F6 DE EA D7 E8 E9 EA F0 E2 E3 E5 E3 E6 E7 E9 E9 F0 EB ED W: 16 64 19 18 X: 2 C: 16 66 00 W: 16 00 0A 0D 00 00 E9 E7 E5 E3 DF EC EF E2 BC 9F B1 B7 E9 DD A4 00 F3 CD 04 0E 0A 92 CB 24 D6 1D 74 DA 4D 92 D7 DD W: 16 64 A9 14 X: 2 C: 16 66 00 W: 16 00 0A 0E 00 00 50 D1 BE 13 EB FE F9 FC 0F FF F7 AD 09 C5 BC A0 D3 FD 6B DD 3E 3B DC 7D D1 C9 CB 53 AA BA AA 98 W: 16 64 0C 15 X: 2 C: 16 66 00 W: 16 00 0A 0F 00 00 29 3F 9E 78 C2 10 B0 00 7B 2D 5D D2 4F 1E D3 60 F0 FF 55 00 14 01 01 03 05 F8 03 FF 03 10 24 28 W: 16 64 4B 0B X: 2 C: 16 66 00 W: 16 00 0A 10 00 00 1E 2C 77 7F 00 00 FF D0 00 FA EF ED 2A F2 00 3D 03 12 EF EE FE 05 DA 00 00 FE E9 00 03 1D 33 B1 W: 16 64 12 0E X: 2 C: 16 66 00 W: 16 00 0A 11 00 00 19 F7 00 43 2D FA 9E 88 11 6D 00 00 01 C2 00 32 00 C8 10 68 00 32 FF CE 02 26 00 00 01 18 00 19 W: 16 64 C7 08 X: 2 C: 16 66 00 W: 16 00 0A 12 00 00 00 64 28 63 5F FF 62 00 32 09 73 04 2E 00 6E 14 01 04 00 00 4A 2C 5E 00 09 04 00 00 14 0A F0 0B W: 16 64 2C 06 X: 2 C: 16 66 00 W: 16 00 0A 13 00 00 B8 00 0A 05 00 32 01 C2 14 14 00 08 09 F6 00 C8 00 4B 00 82 00 3C 3C 01 80 80 01 90 36 72 04 14 W: 16 64 67 07 X: 2 C: 16 66 00 W: 16 00 0A 14 00 00 FF FF FF FF 02 26 02 01 F4 02 58 02 02 26 00 00 00 A7 14 65 89 01 F4 00 00 64 01 B0 F6 FE 0C 03 W: 16 64 73 0B X: 2 C: 16 66 00 W: 16 00 0A 15 00 00 84 5A 0D AC 01 FE 70 0B A6 07 62 71 32 37 35 32 30 00 00 00 96 00 AF 00 4B 00 64 32 0C 4E 02 0D W: 16 64 3F 08 X: 2 C: 16 66 00 W: 16 00 0A 16 00 00 48 0C 1C 02 00 00 00 00 FE D5 FB 95 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 W: 16 64 F5 03 X: 2 C: 16 66 00 W: 16 00 0A 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF W: 16 64 0E 13 X: 2 C: 16 66 00 W: 16 00 0A 18 00 00 FF 55 00 14 01 01 03 05 F8 03 FF 03 10 24 28 1E 2C 77 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 W: 16 64 2D 05 X: 2 C: 16 66 00 W: 16 00 0A 19 00 00 FF 55 00 14 01 01 03 05 F8 03 FF 03 10 24 28 1E 2C 77 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 W: 16 64 2E 05 X: 2 C: 16 66 00 W: 16 00 0A 1A 00 00 FF FF 00 14 01 01 03 05 F8 03 FF 03 10 24 28 1E 2C 77 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 W: 16 64 D9 05 X: 2 C: 16 66 00 W: 16 00 0A 1B 00 00 FF FF 00 14 01 01 03 05 F8 03 FF 03 10 24 28 1E 2C 77 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 W: 16 64 DA 05 X: 2 C: 16 66 00 W: 16 00 0A 1C 00 00 F3 00 00 17 F3 00 00 3A 36 FD 91 00 25 30 01 00 EF 05 11 05 01 00 00 10 01 00 3C 00 50 3C 00 64 W: 16 64 BF 06 X: 2 C: 16 66 00 W: 16 00 0A 1D 00 00 3C 00 20 01 00 03 E8 00 05 00 03 E8 00 00 00 FE D5 FB 95 00 02 02 BC 00 14 03 E8 10 62 10 68 01 W: 16 64 6C 08 X: 2 C: 16 66 00 W: 16 00 0A 1E 00 00 FF FF FF FF 00 00 00 51 FF FF FF AD FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF W: 16 64 0B 1C X: 2 C: 16 66 00 W: 16 00 0A 1F 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF W: 16 64 09 20 X: 2 C: 16 66 00 W: 16 00 08 W: 16 64 08 00 X: 2 C: 16 66 00 C: 16 04 30 8D W: 16 00 05 W: 16 64 05 00 X: 170 C: 16 66 00 C: 16 04 36 FC 4F 9F W: 16 00 01 00 00 05 54 54 15 W: 16 64 C3 00 X: 20 C: 16 66 00 W: 16 00 05 W: 16 64 05 00 X: 170 C: 16 66 00 C: 16 04 8B 50 25 9F ;-------------------------------------------------------- ;Execute Flash Code ;-------------------------------------------------------- W: 16 00 0F W: 16 64 0F 00 X: 4000
我的编程器的输出是:
openend I2C bus FW_VERSION = 0x0000 VOLTAGE = 7432 [mV] CONTROL_STATUS = 0x0000 source file 'test.df.fs', size = 6748 W:AA000200 C:AA002903 ;-------------------------------------------------------- ;Unsealdevice ;-------------------------------------------------------- W:AA001404 W:AA007236 W:AA00FFFF W:AA00FFFF X:1000 ;-------------------------------------------------------- ;GoToROMMode ;-------------------------------------------------------- W:AA00000F X:1000 ;-------------------------------------------------------- ;DataBlock ;-------------------------------------------------------- W:1600030000 W:16640300 X:20 C:166600 W:160002000000EAFF3306FA338CFA3339FE3341FE33FFFF3FFFFF3FFFFF3FFFFF3FFFFF3FFFFF3FFFFF3FFFFF3FFFFF3FFFFF3FFFFF3F29033F58CB33C10008000000000000FFAA0EFBA70EFFA60EFFA10EFFA00EFEA30E6CA20ED2FF3AFFA10E63A00EFFA30E W:1664C934 X:2 C:166600 W:16000201000061A20EBDA50E13A40ECAFF3AFEA10E6CA00EFEA30E6CA20ECAFF3AC2FF3AD6FF33FFAF0E014F033F110CCDFF30D4FF352F100CD4FF35FFFF2301AF14014F033F110CC5FF30CCFF352F100CCCFF35FFFF23FFDF0BC4FF33A4F639FEAF16C1AB0E W:1664892E X:2 C:166600 W:160005 W:16640500 X:170 C:166600 C:160436FC4F9F W:16000C00000083DE W:16646D01 X:400 C:166600 W:16000A0000007F741F21940A9C08FAB8004C000000000BB810680BA403E8002003E800200020 W:16649D08 X:2 C:166600 W:16000A010000109600D4864AC6B4C26E2B037C0148FDA3F67512582DB72C4A00000000CFDC17 W:1664830C X:2 C:166600 W:16000A020000F3000017F300003A36FD910025300100EF0511050100001001003C00503C0064 W:1664A506 X:2 C:166600 W:16000A0300003C0020010003E800050003E8000000FED5FB95000202BC001403E81062106801 W:16645208 X:2 C:166600 W:16000A0400000102BC012C001E00C8C81410003C0E10000A46050F070F0320006446500A0FF0 W:1664C605 X:2 C:166600 W:16000A0500000FD00190006419DC5C60007D00040319255A0F14606E0C8000C82801F4000000 W:16641208 X:2 C:166600 W:16000A0600000000000000000043800400000114002C05000A138800C80A236103E8001060C9 W:16643C05 X:2 C:166600 W:16000A070000D7F6F5F8F6DEEAD7E8E9EAF0E2E3E5E3E6E7E9E9F0EBEDE9E7E5E3DFECEFE2BC W:1664EF1C X:2 C:166600 W:16000A0800009FB1B7E9DDA400F3CD040E0A92CB24D61D74DA4D92D7DD50D1BE13EBFEF9FC0F W:16649312 X:2 C:166600 W:16000A090000FFF7AD09C5BCA0D3FD6BDD3E3BDC7DD1C9CB53AABAAA98293F9E78C210B0007B W:1664A312 X:2 C:166600 W:16000A0A00002D5DD24F1ED360F0FF55001401010305F803FF031024281E2C777F0000FFD000 W:1664DA0A X:2 C:166600 W:16000A0B0000FAEFED2AF2003D0312EFEEFE05DA0000FEE900031D33B119F700432DFA9E8811 W:1664AF0E X:2 C:166600 W:16000A0C00006D236103E8001060C9D7F6F5F8F6DEEAD7E8E9EAF0E2E3E5E3E6E7E9E9F0EBED W:16641918 X:2 C:166600 W:16000A0D0000E9E7E5E3DFECEFE2BC9FB1B7E9DDA400F3CD040E0A92CB24D61D74DA4D92D7DD W:1664A914 X:2 C:166600 W:16000A0E000050D1BE13EBFEF9FC0FFFF7AD09C5BCA0D3FD6BDD3E3BDC7DD1C9CB53AABAAA98 W:16640C15 X:2 C:166600 W:16000A0F0000293F9E78C210B0007B2D5DD24F1ED360F0FF55001401010305F803FF03102428 W:16644B0B X:2 C:166600 W:16000A1000001E2C777F0000FFD000FAEFED2AF2003D0312EFEEFE05DA0000FEE900031D33B1 W:1664120E X:2 C:166600 W:16000A11000019F700432DFA9E88116D000001C2003200C810680032FFCE0226000001180019 W:1664C708 X:2 C:166600 W:16000A120000006428635FFF6200320973042E006E14010400004A2C5E0009040000140AF00B W:16642C06 X:2 C:166600 W:16000A130000B8000A05003201C21414000809F600C8004B0082003C3C018080019036720414 W:16646707 X:2 C:166600 W:16000A140000FFFFFFFF02260201F40258020226000000A714658901F400006401B0F6FE0C03 W:1664730B X:2 C:166600 W:16000A150000845A0DAC01FE700BA607627132373532300000009600AF004B0064320C4E020D W:16643F08 X:2 C:166600 W:16000A160000480C1C0200000000FED5FB950000000000000000000000000000000000000000 W:1664F503 X:2 C:166600 W:16000A17000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF W:16640E13 X:2 C:166600 W:16000A180000FF55001401010305F803FF031024281E2C777F00000000000000000000000000 W:16642D05 X:2 C:166600 W:16000A190000FF55001401010305F803FF031024281E2C777F00000000000000000000000000 W:16642E05 X:2 C:166600 W:16000A1A0000FFFF001401010305F803FF031024281E2C777F00000000000000000000000000 W:1664D905 X:2 C:166600 W:16000A1B0000FFFF001401010305F803FF031024281E2C777F00000000000000000000000000 W:1664DA05 X:2 C:166600 W:16000A1C0000F3000017F300003A36FD910025300100EF0511050100001001003C00503C0064 W:1664BF06 X:2 C:166600 W:16000A1D00003C0020010003E800050003E8000000FED5FB95000202BC001403E81062106801 W:16646C08 X:2 C:166600 W:16000A1E0000FFFFFFFF00000051FFFFFFADFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF W:16640B1C X:2 C:166600 W:16000A1F0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF W:16640920 X:2 C:166600 W:160008 W:16640800 X:2 C:166600 C:1604308D W:160005 W:16640500 X:170 C:166600 C:160436FC4F9F W:160001000005545415 W:1664C300 X:20 C:166600 W:160005 W:16640500 X:170 C:166600 C:16048B50259F ;-------------------------------------------------------- ;ExecuteFlashCode ;-------------------------------------------------------- W:16000F W:16640F00 X:4000 ��closed I2C bus
之后,设备在地址0xAA 处无响应,只响应0x16,即似乎卡在 ROM 模式下。
根据 SLUA541:
但是,设备似乎没有退出 ROM 模式,尝试手动执行上述命令步骤也不会产生任何结果-设备在 AA 上仍无响应,实际上根本不会写入0x00:
上传 FS 文件的功能:
char *gauge_execute_fs(void *pHandle, char *pFS) { int nLength = _strlen(pFS); int nDataLength; char pBuf[16]; char pData[32]; int n, m; char *pEnd = NULL; char *pErr; bool bWriteCmd = false; unsigned char nRegister; m = 0; for (n = 0; n < nLength; n++) if (pFS[n] != ' ') pFS[m++] = pFS[n]; pEnd = pFS + m; pEnd[0] = 0; do { switch (*pFS) { case ';': break; case 'W': case 'C': bWriteCmd = *pFS == 'W'; pFS++; if ((*pFS) != ':') return pFS; pFS++; n = 0; while ((pEnd - pFS > 2) && (n < sizeof(pData) + 2) &&(*pFS != '\n')) { pBuf[0] = *(pFS++); pBuf[1] = *(pFS++); pBuf[2] = 0; m = strtoul(pBuf, &pErr, 16); if (*pErr) return (pFS - 2); if (n == 0) gauge_address(pHandle, m); if (n == 1) nRegister = m; if (n > 1) pData[n - 2] = m; n++; } if (n < 3) return pFS; nDataLength = n - 2; if (bWriteCmd) gauge_write(pHandle, nRegister, pData, nDataLength); else { char pDataFromGauge[nDataLength]; gauge_read(pHandle, nRegister, pDataFromGauge, nDataLength); if (memcmp(pData, pDataFromGauge, nDataLength)) return pFS; } break; case 'X': pFS++; if ((*pFS) != ':') return pFS; pFS++; n = 0; while ((pFS != pEnd) && (*pFS != '\n') &&(n <sizeof(pBuf) - 1)) { pBuf[n++] = *pFS; pFS++; } pBuf[n] = 0; n = atoi(pBuf); usleep(n * 1000); break; default: return pFS; } while ((pFS != pEnd) && (*pFS != '\n')) pFS++; //skip to next line if (pFS != pEnd) pFS++; } while (pFS != pEnd); //end do-while loop return pFS; }