|
|
View previous topic :: View next topic |
Author |
Message |
runeso
Joined: 27 Nov 2003 Posts: 1
|
Bootloader again |
Posted: Mon Sep 20, 2004 12:58 pm |
|
|
Hi all
I have made the CCS included bootloader to work (ex-bootloader.c, bootloader.h and loader.c) on my 18F458
But I can't compile a code with both my bootloader and a source code included.
What I want to do is to create a new version of my source code with the bootloader included so that I can program this with mplab. And then when a new release is done, this code is whitout the bootloader which can then be DL'ed with RS-232. (The download of the source code works fine now.)
Has anyone done this before.
How do I set up the #org, #build reset and so on, in the ex_bootloader.c file to make this work.
Best regards Rune |
|
|
Guest
|
|
Posted: Mon Sep 20, 2004 2:10 pm |
|
|
I also use loader.c in my project.
main.c
#fuses HS,NOWDT,PUT, NOPROTECT, NOLVP, BROWNOUT
#include "loader.c" //it is pretty much the same as the example, except #define LOADER_SIZE 0x4FF
main()
{
....
CommandDispatcher();
....
}
CommandDispatcher()
{
...
/*Ready to run the loader.c*/
disable_interrupts(global);
putchar(XON);
LED_RED();
load_program(); //this will not return
}
Everything seems to work fine, so far.
The only concern is:
If the loader can't finish due to any reason (such as power lost), the micro has to be sent back to me -- thus I am not telling my customers about this feature, and only use it when it is absolutely necessary. |
|
|
asmallri2 Guest
|
Bootloader again |
Posted: Mon Sep 20, 2004 6:06 pm |
|
|
Quote: | If the loader can't finish due to any reason (such as power lost), the micro has to be sent back to me -- thus I am not telling my customers about this feature, and only use it when it is absolutely necessary. |
I have my own flavour of bootloader and it uses flags to control the loading process. When it start loading new code it sets a "code invalid flag" this flag is not cleared until the eof record is received. When the system is booted, and the bootloader has control, it will not execute user code if the "code invalid" flag is set. In the event of power failure during programing, the system restarts in the bootloader mode and stays there until a new image is programmed. I have successfully used this feature to reprogram remote systems thousands of kilometres away and recover from loader failures. |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Tue Sep 21, 2004 10:28 am |
|
|
asmallri2,
Can you share this code?
I looked into this for a while, and I also had loader problem.
I ended up going in a different direction,... But I would love to find out what went wrong with my code.
Thanks for your help.
tjr |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Bootloader again |
Posted: Wed Sep 22, 2004 6:15 am |
|
|
Quote: | asmallri2,
Can you share this code?
I looked into this for a while, and I also had loader problem.
I ended up going in a different direction,... But I would love to find out what went wrong with my code. |
Send me an email at asmallri@westnet.com.au and I will send you the code and the programmer application. NOTE: This bootloader bears no resemblance whatsoever to the Loader.c example on CCS, it is written in assembler and was designed for fault tolerant operation. It is not small. (end of disclaimers) |
|
|
Guest
|
Re: Bootloader again |
Posted: Wed Sep 22, 2004 12:51 pm |
|
|
asmallri2 wrote: | Quote: | If the loader can't finish due to any reason (such as power lost), the micro has to be sent back to me -- thus I am not telling my customers about this feature, and only use it when it is absolutely necessary. |
I have my own flavour of bootloader and it uses flags to control the loading process. When it start loading new code it sets a "code invalid flag" this flag is not cleared until the eof record is received. When the system is booted, and the bootloader has control, it will not execute user code if the "code invalid" flag is set. In the event of power failure during programing, the system restarts in the bootloader mode and stays there until a new image is programmed. I have successfully used this feature to reprogram remote systems thousands of kilometres away and recover from loader failures. |
Is it similar to what described in this app note?
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en012031 |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: Bootloader again |
Posted: Wed Sep 22, 2004 3:08 pm |
|
|
Is it similar to what described in this app note?
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en012031[/quote]
No but it follows the general principle of a bootloader. My loader is located high in memory and the only low memory consumed is the reset vector. My initial implementation was a bootloader that works over ethernet (appearded in issue #165 of Circuit Cellar in May this year). It works but reading a line of the hex file and sending the entire line wrapped in a header to the target. The target returns status, line by line to the coontrolling host. I then ported it to RS232. I also have a flavour that I use for bootloadinng thru an intermediary PIC and every bootloads a MAX1463 digital ananlog processor thru the downstream remote pic over the SPI bus. This bootloader's hex file is included in issue #171 (October 2004). |
|
|
bloodynri
Joined: 03 Nov 2004 Posts: 2
|
|
Posted: Wed Nov 03, 2004 2:16 pm |
|
|
I have a problem with loader.c
First of all I'm confused about what is required to run a bootloader.
In my project, I have my main C file, the header files related to that and the loader.c file. Is this all I need? Do I need the ex_bootloader etc that come with CCSC?
When I compile the Main C file, I get an error for loader.c that says "unidentified identifier getch" and the same for putchar. Can someone please help me with these issues?
Thanks alot! |
|
|
Nick Guest
|
|
Posted: Wed Jun 08, 2005 10:42 pm |
|
|
bloodynri wrote: |
When I compile the Main C file, I get an error for loader.c that says "unidentified identifier getch" and the same for putchar. Can someone please help me with these issues?
Thanks alot! |
I'm getting the same error, just a different year. |
|
|
Guest
|
|
Posted: Wed Jun 08, 2005 10:49 pm |
|
|
Code: |
#include <16F876.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=38400, xmit=PIN_C6, rcv=PIN_C7)
#include <loader.c>
/*
#include <16F876.h>
#fuses HS,NOWDT,NOPROTECT,PUT//,//BROWNOUT,NOLVP
#use delay(clock=20000000)// 20mhz clock
//set up PC communications
#include <loader.c>
#use rs232(baud=38400, xmit=PIN_C6, rcv=PIN_C7,errors)
*/
|
the error is in the header.... the commented out header will generate that error... this is for the archives. I hope it helps |
|
|
|
|
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
|