Is there a way to expand the base bootloader program?


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default Found some code

    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

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

  2. #2
    Join Date
    Apr 2005
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    We will obviously have to rewrite the code in PBP conventions to make it work tho.

  3. #3
    Join Date
    May 2005
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    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

Similar Threads

  1. PIC18F4680 bootloader
    By vinyl_theif in forum General
    Replies: 1
    Last Post: - 29th January 2009, 18:45
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd November 2008, 00:51
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  4. Disabling bootloader under program control
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th March 2007, 16:35
  5. Bootloader Problems
    By rossfree in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th February 2005, 18:51

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts