public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] Strange data behaviour
@ 2009-02-17 11:55 Remco Poelstra
  2009-02-17 19:12 ` Wolfgang Denk
  0 siblings, 1 reply; 4+ messages in thread
From: Remco Poelstra @ 2009-02-17 11:55 UTC (permalink / raw)
  To: u-boot

Hi,

I'm trying to get my LPC2468 based board to work. I've some problems 
with the external memory databus.
I would like to know the settings of internal registers to see whether 
I've initialized them correctly, so I tried making a function that 
prints the content over the serial link. I'm still in the lowlevel_init 
function, so I do not have the U-boot puts functions available.
I wrote the following function to convert a long to a HEX string:
-------------------
void print_long(unsigned long data) {
   char i;
   char 
hex_data[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

   for(i=0; i<8; i++) {
     while((U0LSR & (1<<5)) == 0); /* Wait for empty U0THR */
//    U0THR = hex_data[(0xDEADBEEF>>i*4)&0xF];
     U0THR = hex_data[(0xDEADBEEF>>4)&0xF];
   }
}
---------------
When I run it likes this I get 8 E's. Which is what I expect. When I run 
it with the commented-out line, I get back 8 0x0's. So it seems that the 
output is only correct when it is constant.
Does anyone have a clue on why that is?

Kind regards,

Remco Poelstra

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] Strange data behaviour
  2009-02-17 11:55 [U-Boot] Strange data behaviour Remco Poelstra
@ 2009-02-17 19:12 ` Wolfgang Denk
  2009-02-18  8:19   ` Remco Poelstra
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2009-02-17 19:12 UTC (permalink / raw)
  To: u-boot

Dear Remco Poelstra,

In message <499AA5B8.7030805@duran-audio.com> you wrote:
> 
> I'm trying to get my LPC2468 based board to work. I've some problems 
> with the external memory databus.
> I would like to know the settings of internal registers to see whether 
> I've initialized them correctly, so I tried making a function that 
> prints the content over the serial link. I'm still in the lowlevel_init 
> function, so I do not have the U-boot puts functions available.
> I wrote the following function to convert a long to a HEX string:
> -------------------
> void print_long(unsigned long data) {
>    char i;
>    char 
> hex_data[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
> 
>    for(i=0; i<8; i++) {
>      while((U0LSR & (1<<5)) == 0); /* Wait for empty U0THR */
> //    U0THR = hex_data[(0xDEADBEEF>>i*4)&0xF];

For clearity of the code I would write that as "...>>(i*4)...", but
that's not relevant here.

>      U0THR = hex_data[(0xDEADBEEF>>4)&0xF];
>    }
> }
> ---------------
> When I run it likes this I get 8 E's. Which is what I expect. When I run 
> it with the commented-out line, I get back 8 0x0's. So it seems that the 
> output is only correct when it is constant.
> Does anyone have a clue on why that is?

What exactly is U0THR ? 

The only definition I can find in the U-Boot sources is here:

include/asm-arm/arch-lpc2292/lpc2292_registers.h:#define U0THR 0xE000C000

but that is obviously not what you are using.

You probably forget the effects of compiler optimization and/or
caching here.


I bet you are using a plain  pointer  access  without  a  "volatile",
which is essential here. Maybe even some form of "sync" is needed. In
any  case,  you  should  use appropriate accessor functions to access
device registers.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Never call a man a fool.  Borrow from him.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] Strange data behaviour
  2009-02-17 19:12 ` Wolfgang Denk
@ 2009-02-18  8:19   ` Remco Poelstra
  2009-02-19  0:32     ` Kim Phillips
  0 siblings, 1 reply; 4+ messages in thread
From: Remco Poelstra @ 2009-02-18  8:19 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk schreef:
>>      U0THR = hex_data[(0xDEADBEEF>>4)&0xF];
>>    }
>> }
>> ---------------
>> When I run it likes this I get 8 E's. Which is what I expect. When I run 
>> it with the commented-out line, I get back 8 0x0's. So it seems that the 
>> output is only correct when it is constant.
>> Does anyone have a clue on why that is?
> 
> What exactly is U0THR ? 

Hi,

Thanks for your reply.

For my processor, U0THR is defnied as:
#define U0THR          (*(volatile unsigned char *)(UART0_BASE_ADDR + 
0x00))

UART0_BASE_ADDR is equal to 0xE000C000

The register itself represents the top of the UART0 transmit FIFO.

> 
> The only definition I can find in the U-Boot sources is here:
> 
> include/asm-arm/arch-lpc2292/lpc2292_registers.h:#define U0THR 0xE000C000
> 
> but that is obviously not what you are using.
> 
> You probably forget the effects of compiler optimization and/or
> caching here.
> 
> 
> I bet you are using a plain  pointer  access  without  a  "volatile",
> which is essential here. Maybe even some form of "sync" is needed. In
> any  case,  you  should  use appropriate accessor functions to access
> device registers.

I do not know any accessor functions.
What do you mean with a "sync"?

Kind regards,

Remco Poelstra

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] Strange data behaviour
  2009-02-18  8:19   ` Remco Poelstra
@ 2009-02-19  0:32     ` Kim Phillips
  0 siblings, 0 replies; 4+ messages in thread
From: Kim Phillips @ 2009-02-19  0:32 UTC (permalink / raw)
  To: u-boot

On Wed, 18 Feb 2009 09:19:08 +0100
Remco Poelstra <remco.poelstra@duran-audio.com> wrote:

> Wolfgang Denk schreef:
> > I bet you are using a plain  pointer  access  without  a  "volatile",
> > which is essential here. Maybe even some form of "sync" is needed. In
> > any  case,  you  should  use appropriate accessor functions to access
> > device registers.
> 
> I do not know any accessor functions.

things like out_be32 (at least that's what it's called on ppc arch).

> What do you mean with a "sync"?

it's a processor instruction that ensures that memory and/or i/o
accesses occur exactly when you specify they occur.  For this reason, a
sync instruction is included as a part of the accessor functions.

Kim

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-19  0:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-17 11:55 [U-Boot] Strange data behaviour Remco Poelstra
2009-02-17 19:12 ` Wolfgang Denk
2009-02-18  8:19   ` Remco Poelstra
2009-02-19  0:32     ` Kim Phillips

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox