Index
|> Using the Bootloader
|> Bootloader Modifications
The following is a summary of the information contained on the
Dontronics PIC-Loader page.
It discusses how to use the Bootloader with the Windows Hyperterminal program, but
other terminal emulators will work in a similar fashion.
Note that we have modified the original PICLoader slightly, as shown in the last
section below.
How to Use the Bootloader
1. Connect the BOT40 to a PC RS-232 port using a straight-through (not a "null-modem")
serial cable.
2. Start HyperTerminal.
- open a terminal session (ie, make a connection), and set it as a "direct connection" to
the appropriate COM port.
- in the "Port Settings" screen, select 9600-8-N-1 and flow control = none.
- go to the "File - Properties - Settings" menu, and make the following selections:
terminal-keys, Ctrl-H, ANSI mode.
- in the same menu under "ASCII Setup - ASCII Sending", select line feeds = off,
local echo = off, and line delay = 100ms [or greater].
- NOTE - correct setting of the line-delay value is important, since the eeprom
in the '877 chip needs time to write between data character receipts.
If assembled HEX files look ok, but there is trouble writing them to the PIC,
then a longer line-delay value may be necessary.
- in the same menu under "ASCII Setup - ASCII Receiving", select
wrap lines = on, line-feeds = off, and 7-bit data = off.
3. To Run the Bootloader
- Reset the target board to invoke the Bootloader.
- When the Bootloader starts you'll see a splash command screen (see below)
that displays information on the current version of both Bootloader and the user program code.
- If there is already a user program in memory, however, the program will start running.
If there is no user program loaded, the Bootloader will jump straight to the command prompt.
- Next you will get a message that says, if you press "?" at the command prompt,
you'll get a list of commands. The command set is explained in the next section.
Note - in the Rick Farmer PICLoader, if a user program has been previously loaded,
then it will automatically start executing when the chip is powered-up.
In order to break-out to the PICLoader, 2 steps are required:
- First, the RB6 pin on the PIC chip must be tied or pulled to ground.
- Secondly, a capital 'Z' must be received by the chip RS-232 port within 5-sec after power-up.
- if these conditions are met, then the PICLoader splash screen (below) will appear.
See modifications section below regards slight differences in accessing original and
modified Bootloaders.
4. PIC-LOADER Commands
8K PICLOADER v1.5
user code version = none
? - display this command screen
Q - Quit and jump to user code
U - Upload user code to program memory
D - Download user code from program memory
W - Write to EEPROM, "W DD @ AA"
R - Read from EEPROM, "R AA"
V - Display user code revision string
Note that the data eeprom referenced in commands 'W' and 'R'
is not the same as the code eeprom space.
5. The following sequence pertains to Uploading a Program to the '877 eeprom,
using the U command.
- an assembler .HEX file should have been prepared previously, using an ASCII-text editor
and assembled using MPASM, MPASMWIN, or another assembler or compiler tool.
This file should have been assembled into INHX8M format.
- press the U command, and a prompt will appear.
Type "y" to proceed with the upload. Any other input will cancel the download.
Press the "Return" key after each command.
- During the next 10-30 seconds the bootloader will proceed to erase the code and data
eeproms, and display '.' (dots) on the screen until this finishes. Then, "Ready" will appear,
and the bootloader will wait for file receipt.
- There are 2 ways to send a .HEX file to the target.
- First, the Windows copy+paste feature can be used to paste a .HEX file into the
Hyperterminal screen, after the 'Ready" message appears.
- Secondly, the Hyperterminal "Transfer - Send Text File" menu can be used to upload
the .HEX file.
- the Bootloader will read the file one line at a time and checksum each line before
programming the data the line contains.
- If there is an error, the Bootloader will issue one of the following messages:
invalid record type, checksum error, FLASH or EEPROM programming error,
attempting to overwrite the Bootloader, trying to program the CONFIG fuses (not allowed),
and non-hex characters in the hex file.
- The offending line number (in decimal) of the hex file being uploaded is included in the
error message to aid debugging.
- A programming error will give the address of the bad memory location.
- A successful upload will result in a success message and a prompt for a
code revision string, and a string of up to 31 characters, such as 'myprog 010105',
can be entered.
- An error will abort the upload and the rest of the file will be sent to the bit bucket.
- An unsuccessful upload will also erase the partial user image and previous revision string.
- An image is not marked as valid until the last line is checksummed and the last byte is
programmed.
- A loss of power or reset during upload will leave garbage in memory, but it will be marked
as such, and the part will be reported as blank.
6. To simply Erase the program stored in the '877 eeprom without writing a new program,
press the "Return" key alone after the U-command "Ready" prompt appears.
7. Use the D-command to Dump the current program image to the terminal in INHX8M format.
Storing a downloaded image is essentially the reverse of uploading an image.
This allows you to verify a code upload and retrieve data stored in user program space.
Data EEPROM memory is also included in the dumped image.
- Use the Hyperterminal "Transfer - Capture Text" menu to capture the file download
to disk.
The following ZIP file can be downloaded, and contains source and .HEX files for
the Rick Farmer PICLoader ver 1.5.
The .HEX files can be programmed into an erased PIC 16F876 or 16F877, 20-Mhz chip.
Note - when programming, do not use code protection.
These files do not work with 16F876A or 16F877A version "A" chips.
download:
PICLDR15.ZIP
(20 Kbytes, 01.2005).
|
<| Bootloader Modifications
We have made several minor modifications to the original Rick Farmer PICLoader, in order
to make it easier to use with the BOT40 boards.
- the default mode is now for operation with a 20 Mhz crystal, and 9600 baud serial port.
- the watchdog timer has been disabled.
- cpu pin RB6 no longer has to be held low in order to access the bootloader.
- as before, once a user program has been loaded, access to the bootloader is done by
sending capital 'Z' over the RS-232 port.
In the modified software, this must be done within 3 sec of power-up.
- the splash screen wording is slightly different.
- the modified bootloader is labelled as OTFLoader v 2.x to distinquish it from the original.
Uploading Program Code.
As described above, program files of .HEX format are generated using the Microchip assembler,
and uploaded to the bootloader internal code eeprom using ASCII file transfer mode on a
terminal emulator program.
First, the bootloader "U" command is used to erase the code space, and the file then transferred
at 9600 bps using 8N1 protocol.
Remember that line pacing/delay must be set to 100-msec or greater in the temrinal
software to give the bootloader time to write each line to the eeprom.
To erase a stored program, use the bootloader "U" command without a file transfer.
|
The following shows a sample bootloader session:
|
8K OTFLoader v2.0
user code version = none
? - Help
Q - Quit to user code
U - Upload user code
D - Download user code + data eeprom to PC
W - Write data eeprom, "W DD @ AA"
R - Read data eeprom, "R AA"
V - user code version
PIC>u
Are you sure? [y/N]>y
Erasing........................
Ready.
[... file xfer initiated here via the terminal emulator ...]
Upload ok
Enter user code version>myprog01
user code version = myprog01
PIC>v
user code version = myprog01
PIC>q
Jumping to user code
|
|
<| TOP
© Oricom Technologies, updated Jan 2005