Re: [lwip-users] how to set the link up

2017-07-07 Thread Krzysztof Wesołowski
One simplification would be to do those link monitoring operations on timer
running on LwIP thread, it removes threading issues (ie. Modifying stack
data, accessing PHY). Only dhcp/ip setup would need to come from external
memory/queue.

On Fri, 7 Jul 2017, 18:52 massimiliano cialdi, <
massimiliano.cia...@powersoft.it> wrote:

> On 07/07/2017 18:04, Noam Weissman wrote:
> >
> > Speed, duplex, link etc... is low level handling and the TCP stack is
> > not aware of that.
> >
> >
> > This is why you call the set_link_up/down in your task, informing the
> > stack !.
> >
> Yes, of course
>
> > The MDIO interface between your micro and PHY has no relation with
> > netif so why do you
> >
> > pass it as argument ?
> >
> because, in our implementation (NXP), netif->state is pointer to
> structure containing information to interface with PHY.
>
> > You several options to get the link state. You can connect the link
> > led in the ETH connector
> >
> > to your micro and read it as a simple IO.
> >
> >
> > If your PHY supports MII and it is connected as an MII you can hook an
> > interrupt to the link line.
> >
> We are compliant to RMII, except interrupt signal that is not routed, so
> we have to poll PHY.
>
> > The third option is what I suggested to read the PHY basic register
> > and check for the link bit.
> >
> Is what I do.
>
> > Your link task should not only check if link is up or down but also
> > know if it has changed !!. In your
> >
> > code is constantly calling the netifapi functions unless I missed
> > something ?
> >
> Yes, I have further modified the task:
>
> static void PhyStatus_Task( struct netif *netif )
> {
>  enum { link_up, link_down } linkstatus = link_down;
>  phy_speed_t physpeed;
>  phy_duplex_t phyduplex;
>  bool link;
>  status_t result;
>
>  ETHSPDOFF();
>  netifapi_netif_set_link_down(netif);
>  while(1)
>  {
>  result = ethernetif_GetLinkStatus(netif, );
>  if(result == kStatus_Success)
>  {
>  switch(linkstatus)
>  {
>  case link_down:
>  if(true == link)
>  {
>  linkstatus = link_up;
>  netifapi_netif_set_link_up(netif);
>  }
>  break;
>  case link_up:
>  if(false == link)
>  {
>  linkstatus = link_down;
>  netifapi_netif_set_link_down(netif);
>  ETHSPDOFF();
>  }
>  else
>  {
>  result = ethernetif_GetLinkSpeedDuplex(netif,
> , );
>  if(result == kStatus_Success)
>  {
>  ETHSPD(physpeed);
>  }
>  }
>  break;
>  }
>  }
>  vTaskDelay(100);
>  }
> }
>
>
> I have investigated the problems: netifapi_netif_set_link_up() is called
> and it cause call to link callback, in this function I call another
> function in netifapi (netifapi_dhcp_start()), so I have a deadlock.
>
> best regards
> Max
>
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
-- 
Pozdrawiam,
Krzysztof Wesołowski
+48 721 337 238
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Bootloader to Application + lwip crash

2017-05-02 Thread Krzysztof Wesołowski
Can you load and start application without involving bootloader?

It's quite possible that driver handling hardware init does not work as
expected if hw was already configured (i.e. MAC, DMA are already setup and
in the middle of operation when application start).

On Mon, 1 May 2017, 23:27 nrichard, <nrich...@ipgphotonics.com> wrote:

> Hello,
>
> My project consists of two sub-projects, a bootloader and an application.
> My bootloader is programmed at the start of flash, and always starts when
> the board is given power.  I also have an application project, that through
> my bootloader I use FTP to transfer the image to a certain address.  Then I
> can jump to that address and my application starts.  This process works
> perfectly fine.
>
> In both my application and my bootloader, I am using lwip version 2.0.2 raw
> api for all internet related protocols and applications.  These include
> ftp,
> http, telnet, and snmp.  The bootloader specifically has ftp, http, and
> telnet.  The application has ftp, http, telnet, AND snmp.  So other than
> snmp, these two projects are nearly identical.
>
> The issue I'm having is that when I jump from my bootloader to my
> application, lwip crashes my board.  The initialization works perfectly
> fine, but when I try to ping the board, go to the built in web page, or try
> snmp, etc. it completely locks up my board and I am forced to hit the reset
> button.  What's more interesting is that when I turn on one of the built in
> printf debug statements, it prints messages for random traffic.  Along with
> that, if I turn multiple debug options on, aka, cluttering my console with
> debug print statements, my application works exactly as intended, just with
> a very high ms (around 60+ when it should be <1).
>
> Just to clarify, my bootloader is working exactly as intended with lwip.
> The webpage works, I can ping the board, and use telnet.  My application is
> exactly the same as my bootloader, it just has snmp added on and a few
> minor
> changes (none that would break lwip since they are unrelated).
>
> Any ideas? What steps could I take to resolve this issue?  I'm not sure if
> this is a problem with my lwip settings in my application somehow, or an
> issue with something else.  I find it very strange that lwip on my
> bootloader works perfectly yet the lwip on my application does not.
>
> Thanks, Nick
>
>
>
> --
> View this message in context:
> http://lwip.100.n7.nabble.com/Bootloader-to-Application-lwip-crash-tp29489.html
> Sent from the lwip-users mailing list archive at Nabble.com.
>
> _______
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
-- 
Pozdrawiam,
Krzysztof Wesołowski
+48 721 337 238
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] LWIP_RAND in dns.c

2015-10-01 Thread Krzysztof Wesołowski
>
> #ifndef DNS_RAND_TXID
> #if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_RAND_XID) != 0)
> #define DNS_RAND_TXID *LWIP_RAND*


>From reading code above I would guess it is required when both LWIP_DNS_SECURE
& LWIP_DNS_SECURE_RAND_XID are defined, so why are you defining them?

Regards,
Krzysztof Wesołowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] memory management

2015-08-21 Thread Krzysztof Wesołowski
Just to continue with off-topic :)

AFAIK all solution are toolchain specific, for GCC we use:

#define MEMORY_EXSRAM1_ORIGIN 0x6000
#define MEMORY_EXSRAM1_LENGTH 4194304 /* 4M */
#define MEMORY_EXSRAM1_ATTRIBUTE __attribute__((section(.exsram1)))

And in linker script:
.exsram1 (NOLOAD) :
{
. = ALIGN(4);
__exsram1_start = .;
*(.exsram1);
__exsram1_end = .;
}  EXSRAM1
PROVIDE(__exsram1_start = __exsram1_start);
PROVIDE(__exsram1_end = __exsram1_end);

We don't initialize data there (so only bss style variables are stored),
but multiple memory buffers go there and in long term its much easier for
us to maintain than fixed memory map.


Pozdrawiam,
Krzysztof Wesołowski,
tel. +48 721 337 238

On Fri, Aug 21, 2015 at 4:45 PM, Sergio R. Caprile scapr...@gmail.com
wrote:

  It's much safer to integrate this with linker script (for example
  with attributes on gcc).  Casting number to pointer does not
  guarantee that other variable will no be placed in the same area (by
  linker or other Dev using such tricks). Happy debugging when it
  happens :)

 Yes.
 However, in this particular example, since by definition of external
 memory there is no on-chip memory at that location, the linker will not
 assign any variable to that memory space. As for other Devs... well,
 let's say all developers know the external memory map...

 Had that double allocation happening once when toying with fixed
 addresses in internal memory though, don't remember what I was doing and
 why I did that... Nice pointing that out anyway!

 AFAIK there is no CMSIS way of assigning segments, is it ? (but that is
 completely off-topic)

 --


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

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

Re: [lwip-users] freertos + lwip = no uart ?

2015-07-28 Thread Krzysztof Wesołowski
Hello,

