Searching \ for '[PIC] relocation of code using HiTech C compiler' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=c
Search entire site for: 'relocation of code using HiTech C compiler'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] relocation of code using HiTech C compiler'
2006\12\31@200016 by David

flavicon
face
I am trying to get a bootloader running with the PIC18LF1320 micro and
find the program is writing over itself.

The bootloader calculates the memory top and erases from where
bootloader ends and the end of memory.
The problem is that instead of the bootloader being placed in the bottom
0x300 bytes the compiler is placing most of the code up at 1B62. This
means the bootloader writes over itself when it runs.

Does anyone know how I can make the Hi-Tech C compiler put the
bootloader code in the block from 0000 to 0300 ?

Thanks

Regards

David

2006\12\31@205242 by Brent Brown

picon face
David wrote:
> I am trying to get a bootloader running with the PIC18LF1320 micro and
> find the program is writing over itself.
>
> The bootloader calculates the memory top and erases from where
> bootloader ends and the end of memory.
> The problem is that instead of the bootloader being placed in the
> bottom 0x300 bytes the compiler is placing most of the code up at
> 1B62. This means the bootloader writes over itself when it runs.
>
> Does anyone know how I can make the Hi-Tech C compiler put the
> bootloader code in the block from 0000 to 0300 ?

Just for an example that might give you some clues... to get the TinyBootloader to
work in a recent PIC project I had to tell the compiler to NOT put application code
where the Bootloader resides. In my case I added the following in MPLAB under
Project/Build options/Project/PICC Linker - use alternate settings:

-RESROM1F9C-1FFF

Typically your Bootloader code will be compiled/assebled sepeartely from your
application code and should have directives to be located at a specific address. As
shown in the example above, your application code might reasonably be expected
to reside anywhere else in your chip except where the Bootloader resides.

Hope that helps some!

--
Brent Brown, Electronic Design Solutions
16 English Street, St Andrews,
Hamilton 3200, New Zealand
Ph: +64 7 849 0069
Fax: +64 7 849 0071
Cell: 027 433 4069
eMail:  spam_OUTbrent.brownTakeThisOuTspamclear.net.nz


2006\12\31@210044 by John Temples

flavicon
face
On Mon, 1 Jan 2007, David wrote:

> Does anyone know how I can make the Hi-Tech C compiler put the
> bootloader code in the block from 0000 to 0300 ?

Check the --rom command line switch in the manual.  This lets you
override the compiler's idea of what memory ranges are available to it
for placing code.

--
John W. Temples, III


'[PIC] relocation of code using HiTech C compiler'
2007\01\01@001127 by David
flavicon
face
Hi,

The problem IS with the bootloader code. The application is loaded by
the bootloader later and is offset by 0x300.

The Bootloader when compiled uses just under 0x300 bytes (a bit larger
than original Hi-Tech bootloader due to encryption decoding and
bit-bashed serial.

But, when I compile the bootloader it puts a small amount of code at
0000 to about 0026 than puts the rest of the bootloader code just below
top of memory.

I have used the same base code for the PIC18F6720 and PIC18F2520 and the
compiler does place all the bootloader code between 0000-0300 in these
programs. In fact this version was created from the working PIC18F2520
bootloader with minor changes to set up the OSCCON and Port direction
registers only

I tried --ROM=0000-0300 but this did not fix the problem. I cannot
understand what determines that some of the code gets pushed into upper
memory and why it all cannot simply compile linearly into memory from
0000-02ff as the other versions do ??

Would anyone be prepared to take a look at it if I zipped the project up
and emailed it to you to see if I have done something silly ?

I am using Hi-Tech compiler V9.5 PL3 and MPLAB V7.51. Target device is
PIC18LF1320.

Thanks in advance for your help. I have emailed Hi-Tech support and
posted into their forum but I think they are on holiday for another week
or more.

Regards

David

Brent Brown wrote:
{Quote hidden}

2007\01\01@004845 by John Temples

flavicon
face
On Mon, 1 Jan 2007, David wrote:

> I tried --ROM=0000-0300 but this did not fix the problem.

Tried it how?  You realize that's a linker option, not a compiler
option, right?

--
John W. Temples, III

2007\01\01@005506 by David

flavicon
face
John,

Thank you for pointing that out to me. I did have the command line
option in the wrong place (under compiler tab instead of linker).

That does in fact now place all the code in the bottom of memory as desired.

Any idea why the compiler would do otherwise by default ?

Regards

David

John Temples wrote:
{Quote hidden}

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...