try to imple vbf-tool by rust
ref. https://mk4-wiki.denkdose.de/artikel/vbf/start
The VBF format contains a readable part in ASCII format and a machine part in binary format.
- Header
vbf_version = 2.6;
header {
//**********************************************************
//*
//* Volvo Car Corporation
//*
//* This file is generated by VBF CONVERT ver. 5.10.0
//*
//* DO NOT EDIT !
//*
//**********************************************************
// Volvo software part number
sw_part_number = "8894084567";
// Software Version:
sw_version = "A";
// Volvo software part type: Executable
sw_part_type = EXE;
// Data format identifier: 0x00 = Uncompressed, 0x10 = Compressed
data_format_identifier = 0x00;
// ECU Address:
ecu_address = 0x1234;
// Erase information
// start, length
erase = { { 0x0cc00000, 0x0004ef15 },
{ 0xffffe800, 0x0000002c }
};
// Start address of the hash table
verification_block_start = 0xFFFFE800;
// Length of the hash table
verification_block_length = 0x0000002C;
// Root hash value
verification_block_root_hash = 0x3E263C8F66129C46B39D59E5964D7F3254FFA272AD3A3E70FC57ED95D73E1234;
// Blocks sorted
// Blocks grouped
// Blocks: 2
// Bytes: 323476
file_checksum = 0x6A8DB4CC;
}
- Payload: The binary part (payload) the VBF begins directly after the last ASCII character of the description part (the }). The following data are to be interpreted as bytes in big endian.
Offset | LENGTH | BYTES | DATETYPE | FUNCTION | SAMPLE |
---|---|---|---|---|---|
0x0000 | 4 Bytes | DWORD | DATA_START | Start address on the target system | 0x000004F4 |
0x0003 | 4 Bytes | DWORD | DATA_LENGTH | Length of the following block | |
0x0007 | x Bytes | BYTE | DATA | data of the block | |
0x0007 + DATA_LENGTH | 2 Bytes | WORD | DATA_CRC | CRC-16 CCITT checksum of the DATA |
- VBT(verification block table)
The verification block table, encoded with big endian, shall have the following format:
- Verification Block Table Format Identifier. [ size 16 bits]
- Number of data blocks. [ size 16bits]
- StartAddress [ size 32 bits] , Length [ size 32 bits], Hash value. Every data blocks shall be defined, except the block table itself. The size of the hash is dependent of the hash function used and is specified elsewhere. The Length is the unprocessed length
- The data blocks shall be sorted according to the order the data blocks are being programmed to the ECU.
- SHA-256 hash function is used, i.e. each hash value is 256 bits.
the description of vbf file parameters.
$ vbf-tool ./vbb_script.json