first thing first - i have no experience with XMEGA, but have learned many
things about  STM32 - sometimes the hard way :)

If adding LWIP without initialization (you written it is only compiled, not
initialized, so basically adding global variables (sections .data /.bss)
and not called code (sections .text)) alters your system behavior IMHO you
are in realatively deep voodo programming, and not tracking root of the
problem would probably hit you later.

Teoretically adding new code can also replace so called weak references
to interrupt handlers (so for example addin LWIP can change ETH IRQ
handler), but if this IRQ is disabled it shoudl not change anything.

Are you using debugger so you can track values in variables/registers to
check UART registers when app is not working??

Are you sure your linker script has correctly configured memory areas (if
so extra variables will cause link time section overflow information, if
linker has bigger memories than MCU some variables are not actually
store'able/readable).

If you use dynamic memory allocation are you sure that:
a) there is enough memory in FreeRTOS heap?
b) if other parts of code (linke printf) call malloc do you use wrapper
redirecting malloc to FreeRTOS heap / are you sure that you malloc
implementation is ok and works with linker script?

I have also have seen some linker scripts where heap is happily growing
from other end of RAM (and _sbrk and malloc are used), waiting from stacks
to come other way - it is rather ticking timebomb :)

Do you have ASSERT configured in FreeRTOS so you can detect
misconfigurations?

Basically there is 98% chance (2% is for you calling LWIP without knowing)
that at the moment UART is working by luck/accident :)

Regards,
Krzysztof Wesołowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] lwip-1.4.1 assert-- file:tcp_out.c line: 445

2015-06-18 Thread Krzysztof Wesołowski
AFAIR there was bug in oversize related code, i have used 1.4.1 with
oversize disabled (after encountering this assert) without problems, and it
is resolved in current master.

Regardsm,
Krzysztof Wesołowski

On Thu, Jun 18, 2015 at 9:50 AM, jo.van.montfo...@telenet.be wrote:

 An assert gets triggered on following line in 
 tcp_out.cLWIP_ASSERT(unsent_oversize
 mismatch (pcb vs. last_unsent),
 pcb-unsent_oversize == last_unsent-oversize_left);
 TCP_OVERSIZE = TCP_MSSTCP_MSS = 1460

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

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

Re: [lwip-users] memory leak ?

2015-06-04 Thread Krzysztof Wesołowski
I would just suggest that if you have RTOS, tasks/threads, queues etc then
using netconn/socket API might be better choice (they use message passing,
queues and semaphores to make programming easier, and I think that using
tcpip_callback tcpip_callback_with_blocking to reimplement this
functionality should be considered after trying to use multithreaded APIs).

Regards,
Krzysztof Wesołowski,
tel. +48 721 337 238

On Thu, Jun 4, 2015 at 2:34 PM, Jan Menzel men...@peperoni-light.de wrote:

 Hi Noam!
 From earlier discussion on this list, I learned that for this
 purpose
 one may schedule a callback into the LWIPs internal task using
 tcpip_callback() or tcpip_callback_with_blocking(). Both queue your
 function and its arguments for execution from within the main Lwip task
 context. I'm not sure if this is applicable here, but if so, I would
 favour the callback solution as yours might introduce dead locks in case
 tcp_sndbuf() blocks. This type of errors are comparably difficult to
 find and likely to happen if eg. an other task is used to free buffers
 after transmission completed.

 Jan

 On 04.06.2015 14:18, Noam weissman wrote:
  Hi,
 
  PROBLEM SOLVED :-)
 
  As mentioned earlier by Sergio we should not call LwIP code from within
  other threads.
 
  I must call tcp_write and other functions from a separate thread. This
  is the implementation.
 
  My TCP stack has the highest task priority in the system.  As a result
  calling tcp_write or any other
  LwIP function may cause unpredictable LwIP internal code problems.
 
  I added  taskENTER_CRITICAL(); and taskEXIT_CRITICAL();
  Function calls to the portion of code that call tcp_write etc.. this
  synchronizes the threads
  Interaction and solved the problem I faced completely.
 
  For example:
 
taskENTER_CRITICAL();
{
AvailableSpace = tcp_sndbuf(ts-pcb);
}
taskEXIT_CRITICAL();
 
 
  Thanks for your insight.
 
  BR,
  Noam.
 
  -Original Message-
  From: lwip-users-bounces+noam=silrd@nongnu.org
  [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On Behalf Of
  Sergio R. Caprile
  Sent: Thursday, June 04, 2015 12:02 AM
  To: lwip-users@nongnu.org
  Subject: Re: [lwip-users] memory leak ?
 
  Tx: yes
  Rx: if you free them properly then they shouldn't be scarce. Have you
  tested this ?
 
  I'm not familiar with lwIP under RTOS except that you must adhere to the
  general rule of not calling the stack from different threads.
  You should check your port with a known good application first. Try
  echo, for example, or netio; both are available in the contrib tree (and
  there is nice patch for netio sent by youknowho)
 
 
  ___
  lwip-users mailing list
  lwip-users@nongnu.org
  https://lists.nongnu.org/mailman/listinfo/lwip-users
 
 
 
  
  
  This footnote confirms that this email message has been scanned by
  PineApp Mail-SeCure for the presence of malicious code, vandals 
  computer viruses.
  
  
 
 
 
 
 
 
 
 
  This footnote confirms that this email message has been scanned by
  PineApp Mail-SeCure for the presence of malicious code, vandals 
 computer viruses.
 
 
 
 
 
 
  ___
  lwip-users mailing list
  lwip-users@nongnu.org
  https://lists.nongnu.org/mailman/listinfo/lwip-users
 

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

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

Re: [lwip-users] dns_gethostbyname

2015-05-08 Thread Krzysztof Wesołowski
On Tue, May 5, 2015 at 11:27 AM, Sandra Gilge sgi...@adatis.com wrote:

 Hallo Christoph,

 I think the tcpip_callback_with_block is the right solution for me. Many
 thanks for that hint.

 But I wonder how I can pass several parameters to dns_gethostbyname then.
 Is
 it done in a struct?
 Dns_gethostbyname has four parameters:
 dns_gethostbyname (const char *hostname, struct ip_addr *addr,
 dns_found_callback  found,
 void *callback_arg)

 As far as I understand a message is sent to tcpip_thread with
 functionpointer and pointer to parameter as payload of that message.


Hello,

Yes you can use struct to pass multiple arguments via void * argument.
struct can be global or dynamically allocated, or if you use blocking
version ( tcpip_callback_with_block (,,1)) you can place struct on stack in
calling thread.

Regards,
Krzysztof Wesolowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] dns_gethostbyname

2015-05-03 Thread Krzysztof Wesołowski
Hi there,


What do you mean with You can however post your callback to be executed on
 lwip thread?

What callback do you talk about, the callback function that is given as
 parameter in the dns_gethostbyname?


both netconn api and socket api use raw api under the hood, those APIs
handle inter thread communication for you.

You can do something similar if you need to execute code on tcpip_thread
from your code. Just use function:

tcpip_callback_with_block

This function simply takes function pointer, void * argument (to pass
additional context to your function if it is needed), and uses RTOS
mechanisms to execute in on tcpip thread (extra argument determines if
current thread will block until execution on tcpip thread completes).

You need to prepare your own functions:
- one responsible for starting request, which will call dns_gethostbyname
and will be passed to tcpip_callback_with_block,
- one responsible for handling result of request, passed to
dns_gethostbyname. This function will be called by dns code on tcpip thread
when requests completes.

Unfortunately I do not have sample at hand.

Regards,
Krzysztof Wesołowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] dns_gethostbyname

2015-04-30 Thread Krzysztof Wesołowski
On Thu, Apr 30, 2015 at 10:37 AM, Sandra Gilge sgi...@adatis.com wrote:

 It is stated that dns_gethostbyname is for the raw-api. Is there a reason
 to use it in combination with sockets? Is there a thread safety issue?


