EmbeddedRelated.com
Forums

Tiny Bootloader

Started by JohnT August 29, 2006
Hi All,

Has anyone manged to get the tiny bootloader from
http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm working?

I have a 16F877A with a 4MHz crystal.  I modified the frequency in the
software and downloaded it with no problem.  Running the software it
discovers the PIC with no problem.

However, I tried to create a simple program in assembler that would
turn on all the outputs of Port B.  I know my program works fine as
I've downloaded it using a programmer.  However, when I download it
using the bootloader nothing happens.  It appears that the PIC is
'stuck' in the bootloader section and not jumping to my code when it's
done.

I suspect this is the case as the bootloader software detects the PIC
straight away without the need for me to reset the PIC.

Any ideas anyone?

John

JohnT wrote:
> Hi All, > > Has anyone manged to get the tiny bootloader from > http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm working? > > I have a 16F877A with a 4MHz crystal. I modified the frequency in the > software and downloaded it with no problem. Running the software it > discovers the PIC with no problem. > > However, I tried to create a simple program in assembler that would > turn on all the outputs of Port B. I know my program works fine as > I've downloaded it using a programmer. However, when I download it > using the bootloader nothing happens. It appears that the PIC is > 'stuck' in the bootloader section and not jumping to my code when it's > done. > > I suspect this is the case as the bootloader software detects the PIC > straight away without the need for me to reset the PIC. > > Any ideas anyone? > > John >
Greetings First: You don't download _TO_ something. you upload _TO_ a device ! (I really couldn't help it :-) ) Second : Have you made sure that you application program starts at the same address as the booloader jumps to when it does not receive a char from the PC ? /RaceMouse
Does the bootloader needs to know where the application is programmed? 
(at what address)



-------- Origineel bericht --------

> Hi All, > > Has anyone manged to get the tiny bootloader from > http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm working? > > I have a 16F877A with a 4MHz crystal. I modified the frequency in the > software and downloaded it with no problem. Running the software it > discovers the PIC with no problem. > > However, I tried to create a simple program in assembler that would > turn on all the outputs of Port B. I know my program works fine as > I've downloaded it using a programmer. However, when I download it > using the bootloader nothing happens. It appears that the PIC is > 'stuck' in the bootloader section and not jumping to my code when it's > done. > > I suspect this is the case as the bootloader software detects the PIC > straight away without the need for me to reset the PIC. > > Any ideas anyone? > > John >
RaceMouse wrote:

> First: You don't download _TO_ something. you upload _TO_ a device ! > (I really couldn't help it :-) )
You'd have no idea how many arguments I've had about this. I agree with what you just said, but I've never been able to convince anyone else of this. It is common parlance that programming a chip is "downloading to" that chip.
Pietje Bell wrote:
> Does the bootloader needs to know where the application is programmed? > (at what address) > > > > -------- Origineel bericht -------- > >> Hi All, >> >> Has anyone manged to get the tiny bootloader from >> http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm working? >> >> I have a 16F877A with a 4MHz crystal. I modified the frequency in the >> software and downloaded it with no problem. Running the software it >> discovers the PIC with no problem. >> >> However, I tried to create a simple program in assembler that would >> turn on all the outputs of Port B. I know my program works fine as >> I've downloaded it using a programmer. However, when I download it >> using the bootloader nothing happens. It appears that the PIC is >> 'stuck' in the bootloader section and not jumping to my code when it's >> done. >> >> I suspect this is the case as the bootloader software detects the PIC >> straight away without the need for me to reset the PIC. >> >> Any ideas anyone? >> >> John >>
My best quess is that your PIC progam should start with something like "ORG 0x100" or whatever the "jump-to-application-address" is. /RaceMouse
larwe wrote:
> RaceMouse wrote: > > >>First: You don't download _TO_ something. you upload _TO_ a device ! >>(I really couldn't help it :-) ) > > > You'd have no idea how many arguments I've had about this. I agree with > what you just said, but I've never been able to convince anyone else of > this. It is common parlance that programming a chip is "downloading to" > that chip. >
As long as you agree with me you're doing fine :-) The only way to change this "common parlance" is to use the correct terms. Agree ? -maybe the discussion belongs in an other thread but ... /RaceMouse
Thanks for the response.

Firstly, my background is in PLC's and the various pieces of software I
use 'download to the PLC' or 'upload from the PLC'

Secondly, the bootloader I'm trying to should move the 'goto'
instruction that you need to put in the first four lines of code to the
start of the bootloader code.  This leaves the start of memory as the
bootloader set it, i.e. jump to the bootloader routine.  After it has
executed the bootloader routine, it jumps to just before the bootloader
and should find the address of where to go next, i.e. the 'goto'
instruction in my code.  If you look at the web address of my initial
query there is a nice picture showing what I've just tried to explain.

