|
|
|
|
|
|
|
||
|
||
|
|
||
May 2000 |
Revision 1.06 |
|
© 2000 Peripheral Issues |
All rights reserved. |
|
This document describes the Persistor Boot Monitor (PBM) program that resides in the bottom 16KB of flash memory and which quietly takes care of running PicoDOS or your application program when the CF1 starts up. Most users will seldom need to interact directly with PBM, and will instead let the more capable PicoDOS handle changes to startup and program execution tasks. Unless you are installing custom software or operating systems that bypass PicoDOS, you can safely skip this entire section.
A tiny portion of PBM is the first bit of software to execute from a power-up or reset. Its primary job is to figure out what program should take over at reset and start it running. Failing that, it performs its secondary job as a monitor program to load and test new programs into the CF1. PBM is a minimalist monitor that's meant to let you load and run more sophisticated software. It accepts standard Motorola S records and MotoCross binary load files which can be stored to RAM or flash memory, and with the help of PBM, configured to automatically run at startup. PBM also provides a limited set of commands to examine memory locations to help in debugging loads that do not work correctly.
PBM lives at the base of flash and executes its principle reset vectoring function directly from flash. When required to do anything more challenging than this, it moves itself to RAM and runs from 32KB of RAM at the base of what is normally considered the PicoDOS private data area (0x4000 - 0x7FFF). PBM is entirely self-contained and can accomplish all of its maintenance tasks with no references to external driver software. Its terse and unforgiving command set reflects the size limitations and the infrequent need to use a boot monitor where software like PicoDOS is generally resident to provide more elegant services.
You will automatically end up in the boot monitor if there's a fatal error trying to launch PicoDOS or your flashed application program. At any time, you can also force the CF1 to enter the boot monitor by grounding the /IRQ5 signal during reset. The /IRQ5 signal is internally pulled high with a 10K resistor and connects at pin C39 which is on the outside edge of the 2x25 connector strip, the 6th pin from end, and adjacent to pin C40 which has a white marking. Once in PBM, you can use the BOOT command to force future resets to always enter PBM.
From reset, PBM performs only the most minimal hardware setup which basically activates and maps the flash chip selects to read-only operation at 0xE00000-0xEFFFFF, activates and maps the SRAM chip selects to 0x000000-0x03FFFF, tickles the watchdog timer, sets all the port F (IRQ) lines to simple digital inputs, and takes a look at /IRQ5 (port F, line 5, CF1 pin 39) which is pulled high with an onboard 10K resistor.
If /IRQ5 is not being held low,PBM first looks for a valid startup vector in the battery backed static RAM which could indicate that it is resuming from a suspend operation or performing some kind of special controlled reset (see suspend/resume). If this is found and additional verification fields check out, PBM will defer and vector to the suspended program which should resume where it left off, with the resuming application responsible for any additional re-initializations.
If /IRQ5 is not held low, and there is no valid RAM startup
vector, the PBM looks in the OS-VEE (Operating System section of the
Virtual EEPROM) for startup instructions. PBM scans the boot action
table which contains 512 four bit instructions and looks for the
first nibble that contains one or more nonzero bits with the
following interpretation:
Action Code (Hex)
Description
0 Deleted entry - skip this and continue scanning table
1-8
Reserved for future use
9 Flash absolute at 0xE10000 - PicoDOS
A Flash absolute at 0xE40000 - User Flash
B Flash absolute at 0xE80000 - Alternate Flash
C Flash absolute at 0xEC0000 - Alternate Flash
D PBM - timeout to LPSTOP (RS-232 wakes)
E PBM - timeout to LPHALT (RESET to wake)
F Table End - PBM - no timeouts
Boot actions are selected using the PBM or PicoDOS BOOT command described ahead. Erased flash (all FFs) looks like an immediate end to the table and tells PBM to just enter the monitor. Older boot action codes are zeroed as you change the startup behavior and PBM simply skips these entries when it scans the table. You can switch the boot mode over 500 times before the OS-VEE sector needs an erase/refresh cycle (handled transparently by PicoDOS) and since you can do that over 100,000 times, you've got about 50 million changes before you have to worry about wear and tear on the flash. PBM is pretty smart about searching the table and even with over 500 zeroed nibbles, it only takes a couple hundred microseconds to determine the appropriate action.
Flash Absolute: Action codes 9 to C vector to absolute flash addresses if the first word at the selected location is not 0x0000 (cleared) or 0xFFFF (erased). Otherwise PBM advances to the last table entry and resumes the search with behavior as described above for Flash Apps. By convention, action code 9 launches PicoDOS and action code A launches your main flash application at 0xE40000.
PBM Monitor: Action codes D to F all select PBM as the startup application, but they each specify different behaviors for situations when there could be nobody paying attention as is likely in a remote or embedded application. The action code F behavior is to stay on forever drawing about 10 mA until the batteries run our or somebody pulls the plug.
For all boot actions except F, PBM activates a timout mechanism to prevent the CF1 from failing a remote mission because some spurious software or hardware failure managed to force a reset or power cycling that concluded with the system entering PBM. Rather than just waiting forever for an operator's attention (which may never come) or for the batteries to wear out, PBM activates a sixty second countdown timer and announces this with the following additional signon message:
=== TIMEOUTS ACTIVATED ===
In also reminds anyone watching that a countdown is pending by periodically printing hints about the amount of time remaining. These come at one minute intervals for remaining time over one minute, ten second intervals for time remaining between ten seconds and one minute, and finally, once each second for the last ten seconds. With no intervention, this will look like:
RBM>60>50>40>30>20>10>9>8>7>6>5>4>3>2>1>
What happens after the timout expires depends on the current boot action. For boot action D, the CF1 will drop into LPSTOP mode until it sees some activity on its RS-232 receive line. For boot action E, the CF1 will drop into LPSTOP mode until the next reset or power cycling. For boot actions 9 through C, PBM will reset the CF1 in an effort to give the system another chance at completing its assigned mission.
Once in LPSTOP mode, the CF1 will draw about 300 microamps from the main supply if all of the digital I/O lines are actively driven or pulled high or low with resistors. If some lines are "floating", the current will vary, probably between one and ten milliamps. LPSTOP and the I/O pin descriptions are explained in the Persistor CF1 User's Manual.
For the D and E boot actions, each command typed in will will restart the timout when the <enter> key is hit. For all boot actions, entering the following command will unconditionally turn off the timouts until the next restart:
PBM>60>50>boot off turns off timeouts until the next reset Timeouts off PBM>
When PBM's monitor gets control, it performs additional hardware initializations to enable serial communications and to prevent the watchdog timer from interfering with the monitor. At this point, the system is running at 14.72MHz (for optimal high speed communications) and waiting in reduced power modes to receive command strings from the RS232 port at 9600 baud. All of the bidirectional I/O lines that do not perform RS232 functions revert to inputs from the reset and PBM leaves them as inputs. This implies that any I/O lines not pulled high or low will draw some small amount of current as expected of floating CMOS inputs. While in PBM, the CF1 electronics (exclusive of any external circuitry) will be drawing about 10 mA and will do so until you remove power or the batteries run out.
Persistor Boot Monitor signs on with a message similar to the following:
-------------------------- CF1 Persistor Boot Monitor (C) 1998 Peripheral Issues www.persistor.com V2.31 -------------------------- PBM>
From the PBM> prompt, you can enter any of the following commands which are described in detail ahead.
Command:
Parameters:
Description:
Enter PicoDOS
[new rate]
view/change the BAUD rate
[code]
view/change the boot target
[range]
check flash memory erased
[range]
clear (erase) flash memory
[range]
compute 32 bit CRC of memory range
[.X]
display previous error messages
[addr]
go (execute) to specified or last load
show this list of commands
[offset]
load hex (S) records from serial port
baud addr len
load binary data from MotoCross
[range]
memory display in hexadecimal
reset the CF1
write enable the flash
burn the current PBM image to flash
All commands may be entered in upper or lower case, and editing with the backspace is supported. Commands are acted on when you hit the <enter> key, and commands with possibly irreversible results (like CLEAR) will prompt you for confirmation before acting. All of the numeric command parameters (except for BAUD) expect hexadecimal numbers. Parameter shown in braces are optional, and multiple parameters should be separated with a comma or space character.
[range] Commands that expect a range will accept a starting address and ending address (inclusive), or a starting address followed by a colon (:) and a length value. For example, CRC E40000 EFFFFF and CRC E40000:C00000 yield the same results. Some commands (like MD) that expect a range will also accept just a start address and fill in an appropriate end address, while other commands will issue an error message.
PBM's command handling is based on a subset of the PicoDOS "CMD" library services. Refer to the Table Driven Command Processor for more details on usage.
PBM takes several precautions to prevent you or another computer talking to the CF1 from accidentally issuing a command that could erase or overwrite the contents of the flash memory. As described in the CF1 Startup section, two tables in the OS-VEE (Operating System section of the Virtual EEPROM) determine startup behavior. When the monitor mode is entered, the flash directory table determines the default behavior of commands that modify flash. If the entire flash directory table contains only erased entries, write and erase commands will be automatically enabled. If not, someone has presumably taken steps to put an image into flash and probably wants to protect it, so flash write and erase commands will be disabled.
When PBM first signs on, it will display one of the following messages:
== FLASH WRITES ENABLED == == FLASH WRITES DISABLED =
If writing is disabled, you can still manually enable writing, but you must do this in a specific sequence as detailed in the WREN command description.
The PICO command exits PBM by starting PicoDOS. PBM first makes sure that there's something in existance where PicoDOS is expected to reside in flash, and if it's not zero or 0xFFFF at the first location, PicoDOS gets launched.
The LO and LOAD commands let you load programs (or data) into RAM or flash memory. PBM uses the LO command to setup for receiving standard Motorola S records (hex files), and the LOAD command for receiving binary load files (CPM68K) from MotoCross. S records are a standard and universal format that is supported by almost all development tools, but their ASCII format and overhead data causes them to load at less than half the speed of binary data. MotoCross binary files have no such limitations, and in fact will auto adjust from the standard 9600 baud up to the maximum speed supported by your host computer (to 230kBaud). If you have MotoCross, use its built-in file loading features for the simplest and fastest operation.
The LO command exists primarily to allow developers to adapt the CF1 to development tools not directly supported. After typing LO and a carriage return, the monitor stops echoing characters and expects to receive a stream of S records, and does not return to command mode until it sees a final valid S record signaling the end. You can force the LO command to abort by sending a serial BREAK for 250 milliseconds. You may also specify an optional offset value (hex) which is added to each load address specified in the S records. This is primarily for development tools which always generate S records with a base address of zero. The LO command aborts on any type of error during the load and waits for the serial line to remain inactive for five seconds before displaying the error message and resuming command mode.
Only the RAM area from 0x010000 to 0x03FFFF (192KB) and the flash area from 0xE08000 to 0xEFFFFF (992KB) are valid load address for the S records. Any addresses out of this range will cause the command to fail. When flash memory is the target, MotoCross binary loads will automatically erase the necessary sectors, but when using S records, sectors falling into the load range must be manually erased before attempting the load. For flash loads, each line of S records is buffered to RAM, then written to flash when the checksum at the end of the line is verified, then the checksum is reverified on completion of the burn. The PBM buffers serial data while burning so your sending program does not need to insert delays or implement handshaking even at the highest baud rates.
The flash memory needs to be erased before you can load S records. This is necessary because erasing a flash sector typically takes about a second, but has a worst case specification of 15 seconds, and this is way too much data for the PBM to buffer at the highest data rates. You can only erase flash in the area from 0xE04000 to 0xEFFFFF, and with the exception of the first 32KB sector, all erases apply to 64KB sectors on even 64KB boundaries.
If you do not specify a range, these commands assume you want to clear or check the entire application area of flash (768KB) from 0xE40000 to 0xEFFFFF. When you specify an erase or check range, the start address must either be 0xE04000, 0xE08000, or on one of the fifteen even 64KB bounds (0xE10000, 0xE20000, ..., 0xEF0000). The end address does not have to fall on an even bound, but the entire sector containing the end address will be checked or erased.
The check command will either report back that the entire range is erased, or will list the first and last non-erased addresses in the range. The clear command assumes you have issued the WREN command and will validate the specified range then ask for confirmation to perform the erase. If you key in 'Y', PBM will erase any sectors in the range that are not already cleared and update you on its progress.
Erase Limitations: To protect the flash, once PBM has successfully completed an erase operation, it will no longer accept the CLEAR command. To erase again, you will need to go through a full reset cycle.
The G command lets you run a any program that's in RAM or flash memory. If you specify an address, that's where program execution will begin. If you don't specify an address and a LO or LOAD operation has completed successfully, execution will begin at the beginning load address, or the execution address if that was embedded in the start address field of the S records.
Before exiting, PBM disables the buffered RS232 driver and all interrupts and interrupt sources. You program will be on its own and can feel free to clobber any memory or registers formerly used by the boot monitor. Your running program cannot return to PBM and must perform an explici reset (using BIOSReset(), BIOSResetToPBM(), or BIOSResetToPicoDOS()) to get back to PicoDOS or the boot monitor.
MotoCross Note: When loading binary programs to RAM from MotoCross, it will automatically finish the load by sending a final 'G', and you need only hit <enter> to begin execution. Sometimes the echoed 'G' will not display properly in the MotoCross terminal window, but even without showing the 'G', MotoCross will run the loaded program if you just hit <enter>.
This command will compute and display a 32 bit cyclic redundancy check (CRC) value on an explicitly specified memory range or on the memory range of the most recent LO or LOAD command. It displays the start address, end address, and CRC as three eight digit hexadecimal numbers separated by one space character per value. This is primarily used by automated loaders like MotoCross to verify that a load transferred correctly.
PBM>crc e00000:100 CRC32 E00000-E000FF = F30310C5 PBM>
The 32 CRC value is generated using the same standard CCITT32 32 bit generating polynomial (x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1) used by the PicoDOS libraries, ZMODEM and Ethernet ( IEEE 802) protocols.
This command lets you view and control the reset behavior as described above. It shows what program gets to run at startup, where programs reside in flash, and whether or not the program has a valid CRC and will be allowed to run. This information is stored in the operating system portion of the virtual EEPROM and contains the name, start address, length, and 32 bit CRC. If you do not specify an action code in the command line, PBM will offer you the option of selecting a different startup option by keying in 9 or A-F after listing the available options as shown below:
PBM>BOOT Boot Options: 9 - PicoDOS at E10000 => A - Program at E40000 B - Program at E80000 C - Program at EC0000 D - PBM (LPSTOP timeout) E - PBM (SUSPEND timeout) F - PBM (no timeout) New Boot Action (9,A-F) [A] ?
PBM will let you choose a deleted of free file slot, but validity tests at reset will fail and you'll end up back in PBM just as if you'd chosen action code F.
With PBM 1.25 and above, you can type any of the following to make a quick and less cryptical change.
PBM>BOOT PICO <enter> next reset runs PicoDOS
PBM>BOOT APP <enter> next reset runs the application at 0xE40000
PBM>BOOT PBM <enter> next reset runs PBM
With PBM 2.31 and above, you can turn off timouts with the following command.
PBM>BOOT OFF <enter> turns off reset and lpstop timeouts
Development Notes: Action 9 is the CF1's normal startup mode for test and development and brings you into PicoDOS which will offer even more startup options and controls. Action A is the alternate primitive test and development mode when used with the standard flash load address of 0xE40000. Once set, each time you load a program, it automatically becomes the startup program and PBM simply resets to fully test your code the way it will actually operate. Remember, you can always return control to PBM by grounding IRQ5 (pin 39).
This command lets you specify a different baud rate for subsequent commands. Though PicoDOS allows to specify additional communications options, PBM limits these to 1 stop bit, 8 data bits, and no parity. You can select any arbitrary baud rate from 300 to 230,400 baud. The newly selected rate reverts to 9600 baud on the next reset.
Typing BAUD with no parameters simply displays the current setting which may not be precisely what you expected as the true rate is always some multiple of the system clock frequency (14.72MHz) divided by 32 times some baud divider. As shown below, choosing 9600 baud results in an actual baud rate of 9583 which is an error of less than 0.2% and well within the acceptable 2% error range for asynchronous communications.
PBM>baud 9600 Changing to 9600 BAUD Hit <return> when ready...<enter> 9583 BAUD,N PBM>
As shown above, PBM will send a message telling you to change your communications software to the new rate before actually making the change, then it will setup for the new baud rate and wait for the next incoming serial character to resume execution.
This command simply redisplays the most recent error message in case it has scrolled off the screen or was lost while a terminal was not connected. If no error is logged, the command simply says "None", otherwise it will display the last error text and clear the error flags. The load commands and others that operate on the flash save additional error information that may be displayed and cleared if appropriate.
PBM>err None PBM>blah Huh? PBM>err Error: "Huh?" 0:0, 0x0, 0x0 PBM>err None cleared from the last err command PBM>
The four field in the cryptic response are: numeric error code, error count, and two optional error dependent parameters. Only the first error code encountered is logged as some kinds of errors can result in meaningless cascading errors, and the error count lets you know if this has happened. Below are the likely error codes and decoding:
|
Code: |
Description: |
Parameter 1: |
Parameter 2: |
|
|
No error |
none (zero) |
none (zero) |
|
|
UART receive buffer overflow (probably during load) |
queue head |
queue tail |
|
|
Flash write or erase failed (timed out) |
failed address |
data word |
|
|
Attempted to burn flash at odd address |
failed address |
data word |
|
|
Attempted to burn a zeroed bit to one |
failed address |
data word |
|
|
Attempted to burn or erase an invalid flash address |
top address |
bottom address |
|
|
Attempted to erase a block more than one time |
top address |
bottom address |
|
|
S-Record (hex) load error |
failed address |
error code |
This command forces a complete system reset and is effectively the same as grounding the /RESET signal.
The memory display command will send the specified range of memory to the serial port as lines of hexadecimal values and their ASCII equivalent characters. Specifying just a starting address will display a single line of data. Typing the command with no parameters will advance the display address to the next line of data. Long displays of data can be interrupted by typing any key.
PBM>md e00000:20 00E00000 4EFA 0966 0000 0610 0000 0000 7707 3096 N..f........w.0. 00E00010 EE0E 612C 9909 51BA 076D C419 706A F48F ..a,..Q..m..pj.. PBM>md e00100 00E00100 C161 1DAB B666 2D3D 76DC 4190 01DB 7106 .a...f-=v.A...q. <enter> 00E00110 98D2 20BC EFD5 102A 71B1 8589 06B6 B51F .. ....*q....... <enter> 00E00120 9FBF E4A5 E8B8 D433 7807 C9A2 0F00 F934 .......3x......4 <enter> 00E00130 9609 A88E E10E 9818 7F6A 0DBB 086D 3D2D .........j...m=- <enter> PBM>
The command to enable writing of the flash is special in that it must be the first command you issue to PBM or you will not be able to perform any operations that write or erase the flash. In addition, /IRQ5 (pin C39) must be grounded when you enter the WREN command for it to be accepted. Not only that, but /IRQ5 must not be grounded when you confirm PBM's query to enable writing. If you forget to do this, the commands that need to write to flash will remind you. If you attempt this command after issuing other commands, you will be reminded about the necessary sequencing.
-------------------------- CF1 Persistor Boot Monitor (C) 1998 Peripheral Issues www.persistor.com V2.24 --------------------------I == FLASH WRITES DISABLED = === TIMEOUTS ACTIVATED === PBM>60>WREN (with pin C39 still grounded) Release 39 and confirm (Y/N) ? Y (with pin C39 released) == FLASH WRITES ENABLED == PBM>WREN Enabled! Flash ID = 0001225B PBM>
The second time you enter the command, it will fetch and display the flash ID code. You can now load flash programs or change the boot options.
The "MotoCross Support\CF1\Bin" directory of CF1 Developer's CD will contain the most recent version of PBM with a name something like "PBM338.2.30.RUN". You can load this using the MotoCross "Load CPM68K..." command from the "Transfer" menu. Hit <enter> to auto-go after MotoCross completes the load and you'll see the normal signon banner followed by the "WRITES ENABLED" message. At this point, you are running a new PBM image in RAM. To burn that image to flash, type the BURN command as shown.
PBM>BURN Burn from 4000 - 8000 to E00000 Are you sure (Y/N) ? Y Checking ... Erasing ... Burning ... Complete
When you update to a newer version of PicoDOS, you may be prompted with an offer to automatically update PBM by PicoDOS. Generally, you should just accept the offer.
|
|
|
|
|
|
Tel: 508-759-6434 |
|
Fax: 508-759-6436 |
|
|
||