Helpful ReplyHot!XC8 linker force output to be coherent

Author
Reini
Starting Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2015/09/11 03:21:24
  • Location: 0
  • Status: offline
2018/03/13 04:16:13 (permalink)
0

XC8 linker force output to be coherent

Hi All,
I am using a PIC16F18346 along with XC8 v1.44 compiler to build an application that is programmed by a bootloader into the chip. This bootloader can only handle a binary file. The XC8 linker creates a hex-file with several code sections spread over the available program memory space. That is unfortunate and unwanted, because I transfer the Intel-hex file into a bin file and the inter-program sections that the linker did not use are contained in the binfile which cause the binfile to be much larger than I really need.
My question therfore is: What is the (best) way to instruct the linker to create an hex output file with code that is put as close together as it can? Any help would be nice :-)
 
With kind regards,
 
Reini
#1
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: XC8 linker force output to be coherent 2018/03/13 04:22:49 (permalink) ☄ Helpfulby Reini 2018/03/13 04:59:09
+1 (1)
I think the only way you can do it is in two passes.
One normal pass, to find out how big your code is.
Then, edit the project properties to change the amount of ROM you let it use, and give it just enough to fit the code.
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
#2
Reini
Starting Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2015/09/11 03:21:24
  • Location: 0
  • Status: offline
Re: XC8 linker force output to be coherent 2018/03/13 05:04:27 (permalink)
0
qɥb
I think the only way you can do it is in two passes.
One normal pass, to find out how big your code is.
Then, edit the project properties to change the amount of ROM you let it use, and give it just enough to fit the code.
 


Hi,thanks for your input.
That's what I already did, but that would force my colleague developers every time to check the program size after changing the code. I thought, it would be much simpler if the linker (who is already in charge of placing code around the available spaces) could do that for us...
Kind regards,
 
Reini
#3
NKurzman
A Guy on the Net
  • Total Posts : 16668
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: XC8 linker force output to be coherent 2018/03/13 05:30:21 (permalink)
0
The linker starts with the code at the bottom, and the data at the top. It was not always that way, it changed a few years back. It broke a lot of bootloaders.
Are you concerned about size or speed. If it is speed then skipping the records that are all 0xFF will not waste time programming empty records, assuming you do a full erase on the pic first.
#4
crosland
Super Member
  • Total Posts : 1331
  • Reward points : 0
  • Joined: 2005/05/10 10:55:05
  • Location: Bucks, UK
  • Status: offline
Re: XC8 linker force output to be coherent 2018/03/13 06:09:25 (permalink)
+1 (1)
There aren't really any "records" in a .bin file.
 
The bootloader would need to parse it, knowing the PIC flash page size, and check for uneccessary writes.
 
Change the bootloader and host app to handle hex files, or use sime other protocol like the old Microchip bootloader I use which does tranfer "records" in a binary format.
 
Either way means re-writing the bootloader.
#5
NKurzman
A Guy on the Net
  • Total Posts : 16668
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: XC8 linker force output to be coherent 2018/03/13 06:15:45 (permalink)
+1 (1)
Rewriting the bootloader, or host program.
#6
jswanson
Super Member
  • Total Posts : 327
  • Reward points : 0
  • Joined: 2003/11/07 12:44:05
  • Status: offline
Re: XC8 linker force output to be coherent 2018/03/13 08:16:47 (permalink)
0
I had the same problem a few years back.  There was a feature request for it: http://www.microchip.com/forums/FindPost/824149
#7
mlp
boots too small
  • Total Posts : 630
  • Reward points : 0
  • Joined: 2012/09/10 15:12:07
  • Location: previously Microchip XC8 team
  • Status: offline
Re: XC8 linker force output to be coherent 2018/03/13 08:40:02 (permalink)
+2 (2)
NKurzman
The linker starts with the code at the bottom, and the data at the top. It was not always that way, it changed a few years back.

The linker starts allocating from both ends of memory working towards the middle, to give it more chance of fitting everything in when space gets tight than if it allocated from one end only. As I recall, this was introduced around the time HI-TECH brought out the PRO compilers.
 
It broke a lot of bootloaders.

You misspelled "It highlighted a limitation, or design deficiency, in a lot of bootloaders."
The bootloaders that HI-TECH supplied were quite happy with sparse .HEX files.



Mark (this opinion available for hire)
#8
NKurzman
A Guy on the Net
  • Total Posts : 16668
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: XC8 linker force output to be coherent 2018/03/13 09:59:51 (permalink)
0
Yes, I remember that time frame.
Thanks for the correction.  I noted what it looked like it was doing to me.
I assumed there was a reason for the change.  Some OCG thing.
 
It was interesting to see how many bootloader writers tried the same clever trick. Stop on the fist Blank record.
#9
Jump to:
© 2018 APG vNext Commercial Version 4.5