The download program that is on that website must modify the hex file,
find the 'goto' instruction in the first four lines and overwrite that
line of the bootloader.

I can't think how to test it though, has anyone else used a bootloader
successfully?

John


RaceMouse wrote:
> Pietje Bell wrote: > > Does the bootloader needs to know where the application is programmed? > > (at what address) > > > > > > > > -------- Origineel bericht -------- > > > >> Hi All, > >> > >> Has anyone manged to get the tiny bootloader from > >> http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm working? > >> > >> I have a 16F877A with a 4MHz crystal. I modified the frequency in the > >> software and downloaded it with no problem. Running the software it > >> discovers the PIC with no problem. > >> > >> However, I tried to create a simple program in assembler that would > >> turn on all the outputs of Port B. I know my program works fine as > >> I've downloaded it using a programmer. However, when I download it > >> using the bootloader nothing happens. It appears that the PIC is > >> 'stuck' in the bootloader section and not jumping to my code when it's > >> done. > >> > >> I suspect this is the case as the bootloader software detects the PIC > >> straight away without the need for me to reset the PIC. > >> > >> Any ideas anyone? > >> > >> John > >> > > My best quess is that your PIC progam should start with something like > "ORG 0x100" or whatever the "jump-to-application-address" is. > > /RaceMouse
JohnT wrote:
> Thanks for the response. > > Firstly, my background is in PLC's and the various pieces of software I > use 'download to the PLC' or 'upload from the PLC' > > Secondly, the bootloader I'm trying to should move the 'goto' > instruction that you need to put in the first four lines of code to the > start of the bootloader code. This leaves the start of memory as the > bootloader set it, i.e. jump to the bootloader routine. After it has > executed the bootloader routine, it jumps to just before the bootloader > and should find the address of where to go next, i.e. the 'goto' > instruction in my code. If you look at the web address of my initial > query there is a nice picture showing what I've just tried to explain. > > The download program that is on that website must modify the hex file, > find the 'goto' instruction in the first four lines and overwrite that > line of the bootloader. > > I can't think how to test it though, has anyone else used a bootloader > successfully? > > John > > > RaceMouse wrote: > >>Pietje Bell wrote: >> >>>Does the bootloader needs to know where the application is programmed? >>>(at what address) >>> >>> >>> >>>-------- Origineel bericht -------- >>> >>> >>>>Hi All, >>>> >>>>Has anyone manged to get the tiny bootloader from >>>>http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm working? >>>> >>>>I have a 16F877A with a 4MHz crystal. I modified the frequency in the >>>>software and downloaded it with no problem. Running the software it >>>>discovers the PIC with no problem. >>>> >>>>However, I tried to create a simple program in assembler that would >>>>turn on all the outputs of Port B. I know my program works fine as >>>>I've downloaded it using a programmer. However, when I download it >>>>using the bootloader nothing happens. It appears that the PIC is >>>>'stuck' in the bootloader section and not jumping to my code when it's >>>>done. >>>> >>>>I suspect this is the case as the bootloader software detects the PIC >>>>straight away without the need for me to reset the PIC. >>>> >>>>Any ideas anyone? >>>> >>>>John >>>> >> >>My best quess is that your PIC progam should start with something like >>"ORG 0x100" or whatever the "jump-to-application-address" is. >> >>/RaceMouse > >
Hmmm... Can you post the souce code of you application ? /RaceMouse
How do I post my code, I can't see of a way to upload a file.  The
start of my code is as follows though.

		ORG	0x00		; Start of the program
		CLRF	STATUS
		MOVLW	0x00
		MOVWF	PCLATH
		GOTO 	INIT


		ORG	0x04		; Interrupt address
		GOTO	INT_HAND

All I'm doing after it goes to the INIT routine is set all the outputs
on for PortA and B.  I've simulated this and it works fine.

John

