2009-04-29 15:55:34     Problem porting u-boot 2009.03 to my board (NAND backend driver)

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

2009-04-29 15:55:34     Problem porting u-boot 2009.03 to my board (NAND backend driver)

Jay Ku (UNITED STATES)

Message: 73448   

 

I'm trying to port u-boot 2009.03 to my BF532 board.  I managed to get 2008R1.5 (1.1.6) running on my board, but it looks like some things have changed and my old backend NAND driver no longer compiles.  Previously I used the nand.c driver in boards/bf537-stamp as a model for my own nand.c file, but I don't see NAND drivers in any of the board/bf5* directories in the new distribution.   Is there a Blackfin NAND driver for the 2009.03 release that I can use as a starting point?

 

Thanks,

 

Jay

QuoteReplyEditDelete

 

 

2009-04-29 16:06:31     Re: Problem porting u-boot 2009.03 to my board (NAND backend driver)

Mike Frysinger (UNITED STATES)

Message: 73449   

 

all the NAND drivers are in drivers/mtd/nand/

 

the NAND framework has changed since 1.1.6 so you'll have to rewrite your driver a bit

QuoteReplyEditDelete

 

 

2009-04-29 16:28:28     Re: Problem porting u-boot 2009.03 to my board (NAND backend driver)

Jay Ku (UNITED STATES)

Message: 73450   

 

Is NAND support on 2009.03 working for Blackfins without internal controllers (like BF53x)?

 

All I really wanted was to have U-Boot store its environment in my SPI NOR-flash... is that possible in 2008R1.5?

QuoteReplyEditDelete

 

 

2009-04-29 16:49:41     Re: Problem porting u-boot 2009.03 to my board (NAND backend driver)

Mike Frysinger (UNITED STATES)

Message: 73451   

 

the only regression atm is USB.  everything else should work just fine (NAND/SPI/etc...).

 

if your NAND driver is merely a copy of the one that was in the bf537-stamp, then you can use the common nand_plat.c driver

QuoteReplyEditDelete

 

 

2009-04-29 17:50:50     Re: Problem porting u-boot 2009.03 to my board (NAND backend driver)

Jay Ku (UNITED STATES)

Message: 73452   

 

Almost there (at least getting it to compile).  Here's some of my config file:

 

/* SPI Settings */

#define CONFIG_BFIN_SPI

#define CONFIG_ENV_SPI_MAX_HZ 20000000

#define CONFIG_SF_DEFAULT_HZ 20000000

#define CONFIG_SPI_FLASH

#define CONFIG_SPI_FLASH_STMICRO

 

/* Env storage settings */

#define CONFIG_ENV_IS_IN_SPI_FLASH

#define CONFIG_ENV_OFFSET 0x30000

#define CONFIG_ENV_SECT_SIZE 0x10000

#define ENV_IS_EMBEDDED_CUSTOM

#define CONFIG_ENV_SIZE 0x10000

 

/*  NAND configuration  */

#define CONFIG_NAND_PLAT

#define CONFIG_SYS_NAND_BASE  0x20000000

#define CONFIG_SYS_MAX_NAND_DEVICE 1

 

#define BFIN_NAND_CLE(chip) ((unsigned long)(chip)->IO_ADDR_W | (1 << 2))

#define BFIN_NAND_ALE(chip) ((unsigned long)(chip)->IO_ADDR_W | (1 << 1))

#define BFIN_NAND_READY_PORT (*(volatile unsigned char *)(0x20200000))

#define BFIN_NAND_READY_BIT_MASK 8

 

#define NAND_PLAT_WRITE_CMD(cmd, chip) bfin_write8(BFIN_NAND_CLE(chip), cmd)

#define NAND_PLAT_WRITE_ADR(cmd, chip) bfin_write8(BFIN_NAND_ALE(chip), cmd)

#define NAND_PLAT_DEV_READY(chip)      ((BFIN_NAND_READY_PORT & BFIN_NAND_READY_BIT_MASK) ? 1 : 0)

#define NAND_PLAT_INIT()

 

But I'm getting a ldr error right at the end:

 

bfin-uclinux-objcopy -O srec u-boot u-boot.srec

bfin-uclinux-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin

tools/envcrc common/env_common.o --binary > env-ldr.o

bfin-uclinux-ldr -T bf532-0.5 -c u-boot.ldr u-boot --bmode SPI_MASTER --use-vmas --initcode cpu/blackfin/initcode.o --punchit $((0x30000)):$((0x10000)):env-ldr.o

