decorative bevel

B.2 Cerebellum Firmware Communications Protocol

It is possible to directly interact with the firmware over a standard serial terminal. This is helpful if your OS does not yet have supported downloading utilities, or you have a custom hardware serial interface that doesn't easily detach.


The Cerebellum firmware supports a rich set of commands that can be used to set several board features, as well as program, verify, and erase your Cerebellum's memory.

Entering Programming Mode

Depending on the firmware in your Cerebellum, you will need to enter a special key sequence to enter programming mode. To communicate with the firmware, you'll need to connect to the serial port at the firmware settings and send the code word.

Even if your Cerebellum program communicates at a different speed, you must set the serial settings as listed to communicate with the Firmware.
Firmware VersionKey Sequence as ASCIIKey Sequence as Hexadecimal
v0.3<enter> MOO<enter>0x0D204D4F4F0D
V1.03b+fhqwhgads0x666871776867616473


Settings for Communicating with the Cerebellum Firmware

You need to set your serial port in the following configuration in order to communicate with the Firmware.
Important Settings

Baud Rate115200
Bits8
Paritynone
Stop Bits1
Line Delay200 msec


Serial settings in Tera Term 2.3


A line delay of 200 ms (sometimes up to 500 ms) is required to reliably program the device. See the filesend sequence for more information.

If you have set the firmware to slow speed(V1.03C+ only), you will need to set your baud rate to 9600.

Programming Mode (pre-V1.03C)

After successfully receiving the proper key sequence, the Cerebellum will output the following:

[V1.03b] Ready to Program:r

It has automatically entered programming mode, and is awaiting a file via the filesend sequence. Once it has finished, it will output Done and run your just-downloaded program.

If your firmware is obsolete - it is strongly recommended you follow the instructions to update your firmware to the most current version.

Cerebellum Firmware Interface Commands (V1.03C+ Only)

After successfully receiving the proper key sequence, the Cerebellum will output the following:

[V1.03c]:

The ':' is the firmware prompt, which supports the commands listed in the table. After typing in a command, hitting <enter> (or sending 0x0D) will cause it to process the command. Most commands return 'D' on completion or 'E' on error. Some commands may require more user interaction before they can complete, see below:

CommandAscii ValueHex ValueDescription
Program'p'0x70Enters programming mode, starts filesend sequence
Verify'v'0x76Enters verify mode, starts filesend sequence
Read All'r'0x72Begins full read sequence
Read - Prog EEPROM'rp'0x7270Begins program EEPROM-only read sequence
Read - Config'rc'0x7263Begins config-only read sequence
Read - Data EEPROM're'0x7265Begins data EEPROM-only read sequence
Erase'e'0x65Erases all program and data EEPROM (but not configuration)
Info'i'0x69Firmware information - Prints firmware data.
Set Serial (slow)'ss'0x7373Sets Firmware serial to 9600 after next power cycle.
Set Serial (fast)'sf'0x7366[Default] Sets Firmware serial to 115200 after next power cycle.
Set Turnoff (enabled)'de'0x6465Enables Firmware Timeout.
Set Turnoff (disabled)'dd'0x6464[Default] Disables Firmware Timeout.
Exit'x'0x78Exits firmware (restarting main program)
Abort'x'0x78Aborts current filesend sequence


For information on what has changed or using older firmware, see the changelog.

Firmware Filesend Sequence

The Cerebellum firmware follows a special protocol for receiving files in Cerebellum Hex Format. It has software handshaking, meaning that special routines(such as in our Downloader) can quickly and reliably send files to the Cerebellum. If that is unavailable, it is also possible to blindly transfer files to the Cerebellum - but only with a proper delay. In Tera Term, this is set by using the Line Delay area. 200 ms is the minimum necessary for reliable transfers - although sometimes you may need to set this to 500 ms or higher!

Cerebellum outputDescriptionRequired Host Action
'r'Request for lineSend the current line in the .HEX file, including newline
'a'Line acknowledgedDiscard current line; move on to next line


To cancel programming/verification, use the Exit/Abort command(V1.03C+ only). Note: Any lines already programmed will remain programmed - very unstable programs may result.

Firmware Read Sequence

When a read command is sent, it will begin sending back the data in human readable format. This is useful in verifying that the code on the device is as you expect it to be, or for reading data EEPROM state variables when the Cerebellum is not running. By default the read command will output the entire contents of the PIC's memory - over 1000 lines of text! If you only are interested in a specific section of memory, use one of the more specific read commands.

Example of Cerebellum Read output

0000: 3000 008A 2D18 0000 100A 108A 110A 0782
0008: 3445 3472 3472 346F 3472 3420 3461 3474
0010: 3420 3425 344C 3458 343A 3420 3452 3465 
...
1FE8: 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 
1FF0: 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 
1FF8: 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 
2000: 3FFF 3FFF 3FFF 3FFF 0000 3F15 09A6 3FFA 
2100: FF FF FF FF FF FF FF FF 
2108: FF FF FF FF FF FF FF FF 
2110: FF FF FF FF FF FF FF FF 
...
21E8: FF FF FF FF FF FF FF FF 
21F0: FF FF FF FF FF FF FF FF 
21F8: FF FF FF FF FF FF FF FF 
Line Format
Address
Word address of current line, in hexadecimal. Program data ranges from 0x0000-0x1FFF. The configuration data resides at 0x2000. Data EEPROM is in the address range of 0x2100-0x2200, though this area is byte-addressed and not word addressed.
Program Data
In the program data space, data is stored in 14-bit words(0x0000 - 0x3FFF). Note that an erased location in EEPROM is read as 0x3FFF.
Data EEPROM
In the data space, data is stored in 8-bit words(0x00 - 0xFF). Note that an erased location in EEPROM is read as 0xFF.
Device ID
The device ID is stored in parts in address locations 0x2000-0x2003. The device ID is 16 bits, comprised of the lower 4 bits of each address location.
Configuration Word
The configuration word specifies various hardware options on the PIC16F877. Many of these are specifically set by firmware(V1.03C+ only) and cannot be overwritten. For more information, see the fuses section.

Firmware Information Data


The Cerebellum will return a text string identifying itself, its options, and its target.
Information Packet Format
Firmware Version
This is the version of the Firmware you are interacting with.
Target
This is the target architecture that it is designed to program.
Target Program ROM
This is the addressable program space on the target processor.
Target Data EEPROM
This is the addressable data EEPROM space on the target processor.
Serial Setting
Allows you to choose Fast or Slow serial for the Firmware. This is useful if you are using a legacy connection and would like to be able to program over a slow link. Changing this value is permanent. Changes take effect after a power cycle.
  • Fast(default) - Baud Rate is 115200
  • Slow - Baud Rate is 9600
Firmware Timeout Setting
Allows you to disable the firmware interface after a short time. This is useful if you are having problems with the firmware intercepting your character strings and inadvertantly entering the programming interface. Changing this value is permanent. Changes take effect after a power cycle.
  • Enabled - After 3 seconds, programming interface is no longer accessible. The power light will quickly flash to indicate that the interface is disabled.
  • Disabled(default) - Entering programming interface is always possible.
If you forget what state your firmware is in, and are having trouble accessing it, consider using the Emergency Jumper. Once in firmware mode, change the values back to known values.