0
votes

Is there a way to make the bootloader code occupy a specific section in program memory?

I noticed that some of the code is written in the top section of memory but the other part is written starting at section $11000. In my case it conflicts with my application code. So how do I force the bootloader code to occupy program memory starting from $00000 to $10000? I am assuming it can be done by changing some settings under Mplab XC8 compiler.

PIC: PIC18F87J11

Compiler: MPLAB XC8

Update:

Found the fix

Project properties > XC8 global options category > Memory Model > ROM ranges

ROM RANGE: 0-10000

Update:

I am seeing another issue though.

So I set the ROM range from $00000-$10000, but that's not enough space for the bootloader code even though it should. However when I look at the program memory under MPLAB XC8 after building the project, I noticed that there are some addressees left empty.

How do I force those addressees to be used? If those sections were used then the specified ROM size from 0-10000 should be enough for my bootloader code.

For example those addresses are used (data written there)

00000-0925C

But then these address are not used, just left blank

0925E- 0F77A (huge section, what a waste)

Then these addresses are used

0F77C-0FFFE

But then my program gets cut off at $10000 even though there seems to be more code to be written to memory.

So

How do I force those unused addressee to be used? Its just a huge waste of memory to skip them and I don't understand why they are empty. I can not give the Bootloader anymore ROM space, the rest must be given to the Application Code.

I hope everything is clear, thanks!

1
I'm not familiar with PIC, but typically you specify memory sections in the linker directive file. Read the linker manual.kkrambo
Under MPLAB C18, there are no gaps or unused addresses. However, with MPLAB XC8, some addresses are unused like described above, so the problem seems to be coming from the compiler.Ammar

1 Answers

0
votes

To place the bootloader in the specified memory, you should:

1) In the code - create the section.

int __section("_bootloader") helper(int mode) {
/* ... */ 
//bootloader functions here
}

2) In the options of linker - add options to place the section to the specified memory.

-L-A_BLOADER=00h-ffffh
-L-p_bootloader=_BLOADER

To see the exect functions placed in the memory range 0F77C-0FFFE, you may see the *.map file (if it is generated).