AFAIR dns_gethostbyname  uses other tcpip thread only components, so using
it from outside this thread can be unsafe.

You can however post your callback to be executed on lwip thread - it is
usually sufficient (we use similar patter to handle incoming udp data via
callback in tcpiip thread instead of blocking with netconn).

Regards,
Krzysztof Wesołowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Fwd: question about using master/head instead of 1.4.1

2015-01-15 Thread Krzysztof Wesołowski
As it is open source project, and master is pretty stable (we also use it
in production, after encountering some issues with 1.4.1 which were fixed
in master), consider community in your decision.

Community will be better off you use, test, report bugs and improve current
master, not some old, not maintained stuff.

If you find bug in master we will be interested in solving it - because it
affects our software and products. If you fix bug in master - devs would be
happy to integrate it into master.

If you pick code without community you will be basically responsible for
any ongoing/needed maintenance.

Regards,
Krzysztof Wesołowski,
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] What is the best version of code to use for production

2015-01-10 Thread Krzysztof Wesołowski
I will love to hear from current developers how they feel about current
master stability, but we are successfully using lwip-master in our
maintained and new projects - and if we encounter any problems they are
driver, not lwip core  related.

Regards,
Krzysztof Wesołowski

On Fri, Jan 9, 2015 at 10:03 PM, Robert Deschambault 
robert.deschamba...@gmail.com wrote:

 Hi all,

 I notice that there have been a lot of fixes since the release of v1.4.1.
 Should we be looking at the latest fixes?  Is a release coming soon?

 Thanks,

 Bob

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

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

Re: [lwip-users] CRC of each IP Header is not calculated after some point (STM32F4)

2014-09-23 Thread Krzysztof Wesołowski
AFAIR STM32 requires place for HW calculated CRC to be zero initialized, so
if outgoing buffer is corrupted (modified from zero) at some point it would
break CRC calculation.
On Sep 23, 2014 11:14 AM, Simon Goldschmidt goldsi...@gmx.de wrote:

 Michael Steinecke wrote:
  But from one point on, the CRC calculation for all outgoing packets
 fails or
  is not executed entirely.
  [..]
  CRC calculation is done by HW (SW calculation in LwIP turned off),
 therefore
  I would expect another STM bug. Is there something known? Some ideas how
 to
  track down this?

 I guess you mean checksum, not CRC. Have you tried disabling hardware
 checksum calculation? That would be an ideal way to see if it's the
 hardware driver or another problem.


 Simon

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

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

Re: [lwip-users] TCP retransmission flooding at end of stream

2014-09-16 Thread Krzysztof Wesołowski
I  need to achieve a throughput of at least 2 MBit/s, according our
 requirements. Due to the HW this should be possible.

I am not sure why you decided to go in such extreme direction with your
changes.

We are almost able to saturate 100MBit connection (8 MB/s) and upload
about 2MB/s from SD Card on STM32F407 with RMII attached PHY (Some Micrels
KSZ...)

Are you using some WiFi in your setup? With Ethernet networks we only
needed to tune memory in lwipopts, and there was no need to change types
and/or polling interval.

Have you benchmarked if the need for optimization really is within LwIP
related code?

Regards,
Krzysztof Wesołowski,
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] packet order with tcp_recv

2014-09-10 Thread Krzysztof Wesołowski
I think that without this flag out of order packets are dropped, TCP stream
with out of order packets will be completely unusable.

Regards,
Krzysztof Wesołowski

On Wed, Sep 10, 2014 at 8:43 AM, Richner Simon simon.rich...@psi.ch wrote:

 I think I found the answer in the lwip options:

 /**
  * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order.
  * Define to 0 if your device is low on memory.
  */

 I didn't analyze the code, but to my understanding this means: If this
 flag is set (default), then lwip will queue out of order segments and wait
 for the missing segment, before calling tcp_recv. In this case the
 application doesn't need to worry about out of order packets.

 Please let me know  if I'm mistaken.

 Cheers, Simon


 -Ursprüngliche Nachricht-
 Von: lwip-users-bounces+simon.richner=psi...@nongnu.org [mailto:
 lwip-users-bounces+simon.richner=psi...@nongnu.org] Im Auftrag von
 Radouch, Zdenek
 Gesendet: Dienstag, 9. September 2014 19:20
 An: Mailing list for lwIP users
 Betreff: Re: [lwip-users] packet order with tcp_recv

  Packets will be received in the order they were sent.

 No, TCP packets are IP datagrams that can be lost, duplicated, or that can
 arrive out of order. That is, they won't necessarily arrive in the order
 they were sent. The TCP input module (tcp_in.c) does the necessary ordering
 (it either passes the packet to the user or queues it to be passed in
 later) and Simon's question is whether the tcp_recv callback is delivering
 packets in order they were received or in a sorted order (the reconstructed
 data stream).

 Unfortunately I am not familiar with that callback so I don't know the
 answer :-(.

 Cheers,
 -Z


  -Original Message-
  From: lwip-users-bounces+zradouch=irobot@nongnu.org [mailto:lwip-
  users-bounces+zradouch=irobot@nongnu.org] On Behalf Of Noam
  weissman
  Sent: Tuesday, September 09, 2014 11:49 AM
  To: Mailing list for lwIP users
  Subject: Re: [lwip-users] packet order with tcp_recv
 
  Hi,
 
  In TCP there should not be such an issue. Packets will be received in
  the order they were sent.
 
  TCP is a stream.
 
  BR,
  Noam.
 
  -Original Message-
  From: lwip-users-bounces+noam=silrd@nongnu.org
  [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On Behalf Of
  Richner Simon
  Sent: Tuesday, September 09, 2014 3:30 PM
  To: Mailing list for lwIP users
  Subject: [lwip-users] packet order with tcp_recv
 
  Hi all,
 
  I have a basic question about tcp_recv:
 
  Let's say I have some MBs of data I send to the lwip stack. If (for
  whatever reason) tcp packets arrive out of order, will the stack sort
  this out for me and call the tcp_recv callback with packets sorted in
  correct order? Or do I have to check the sequence number myself to
  make sure I put data back together in correct order?
 
  Thanks for your help
  Simon
 
  ___
  lwip-users mailing list
  lwip-users@nongnu.org
  https://lists.nongnu.org/mailman/listinfo/lwip-users
 
 
 
  **
  *
  *
  
  This footnote confirms that this email message has been scanned by
  PineApp Mail-SeCure for the presence of malicious code, vandals 
  computer viruses.
  **
  *
  *
  
 
 
 
 
 
 
  **
  *
  *
  This footnote confirms that this email message has been scanned by
  PineApp Mail-SeCure for the presence of malicious code, vandals 
  computer viruses.
  **
  *
  *
 
 
 
 
  ___
  lwip-users mailing list
  lwip-users@nongnu.org
  https://lists.nongnu.org/mailman/listinfo/lwip-users

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

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

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

Re: [lwip-users] ping flood crash

2014-09-10 Thread Krzysztof Wesołowski
It rather seems that your hardware driver is not protected.

LwIP core does not care about you RX fifo, interrupts etc.

Regards,
Krzysztof Wesołowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Multi-threaded socket access once again

2014-07-18 Thread Krzysztof Wesołowski
Hi,

We used LwIP in similar scenario, but with one task responsible for this
socket/netconn.

Using internal RTOS queues to pass data to this single task was relatively
simple, and all multitasking problems were avoided.

Are there any reasons you cannot use this socket in single thread with
external mechanism for aggregating data from multiple senders?

Fabian, I guess this can be implemented in LwIP in a way to allow such use
scenario, but wouldn't it be extra code to test/maintain for current
maintainers?

Regards,
Krzysztof Wesołowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

[lwip-users] Data buffering before calling netcon_write

2014-06-13 Thread Krzysztof Wesołowski
Hello,

I am using code similar to std::ostream, writing to open TCP connection.

Without buffering (calling netconn_write for each small data chunk),
performance was an issue, so i implemented simple buffer (over 1kB) to
write data to buffer first, and when buffer is full call netconn_write.

I was considering if i can avoid this extra copy, by pre-allocating sth
like pbuf - filling it and then passing to lwip stack, but it seems tcp
connections only support copy based approach.

Am i right or have I missed something?

Regards,
Krzysztof Wesołowski,
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] lwip with fatfs on a STM32 speed problem

