fmc-write-eeprom.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. fmc-write-eeprom
  2. ================
  3. This module is designed to load a binary file from /lib/firmware and to
  4. write it to the internal EEPROM of the mezzanine card. This driver uses
  5. the `busid' generic parameter.
  6. Overwriting the EEPROM is not something you should do daily, and it is
  7. expected to only happen during manufacturing. For this reason, the
  8. module makes it unlikely for the random user to change a working EEPROM.
  9. However, since the EEPROM may include application-specific information
  10. other than the identification, later versions of this packages added
  11. write-support through sysfs. See *note Accessing the EEPROM::.
  12. To avoid damaging the EEPROM content, the module takes the following
  13. measures:
  14. * It accepts a `file=' argument (within /lib/firmware) and if no
  15. such argument is received, it doesn't write anything to EEPROM
  16. (i.e. there is no default file name).
  17. * If the file name ends with `.bin' it is written verbatim starting
  18. at offset 0.
  19. * If the file name ends with `.tlv' it is interpreted as
  20. type-length-value (i.e., it allows writev(2)-like operation).
  21. * If the file name doesn't match any of the patterns above, it is
  22. ignored and no write is performed.
  23. * Only cards listed with `busid=' are written to. If no busid is
  24. specified, no programming is done (and the probe function of the
  25. driver will fail).
  26. Each TLV tuple is formatted in this way: the header is 5 bytes,
  27. followed by data. The first byte is `w' for write, the next two bytes
  28. represent the address, in little-endian byte order, and the next two
  29. represent the data length, in little-endian order. The length does not
  30. include the header (it is the actual number of bytes to be written).
  31. This is a real example: that writes 5 bytes at position 0x110:
  32. spusa.root# od -t x1 -Ax /lib/firmware/try.tlv
  33. 000000 77 10 01 05 00 30 31 32 33 34
  34. 00000a
  35. spusa.root# insmod /tmp/fmc-write-eeprom.ko busid=0x0200 file=try.tlv
  36. [19983.391498] spec 0000:03:00.0: write 5 bytes at 0x0110
  37. [19983.414615] spec 0000:03:00.0: write_eeprom: success
  38. Please note that you'll most likely want to use SDBFS to build your
  39. EEPROM image, at least if your mezzanines are being used in the White
  40. Rabbit environment. For this reason the TLV format is not expected to
  41. be used much and is not expected to be developed further.
  42. If you want to try reflashing fake EEPROM devices, you can use the
  43. fmc-fakedev.ko module (see *note fmc-fakedev::). Whenever you change
  44. the image starting at offset 0, it will deregister and register again
  45. after two seconds. Please note, however, that if fmc-write-eeprom is
  46. still loaded, the system will associate it to the new device, which
  47. will be reprogrammed and thus will be unloaded after two seconds. The
  48. following example removes the module after it reflashed fakedev the
  49. first time.
  50. spusa.root# insmod fmc-fakedev.ko
  51. [ 72.984733] fake-fmc: Manufacturer: fake-vendor
  52. [ 72.989434] fake-fmc: Product name: fake-design-for-testing
  53. spusa.root# insmod fmc-write-eeprom.ko busid=0 file=fdelay-eeprom.bin; \
  54. rmmod fmc-write-eeprom
  55. [ 130.874098] fake-fmc: Matching a generic driver (no ID)
  56. [ 130.887845] fake-fmc: programming 6155 bytes
  57. [ 130.894567] fake-fmc: write_eeprom: success
  58. [ 132.895794] fake-fmc: Manufacturer: CERN
  59. [ 132.899872] fake-fmc: Product name: FmcDelay1ns4cha
  60. Accessing the EEPROM
  61. =====================
  62. The bus creates a sysfs binary file called eeprom for each mezzanine it
  63. knows about:
  64. spusa.root# cd /sys/bus/fmc/devices; ls -l */eeprom
  65. -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcAdc100m14b4cha-0800/eeprom
  66. -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcDelay1ns4cha-0200/eeprom
  67. -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcDio5cha-0400/eeprom
  68. Everybody can read the files and the superuser can also modify it, but
  69. the operation may on the carrier driver, if the carrier is unable to
  70. access the I2C bus. For example, the spec driver can access the bus
  71. only with its golden gateware: after a mezzanine driver reprogrammed
  72. the FPGA with a custom circuit, the carrier is unable to access the
  73. EEPROM and returns ENOTSUPP.
  74. An alternative way to write the EEPROM is the mezzanine driver
  75. fmc-write-eeprom (See *note fmc-write-eeprom::), but the procedure is
  76. more complex.