• AVR Freaks

Hot!Hex files missing initial type 2 record

Author
crosland
Super Member
  • Total Posts : 1936
  • Reward points : 0
  • Joined: 2005/05/10 10:55:05
  • Location: Warks, UK
  • Status: offline
2020/03/28 09:40:10 (permalink)
0

Hex files missing initial type 2 record

XC8 2.10 MPLAB X 5.35
 
All my old hex files from MPLAB/C18 have a type 2 record at the start of the file to set the address to 0.
 
In MPLAB X/XC8 I have a number of projects that all include the same bootloader as an Loadable project.
 
All projects have the linker option "Format hex file for download" selected.
 
I am looking at hex files from <project>/dist/default/production directory.
 
None of the <project>.X.production.unified.hex unified hex files has a type 2 record. 
 
Three of the four <project>.X.production.hex do have the required type 2 record, one does not.
 
When the type 2 record is missing, neither my host bootloader client nor the device bootloader set the correct initial address. It's too late to change this.
 
I have a special case of updating the bootloader AND application (using a special bootloader) where I NEED to send the unified hex file. In most cases the non-unified is sufficient except for the one project where the type 2 record is missing.
 
I can add the required record manually, but does anyone know:
 
What controls the inclusion of the type 2 record?
 
Why is it not included in the unified hex?
 
Why is one project generated differently?
 
#1

