Bug 6441 - Minnowboard UEFI + SpiDeviceDxe driver doesnot remove SPI Write Protection
Summary: Minnowboard UEFI + SpiDeviceDxe driver doesnot remove SPI Write Protection
Status: RESOLVED FIXED
Alias: None
Product: MinnowBoard MAX Firmware
Classification: Hardware Platforms
Component: minnowboard-uefi-firmware (show other bugs)
Version: unspecified
Hardware: MinnowBoard x86
: Undecided minor
Target Milestone: ---
Assignee: Vijai Kumar K
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2014-06-13 05:24 UTC by Vijai Kumar K
Modified: 2014-06-13 09:27 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vijai Kumar K 2014-06-13 05:24:11 UTC
In Minnowboard UEFI we have got EFI_SPI_PROTOCOL, Inside IntelE6xxRuPkg/SpiDeviceDxe folder we have SpiDeviceDxe.c file. It has a function called InitSpiDevice which has the following line of code which claims to remove write protection in SPI flash chip. 
Status = mSpiProtocol->Execute (
      mSpiProtocol,
      SPI_DEVICE_READ_STATUS_CMD_INDEX,
      SPI_FLASH_PART_OPCODE_WRITE_STATUS,
      SPI_DEVICE_PREFIX_OP_WRITE_S_EN_INDEX,
      TRUE,
      TRUE,
      TRUE,
      0,
      sizeof (Data),
      &Data,
      EnumSpiRegionAll
      );
By default WinBond SPI Flash is Not write protected on powerup (i.e BP0 BP1 BP2 are zero). I tried writing some value (0x55) into the Status Register using the above API, when i read back I should get 54(depending on the BITs which are write only). But I get "02". It is not actually writing the required opcode to the SPI.
Comment 1 Vijai Kumar K 2014-06-13 05:29:18 UTC
 We should pass the index of the opcode to be used to that API, here they have passed the opcode itself.
The code should be as follows: 
Pass SPI_DEVICE_WRITE_STATUS_CMD_INDEX as 3rd argument instead of  SPI_FLASH_PART_OPCODE_WRITE_STATUS

Status = mSpiProtocol->Execute (
      mSpiProtocol,
      SPI_DEVICE_READ_STATUS_CMD_INDEX,
      SPI_DEVICE_WRITE_STATUS_CMD_INDEX,
      SPI_DEVICE_PREFIX_OP_WRITE_S_EN_INDEX,
      TRUE,
      TRUE,
      TRUE,
      0,
      sizeof (Data),
      &Data,
      EnumSpiRegionAll
      );