2008-07-30 14:14:11     how to find the system clock speed in u-boot

Document created by Aaronwu Employee on Sep 18, 2013
Version 1Show Document
  • View in full screen mode

2008-07-30 14:14:11     how to find the system clock speed in u-boot

murti iki (GERMANY)

Message: 59614   

 

Hello,

 

I was wondering about how to find the clock speed that U-Boot sets in its environment. The issue is I want to

 

have an idea about the overhead that uclinux has so I have set up a U-Boot standalone program and a uClinux program

 

that make a SPI data transfer with some device. I expected that both ones would be almost the same with U-Boot a little bit

 

faster however it turned out that uClinux is faster.

 

The only explanation that I came up with was that uclinux had a faster clock. If that makes sense how can I learn the clock rate

 

that u-boot sets?  Also can it be possible for uClinux version to be faster than an U-Boot standalone?

 

 

 

thanks alot

 

murti

 

ps: I don't know if it's relevant but I wrote a seperate driver module for the uClinux version. I didn't use the SPI subsystem.

 

would this also make the uClinux version faster?

QuoteReplyEditDelete

 

 

2008-07-30 15:12:49     Re: how to find the system clock speed in u-boot

Ben Matthews (UNITED STATES)

Message: 59617   

 

U-Boot's clock settings are hard coded in [U-Boot source]/include/configs/[board_name].h ,fairly close to the start of the file (starts on line 45 in the file for the bf533-stamp). On a running board you can get some of the same info with the "bdinfo" command

QuoteReplyEditDelete

 

 

2008-07-30 17:13:44     Re: how to find the system clock speed in u-boot

murti iki (GERMANY)

Message: 59619   

 

hello thanks for the pointer,

 

I checked that file and both the core and system clock seem to be in accordance with the value in linux.

 

500 Mhz vs 100 Mhz. This makes things most weird, because the SPI code is written in the same way

 

in both versions (U-boot and uClinux). I wonder if anybody has seen such a behaivor before.

 

 

 

by the way the driver module in uClinux also directly accesses the SPI peripheral registers.

QuoteReplyEditDelete

 

 

2008-07-30 23:34:30     Re: how to find the system clock speed in u-boot

Mike Frysinger (UNITED STATES)

Message: 59625   

 

unless you told the kernel to reprogram clocks when booting, then u-boot and linux will use the same exact clock settings

 

the linux spi driver uses interrupts (and a bit of dma) while in u-boot, it just bit-bangs registers and busy waits on things

QuoteReplyEditDelete

 

 

2008-07-31 06:18:37     Re: how to find the system clock speed in u-boot

murti iki (GERMANY)

Message: 59660   

 

I am using a module that I have written as the spi driver in uclinux. It doesn't use the interrupts or dma.

 

Just like u-boot it bitbangs the registers and busy waits so both u-boot and uclinux uses the same driver.

 

All the same, uclinux seems to be faster. I am just wondering if there is a possibility that a uclinux program

 

will be able to be faster than its standalone counterpart

QuoteReplyEditDelete

 

 

2008-07-31 08:56:49     Re: how to find the system clock speed in u-boot

Mike Frysinger (UNITED STATES)

Message: 59662   

 

it'd be impossible for correctly written code to be faster in Linux than standalone.  you're talking about the same exact hardware.

QuoteReplyEditDelete

 

 

2008-07-31 09:32:32     Re: how to find the system clock speed in u-boot

Ben Matthews (UNITED STATES)

Message: 59667   

 

Perhaps you are using different compiler flags (particularly optimization related ones)?

QuoteReplyEditDelete

 

 

2008-07-31 10:26:34     Re: how to find the system clock speed in u-boot

murti iki (GERMANY)

Message: 59700   

 

bfin-uclinux-gcc -g  -O2   -mcpu=bf537 -ffixed-P5  -D__KERNEL__ -DTEXT_BASE=do-not-use-me  -I../include -fno-builtin

 

-ffreestanding -nostdinc -isystem /opt/uClinux/bfin-uclinux/lib/gcc/bfin-uclinux/4.1.1/include -pipe  -DCONFIG_BLACKFIN -Wall

 

-Wstrict-prototypes -c -o initialization.o initialization.c

 

 

 

This is the command that I compile my code with, it is taken from the u-boot makefile that is used to compile the u-boot

 

standalone applications. I admit I am not very familiar with the gcc flags but there doesn't seem to be any optimization flags.

 

For the uclinux module I simply use   obj-m += module.o

 

 

 

since I use bit banging and busy wait in uClinux, I would say that both codes are the same. If it would be okey for you I can

 

send the related part of my code as an email.

 

Thanks again for your help

 

murti

QuoteReplyEditDelete

 

 

2008-08-01 10:28:04     Re: how to find the system clock speed in u-boot

murti iki (GERMANY)

Message: 59756   

 

okey the optimization flag seems to be there -O2, I tried others to no avail.

 

Anyway here is a code snippet that runs on both versions.

 

for standalone:

 

 

    before = cycles();

 

 

     // send the master status

   *pSPI_TDBR = ip_int->master_status;

    dummy =  *pSPI_RDBR;    // read_RDBR();

                              ssync();

                              do {} while (!( (dummy = *pSPI_STAT) & RXS) );

 

  // receive the slave status

   *pSPI_TDBR = 0x00;     ssync();

   dummy =  *pSPI_RDBR;    // read_RDBR();

                           ssync();

                          do {} while (!( (dummy = *pSPI_STAT) & RXS) );

        murti->slave_status = *pSPI_SHADOW;  // bfin_read_SPI_SHADOW();

 

after = cycles();      result = after-before;                       result is 2995 core cycles

 

 

 

for uClinux driver module

 

  before= cycles();

 

 

   // send the master status

    write_TDBR(ip_int->master_status);

   read_RDBR(); __builtin_bfin_ssync();

             do {} while (!(read_STAT() & RXS) );

 

  // receive the slave status

   write_TDBR(0x00);

   read_RDBR(); __builtin_bfin_ssync();

              do {} while (!(read_STAT() & RXS) );

  murti->slave_status = bfin_read_SPI_SHADOW();

 

after = cycles();       // result =  after - before;              result is 1085 core cycles

 

 

 

both of these snippets sends two bytes over spi, the hardware and the baud rate are the same.

Attachments

    Outcomes