Creating LDR u-boot.ldr ...

Adding DXE 'u-boot' ... [initcode 1184] [jump block] [ELF block: 125376 @ 0x01FC0000] [ELF block: 40 @ 0xFFA08000] [ELF block: 26668 @ 0x01FDE9E8] bfin-uclinux-ldr: Punching holes beyond the end of an LDR is not supported

 

Backtrace:

bfin-uclinux-ldr[0x8049d7a]

bfin-uclinux-ldr[0x804cd62]

bfin-uclinux-ldr[0x804aa92]

bfin-uclinux-ldr[0x804ae27]

/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0x4005b450]

bfin-uclinux-ldr(wait+0x35)[0x8049571]

make: *** [u-boot.ldr] Error 1

 

Any advice?

 

 

 

 

QuoteReplyEditDelete

 

 

2009-04-29 18:11:47     Re: Problem porting u-boot 2009.03 to my board (NAND backend driver)

Mike Frysinger (UNITED STATES)

Message: 73453   

 

you defined ENV_IS_EMBEDDED which makes no sense if you arent embedding the environment

QuoteReplyEditDelete

 

 

2009-04-30 16:18:09     Re: Problem porting u-boot 2009.03 to my board (LAN driver)

Jay Ku (UNITED STATES)

Message: 73493   

 

Thanks... that got it to compile.  I've fixed a few other things and now everything is working except my LAN chip.  This was working fine in 1.1.6 with the contributed LAN driver from https://blackfin.uclinux.org/gf/project/u-boot/forum/?action=ForumBrowse&forum_id=51&thread_id=26869&_forum_action=ForumMessageBrowse.  Unfortunately it's not quite working with the smc911x.c driver in the latest u-boot:

 

bfin> ping 192.168.1.5

smc911x: initializing

smc911x: detected LAN9215 controller

smc911x: phy initialized

smc911x: MAC 02:80:ad:20:31:b8

ping failed; host 192.168.1.5 is not alive

carui> printenv

baudrate=57600

ethaddr=02:80:ad:20:31:b8

ipaddr=192.168.1.111

gatewayip=192.168.1.1

netmask=255.255.255.0

hostname=carui

loadaddr=0x1000000

serverip=192.168.1.5

stdin=serial

stdout=serial

stderr=serial

 

Environment size: 202/65532 bytes

bfin>

 

Here's the relevant part of my config file:

 

/*

* Network Settings

*/

#define ADI_CMDS_NETWORK    1

#define CONFIG_DRIVER_SMC911X  1

#define CONFIG_DRIVER_SMC911X_BASE  0x20100000

#define CONFIG_DRIVER_SMC911X_16_BIT

#define CONFIG_HOSTNAME     bfin

#define CONFIG_ETHADDR  02:80:ad:20:31:b8

#define CONFIG_IPADDR 192.168.1.111

#define CONFIG_GATEWAYIP 192.168.1.1

#define CONFIG_NETMASK 255.255.255.0

 

 

I'm looking at my LAN with Wireshark and I don't see any packets coming from my board.  I works with 1.1.6 so I know the HW is ok.  I see this driver being used in the BF548 EZ-kit (which uses a similar LAN9218), so I'm probably just making some small mistake.  Any thoughts?

 

 

QuoteReplyEditDelete

 

 

2009-04-30 16:52:32     Re: Problem porting u-boot 2009.03 to my board (LAN driver)

Mike Frysinger (UNITED STATES)

Message: 73494   

 

you're using the driver in the source tree right ?  you're not still using the custom one from the forum ?

 

might check the async portmux in bf548-ezkit.c:board_early_init_f() ...

 

or edit the smc driver and add "#define DEBUG" to the top and maybe you'll get some useful output ...

QuoteReplyEditDelete

 

 

2009-04-30 18:09:40     Re: Problem porting u-boot 2009.03 to my board (LAN driver)

Jay Ku (UNITED STATES)

Message: 73497   

 

Yeah - this is all stuff from the source tree I pulled down with SVN... all I did was specify the address, etc. in my config file.

 

There are some error messages in smc911x.c that are enabled all the time, but I don't see anything conditional.  I defined ET_DEBUG in net.c which gives me:

 

bfin> ping 192.168.1.5

smc911x: initializing

smc911x: detected LAN9215 controller

smc911x: phy initialized

