hi everybody, i am trying to understand an851 - A flash bootloader for PIC16 and PIC18 Devices. On page 4 it says
Quote:
Entering and Leaving Boot Mode
With the bootloader firmware loaded, there are two distinct modes of operation: Boot Mode and User Mode. The bootloader uses the last location of data memory to determine which mode to run in. A value of FFh indicates Boot mode. Any other value indicates User mode. Thus, a new part with its data memory not initialized will automatically enter Boot mode the first time.
i have checked ex_bootloader.c and ex_bootloader.lst but i cant seem to find that it changes a certain location to FFh. Did the example code ex_bootloader.c apply the statement above?
please help..
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
Posted: Sun Feb 12, 2012 12:39 pm
Code:
//// for PCH ex 18F2620
/// +---------------+<-0
/// | reserved |<--0x40,0x8F main
/// +---------------+ <-- 1FF loader addr
/// | load_prog | <-- loader addr+9
/// | |
/// |real_load_prog | <-- loader addr+10
/// | atoi |
/// . .
/// . Loader .
/// | size=0x3ff |
/// | |
/// +---------------+ <--- 4FF end of loader
/// | application | <--- loader end+2 to loader end +9
// | reset vectors | <--- loader end +10=0x509 restart vector
// +---------------+
/// | real |
//// | application |
/// | code area |
/// . .
/// . .
/// | |
/// +---------------+ <- top of memory -debug space-256 bytes ex FB00
/// | |
/// | ROM for appl |
/// | structs paras |
/// | |
/// | XX| <-- downloadflag word at top of memory-2 ex 0xFBFE .. 9xFBFF
/// +---------------+ <--- top of program-debugger space 0xFC00
/// . .
/// | Debug 400 |
/// +---------------+ <-PROGRAM_MEMORY-1 or 0xFFFF
Above is a typical memory map including space for the CCS IDE debuger
it contains two logical elements the real application and the bootloader and if debugging using the CCS debugger code for the debugger.
Typically a semaphore is assigned ( a flag in ROM which both the loader element and the application element share read/write access to)
The pic starts up and if it is a normal start up ( no special conditions ) vectors to the loader at 1FF which if the flag is set to run the application element it re-vectors to the start of the application otherwise it stays with the bootloader which loads the application resets the semaphore flag and reboots the PIC.The PIC on reboot then calls the loader which re-vectors to the application...if the application receives a signal could be a pin value or something via rs232 I2C SPI etc and the signal means start bootloading
then the application writes the semaphore and resets the PIC to reboot.
Bootloading isn't easy to explain.....this probably falls short...but the library has examples and others may have a better explanation
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
Posted: Sun Feb 12, 2012 2:58 pm
I think his question is more along the lines of "OK, so who sets the 0xFF" value in that top data memory/flag location. I believe the answer to that is - a non-programmed part has all 0xFF in the data memory (which will cause the boot loader to default to boot mode). It is the responsibility of the users program when it runs to set that flag to some other value so "bootloader mode" is not the default (or to set it to 0xFF if they want it to go back into bootloader mode next time it restarts).
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum