Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: atmel_spi and at25 driver for eeprom with AT91SAM9260ek ?!
PostPosted: Thu Apr 03, 2008 8:50 am 
Offline

Joined: Tue Jun 26, 2007 6:27 pm
Posts: 81
Hello,

KernelVersion 2.6.24.3

I try to use the at25 EEPROM driver included in the kernel.

I add the following lines to my boardsam9260ek.c file:

Code:
static struct spi_eeprom eeprom = {
      .name = "at25160",
      .byte_len = 2048,
      .page_size = 32,
      .flags = EE_ADDR2,
};

static struct spi_board_info spi1_board_info[] __initdata = {
   {
      /* EEPROM */
      .modalias      = "at25",
      .max_speed_hz   = 1000000,
      .chip_select   = 2,
      .mode      = SPI_MODE_0,
      .platform_data = &eeprom,
      .bus_num = 0,
   },
};

I want to use the SPI EEPROM at SPI0_CS2 -> Pin PC16

If I choose this Chip select the kernel hangs on booting -> no message just stop !

Could anybody explain me, what´s wrong ? If I use Pin PC17 (.chip_select = 3) same Problem...

If I try .chip_select = 0 or .chip_select = 1 (PA3 or PC5) it seems to work ?

Thank you for your help.

Manuel Sahm


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 1:24 pm 
Offline

Joined: Fri Jun 08, 2007 7:06 am
Posts: 5
Location: Ukraine / Kiev
try :
1) if this pins (PC16 , PC17) defined or used somewhere else;
2) use osciloscope to see any activity;
3) try osciloscope on CS, CLK, DI, DO - posybly sync. problem ( i had some timing problems with my AT25256W)
4) if interesting - got driver for AT25256W (use with AVR ATMEGA 128), work's on any pin you chose, some code modification and you got external memory runing.

GL :)

_________________
There is nothing imposible.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 3:00 pm 
Offline

Joined: Tue Jun 26, 2007 6:27 pm
Posts: 81
Hello,

I found out the problem,

PC16 and PC17 are used for the SDRAM Data lines....

I have to choose CS_0 (PA3).

With this configuration it seems to work.

Another problem:
---------------------------
How can I write/read to the eeprom ?
The code fails:
Code:
int fd = open("/sys/bus/spi/devices/spi0.0/eeprom", O_RDWR);

the file exists but I get fd = -1

What´s wrong ?

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 4:07 pm 
Offline

Joined: Fri Jun 08, 2007 7:06 am
Posts: 5
Location: Ukraine / Kiev
Probably instruction set problem, try to fin source code for othe EEPROM and compare it, diferent EEPROM, especialy SPI has diferent memory maping and instruction set (check data and command exchange protocol for your EEPROM), also pay atantion at your reading and writing mode's (page read/write, byte read/write), and final - chaeck Write Protect and "hold" pin's.

GL

_________________
There is nothing imposible.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 4:56 pm 
Offline

Joined: Tue Jun 26, 2007 6:27 pm
Posts: 81
Found out the problem:

you have to use:
Code:
FILE* fd = fopen("/sys/bus/spi/devices/spi0.0/eeprom", "rb+");


then it works,

now use: fseek, fwrite, fread, flcose to access the eeprom.


Best regards

Manuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: