Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12590 Discussions

How does NicheStack recognize Ethernet interfaces?

Altera_Forum
Honored Contributor II
1,511 Views

Hello, 

 

I am using uC/OS II on Nios II processor. I want to create a simple socket server. I want to understand how will the NicheStack know if an ethernet interface is present or not?  

 

I am debugging a problem --> unable to find any working interfaces. I know that this error message arise from ip_startup() function stored in ipstart.c file. It seems that in iniche_devices_init() stored in alt_iniche_dev.c, initialization of InterNiche devices fail. The InterNiche devices List -- p_dev and p_dev_list_end have same values for some reason. So this function returns 0 as if_count (interface count). I do not know the exact reason.  

 

Can anyone throw some light on this?
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
470 Views

Long story short, the ethernet interface software should add itself to the list before iniche_devices_init() runs. alt_iniche_dev.c is an Altera-creation and part of the glue to bring InterNiche into a NIOS HAL system. If you just want to understand how InterNiche works (and don't care about Altera creations) then review the InterNiche documentation - search for "doc31.zip" in your Quartus install folder. 

 

If you are creating a new network interface, I suggest you review Altera Triple Speed Ethernet driver software to see how they did it, and re-use as much of their glue as possible.
0 Kudos
Altera_Forum
Honored Contributor II
470 Views

Hello Ted, 

 

Thank you. I will go through the documentation over the weekend. As of now I dont care how Altera or InterNiche works. I just want to understand the cause of my problem. From other threads in forums, I found that the alt_iniche_dev_list is not having any alt_iniche_dev nodes, that is why it is returning the 'if_count'(interfaces found) as 0. 

 

The alt_iniche_dev node should be inserted into the alt_iniche_dev_list as part of the alt_sys_init( ), which will be called before the application main( ) function. The alt_sys_init( ) calls the ALTERA_AVALON_LAN91C111_INIT( LAN91C111, lan91c111 ); macro to register the lan91c111 driver(by adding to the alt_iniche_dev_list). So it seems the registering of lan91c111 is not happening properly. 

 

In my case it is Altera TSE instead of LAN91C111.
0 Kudos
Altera_Forum
Honored Contributor II
470 Views

OK I think you probably understand enough of how it works, and you're just running into a very specific problem (which I don't know the solution of). 

Keep searching for LAN91C111 related topics, or if you feel like fixing it yourself, the first steps would be stepping through alt_iniche_dev lan91c111() as that is where it should have been adding itself to the array. 

Skimming that code, one thing I'm seeing is that this code will dtrap() and not add itself to the array if it fails reading a LAN91C111 register, which may be your problem. 

 

Good luck.
0 Kudos
Altera_Forum
Honored Contributor II
470 Views

You would need a driver for the Altera TSE as well as whatever PHY chip is on your board. Don't forget the PHY.

0 Kudos
Altera_Forum
Honored Contributor II
470 Views

Thank you Ted and Galfonz, 

 

I checked the drivers. They are installed correctly. I am using Stratix IV GX development kit. And NiosII standard ethernet design for configuring FPGA. I think it does not recognize the PHY or MAC driver. I am looking into it. And the code does dtrap(), but i do not know what to make of it. The NIOS II Console message is: 

 

prepped 0 interfaces, initializing... 

inet setup error: unable to find any working interfaces 

panic: IP 

dtrap - needs breakpoint
0 Kudos
Altera_Forum
Honored Contributor II
470 Views

I looked into alt_init_dev. Here it goes through the list of InterNiche devices. But the list is empty. I am trying to find how the list gets populated.

0 Kudos
Altera_Forum
Honored Contributor II
470 Views

You are using LAN91C111, and not TSE, right? 

 

My previous reply had a copy&paste error and I didn't tell you the right function: my suggestion is to use the Eclipse debugger and to single step through the function alt_avalon_lan91c111_init() as this is where the device is added to the array. 

The code is pretty simple, and it will tell you if this is part of where the problem is. It probes the hardware, and if it's not found, it doesn't add itself to the array.
0 Kudos
Altera_Forum
Honored Contributor II
470 Views

Ted, 

 

I am using Altera TSE (MAC) along with Marvell 88e1111 ethernet PHY. I am using Eclipse debugger and I am not able to find where any of these are initiated. Maybe they are not initiated at all (I do not know) as I am using a ready-made project template - Simple Socket Server.
0 Kudos
Altera_Forum
Honored Contributor II
470 Views

I just had a look at hardware configuration. The ethernet_susbystem.qsys file has connections to and fro TSE to SGDMA RX and SGDMA TX. I am not a hardware guy. So i do not know if this is correct or not. There is no mention about 88e1111 PHY that should be connected to TSE. Assuming this is correct, then the TSE is not being properly initiated.

0 Kudos
Altera_Forum
Honored Contributor II
470 Views

It seems this was issue because I have QII v15.0 and the example design was from QII v12.0. For newer designs look here: 

https://cloud.altera.com/devstore/platform/15.0.0/nios-ii-simple-socket-server-ethernet-example/
0 Kudos
Reply