Bootloader For 18F4520


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    brighton
    Posts
    149

    Default Bootloader For 18F4520

    Hey All
    I have being off pic programming for quite a while now due to other commitments
    i have only just come back and wanted to continue with my beloved 18F452
    and my LAB-X1 Experimenter Board only to find that microchip are recommending the 18f4520 for new designs.
    my problem is that i use pbp 2.50 with microcode studio plus but the loader does not contain the bootloader code for the 18f4520 .
    i have emailed Mecanique about this since monday but they haven't so far replied to my email.
    i have done the online update but its still not there.
    I am presently going through the data sheet of the 18f4520 to see what are the things that i need to change in my code the one thing i never used in my program was the caparator all other things are just normal stuff like LCD, A/D
    i am i opening up a can of worms with the 18f4520 or is it as easy to use as the 18f452.

    Regards
    Isaac

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Isaac,

    I have used the PIC18F252 (no zero at the end) bootloader from http://www.etc.ugal.ro/cchiculita/so...bootloader.htm
    on a PIC18F2520 chip, and it did work correctly. The site says you can use a PIC18F4520 with the same bootloader code. If you look on the page I linked, you will notice what different chips operate with their Tiny bootloader. This might mean that the same would be true with Micro Code Studio's bootloaders. You might try a couple close chips hex code from MCS, and see if it works.

    Or, you could use the Tiny bootloader instead. But I agree, it is nicer to be able to do it right from inside micro code studio.

    On a side note, with Tiny Bootloader they give you the assembly code for the bootloader, so you can add in two lines to change the hardware serial port to inverted. That way, you can do without a max232 chip.

    As far as the worms, I am not sure if it is a single serving, or family sized can. I have only used the PIC18F2520, and not the predecessors. But if you ever made the move from PIC16 to PIC18 devices, it's got to be a piece of cake in comparison.

    Walter
    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 11th February 2010 at 00:53.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Remember that the bootloader cannot protect your code from a reading/copying.

    Ioannis

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Ioannis, it is possible for your PBP application code to disable the bootloader by modifying it or erasing it. You can even change configuration registers at run time.


    You can get a pretty good level of code protection that way.

    I have military customers who want to do a code update, and when they are happy that the load went well, select a menu option. They then get code protection to the limit of what Microchip offers.
    Charles Linquist

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Hi Charles. Thanks for the post. Can you elaborate on this?

    I was pretty sure that Bootloader and Secutity don't go together.

    Ioannis

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I don't know about all the others, but the 18F series lets you modify FLASH at run-time. You have to first erase a block, (8-64 bytes, depending on your chip type - and you have to start at a block boundary) with the ERASECODE command. After erasure, you can write whatever you want.
    I did this in several versions or "levels". This is the lowest level.

    The following to allow the bootloader to run (or not) depending on a program variable. If you set PROTECT and called PatchLoader, the bootloader will not run. If in the program, you set PROTECT = 0, and run it, the bootloader will again work.

    It should be noted that this was used with PBP 250a and an 18F8722 and MCLOADER.

    PBP2.50a could not access the upper half of the big chips (>64K) memory using READCODE,WRITECODE or ERASECODE, so I had to modify PBPPPIC18.LIB to include a new SYSTEM variable called UPMEM. The library modification set TBLPTRU to UPMEM at the beginning of these 3 routines, and cleared UPMEM at the end (so as not to screw up PBP). By setting UPMEM to 1, I could read the upper half of memory (and by setting it to 0x30, you can set/read the configuration registers). You will see that I need to set upmem before each operation to get to that upper half of FLASH. You wouldn't have to deal with that in a smaller chip.

    I have done quite a bit of this, let me know if you need any more help.


    Code:
    PatchLoader:
    
              UPMEM = 0
          
             ERASECODE $0
           
             WRITECODE $0,$EFE0          ; Change the initial jump vector
             WRITECODE $2,$F0FF          ; 0X1FFC0
     
             WRITECODE $4,$FFFF
             WRITECODE $6,$FFFF
           
             for xx = $8 TO $3E STEP 2    ; Do the rest of the block
             WRITECODE XX,$FFFF
             NEXT Xx
             
             PAUSE 100
             
             PROTECT = 1
             GOSUB PROTECT_UNPROTECT 
    
             RETURN
    
    
    PROTECT_UNPROTECT:
    
             UPMEM = 1     
             ERASECODE $FFC0
            
             UPMEM = 1 
             WRITECODE $FFC0,$6B08
             UPMEM = 1 
             WRITECODE $FFC2,$0000
             UPMEM = 1 
             WRITECODE $FFC4,$0000
             UPMEM = 1 
             WRITECODE $FFC6,$0000
             UPMEM = 1 
             WRITECODE $FFC8,$3F08
             UPMEM = 1 
             WRITECODE $FFCA,$D7FB
             
           if PROTECT = 0 THEN        
                 UPMEM = 1 
                 WRITECODE $FFCC,$EF82
                 UPMEM = 1 
                 WRITECODE $FFCE,$F0FE    ; JUMP TO 1FD04
           ELSE  
                 UPMEM = 1 
                 WRITECODE $FFCC,$EF78
                 UPMEM = 1 
                 WRITECODE $FFCE,$F0FE    ; JUMP TO 1fcF0
           ENDIF
            
           FOR XX = $FFD0 TO $FFFE STEP 2
                 UPMEM = 1 
                 WRITECODE XX,$FFFF
           NEXT XX
             
             RETURN
    
    REPROTECT:
             UPMEM = 1
             READCODE $FFCC,X
               IF X = $82 THEN
                HSEROUT [13,10,10,"Reprotecting Loader",13,10]
                PROTECT = 1
                GOSUB PROTECT_UNPROTECT
               ENDIF 
              RETURN  
              
    GetTypeLoader:
             READCODE 0,TypeLoader
             RETURN
    Charles Linquist

Similar Threads

  1. PIC18F4680 bootloader
    By vinyl_theif in forum General
    Replies: 1
    Last Post: - 29th January 2009, 17:45
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  3. USBDemo with Bootloader
    By vacpress in forum USB
    Replies: 4
    Last Post: - 25th January 2007, 22:29
  4. Bootloader Problems
    By rossfree in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th February 2005, 17:51
  5. Replies: 3
    Last Post: - 26th January 2005, 13:41

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