View previous topic :: View next topic |
Author |
Message |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
Again bootloader and space compiled |
Posted: Wed Oct 26, 2011 6:46 am |
|
|
Hi to all,
In order to update firmware I decided to insert bootloader routine call by rs232 command. I put bootloader at the end of memory space ad I used, for test, this application:
http://www.ccsinfo.com/forum/viewtopic.php?t=39179&highlight=bootloader
The routine work fine but I decided to do some test with same PIC18 micro but different application one with 10% of memory used and the other with 90%. The bootloader and it's allocation defines are the same but I found difference between the two disassamble listing. It seems the CCS compile in different way the same c lines in the two different application. So I can't load one application int the other more then 1 time. I need to have the same machine code and allocation memori in all my project of bootloader routine.
Have you got any suggestion to have what I need ?
My compiler is Vers. 3,249
Any comments and suggestion are appreciated.... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Wed Oct 26, 2011 9:26 am |
|
|
Er. Of course it will.
Every line is dependant on several other things:
The locations variables are declared at.
What is happening in front of it (will affect things like bank switching).
Where the routines are called from (multiple copies may switch to be subroutines, of inline).
etc. etc.
That the code changes, is expected, and shouldn't affect the bootloader at all.
You will need to compile the code with a 'build' option, so it is put above the lines at the bottom of memory that jump to the bootloader (if the bootloader is at the bottom of memory, you place the code above the bootloader, if the bootloader is at the top of memory, you only need to locate the code above the vectors for boot, and the interrupt vectors. Then the bootloader needs to be written to jump back to the location defined in this build (which you keep constant on all your code), and to similarly re-vector interrupts back to the defined location).
Best Wishes |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Wed Oct 26, 2011 10:18 am |
|
|
Thanks Ttelmah,
It's correct in case of start-up bootloader as is in the main cases...but I want to start bootloader by serial command from my pc application..... there any way to have fixed bootloader code doesn't change?
I'm thinking to copy disassemble listing of bootloader one time compiled into C code under #asm directive.... does it will work ?
Regards & thanks, |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Oct 26, 2011 12:31 pm |
|
|
The regular way to integrate a precompiled bootloader into an application is to use a #import statement.
I don't however understand what's exactly your problem. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Wed Oct 26, 2011 3:05 pm |
|
|
Yes. Normally you would always compile the bootloader separately, so it is not affected/reliant on the main program.
Best Wishes |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Fri Oct 28, 2011 2:14 am |
|
|
I'm just doing some test because I'm afraid about adding bootloader in my firmware because it is in continuous updating and I be sure the bootloader firmware doesn't change in second time after new compiling.
Now I hope you understand, my english is quite poor....
I ever used #import statement and I'll study about. Does it also for CCS V3.249 ? have you got to suggest me examples ?
Regards and thanks, |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Oct 28, 2011 4:10 am |
|
|
I'm using PCH V3.222 for a legacy project, and in this version #import isn't yet supported. I don't know, if it possibly had been introduced until V3.249. With V3.222 we have also a separate bootloader, but we are merging the *.hex files. |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Fri Oct 28, 2011 6:31 am |
|
|
I supposed it.....
Can you explain me how compile separated and merge in in hex file ?
Thanks,
Fabri |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Oct 28, 2011 10:19 am |
|
|
As a first point, you have to decide about a suitable bootloader layout and configure bottloader and application to use the respective memory areas. The bootloader examples provided with CCS C V3.xxx can be used as a template.
For the V3.xxx botloader, that can't use #include to make a factory image comprised of both bootloader and application, CCS suggests to load them sequentially, in other words flash the bootloader and load the application image by the serial bootloader.
Alternatively, you can cut and assemble the respective lines of the *.hex files, once you understood their syntax. Or use MPLAB, that has the cabability to load and save specified parts of the memory image manually. |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Fri Oct 28, 2011 10:44 am |
|
|
Thanks for suggestion and help. I'll work around.
Regards,
Fabri |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Tue Nov 01, 2011 2:22 am |
|
|
At last:
I compiled separately bootloader routine and imported with #import directive the HEX file.
All working as I need.
Thanks for help.
Regards,
Fabri |
|
|
|