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 <Ti...@JTi.uk.com.INVALID> on 2021/08/24 16:39:52 UTC

SPI EEPROM

The more time I spend with nuttx the more I think I just haven't found some
treasure trove of documentation somewhere. All I seem to end up doing is
searching every single file for some kind of clue as to what to do!

 

I have an SPI EEPROM device. Menuconfig allows me to set it up, lovely! I
end up with

CONFIG_EEPROM=y

CONFIG_SPI_EE_25XX=y

 

(Also SPI mode and frequency).

 

Now what..

 

If I search for either of those CONFIG parameters, the first is not
referenced anywhere (apart from my .config), the second confirms that it
will include spi_xx25xx.c as a source. Getting there..

 

It'll be ee25xx_initialize(FAR struct spi_dev_s *dev, FAR char *devname, int
devtype, int readonly) I need to call - makes sense.

 

Only there is no explanation, or examples of, how to make that call, and a
Google search doesn't help either.

 

Next step will be to look for examples of spi_dev_s and see if I can deduce
it somehow.

 

Just how am I supposed to know how to call that initialisation code? Which
is why I started this question with the observation that surely I must be
missing something somewhere!!??

 

Yes, it's a bit of a whinge, but also a request for help..please :)


Re: Re[2]: SPI EEPROM

Posted by Tim Hardisty <Ti...@JTi.uk.com.INVALID>.
Thanks Vadim – that’s pretty much the conclusion I had come to.

 

Tim.

 

 

 


Subject: Re[2]: SPI EEPROM

 

 

Hi Tim,

 

You could search for any spi device being initialized. Search for spi_dev_s being declared in boards folder for some board, use it as an example and do the same initialization.

 

 


Re[2]: SPI EEPROM

Posted by Вадим Ястребов <wo...@mail.ru.INVALID>.
Hi Tim,

You could search for any spi device being initialized. Search for spi_dev_s being declared in boards folder for some board, use it as an example and do the same initialization.

Vadim


Sent from Mail.ru app for iOS


Tuesday, August 24, 2021, 3:16 PM -0400 from timh@jti.uk.com.invalid  <ti...@jti.uk.com.invalid>:
>AT24 is I2C and this is well supported in NuttX. AT25 is SPI and is what I have (AT25128) and it is not well supported, with no example code or boards that support it (that I can find)
>
> 
>
> 
>
> 
>
> 
>
>From: Gregory Nutt < spudaneco@gmail.com >
>Reply to: < dev@nuttx.apache.org >
>Date: Tuesday, 24 August 2021 at 20:11
>To: < dev@nuttx.apache.org >
>Subject: Re: SPI EEPROM
>
> 
>
> 
>
>That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look it “just worked” ☹
>
> 
>
>There is support for the AT24 in other SAM boards.  Search for AT24 in 
>
>defconfigs, I find
>
> 
>
>boards/arm/samv7/same70-xplained/
>
>boards/arm/samv7/samv71-xult/
>
>boards/arm/xmc4/xmc4500-relax
>
> 
>
>There is even simulated AT24 support:
>
> 
>
>boars/sim/sim/sim
>
> 
>
>You should be able to duplicate the logic from the samv7 boards.
>
> 
>
> 
>

Re: SPI EEPROM

Posted by Tim Hardisty <Ti...@JTi.uk.com.INVALID>.
Thanks Alan – all my SPI pins are configured. That was easy to work out :)

I will follow this tomorrow and I’m sure it will all seem easier in the morning!

 

From: Alan Carvalho de Assis <ac...@gmail.com>
Reply to: <de...@nuttx.apache.org>
Date: Tuesday, 24 August 2021 at 20:59
To: <de...@nuttx.apache.org>
Subject: Re: SPI EEPROM

 

Hi Tim,

 

It is very straightforward, basically you will replace:

 

FAR struct i2c_master_s *i2c;

 

i2c = stm32_i2cbus_initialize(AT24_I2C_BUS);

 

