How to activate ethernet driver

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to activate ethernet driver

Dennis S
Good evening,
I have a question concerning the programming of the ethernet in eCos.

The current state is, that I can use some existent functions for the
MAC of my Embedded System located in /devs/eth. They provide the
possibility to access the hardware via HAL_WRITE(). The init function
is used in the NETDEV_TAB macro.

Additionally I wrote some drivers for the seperated PHY with the
obligatory "phy_stat" function. When I started debugging I was very
suprised, that either the init function of the mac nor some function
of the PHY driver was used (I set a brakpoint there and nothing
happens).

So my question is: do I have to activate some other things to get
the ethernet work? What possibilities are there to check the result?
By the way: the plan is to use a third party TCP-stack later.

Kind regards,
Dennis

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

Reply | Threaded
Open this post in threaded view
|

Re: How to activate ethernet driver

Jerzy Dyrda-2
Hello Dennis,

You have to add your PHY driver to the list in
devs/eth/phy/current/cdl/phy_eth_drivers.cdl like that:
    cdl_option CYGHWR_DEVS_ETH_PHY_LAN8720A {
        display       "SMSC LAN8720A"
        flavor        bool
        default_value 0
        compile       -library=libextras.a LAN8720A.c
        description "
          Include support for SMSC LAN8720A"
    }

and after that of course choose it.

Regarding ETH driver you have to provide such entry in an code of driver :

ETH_DRV_SC(stm32_sc,
           &stm32_priv_data,      // Driver specific data
           "eth0",                // Name for this interface
           stm32_eth_start,
           stm32_eth_stop,
           stm32_eth_control,
           stm32_eth_can_send,
           stm32_eth_send,
           stm32_eth_recv,
           stm32_eth_deliver,
           stm32_eth_poll,
           stm32_eth_int_vector);

NETDEVTAB_ENTRY(stm32_netdev,
                "stm32",
                stm32_eth_init,
                &stm32_sc);
after that init() funtion (in my case stm32_eth_init,) will be called.


Best regards,
jerzy

2015-04-07 23:10 GMT+02:00 Dennis S <[hidden email]>:

> Good evening,
> I have a question concerning the programming of the ethernet in eCos.
>
> The current state is, that I can use some existent functions for the
> MAC of my Embedded System located in /devs/eth. They provide the
> possibility to access the hardware via HAL_WRITE(). The init function
> is used in the NETDEV_TAB macro.
>
> Additionally I wrote some drivers for the seperated PHY with the
> obligatory "phy_stat" function. When I started debugging I was very
> suprised, that either the init function of the mac nor some function
> of the PHY driver was used (I set a brakpoint there and nothing
> happens).
>
> So my question is: do I have to activate some other things to get
> the ethernet work? What possibilities are there to check the result?
> By the way: the plan is to use a third party TCP-stack later.
>
> Kind regards,
> Dennis
>
> --
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Re: [ECOS] How to activate ethernet driver

Jerzy Dyrda-2
Hello Dennis,

2015-04-09 15:08 GMT+02:00  <[hidden email]>:

> In my debugger I can see the "stm32_netdev" structure, which seems to
> be filled correctly except for the "status". This is set to zero, for what I
> do not know if it is correct?
I also don't know but the most important issue is that "stm32_eth_init"
have to be called. But to achive it you have to have properly configured system.
Please look below.

> Anyway.. putting a breakpoint in the beginning of "stm32_eth_init" does
> not have any effect. The program does not stop!

> Any other suggestions?
Sorry for such basic question but do you have such packages like:
CYGPKG_IO_ETH_DRIVERS, network driver and so on?

BTW.
Maybe in this way it will be easier. Generally if I like to add
new eth/phy driver I create eCos configuration file with using template
usually "lwIP for Ethernet" and proper hardware target. After that
I didn't have any problem with "calling" eth/phy driver.

Could you provide information about your target?
Is it any known reference board?
Do you have HAL (BSP) for it?


