View previous topic :: View next topic |
Author |
Message |
Krille28
Joined: 08 Nov 2007 Posts: 6
|
Bootloader and application program using the same subroutine |
Posted: Thu Jan 24, 2008 11:53 am |
|
|
I´m going to make a bootloader program for my pic18F2455. I think i have understand the concept for bootloading:
First i have to make a boot program that has a main for writing the flash memory. In my case i have to import my usb hid program also, so that the new program can be downloaded via usb from my PC program.
I have to remap the interrupt vectors.
Program the new application program to a specific memory location, so that I wont program over the bootloader program.
So far I think I got it right. My question is how do I do it if I want to use the USB interface also in my application program for other purpose than downloading a new application? The pic already have this function in the bootloader program, so I think it would be wrong to import the usb hid also to the application program. Should I use the GOTO syntax or what when I want to check if there is something in the USB buffer?
If anyone know the answer to this question or have programmed a bootloader for this purpose, I would be very happy for an answer. |
|
|
Krille28
Joined: 08 Nov 2007 Posts: 6
|
|
Posted: Tue Jan 29, 2008 2:22 am |
|
|
Anyone? |
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 29, 2008 3:25 am |
|
|
Make sure the routines are declared as 'separate'.
Use the #ORG directive, to put the subroutine(s) required, into the _same_ area of memory, in both the bootloader code, and the main code.
Use as normal.
So your memory layout becomes:
Bootloader
Shared area used by both programs
Main code
Then _provided_ the same compiler version is used to build the main code, and the bootloader code - be careful on this...., both sets of code contain identical definitions for the 'shared' functions. Normally you modify the bootloader, so it won't overwrite stuff in the 'shared' area, so the code from the 'main', when reloaded, doesn't overwrite this code.
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Apr 16, 2008 7:49 pm |
|
|
Ttelmah's solution will work for some time but eventually (after several years) compiler versions will have to change. An improvement to the proposed scheme would be to define a strict prescribed interface: a jump table and fixed addresses for the function parameters. A bit like how the BIOS functions in a DOS-PC are called. |
|
|
pfer90
Joined: 16 Apr 2008 Posts: 3 Location: Argentina
|
|
Posted: Wed Apr 16, 2008 9:42 pm |
|
|
Hi ckielstra, i have de same problem. You solved it as Ttelmah explained? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Apr 17, 2008 6:29 am |
|
|
The method explained above is only a design suggestion. I haven't worked it out into a complete program. |
|
|
trrudeau Guest
|
Bootloader |
Posted: Tue May 13, 2008 11:49 am |
|
|
Hello all.
I'm still trying to figure how to place the boot code in ROM 0x00 to 0x1ff so I can set the protect bit on this block. Main() then should be placed at address 0x200 but I can't get the compiler to let me use an #org 0x200 in front of main() . It complains that I have an overlap. I must need to modify the link script but I have not found how to do this when calling the CCS compiler via MPLAB. Can someone point me to a post that explains the process better than the totally uncommented CCS bootloader example? |
|
|
|