Hi Frank-Christian,

For small EEPROM you can use the EEPROM char driver directly, please
take a look inside drivers/eeprom/

Then in your board side you just need to do something like this:

finfo("Initialize I2C%d\n", AT24_I2C_BUS);
      i2c = sam_i2c_master_initialize(AT24_I2C_BUS);
      if (!i2c)
        {
          ferr("ERROR: Failed to initialize I2C%d\n", AT24_I2C_BUS);
          return -ENODEV;
        }

      /* Now bind the I2C interface to the AT24 I2C EEPROM driver */

      finfo("Bind the AT24 EEPROM driver to I2C%d\n", AT24_I2C_BUS);
      ret = ee24xx_initialize(i2c, 0x50, path, EEPROM_AT24CM02, false);
      if (ret < 0)
        {
          ferr("ERROR: Failed to bind I2C%d to the AT24 EEPROM driver\n",
               AT24_I2C_BUS);
          return -ENODEV;
        }

Also you need to remember to disable the write protection (WP) pin:

/* Enable EEPROM Writting (put WP pin to 0) */

      (void)sam_configport(PIN_EEPROM_WP);
      (void)sam_portwrite(PIN_EEPROM_WP, 0);

BR,

Alan

On 4/29/21, Frank-Christian Kruegel <nu...@istda.com> wrote:
> Hi.
>
> I'm currently porting NuttX to some proprietary compute modules with
> STM32F7 and STM32H7. Each and every board has got a small AT24MAC402 256
> Byte EEPROM with additional UID and MAC address accessible under a
> second I2C address, and many boards have an additional AT24C256 32kB
> EEPROM.
>
> I've had a look at the At24 driver and example board drivers. For the
> 32k EEPROM using a file system seems a good idea. The small ID EEPROM
> however is another story. 256 bytes seem to me way to small to use a
> file system on it. And how do I extract the 6 bytes of MAC address
> residing in the midde of the second bank?
>
> How is this designed to work? I have no problem using the at24 driver as
> a base for something own, but I'd rather like to use what is there or
> feed my own solution back into the main repository so others can reuse it.
>
> Best Regards
>
> Frank-Christian
>
> Datasheet for AT24MAC402/602:
> https://ww1.microchip.com/downloads/en/DeviceDoc/I%C2%B2C-Compatible-(Two-Wire)-Serial-EEPROM-with-a-Factory%E2%80%91Programmed-EUI-48%E2%84%A2-or-EUI-64%E2%84%A2-Address-Plus-a-Unique-Factory-Programmed-128%E2%80%91Bit-Serial-Number-2%E2%80%91Kbit-(256x8)-20006430A.pdf
>

Reply via email to