18F4550 Bootloader enter via eeprom setting


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bcd View Post
    bradb,

    Nice solution - reminds me of the old serial bootloaders where they would look for a single character on the com port at startup and use that to enter bootloader mode.

    Giving the pic the ability to put itself into bootload mode rather than requiring a crazy key combination on reset, which some poor end user will manage to do while trying to mount a device in the wall is a great idea.

    I notice you removed the blinky led code in the HID Bootloader to code - how much bigger does the read and write eeprom code make the bootloader code ? - from memory the HID one is about 1100 bytes.

    Hmm, wonder if I could make it work with an I2C eeprom... I knew there was a reason the 18F2550 would be better than the 18f2450...

    Quick thought though - what happens if you PBP program gets trashed ? - how can you get the unit into bootloader mode to get new code into it? I am thinking bootload session that crashes out half way through or cable falls out etc. - would it be better to write the eeprom once the bootloader has completed sucessfully, say after the ProcessIO() call in the HID bootlader code ?

    Good work,
    bill
    I thought about adding the write byte1 = 1 code only after completing the firmware upgrade, but for my purpose I wanted the PIC to fall back to the Pic Basic code in the event of an aborted firmware upgrade attempt. I did not want to get stuck in pic upgrade loop. A quick power cycle aborts the upgrade procedure without even having to start the HID boot loader program. This was personal choice.

    I would like to add a counter to eprom byte 2.
    Every time the C code boots it would increment byte 2 by 1.
    If byte 2 > 5 then the C program would go into boot loader mode regardless of the status of eprom byte1.

    At the end of my Basic loop I would set eeprom byte2 back to 0, clearing the Eprom Byte 2 counter. 5 Failed boot attempts in a row would automatically send the PIC into boot loader mode, like hosed code from a failed upgrade. This gets around the failed upgrade issue with a handful of reboots.

    However, I'm going to have to find some place to get more code space from, I'm not at my work PC but from memory I think I only have about 8 bytes left under the first 1000h which is why I had to remove the USB Led Blink status to begin with. Either that or figure out if it’s possible to change the start vector of the pic basic to 1200h.

    Or, I can add an upgrade switch but because of the nature of the device I'm making I do not want the board or a switch field accessible. I really need to be able to upgrade these via a remote control solution, IE I remote desktop to a PC with the device attached via USB and then I can personally do the upgrade. I have the procedure in my VB program password protected so users can't send the pic into upgrade mode.

    This was a quick project today but it is working.

    The other mistake I can already see I made was writing byte 1 back to a every time even it’s already a 1, my code should be more like this:

    Code:
     
    void main(void)
    {   
        
    	//read the first byte store in var eepTemp
    	signed char eepTemp;  	//setup a var to read the eep
    	EEADR = 0x0001; 		//location to read, I'm using eeprom address 1
    	EECON1bits.EEPGD = 0; 
    	EECON1bits.CFGS = 0; 
    	EECON1bits.RD = 1; 
    	eepTemp = EEDATA; 
    
        //Check Bootload Mode Entry Condition
    	if(eepTemp == 0x01)	//Check the eepTemp and see if it's 0x01, if so boot to the PIC Basic code at 0x1000
    	{
    		_asm
    		goto 0x1000			//If the user is not trying to enter the bootloader, go straight to the main application remapped "reset" vector.
    		_endasm
    	}
    
    	//write Byte "1" back to a 1
        	EEADR =0x0001; 
       	EEDATA =0x01;
       	Nop();
       	Nop();
    	EECON1bits.EEPGD = 0;
       	EECON1bits.CFGS = 0;
       	EECON1bits.WREN = 1;
       	INTCONbits.GIE = 0;
       	EECON2 = 0x55;
       	EECON2 = 0xAA;
       	EECON1bits.WR = 1;
    	while(EECON1bits.WR); 
       	INTCONbits.GIE = 1;
       	EECON1bits.WREN = 0;
    
    
        InitializeSystem();
        etc ....
    I've only been programming PICs for a couple months... the possibilities are so endless. The 18F4550 with USB connection is the coolest thing since sliced bread..

  2. #2
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126


    Did you find this post helpful? Yes | No

    Default

    ...the possibilities are so endless. The 18F4550 with USB connection is the coolest thing since sliced bread..
    I have to agree that the USB pics and the ease of using them with PBP has really got my excited again about dreaming up cool projects and making them a reality!

    bill.

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 15:46
  2. PICKit2 - warning about configuration words
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 4th August 2009, 15:01
  3. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 07:26
  4. Bootloader and EEPROM
    By milestag in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th November 2005, 23:57
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 20:59

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