RaceMouse wrote:
> JohnT wrote: > > Thanks for the response. > > > > Firstly, my background is in PLC's and the various pieces of software I > > use 'download to the PLC' or 'upload from the PLC' > > > > Secondly, the bootloader I'm trying to should move the 'goto' > > instruction that you need to put in the first four lines of code to the > > start of the bootloader code. This leaves the start of memory as the > > bootloader set it, i.e. jump to the bootloader routine. After it has > > executed the bootloader routine, it jumps to just before the bootloader > > and should find the address of where to go next, i.e. the 'goto' > > instruction in my code. If you look at the web address of my initial > > query there is a nice picture showing what I've just tried to explain. > > > > The download program that is on that website must modify the hex file, > > find the 'goto' instruction in the first four lines and overwrite that > > line of the bootloader. > > > > I can't think how to test it though, has anyone else used a bootloader > > successfully? > > > > John > > > > > > RaceMouse wrote: > > > >>Pietje Bell wrote: > >> > >>>Does the bootloader needs to know where the application is programmed? > >>>(at what address) > >>> > >>> > >>> > >>>-------- Origineel bericht -------- > >>> > >>> > >>>>Hi All, > >>>> > >>>>Has anyone manged to get the tiny bootloader from > >>>>http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm working? > >>>> > >>>>I have a 16F877A with a 4MHz crystal. I modified the frequency in the > >>>>software and downloaded it with no problem. Running the software it > >>>>discovers the PIC with no problem. > >>>> > >>>>However, I tried to create a simple program in assembler that would > >>>>turn on all the outputs of Port B. I know my program works fine as > >>>>I've downloaded it using a programmer. However, when I download it > >>>>using the bootloader nothing happens. It appears that the PIC is > >>>>'stuck' in the bootloader section and not jumping to my code when it's > >>>>done. > >>>> > >>>>I suspect this is the case as the bootloader software detects the PIC > >>>>straight away without the need for me to reset the PIC. > >>>> > >>>>Any ideas anyone? > >>>> > >>>>John > >>>> > >> > >>My best quess is that your PIC progam should start with something like > >>"ORG 0x100" or whatever the "jump-to-application-address" is. > >> > >>/RaceMouse > > > > > Hmmm... > > Can you post the souce code of you application ? > > /RaceMouse
JohnT wrote:
> How do I post my code, I can't see of a way to upload a file. The > start of my code is as follows though. > > ORG 0x00 ; Start of the program > CLRF STATUS > MOVLW 0x00 > MOVWF PCLATH > GOTO INIT > > > ORG 0x04 ; Interrupt address > GOTO INT_HAND > > All I'm doing after it goes to the INIT routine is set all the outputs > on for PortA and B. I've simulated this and it works fine. > > John > > RaceMouse wrote: > >>JohnT wrote: >> >>>Thanks for the response. >>> >>>Firstly, my background is in PLC's and the various pieces of software I >>>use 'download to the PLC' or 'upload from the PLC' >>> >>>Secondly, the bootloader I'm trying to should move the 'goto' >>>instruction that you need to put in the first four lines of code to the >>>start of the bootloader code. This leaves the start of memory as the >>>bootloader set it, i.e. jump to the bootloader routine. After it has >>>executed the bootloader routine, it jumps to just before the bootloader >>>and should find the address of where to go next, i.e. the 'goto' >>>instruction in my code. If you look at the web address of my initial >>>query there is a nice picture showing what I've just tried to explain. >>> >>>The download program that is on that website must modify the hex file, >>>find the 'goto' instruction in the first four lines and overwrite that >>>line of the bootloader. >>> >>>I can't think how to test it though, has anyone else used a bootloader >>>successfully? >>> >>>John >>> >>> >>>RaceMouse wrote: >>> >>> >>>>Pietje Bell wrote: >>>> >>>> >>>>>Does the bootloader needs to know where the application is programmed? >>>>>(at what address) >>>>> >>>>> >>>>> >>>>>-------- Origineel bericht -------- >>>>> >>>>> >>>>> >>>>>>Hi All, >>>>>> >>>>>>Has anyone manged to get the tiny bootloader from >>>>>>http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm working? >>>>>> >>>>>>I have a 16F877A with a 4MHz crystal. I modified the frequency in the >>>>>>software and downloaded it with no problem. Running the software it >>>>>>discovers the PIC with no problem. >>>>>> >>>>>>However, I tried to create a simple program in assembler that would >>>>>>turn on all the outputs of Port B. I know my program works fine as >>>>>>I've downloaded it using a programmer. However, when I download it >>>>>>using the bootloader nothing happens. It appears that the PIC is >>>>>>'stuck' in the bootloader section and not jumping to my code when it's >>>>>>done. >>>>>> >>>>>>I suspect this is the case as the bootloader software detects the PIC >>>>>>straight away without the need for me to reset the PIC. >>>>>> >>>>>>Any ideas anyone? >>>>>> >>>>>>John >>>>>> >>>> >>>>My best quess is that your PIC progam should start with something like >>>>"ORG 0x100" or whatever the "jump-to-application-address" is. >>>> >>>>/RaceMouse >>> >>> >>Hmmm... >> >>Can you post the souce code of you application ? >> >>/RaceMouse > >
Ok. It seems to me that you have 5 instructions within the first four program counts. Your Interrupt vector starts at 0x04 but your startup code ends at 0x05. My suggestion: ORG 0x00 ; Start of the program CLRF STATUS CLRF PCLATH GOTO INIT Please report back. /RaceMouse