mtd = at24c_initialize(i2c);

 

 

WITH:

 

 

FAR struct spi_dev_s *spi;

 

spi = sam_spibus_initialize(AT25_SPI_PORTNO);

 

mtd = at25_initialize(spi);

 

 

But of course, if you don't know how to configure the SPI pins

(including the GPIO pin CS), nothing will work.

 

For Atmel/Microchip SAMxx family SPI, I think

boards/arm/samv7/samv71-xult/src/sam_st7789.c could be a good

reference.

 

BR,

 

Alan

 

On 8/24/21, Tim Hardisty <Ti...@jti.uk.com.invalid> wrote:

AT24 is I2C and this is well supported in NuttX. AT25 is SPI and is what I

have (AT25128) and it is not well supported, with no example code or boards

that support it (that I can find)

 

 

 

 

 

 

 

 

 

From: Gregory Nutt <sp...@gmail.com>

Reply to: <de...@nuttx.apache.org>

Date: Tuesday, 24 August 2021 at 20:11

To: <de...@nuttx.apache.org>

Subject: Re: SPI EEPROM

 

 

 

 

 

That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look it

“just worked” ☹

 

 

 

There is support for the AT24 in other SAM boards.  Search for AT24 in

 

defconfigs, I find

 

 

 

boards/arm/samv7/same70-xplained/

 

boards/arm/samv7/samv71-xult/

 

boards/arm/xmc4/xmc4500-relax

 

 

 

There is even simulated AT24 support:

 

 

 

boars/sim/sim/sim

 

 

 

You should be able to duplicate the logic from the samv7 boards.

 

 

 

 

 

 

 


Re: SPI EEPROM

Posted by Tim Hardisty <Ti...@JTi.uk.com.INVALID>.
That isn't quite right, Alan, as the mtd at25_initialize routine is for 
SPI FLASH not SPI EEPROM - it tries to read an ID.

I have replied to my other thread with the solution for AT25 SPI EEPROM, 
for others to refer to if they want

On 24/08/2021 20:59, Alan Carvalho de Assis wrote:
> Hi Tim,
>
> It is very straightforward, basically you will replace:
>
> FAR struct i2c_master_s *i2c;
>
> i2c = stm32_i2cbus_initialize(AT24_I2C_BUS);
>
> mtd = at24c_initialize(i2c);
>
>
> WITH:
>
>
> FAR struct spi_dev_s *spi;
>
> spi = sam_spibus_initialize(AT25_SPI_PORTNO);
>
> mtd = at25_initialize(spi);
>
>
> But of course, if you don't know how to configure the SPI pins
> (including the GPIO pin CS), nothing will work.
>
> For Atmel/Microchip SAMxx family SPI, I think
> boards/arm/samv7/samv71-xult/src/sam_st7789.c could be a good
> reference.
>
> BR,
>
> Alan
>
> On 8/24/21, Tim Hardisty <Ti...@jti.uk.com.invalid> wrote:
>> AT24 is I2C and this is well supported in NuttX. AT25 is SPI and is what I
>> have (AT25128) and it is not well supported, with no example code or
>> boards
>> that support it (that I can find)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> From: Gregory Nutt <sp...@gmail.com>
>> Reply to: <de...@nuttx.apache.org>
>> Date: Tuesday, 24 August 2021 at 20:11
>> To: <de...@nuttx.apache.org>
>> Subject: Re: SPI EEPROM
>>
>>
>>
>>
>>
>> That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look
>> it
>> “just worked” ☹
>>
>>
>>
>> There is support for the AT24 in other SAM boards.  Search for AT24 in
>>
>> defconfigs, I find
>>
>>
>>
>> boards/arm/samv7/same70-xplained/
>>
>> boards/arm/samv7/samv71-xult/
>>
>> boards/arm/xmc4/xmc4500-relax
>>
>>
>>
>> There is even simulated AT24 support:
>>
>>
>>
>> boars/sim/sim/sim
>>
>>
>>
>> You should be able to duplicate the logic from the samv7 boards.
>>
>>
>>
>>
>>
>>

