Hi,Artist wrote: ↑14 Sep 2019, 08:55 Thank you for your response ...
I tried the following attempt, but so far without writing to IPC.
I put the .bin dump into the hex editor and then exported it to the motorola s-hex file. Then I imported this file in VBF Tool 2.2, added the same header as the original vbf file.
The header contains information about the length of the file, the starting address ...
But I can't change the start address, I only have 00000000.
It should be on IPC main flash since 00005000.
Maybe it's not a problem, but I'm not sure the result ...
well thank you...
The readable text field in the header are only for informational purpose.
After the readable (plain text) VBF header there are one or more data segements. Each data segment begins with 32bits CallAddress (memory address where data will be loaded), 32bits DataLength, than comes the Data and 16Bits crc checksum at the end of segment.
Here is one little code snippet from my vbf flasher (posted some years ago here) about reading first data segment from VBF file:
Code: Select all
uint8_t *seekVBF2Data(uint8_t *buffer) {
char pattern[] = "file_checksum =";
uint8_t flag = 0;
uint8_t *subbuf;
if ((subbuf = (uint8_t *) strstr((char *) buffer, pattern)) != NULL)
if ((subbuf = (uint8_t *) strstr((char *) subbuf, "}")) != NULL)
return subbuf+1;
return NULL;
}
uint8_t *readVBF(char *filename, sDataSegment *fw) {
FILE *f = fopen(filename, "r");
//get filesize
fseek(f, 0L, SEEK_END);
long sz = ftell(f);
fseek(f, 0, SEEK_SET);
//alloc buffer
uint8_t *retbuf, *buffer = malloc(sizeof(uint8_t) * sz);
fread(buffer, 1, sz, f);
fclose(f);
//seek vbf to fw data
if ((retbuf = seekVBF2Data(buffer)) == NULL) exit(-1);
fw->callAddress = getInt32(retbuf);
retbuf += sizeof(uint32_t);
fw->length = getInt32(retbuf);
retbuf += sizeof(uint32_t);
fw->data = malloc(sizeof(uint8_t) * fw->length);
memcpy(fw->data, retbuf, fw->length);
retbuf += fw->length;
fw->crc = getInt16(retbuf);
printf("%08X %08X %04X\n", fw->callAddress, fw->length, fw->crc);
free(buffer);
return retbuf;
}
To rebuild data segment it's simple. Just replace the binary data it self in the vbf file (keeping the 2x32bit call address and data length at the begining) and finally rebuild the crc16 checksum at the end of the file (crc16 ccitt must be calcualted on the data segment).
The data must be exactly the same size as the original one.
The file checksum of the header is a CRC32 checksum calcualted on the entire file excluding the header. I allways recalculate this value after modfying the data, but never found any tool that use this field for validation. So you can simple ignore it in most of cases.
Regards,
leader