Bootloader Class Reference


Overview


The Bootloader object provides an alternate method for downloading firmware to Metis in case the upper partition of the Metis EEPROM is corrupted, and renders the Command mode (described in Programmer API) inoperable.

The EEPROM in Hermes and Angelia consists of two 1 MB code partitions.

Normally, the Bootloader jumper is not installed, and the FPGA runs the command mode code that is in the upper 1 MB of the EEPROM. When the Bootloader jumper is installed, the FPGA runs the Bootloader code that is in the lower 1 MB of the EEPROM.

The Bootloader jumper is JP12 on Hermes, JP17 on Angelia and JP1 on the stand-alone Metis board.

When the Bootloader jumper is installed, the Metis interface will not respond to any IP (Internet protocol) packets; it only responds to raw packets that are sent to MAC address 11:22:33:44:55:66. Replies from the Bootloader also originates from this hardwired MAC address.
MetisDiscovery will not find a Metis board that is configured for bootloader mode. The Metis board also does not appear in any Ethernet router's tables.

The bootloader partition of the EEPROM is protected against erasure, and except for extremely rare conditions (bad FPGA timing, for example), one can fall back to using the bootloader API when the programmer API is not functional. The bootloader code should be present in all assembled Hermes, Angelia boards. It is designed to only be changed by using an
Altera USB-Blaster cable, using Altera's Quartus II software.

An example Xcode project that makes use of the Bootloader class can be found in the form of a working
Metis Bootloader application.


Tasks


Creating a Bootloader object

- initWithInterface:


Writing to Metis Device

- sendErase
-
writeProgram:


Requesting information from Metis Device

- readIP
-
readMAC:


Checking Erase Status

- eraseStatus



Instance Methods


eraseStatus

Check the status of the Metis device after a -sendErase command. After sending the -sendErase, the -eraseStatus method should be repeatedly called until the returned value from it is no longer 0 (ERASE_WAITING). -eraseStatus returns immediately without blocking.

- (int)eraseStatus

Return Value

The returned integer is one of the following

 0 (ERASE_WAITING) waiting for erase command to complete (this can take more than 10 seconds),
 1 (ERASE_SUCCESSFUL) erase command completed successfully,
-1 (ERASE_FAILED) 20 seconds have elapsed without a reply from the Metis device.





initWithInterface:

Initializes the Bootloader object. The networkInterface is the name of the interface, e.g., "en0".

- (id)initWithInterface:(char*)networkInterface

Parameters

networkInterface
a C string that is the name of the network interface.


Return Value

An initialized Bootloader object.




sendErase

Erases the upper 1 MB of the FLASH memory. This has to be performed before writing the new firmware into the EEPROM. Erasing can take more than 10 seconds.

After sending a -sendErase message, repeatedly call
-eraseStatus to inspect the reply from the Metis device until an ERASE_DONE (1) or ERASE_TIMEDOUT (-1) is received from -eraseStatus.

- (Boolean)sendErase

Return Value

True, if the erase command has been sent to the Metis device.




writeProgram:

Data is sent in 256 byte blocks. Blocks are sent in sequence they are read from the firmware file. If the last block does not use up all 256 bytes, the remaining bytes should be filled with 0xff.

The Bootloader object checks for a reply from the Metis device and returns true if the block has been successfully written.

- (Boolean)sendProgram:(unsigned char*)dataBlock

Parameters

dataBlock
byte data,

Return Value

True, if the Metis device acknowledges successful writing of the 256 byte EEPROM block.