Re: SPI EEPROM

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Tim,

It is very straightforward, basically you will replace:

FAR struct i2c_master_s *i2c;

i2c = stm32_i2cbus_initialize(AT24_I2C_BUS);

mtd = at24c_initialize(i2c);


WITH:


FAR struct spi_dev_s *spi;

spi = sam_spibus_initialize(AT25_SPI_PORTNO);

mtd = at25_initialize(spi);


But of course, if you don't know how to configure the SPI pins
(including the GPIO pin CS), nothing will work.

For Atmel/Microchip SAMxx family SPI, I think
boards/arm/samv7/samv71-xult/src/sam_st7789.c could be a good
reference.

BR,

Alan

On 8/24/21, Tim Hardisty <Ti...@jti.uk.com.invalid> wrote:
> AT24 is I2C and this is well supported in NuttX. AT25 is SPI and is what I
> have (AT25128) and it is not well supported, with no example code or boards
> that support it (that I can find)
>
>
>
>
>
>
>
>
>
> From: Gregory Nutt <sp...@gmail.com>
> Reply to: <de...@nuttx.apache.org>
> Date: Tuesday, 24 August 2021 at 20:11
> To: <de...@nuttx.apache.org>
> Subject: Re: SPI EEPROM
>
>
>
>
>
> That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look it
> “just worked” ☹
>
>
>
> There is support for the AT24 in other SAM boards.  Search for AT24 in
>
> defconfigs, I find
>
>
>
> boards/arm/samv7/same70-xplained/
>
> boards/arm/samv7/samv71-xult/
>
> boards/arm/xmc4/xmc4500-relax
>
>
>
> There is even simulated AT24 support:
>
>
>
> boars/sim/sim/sim
>
>
>
> You should be able to duplicate the logic from the samv7 boards.
>
>
>
>
>
>

Re: SPI EEPROM

Posted by Tim Hardisty <Ti...@JTi.uk.com.INVALID>.
AT24 is I2C and this is well supported in NuttX. AT25 is SPI and is what I have (AT25128) and it is not well supported, with no example code or boards that support it (that I can find)

 

 

 

 

From: Gregory Nutt <sp...@gmail.com>
Reply to: <de...@nuttx.apache.org>
Date: Tuesday, 24 August 2021 at 20:11
To: <de...@nuttx.apache.org>
Subject: Re: SPI EEPROM

 

 

That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look it “just worked” ☹

 

There is support for the AT24 in other SAM boards.  Search for AT24 in 

defconfigs, I find

 

boards/arm/samv7/same70-xplained/

boards/arm/samv7/samv71-xult/

boards/arm/xmc4/xmc4500-relax

 

There is even simulated AT24 support:

 

boars/sim/sim/sim

 

You should be able to duplicate the logic from the samv7 boards.

 

 


Re: SPI EEPROM

Posted by Gregory Nutt <sp...@gmail.com>.
> That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look it “just worked” ☹

There is support for the AT24 in other SAM boards.  Search for AT24 in 
defconfigs, I find

boards/arm/samv7/same70-xplained/
boards/arm/samv7/samv71-xult/
boards/arm/xmc4/xmc4500-relax

There is even simulated AT24 support:

boars/sim/sim/sim

You should be able to duplicate the logic from the samv7 boards.


Re: SPI EEPROM

Posted by Tim Hardisty <Ti...@JTi.uk.com.INVALID>.
I have 3 different SAMA5D2 eval board and have used them for years. I have had my custom board running “bare metal” code based on the Atmel code with no problems. Everything works, including the many many custom device on the board. I can swim. Using Lvgl too.

 

I made the decision to move to NuttX as I hoped it would make it easier to write the final app as I need USB host, USB device, and a file system. It feels, right now, like it was a bad move as the documentation is seemingly incomplete.

 