> Gesendet: Donnerstag, 09. April 2015 um 14:15 Uhr
> Von: "Jerzy Dyrda" <[hidden email]>
> An: "Dennis S" <[hidden email]>
> Cc: "eCos Discussion" <[hidden email]>
> Betreff: Re: [ECOS] How to activate ethernet driver
> Hello Dennis,
>
> You have to add your PHY driver to the list in
> devs/eth/phy/current/cdl/phy_eth_drivers.cdl like that:
> cdl_option CYGHWR_DEVS_ETH_PHY_LAN8720A {
> display "SMSC LAN8720A"
> flavor bool
> default_value 0
> compile -library=libextras.a LAN8720A.c
> description "
> Include support for SMSC LAN8720A"
> }
>
> and after that of course choose it.
>
> Regarding ETH driver you have to provide such entry in an code of driver :
>
> ETH_DRV_SC(stm32_sc,
> &stm32_priv_data, // Driver specific data
> "eth0", // Name for this interface
> stm32_eth_start,
> stm32_eth_stop,
> stm32_eth_control,
> stm32_eth_can_send,
> stm32_eth_send,
> stm32_eth_recv,
> stm32_eth_deliver,
> stm32_eth_poll,
> stm32_eth_int_vector);
>
> NETDEVTAB_ENTRY(stm32_netdev,
> "stm32",
> stm32_eth_init,
> &stm32_sc);
> after that init() funtion (in my case stm32_eth_init,) will be called.
>
>
> Best regards,
> jerzy
>
> 2015-04-07 23:10 GMT+02:00 Dennis S <[hidden email]>:
>> Good evening,
>> I have a question concerning the programming of the ethernet in eCos.
>>
>> The current state is, that I can use some existent functions for the
>> MAC of my Embedded System located in /devs/eth. They provide the
>> possibility to access the hardware via HAL_WRITE(). The init function
>> is used in the NETDEV_TAB macro.
>>
>> Additionally I wrote some drivers for the seperated PHY with the
>> obligatory "phy_stat" function. When I started debugging I was very
>> suprised, that either the init function of the mac nor some function
>> of the PHY driver was used (I set a brakpoint there and nothing
>> happens).
>>
>> So my question is: do I have to activate some other things to get
>> the ethernet work? What possibilities are there to check the result?
>> By the way: the plan is to use a third party TCP-stack later.
>>
>> Kind regards,
>> Dennis
>>
>> --
>> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>>

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

Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: [ECOS] How to activate ethernet driver

Jerzy Dyrda-2
Hello Dennis,

2015-04-10 11:11 GMT+02:00  <[hidden email]>:
[snip]
We are a bit closer.
> I digged a little deeper in the source code and found the function
> "cyg_io_init" which iterates over the __DEVTAB__ table. I can see how it runs through
> different devices like tty, flash, adc, ... but not the ethernet driver.
> As far as I understand the reference manual, this SHOULD happen here too!
No exactly, it seems that Ethernet driver is a different sort of
devices strictly connected to network stack.
I assume that this is reason why is called from network stack. Please
look at lwIP stack which is much simple to
analyse:
./net/lwip_tcpip/current/src/ecos/simple.c:

cyg_lwip_simple_init(void)
{
[snip]

        // Initialize network devices
        for (t = &__NETDEVTAB__[0]; t != &__NETDEVTAB_END__; t++) {
            if (t->init(t)) {
                t->status = CYG_NETDEVTAB_STATUS_AVAIL;
            } else {
                // Device not [currently] available
                t->status = 0;
            }
        }

similar mechanism is in BSD stack.

>In the configuration tree under "I/O sub-system -> Common ethernet support" I:
>1) activated "Support for stand-alone stack"
Regarding "stand-alone stack" - this mode is used by Redboot and Redboot is
responsible for driver initialization :
./redboot/current/src/net/net_io.c:

net_init(void)
{
[snip]

    if (t->init(t)) {
            t->status = CYG_NETDEVTAB_STATUS_AVAIL;
            if (primary_net == (struct eth_drv_sc *)0) {
                primary_net = __local_enet_sc;
            }

You have to use one of the existing stack FreeBSD/lwIP or build RedBoot as
a target until you provide your own network stack.

Best regards,
jerzy


> Gesendet: Donnerstag, 09. April 2015 um 15:43 Uhr
> Von: "Jerzy Dyrda" <[hidden email]>
> An: "Dennis S" <[hidden email]>
> Cc: "eCos Discussion" <[hidden email]>
> Betreff: Re: Re: [ECOS] How to activate ethernet driver
> Hello Dennis,
>
> 2015-04-09 15:08 GMT+02:00 <[hidden email]>:
>
>> In my debugger I can see the "stm32_netdev" structure, which seems to
>> be filled correctly except for the "status". This is set to zero, for what
>> I
>> do not know if it is correct?
> I also don't know but the most important issue is that "stm32_eth_init"
> have to be called. But to achive it you have to have properly configured
> system.
> Please look below.
>
>> Anyway.. putting a breakpoint in the beginning of "stm32_eth_init" does
>> not have any effect. The program does not stop!
>
>> Any other suggestions?
> Sorry for such basic question but do you have such packages like:
> CYGPKG_IO_ETH_DRIVERS, network driver and so on?
>
> BTW.
> Maybe in this way it will be easier. Generally if I like to add
> new eth/phy driver I create eCos configuration file with using template
> usually "lwIP for Ethernet" and proper hardware target. After that
> I didn't have any problem with "calling" eth/phy driver.
>
> Could you provide information about your target?
> Is it any known reference board?
> Do you have HAL (BSP) for it?
>
>
>> Gesendet: Donnerstag, 09. April 2015 um 14:15 Uhr
>> Von: "Jerzy Dyrda" <[hidden email]>
>> An: "Dennis S" <[hidden email]>
>> Cc: "eCos Discussion" <[hidden email]>
>> Betreff: Re: [ECOS] How to activate ethernet driver
>> Hello Dennis,
>>
>> You have to add your PHY driver to the list in
>> devs/eth/phy/current/cdl/phy_eth_drivers.cdl like that:
>> cdl_option CYGHWR_DEVS_ETH_PHY_LAN8720A {
>> display "SMSC LAN8720A"
>> flavor bool
>> default_value 0
>> compile -library=libextras.a LAN8720A.c
>> description "
>> Include support for SMSC LAN8720A"
>> }
>>
>> and after that of course choose it.
>>
>> Regarding ETH driver you have to provide such entry in an code of driver :
>>
>> ETH_DRV_SC(stm32_sc,
>> &stm32_priv_data, // Driver specific data
>> "eth0", // Name for this interface
>> stm32_eth_start,
>> stm32_eth_stop,
>> stm32_eth_control,
>> stm32_eth_can_send,
>> stm32_eth_send,
>> stm32_eth_recv,
>> stm32_eth_deliver,
>> stm32_eth_poll,
>> stm32_eth_int_vector);
>>
>> NETDEVTAB_ENTRY(stm32_netdev,
>> "stm32",
>> stm32_eth_init,
>> &stm32_sc);
>> after that init() funtion (in my case stm32_eth_init,) will be called.
>>
>>
>> Best regards,
>> jerzy
>>
>> 2015-04-07 23:10 GMT+02:00 Dennis S <[hidden email]>:
>>> Good evening,
>>> I have a question concerning the programming of the ethernet in eCos.
>>>
>>> The current state is, that I can use some existent functions for the
>>> MAC of my Embedded System located in /devs/eth. They provide the
>>> possibility to access the hardware via HAL_WRITE(). The init function
>>> is used in the NETDEV_TAB macro.
>>>
>>> Additionally I wrote some drivers for the seperated PHY with the
>>> obligatory "phy_stat" function. When I started debugging I was very
>>> suprised, that either the init function of the mac nor some function
>>> of the PHY driver was used (I set a brakpoint there and nothing
>>> happens).
>>>
>>> So my question is: do I have to activate some other things to get
>>> the ethernet work? What possibilities are there to check the result?
>>> By the way: the plan is to use a third party TCP-stack later.
>>>
>>> Kind regards,
>>> Dennis
>>>
>>> --
>>> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>>> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>>>

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

Reply | Threaded
Open this post in threaded view
|

Re: How to activate ethernet driver

Grant Edwards-6
On 2015-04-10, Jerzy Dyrda <[hidden email]> wrote:
> Hello Dennis,
>
> 2015-04-10 11:11 GMT+02:00  <[hidden email]>:
> [snip]
> We are a bit closer.

>> I digged a little deeper in the source code and found the function
>> "cyg_io_init" which iterates over the __DEVTAB__ table. I can see how
>> it runs through different devices like tty, flash, adc, ... but not
>> the ethernet driver. As far as I understand the reference manual,
>> this SHOULD happen here too!
>
> No exactly, it seems that Ethernet driver is a different sort of
> devices strictly connected to network stack.

[...]

True.  However, you can create a "normal" driver table entry for an
Ethernet driver if you want to.

Then you can have an init function called exactly once at system
startup time.

You can also then use use cyg_io_read(), cyg_io_write(),
cyg_io_set_config(), cyg_io_get_config() etc. for whatever you want.
I've done that in the past for a number of Ethernet drivers so that
user application can read/write raw MAC-level packets for certain
proprietary Ethernet protocols. [The eCos network stacks didn't used
to provide any mechanism for that].  We also use the normal cyg_io API
to allow application code to configure and uery a variety of features
in the Ethernet controller hardware that the normal network stacks are
not aware of and for which they provide no API.

--
Grant Edwards               grant.b.edwards        Yow! Don't hit me!!  I'm in
                                  at               the Twilight Zone!!!
                              gmail.com            


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