2014-01-28 Thread Krzysztof Wesołowski
What performance do you achieve when sending random data from flash instead
of reading it from FAT FS? Have you measured which module is responsible
for this speed?

Regards,
Krzysztof Wesołowski


On Tue, Jan 28, 2014 at 8:23 AM, Noam weissman n...@silrd.com wrote:

 Hi Dave,

 Attached please find the low level driver I used. This is a bit modified
 driver
 based on inputs I found over the net.

 Try to use it and see if it is better for you.

 BR,
 Noam.

 -Original Message-
 From: lwip-users-bounces+noam=silrd@nongnu.org
 [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On Behalf Of Dave
 Sandl
 Sent: Tuesday, January 28, 2014 5:10 AM
 To: lwip-users@nongnu.org
 Subject: [lwip-users] lwip with fatfs on a STM32 speed problem

 Hi,

 I am having problems getting good speed results on sending files using a
 stm32 with fatfs files system.
 I can only get max of around 2.5kBs on a image download.

 My server and file system seem to work fine, here are the specs
 STM32F4discovery with the ethernet/sdcard baseboard from element14

 I used the ST supplied drivers for both lwip and fatfs to create a raw
 api basic server.

 Here is the relevant code sections, any help would be appreciated.
 If I increase the sd_read_buff to 1024 or higher is does not send the
 file correctly (not sure what to do here or if it should be bigger?)



 #define sd_read_buff 512

 struct http_state
 {
  FIL fileFS;
  char *file;
  u32_t left;
  uint8_t buff[sd_read_buff];
 };

 static void send_data(struct tcp_pcb *pcb, struct http_state *hs)
 {
  err_t err;
  FRESULT ret;
  u16_t len;
  uint br;
  uint temp1 = tcp_sndbuf(pcb);

  if(tcp_sndbuf(pcb)  sd_read_buff)
  len = tcp_sndbuf(pcb);
  else
  {
  if(hs-left  sd_read_buff)
  len = hs-left;
  else
  len = sd_read_buff;
  }

ret = f_read(hs-fileFS, hs-buff, len, br);
if(ret == FR_OK){
err = tcp_write(pcb, hs-buff, br, 0);
if (err == ERR_OK)
{
if(br  len)
hs-left = 0;
else
hs-left -= br;

}
}
 }


 static err_t http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
 {

  struct http_state *hs;
  hs = arg;
  if (hs-left  0)
{
  send_data(pcb, hs);
}
  else
  {
  f_close(hs-fileFS);
  close_conn(pcb, hs);
  }
  return ERR_OK;
 }


 static err_t http_recv(void *arg, struct tcp_pcb *pcb,  struct pbuf *p,
 err_t err)
 {
int32_t len=0;
char *data;
struct http_state *hs;

hs = arg;

if (err == ERR_OK  p != NULL)
{
  /* Inform TCP that we have taken the data */
  tcp_recved(pcb, p-tot_len);

  if (hs-file == NULL)
  {
data = p-payload;
len = p-tot_len;

/* process HTTP GET requests*/
if (strncmp(data, GET /index.htm, 10) == 0)
{

  FIL file;
  FRESULT ret;
  hs-fileFS = file;

  ret = f_open(hs-fileFS, index.htm, FA_READ);
  if(ret == FR_OK)
  {
  pbuf_free(p); // Free the receive data
  hs-left = f_size(hs-fileFS);
  send_data(pcb, hs);
  tcp_sent(pcb, http_sent);
  }
  else
  {
  tcp_write(pcb, file_error, sizeof(file_error), 0);
  pbuf_free(p);
  close_conn(pcb, hs);
  }

}

else if (strncmp(data, GET /pic.jpg, 12) == 0)
{

  FIL file;
  FRESULT ret;
  hs-fileFS = file;

  ret = f_open(hs-fileFS, pic.jpg, FA_READ);
  if(ret == FR_OK)
  {
  pbuf_free(p); // Free the receive data
  hs-left = f_size(hs-fileFS);
  send_data(pcb, hs);
  tcp_sent(pcb, http_sent);
  }
  else
  {
  tcp_write(pcb, file_error, sizeof(file_error), 0);
  pbuf_free(p);
  close_conn(pcb, hs);
  }

}

else
{
tcp_write(pcb, http_index_html, sizeof(http_index_html), 0);
pbuf_free(p);
close_conn(pcb, hs);
}
  }
  else
  {
pbuf_free(p);
close_conn(pcb,hs);
  }
}
if (err == ERR_OK  p == NULL)
{
  close_conn(pcb, hs);
}
return ERR_OK;
 }


 void IAP_httpd_init(void)
 {
struct tcp_pcb *pcb;
/*create new pcb*/
pcb = tcp_new();

if (!pcb)
{
  return ;
}
/* bind HTTP traffic to pcb */
tcp_bind(pcb, IP_ADDR_ANY, 80);
/* start listening on port 80 */
pcb = tcp_listen(pcb);
/* define callback function for TCP connection setup */
tcp_accept(pcb, http_accept

Re: [lwip-users] missing TX packets

2014-01-01 Thread Krzysztof Wesołowski
I dont know how MAC operates in this particular CHIP, but in STM32 you can
select to either transmit frames directly from memory (using FIFO as
temporary buffer) or in store and forward mode when complete frame is
gatheren in FIFO and sent as a whole from FIFO. Maybe you have similar
settings, and change to more buffered mode will be solution? have you
checked underrun flags (if they are available) to detect if tihs is a
source of problem?

Regards,
Krzysztof Wesolowski


On Wed, Jan 1, 2014 at 8:13 AM, Lehel Benedek artshadow2...@gmail.comwrote:

 Hello,

 I'm using an SBC1788 board with an LPC1788 micro controller and
 successfully implemented a web server based on lwIP v1.4.1 with FreeRTOS
 v7.4.2.
 I am using zero copy TX buffers located in the external SDRAM, the
 performance is quite good (the webpage of 600KB (also buffered in the
 external SDRAM) gets loaded up in less than 1sec), and was working
 flawlessly, until I added emWin to the project. Using the embedded LCD
 controller from the LPC1788 and the video buffers also located in the
 external SDRAM I got also the LCD and touchscreen working, however I notice
 that the web-server was no longer working.
 After some debugging I found the following:
  - the problem with the web-server is that some TX packets are not sent
 out at all, although the frame transmission gets correctly called, so from
 100 packets only around 70-80 are sent out
  - the only thing that will cause this problem is the LCD power control.
 When I enable power to the LCD controller the problem is there, if I
 disable power to the LCD controller it's gone.

 I'm guessing it could be a conflict between the Ethernet chip and LCD
 controller both accessing the external SDRAM through DMA, but I have no
 idea on how to proceed.
 I tried different AHB matrix priority settings, without any success.

 Any thoughts on this?

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

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

Re: [lwip-users] Size of ARP Response too much 1534 bytes, packet contains lots of 0xA5 values

2013-10-25 Thread Krzysztof Wesołowski
In my small embedded world, lot 0xA5 and FreeRTOS implicates problem with
stack size (too small stack, overflow and magic happens). If you are using
FreeRTOS try changing FILL BYTE to sth different to confirm this extra data
comes from unused stack space.

Pozdrawiam,
Krzysztof Wesołowski,
tel. +48 721 337 238


On Fri, Oct 25, 2013 at 5:26 AM, Ishmeet ishmeetsing...@gmail.com wrote:

 Size of ARP Response too much 1534 bytes, packet contains lots of 0xA5
 values.
 ARP Request is 64 bytes which is ok.
 Has any one faced this before



 --
 View this message in context:
 http://lwip.100.n7.nabble.com/Size-of-ARP-Response-too-much-1534-bytes-packet-contains-lots-of-0xA5-values-tp21988.html
 Sent from the lwip-users mailing list archive at Nabble.com.

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

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

Re: [lwip-users] Low Iperf performance of lwip 1.4.1 on STM32 and FreeRTOS

2013-07-02 Thread Krzysztof Wesołowski
We put 25MHz HSE to STM32F4, then forward same clock from MCO to micrel phy
and then use micrels 50MHz for RMII.
On Jul 2, 2013 8:50 PM, Jeff Barlow j...@wb6csv.net wrote:

 On 7/2/2013 4:50 AM, Claudius Zingerli wrote:

 In the final design, we plan use a 3-port switch from Micrel. It can be
 clocked from 25MHz or 50MHz, but the board I'm using to develop the
 software has a DP83848 that does need a 50MHz clock source for RMII.
 STM32F4 /might/ be able to handle 50MHz as a main clock source.


 I see. For a one-off dev board I think it's always less frustrating to
 just use a separate 50MHz oscillator. The older PHY chips can be really
 fussy about clock jitter. I think once you get away from that DP83848
 you'll find things less painful.

 I was just suggesting using the Micrel RMII clock output to feed the RMII
 clock input on the MCU. I've never tried feeding a 50MHz clock into the HSE
 on a STM32F407 but it strikes me as risky. I do seem to recall that some of
 the PHYs also have a direct 25MHz output that would work for that. Don't
 know if that includes your switch chip, however.
 --
 Later,
 Jeff

 __**_
 lwip-users mailing list
 lwip-users@nongnu.org
 https://lists.nongnu.org/**mailman/listinfo/lwip-usershttps://lists.nongnu.org/mailman/listinfo/lwip-users

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

Re: [lwip-users] a question!?

2013-06-25 Thread Krzysztof Wesołowski

 After all, I think there should not be many packets processed uselessly if
 the MAC filters them out correctly.


Exactly - nowadays when we use switches, most of traffic is either unicast
adressed to our device or broadcast.

Regards,
Krzysztof
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Blocking netif_linkoutput

2013-06-05 Thread Krzysztof Wesołowski


 I don't know where the idea came from, but that sempaphore is not
 necessary.


This semaphore is usually given in some TxCompleted interrupt
(synchronization), so call to linkoutputs block for only as long as
neccesary.

Regards,
Krzysztof Wesolowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] TCP_MSS questions

2013-03-14 Thread Krzysztof Wesołowski
 It is probably a logical explanation for the behavior I see with different
 TCP_MSS settings.

Its quick guess, but some other parameters are calculated using
TCP_MSS, so maybe (just for example) windows size affects behavior?

Go throuth lwipopts.h and opts.h looking where TCP_MSS is also used,
meybe something will pop-up.

Regards,
Krzysztof Wesołowski,

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


Re: [lwip-users] Problem with fragmented TCP packets using slow 3G connection

2013-02-22 Thread Krzysztof Wesołowski
 lwIP - maybe that case with embedded device, router and slow 3G network is
 rare and lwIP dont handle it proprely.
 I use FreeRTOS 7.2 and lwIP 1.4.0 with socket API.

I use LwIP 1.4.1 and netconn API, allowing for example to remotely
dump flash image of STM32F4 (1MB) over EDGE router so slow connection
is not problem for LwIP itself - i was actually impressed that it
works so well. Maybe something is not well tuned in lwipopts - have
you tried to enable debug messages in lwip to see if there is no
memory issue?

AFAIK lwip 1.4.0 compatible driver is also compatible with 1.4.1, so
consider upgrading - it is usually less to look for with more bugs
fixed :)

I had some issues due to watchdog (as downloading 1MB can take a few
minutes), and i used switch with port speed limited to few Kbps to
test it locally.

Regards,
Krzysztof Wesołowski,

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


Re: [lwip-users] Correctly manage cable disconnection and reconnection

2012-12-08 Thread Krzysztof Wesołowski
In similar case with freertos i created timer to poll phy and called netif
set link down on disconection and up on connection. It works well, even tcp
ip connections can last through temporal disconnection.
On Dec 8, 2012 8:09 AM, CORRADIN Michele michele.corra...@socomec.com
wrote:

 Hi,
 I'm new to LWIP and I'm trying to use it on a a board with an STM32F407
 under ucOS III. I have just ported LWIP on ucOS III based on a project I
 found online, I fixed a couple of bugs and I make it running with fix IP
 and DHCP. The MAC driver is based on the ST one with some modifications for
 my micrel PHY.
 It seems to work fine but I have some problems to correctly manage cable
 disconnection and re-connection.
 Up to now I created a slow task that checks the PHY register to verify the
 connection status and if I see a cable disconnection and re-connection I
 restart the phi init in order to correctly set speed, .. but it's not clear
 to me what I should do to re-init LWIP.
 Un to now I'm doing nothnig and it seems it work 80% of the time .. but
 sometimes it seems it's not able to correctly restart.
 I'm just trying with a ping to see what happens.
 thanks for the support
 michele

 This message and any attachments are established exclusively for his or
 its recipients, and are confidential.
 Any use, diffusion or unauthorized publication is prohibited.
 Please notify the sender immediately by email if you have received this
 email by mistake and delete this email from your system.
 SOCOMEC declines all responsibility concerning this message if it has been
 altered or tampered with.
 It normally contains no virus, but it is the responsibility of the
 recipient to ensure this.
 Please note that any views or opinions presented in this email are solely
 those of the author and do not necessarily represent those of the
 organization.

 Ce message et ses éventuelles pièces jointes sont établies à l'intention
 exclusive de son ou de ses destinataires et sont confidentiels.
 Toute utilisation, diffusion ou publication non autorisée est prohibée.
 Merci d’informer immédiatement l’auteur par retour de message si vous avez
 reçu ce message par erreur, et supprimez ce message.
 SOCOMEC décline toute responsabilité au titre de ce message s'il a été
 altéré ou falsifié.
 Il ne contient normalement aucun virus, mais il est de la responsabilité
 de son destinataire de s'en assurer.
 L’organisation décline toute responsabilité en ce qui concerne les
 informations fournies et les avis exprimés dans le présent message.
 ___
 lwip-users mailing list
 lwip-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/lwip-users
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] how to detect cable down in this case

