PDA

View Full Version : Is there a way to expand the base bootloader program?



modifyit
- 10th June 2005, 22:07
Is there a way to expand the base bootloader program? I would like to be able to have a portion of my code be resident in the bootloader portion of the code so that it will still work when programming the rest of the pic.

A simple example would be a program that flashes an LED and performs other functions.

In this example I would like the LED to flash all the time, even if I am programing using the bootloader. So if I can add a section of code to the bootloader to flash an led while the bootloader is programing I think it would work.

Let me know if need to better explain myself, I realize I may not be being that clear.

Thanks for any input

modifyit
- 14th June 2005, 04:08
any thoughts?

I'd be happy to clarify my question if I can...I basically want to add my own personal code to the bootloader so I have a default code while programing.

BTW I am trying to do this on an 877a chip.

Thanks again

nimonia
- 14th June 2005, 04:31
i've seen bootloaders in C , ASM... i post a thraed before asking if it is possible to code in PBP... i've figured out some stuff and tought of mixing it with asm... leave all the org statements in asm and anythign to do with adressing in ASM then just add personal functions like password and stuff in the middle... i also am gonna try using the write and read function after i finish my work... WORK SUX.!!!

modifyit
- 14th June 2005, 18:57
I just found this site doing a quick search

http://www.oshonsoft.com/picbootloader.html

Looks like this code may be what we need to get started making our own bootloaders with PBP

---------------------------------
Define CONF_WORD = 0x3f72
StartFromZero

Dim i As Byte
Dim num As Byte
Dim total As Word
Dim j As Word
Dim address As Word
Dim data(4) As Word
Dim dat As Word
Dim din As Byte

ASM: BSF PCLATH,3
ASM: BSF PCLATH,4
Goto bootloader_start

'beginning of user program
ASM: ORG 0x0004
user_program:
Goto user_program

'beginning of bootloader
ASM: ORG 0x1E00
execute_user_program:
Gosub reset_state
ASM: CLRF STATUS
ASM: CLRF PCLATH
ASM: NOP

ASM: BCF PCLATH,3
ASM: BCF PCLATH,4
ASM: GOTO 0x0004
ASM: NOP

bootloader_start:
Hseropen 19200
WaitMs 100
Hserout 0x55
For i = 1 To 100
WaitMs 1
Hserget num
If num = 0x55 Then
Goto bootloader_main
Endif
Next i
Goto execute_user_program

bootloader_main:
Gosub get_byte
total.LB = din
Gosub get_byte
total.HB = din
address = 0x0004
For j = 1 To total
Gosub get_data
For i = 0 To 3
If address <= 0x1e00 Then
Gosub prepare_write
Gosub write_flash_memory
Endif
address = address + 1
Next i
Next j
address = 0x1e04
Gosub get_data
For i = 0 To 3
Gosub prepare_write
Gosub write_flash_memory
address = address + 1
Next i
WaitMs 100
Goto execute_user_program
End

get_data:
Gosub get_word
data(0) = dat
Gosub get_word
data(1) = dat
Gosub get_word
data(2) = dat
Gosub get_word
data(3) = dat
Return

get_word:
Gosub get_byte
dat.LB = din
Gosub get_byte
dat.HB = din
Return

get_byte:
Hserin din
Hserout din
Return

prepare_write:
EEADR = address.LB
EEADRH = address.HB
dat = data(i)
EEDATA = dat.LB
EEDATH = dat.HB
Return

write_flash_memory:
ASM: BSF STATUS,RP0
ASM: BSF STATUS,RP1
ASM: BSF EECON1,EEPGD
ASM: BSF EECON1,WREN
ASM: MOVLW 0x55
ASM: MOVWF EECON2
ASM: MOVLW 0xAA
ASM: MOVWF EECON2
ASM: BSF EECON1,WR
ASM: NOP
ASM: NOP
ASM: BCF EECON1,WREN
ASM: BCF STATUS,RP0
ASM: BCF STATUS,RP1
Return

reset_state:
RCSTA = 0
TXSTA = 0
SPBRG = 0
EECON1 = 0
PIR1 = 0
PIR2 = 0
Return

------------------

modifyit
- 14th June 2005, 18:59
We will obviously have to rewrite the code in PBP conventions to make it work tho.

nimonia
- 15th June 2005, 15:24
my mistake bout read and write... wat i really meant was the READCODE and WRITECODE.. haf alookup on tht. writes to program code memory.. i've got one problem now.. anyone outthere, how do i reset the PIC in PBP? or in assembly? no hardware involve as in pulling the MCLR low with another pin.. thnks