This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Linker : crc computing and filling unused bytes with a specific value

Hi,

I wrote a perl program which calculates the CRC32 checksum of my .hex generated file (previously converted to binary of course). So I should just have to write it back to my .hex file at a fixed memory address for example and test it from my boot code.

The problem I have is that I don't know if Keil linker inserts holes (not programmed bytes) in the built .hex file.

If so, my perl cksum calculation will be wrong since it does not take into account these holes. The embedded cksum code will calculate the cksum on a range of adresses including non programmed bytes (0xFF)... :-(

My questions are :

- Is the linker inserting holes in the generated .hex?
- If so, is there a means to force it to fill holes with a specific value in the .hex file; 0xFF for example... ;-) ?

Thank you very much for your precious help !

Pierre

PS : I found a FLASH Fill Byte field in the Output options : could it be these famous option I'm looking for ?

  • The HEX file is created after the Linker has finished - so what you have in the HEX file is what will be burned into your PROM.

    The HEX file is usually created by a utility such as BIN2HEX that converts the linker's absolute output file to Intel Hex:
    http://www.keil.com/download/docs/113.asp

    You can control this utility to determine what it does with unprogrammed locations...

  • Thanks for your answer Andy.

    I have tried to run bin2hex utilities... but I can't see any option that can insert ,for example, 0xFF to unprogrammed locations...

    Syntax: BIN2HEX [/option] binfile [hexfile]
    
    binfile is the binary input file
    hexfile is the Intel HEX file to create
    
    option  may be any of the following
    
      /Ln     Bytes to read from binary file
      /In     Binary file starting offset
      /On     Output file address offset (where HEX data starts)
      /M      Merge data into existing HEX file
      /2      Generate HEX file using ext. segment address records (HEX86)
      /4      Generate HEX file using ext. linear address records (HEX386)
      /Q      Quiet mode (no statistics are displayed)
      /T      Exclude EOF record
      /A      Append to end of existing HEX file
    

    Perhaps hex2bin does... with the /Pn option ? I've tried the following sequence on my .H86 file :

    HEX2BIN /P255 KEIL.H86 KEIL.BIN
    BIN2HEX /2 KEIL.BIN KEIL2.H86
    

    Comparing KEIL.H86 and KEIL2.H86 is not so easy because they do not use the same record byte count value. I cannot see unprogrammed values set to 0xFF as expected...

    Any idea ? Thanks for your time !

    Pierre

    PS : I tried to run HEX2BIN with /PFF option too... same output...

  • My mistake: a BIN file is always a verbatim record of every single byte in its address range;

    The HEX file may or may not contain gaps, and it's HEX2BIN that decides what to do in any gaps.

    The conversion from the Linker's output file is done by the Object-to-Hex converter:
    http://www.keil.com/support/man/docs/oh166/