2012-08-21 Thread Krzysztof Wesołowski
Lwip is just network a stack, it does not interact with physical
medium directly.

In ethernet application usually (always?)  PHY i responsible for link up/down,
negotiation, mode configuration etc.

So your driver must detectrelated events and/or check state, and
report it to LwIP.

Regards,
Krzysztof Wesołowski,


On Tue, Aug 21, 2012 at 9:42 PM, vincent cui vincent@enlogic.com wrote:
 Hi:

 When internet cable is plugged into board, but another side is plugged out
 Slotn how lwip know that the cable is down?

 Vincent

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

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


Re: [lwip-users] how to detect cable down in this case

2012-08-21 Thread Krzysztof Wesołowski
On Tue, Aug 21, 2012 at 10:38 PM, Bill Auerbach
bauerb...@arrayonline.com wrote:
 I think he means if you are connected to a switch and the connection to
 another device on the switch is removed.  In this case there is no loss of
 link since the switch maintains that but there is a loss of connection.

Now I see, i have to often used config when other end was other end of
physical cable ;)

There where sevaral topics about detecting connection break, with
techniques like Keep-Alive Packets mentioned.

TCP/IP itself is capable of delivering packets in connection even when
physical link was down between them, sothere is no simple/ultimate
other plug out on this layer.

