User`s manual
22 rabbit.com How Dynamic C Cold Boots the Target System
6. The initial loader then reads 7 bytes from the serial port. First a 4-byte address field: the physical
address to place the secondary loader, followed by a 2-byte length field: the number of bytes in the sec-
ondary loader. The 7th byte is a checksum (simple summation) of the previous 6 bytes. Whether or not
the checksum matched, it is echoed back as an acknowledgement.
7. The data segment is then mapped to the given physical location, using the DATASEG register. The data
segment boundary will also be set to 0x6000, so the secondary loader will always be located at the
same place in logical space, regardless of where it physically resides.
8. The initial loader finally enters a loop where it receives the specified number of bytes that compose the
secondary loader program (pilot.bin sent by the PC) and writes those bytes starting at 0x6000 (log-
ical). The first byte sent this way MUST be 0xCC, as an indicator to the initial loader. This byte will be
stored as 0x00 (nop), instead of 0xCC. A 2-byte checksum will be sent after the secondary loader has
been received, using the 8-bit Fletcher Algorithm (see RFC1145 for details), such that the load can be
verified. After all of the bytes are received, and the checksum has been sent, program execution jumps
to 0x6000.
9. The secondary loader does a wrap-around test to determine how much RAM is available, and reads the
flash and CPU IDs. This information is made available for transmittal to Dynamic C when requested.
10.The secondary loader now enters a finite state machine (FSM) that is used to implement the Dynamic
C/Target Communications protocol. Dynamic C requests the CPU ID, flash ID, RAM size, and 19200
baud rate divisor to define internally defined constants and macros. Dynamic C uses the flash ID to
lookup flash parameters that are sent back to the secondary loader so that it can initialize flash
write/erase routines. At this stage, the compiler can request the baud rate be increased to a higher value.
The secondary loader is now ready to load a BIOS and user program.
11.Dynamic C now compiles the BIOS and user programs. Both are compiled to a file, then the file is
loaded to the target using the Pilot BIOS’ FSM. After the loading is complete, Dynamic C, using the
Pilot BIOS’ FSM, tells the Pilot BIOS to map flash to 0x00000, map RAM to 0x80000, and start pro-
gram execution at 0x0000, thereby running the compiled BIOS.
12.If the Pilot BIOS detects a RAM compile or small-sector flash that uses sector-write mode, Dynamic C
uses a slightly different loading procedure. The BIOS will be compiled as normal, and loaded using the
Pilot BIOS. After the BIOS is loaded, Dynamic C will tell the Pilot BIOS to start it, and the rest of the
program will be loaded through the compiled BIOS.
13.Once the compiled BIOS starts up, it runs some initialization code. This includes setting up the serial
port for the debug baud rate (set in the Communications tab in Options | Project Options), setting up
serial interrupts and starting the BIOS FSM. Dynamic C sets a breakpoint at the beginning of main()
and runs the program up to the breakpoint. The board has been programmed, and Dynamic C is now in
debug mode.
14.If the programming cable is removed and the target board is reset, the user’s program will start running
automatically because the BIOS will check the SMODE pins to determine whether to run the user
application or enter the debug kernel.