This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ethernet driver question


Hello,

I'm sorry,since I am a Japanese it took me long time to write reply.

Mr JÃrgen Lambrecht wrote,
I think the problem could be that your hardware driver has not been compiled.
If you are using an existing board supported by eCos, and are using the net template of the board, then it must be something else.


Can you better discribe all of it.


I apologize for lengthy reply.


I already made "MyTarget" template for my board, copying and amending "Hitachi SE77x9 board" template.
I already checked RedBoot is working properly.


I am chechikng SMSC LAN91C111 driver(if_lan91cxx.c) using eCos test program "nc_test_slave.c".

I build using "MyTarget" hardware template and "net" package template,and link to nc_test_slave.c.

My target's configuration is like next.
[in  ecos.db]
target mytarget {
       alias       { "Hitachi mytarget board" }
       packages    { CYGPKG_HAL_SH
                     CYGPKG_HAL_SH_SH3
                     CYGPKG_HAL_SH_SH77X9_mytarget
                     CYGPKG_IO_FLASH
                     CYGPKG_DEVS_FLASH_SH_mytarget
                     CYGPKG_DEVS_FLASH_AMD_AM29XXXXX

                     CYGPKG_DEVS_ETH_SMSC_LAN91CXX
                     CYGPKG_DEVS_ETH_SH_MYTARGET
                     CYGPKG_IO_ETH_DRIVERS

                     CYGPKG_IO_SERIAL_SH_mytarget
                     CYGPKG_IO_SERIAL_SH_SCIF
       }
       description "
          The mytarget target provides the packages needed to run
          eCos on a Hitachi Solution Engine 77x9 board."
}

[in mytarget_eth_drivers.cdl]
cdl_package CYGPKG_DEVS_ETH_SH_MYTARGET {

display "Mytarget SMC91C111 ethernet driver"

   parent        CYGPKG_IO_ETH_DRIVERS
   active_if     CYGPKG_IO_ETH_DRIVERS
   active_if     CYGPKG_HAL_SH_SH77X9_mytarget

   # chip wired in PCMCIA, 16-bit mode, no EEPROM
   implements    CYGHWR_NET_DRIVERS
   implements    CYGHWR_NET_DRIVER_ETH0
   implements    CYGINT_DEVS_ETH_SMSC_LAN91CXX_REQUIRED
##    implements    CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE
   implements    CYGINT_DEVS_ETH_SMSC_LAN91CXX_STATIC_ESA

   requires      CYGPKG_DEVS_ETH_SMSC_LAN91CXX
   description   "Ethernet driver for Mytarget boards."

   include_dir   cyg/io
   compile       if_mytarget.c

define_proc {
puts $::cdl_system_header "/***** ethernet driver proc output start *****/"
puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_SMSC_LAN91CXX_INL <cyg/io/devs_eth_mytarget.inl>"
puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_SMSC_LAN91CXX_CFG <pkgconf/devs_eth_sh_mytarget.h>"
puts $::cdl_system_header "/***** ethernet driver proc output end *****/"
}


   # Arguably this should do in the generic package
   # but then there is a logic loop so you can never enable it.

   cdl_interface CYGINT_DEVS_ETH_SMSC_LAN91CXX_REQUIRED {
       display   "SMSC LAN91CXX driver required"
   }

   cdl_option CYGDAT_DEVS_ETH_SH_MYTARGET_NAME {
       display       "Device name for the ethernet driver"
       flavor        data
       default_value {"\"eth0\""}
       description   "
           This option sets the name of the ethernet device for the
           ethernet port."
   }

   cdl_option CYGDAT_DEVS_ETH_SH_MYTARGET_ESA {
       display       "The ethernet station address (MAC)"
       flavor        data
       default_value {"{0x00, 0x40, 0x31, 0x08, 0x01, 0x00}"}
       description   "A static ethernet station address.
           Caution: Booting two systems with the same MAC on the same
           network, will cause severe conflicts."
       active_if     !CYGSEM_DEVS_ETH_SH_MYTARGET_REDBOOT_ESA
   }

   cdl_option CYGSEM_DEVS_ETH_SH_MYTARGET_REDBOOT_ESA {
       display "Use the RedBoot ESA (MAC address)"
       default_value 0
       flavor        bool
       description   "
           Use the ESA that is stored as a RedBoot variable instead of
           a static ESA."
   }

}
end of [in mytarget_eth_drivers.cdl]

I register interrupt ruoitnes
in \packages\devs\eth\smsc\lan91cxx\current\src\if_lan91cxx.c's
smsc_lan91cxx_init() like next,
#ifndef CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
  // Initialize environment, setup interrupt handler
  cyg_drv_interrupt_create(cpd->interrupt,
                           CYGNUM_DEVS_ETH_SMSC_LAN91CXX_INT_PRIO,
                           (cyg_addrword_t)sc,
                           (cyg_ISR_t *)lan91cxx_isr,
                           (cyg_DSR_t *)eth_drv_dsr,
                           &lan91cxx_interrupt_handle,
                           &lan91cxx_interrupt);
  cyg_drv_interrupt_attach(lan91cxx_interrupt_handle);