Regards,
Krzysztof Wesołowski

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


Re: [lwip-users] how to detect cable down in this case

2012-08-21 Thread Krzysztof Wesołowski
Please, specify your topology (devices/switches/hubs/routers/etc,
which one is lwIP) and tell us what you mean by unpluging another side.

Keep Alives are sent between hosts, so L2/L3 devices are usually
transparen to them.

Regards,
Krzysztof Wesołowski,

On Tue, Aug 21, 2012 at 11:06 PM, vincent cui vincent@enlogic.com wrote:
 You mean that I have to send keep-alive packet to switch and hub to get 
 response ? if no response, it should be break up ?

 -Original Message-
 From: lwip-users-bounces+vincent.cui=enlogic@nongnu.org 
 [mailto:lwip-users-bounces+vincent.cui=enlogic@nongnu.org] On Behalf Of 
 Krzysztof Weso?owski
 Sent: 2012年8月22日 4:44
 To: Mailing list for lwIP users
 Subject: Re: [lwip-users] how to detect cable down in this case

 On Tue, Aug 21, 2012 at 10:38 PM, Bill Auerbach
 bauerb...@arrayonline.com wrote:
 I think he means if you are connected to a switch and the connection to
 another device on the switch is removed.  In this case there is no loss of
 link since the switch maintains that but there is a loss of connection.

 Now I see, i have to often used config when other end was other end of
 physical cable ;)

 There where sevaral topics about detecting connection break, with
 techniques like Keep-Alive Packets mentioned.

 TCP/IP itself is capable of delivering packets in connection even when
 physical link was down between them, sothere is no simple/ultimate
 other plug out on this layer.

 Regards,
 Krzysztof Wesołowski

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

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

Re: [lwip-users] how to detect cable down in this case

2012-08-21 Thread Krzysztof Wesołowski
So, assuming that cable is only passive copper physical medium:)
there is no difference which side of cable is unplugged - PHY device
will report link down.

Regards,
Krzysztof Wesołowski,



On Tue, Aug 21, 2012 at 11:12 PM, vincent cui vincent@enlogic.com wrote:
 Actually, I always plug in cable another side in wall, I think it is 
 connected into some switch or hub ..
 But anyway , I really don't know what type the customer use.



 -Original Message-
 From: lwip-users-bounces+vincent.cui=enlogic@nongnu.org 
 [mailto:lwip-users-bounces+vincent.cui=enlogic@nongnu.org] On Behalf Of 
 Krzysztof Weso?owski
 Sent: 2012年8月22日 5:12
 To: Mailing list for lwIP users
 Subject: Re: [lwip-users] how to detect cable down in this case

 Please, specify your topology (devices/switches/hubs/routers/etc,
 which one is lwIP) and tell us what you mean by unpluging another side.

 Keep Alives are sent between hosts, so L2/L3 devices are usually
 transparen to them.

 Regards,
 Krzysztof Wesołowski,

 On Tue, Aug 21, 2012 at 11:06 PM, vincent cui vincent@enlogic.com wrote:
 You mean that I have to send keep-alive packet to switch and hub to get 
 response ? if no response, it should be break up ?

 -Original Message-
 From: lwip-users-bounces+vincent.cui=enlogic@nongnu.org 
 [mailto:lwip-users-bounces+vincent.cui=enlogic@nongnu.org] On Behalf Of 
 Krzysztof Weso?owski
 Sent: 2012年8月22日 4:44
 To: Mailing list for lwIP users
 Subject: Re: [lwip-users] how to detect cable down in this case

 On Tue, Aug 21, 2012 at 10:38 PM, Bill Auerbach
 bauerb...@arrayonline.com wrote:
 I think he means if you are connected to a switch and the connection to
 another device on the switch is removed.  In this case there is no loss of
 link since the switch maintains that but there is a loss of connection.

 Now I see, i have to often used config when other end was other end of
 physical cable ;)

 There where sevaral topics about detecting connection break, with
 techniques like Keep-Alive Packets mentioned.

 TCP/IP itself is capable of delivering packets in connection even when
 physical link was down between them, sothere is no simple/ultimate
 other plug out on this layer.

 Regards,
 Krzysztof Wesołowski

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

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

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

Re: [lwip-users] implementing device driver: netif events handling

2012-08-09 Thread Krzysztof Wesołowski
 2. Link change events initiated by driver are not thread-safe.
 Wiki page
 http://lwip.wikia.com/wiki/Writing_a_device_driver#Link_change_events
 claims that driver should use netif_set_link_up/netif_set_link_down
 functions. But they manipulate netif flags directly. Moreover, they
 directly call several lwip processing functions leading to execute them in
 driver thread context.
While multiple ports use separate thread for packets input, it is not
the only way LwIP can work. If yor driver operates in tcp_ip thread
there is no need for it to be thread safe. If u use separate threa
thera are netifapi_* variants of functions which uses messages with
call back to pass execution to tcpip thread.

I have modified some sample STM32 driver, added extra maintenance
timer to check PHY/Link status and I execute it with timers inside
tcpip thread. So called driver context is not the one and only
solution - and especially TX is usually handled directly in tcpip
thread.

Regards,
Krzysztof Wesołowski

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

Re: [lwip-users] how to upload file to web server

2012-07-26 Thread Krzysztof Wesołowski
 I develop a webserver with lwIP. Now, I need upload a file from PC to server
 by web. Do I use GET or POST method to do that ?

If you want to upload via web panel you use POST with mime type
multipart/form data.

Implement it or wathc on some working serwer and use wireshark to see basics ;)

Regards,
Krzysztof Wesołowski,

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


Re: [lwip-users] how to upload file to web server

2012-07-26 Thread Krzysztof Wesołowski
I am receiving POST data with netconn api, its matter of reception
logic, not used api. You must add POST request support to your server,
starting with initial request line and using content sent after
headers.

I have written my own server, started with form upload (simple text
data in request body). Then implemented file upload. Basically by
watching data send by browser in wireshark and reading about HTTP.

Regards,
Krzysztof Wesołowski,

On Thu, Jul 26, 2012 at 12:24 PM, vincent cui vincent@enlogic.com wrote:
 Hi Krzy:

 I want to upload via web panel use POST with mime type . but my server can't 
 capture the POST request in HTTP protocol.
 The web server is developed with SOCKET api, not RAW API 
 As you mean, I need receive file by RAW api once press upload button ?

 Vincent

 -Original Message-
 From: lwip-users-bounces+vincent.cui=enlogic@nongnu.org 
 [mailto:lwip-users-bounces+vincent.cui=enlogic@nongnu.org] On Behalf Of 
 Krzysztof Weso?owski
 Sent: 2012年7月26日 18:04
 To: Mailing list for lwIP users
 Subject: Re: [lwip-users] how to upload file to web server

 I develop a webserver with lwIP. Now, I need upload a file from PC to server
 by web. Do I use GET or POST method to do that ?

 If you want to upload via web panel you use POST with mime type
 multipart/form data.

 Implement it or wathc on some working serwer and use wireshark to see basics 
 ;)

 Regards,
 Krzysztof Wesołowski,

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

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

Re: [lwip-users] Making the HTTP server working with RAW API

2012-07-25 Thread Krzysztof Wesołowski


 Whenever I am connecting to the host IP I am downloading a file attached
 to this email instead of visualizing the actual data.

Use wireshark to check headers sent by your server, probably Content-Type
is not send properly.

Regards,
Krzysztof Wesołowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Embedded web page access needs refresh with Google Chrome

2012-07-25 Thread Krzysztof Wesołowski
On Wed, Jul 25, 2012 at 3:20 PM, Daniel Goertzen
daniel.goert...@gmail.comwrote:

 Hmm.  In the not-loaded file the web server is definitely replying.  One
 thing that looks weird is that the webserver is replying with giant TCP
 packets consisting of many fragments.  It appears to work, but my
 understanding is that the packet size should be below MTU.

