Sign in

username:

password:



Not a member?

Search Comp.Arch.Embedded



Search tips

embedded by Keywords

68HC11 | 68HC12 | 8051 | 8052 | ARM | ARM7 | Asic | AT91 | AT91RM9200 | Atmel | AVR | AVRStudio | Bootloader | CFP | CompactFlash | Cygnal | Cypress | Dataflash | DSP | eCos | EEPROM | Embedded Linux | Emulator | Endian | Ethernet | Firewire | FPGA | Freescale | GCC | GNUARM | GSM | H8 | HDLC | I2C | Infineon | Interrupts | Java | JTAG | LCD | LED | LPC2000 | MCU | Microchip | MMC | MPLAB | MSP430 | PC104 | PCB | PCI | PCMCIA | PowerPC | Rabbit | RS232 | RS485 | RTOS | SBC | SDRAM | Sensor | SPI | STK500 | UART | UML | USART | USB | Verilog | VHDL | VxWorks | Xilinx

Ads

Discussion Groups

There are 23 messages in this thread.

You are currently looking at messages 20 to 23.

Re: Tiny Bootloader - Diogo G. Casado (a.k.a dIIo) - 07:42 30-08-06

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.




Re: Tiny Bootloader - JohnT - 13:06 30-08-06

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


Re: Tiny Bootloader - Stef Mientki - 13:23 30-08-06

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
> 

previous | 1 | 2 | 3