smc911x: MAC 02:80:ad:20:31:b8

sending ARP for 0501a8c0

ARP broadcast 1

ARP broadcast 2

packet received

packet received

Receive from protocol 0x800

Got IP

len=612, v=45

packet received

packet received

Receive from protocol 0x800

Got IP

len=40, v=45

ping failed; host 192.168.1.5 is not alive

bfin>

 

Something's happening, although I don't know where the 'len=612' is coming from... here's a capture from the network:

 

1    0.000000    02:80:ad:20:31:b8    Broadcast    ARP    Who has 192.168.1.5?  Tell 192.168.1.111    60

2    0.000013    IntelCor_18:70:c6    02:80:ad:20:31:b8    ARP    192.168.1.5 is at 00:1b:21:18:70:c6    42

3    5.000139    02:80:ad:20:31:b8    Broadcast    ARP    Who has 192.168.1.5?  Tell 192.168.1.111    60

4    5.000153    IntelCor_18:70:c6    02:80:ad:20:31:b8    ARP    192.168.1.5 is at 00:1b:21:18:70:c6    42

 

Looks like I'm gonna have to spend some time digging through u-boot's network stack and maybe adding some more debugging messages.

 

 

QuoteReplyEditDelete

 

 

2009-05-04 02:31:10     Re: Problem porting u-boot 2009.03 to my board (LAN driver)

Jay Ku (UNITED STATES)

Message: 73539   

 

I got it working.  It looks like the smc911x.c driver I pulled down from the repository doesn't work with controllers that don't have config EEPROMs (like my board - what's the point of an additional part when I've already got megabits of flash?).  I added some code that displayed ADDRH and ADDRL in the MAC at the end of eth_init() and they were both still set to 0xffffffff.  It looks like smx911x_handle_mac_address() is supposed to deal with this:

 

static int smx911x_handle_mac_address(bd_t *bd)

{

    unsigned long addrh, addrl;

    uchar m[6];

 

    /* if the environment has a valid mac address then use it */

    if (!eth_getenv_enetaddr("ethaddr", m)) {

        /* if not, try to get one from the eeprom */

        addrh = smc911x_get_mac_csr(ADDRH);

        addrl = smc911x_get_mac_csr(ADDRL);

 

        m[0] = (addrl       ) & 0xff;

        m[1] = (addrl >>  8 ) & 0xff;

        m[2] = (addrl >> 16 ) & 0xff;

        m[3] = (addrl >> 24 ) & 0xff;

        m[4] = (addrh       ) & 0xff;

        m[5] = (addrh >>  8 ) & 0xff;

 

 

        /* we get 0xff when there is no eeprom connected */

        if ((m[0] & m[1] & m[2] & m[3] & m[4] & m[5]) == 0xff) {

            printf(DRIVERNAME ": no valid mac address in environment "

                "and no eeprom found\n");

            return -1;

        }

 

        eth_setenv_enetaddr("ethaddr", m);

    } else {

        smc911x_set_mac_csr(ADDRH, (m[5] << 8) | m[4]);

        smc911x_set_mac_csr(ADDRL, (m[3] << 24) | (m[2] << 16) | (m[1] << 8) | m[0]);

    }

 

    printf(DRIVERNAME ": MAC %pM\n", m);

 

    return 0;

}

 

 

The printf at the end of the function was reporting the correct MAC address as read from the environment but smx911x_handle_mac_address was never actually loading it into the chip.  I added the two lines in the 'else' at the end and everything seems to work now.

 

Is this a bug in the driver or am I doing something else wrong?

 

 

QuoteReplyEditDelete

 

 

2009-05-04 22:20:01     Re: Problem porting u-boot 2009.03 to my board (LAN driver)

Mike Frysinger (UNITED STATES)

Message: 73602   

 

hmm, i recall seeing a patch on the u-boot list for this problem (no memory attached to the MAC/PHY).  can you try that one instead ?

 

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/57633

QuoteReplyEditDelete

 

 

2009-05-05 14:31:05     Re: Problem porting u-boot 2009.03 to my board (LAN driver)

Jay Ku (UNITED STATES)

Message: 73686   

 

That works fine.

QuoteReplyEditDelete

 

 

2009-05-05 15:58:09     Re: Problem porting u-boot 2009.03 to my board (LAN driver)

Mike Frysinger (UNITED STATES)

Message: 73698   

 

thanks, i'll merge that into our repo

Attachments

    Outcomes