TElmed
Posts: 3
Joined: Fri Jun 08, 2018 10:21 am

Use NAND Flash over SPI

Mon Jun 11, 2018 9:32 am

Hey guys,

so I wanted to try to add a nand flash (AT45DB041b) to my raspi through SPI.

Goals
  1. Test SPI
  2. Test NandFlash
  3. Find a driver to embed into system and put FS on it
1. Systemtests:
I enabled

Code: Select all

dtparam=spi=on
in /boot/config.txt,
I checked lsmod containing spi_bcm2835 (and spidev),
I verified existing /dev/spidev0.0 and /dev/spidev0.1
I downloaded spitest.c, compiled and ran it with the loopback jumper on and off the pins to verify functionality.
I made a python script with py-spidev also doing loopback tests.

2. Work start
System seems ready to continue, I connected the NAND Flash (It looks flaky, but I've tested the pins with the multimeter, everything should be okay, no shortcuts).
Write Protect (Inv), Reset (Inv) and VCC are connected to the pis 3.3V
GND is connected to the pis GND
CS (Inv) is connected to the pis CE0
SI to pis MOSI
SO to pis MISO
SCK to pis SCLK

The AT45DB041B uses SPI Mode 3 (but shall automatically recognize and switch to Mode 0) [http://www.farnell.com/datasheets/94385.pdf#page=12 page 12]
Additionally it states:
Datasheet wrote:... a high-to-low transition on the CS (Inv) pin will be required to start a valid instruction
In my python script I've put

Code: Select all

spi.mode = 3
spi.max_speed_hz = 500000 # 500kHz
Actual problem
http://www.farnell.com/datasheets/94385.pdf#page=5 Status Register Reads states, with the opcodes 0x57 or 0xD7 I should receive Ready, Complement, 0, 1,1,1,x,x.
But there are only zeros. I also tried 0x00 0x57 0x00 (same with 0xD7) - but I do not receive anything.
Is there probably something strange with the Chip Select (because it is inverted on the nand flash)?

3. Embed the Nand into the system
If I would like to mount a filesystem on it, from what I understood, the following things need to be done:
  1. spidev must be disabled
  2. mkd must recognize the nand and bring it into the /dev/mkd* lalala
  3. something like ubifs must be put on the mkd in order to mount it and use it systemwide
Is this correct?

Thank you for taking your time reading this whole story.
Thank you even more for taking your time responding to it :)

Best regards!

TElmed
Posts: 3
Joined: Fri Jun 08, 2018 10:21 am

Re: Use NAND Flash over SPI

Fri Jul 13, 2018 10:50 am

Okay, so probably I am generally misunderstanding the whole thing with drivers/spi/linux - please bare with me
and tell me if I probably misunderstood something (or even everything :D )

Is it possible and/or are there for example drivers so that something connected through SPI can be used 'natively' in the linux environment -
like I did with an RTC over I²C, directly getting hooked into the system)
or like a filesystem
or like an Ethernet Controller
or like an UART?

Best regards

Return to “Interfacing (DSI, CSI, I2C, etc.)”