2008-04-24 12:52:02     where is eth_mac.c?

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

2008-04-24 12:52:02     where is eth_mac.c?

blue hash (UNITED STATES)

Message: 54877    There is the following line in bfin_mac.c in drivers/net/

Both the 2008-r1-rc8 as well as the trunk dont have this file. I'm using a BF537

The only place, bfin_get_ether_addr is in stamp.c in boards/

 

2008-R1-RC8

/*Is it valid? (Did bootloader initialize it?) */

    if (!is_valid_ether_addr(dev->dev_addr)) {

        /* Grab the MAC from the board somehow - this is done in the

           arch/blackfin/mach-bf537/boards/eth_mac.c */

        bfin_get_ether_addr(dev->dev_addr);

    }

 

Trunk

 

/*

     * Is it valid? (Did bootloader initialize it?)

     * Grab the MAC from the board somehow

     * this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c

     */

    if (!is_valid_ether_addr(ndev->dev_addr))

        bfin_get_ether_addr(ndev->dev_addr);

 

Thanks.

QuoteReplyEditDelete

 

 

2008-04-24 13:27:16     Re: where is eth_mac.c?

Robin Getz (UNITED STATES)

Message: 54879    Blue:

 

That is because you are supposed to implement your own, board specific function (with the same name).

 

-Robin

QuoteReplyEditDelete

 

 

2008-04-24 14:09:26     Re: where is eth_mac.c?

blue hash (UNITED STATES)

Message: 54883    Robin,

Thanks. Is there an example of how to go about it or a wiki

QuoteReplyEditDelete

 

 

2008-04-24 14:41:58     Re: where is eth_mac.c?

Robin Getz (UNITED STATES)

Message: 54887    Blue:

 

The example is the one you found in the boards/bf537-stamp directory.

 

-Robin

QuoteReplyEditDelete

 

 

2008-04-24 16:01:04     Re: where is eth_mac.c?

blue hash (UNITED STATES)

Message: 54896    Robin,

 

My stamp.c file has the following

/*

* Currently the MAC address is saved in Flash by U-Boot

*/

#define FLASH_MAC    0x203f0000

void bfin_get_ether_addr(char *addr)

{

    *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);

    *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);

}

EXPORT_SYMBOL(bfin_get_ether_addr);

 

 

In bfin_mac.c, where the driver looks for the MAC in flash address (203F0000).

If it doesnt get it, it generates a random MAC.

 

    /*Is it valid? (Did bootloader initialize it?) */

    if (!is_valid_ether_addr(dev->dev_addr)) {

        /* Grab the MAC from the board somehow - this is done in the

           arch/blackfin/mach-bf537/boards/eth_mac.c */

        bfin_get_ether_addr(dev->dev_addr);

  }

 

The driver can never gets pass the line          bfin_get_ether_addr(dev->dev_addr);

If I comment this section out, the driver generates a random address.

 

Why is the driver not able to load the MAC from (203F0000)? I'm sure I have it, because md 0x203F0000 gives:

bfin> md 0x203F0000

203f0000: 03020100 ffff0504 ffffffff ffffffff    ................

203f0010: ffffffff ffffffff ffffffff ffffffff    ................

 

MAC address 00:01:02:03:04:05

QuoteReplyEditDelete

 

 

2008-04-24 16:11:48     Re: where is eth_mac.c?

Mike Frysinger (UNITED STATES)

Message: 54898    what do you mean "my stamp.c" ?  there is only one stamp.c and that is for the BF537 STAMP board.  if you arent using a stamp, then you should be creating your own board resource file and thus your own bfin_get_ether_addr() function.

QuoteReplyEditDelete

 

 

2008-04-24 16:20:14     Re: where is eth_mac.c?

blue hash (UNITED STATES)

Message: 54899    Mike, it's the stamp.c in arch/blackfin/mach-bf537/boards/.

The board is electrically similar to the stamp, so I just made changes to the bf537-stamp files.

QuoteReplyEditDelete

 

 

2008-04-24 16:23:01     Re: where is eth_mac.c?

Mike Frysinger (UNITED STATES)

Message: 54901    so what exactly is your question ?  you wanted to know about the function and we told you ... each board needs to implement it according to their own needs.

QuoteReplyEditDelete

 

 

2008-04-24 16:27:44     Re: where is eth_mac.c?

blue hash (UNITED STATES)

Message: 54902    I just want to know why the driver is not able to retrieve the MAC from the address (203F0000)

Thanks

QuoteReplyEditDelete

 

 

2008-04-24 16:51:49     Re: where is eth_mac.c?

Mike Frysinger (UNITED STATES)

Message: 54904    did you put printk's into your func to make sure it got there ?  does the system hang or crash ?

 

did you program your flash bank settings according to the 4 meg flash you have hooked up ?

QuoteReplyEditDelete

 

 

2008-04-24 17:15:48     Re: where is eth_mac.c?

blue hash (UNITED STATES)

Message: 54906    Yes I did.

 

--------------------------bfin_mac.c------------------------------------------------------