There is no point me getting yet another eval board just to prove that boards that are already supported work. Or should work - the SAMA5 eval boards are “supported” but are full of errors (e.g. flexcom is based on SAMA5D3 which is different; SAMA5D2 has MCAN but the D3 has CAN and needs a completely different driver; and so on. PRs to follow!!). As I have found, even basic devices such as nor flash or SPI EEPROM have only minimal support and, more importantly, no documentation that’s worth using.

 

I will just have to keep struggling, googling, grepping, and hoping to hit lucky. I will add to the documentation once I have it working. If I get it working.

 

And this is not aimed at you, Alan, as I know you are trying hard to help.

 

 

 

From: Alan Carvalho de Assis <ac...@gmail.com>
Reply to: <de...@nuttx.apache.org>
Date: Tuesday, 24 August 2021 at 19:42
To: <de...@nuttx.apache.org>
Subject: Re: SPI EEPROM

 

Hi Tim,

 

The process to get AT25 SPI is similar, but for SPI you need to get

the CS pin configure besides the other four SPI pins.

 

Is this your first time using SPI on NuttX?

 

There are some tutorials at NuttX Channel explaining how to use SPI on

NuttX, like using SDCard over SPI. I suggest you to start with a board

that has everything in place already, like the STM32F4Discovery or

BluePill (stm32f103-minimum).

 

Also the guys from MicroROS wrote a more technical tutorial about how

SPI works on NuttX:

 

https://github.com/micro-ROS/NuttX/issues/29

 

There is not theoretical class of swimming, you need to enter in the

water, just start in the shallow place: stm32 + sdcard spi for

example.

 

BR,

 

Alan

 

On 8/24/21, Tim Hardisty <Ti...@jti.uk.com.invalid> wrote:

That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look it

“just worked” ☹

 

 

 

 

 

 

 

From: Alan Carvalho de Assis <ac...@gmail.com>

Reply to: <de...@nuttx.apache.org>

Date: Tuesday, 24 August 2021 at 18:01

To: <de...@nuttx.apache.org>

Subject: Re: SPI EEPROM

 

 

 

Hi Tim,

 

 

 

You are right, Documentation is one of our "Achilles tendon".

 

 

 

But, of course, some times it is also the user search fault, maybe

 

they don't have the Google-fun skills yet (please don't take it as

 

personal).

 

 

 

If you search for NuttX EEPROM Tutorial

 

 

 

It will returns this tutorial:

 

 

 

https://www.youtube.com/watch?v=qzjf2JtgYN0

 

 

 

Please get us to improve this situation, write a tutorial at:

 

nuttx/Documentation/guides/ about it.

 

 

 

BR,

 

 

 

Alan

 

 

 

On 8/24/21, Tim <Ti...@jti.uk.com.invalid> wrote:

 

The more time I spend with nuttx the more I think I just haven't found some

 

treasure trove of documentation somewhere. All I seem to end up doing is

 

searching every single file for some kind of clue as to what to do!

 

 

 

 

 

 

 

I have an SPI EEPROM device. Menuconfig allows me to set it up, lovely! I

 

end up with

 

 

 

CONFIG_EEPROM=y

 

 

 

CONFIG_SPI_EE_25XX=y

 

 

 

 

 

 

 

(Also SPI mode and frequency).

 

 

 

 

 

 

 

Now what..

 

 

 

 

 

 

 

If I search for either of those CONFIG parameters, the first is not

 

referenced anywhere (apart from my .config), the second confirms that it

 

will include spi_xx25xx.c as a source. Getting there..

 

 

 

 

 

 

 

It'll be ee25xx_initialize(FAR struct spi_dev_s *dev, FAR char *devname,

 

int

 

devtype, int readonly) I need to call - makes sense.

 

 

 

 

 

 

 

Only there is no explanation, or examples of, how to make that call, and a

 

Google search doesn't help either.

 

 

 

 

 

 

 

Next step will be to look for examples of spi_dev_s and see if I can deduce

 

it somehow.

 

 

 

 

 

 

 

Just how am I supposed to know how to call that initialisation code? Which

 

is why I started this question with the observation that surely I must be

 

missing something somewhere!!??

 

 

 

 

 

 

 

Yes, it's a bit of a whinge, but also a request for help..please :)

 

 

 

 

 

 

 

 

 


Re: SPI EEPROM

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Tim,

The process to get AT25 SPI is similar, but for SPI you need to get
the CS pin configure besides the other four SPI pins.

Is this your first time using SPI on NuttX?

There are some tutorials at NuttX Channel explaining how to use SPI on
NuttX, like using SDCard over SPI. I suggest you to start with a board
that has everything in place already, like the STM32F4Discovery or
BluePill (stm32f103-minimum).

Also the guys from MicroROS wrote a more technical tutorial about how
SPI works on NuttX:

https://github.com/micro-ROS/NuttX/issues/29

There is not theoretical class of swimming, you need to enter in the
water, just start in the shallow place: stm32 + sdcard spi for
example.

BR,

Alan

On 8/24/21, Tim Hardisty <Ti...@jti.uk.com.invalid> wrote:
> That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look it
> “just worked” ☹
>
>
>
>
>
>
>
> From: Alan Carvalho de Assis <ac...@gmail.com>
> Reply to: <de...@nuttx.apache.org>
> Date: Tuesday, 24 August 2021 at 18:01
> To: <de...@nuttx.apache.org>
> Subject: Re: SPI EEPROM
>
>
>
> Hi Tim,
>
>
>
> You are right, Documentation is one of our "Achilles tendon".
>
>
>
> But, of course, some times it is also the user search fault, maybe
>
> they don't have the Google-fun skills yet (please don't take it as
>
> personal).
>
>
>
> If you search for NuttX EEPROM Tutorial
>
>
>
> It will returns this tutorial:
>
>
>
> https://www.youtube.com/watch?v=qzjf2JtgYN0
>
>
>
> Please get us to improve this situation, write a tutorial at:
>
> nuttx/Documentation/guides/ about it.
>
>
>
> BR,
>
>
>
> Alan
>
>
>
> On 8/24/21, Tim <Ti...@jti.uk.com.invalid> wrote:
>
> The more time I spend with nuttx the more I think I just haven't found some
>
> treasure trove of documentation somewhere. All I seem to end up doing is
>
> searching every single file for some kind of clue as to what to do!
>
>
>
>
>
>
>
> I have an SPI EEPROM device. Menuconfig allows me to set it up, lovely! I
>
> end up with
>
>
>
> CONFIG_EEPROM=y
>
>
>
> CONFIG_SPI_EE_25XX=y
>
>
>
>
>
>
>
> (Also SPI mode and frequency).
>
>
>
>
>
>
>
> Now what..
>
>
>
>
>
>
>
> If I search for either of those CONFIG parameters, the first is not
>
> referenced anywhere (apart from my .config), the second confirms that it
>
> will include spi_xx25xx.c as a source. Getting there..
>
>
>
>
>
>
>
> It'll be ee25xx_initialize(FAR struct spi_dev_s *dev, FAR char *devname,
>
> int
>
> devtype, int readonly) I need to call - makes sense.
>
>
>
>
>
>
>
> Only there is no explanation, or examples of, how to make that call, and a
>
> Google search doesn't help either.
>
>
>
>
>
>
>
> Next step will be to look for examples of spi_dev_s and see if I can deduce
>
> it somehow.
>
>
>
>
>
>
>
> Just how am I supposed to know how to call that initialisation code? Which
>
> is why I started this question with the observation that surely I must be
>
> missing something somewhere!!??
>
>
>
>
>
>
>
> Yes, it's a bit of a whinge, but also a request for help..please :)
>
>
>
>
>
>
>
>

Re: SPI EEPROM

Posted by Tim Hardisty <Ti...@JTi.uk.com.INVALID>.
That’s AT24 I2C not AT25 SPI EEPROM unfortunatel,  and from a quick look it “just worked” ☹

 

 

 

