* [U-Boot-Users] SOFT_I2C on at91rm9200
@ 2007-06-18 11:39 Nils Gjerdevik
2007-06-18 11:59 ` Joakim Tjernlund
2007-06-18 16:27 ` Matteo Vit
0 siblings, 2 replies; 5+ messages in thread
From: Nils Gjerdevik @ 2007-06-18 11:39 UTC (permalink / raw)
To: u-boot
Hi,
I'm trying to store the u-boot environment in an EEPROM (at24c128) on
a custom at91rm9200 based board. This fails when using the included
HARD_I2C driver, and since there are known problems with the I2C
controller on this uC, I'm trying to set up SOFT_I2C instead, without
success so far...
This is what I've put in my config file:
#define I2C_INIT \
do { \
*AT91C_PIOA_PER = AT91C_PA25_TWD | AT91C_PA26_TWCK; \
*AT91C_PIOA_ODR = AT91C_PA25_TWD; \
*AT91C_PIOA_OER = AT91C_PA26_TWCK; \
}while(0)
#define I2C_ACTIVE (*AT91C_PIOA_OER = AT91C_PA25_TWD)
#define I2C_TRISTATE (*AT91C_PIOA_ODR = AT91C_PA25_TWD)
#define I2C_READ ((*AT91C_PIOA_PDSR & AT91C_PA25_TWD) != 0)
#define I2C_SDA(bit) \
if(bit) { \
*AT91C_PIOA_SODR = AT91C_PA25_TWD; \
} else { \
*AT91C_PIOA_CODR = AT91C_PA25_TWD; \
}
#define I2C_SCL(bit) \
if(bit) { \
*AT91C_PIOA_SODR = AT91C_PA26_TWCK; \
} else { \
*AT91C_PIOA_CODR = AT91C_PA26_TWCK; \
}
#define I2C_DELAY udelay(5)
Can anyone see what's wrong with this code?
I can access the EEPROM without problems in Linux, using the
bit-banging driver, so the board design should be OK. The code above
is(loosely) based on the Linux bit-banging driver.
Regards,
Nils
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot-Users] SOFT_I2C on at91rm9200
2007-06-18 11:39 [U-Boot-Users] SOFT_I2C on at91rm9200 Nils Gjerdevik
@ 2007-06-18 11:59 ` Joakim Tjernlund
2007-06-18 13:51 ` Nils N. Gjerdevik
2007-06-18 16:27 ` Matteo Vit
1 sibling, 1 reply; 5+ messages in thread
From: Joakim Tjernlund @ 2007-06-18 11:59 UTC (permalink / raw)
To: u-boot
On Mon, 2007-06-18 at 13:39 +0200, Nils Gjerdevik wrote:
> Hi,
> I'm trying to store the u-boot environment in an EEPROM (at24c128) on
> a custom at91rm9200 based board. This fails when using the included
> HARD_I2C driver, and since there are known problems with the I2C
> controller on this uC, I'm trying to set up SOFT_I2C instead, without
> success so far...
> This is what I've put in my config file:
>
> #define I2C_INIT \
> do { \
> *AT91C_PIOA_PER = AT91C_PA25_TWD | AT91C_PA26_TWCK; \
> *AT91C_PIOA_ODR = AT91C_PA25_TWD; \
> *AT91C_PIOA_OER = AT91C_PA26_TWCK; \
> }while(0)
>
> #define I2C_ACTIVE (*AT91C_PIOA_OER = AT91C_PA25_TWD)
>
> #define I2C_TRISTATE (*AT91C_PIOA_ODR = AT91C_PA25_TWD)
>
> #define I2C_READ ((*AT91C_PIOA_PDSR & AT91C_PA25_TWD) != 0)
>
> #define I2C_SDA(bit) \
> if(bit) { \
> *AT91C_PIOA_SODR = AT91C_PA25_TWD; \
> } else { \
> *AT91C_PIOA_CODR = AT91C_PA25_TWD; \
> }
>
> #define I2C_SCL(bit) \
> if(bit) { \
> *AT91C_PIOA_SODR = AT91C_PA26_TWCK; \
> } else { \
> *AT91C_PIOA_CODR = AT91C_PA26_TWCK; \
> }
>
> #define I2C_DELAY udelay(5)
>
> Can anyone see what's wrong with this code?
> I can access the EEPROM without problems in Linux, using the
> bit-banging driver, so the board design should be OK. The code above
> is(loosely) based on the Linux bit-banging driver.
>
> Regards,
> Nils
Hi Nils
Don't know anything about at91rm9200, but you could
test the below patch I sent a few weeks ago. I have tested
it now and it works for me.
---
I think the README w.r.t I2C_TRISTATE is OK as is(don't change it). I do
think the soft i2c driver is broken in several places w.r.t
IC2_ACTIVE/I2C_TRISTATE and I2C reset sequence. The below patch is an
attempt to fix it, but I havn't tested it.
Signed-off-by: Joakim Tjernlund <joakim.tjernlund@transmode.se>
diff --git a/common/soft_i2c.c b/common/soft_i2c.c
index edad51b..ed3f8f8 100644
--- a/common/soft_i2c.c
+++ b/common/soft_i2c.c
@@ -100,15 +100,18 @@ static void send_reset(void)
#endif
I2C_TRISTATE;
for(j = 0; j < 9; j++) {
+ if(I2C_READ)
+ send_start();
I2C_SCL(0);
I2C_DELAY;
+ I2C_TRISTATE;
+ I2C_SDA(1);
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_DELAY;
}
send_stop();
- I2C_TRISTATE;
}
/*-----------------------------------------------------------------------
@@ -124,12 +127,13 @@ static void send_start(void)
#endif
I2C_DELAY;
+ I2C_TRISTATE;
I2C_SDA(1);
- I2C_ACTIVE;
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_SDA(0);
+ I2C_ACTIVE;
I2C_DELAY;
}
@@ -152,9 +156,9 @@ static void send_stop(void)
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
+ I2C_TRISTATE;
I2C_SDA(1);
I2C_DELAY;
- I2C_TRISTATE;
}
@@ -172,14 +176,17 @@ static void send_ack(int ack)
I2C_SCL(0);
I2C_DELAY;
- I2C_ACTIVE;
I2C_SDA(ack);
+ I2C_ACTIVE;
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_DELAY;
I2C_SCL(0);
I2C_DELAY;
+ I2C_TRISTATE;
+ I2C_SDA(1);
+ I2C_DELAY;
}
@@ -215,8 +222,8 @@ static int write_byte(uchar data)
*/
I2C_SCL(0);
I2C_DELAY;
- I2C_SDA(1);
I2C_TRISTATE;
+ I2C_SDA(1);
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
@@ -224,7 +231,6 @@ static int write_byte(uchar data)
nack = I2C_READ;
I2C_SCL(0);
I2C_DELAY;
- I2C_ACTIVE;
return(nack); /* not a nack is an ack */
}
@@ -249,6 +255,7 @@ static uchar read_byte(int ack)
* Read 8 bits, MSB first.
*/
I2C_TRISTATE;
+ I2C_SDA(1);
data = 0;
for(j = 0; j < 8; j++) {
I2C_SCL(0);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot-Users] SOFT_I2C on at91rm9200
2007-06-18 11:59 ` Joakim Tjernlund
@ 2007-06-18 13:51 ` Nils N. Gjerdevik
2007-06-18 14:02 ` Joakim Tjernlund
0 siblings, 1 reply; 5+ messages in thread
From: Nils N. Gjerdevik @ 2007-06-18 13:51 UTC (permalink / raw)
To: u-boot
Joakim Tjernlund wrote:
> On Mon, 2007-06-18 at 13:39 +0200, Nils Gjerdevik wrote:
>
>> Hi,
>> I'm trying to store the u-boot environment in an EEPROM (at24c128) on
>> a custom at91rm9200 based board. This fails when using the included
>> HARD_I2C driver, and since there are known problems with the I2C
>> controller on this uC, I'm trying to set up SOFT_I2C instead, without
>> success so far...
>> This is what I've put in my config file:
>>
>> #define I2C_INIT \
>> do { \
>> *AT91C_PIOA_PER = AT91C_PA25_TWD | AT91C_PA26_TWCK; \
>> *AT91C_PIOA_ODR = AT91C_PA25_TWD; \
>> *AT91C_PIOA_OER = AT91C_PA26_TWCK; \
>> }while(0)
>>
>> #define I2C_ACTIVE (*AT91C_PIOA_OER = AT91C_PA25_TWD)
>>
>> #define I2C_TRISTATE (*AT91C_PIOA_ODR = AT91C_PA25_TWD)
>>
>> #define I2C_READ ((*AT91C_PIOA_PDSR & AT91C_PA25_TWD) != 0)
>>
>> #define I2C_SDA(bit) \
>> if(bit) { \
>> *AT91C_PIOA_SODR = AT91C_PA25_TWD; \
>> } else { \
>> *AT91C_PIOA_CODR = AT91C_PA25_TWD; \
>> }
>>
>> #define I2C_SCL(bit) \
>> if(bit) { \
>> *AT91C_PIOA_SODR = AT91C_PA26_TWCK; \
>> } else { \
>> *AT91C_PIOA_CODR = AT91C_PA26_TWCK; \
>> }
>>
>> #define I2C_DELAY udelay(5)
>>
>> Can anyone see what's wrong with this code?
>> I can access the EEPROM without problems in Linux, using the
>> bit-banging driver, so the board design should be OK. The code above
>> is(loosely) based on the Linux bit-banging driver.
>>
>> Regards,
>> Nils
>>
>
> Hi Nils
> Don't know anything about at91rm9200, but you could
> test the below patch I sent a few weeks ago. I have tested
> it now and it works for me.
>
> ---
> I think the README w.r.t I2C_TRISTATE is OK as is(don't change it). I do
> think the soft i2c driver is broken in several places w.r.t
> IC2_ACTIVE/I2C_TRISTATE and I2C reset sequence. The below patch is an
> attempt to fix it, but I havn't tested it.
>
Hi Joakim,
I'm afraid your patch didn't help. All reads just return 0x00, so I
guess it's related to my definitions for the at91rm9200 and not the
generic soft_i2c code.
Nils
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot-Users] SOFT_I2C on at91rm9200
2007-06-18 13:51 ` Nils N. Gjerdevik
@ 2007-06-18 14:02 ` Joakim Tjernlund
0 siblings, 0 replies; 5+ messages in thread
From: Joakim Tjernlund @ 2007-06-18 14:02 UTC (permalink / raw)
To: u-boot
On Mon, 2007-06-18 at 15:51 +0200, Nils N. Gjerdevik wrote:
> Joakim Tjernlund wrote:
> > On Mon, 2007-06-18 at 13:39 +0200, Nils Gjerdevik wrote:
> >
> >> Hi,
> >> I'm trying to store the u-boot environment in an EEPROM (at24c128) on
> >> a custom at91rm9200 based board. This fails when using the included
> >> HARD_I2C driver, and since there are known problems with the I2C
> >> controller on this uC, I'm trying to set up SOFT_I2C instead, without
> >> success so far...
> >> This is what I've put in my config file:
> >>
> >> #define I2C_INIT \
> >> do { \
> >> *AT91C_PIOA_PER = AT91C_PA25_TWD | AT91C_PA26_TWCK; \
> >> *AT91C_PIOA_ODR = AT91C_PA25_TWD; \
> >> *AT91C_PIOA_OER = AT91C_PA26_TWCK; \
> >> }while(0)
> >>
> >> #define I2C_ACTIVE (*AT91C_PIOA_OER = AT91C_PA25_TWD)
> >>
> >> #define I2C_TRISTATE (*AT91C_PIOA_ODR = AT91C_PA25_TWD)
> >>
> >> #define I2C_READ ((*AT91C_PIOA_PDSR & AT91C_PA25_TWD) != 0)
> >>
> >> #define I2C_SDA(bit) \
> >> if(bit) { \
> >> *AT91C_PIOA_SODR = AT91C_PA25_TWD; \
> >> } else { \
> >> *AT91C_PIOA_CODR = AT91C_PA25_TWD; \
> >> }
> >>
> >> #define I2C_SCL(bit) \
> >> if(bit) { \
> >> *AT91C_PIOA_SODR = AT91C_PA26_TWCK; \
> >> } else { \
> >> *AT91C_PIOA_CODR = AT91C_PA26_TWCK; \
> >> }
> >>
> >> #define I2C_DELAY udelay(5)
> >>
> >> Can anyone see what's wrong with this code?
> >> I can access the EEPROM without problems in Linux, using the
> >> bit-banging driver, so the board design should be OK. The code above
> >> is(loosely) based on the Linux bit-banging driver.
> >>
> >> Regards,
> >> Nils
> >>
> >
> > Hi Nils
> > Don't know anything about at91rm9200, but you could
> > test the below patch I sent a few weeks ago. I have tested
> > it now and it works for me.
> >
> > ---
> > I think the README w.r.t I2C_TRISTATE is OK as is(don't change it). I do
> > think the soft i2c driver is broken in several places w.r.t
> > IC2_ACTIVE/I2C_TRISTATE and I2C reset sequence. The below patch is an
> > attempt to fix it, but I havn't tested it.
> >
> Hi Joakim,
> I'm afraid your patch didn't help. All reads just return 0x00, so I
> guess it's related to my definitions for the at91rm9200 and not the
> generic soft_i2c code.
>
> Nils
Nils, try changing ACTIVATE and TRISTATE to toggle direction, TRISTATE
should set the pin to input and ACTIVE to output. I think you should
keep my patch while doing so.
If you can use a true open drain output, then ACTIVATE and TRISTATE
should be empty.
Jocke
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot-Users] SOFT_I2C on at91rm9200
2007-06-18 11:39 [U-Boot-Users] SOFT_I2C on at91rm9200 Nils Gjerdevik
2007-06-18 11:59 ` Joakim Tjernlund
@ 2007-06-18 16:27 ` Matteo Vit
1 sibling, 0 replies; 5+ messages in thread
From: Matteo Vit @ 2007-06-18 16:27 UTC (permalink / raw)
To: u-boot
Nils Gjerdevik ha scritto:
> Hi,
> I'm trying to store the u-boot environment in an EEPROM (at24c128) on
> a custom at91rm9200 based board. This fails when using the included
> HARD_I2C driver, and since there are known problems with the I2C
> controller on this uC, I'm trying to set up SOFT_I2C instead, without
> success so far...
This is for the Atmel's AVR32 processor. The PIO block seems the same.
Just change pio2_writel function calls. I hope this help.
Matteo
/*
* Software (bit-bang) I2C driver configuration
*/
#define GPIOG_EECLK 0x80
#define GPIOG_EEDAT 0x40
#define I2C_INIT { \
pio2_writel(PIOA_BASE,PER,GPIOG_EEDAT | GPIOG_EECLK); \
pio2_writel(PIOA_BASE,OER,GPIOG_EEDAT | GPIOG_EECLK); \
pio2_writel(PIOA_BASE,IDR,GPIOG_EEDAT | GPIOG_EECLK); \
pio2_writel(PIOA_BASE,PUDR,GPIOG_EEDAT | GPIOG_EECLK); \
pio2_writel(PIOA_BASE,MDER,GPIOG_EEDAT | GPIOG_EECLK); \
pio2_writel(PIOA_BASE,OWER,GPIOG_EEDAT | GPIOG_EECLK); \
}
#define I2C_ACTIVE (pio2_writel(PIOA_BASE,SODR,GPIOG_EEDAT))
#define I2C_TRISTATE (pio2_writel(PIOA_BASE,SODR,GPIOG_EEDAT))
#define I2C_READ (pio2_readl(PIOA_BASE,PDSR) & GPIOG_EEDAT ? 1 : 0)
#define I2C_SDA(bit) pio2_writel(PIOA_BASE,OER,GPIOG_EEDAT); \
if (bit) pio2_writel(PIOA_BASE,SODR,GPIOG_EEDAT); \
else pio2_writel(PIOA_BASE,CODR,GPIOG_EEDAT)
#define I2C_SCL(bit) pio2_writel(PIOA_BASE,OER,GPIOG_EECLK); \
if (bit) \
pio2_writel(PIOA_BASE,SODR,GPIOG_EECLK); \
else pio2_writel(PIOA_BASE,CODR,GPIOG_EECLK)
#define I2C_DELAY udelay(50) /* 1/4 I2C clock duration */
#endif /* CONFIG_SOFT_I2C */
From "abiyani at unix dot telasic dot com" at unix.telasic.com Mon Jun 18 19:20:15 2007
From: "abiyani at unix dot telasic dot com" at unix.telasic.com (Arun Biyani)
Date: Mon, 18 Jun 2007 10:20:15 -0700
Subject: [U-Boot-Users] U-Boot 1.2 - Cannot run hello_world - Coldfire
In-Reply-To: <IDEBKKLJFJMDCLNCEJPHGEGNCBAA.ganesh.patro@softdel.com>
References: <IDEBKKLJFJMDCLNCEJPHGEGNCBAA.ganesh.patro@softdel.com>
Message-ID: <200706181720.KAA21445@unix.telasic.com>
Ganesh Chandra Patro wrote:
> -----Original Message-----
> From: u-boot-users-bounces at lists.sourceforge.net
> [mailto:u-boot-users-bounces at lists.sourceforge.net]On Behalf Of Arun
> Biyani
> Sent: 15 June, 2007 Friday 11:00 PM
> To: Wolfgang Denk
> Cc: u-boot-users at lists.sourceforge.net
> Subject: Re: [U-Boot-Users] U-Boot 1.2 - Cannot run hello_world -
> Coldfire
>
>
> Wolfgang Denk wrote:
>
>> Eventually you did not download the binary image?
>>
>> Best regards,
>>
>> Wolfgang Denk
>>
>>
>>
> This morning, I also tried to run the .bin file (hello_world.bin).
> U-Boot just hung up. Current status
> is, the hello_world program in the distribution (unmodified) does not
> run on Coldfire based board.
> I tried this on our target board as well as a CSB360 board from Cogent
> Computers. I tried both
> the hello_world.srec file and the hello_world.bin file.
>
> Any ideas as to what I can do to make simple applications run in U-Boot
> on Coldfire? Has anyone
> else tried this?
>
> Thx
>
> Hi Arun,
> There is a specific way to run a bin file. First you have to load to a
> specific memory location let's say 0x2000. You have find the entry point
> address of the bin from it's symbol table and assuming the flash start
> address of the bin file 0, add 0x2000 to know the entry point address of the
> bin in the memory just loaded. Now say go "address" on the CLI. The program
> will run. Every time you load to a different address you need to find the
> actual physical address. That's why loading an ELF is easier than a bin from
> CLI. The same bin or srec can be burnt and run from the flash, but running a
> bin would involve this much to do be done.
>
> Thanks and Regards
>
> Ganesh Chandra Patro
> SoftDel Systems Ltd
> "ACROPOLIS", 2nd Floor
> Marol Maroshi
> Military Road
> Andheri(East)
> Mumbai - 400 059
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users
>
>
>
>
Ganesh, Thx for your response.
The program "hello_world" is part of the release package. I've verified that
the entry point is indeed "0x20000". So, the problem is something else.
Can anyone think of what else
might be the cause? I have 2-3 previous posts on the same subject.
The documentation does not talk about running "elf" files. Could someone
give me a basic intro?
Arun
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-06-18 16:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-18 11:39 [U-Boot-Users] SOFT_I2C on at91rm9200 Nils Gjerdevik
2007-06-18 11:59 ` Joakim Tjernlund
2007-06-18 13:51 ` Nils N. Gjerdevik
2007-06-18 14:02 ` Joakim Tjernlund
2007-06-18 16:27 ` Matteo Vit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox