Reply by Stef Mientki August 30, 20062006-08-30
JohnT wrote:
> I've looked through the bootloader and my interpretation is as follows > :- > > 1. PIC Starts > 2. Jumps to (Max_Memory - 100) > 3. Waits a period of time for 'C1' to be received. > 4a. If 'C1' is receieved then continue to rewrite the program that it > is being sent. > 4b If no 'C1' is received then exit the bootloader. > 5 Jump to the start of the bootloader where the four 'nop' commands > should have been replaced with the 'Goto' command that is at the start > of my program. > 6 It should find my 'Goto' command and then execute my program. > > > I believe that the download program that you get off the site looks at > the start of the user program. Finds this 'Goto' command and relocates > it in memory to the start of the bootloader. I think this is where it > is failing but I don't have the source code for the download program to > verify this.
if you mean the UPLOAD program, here is the first part: <Pascal> const //bootloader types TINY =0; TOLMIE =1; TINY_IDENT = $C1; TINY_IDACK = ord('K'); function TForm_bootloader.TINY_Identify:boolean; (******************************************************************************* *******************************************************************************) begin with Form_comm_usb do begin Flush_Communication(true,true); //great improvement for RS232 !! Transmit_Buffer[0]:=TINY_IDENT; Transmit_Count:=1; result:=Send_Data; //Error message if not ok if not(result) then memo_uploader.lines.add('Transmit Error = '+inttostr(Transmit_Result)+' / '+inttostr(Transmit_Count)); end; end; function TForm_bootloader.TINY_Acknowledge:boolean; (******************************************************************************* *******************************************************************************) var received_byte :byte; starttime :cardinal; begin starttime:=gettickcount; repeat result:= Form_comm_usb.read_byte(TINY_PIC_type); application.processmessages; until result or (gettickcount-starttime>200); if not(result) then exit; starttime:=gettickcount; repeat result:= Form_comm_usb.read_byte(received_byte) and (received_byte=TINY_IDACK); application.processmessages; until result or (gettickcount-starttime>200); end; //main program reset_PIC; //try to he ping the PIC Ping_Count:=0; Uploading_Canceled:=false; repeat if not(TINY_IDENTIFY) then exit; Update_Ping_Count; if Uploading_Canceled then exit; application.ProcessMessages; until TINY_ACKNOWLEDGE; </Pascal>
> > Thanks >
Reply by JohnT August 30, 20062006-08-30
I've looked through the bootloader and my interpretation is as follows
:-

1. PIC Starts
2. Jumps to (Max_Memory - 100)
3. Waits a period of time for 'C1' to be received.
4a. If 'C1' is receieved then continue to rewrite the program that it
is being sent.
4b If no 'C1' is received then exit the bootloader.
5 Jump to the start of the bootloader where the four 'nop' commands
should have been replaced with the 'Goto' command that is at the start
of my program.
6 It should find my 'Goto' command and then execute my program.


I believe that the download program that you get off the site looks at
the start of the user program.  Finds this 'Goto' command and relocates
it in memory to the start of the bootloader.  I think this is where it
is failing but I don't have the source code for the download program to
verify this.

Thanks

Reply by Diogo G. Casado (a.k.a dIIo) August 30, 20062006-08-30
JohnT wrote:
> If I don't put a GOTO in first four instructions it does indeed warn me > that there isn't a GOTO instruction. I also understand how the program > is suppose to work in the PIC. What I don't know and the site doesn't > tell you is what the download program does to your original code. > > Yes I have downloaded the example code as it that is is the program I'm > trying to get working. > > Neil wrote: > > CLIPPED > > 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 > > > > > the instructions show: > > > > > > org 0 > > ;clrf STATUS > > clrf PCLATH > > goto Main > > > > or > > > > org 0 > > ;clrf STATUS > > pagesel Main > > goto Main > > > > The web site says the PC Side will give a warning if the GOTO is wrong. > > > > Did you try to send his sample?
JohnT, Strange... take a look at bootloader code on tinybld16F.asm: ORG first_address nop nop nop nop org first_address+4 IntrareBootloader And if you look deeper: way_to_exit ;exit in all other cases; must be BANK0/1 ;BANK0_ bcf RCSTA, SPEN ; deactivate UART goto first_address first_address is: #define first_address max_flash-100 ; 100 word in size So, what it does is: Loop forever into first_address while not receiving the 0xC1 char. In this case, you will need to put something like this in the end of your program: org max_flash-100 ; You will need to get max_flash value from boot loader includes. clrf PCLATH pagesel MyStart goto MyStart And in the start, don't use an org 0x00. I think that you need only setup the interrupt vector and after it continue with you program. ex: org 0x04 goto INT_HAND MyStart: LALALALA INT_HAND: LALLALAA org max_flash-100 ; You will need to get max_flash value from boot loader includes. clrf PCLATH pagesel MyStart goto MyStart Maybe you can use some #ifdefs using a def like #define USE_LOADER or something, in order to compile with or withou initialization... #ifndef USE_LOADER org 0x00 clrf STATUS movlw 0 movwf PCLATH goto MyStart #endif I don't why examples don't consider this, maybe some mismatch docs release... :) Hope it helps. - Diogo.
Reply by JohnT August 30, 20062006-08-30
If I don't put a GOTO in first four instructions it does indeed warn me
that there isn't a GOTO instruction.  I also understand how the program
is suppose to work in the PIC.  What I don't know and the site doesn't
tell you is what the download program does to your original code.

Yes I have downloaded the example code as it that is is the program I'm
trying to get working.

Neil wrote:
> CLIPPED > 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 > > > the instructions show: > > > org 0 > ;clrf STATUS > clrf PCLATH > goto Main > > or > > org 0 > ;clrf STATUS > pagesel Main > goto Main > > The web site says the PC Side will give a warning if the GOTO is wrong. > > Did you try to send his sample?
Reply by Neil August 30, 20062006-08-30
CLIPPED
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 >
the instructions show: org 0 ;clrf STATUS clrf PCLATH goto Main or org 0 ;clrf STATUS pagesel Main goto Main The web site says the PC Side will give a warning if the GOTO is wrong. Did you try to send his sample?
Reply by Stef Mientki August 29, 20062006-08-29
JohnT wrote:
> I believe I am, I've started my program as it states in the > documentation but it doesn't seem to get that far.
No, you must start with a long jump !! The Tiny bootloader is working perfectly, I used it for many PIC types, and it always worked perfect. And how to program a long jump,... ... sorry I don't know, JAL is doing it for me ;-) And if you also don't know how to program a long jump, you should really take a look at some High Level Language (JAL perhaps). For the other discussion, I fully agree, that's why I called my program UPD (Uploader Programmer Debugger) ;-) cheers, Stef
Reply by Donald August 29, 20062006-08-29
CBFalconer wrote:
> > Now it may be possible to read this and make some sense out of it. > You should never top-post; your answer belongs after (or intermixed
Thank You again Mother Falconer.
> with) the material to which you reply, after snipping the portion > that is not germane to your reply. It takes only a moment (usually > just hit a page down key a few times) to arrive at the end. > > See the links in my sig below. > > In general a bootloader will load some sort of code into a fixed > beginning location, and then transfer control to that same fixed > location. The bootloader has to be very simple as it will usually > be resident in some sort of ROM. Once the control transfer is made > any further action is up to the loaded code, which may in turn do a > more complex load operation. >
Reply by RaceMouse August 29, 20062006-08-29
JohnT wrote:
> I tried that already but with no success. The code I showed you is > straight from an example that came with the bootloader. > > > RaceMouse wrote: > >>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 > >
And I just saw I was wrong 'cause "ORG" is a directive. Not an instruction :-) /RaceMouse
Reply by CBFalconer August 29, 20062006-08-29
*** Horrible confusing topposting fixed as a public service ***
JohnT wrote:
> RaceMouse wrote: >> JohnT wrote: >>> RaceMouse wrote: >>>> JohnT wrote: >>>>> RaceMouse wrote: >>>>>> Pietje Bell wrote: >>>>>>> >>>>>>>> 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'sdone. >>>>>>>> >>>>>>>> I suspect this is the case as the bootloader software >>>>>>>> detects the PIC straight away without the need for me to >>>>>>>> reset the PIC. >>>>>>> >>>>>>> Does the bootloader needs to know where the application is >>>>>>> programmed? (at what address) >>>>>> >>>>>> My best quess is that your PIC progam should start with >>>>>> something like "ORG 0x100" or whatever the >>>>>> "jump-to-application-address" is. >>>>> >>>>> 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? >>>> >>>> Can you post the souce code of you application ? >>> >>> 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. >> >> 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. > > I tried that already but with no success. The code I showed you > is straight from an example that came with the bootloader.
Now it may be possible to read this and make some sense out of it. You should never top-post; your answer belongs after (or intermixed with) the material to which you reply, after snipping the portion that is not germane to your reply. It takes only a moment (usually just hit a page down key a few times) to arrive at the end. See the links in my sig below. In general a bootloader will load some sort of code into a fixed beginning location, and then transfer control to that same fixed location. The bootloader has to be very simple as it will usually be resident in some sort of ROM. Once the control transfer is made any further action is up to the loaded code, which may in turn do a more complex load operation. -- Some informative links: news:news.announce.newusers http://www.geocities.com/nnqweb/ http://www.catb.org/~esr/faqs/smart-questions.html http://www.caliburn.nl/topposting.html http://www.netmeister.org/news/learn2quote.html
Reply by RaceMouse August 29, 20062006-08-29
JohnT wrote:
> I believe I am, I've started my program as it states in the > documentation but it doesn't seem to get that far. > > > Pietje Bell wrote: > >>Are you linking your application code for the correct address? >>The memory map should comply with the bootloader requirements. >> >> >> >> >>>I tried that already but with no success. The code I showed you is >>>straight from an example that came with the bootloader. >>> >>> >>>RaceMouse wrote: >>> >>>>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 >>> >
Can you merge the two hex files (the bootloader and you application) and run it in a simulator ? /RaceMouse