CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Bootloader and application program using the same subroutine

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Krille28



Joined: 08 Nov 2007
Posts: 6

View user's profile Send private message

Bootloader and application program using the same subroutine
PostPosted: Thu Jan 24, 2008 11:53 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 29, 2008 2:22 am     Reply with quote

Anyone?
Ttelmah
Guest







PostPosted: Tue Jan 29, 2008 3:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Apr 16, 2008 7:49 pm     Reply with quote

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

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Wed Apr 16, 2008 9:42 pm     Reply with quote

Hi ckielstra, i have de same problem. You solved it as Ttelmah explained?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Apr 17, 2008 6:29 am     Reply with quote

The method explained above is only a design suggestion. I haven't worked it out into a complete program.
trrudeau
Guest







Bootloader
PostPosted: Tue May 13, 2008 11:49 am     Reply with quote

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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group