printk(KERN_INFO "Above Functionr\n");

    /*Is it valid? (Did bootloader initialize it?) */

    if (!is_valid_ether_addr(dev->dev_addr)) {

        /* Grab the MAC from the board somehow - this is done in the

           arch/blackfin/mach-bf537/boards/eth_mac.c */

        printk(KERN_INFO "Within Function\n");

        bfin_get_ether_addr(dev->dev_addr);

}

----------------------------------------------------------------------------------

 

-------------------------------boot log---------------------------------------

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 512 (order: 0, 4096 bytes)

TCP bind hash table entries: 512 (order: -1, 2048 bytes)

TCP: Hash tables configured (established 512 bind 512)

TCP reno registered

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler cfq registered

bfin-wdt: initialized: timeout=20 sec (nowayout=0)

Serial: Blackfin serial driver

bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

SMSC LAN83C185: Registered new driver

Above Function

Within Function

-----boot stops/hangs  here-----

 

 

Flash banks are for 4Mb flash. I can successfully create and detect partitions.

----------bootlog------------

physmap platform flash device: 00400000 at 20000000

physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank

Support for command set 0002 not present

gen_probe: No supported Vendor Command Set found

RedBoot partition parsing not available

Using physmap partition information

Creating 4 MTD partitions on "physmap-flash.0":

0x00000000-0x00040000 : "Bootloader"

0x00040000-0x00240000 : "Kernel"

0x00240000-0x003f0000 : "RootFS"

0x003f0000-0x00400000 : "MAC Address"

 

 

If compiled as a module, I can boot up to prompt.

When modprobed, the board hangs and does nothing.

QuoteReplyEditDelete

 

 

2008-04-24 17:32:20     Re: where is eth_mac.c?

Mike Frysinger (UNITED STATES)

Message: 54908    that isnt within the function.  you've shown that the driver is calling bfin_get_ether_addr(), but you havent shown which bfin_get_ether_addr() is getting called and where in bfin_get_ether_addr() it's getting stuck.

QuoteReplyEditDelete

 

 

2008-04-24 18:11:58     Re: where is eth_mac.c?

blue hash (UNITED STATES)

Message: 54910    It gets stuck when it tries the function bfin_read32(),

 

-------------bfin_get_ether_addr(stamp.c)------------

#define FLASH_MAC    0x203f0000

void bfin_get_ether_addr(char *addr)

{

    printk(KERN_INFO "Within bfin_get_ether_addr\n");

    *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);

    printk(KERN_INFO "between bfin_get_ether_addr\n");

    *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);

    printk(KERN_INFO "End bfin_get_ether_addr\n");

}

EXPORT_SYMBOL(bfin_get_ether_addr);

 

 

------------boot log-------------------------------

<snip>

io scheduler anticipatory registered (default)

io scheduler cfq registered

bfin-wdt: initialized: timeout=20 sec (nowayout=0)

Serial: Blackfin serial driver

bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

SMSC LAN83C185: Registered new driver

Above bootloader

Within bootloader

Within bfin_get_ether_addr

 

QuoteReplyEditDelete

 

 

2008-04-24 18:51:24     Re: where is eth_mac.c?

blue hash (UNITED STATES)

Message: 54912    If its of help:

 

Is there any reason why the line

*(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);

 

will not read the flash address?

 

I changed the following lines in bfin_get_ether_addr:

    *(u32 *)(&(addr[0])) = 0;//bfin_read32(FLASH_MAC);

    *(u16 *)(&(addr[4])) = 1;//bfin_read16(FLASH_MAC + 4);

 

and got MAC address:  00:00:00:00:01:00

 

I can read from the flash ok, with md.b 0x203F0000

 

Another thing is that if U-boot(setenv ethaddr xx:xx:xx:xx:xx:xx, saveenv) takes care of burning the MAC into the MAC controller, why is the kernel driver looking for it in flash.

QuoteReplyEditDelete

 

 

2008-04-28 18:26:33     Re: where is eth_mac.c?

Mike Frysinger (UNITED STATES)

Message: 55178    i dont know why the core is hanging when attempting to read that memory location.  i would boot up the system and write a userspace application that reads the same address and see if it hangs as well.

QuoteReplyEditDelete

 

 

2008-04-28 20:11:45     Re: where is eth_mac.c?

blue hash (UNITED STATES)

Message: 55182    Mike,

I dont know why, but u-boot was not writing to the MAC controller.

I used the setupmac() function (which was in 1.1.3) in the misc_init_r() and it worked.

 

I am not sure if it's a bug.

Thanks to all for helping me debug this.

QuoteReplyEditDelete

 

 

2008-04-29 10:47:02     Re: where is eth_mac.c?

Robin Getz (UNITED STATES)

Message: 55231    Blue/Mike:

 

The only time I have seen something like this is when an external device asserts the Blackfin ARDY, and what is in the EBIU_AMBCTLn registers (BnRDYEN bit).

 

-Robin

Attachments

    Outcomes