aqhome-tool: flash always 16 bytes at a time

This commit is contained in:
Martin Preuss
2025-03-24 00:18:28 +01:00
parent c6f1ac94fa
commit 45e668ec88

View File

@@ -45,6 +45,8 @@
#define A_INT GWEN_ArgsType_Int #define A_INT GWEN_ArgsType_Int
#define FLASH_TOOL_PAGESIZE 16
#define FLASH_TOOL_MAX_REPEAT 16 #define FLASH_TOOL_MAX_REPEAT 16
#define FLASH_TOOL_DEFAULT_TIMEOUTINSECS 5 #define FLASH_TOOL_DEFAULT_TIMEOUTINSECS 5
#define FLASH_TOOL_WAITFORFLASHREADY_INSECS 30 #define FLASH_TOOL_WAITFORFLASHREADY_INSECS 30
@@ -190,7 +192,7 @@ int doFlash(AQH_OBJECT *o)
/* perform flash */ /* perform flash */
// rv=_performFlashProcedure(o, uid, flashRecordList, pageSize, timeoutInSeconds); // rv=_performFlashProcedure(o, uid, flashRecordList, pageSize, timeoutInSeconds);
rv=_performFlashProcedure(o, uid, flashRecordList, 16, timeoutInSeconds); rv=_performFlashProcedure(o, uid, flashRecordList, FLASH_TOOL_PAGESIZE, timeoutInSeconds);
if (rv<0) { if (rv<0) {
if (rv<0) { if (rv<0) {
DBG_INFO(NULL, "here (%d)", rv); DBG_INFO(NULL, "here (%d)", rv);
@@ -210,7 +212,7 @@ int _rebootNode(AQH_OBJECT *o, unsigned int uid, int timeoutInSeconds)
AQH_MESSAGE *nodeMsg; AQH_MESSAGE *nodeMsg;
/* send REBOOT_REQUEST message */ /* send REBOOT_REQUEST message */
fprintf(stdout, "- sending REBOOT request\n"); fprintf(stdout, "- Sending REBOOT request\n");
DBG_INFO(NULL, "Sending REBOOT REQUEST message"); DBG_INFO(NULL, "Sending REBOOT REQUEST message");
nodeMsg=AQH_RebootMessage_new(0xff, 0x00, AQH_MSG_TYPE_REBOOT_REQ, uid); nodeMsg=AQH_RebootMessage_new(0xff, 0x00, AQH_MSG_TYPE_REBOOT_REQ, uid);
if (nodeMsg==NULL) { if (nodeMsg==NULL) {
@@ -295,13 +297,15 @@ int _flashRecord(AQH_OBJECT *o,
ptr=AQH_FlashRecord_GetDataPointer(flashRecord); ptr=AQH_FlashRecord_GetDataPointer(flashRecord);
len=AQH_FlashRecord_GetDataLength(flashRecord); len=AQH_FlashRecord_GetDataLength(flashRecord);
address=AQH_FlashRecord_GetAddress(flashRecord); address=AQH_FlashRecord_GetAddress(flashRecord);
DBG_ERROR(NULL, "Sending record: addr=%04x, len=%d, pagesize=%d", address, len, pageSize); DBG_INFO(NULL, "Sending record: addr=%04x, len=%d, pagesize=%d", address, len, pageSize);
fprintf(stdout, "- sending record: addr=%04x, len=%d, pagesize=%d\n", address, len, pageSize);
while(ptr && len) { while(ptr && len) {
int rv; int rv;
uint32_t sendLen; uint32_t sendLen;
usleep(100000); // usleep(100000);
sendLen=(len>pageSize)?pageSize:len; sendLen=(len>pageSize)?pageSize:len;
fprintf(stdout, " - sending page: addr=%04x, len=%d (%d bytes left)\n", address, sendLen, len);
rv=_flashData(o, address, ptr, sendLen, timeoutInSeconds); rv=_flashData(o, address, ptr, sendLen, timeoutInSeconds);
if (rv<0) { if (rv<0) {
DBG_INFO(NULL, "here (%d)", rv); DBG_INFO(NULL, "here (%d)", rv);