#endif // !CYGPKG_IO_ETH_DRIVERS_STAND_ALONE
  cyg_drv_interrupt_acknowledge(cpd->interrupt);
  cyg_drv_interrupt_unmask(cpd->interrupt);


My target's LAN91C111 driver instantiating file is
\packages\devs\eth\sh\mytarget\current\include\devs_eth_mytarget.inl,
copying and amending \packages\devs\eth\arm\flexanet\current\include\devs_eth_flexanet.inl


[devs_eth_mytarget.inl]
#include <pkgconf/system.h>
#include <pkgconf/devs_eth_sh_mytarget.h>
#include <cyg/hal/hal_intr.h>

// MAC address is stored as a Redboot config option
#ifdef CYGPKG_REDBOOT
#include <pkgconf/redboot.h>
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
#include <redboot.h>
#include <flash_config.h>

#define LAN91CXX_IS_LAN91C111

RedBoot_config_option("Network hardware address [MAC]",
                    mytarget_esa,
                    ALWAYS_ENABLED, true,
                    CONFIG_ESA, 0
  );
#endif
#endif

// ESA address fetch function
static void mytarget_get_ESA(struct lan91cxx_priv_data *cpd)
{
  // Fetch hardware address from RedBoot config
#if defined(CYGSEM_DEVS_ETH_SH_MYTARGET_REDBOOT_ESA)
#if defined(CYGPKG_REDBOOT) && \
  defined(CYGSEM_REDBOOT_FLASH_CONFIG)
  flash_get_config("mytarget_esa", cpd->enaddr, CONFIG_ESA);
#else
#error "No RedBoot flash configuration to store ESA"
#endif
#else
  unsigned char static_esa[] = CYGDAT_DEVS_ETH_SH_MYTARGET_ESA;
  memcpy(cpd->enaddr, static_esa, 6);
#endif
}

static lan91cxx_priv_data lan91cxx_eth0_priv_data = {
  config_enaddr : mytarget_get_ESA,
#ifndef CYGSEM_DEVS_ETH_SH_MYTARGET_REDBOOT_ESA
  enaddr: CYGDAT_DEVS_ETH_SH_MYTARGET_ESA,
  hardwired_esa : true,
#else
  hardwired_esa : false,
#endif
 base : (unsigned short *) 0xa8000000,
 interrupt : 9,
};

ETH_DRV_SC(lan91cxx_sc,
         &lan91cxx_eth0_priv_data,          // Driver specific data
         CYGDAT_DEVS_ETH_SH_MYTARGET_NAME, // Name for device
         lan91cxx_start,
         lan91cxx_stop,
         lan91cxx_control,
         lan91cxx_can_send,
         lan91cxx_send,
         lan91cxx_recv,
         lan91cxx_deliver,
         lan91cxx_poll,
         lan91cxx_int_vector
);

NETDEVTAB_ENTRY(lan91cxx_netdev,
              "lan91cxx_" CYGDAT_DEVS_ETH_SH_MYTARGET_NAME,
              smsc_lan91cxx_init,
              &lan91cxx_sc);

//EOF devs_eth_mytarget.inl
end of [in mytarget_eth_drivers.cdl]

I think if I could call lan91cxx_start routine properly,lan91cxx drv will work,
but as I said in previous mail,since ng_ether_attach_p == NULL,I couldn't execute
attach routine (*ng_ether_attach_p)(ifp);


As a try,I inserted next coding before calling (*ng_ether_attach_p) in ether_ifattach().

ng_ether_attach_p = if_attach;
if (ng_ether_attach_p != NULL)
 (*ng_ether_attach_p)(ifp);

Then executed (*ng_ether_attach_p)(ifp) and jumped
if_attach(ifp)
in packages\net\bsd_tcpip\current\src\sys\net\if.c

But lan91cxx_start was never called.

Although I cannot understand how lan91cxx_start is called,
looks like the mechanism that calls lan91cxx_start is not working.

My fconfig setting is below.
[my fconfi setting]
RedBoot> fconfig
Run script at boot: true
Boot script:
.. fis load -b 0x8c010000 nc_slave
.. channel 1
.. go 0x8c010000
Enter script, terminate with empty line
fis load -b 0x8c010000 nc_slave
channel 1
go 0x8c010000

Boot script timeout (1000ms resolution): 3
Use BOOTP for network configuration: false
Gateway IP address: 172.16.1.1
Local IP address: 172.16.1.200
Local IP address mask: 255.255.255.0
Default server IP address: 172.16.1.1
Console baud rate: 38400
dns_ip: 172.16.1.1
GDB connection port: 9000
Force console for special debug messages: false
Network hardware address [MAC]: 0x00:0x40:0x31:0x08:0x01:0x00
Network debug at boot time: true
Update RedBoot non-volatile configuration - continue (y/n)? y
... Erase from 0xa03f0000-0xa0400000: .
... Program from 0x8fff0000-0x90000000 at 0xa03f0000: .
RedBoot>
end of [my fconfi setting]

