Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tofino SPI EEPROM Read/Write Size #42

Open
CommitThis opened this issue Jan 22, 2025 · 1 comment
Open

Tofino SPI EEPROM Read/Write Size #42

CommitThis opened this issue Jan 22, 2025 · 1 comment
Labels
question Further information is requested

Comments

@CommitThis
Copy link

CommitThis commented Jan 22, 2025

Hello! Good to see that the SDE has been (or is in the process of being) open sourced.

So we (APS Networks) recently came across an issue with verifying the contents of the attached SPI EEPROM for (I think) PCIe link training or something similar. It appears that using the SPI functions in the lld module are set up for a 2-byte address space. However:

  • In our later systems we have a 1Mbit part attached (I'm not sure how much this matters); and,
  • The register map uses three bytes to control the target address; and,
  • The SPI functions populate bytes 0 and 1 of these registers with the least significant second byte plus one and the least significant byte respectively; meaning that,
  • The most significant byte in the target address register ends up being the second least significant address byte; and,
  • The middle byte in the target address register ends up being the least significant byte of the intended address.

The consequence of this is that we were essentially getting garbage from an EEPROM dump using the aforementioned functions. We have copied and modified the code from the SDE to at least one of our BSPs, but if it is true that it was always intended to be three byte addressing irrespective of the supplied EEPROM part, then I could produce a PR for review.

Edit: So it may not be the case that, underneath the hood, this is not what happens with the registers, but the point is illustrative and modifying (at least) the address buffer to be three bytes and bit shifted accordingly addresses the issue.

@fruffy fruffy added the question Further information is requested label Jan 23, 2025
@rrao-bfn
Copy link

Please note below define in lld_spi_if.h.
Modifications to support 1Mbit part should be fine.
Please ensure changes are backward compatible with 512 Kbits part.

/* SPI EEPROM constants /
#define BF_SPI_EEPROM_SIZE (512 * 1024 / 8) _/ 512 Kbits part */*_
#define BF_SPI_EEPROM_WR_SIZE 4 /
write 4 bytes at a time /
#define BF_SPI_EEPROM_RD_CMD_SIZE
2 /
bytes to write to issue a eeprom read
/
#define BF_SPI_EEPROM_RD_SIZE 4 /
write 4 bytes at a time */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants