[lwip-users] HOWTO LwIP if NO_SYS = 1

564 views
Skip to first unread message

Niraj Kulkarni

unread,
Apr 28, 2011, 10:15:23 AM4/28/11
to jeff...@gmail.com, lwip-...@nongnu.org

Hi,

I am porting LwIP on Renesas 16-bit controller with no OS. After reading

1.       lwip-1.4.0.rc2\doc\rawapi.txt

2.       http://lwip.wikia.com/wiki/Porting_For_Bare_Metal

3.       http://lwip.wikia.com/wiki/LwIP_with_or_without_an_operating_system

4.       http://permalink.gmane.org/gmane.network.lwip.general/9824

I have understood that in my case “NO_SYS = 1” and All applications must be written using the raw (or native) API.

I have following quires:

1.       Do I have to implement etharp_tmr(), ip_reass_tmr(), tcp_tmr(), etc using some way ( may be Hardware time of the controller).

2.       I could not understand arguments of “netif_add” function ; specially first and last two arguments. Out of the last two functions which one I have

to implement.

3.       Is there any code ported on any controller with LwIP on it with NO_SYS = 1 , available for download.  

 

Regards,

Niraj

 

 



Larsen & Toubro Limited

www.larsentoubro.com

This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.

Bill Auerbach

unread,
Apr 28, 2011, 12:30:17 PM4/28/11
to Mailing list for lwIP users

Although it’s obviously for a different platform, the Altera NIOS II port here http://lwip.wikia.com/wiki/Available_device_drivers has a sample NO_SYS program including a WEB server.  I would think using it with your driver should work almost as-is.

 

Bill

Niraj Kulkarni

unread,
Apr 29, 2011, 6:41:15 AM4/29/11
to Jeff Barber, lwip-...@nongnu.org
In continuation with pervious questions, I have few more

1. What is the significance of "ram" variable in mem_init().
I am referring : LwIP_M16C (although it is for uCos OS and my system is NO OS),
here "ram" is a well array defined by user of size MEM_SIZE
In lwip-1.4.0.rc2 source code : "ram" is a static u8_t pointer.

I guess MEM_SIZE is the maximum heap memory (or say buffer ) lwip will use and I have to configure
"memp" and "pbuf_pool" considering MEM_SIZE in mind.

Should I assign my controllers RAM memory to this "ram" variable?

2. As I will be using NO_SYS = 1 , in a single-threaded (non-OS) environment,
What will be my "input_function" in netif_add : ip_input() or tcpip_input() ?

Ref: http://www.sics.se/~adam/lwip/os.html

-----Original Message-----
From: Jeff Barber [mailto:jeff...@gmail.com]
Sent: 28 April, 2011 10:52 PM
To: Niraj Kulkarni
Subject: Re: HOWTO LwIP if NO_SYS = 1

On Thu, Apr 28, 2011 at 10:15 AM, Niraj Kulkarni
<Niraj.K...@lnties.com> wrote:
[snip]


> I have following quires:
>
> 1. Do I have to implement etharp_tmr(), ip_reass_tmr(), tcp_tmr(), etc
> using some way ( may be Hardware time of the controller).

No, you do not have to implement them. They are provided by lwip.
You just need to determine when it's time to call them. Assuming you
have a periodic clock interrupt, you could just count interrupts and
determine how long it's been since the last time you called them.


> 2. I could not understand arguments of "netif_add" function ;
> specially first and last two arguments. Out of the last two functions which
> one I have to implement.

The first argument is to a netif structure that you allocate. It will
be filled in partly by lwip itself in netif_add and partly in your
driver initialization function.

The last two arguments are pointers to (a) your network driver's
initialization function, and (b) the input function that is to be
called from your driver.

The init function, (a), should intiialize your driver and should also
fill in various fields of the netif:
name = the network device name (something like 'e0')
link_output = the function (in your driver) to call to actually
enqueue a frame for transmission
output = function to call to output an IP frame (this is typically
the lwip-provided etharp_output to allow ARP to work -- it will
eventually call your driver via link_output).
mtu = your network MTU
flags = NETIF_FLAG_* (BROADCAST, ETHARP, etc.)
hwaddr_len = (typically ETHARP_HWADDR_LEN=6 for ethernet)
hwaddr = your device's MAC address

The input function, (b), is what will be assigned to the netif->input
field (the assignment is done inside of netif_add) and what your
driver should invoke to pass frames into the lwip stack (typically you
will pass the lwip-provided function ethernet_input as this argument).

So, something like this:
if (netif_add(&my_netif, &my_ip_addr, &my_netmask, &my_gateway,
my_private_data_structure, my_driver_init_function, ethernet_input) ==
NULL)
handle_error();


> 3. Is there any code ported on any controller with LwIP on it with
> NO_SYS = 1 , available for download.

There are various partial examples in the contrib directory on the web site.


Larsen & Toubro Limited

www.larsentoubro.com

This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.

_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

gold...@gmx.de

unread,
Apr 29, 2011, 7:27:39 AM4/29/11
to Mailing list for lwIP users
Niraj Kulkarni wrote:
> In continuation with pervious questions, I have few more
>
> 1. What is the significance of "ram" variable in mem_init().
> I am referring : LwIP_M16C (although it is for uCos OS and my system is NO OS),
> here "ram" is a well array defined by user of size MEM_SIZE
> In lwip-1.4.0.rc2 source code : "ram" is a static u8_t pointer.
>
> I guess MEM_SIZE is the maximum heap memory (or say buffer ) lwip will use and I have to configure
> "memp" and "pbuf_pool" considering MEM_SIZE in mind.
>
> Should I assign my controllers RAM memory to this "ram" variable?
No, just define MEM_SIZE and the compiler will allocate memory for you.
But make sure your compiler/linker warns if you allocate too much memory
for your target controller

> 2. As I will be using NO_SYS = 1 , in a single-threaded (non-OS) environment,
> What will be my "input_function" in netif_add : ip_input() or tcpip_input() ?
When using an ethernet device, ethernet_input() will be the correct
function. tcpip_input() will not even be compiled for NO_SYS==1.
> Ref: http://www.sics.se/~adam/lwip/os.html
That one is so old. It can be used as a starter, but not as an
up-to-date reference: since Adam wrote this, many things have changed in
the stack.

Simon

Reply all
Reply to author
Forward
0 new messages