You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Tim Hardisty <ti...@hardisty.co.uk> on 2023/05/25 16:35:00 UTC

SPI EEPROM

Could have sworn I had this working a year or 2 ago but it's stumped me today...

I have an SPI EEPROM device on my board, and use "ee25xx_initialize" to register it as /dev/at25. That works fine.

But I can't do anything with it.

Unlike at25_initialize, the ee25xx_initialize doesn't return mtd_dev_s, just a success/fail, so I can't then use an FTL etc to allow me to mount it in anyway.

How can I get this device mounted with some form of FS on it so I can read/write config data to it?

Perhaps FTL isn't the way to go; if so, I've forgotten what is!

Re: SPI EEPROM

Posted by Tim Hardisty <ti...@jti.uk.com.INVALID>.
Thanks for replies.

 

Alan – your video (which I had watched!) is for AT24 I2C EEPROM and it can’t be done in the same way for SPI EEPROM with no device ID to read back We had this same conversation a year or 2 ago when I was very new to NuttX, and I even found an archived email saying I’d sorted it, but no record of how I sorted it. My lack of thoroughness :(

 

Sebastien. Of course, it’s a character driver…der. I have been so bogged down in choosing a filesystem for the big NOR flash I lost the plot!

 

Gregory. Loop device – that’s what I used a couple of years ago! Not for real, but just to prove the device could be written to etc without having to do anything clever (i.e. just from an nsh prompt).

 

This device will be used to store a settings struct, so a character driver will work fine – I will probably use a FAT-formatted ram drive as an intermediary storage area to allow access via USB from PCs etc., probably using YAML formatting. Still thinking this all through.

 

From: Tim Hardisty <ti...@hardisty.co.uk>
Reply to: <de...@nuttx.apache.org>
Date: Thursday, 25 May 2023 at 17:35
To: "dev@nuttx.apache.org" <de...@nuttx.apache.org>
Subject: SPI EEPROM

 

Could have sworn I had this working a year or 2 ago but it's stumped me today...

 

I have an SPI EEPROM device on my board, and use "ee25xx_initialize" to register it as /dev/at25. That works fine.

 

But I can't do anything with it.

 

Unlike at25_initialize, the ee25xx_initialize doesn't return mtd_dev_s, just a success/fail, so I can't then use an FTL etc to allow me to mount it in anyway.

 

How can I get this device mounted with some form of FS on it so I can read/write config data to it?

 

Perhaps FTL isn't the way to go; if so, I've forgotten what is!

 


Re: SPI EEPROM

Posted by "Alan C. Assis" <ac...@gmail.com>.
Hi Tim,

There are two ways to access EEPROM on NuttX, one is using this
character driver that you are using and the other is accessing it as a
MTD.

I created a video tutorial some years ago explaining how to do it:
https://www.youtube.com/watch?v=qzjf2JtgYN0

Keep in mind that using MTD with I2C EEPROM is tooo sloooowwww!

Using the character driver you need to take care of the EEPROM
manually, reading/writing to it like it was a binary file.

BR,

Alan

On 5/25/23, Sebastien Lorquet <se...@lorquet.fr> wrote:
> Hi,
>
> This eeprom is not an mtd device, it is too small for any filesystem,
> usually. So it's just a character device that makes the eeprom appear as a
> fixed size file.
>
> If you need an eeprom mtd, the driver could be extended to make it behave as
> a mtd device.
>
> Sebastien
>
> Le 25 mai 2023 16:35:00 UTC, Tim Hardisty <ti...@hardisty.co.uk> a écrit :
>>Could have sworn I had this working a year or 2 ago but it's stumped me
>> today...
>>
>>I have an SPI EEPROM device on my board, and use "ee25xx_initialize" to
>> register it as /dev/at25. That works fine.
>>
>>But I can't do anything with it.
>>
>>Unlike at25_initialize, the ee25xx_initialize doesn't return mtd_dev_s,
>> just a success/fail, so I can't then use an FTL etc to allow me to mount
>> it in anyway.
>>
>>How can I get this device mounted with some form of FS on it so I can
>> read/write config data to it?
>>
>>Perhaps FTL isn't the way to go; if so, I've forgotten what is!
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma
> brièveté.

Re: SPI EEPROM

Posted by Sebastien Lorquet <se...@lorquet.fr>.
Hi,

This eeprom is not an mtd device, it is too small for any filesystem, usually. So it's just a character device that makes the eeprom appear as a fixed size file.

If you need an eeprom mtd, the driver could be extended to make it behave as a mtd device.

Sebastien

Le 25 mai 2023 16:35:00 UTC, Tim Hardisty <ti...@hardisty.co.uk> a écrit :
>Could have sworn I had this working a year or 2 ago but it's stumped me today...
>
>I have an SPI EEPROM device on my board, and use "ee25xx_initialize" to register it as /dev/at25. That works fine.
>
>But I can't do anything with it.
>
>Unlike at25_initialize, the ee25xx_initialize doesn't return mtd_dev_s, just a success/fail, so I can't then use an FTL etc to allow me to mount it in anyway.
>
>How can I get this device mounted with some form of FS on it so I can read/write config data to it?
>
>Perhaps FTL isn't the way to go; if so, I've forgotten what is!

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.

Re: SPI EEPROM

Posted by Gregory Nutt <sp...@gmail.com>.
On 5/25/2023 10:35 AM, Tim Hardisty wrote:
> I have an SPI EEPROM device on my board, and use "ee25xx_initialize" to register it as /dev/at25. That works fine.
>
> But I can't do anything with it.
Sure you can.  That is a character device, not an MTD or block driver, 
and it should behave like the whole device is one file.  You should be 
able to open it, read from it, write to it, seek to positions on the EEPROM.
> Unlike at25_initialize, the ee25xx_initialize doesn't return mtd_dev_s, just a success/fail, so I can't then use an FTL etc to allow me to mount it in anyway.
But it does register a character device.
> How can I get this device mounted with some form of FS on it so I can read/write config data to it?
Most EEPROMs are not big enough to hold any meaningful file system. But 
you can always access the character device like it were a file as 
described above.

There are some larger AT25 EEPROM parts that could possibly hold a file 
system, but there is no MTD device for AT25 EEPROM (there is an AT24 
EEROM MTD driver).  You could probably use a loop device on top of the 
AT25 character device if you wanted to mount the character driver.