Adding Flash Devices to the EDK

From Sage Wiki

Jump to: navigation, search

There will be times when EDK users need to be able to use SPI Flash devices which were not included in a given EDK release. To this end, we added the means by which a user can add flash devices for their own EDK. In general, it works like this:

  • Create a data file in your sage_edk/eclipse folder (FlashDeviceData.xml)
  • Fill in the data for your flash device
  • Restart the EDK

When the EDK starts it loads the internal SPI Flash device definitions first, and then it loads definitions from the FlashDeviceData.xml file found in the eclipse folder. This makes it possible to add new SPI Flash devices or to override existing device definitions.

Here is the template for the FlashDeviceData.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<flashdevicedata>
   <spi>
      <spiflash
         mfr_name=""
         device_name=""
         size=""
         mfr_id="" mem_id="" dev_id=""
         max_bytes_per_write=""
         cmd_data_read=""
         cmd_erase_4kb=""
         cmd_erase_8kb=""
         cmd_erase_16kb=""
         cmd_erase_32kb=""
         cmd_erase_64kb=""
         cmd_erase_device=""
         cmd_byte_program=""
         cmd_power_down=""
         cmd_power_up=""
         cmd_read_id=""
         cmd_read_jedec_id=""
         cmd_status_reg_read=""
         cmd_status_reg_write=""
         cmd_status_reg_write_enable=""
         cmd_write_disable=""
         cmd_write_enable=""
         block_protect_0=""
         block_protect_1=""
         block_protect_2=""
         block_protect_3=""
         block_protect_4=""
         block_protect_5=""
         block_protect_6=""
         block_protect_7=""
         block_protect_8=""
         block_protect_9=""
         block_protect_a=""
         block_protect_b=""
         block_protect_c=""
         block_protect_d=""
         block_protect_e=""
         block_protect_f=""
         max_erase_frequency=""
         max_read_frequency=""
         max_write_frequency=""
         max_erase_frequency=""
      />
   </spi>
</flashdevicedata>

For each SPI Flash device to be added, create a new spiflash entry between <spi> and </spi>.

Here's the breakdown of the "spliflash" entry (note: all hex data is "undecorated" -- no leading "0x" and no trailing "h"):

Field Description Examples
mfr_name The human-readable name of the device manufacturer. mfr_name="Macronix"
device_name The human-readable name of the device. device_name="MX25L4005"
size The size of the device in the format <decimal number><modifier>, like 16MBIT or 2GB. The <modifier> can be one of {MBIT, GBIT, KB, MB, GB}. size="8MBIT"

size="2GB"

mfr_id, mem_id, dev_id These are the three bytes (hexadecimal notation) returned from sending command 0x9F (JEDEC ID) to the device via the SPI controller. mfr_id is the same for all devices by a manufacturer (e.g. Winbond is EF, SST is BF, Macronix is C2); mem_id and dev_id are the memory and device id which you will find in the device's documentation. mfr_id="C2" mem_id="20" dev_id="13"
max_bytes_per_write This is the maximum number of bytes (decimal notation) that could be written per write operation. For page-programmable devices, this is 256 (or whatever the page size is); for byte-programmable devices, this is 1. If the device can take two bytes at a time, this would be 2. max_bytes_per_write="1"

max_bytes_per_write="256"

cmd_data_read If the "read" command is supported, this is the hex value of that command.
Leave the string empty ("") if the device does not support this command.
cmd_data_read="03"

or cmd_data_read="" if not supported

cmd_erase_4kb If the device supports erasing 4KB blocks, this is the hex value of that command.
Leave the string empty ("") if the device does not support erasing 4KB blocks.
cmd_erase_4kb="20"

or cmd_erase_4kb="" if not supported

cmd_erase_8kb If the device supports erasing 8KB blocks, this is the hex value of that command.
Leave the string empty ("") if the device does not support erasing 8KB blocks.
cmd_erase_8kb="55"

or cmd_erase_8kb="" if not supported

cmd_erase_16kb If the device supports erasing 16KB blocks, this is the hex value of that command.
Leave the string empty ("") if the device does not support erasing 16KB blocks.
cmd_erase_16kb="AA"

or cmd_erase_16kb="" if not supported

cmd_erase_32kb If the device supports erasing 32KB blocks, this is the hex value of that command.
Leave the string empty ("") if the device does not support erasing 32KB blocks.
cmd_erase_32kb="52"

or cmd_erase_32kb="" if not supported

cmd_erase_64kb If the device supports erasing 64KB blocks, this is the hex value of that command.
Leave the string empty ("") if the device does not support erasing 64KB blocks.
cmd_erase_64kb="D8"

or cmd_erase_64kb="" if not supported

cmd_erase_device If the "Erase chip/Erase device" command is supported, this is the hex value of that command.
Leave the string empty ("") if the device does not support this command.
cmd_erase_device="C7"

or cmd_erase_device="" if not supported

cmd_byte_program If the "byte program" or "page program" command is supported, this is the hex value of that command.
Leave the string empty ("") if the device does not support this command.
cmd_byte_program="02"

or cmd_byte_program="" if not supported

cmd_power_down If the "Power down device" command is supported, this is the hex value of that command.
Leave the string empty ("") if the device does not support this command.
cmd_power_down="B9"

or cmd_power_down="" if not supported

cmd_power_up If the "Power up device" command is supported, this is the hex value of that command.
Leave the string empty ("") if the device does not support this command.
cmd_power_up="AB"

or cmd_power_up="" if not supported

cmd_read_id If the "Read ID" command is supported, this is the hex value of that command.
Leave the string empty ("") if the device does not support this command.
cmd_read_id="90"

or cmd_read_id="" if not supported

cmd_read_jedec_id If the "Read JEDEC ID" command is supported, this is the hex value of that command. This should always be 9F. cmd_read_jedec_id="9F"
cmd_status_reg_read If the "Read Status Register" command is supported, this is the hex value of that command. cmd_status_reg_read="05"

or cmd_status_reg_read="" if not supported

cmd_status_reg_write If the "Write Status Register" command is supported, this is the hex value of that command. cmd_status_reg_write="01"

or cmd_status_reg_write="" if not supported

cmd_status_reg_write_enable If the "Enable writes to Status Register" command is supported, this is the hex value of that command. This is usually sent before cmd_status_reg_write. cmd_status_reg_write_enable="06"

or cmd_status_reg_write_enable="" if not supported

cmd_write_disable If the "Disable Write" command is supported, this is the hex value of that command. cmd_write_disable="04"

or cmd_write_disable="" if not supported

cmd_write_enable If the "Enable Write" command is supported, this is the hex value of that command. This is sent before writing a byte to the storage array. cmd_write_enable="06"

or cmd_write_enable="" if not supported

block_protect_0 - block_protect_f These are the block protection values represented by the middle 4 bits in the status register (e.g. a mask of 0b00111100, or 0x3C).

Each entry represents the range of addresses (inclusive) which are protected by the given value for block protection bits, in the format <start_address>-<end_address>.
Special keywords are "all" and "none".

block_protect_0="none"

block_protect_1="3F0000-3FFFFF"
block_protect_2="3E0000-3FFFFF"
block_protect_3="3C0000-3FFFFF"
block_protect_4="380000-3FFFFF"
block_protect_5="300000-3FFFFF"
block_protect_6="200000-3FFFFF"
block_protect_7="all"
block_protect_8="none"
block_protect_9="3F0000-3FFFFF"
block_protect_a="3E0000-3FFFFF"
block_protect_b="3C0000-3FFFFF"
block_protect_c="380000-3FFFFF"
block_protect_d="300000-3FFFFF"
block_protect_e="200000-3FFFFF"
block_protect_f="all"

max_erase_frequency Not yet used; represents the maximum clock frequency (MHz, decimal notation) for erase operations. max_erase_frequency="75"
max_read_frequency Not yet used; represents the maximum clock frequency (MHz, decimal notation) for read operations. max_read_frequency="33"
max_write_frequency Not yet used; represents the maximum clock frequency (MHz, decimal notation) for write operations. max_write_frequency="50"
max_erase_time The manufacturer specified maximum time in seconds to allow for chip erase functions to complete. max_erase_time="50"
Personal tools
Create a book