From: Alan Carvalho de Assis <ac...@gmail.com>
Reply to: <de...@nuttx.apache.org>
Date: Tuesday, 24 August 2021 at 18:01
To: <de...@nuttx.apache.org>
Subject: Re: SPI EEPROM

 

Hi Tim,

 

You are right, Documentation is one of our "Achilles tendon".

 

But, of course, some times it is also the user search fault, maybe

they don't have the Google-fun skills yet (please don't take it as

personal).

 

If you search for NuttX EEPROM Tutorial

 

It will returns this tutorial:

 

https://www.youtube.com/watch?v=qzjf2JtgYN0

 

Please get us to improve this situation, write a tutorial at:

nuttx/Documentation/guides/ about it.

 

BR,

 

Alan

 

On 8/24/21, Tim <Ti...@jti.uk.com.invalid> wrote:

The more time I spend with nuttx the more I think I just haven't found some

treasure trove of documentation somewhere. All I seem to end up doing is

searching every single file for some kind of clue as to what to do!

 

 

 

I have an SPI EEPROM device. Menuconfig allows me to set it up, lovely! I

end up with

 

CONFIG_EEPROM=y

 

CONFIG_SPI_EE_25XX=y

 

 

 

(Also SPI mode and frequency).

 

 

 

Now what..

 

 

 

If I search for either of those CONFIG parameters, the first is not

referenced anywhere (apart from my .config), the second confirms that it

will include spi_xx25xx.c as a source. Getting there..

 

 

 

It'll be ee25xx_initialize(FAR struct spi_dev_s *dev, FAR char *devname,

int

devtype, int readonly) I need to call - makes sense.

 

 

 

Only there is no explanation, or examples of, how to make that call, and a

Google search doesn't help either.

 

 

 

Next step will be to look for examples of spi_dev_s and see if I can deduce

it somehow.

 

 

 

Just how am I supposed to know how to call that initialisation code? Which

is why I started this question with the observation that surely I must be

missing something somewhere!!??

 

 

 

Yes, it's a bit of a whinge, but also a request for help..please :)

 

 

 


Re: SPI EEPROM

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Tim,

You are right, Documentation is one of our "Achilles tendon".

But, of course, some times it is also the user search fault, maybe
they don't have the Google-fun skills yet (please don't take it as
personal).

If you search for NuttX EEPROM Tutorial

It will returns this tutorial:

https://www.youtube.com/watch?v=qzjf2JtgYN0

Please get us to improve this situation, write a tutorial at:
nuttx/Documentation/guides/ about it.

BR,

Alan

On 8/24/21, Tim <Ti...@jti.uk.com.invalid> wrote:
> The more time I spend with nuttx the more I think I just haven't found some
> treasure trove of documentation somewhere. All I seem to end up doing is
> searching every single file for some kind of clue as to what to do!
>
>
>
> I have an SPI EEPROM device. Menuconfig allows me to set it up, lovely! I
> end up with
>
> CONFIG_EEPROM=y
>
> CONFIG_SPI_EE_25XX=y
>
>
>
> (Also SPI mode and frequency).
>
>
>
> Now what..
>
>
>
> If I search for either of those CONFIG parameters, the first is not
> referenced anywhere (apart from my .config), the second confirms that it
> will include spi_xx25xx.c as a source. Getting there..
>
>
>
> It'll be ee25xx_initialize(FAR struct spi_dev_s *dev, FAR char *devname,
> int
> devtype, int readonly) I need to call - makes sense.
>
>
>
> Only there is no explanation, or examples of, how to make that call, and a
> Google search doesn't help either.
>
>
>
> Next step will be to look for examples of spi_dev_s and see if I can deduce
> it somehow.
>
>
>
> Just how am I supposed to know how to call that initialisation code? Which
> is why I started this question with the observation that surely I must be
> missing something somewhere!!??
>
>
>
> Yes, it's a bit of a whinge, but also a request for help..please :)
>
>