Saturday, June 27, 2009
I recently needed to pad a very small .BIN file of around 1.4KB to fit into a 128KB memory space. I am sure there are much easier ways of doing this than my solution, but it worked for me so I thought I would share. You will need bin2hex and hex2bin.
1. Copy bin2hex and hex2bin to the same directory as your .BIN file.
2. Open a command prompt in Windows. Navigate to your .BIN file directory.
3. Type "bin2hex file.bin file.hex" where file.bin is the input .BIN file and file.hex is an output .HEX file.
4. Type "hex2bin file.hex /Lxxxxxx file2.bin" where file.hex is the .HEX file that was created in step 3, xxxxxx is the length in bytes of the padded output file and file2.bin is the output .BIN file.
For example, if I wanted to pad my file to be 128KB in length, I simply type "hex2bin file.hex /L131072 file2.bin" because 128KB is equal to 128 x 1024 bytes (which is 131072 bytes).