By huge you mean 1514?

I am also seeing some bad checksum (with bad value, not simply offloaded
0x).

I have encountered similar problem few weeks ago, but I did not solved it -
it stopped hapenning when i stopped sending small chunks of data (i use
netconn_write without oversize enabled, so i just added another buffering
layer to stop sending super short packets occupying whole pbuf each).

Reported packets sizes were similar so it might help :/

Regards,
Krzysztof Wesołowski
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] select issue

2012-07-24 Thread Krzysztof Wesołowski

 I develop SSH server with LWIP SOCKET, and I can connect it with PUTTY
 client tool.
 After connect ok, SSH server trigger a internal SHELL to accept commands
 user input.
 But I found a strange problem about reconnection, that is
 close the PUTTY by press windows right upper X button to disconnect SSH
 server first, then
 rerun PUTTY tool to connect SSH server, it can connect successfully, but
 repeat above operation
 3 times. Connection fail in SELECT functions ,

 Any one know that ?


I am not sure, but afair closing putty with X does not close session
completely - do you have warning about memory pools enabled and they are
not showing up during problems?

Repeating it 3 times may mean just use all available resources, so no new
connection can be processed.

Regards,
Krzysztof Wesołowski,
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

[lwip-users] Handling link-up/down, netif-up/down events in LwIP

2012-07-06 Thread Krzysztof Wesołowski
Hi there,

I am working on device using LwIP to host simple WebPanel.

I am using STM32F4x with FreeRTOS, and I have started with ST's driver and
code - they basically make netif_up and link_up at the beginning, assuming
that connection will be succesfully initialized.

However, i would like to gracefully close what I can when plug is
disconeccted and reestablish connection when link is back.

Currently I am doing it this way:

At the beginning of program i init TCPIP, bring stm32 netif up, and setup
link maintenence timer (so code is periodically called from lwip thread).

In maintenence timer code i jump through simple state machine:
1   stm32_lwip_driver_state_power_up,
2   stm32_lwip_driver_state_waiting_for_link_up,
3   stm32_lwip_driver_state_auto_negotiating,
4   stm32_lwip_driver_state_mac_dma_confgured_for_link

At power up if cable is ok states are 1-2-3-4.

Entering state 4 calls netif_link_up.

If cable is not connected we simply stay in state 2 (link is down).

When cable gets disconnected during operation there is transition 4-2,
netif_link_down_is called and we poll phy for connection.

So there are following questions:
1. Is such scheme alright, thread safe (i use same thread)?
2. Any errors/problem i might encounter which are worth to know upfront?
3. Should netif stay up for whole program operation or should I call
netif_set_down?
4. How listening and/or active connections made with netconn API would
react to such event?
5. If i write own, simple etharp_output function to check link state before
sending, which return code should be used if netif_link_is_down? Does this
error will be simply forwarded to caller? should i

Any other comments are welcome, device is designed to handle big uptimes,
so I must eliminate or memory leak and/or crash risks I can.

Reagrds,
Krzysztof Wesołowski,
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] DHCP and AUTOIP cooperation

2012-06-25 Thread Krzysztof Wesołowski
On Mon, Jun 25, 2012 at 3:48 PM, Funk, Artur artur.f...@iq-wireless.com wrote:
 The autoip code isn't included. It seems that lwiopts.h doesn't
 overwrites the setting in opt.h

lwipopts.h is directly included by opt.h and configurations are
guarded with #ifdefs to prevent redeclaration.

You can for example:
1. enable -Wall to ensure that there is no redeclarations,
2. use #if/#ifdef with #error directive to check if symbol is defined
and its value in certain point in source file.

Maybe you have multiple lwipopts in include paths?

Regards,
Krzysiek

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


Re: [lwip-users] Need Help for Configuration for lwIP

2012-06-22 Thread Krzysztof Wesołowski
 Please suggest suitable lwip configuration for my application.

Enable LwIP debug with level warning for memory buffers, and see whats
happening on your debug channel - you will which buffer run out etc.

While asking for good speed in both directions you must also consider
host PC you are communicating with.

Delays in receiving ACKs (and thus being unable to free buffer with
data) due to computer load can easily change systems symmetric
throughput from 3MB/s to 1MB/s.

Regards,
Krzysztof Wesołowski,

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

Re: [lwip-users] lwip fails for full duplex communication

2012-05-29 Thread Krzysztof Wesołowski
On Tue, May 29, 2012 at 10:18 AM, lookwong look.wangl...@gmail.com wrote:
 I don't think lwip spports full duplex mode.

I do not know what you mean by full duplex, but LwIP works fine for
example echoing data, so the problem is probably in application

Regards,
Krzysztof Wesołowski,
tel. +48 721 337 238

http://www.rainlabs.pl





 On Tue, May 22, 2012 at 12:36 PM, GICINDIA resea...@gicindia.com wrote:


 Hello Kieran,

 Thanx alot for the reply.

 If no. of pbufs is the issue then, to resolve this problem can i make
 MEMP_NUM_PBUF = 32?

 But, i did not understand lwip data transmit logic fully, if possible can
 u
 explain it? so that i can be able to implement some other logic for buffer
 handling at serial side before writing data into pbufs.


 Regards,
 Asma.



 Kieran Mansley wrote:
 
  It looks to me like you have 16 pbufs, each of size 256 bytes.  Your
  TCP_WND is 2048, so you can have 2KB of data received and waiting for
  your
  application before the other end will stop sending.  Your TCP_SND_BUF is
  6KB, so you can have that much sent by your application waiting to go
  onto
  the wire.  In total, this makes 8KB of buffering, but you only have
  enough
  pbufs to hold 4KB (16 * 256).  I think this is why you're running out.
 
  Kieran
  ___
  lwip-users mailing list
  lwip-users@nongnu.org
  https://lists.nongnu.org/mailman/listinfo/lwip-users
 
 

 --
 View this message in context:
 http://old.nabble.com/lwip-fails-for-full-duplex-communication-tp33862721p33886914.html
 Sent from the lwip-users mailing list archive at Nabble.com.


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



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

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


Re: [lwip-users] lwip performance goes down if running with FreeRTOS

2012-05-11 Thread Krzysztof Wesołowski

 I found root cause now , it is ST CORTEX M3 DMA problem when receive a
 large of file..

 I trace the code, after lwIP performance is down, the Rx Buffer
 unavailable flag is always set. It means that DMA is in unknown status..**
 **

 ** **

 It should be enthernet driver problem ..anyone know how to fix  ? thank you


I was working with STM32 Eth driver in last month, using manufacturer code
as a starting point. Most performance issues was easy to track with LwIP
debug configured on warning level - information about all pool and heap
running low are really useful.

Also in code:

   /* Set Own bit in Rx descriptors: gives the buffers back to DMA */
   for (i=0; iDMA_RX_FRAME_infos-Seg_Count; i++)
   {
 DMARxNextDesc-Status = ETH_DMARxDesc_OWN;
 DMARxNextDesc = (ETH_DMADESCTypeDef
 *)(DMARxNextDesc-Buffer2NextDescAddr);
   }

Lines in for should be in different order - changing descriptor after you
released it to dma might cause extra problems.

When in despeir i put ASSERTS in IRQ code to check all status bits and
detet any problem.

My driver used MTU sized RX buffers so i did not have to take care of
linked descriptors with single frame.
Regards,
Krzysztof Wesołowski,
tel. +48 721 337 238

http://www.wrss.eaie.agh.edu.pl
http://www.integra.agh.edu.pl
http://www.rainlabs.pl
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] lwip performance goes down if running with FreeRTOS