And RedBoot serial output is below.
[RedBoot serial output]
My Flash ID is 4:22f9:0:19
eth_drv_init:enaddr=0x8c0005c4
Ethernet send:
8C002214: FF FF FF FF FF FF 00 40 31 08 01 00 08 06 |.......@1..... |
Ethernet send:
8C002214: FF FF FF FF FF FF 00 40 31 08 01 00 08 06 |.......@1..... |
Ethernet send:
8C002214: FF FF FF FF FF FF 00 40 31 08 01 00 08 06 |.......@1..... |
Ethernet send:
8C002214: FF FF FF FF FF FF 00 40 31 08 01 00 08 06 |.......@1..... |
Ethernet send:
8C002214: FF FF FF FF FF FF 00 40 31 08 01 00 08 06 |.......@1..... |
Ethernet send:
8C002214: FF FF FF FF FF FF 00 40 31 08 01 00 08 06 |.......@1..... |
Ethernet send:
8C002214: FF FF FF FF FF FF 00 40 31 08 01 00 08 06 |.......@1..... |
Ethernet send:
8C002214: FF FF FF FF FF FF 00 40 31 08 01 00 08 06 |.......@1..... |
Ethernet eth0: MAC address 00:40:31:08:01:00
IP: 172.16.1.200/255.255.255.0, Gateway: 172.16.1.1
Default server: 172.16.1.1


RedBoot(tm) bootstrap and debug environment [ROM]
Non-certified release, version UNKNOWN - built 16:50:29, Sep 19 2007

Platform: mytarget (SH 7709S)
Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited

RAM: 0x8c000000-0x90000000, [0x8c00bed0-0x8ffed000] available
FLASH: 0xa0000000 - 0xa0400000, 64 blocks of 0x00010000 bytes each.
== Executing boot script in 3.000 seconds - enter ^C to abort
Ethernet recv:
8C005D34: FF FF FF FF FF FF 00 15 C5 6D 23 F0 08 06 |.........m#... |
Ethernet recv:
8C006344: FF FF FF FF FF FF 00 15 C5 6D 23 F0 08 06 |.........m#... |
Ethernet recv:
8C006954: FF FF FF FF FF FF 00 15 C5 6D 23 F0 08 06 |.........m#... |
RedBoot> fis load -b 0x8c010000 nc_slave
RedBoot> channel 1
RedBoot> go 0x8c010000
Network stack using 69632 bytes for misc space
69632 bytes for mbufs
139264 bytes for mbuf clusters
[cyg_net_init] Init: mbinit(0x00000000)
[cyg_net_init] Init: cyg_net_init_devs(0x00000000)
Init device 'lan91cxx_eth0'
smsc_lan91cxx_init
LAN91CXX - supposed BankReg @ a800000e = 3302
LAN91CXX - type: 9, rev: 1
LAN91CXX - status: 0069
LAN91CXX - static ESA: 00:40:31:08:01:00
[cyg_net_init] Init: loopattach(0x00000000)
[cyg_net_init] Init: ifinit(0x00000000)
[cyg_net_init] Init: domaininit(0x00000000)
[cyg_net_init] Init: cyg_net_add_domain(0x8c05a754)
New domain internet at 0x00000000
[cyg_net_init] Init: cyg_net_add_domain(0x8c05a198)
New domain route at 0x00000000
[cyg_net_init] Init: call_route_init(0x00000000)
[cyg_net_init] Done
Start Network Characterization - SLAVE
No load = 58442
Set background load = 20%
Set background load = 0%
High Load[20] = 37136 => 37%
Set background load = 20%
Set background load = 0%
Load[10] = 47742 => 19%
Set background load = 20%
Set background load = 0%
Final load[10] = 47858 => 19%
Start test for eth0
end of [RedBoot serial output]


What do I lack to install lan91cxx driver ?
I would appreciate any help.

Gokoen Masahiro

My first mail:
Hello,

I am a newcomer to eCos.

I am trying to run LAN91C111 driver using "net" template,but I am encountered what I cannot understand.

My target board is implemented with SH7709S CPU and SMSC LAN91C111 ethernet controller.

Looks like doing nothing,so
I checked attach routine.

I discovered attach is executed at /packages/net/bsd_tcpip/current/src/sys/net/if_ethersubr.c
ether_ifattach(ifp, bpf) function's last part.


if (ng_ether_attach_p != NULL)
 (*ng_ether_attach_p)(ifp);

But I discovered that because ng_ether_attach_p == NULL,
it skipped over (*ng_ether_attach_p)(ifp).

ng_ether_attach_p is defined in /packages/net/bsd_tcpip/current/include/sys/param.h
#define ng_ether_attach_p cyg_ng_ether_attach_p
but cyg_ng_ether_attach_p == NULL.


eCos version is CVS downloaded current version.

I do not know why this happens.
Would you please teach me what shoud I do ?

I would appreciate your help.

Gokoen


-- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]