15 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 18655
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Hex files missing initial type 2 record 2020/03/28 10:58:01 (permalink)
    +1 (1)
    The type 2 record is not required.
    It was an add on for Files greater than 64K.
    It would assumed to be zero.
    I do not know if there’s a way to force into the file via command line options.
    #2
    NorthGuy
    Super Member
    • Total Posts : 6072
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/28 11:23:47 (permalink)
    +1 (1)
    Type 2 records are rare in HEX files. You're probably talking about type 4 record which is commonly used in HEX files such as:
     
    :020000040000fa

     
    You can always pre-pend this type 4 record to your HEX file. This will not alter the contents  the HEX file regardless of what it contains.
     
    #3
    1and0
    Access is Denied
    • Total Posts : 10780
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/28 11:54:23 (permalink)
    +4 (4)
    I agree with NorthGuy in that you meant type 4, not type 2, record. To prepend your hex file with a type 4 record to initialize the upper address to zero, check "Extend address 0 in HEX file" in your project properties linker option.
     
    #4
    crosland
    Super Member
    • Total Posts : 1936
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/28 13:20:23 (permalink)
    0
    Yeah, sorry, I was reading the length, not the type!
     
    I think that's a bug then. Setting the "Extend address 0 in HEX file" option inhibits the type 4 record. That was the difference in the one of four projects that did not include the type 4 record: it had the option set.
     
    I tried setting/unsetting it in the Loadable bootloader project. It has no effect on the unified hex. 
    #5
    ric
    Super Member
    • Total Posts : 26943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Hex files missing initial type 2 record 2020/03/28 14:42:32 (permalink)
    +1 (1)
    As Northguy suggested, you could always add the record to the start of the file as a post build step.
    This could even be done using the command line "copy" command, as they are just text files.
    It would not matter if there were two type 4 records at the start.
     
    n.b. requiring a type 4 record at the start is a bug in the bootloader, but as you say, it's too late to fix that.
     
    post edited by ric - 2020/03/28 14:44:25

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    1and0
    Access is Denied
    • Total Posts : 10780
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/28 20:11:53 (permalink)
    +1 (1)
    crosland
    I think that's a bug then. Setting the "Extend address 0 in HEX file" option inhibits the type 4 record. That was the difference in the one of four projects that did not include the type 4 record: it had the option set.
     
    I tried setting/unsetting it in the Loadable bootloader project. It has no effect on the unified hex. 

    Here with XC8 v2.10 in MPLABX v5.35, unselecting "Extend address 0 in HEX file" generates :020000040000FA, while selecting it does not generate that record.  Definitely a bug.
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 18655
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Hex files missing initial type 2 record 2020/03/28 21:58:55 (permalink)
    0
    If it is a bug, then you would need to enter a support ticket.
    #8
    1and0
    Access is Denied
    • Total Posts : 10780
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/28 22:33:27 (permalink)
    0
    Here with XC8 v2.10 in MPLABX v5.20, both selecting and unselecting "Extend address 0 in HEX file" generate :020000040000FA. 
    #9
    NKurzman
    A Guy on the Net
    • Total Posts : 18655
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Hex files missing initial type 2 record 2020/03/28 23:53:57 (permalink)
    0
    So MPLabX is generating the incorrect command line ?
    New version, new bugs?
    #10
    mad_c
    Super Member
    • Total Posts : 1234
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/30 13:38:08 (permalink)
    +1 (1)
    crosland
    I think that's a bug then. Setting the "Extend address 0 in HEX file" option inhibits the type 4 record. That was the difference in the one of four projects that did not include the type 4 record: it had the option set.

    Hi,
     
    My understanding is that the compiler will only place a type 4 record in the hex file if there is any content at or above 0x10000. The simple tests I did show that the download option has no say over the record's presence. Could this be what you are seeing?
     
    Jeff.
    #11
    1and0
    Access is Denied
    • Total Posts : 10780
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/30 14:28:56 (permalink)
    +1 (1)
    In MPLAB X v5.35, selecting "Extend address 0 in HEX file" uses -ginhx32 command and unselecting it uses -ginhx032 command.
     
    In the XC8 User's Guide, it states
    • -ginhx32      Intel HEX with extended linear address records, allowing use of addresses beyond 64kB
    • -ginhx032    INHX32 with initialization of upper address to zero
    which seems confusing as it sounds like the same thing?! What am I missing?
     
    I used to think selecting that option will prepend hex file with :020000040000FA.
    #12
    mad_c
    Super Member
    • Total Posts : 1234
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/30 14:44:30 (permalink)
    0
    1and0
    In MPLAB X v5.35, selecting "Extend address 0 in HEX file" uses -ginhx32 command and unselecting it uses -ginhx032 command.
     
    In the XC8 User's Guide, it states
    • -ginhx32      Intel HEX with extended linear address records, allowing use of addresses beyond 64kB
    • -ginhx032    INHX32 with initialization of upper address to zero
    which seems confusing as it sounds like the same thing?! What am I missing?
     
    I used to think selecting that option will prepend hex file with :020000040000FA.

    Hi,
     
    The OP indicated they had tried using the download option, which is -mdownload. This has no say over whether the compiler will place a type 4 record in the hex file--that is determined purely by the presence of high data that needs it. If I had had my morning coffee, I probably would have gone on to say that the -g options can control this. The two options you indicated are both for hex file allowing extended linear address records, by the latter will force a type 4 record into the hex file, even for 'extended' addresses of 0.
     
    Jeff.
    #13
    ric
    Super Member
    • Total Posts : 26943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Hex files missing initial type 2 record 2020/03/30 14:53:52 (permalink)
    0
    mad_c
    ...
    The two options you indicated are both for hex file allowing extended linear address records, by the latter will force a type 4 record into the hex file, even for 'extended' addresses of 0.

    and his point was that this seems to be the opposite behaviour to what the "Extend address 0 in HEX file" checkbox implies.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    mad_c
    Super Member
    • Total Posts : 1234
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/30 15:15:15 (permalink)
    0
    ric
     
    and his point was that this seems to be the opposite behaviour to what the "Extend address 0 in HEX file" checkbox implies.

    Indeed. It looks like the IDE has the action of that checkbox reversed. I'll see if I can send a bug report their way.
     
    Jeff.
    #15
    crosland
    Super Member
    • Total Posts : 1936
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: Hex files missing initial type 2 record 2020/03/31 03:26:24 (permalink)
    0
    mad_c
    The OP indicated they had tried using the download option, which is -mdownload.

     
    That was only to avoid being asked whether I had tried it :) 
     
    ric
    and his point was that this seems to be the opposite behaviour to what the "Extend address 0 in HEX file" checkbox implies.

    Indeed.
     
    I have also now discovered that the IPE includes a type 4 record to set the extended address to zero at the start of an exported hex. So someone, somewhere, in Microchip thinks it's a good thing :)
    #16
    Jump to:
    © 2020 APG vNext Commercial Version 4.5