2012-05-11 Thread Krzysztof Wesołowski
On Fri, May 11, 2012 at 8:46 AM, vincent cui vincent@enlogic.comwrote:

  ** **

 HI :

 ** **

 You use MTU SIZE as RX buffer,  in ST code, it define RX buffer like
 uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE];

 ** **

 So, you only set ETH_RXBUFNB to 1 ?

 **

No, as in ST code i use ETH_RX_BUF_SIZE = MTU size and multiple buffers.
Hovewer in RX interrupt i can assume that only current buffer has been
filled.

It might be useful if you to attach ISR code and ETH_Get_Received_Frame_
interrupt();

Can you explain what this code do:

   /* Check if received frame with multiple DMA buffer segments */
   if (DMA_RX_FRAME_infos-Seg_Count  1)
   {
 DMARxNextDesc = DMA_RX_FRAME_infos-FS_Rx_Desc;
   }
   else
   {
 DMARxNextDesc = frame.descriptor;
   }


Regards,
Krzysztof
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Detecting remote close when using netconn API

2012-04-12 Thread Krzysztof Wesołowski
Can I make such non blocking read with already established connection?

Regards,
Krzysztof Wesolowski,



On Thu, Apr 12, 2012 at 2:03 PM,  lwip-users-requ...@nongnu.org wrote:
 Send lwip-users mailing list submissions to
        lwip-users@nongnu.org

 To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.nongnu.org/mailman/listinfo/lwip-users
 or, via email, send a message with subject or body 'help' to
        lwip-users-requ...@nongnu.org

 You can reach the person managing the list at
        lwip-users-ow...@nongnu.org

 When replying, please edit your Subject line so it is more specific
 than Re: Contents of lwip-users digest...


 Today's Topics:

   1. Detecting remote close when using netconn API
      (Krzysztof Weso?owski)
   2. Re: Detecting remote close when using netconn API (Kieran Mansley)
   3. tcp_sndbuf return 0 when sending file (vincent cui)


 --

 Message: 1
 Date: Thu, 12 Apr 2012 00:44:48 +0200
 From: Krzysztof Weso?owski kwes...@kwesoly.net
 To: lwip-users@nongnu.org
 Subject: [lwip-users] Detecting remote close when using netconn API
 Message-ID:
        caprkjpbmoltt5jbzrpke25_ac1pwc8pnkcd220nlrarwacp...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-2

 Hi,

 I am using netcon api in simple application. Device is a server
 processing connections in loop, PC is a client. After PC establishes
 connection we go into simple loop:

    while (err == ERR_OK) {
        if (streaming_enabled()) {
            err = netconn_write(pc,sbuf, 1152, NETCONN_COPY);
        }
        vTaskDelay(1);
    }

 where pc is struct netconn *.

 However if streaming is disabled, there is now way we can detect that
 PC sent FIN and closed connection - so subsequent connection to same
 port to server causes RST (we are still in inner loop so we cannot
 accept next connection).

 What can i do to detect that PC closed connection? I do not mean
 Ethernet layer error and other hard do diagnose in few miliseconds
 problems, rather typical situation with connection closed by PC.

 Regards,
 Krzysztof Weso?owski,



 --

 Message: 2
 Date: Thu, 12 Apr 2012 09:44:45 +0100
 From: Kieran Mansley kie...@recoil.org
 To: Mailing list for lwIP users lwip-users@nongnu.org
 Subject: Re: [lwip-users] Detecting remote close when using netconn
        API
 Message-ID:
        1334220287.1609.4.ca...@kjm-desktop.uk.level5networks.com
 Content-Type: text/plain; charset=UTF-8

 On Thu, 2012-04-12 at 00:44 +0200, Krzysztof Weso?owski wrote:
 What can i do to detect that PC closed connection?

 The simplest way would be to do a non-blocking read from the connection.
 If the PC has closed it in that direction, you will get an error.

 Kieran




 --

 Message: 3
 Date: Thu, 12 Apr 2012 07:09:48 +
 From: vincent cui vincent@enlogic.com
 To: Mailing list for lwIP users lwip-users@nongnu.org
 Subject: [lwip-users] tcp_sndbuf return 0 when sending file
 Message-ID:
        32017c613ef61f42b30f94182979beb7d91...@server4.enlogic.com
 Content-Type: text/plain; charset=us-ascii

 All

 I develop a FTP server with lwIP 1.3.2 in Cortex M3 platform, when I use 
 FlashFXP to get file from the server, the tcp_sndbuf always return 0 after 
 work a while .
 I capture it with wireshark, the file is attached file. The server ip: 
 192.168.1.51. it seems that transfer error and need retransmission.

 [Untitled.png]

 My sendcode in server is below:

 static void send_data(struct tcp_pcb *pcb, struct ftpd_datastate *fsd)
 {
    err_t err;
    u16_t len;
    int i;
    if (sfifo_used(fsd-fifo)  0)
         {
        if (tcp_sndbuf(pcb)  sfifo_used(fsd-fifo))
                   {
            len = tcp_sndbuf(pcb);   - the len is set 0 after work a while.
        }
                   else
                   {
            len = (u16_t)sfifo_used(fsd-fifo);
        }

        i = fsd-fifo.readpos;
        if ((i + len)  fsd-fifo.size)
                   {
            err = tcp_write(pcb, fsd-fifo.buffer + i, (u16_t)(fsd-fifo.size 
 - i), 1);
            if (err != ERR_OK)
                            {
                return;
            }
            len -= fsd-fifo.size - i;
            fsd-fifo.readpos = 0;
            i = 0;
        }
                   err = tcp_write(pcb, fsd-fifo.buffer + i, len, 1);
        if (err != ERR_OK)
                   {
             return;
        }
         fsd-fifo.readpos += len;
    }
 }

 Who know how to solve ?
 Vincent Cui
 Software Engineer Leader
 Mobile: +8613255150315
 Tel: +86 21 34612525x6104
 Fax: +86 21 34619770
 E-Mail: vincent@enlogic.commailto:vincent.c...@enlogic.com
 Shanghai EnLogic Electric Technology Co., Ltd.
 Address: 1104-1106, Building A, No.391, Guiping Road, Xuhui District, 
 Shanghai, 200233


 -- next part --
 An HTML attachment was scrubbed...
 URL: 
 

[lwip-users] Detecting remote close when using netconn API

2012-04-11 Thread Krzysztof Wesołowski
Hi,

I am using netcon api in simple application. Device is a server
processing connections in loop, PC is a client. After PC establishes
connection we go into simple loop:

while (err == ERR_OK) {
if (streaming_enabled()) {
err = netconn_write(pc,sbuf, 1152, NETCONN_COPY);
}
vTaskDelay(1);
}

where pc is struct netconn *.

However if streaming is disabled, there is now way we can detect that
PC sent FIN and closed connection - so subsequent connection to same
port to server causes RST (we are still in inner loop so we cannot
accept next connection).

What can i do to detect that PC closed connection? I do not mean
Ethernet layer error and other hard do diagnose in few miliseconds
problems, rather typical situation with connection closed by PC.

Regards,
Krzysztof Wesołowski,

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


[lwip-users] Possible alignment bug in 1.4.0?

2012-03-05 Thread Krzysztof Wesołowski
I have encountered some HardFaults in rcurrent 1.4.0 version, file
etharp.c code, line 416.

code (stripped from asserts):
static err_t
etharp_send_ip(struct netif *netif, struct pbuf *p, struct eth_addr
*src, struct eth_addr *dst)
{
  struct eth_hdr *ethhdr = (struct eth_hdr *)p-payload;
  ETHADDR32_COPY(ethhdr-dest, dst);
  ETHADDR16_COPY(ethhdr-src, src);

  ethhdr-type = PP_HTONS(ETHTYPE_IP);
  return netif-linkoutput(netif, p);
}

Assumes that ethhdr-dest is 32bit aligned, which is true only for
ETH_PAD_SIZE==0.

Am I doing something wrong?

Regards,
Krzysztof Wesołowski,

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