Re: [lwip-users] LwIP configuration for directing LWIP_DEBUGF to user function

2018-02-25 Thread Noam Weissman
Hi Yacob,


Redirecting may be different from IDE to IDE. Redirecting is not only for 
printf.


In general you should define the macro PUTCHAR or similar to some low level

handling depended on your own hardware.


Here are some examples I found,

   for KAIL: http://www.keil.com/forum/60531/




   For IAR:   
https://stackoverflow.com/questions/23388659/redirect-printf-to-console-i-o-on-iar-embedded-workbench







BR,

Noam.


[https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-i...@2.png?v=73d79a89bded]

Redirect printf to Console I/O on IAR Embedded 
Workbench
stackoverflow.com
I have coded a project of mine in C on a Windows machine in the software IAR 
Embedded Workbench IDE. The project compiles and runs fine. I have a couple of 
printf ...






How printf to specific USART? - Keil
www.keil.com
Thread 60531: Hello,I have STM32F103 with three active USART + one SWO port.I 
need to single UART send different data, ideally using printf, butI do not know 
how to ...







From: lwip-users  on behalf of 
Yacob Hassidim 
Sent: Sunday, February 25, 2018 5:28 PM
To: 'Mailing list for lwIP users'
Subject: Re: [lwip-users] LwIP configuration for directing LWIP_DEBUGF to user 
function


Helo Simon,



Thank you for referring me to lwip-contrib.



I downloaded the version contrib-2.0.1.



I found that LWIP_DEBUG is defined as compilation parameters of project layer.



I didn’t find mention of LWIP_PLATFORM_DIAG.



I use LwIP as part of ST CubeMx environment that defines LWIP_PLATFORM_DIAG in 
cc.h as the following:

#define LWIP_PLATFORM_DIAG(message)  printf message



Can you please advise me how should I direct the “printf message” to 
serial_write(char *message_string)?



Yacob Hassidim.



From: lwip-users [mailto:lwip-users-bounces+yacobh=dds-security@nongnu.org] 
On Behalf Of goldsi...@gmx.de
Sent: Sunday, February 25, 2018 2:27 PM
To: Mailing list for lwIP users 
Subject: Re: [lwip-users] LwIP configuration for directing LWIP_DEBUGF to user 
function



On 25.02.2018 13:18, Yacob Hassidim wrote:

Can you please send an example of definitions of LWIP_DEBUG and 
LWIP_PLATFORM_DIAG?

Instead of sharing yet more ports, why don't you have a look at the example 
ports for windows or linux in lwip-contrib? There you will find what you are 
looking for.

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

Re: [lwip-users] LwIP configuration for directing LWIP_DEBUGF to user function

2018-02-20 Thread Noam Weissman
Hi Yacob,

In file sysy_arch.c you have an include to debug.h

If you set LWIP_DEBUG you need to define  LWIP_PLATFORM_DIAG

LWIP_PLATFORM_DIAG is your wrapper for printing

Normally this is defined in cc.h that is part of your micro porting code.

Hope that helped,
Noam.



From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Yacob Hassidim
Sent: Tuesday, February 20, 2018 2:44 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] LwIP configuration for directing LWIP_DEBUGF to user 
function

Hello,

I use LwIP version 2.0.0.

How to configure LwIP in order to direct LWIP_DEBUGF to user function e.g. 
serial_write() ?

Thanks.

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

Re: [lwip-users] An external filesystem for httpd

2018-02-01 Thread Noam Weissman
Hi,

I have created a separate HTTPD server based on the contribution, some input 
from other users and my own input.

One of the changes that I made was to create a different FS structure. Instead 
of a link list that places each file
after the other and a linked list at the end of data I created a link list that 
holds OFFSET to file location before the list of files.

The difference is, that this construction can be either placed internally in 
the micro or externally in a large FLASH. 

I created a PERL script that has two options. Either creates a C data file 
similar to the one used in the contribution 
And can be linked with the project, or a binary file that can be stored in an 
external FLASH. All the user need to do is 
know where is the base address for the beginning of linked list starts and 
change FS code to read from external FLASH.

The code for using an external FLASH is not yet finished as I never actually 
had time to test it with an external FLASH file. 
I use it now only internally In a micro, similar to the standard HTTPD.

The file construction that I use is as follows:

#  typedef struct 
#  {
#int OffsetToNextHeader;// offset in bytes to the next header
#int OffsetToFileName;  // offset in bytes to the file name
#int FileDataLen;   // file size in bytes
#int OffsetToFileData;   // offset in bytes to the file data
#   
#  } FsDataFile_t;


First the file has a list of the above items. Secondly following the above 
items are the actual HTML etc files.

Actually one even can place the HTML, JS etc... files in none continues memory.

Hope that helps in any way.  


BR,
Noam.


-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Giuseppe Modugno
Sent: Thursday, February 01, 2018 10:15 AM
To: lwip-users@nongnu.org
Subject: [lwip-users] An external filesystem for httpd

Until now, I was using the embedded fs generated by the tool makefsdata. 
Unfortunately the filesystem I'd like to create is bigger than the internal 
Flash memory of the MCU.

I'm thinking to use an external SPI Flash memory to save the filesystem. 
So I need another tool that creates an ouput binary (or Intel Hex) image file 
to save directly in the SPI Flash memory. I know I can write this tool 
completely myself, but I'm sure there are some good examples to look at.
Also I need some source code to access this filesystem over SPI (open file, 
read 100 bytes, and so on).

I think I can use the FAT filesystem, however I think it is over complicated 
respect what I need to do.

Actually httpd automatically search for files in fsdata data structure (that is 
a linked list). With an external file system, I think I have to consider every 
file as a custom file. I'm in doubt if it's better to read immediately the 
content from external Flash in
fs_read_async_custom() (blocking until all data are ready), or start a 
background (non-blocking) process that reads from external SPI Flash and 
signals when it ends.

Any suggestions?


___
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 never tries to send a packet?

2018-01-18 Thread Noam Weissman
Hi Chris,


If you are able to read/write PHY registers that means that the SMI interface 
is up and running.


Before digging into LwIP make sure your MII/RMII and DMA are configured 
correctly with the

driver. I am working with LwIP for last 7 years and I almost had no problems 
with LwIP.


If you are using your own hardware and not some EVB make sure that all your CPU 
pin-outs

are properly defined. Make sure that you are working in correct PHY mode (RMII 
or MII),

check that you defined all the hardware clocks and DMA...


I run LwIP on ST9, STM32F2/4 and now 7 and so far I am happy :-)


Hope that helped a bit.


BR,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Will Wykeham <w...@wykeham.net>
Sent: Thursday, January 18, 2018 7:48 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] LWIP never tries to send a packet?

I had a similar looking issue last week bringing up lwip for the first time. In 
my case it was because I hadn't set both the interface and the link as being 
'up'.

Will

On 18 Jan 2018 5:46 pm, "Chris Seto" 
<chris1s...@gmail.com<mailto:chris1s...@gmail.com>> wrote:
Hi Noam, Thanks for the reply.

A few of the defs seemed to be wrong for my PHY. Specifically, the bits in MISR 
and BMSR. Slight differences. The bits existed, but not in the order the HAL 
config files indicated them to.I copied my config to the bottom of this message.

That said, I don't think that the PHY is the issue for this problem, since it 
does seem like the PHY is RX'ing, but the bigger issue I'm seeing is that I'm 
not even getting debug output from LwIP other than "etharp_timer" once every 
second. I can confirm that I can talk to the PHY and that it's up and running 
ok. When I mentioned that I can guarantee the link up after low_level_init 
runs, what I meant is that I can actually watch the registers change, and I 
don't let low_level_init run until the link is up, as per the PHY SR.

I'm guessing the issue here is some config value in LwIP.

I've also tried allowing a full hanging ASSERT, the code never ASSERTs.

I've played around with the debug message config, and I simply cannot tease any 
other messages out of the stack, even though at least DHCP is started. I do 
know that printf works called from LwIP, because I can at least see the 
etharp_timer message.

Thanks,
Chris

For the TLK110, here are my settings:


// TLK110 datasheet, page 5
#define PHY_ADDR 0x01

// TLK110 Registers
#define PHY_MISR1 0x0012
#define PHY_BMSR 0x0001

#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic 
Control Register   */
#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic 
Status Register*/
#define PHY_RESET   ((uint16_t)(1 << 15)) /*!< PHY Reset */
#define PHY_LOOPBACK((uint16_t)(1 << 14)) /*!< Select 
loop-back mode */
#define PHY_AUTONEGOTIATION ((uint16_t)(1 << 12)) /*!< Enable 
auto-negotiation function */
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)(1 << 9)) /*!< Restart 
auto-negotiation function*/
#define PHY_POWERDOWN   ((uint16_t)(1 << 11)) /*!< Select the 
power down mode   */
#define PHY_ISOLATE ((uint16_t)(1 << 10)) /*!< Isolate PHY 
from MII */
#define PHY_AUTONEGO_COMPLETE   ((uint16_t)(1 << 5)) /*!< 
Auto-Negotiation process completed   */
#define PHY_LINKED_STATUS   ((uint16_t)(1 << 2)) /*!< Valid link 
established   */
#define PHY_JABBER_DETECTION((uint16_t)(1 << 1)) /*!< Jabber 
condition detected*/

#define PHY_SR  ((uint16_t)0x10)/*!< PHY special 
control/ status register Offset */
#define PHY_SPEED_STATUS((uint16_t)(1 << 1))  /*!< PHY Speed 
mask  */
#define PHY_DUPLEX_STATUS   ((uint16_t)(1 << 2))  /*!< PHY Duplex 
mask */



On Thu, Jan 18, 2018 at 11:31 AM, Noam Weissman 
<n...@silrd.com<mailto:n...@silrd.com>> wrote:

Hi Chris,



I am not working with ST HAL, rather with the older SPL (standard peripheral 
library).



I do not know why you needed to change the PHY driver as all the standard PHY’s 
that are IEEE

compatible will work the same.



The ST driver has two portions:

1.   MDIO/MDC connectivity (SMI)

2.   RMII/MII data transfer etc…



Via SMI you control the PHY and or make queries. Meaning you can check if you 
have a link,

what is the speed etc…



Regarding MII/RMII you need to make sure that you defined the driver to work in 
the same mode

that the PHY is strapped. If the PHY is defined to work in RMII but your driver 
is defined to work in MII,

it will not 

Re: [lwip-users] LWIP never tries to send a packet?

2018-01-18 Thread Noam Weissman
Hi Chris,

I am not working with ST HAL, rather with the older SPL (standard peripheral 
library).

I do not know why you needed to change the PHY driver as all the standard PHY’s 
that are IEEE
compatible will work the same.

The ST driver has two portions:

1.   MDIO/MDC connectivity (SMI)

2.   RMII/MII data transfer etc…

Via SMI you control the PHY and or make queries. Meaning you can check if you 
have a link,
what is the speed etc…

Regarding MII/RMII you need to make sure that you defined the driver to work in 
the same mode
that the PHY is strapped. If the PHY is defined to work in RMII but your driver 
is defined to work in MII,
it will not work !

I suggest going over ST examples first and then try to see why you code is not 
working for you.


BT,
Noam.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Chris Seto
Sent: Thursday, January 18, 2018 6:47 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] LWIP never tries to send a packet?

Hi,

I'm using LwIP 2.0 running on an STM32F4 with a TI TLK110 ethernet PHY. I've 
written the driver for the PHY and corrected the definitions within the STM32 
HAL such that the PHY is initialized correctly. When low_level_init() returns, 
the link is guaranteed physically up.

I'm having an issue where it doesn't seem like LwIP is ever trying to send 
packets. I put printf("RX\r\n"); and printf("TX\r\n"); calls in my ethernetif.c 
handlers, and while RX periodically is called, TX is /never/ called. Even if I 
try to open a TCP socket, and even if I try dhcp_start().

I'm sure this is some kind of minor config issue. Any advice?

Debugging is enabled, and I see a bunch of "etharp_timer" at about 2hz or so, 
but nothing else. Shouldn't I at least expect to see a DHCP discover packet 
sent?

Code here:

ethernetif.c
https://pastebin.com/eXGyDWJX

lwipopts.h
https://pastebin.com/ZTmmG43P

Networking.c
https://pastebin.com/20DN07dy

Main loop:
while (1)
{
HAL_Delay(50);
LedToggle(LED_1);
LedToggle(LED_2);
NetworkingUpdate();
}

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

Re: [lwip-users] Problem running lwip on cortex M7 with D cache enabled

2017-11-30 Thread Noam Weissman
Hi,

I am working with STM32F7 with LwIP 2.02 + FreeRTOS 9

D and I cache are enabled.

TX/RX descriptors are hard coded inside DTCM. We have no problems for now.

Most of the rest of LwIP init is as it was in older projects that used the 
STM32F4

I strongly suggest upgrading to LwIP 2.02 or even 2.03 

BR,
Noam.


-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Jochen Strohbeck
Sent: Thursday, November 30, 2017 2:10 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] Problem running lwip on cortex M7 with D cache enabled

Hello,

I'm using lwip 1.4.1 and FreeRTOS on a SAME70 custom board with success if 
D-cache is disabled. If I enable the D-cache no more packets are received. If I 
place the RX descriptor into a non-cacheable region I get packets again but the 
received data is corrupt. Here is the lwip output:

 Checksum (0xa5fd) failed, IP packet dropped.
 IP (len 96) is longer than pbuf (len 50), IP packet dropped.

I understand that I have to move the receive (and send) buffers which are used 
by the GMAC DMA to a non-cacheable region too. And here is where my problem 
starts. In my understanding these buffers are by default in an lwip memory 
pool. If I simply place the entire memory pool to non-cacheable region the CPU 
hangs up. I guess this is due to the D-cache requirements that the (GMAC) DMA 
buffer must be aligned to 32bytes but I don't know how to modify the lwip code 
in such a way that the receive buffer (pbuf->payload?) is 32byte aligned. The 
other (and
better?) way would be to separate the receive buffer (or pbuf->payload) from 
the lwip memory pool so I can place it everywhere I want but I don't know how 
to manage this. Probably there is a better way to do so in lwip ?

Any help is welcome.


___
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_HTTPD_SSI_MULTIPART and concurrent HTTP requests

2017-11-24 Thread Noam Weissman
Hi,


I just seen that I made some errors... I have copied the naming from the HTTPD 
file, as is...

I added here a fix on that.. not complete but a reasonable reference, I hope


u16_t SSIHandler(char *tag, u16_t tag_insert, u16_t  current_tag_part,  u16_t 
*tag_part)
{
  u16_t RespLen = 0;


  if(current_tag_part == 0)
  {
// add some code here...

*tag_part = (current_tag_part + 1);
  }
  else if(current_tag_part == 1)
  {
// add some code here...

*tag_part = (current_tag_part + 1);
  }
  else if(current_tag_part == 2)
  {
// add some code here...

// last part we do not touch tag_part !
  }

  return RespLen;
}



Hope that helped :-)


BR,

Noam.




From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Noam Weissman <n...@silrd.com>
Sent: Friday, November 24, 2017 4:57 PM
To: lwip-users@nongnu.org; R. Diez
Subject: Re: [lwip-users] LWIP_HTTPD_SSI_MULTIPART and concurrent HTTP requests


Hi,


For every connection the HTTP server allocates a session data structure ( 
http_state ).


This data structure is passed to the call back functions as arg. You need to 
use it to

differentiate between session.


See inside httpd_accept:


/* Allocate memory for the structure that holds the state of the
 connection - initialized by that function. */
  hs = http_state_alloc();
  if (hs == NULL) {
LWIP_DEBUGF(HTTPD_DEBUG, ("http_accept: Out of memory, RST\n"));
return ERR_MEM;
  }
  hs->pcb = pcb;

  /* Tell TCP that this is the structure we wish to be passed for our
 callbacks. */
  tcp_arg(pcb, hs);




The above hs is your session structure that passes to the call backs.


Now in function http_init_file:


static err_t
http_init_file(struct http_state *hs, struct fs_file *file, int is_09, const 
char *uri,
   u8_t tag_check, char* params)
{
  if (file != NULL) {
/* file opened, initialise struct http_state */
#if LWIP_HTTPD_SSI
if (tag_check) {
  struct http_ssi_state *ssi = http_ssi_state_alloc();
  if (ssi != NULL) {
ssi->tag_index = 0;
ssi->tag_state = TAG_NONE;
ssi->parsed = file->data;
ssi->parse_left = file->len;
ssi->tag_end = file->data;
hs->ssi = ssi;
  }





In function http_init_file you see an allocation to struct http_ssi_state ssi !!


This ssi is assigned to your connection hs->ssi ... inside the ssi you have the

ssi->tag_part


every time the web server call's your SSI call back it assigns the tag_part to 
HTTPD_LAST_TAG_PART


If you do not change the tag_part the web server assumes that this is the last 
part of your SSI

and will not call your function any more. If you change the tag_part it will 
call your function again

current_tag_part value is either 0 when it first calls your SSI function or it 
will be what ever value

you assign to tag_part but not HTTPD_LAST_TAG_PART.


Example code:

Lets assume your SSI function looks like this:


u16_t SSIHandler(tag, ssi->tag_insert, current_tag_part, *ssi->tag_part)
{
  u16_t RespLen = 0;


  if(current_tag_part == 0)
  {
// add some code here...

*ssi->tag_part = (current_tag_part + 1);
  }
  else if(current_tag_part == 1)
  {
// add some code here...

*ssi->tag_part = (current_tag_part + 1);
  }
  else if(current_tag_part == 2)
  {
// add some code here...

// last part we do not touch tag_part !
  }

  return RespLen;
}



Hope that helped :-)


BR,

Noam.


From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of R. 
Diez <rdiezmail-l...@yahoo.de>
Sent: Friday, November 24, 2017 12:40 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] LWIP_HTTPD_SSI_MULTIPART and concurrent HTTP requests

Hi all:

I am using the httpd server that comes with lwIP version 2.0.2 on a small 
embedded device.

As I am generating dynamic HTML content that can reach 1 or 2 KiB per CGI SSI 
tag, I enabled LWIP_HTTPD_SSI_MULTIPART, so that I can send the tag contents in 
chunks. Whenever I get an SSI tag callback, I fill a small buffer with the 
generated contents for that tag, and I give the data back piece by piece on the 
next callbacks. That is all working fine.

However, I have recently realised that the httpd server can accept and serve 
multiple connections at the same time. I was not aware of this as the SSI 
callbacks do not seem to pass any context pointers. I noticed this because some 
asserts are triggering in my SSI handling logic. For example, say the same web 
page is requested simultaneously from 2 different browsers. Then my SSI 
multipart callbacks do not know which page is meant on the current callback. 
The SSI tag contents can be different per

Re: [lwip-users] LWIP_HTTPD_SSI_MULTIPART and concurrent HTTP requests

2017-11-24 Thread Noam Weissman
Hi,


For every connection the HTTP server allocates a session data structure ( 
http_state ).


This data structure is passed to the call back functions as arg. You need to 
use it to

differentiate between session.


See inside httpd_accept:


/* Allocate memory for the structure that holds the state of the
 connection - initialized by that function. */
  hs = http_state_alloc();
  if (hs == NULL) {
LWIP_DEBUGF(HTTPD_DEBUG, ("http_accept: Out of memory, RST\n"));
return ERR_MEM;
  }
  hs->pcb = pcb;

  /* Tell TCP that this is the structure we wish to be passed for our
 callbacks. */
  tcp_arg(pcb, hs);




The above hs is your session structure that passes to the call backs.


Now in function http_init_file:


static err_t
http_init_file(struct http_state *hs, struct fs_file *file, int is_09, const 
char *uri,
   u8_t tag_check, char* params)
{
  if (file != NULL) {
/* file opened, initialise struct http_state */
#if LWIP_HTTPD_SSI
if (tag_check) {
  struct http_ssi_state *ssi = http_ssi_state_alloc();
  if (ssi != NULL) {
ssi->tag_index = 0;
ssi->tag_state = TAG_NONE;
ssi->parsed = file->data;
ssi->parse_left = file->len;
ssi->tag_end = file->data;
hs->ssi = ssi;
  }





In function http_init_file you see an allocation to struct http_ssi_state ssi !!


This ssi is assigned to your connection hs->ssi ... inside the ssi you have the

ssi->tag_part


every time the web server call's your SSI call back it assigns the tag_part to 
HTTPD_LAST_TAG_PART


If you do not change the tag_part the web server assumes that this is the last 
part of your SSI

and will not call your function any more. If you change the tag_part it will 
call your function again

current_tag_part value is either 0 when it first calls your SSI function or it 
will be what ever value

you assign to tag_part but not HTTPD_LAST_TAG_PART.


Example code:

Lets assume your SSI function looks like this:


u16_t SSIHandler(tag, ssi->tag_insert, current_tag_part, *ssi->tag_part)
{
  u16_t RespLen = 0;


  if(current_tag_part == 0)
  {
// add some code here...

*ssi->tag_part = (current_tag_part + 1);
  }
  else if(current_tag_part == 1)
  {
// add some code here...

*ssi->tag_part = (current_tag_part + 1);
  }
  else if(current_tag_part == 2)
  {
// add some code here...

// last part we do not touch tag_part !
  }

  return RespLen;
}



Hope that helped :-)


BR,

Noam.


From: lwip-users  on behalf of R. 
Diez 
Sent: Friday, November 24, 2017 12:40 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] LWIP_HTTPD_SSI_MULTIPART and concurrent HTTP requests

Hi all:

I am using the httpd server that comes with lwIP version 2.0.2 on a small 
embedded device.

As I am generating dynamic HTML content that can reach 1 or 2 KiB per CGI SSI 
tag, I enabled LWIP_HTTPD_SSI_MULTIPART, so that I can send the tag contents in 
chunks. Whenever I get an SSI tag callback, I fill a small buffer with the 
generated contents for that tag, and I give the data back piece by piece on the 
next callbacks. That is all working fine.

However, I have recently realised that the httpd server can accept and serve 
multiple connections at the same time. I was not aware of this as the SSI 
callbacks do not seem to pass any context pointers. I noticed this because some 
asserts are triggering in my SSI handling logic. For example, say the same web 
page is requested simultaneously from 2 different browsers. Then my SSI 
multipart callbacks do not know which page is meant on the current callback. 
The SSI tag contents can be different per page, think for example about some 
text that has the current clock time embedded.

Is there any way to make lwIP's httpd server provide some "request context" 
when processing an SSI tag? Would I know when the context has been destroyed, 
in order to release the associated SSI multipart buffer?

Or is it possible to make the httpd server accept just 1 connection at a time?

Thanks in advance,
  rdiez

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

Re: [lwip-users] httpd: how to implement AJAX

2017-11-14 Thread Noam Weissman
Hi,

HTTPD is widely used and if you look around you can find examples from ST micro 
TI and other vendors.

The examples that you will find are probably older versions with no POST or 
AJAX  support but they work !

Noam.
 
-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Giuseppe Modugno
Sent: Tuesday, November 14, 2017 2:47 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] httpd: how to implement AJAX

Il 13/11/2017 21:25, goldsi...@gmx.de ha scritto:
> Giuseppe Modugno wrote:
>> The prototype for SSI callbacks is:
>> [..]
>> I don't see any reference to query string parameters. So how to 
>> select the right action?
>
> Sorry for the confusion. This is a mix of resource optimization, 
> missing documentation and maybe missing framework functions.
Thank you very much for your explanation. Now it is clear.

> My plan is to have https examples for the next release...
https would be very interesting (actually a simple non-secure http server isn't 
really useable in public Internet).

If I understood correctly, https means ssl/tls. So the first task is to add 
SSL/TLS to lwip, right? It's a pity lwip doesn't feature those secure network 
layers.

___
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] httpd: how to implement AJAX

2017-11-14 Thread Noam Weissman
Hi,

Yes I use a different server. My server code was based on a variation of the 
httpd code +
many additions.

I use POST to send the user+password and no it is not encoded... this is mainly 
for simple use.

The SSID is not a cookie... The SSID's are handles in a separate task that does 
the house keeping.

Regarding the single file trick you may be right but this is how it works for 
me and I OK with it :)

Regarding the GET/POST params... as the server parses the URL it also parses 
the GET params.


BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Giuseppe Modugno
Sent: Tuesday, November 14, 2017 2:42 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] httpd: how to implement AJAX

Il 13/11/2017 18:04, Noam Weissman ha scritto:

Yes SSID is a session ID that had been added to my own server code.
So are you using a completely different HTTP server from the httpd that is in 
apps folder of lwip main source?


When a user askes for a page and there is no ssid the server will redirect 
(send a 303)
And load a login page instead. After the user writes user+password the data is 
sent to
The server.
How do you send user+password to the server? PUT? Do you encode these sensible 
values?


The server call's external code to check for validity of user+pass... if OK it
Request a new ssid from a separate task.

After that the web server sends the previously request page + ssid... every 
operation
at the browser side must add that ssid value.
Is it a cookie, right?


Every time the web server gets a request
with the correct ssid it clears the related timeout. If the ssid timeouts and 
the user asks
for some data it will again redirect to the login page.
Do you call a specific function from main at regular intervals to clear all 
SSID that expire?


Regarding AJAX:

How do you handle SSI ?... I am doing it differently ? I have something like 
this in my code:

const SSI_t SSI_Table[] =
{
  {"mem_rout", mem_routing},
  {"IOSel", IO_Selection},
   {"get_users", get_users},
   {"ajax_reply", AjaxReply},

   {NULL, NULL} // last tag must always be NULL to close the list
};


mem_routing, IO_Selection,  get_users,  and   AjaxReply  are call-back function 
that are called by the web
server as a result of encountering the proper tag... for mem_routing it is   

I think LWIP_HTTPD_CUSTOM_FILES is simpler to use when you have a file that is 
completely dynamic. Your "single tag trick" works, but IMHO is too complex for 
what you have to do.



my AjaxReply parses the GET params and after that does something like that:
How AjaxReply() function could access GET params if they aren't accessible from 
the SSI handler? Most probably the answer is in the file state 
(LWIP_HTTPD_FILE_STATE) that is filled by httpd_cgi_handler() callback (as 
explained by goldsimon).



// get action param
Char *Action = some_function();


If(strcmp(Action, "do_something_1") == 0)
{

}
elses If(strcmp(Action, "do_something_2") == 0)
{

}


else
{
  // print a debug error :  action unknown
}



Hope that helped,
Noam.






From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Giuseppe Modugno
Sent: Monday, November 13, 2017 6:09 PM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: Re: [lwip-users] httpd: how to implement AJAX

Il 13/11/2017 14:34, Noam Weissman ha scritto:



Hi,



I am using the following technic for AJAX.



Create an empty file named ajax.shtml or ajax.html and add it to your file list.



Inside the file you only write one tag without anything else. For example 




Do not add  CR or LF just the tag !!.



Now when you issue an AJAX call the WEB server opens the file, reads it and 
send its data.

Because the file has only the tag it will parse it, call your handler for that 
tag and send back

To the browser just your data !!
Ok, so you use SSI to create dynamic data. I tried with custom files, because 
*all the content* is dynamic (and not only some parts, defined by specific 
tags).




If you use Juery it will look something like this... actually a function used 
as an event handler in

my own code:



function resetIO()

  {

//Remove the dialog

returnToPage();



$.ajax({

  url: "ajax.shtml",

  dataType : "text",

  type : "GET",

  cache : false,

  data : ({

ssid: ssid,

a: 'opReset',

type: 2

  }),

  error : function()

  {

showMessage("Network Error: Sorry, there was a problem connecting 
to the server.");

  },

  success : function(result)

  {

window.location.href = document.location;

  }

});

  }



In the above data you have the a:  variable,  this is your AJAX action !.
If I understood well, data i

Re: [lwip-users] httpd: how to implement AJAX

2017-11-13 Thread Noam Weissman
Hi,

Yes SSID is a session ID that had been added to my own server code.

When a user askes for a page and there is no ssid the server will redirect 
(send a 303)
And load a login page instead. After the user writes user+password the data is 
sent to
The server. The server call's external code to check for validity of 
user+pass... if OK it
Request a new ssid from a separate task.

After that the web server sends the previously request page + ssid... every 
operation
at the browser side must add that ssid value. Every time the web server gets a 
request
with the correct ssid it clears the related timeout. If the ssid timeouts and 
the user asks
for some data it will again redirect to the login page.


Regarding AJAX:

How do you handle SSI ?... I am doing it differently ? I have something like 
this in my code:

const SSI_t SSI_Table[] =
{
  {"mem_rout", mem_routing},
  {"IOSel", IO_Selection},
   {"get_users", get_users},
   {"ajax_reply", AjaxReply},

   {NULL, NULL} // last tag must always be NULL to close the list
};


mem_routing, IO_Selection,  get_users,  and   AjaxReply  are call-back function 
that are called by the web
server as a result of encountering the proper tag... for mem_routing it is   



my AjaxReply parses the GET params and after that does something like that:

// get action param
Char *Action = some_function();


If(strcmp(Action, "do_something_1") == 0)
{

}
elses If(strcmp(Action, "do_something_2") == 0)
{

}


else
{
  // print a debug error :  action unknown
}



Hope that helped,
Noam.






From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Giuseppe Modugno
Sent: Monday, November 13, 2017 6:09 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] httpd: how to implement AJAX

Il 13/11/2017 14:34, Noam Weissman ha scritto:


Hi,



I am using the following technic for AJAX.



Create an empty file named ajax.shtml or ajax.html and add it to your file list.



Inside the file you only write one tag without anything else. For example 




Do not add  CR or LF just the tag !!.



Now when you issue an AJAX call the WEB server opens the file, reads it and 
send its data.

Because the file has only the tag it will parse it, call your handler for that 
tag and send back

To the browser just your data !!
Ok, so you use SSI to create dynamic data. I tried with custom files, because 
*all the content* is dynamic (and not only some parts, defined by specific 
tags).



If you use Juery it will look something like this... actually a function used 
as an event handler in

my own code:



function resetIO()

  {

//Remove the dialog

returnToPage();



$.ajax({

  url: "ajax.shtml",

  dataType : "text",

  type : "GET",

  cache : false,

  data : ({

ssid: ssid,

a: 'opReset',

type: 2

  }),

  error : function()

  {

showMessage("Network Error: Sorry, there was a problem connecting 
to the server.");

  },

  success : function(result)

  {

window.location.href = document.location;

  }

});

  }



In the above data you have the a:  variable,  this is your AJAX action !.
If I understood well, data is translated in query string, in your example:

GET ajax.shtml?ssid==opReset=2

Of course,  is the value of ssid Javascript variable.



In your own SSI/CGI code you have a table with tags + callbacks... one of the 
callback function

Is your AJAX handler. Inside it you create an if <> else layout and handle the 
different actions.
The prototype for SSI callbacks is:
typedef u16_t (*tSSIHandler)(
#if LWIP_HTTPD_SSI_RAW
 const char* ssi_tag_name,
#else /* LWIP_HTTPD_SSI_RAW */
 int iIndex,
#endif /* LWIP_HTTPD_SSI_RAW */
 char *pcInsert, int iInsertLen
#if LWIP_HTTPD_SSI_MULTIPART
 , u16_t current_tag_part, u16_t *next_tag_part
#endif /* LWIP_HTTPD_SSI_MULTIPART */
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
 , void *connection_state
#endif /* LWIP_HTTPD_FILE_STATE */
 );
I don't see any reference to query string parameters. So how to select the 
right action?



The HTTP server will read your ajax.shtml file and because it has nothing BUT 
your tag it will

only send back the dynamic data you process in your ajax handling function.
As said before, it works if the dynamic content depends only from the name of 
the file (ajax.shtml in your example) and not from the action in the query 
string (a=opReset).

Where is my error?

Another question. I saw ssid in your javascript example. Is it related to a 
"session identifier"? If so, did you implement a sessi

Re: [lwip-users] httpd: how to implement AJAX

2017-11-13 Thread Noam Weissman
Hi,

I am using the following technic for AJAX.

Create an empty file named ajax.shtml or ajax.html and add it to your file list.

Inside the file you only write one tag without anything else. For example 


Do not add  CR or LF just the tag !!.

Now when you issue an AJAX call the WEB server opens the file, reads it and 
send its data.
Because the file has only the tag it will parse it, call your handler for that 
tag and send back 
To the browser just your data !!

If you use Juery it will look something like this... actually a function used 
as an event handler in 
my own code:

function resetIO()
  {
//Remove the dialog
returnToPage();

$.ajax({
  url: "ajax.shtml",
  dataType : "text",
  type : "GET",
  cache : false,
  data : ({
ssid: ssid,
a: 'opReset',
type: 2
  }),
  error : function()
  {
showMessage("Network Error: Sorry, there was a problem connecting 
to the server.");
  },
  success : function(result) 
  {
window.location.href = document.location;
  }
});
  }

In the above data you have the a:  variable,  this is your AJAX action !. 

In your own SSI/CGI code you have a table with tags + callbacks... one of the 
callback function
Is your AJAX handler. Inside it you create an if <> else layout and handle the 
different actions.

The HTTP server will read your ajax.shtml file and because it has nothing BUT 
your tag it will 
only send back the dynamic data you process in your ajax handling function.


Hope that helped,
Noam.



-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Giuseppe Modugno
Sent: Monday, November 13, 2017 12:43 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] httpd: how to implement AJAX

I'm trying to create a website with AJAX technology: the client polls, at 
regular intervals, the server with GET requests of file /status.json. 
The response is dynamic.

I could use only LWIP_HTTPD_CUSTOM_FILES and create the file at runtime in 
fs_open_custom(). It works, but I can't decode the query string, because it 
isn't passed to fs_open_custom() callback.

So I thought to use LWIP_HTTPD_CGI_SSI instead of LWIP_HTTPD_CUSTOM_FILES, but 
I have some difficulties to understand how it works.
First of all, the file /status.json must be present in the filesystem
(fs_open() must return ERR_OK), otherwise httpd_cgi_handler() isn't called at 
all.
However I can't return any data in httpd_cgi_handler().

Any help?


___
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] httpd server app lwip 2.0.2 cgi

2017-11-10 Thread Noam Weissman
Hi,


I am working with my own HTTP server that is different from the one in the 
contribution

but uses a very similar mechanism.


It took me some time to find it but you need to check:

   \src\include\lwip\apps  httpd.h


In the above file your will find more information.


For every connection the server has a buffer with limited size 
(LWIP_HTTPD_MAX_REQ_LENGTH).

You can add data to this buffer but MUST consider the size limit. If the data 
that you need to add is

larger then the send buffer you need to send it in parts !.


Check define HTTPD_LAST_TAG_PART


Your call back function prototype looks like this (taken from httpd.h):


typedef u16_t (*tSSIHandler)(
#if LWIP_HTTPD_SSI_RAW
 const char* ssi_tag_name,
#else /* LWIP_HTTPD_SSI_RAW */
 int iIndex,
#endif /* LWIP_HTTPD_SSI_RAW */
 char *pcInsert, int iInsertLen
#if LWIP_HTTPD_SSI_MULTIPART
 , u16_t current_tag_part, u16_t *next_tag_part
#endif /* LWIP_HTTPD_SSI_MULTIPART */
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
 , void *connection_state
#endif /* LWIP_HTTPD_FILE_STATE */
 );



Inside your call back function you need to create something like this:


u16_t TestSSI(char *pcInsert, int iInsertLen, u16_t current_tag_part, u16_t 
*next_tag_part)

{

u16_t RespLen;


if(current_tag_part == 0) // first part

{

  RespLen = snprintf(pcInsert, iInsertLen, "this is some dynamic data");


  // this will notify the serevr to send your data and call your call back 
again.

  *next_tag_part = (current_tag_part + 1);

}

else if(current_tag_part == 1) // second and last part

{

  RespLen = snprintf(pcInsert, iInsertLen, "this is some more dynamic data");

}


return RespLen;

}





When you do not change *next_tag_part the HTTP server and leave it as is the 
server

knows that this is your last part and never calls your function anymore.


The above is just a minimal example.


You can add HTML code or JavaScript in these call backs.


I am using JS so I am adding variables and after page loads I use this 
variables to update

the page.


I hope that helped :-)



BR,

Noam.


From: lwip-users  on behalf of 
billium 
Sent: Friday, November 10, 2017 5:50 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] httpd server app lwip 2.0.2 cgi

On 10/11/17 13:05, Markus Pischinger wrote:
Hi guys,
I've been trying out the new httpd server app that comes with lwip 2.0.2.
It works great so far for static websites but i'm looking into CGI to make GET 
requests.
Has anyone maybe got an example on how to do this? And what should I use? There 
is a "old style" with LWIP_HTTPD_CGI and "new style" with LWIP_HTTPD_CGI_SSI.
I tried the CGI_SSI, which works so far - i wrote a httpd_cgi_handler and it 
gets called on GET requests. But i don't really get how i should return any 
kind of data here?

That's the only comment in the header file to the cgi_handler:
/** Define this generic CGI handler in your application.
 * It is called once for every URI with parameters.
 * The parameters can be stored to
 */
Thanks in advance for any help!



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

The esp-open-rtos on github examples section has one, also does web sockets, I 
got it working on a TIVA TM4C1294 ok.

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

Re: [lwip-users] Lwip tcp-stack reliability issue when using non-reliable network?

2017-11-07 Thread Noam Weissman
Hi,

So maybe enlarge MEMP_NUM_PBUF   100-150 your have the memory for it ☺

Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Itzik Levi
Sent: Tuesday, November 07, 2017 6:15 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Hi Noam,

Thanks.

Just increased both MEMP_NUM_PBUF to 50, MEM_NUM_TCP_PCB TO 15.
I'm not sure if its harder to reproduce(longer time to run) - maybe. but it 
still happens..




On Tue, Nov 7, 2017 at 5:36 PM, Noam Weissman 
<n...@silrd.com<mailto:n...@silrd.com>> wrote:
Hi,

Check that you have MEMP_NUM_PBUF 50 or more
that MEMP_NUM_TCP_PCB is 15 or more

The above may help, I think.

Noam.

From: lwip-users 
[mailto:lwip-users-bounces+noam<mailto:lwip-users-bounces%2Bnoam>=silrd@nongnu.org<mailto:silrd@nongnu.org>]
 On Behalf Of Itzik Levi
Sent: Tuesday, November 07, 2017 5:29 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Unfortunately, enabling Nagle did not do the trick, still got the same result. 
:(

On Tue, Nov 7, 2017 at 4:20 PM, Itzik Levi 
<levimad...@gmail.com<mailto:levimad...@gmail.com>> wrote:
Thanks for the reply!

Actually, the end goal is to integrate the solution into rfcomm.

For now, the "physical layer" is being simulated by a single local host tcp 
connection(under Android OS).
The losses are simulated by simply randomly dropping data in lwip's pppos 
"output_cb".

I'll attempt to re-enable Nagle, see if there is any changes and report back.



On Tue, Nov 7, 2017 at 4:09 PM, Gisle Vanem 
<gisle.va...@gmail.com<mailto:gisle.va...@gmail.com>> wrote:
Itzik Levi wrote:
I'll go over your lwipopts and see whether I missed something.
In addition, I will attempt to useSO_SNDTIMEO and SO_RCVTIMEO instead of 
polling in parallel to write and read(I understand by the samples its a more 
health way of using this api).

If you have anymore suggestions, that will be great!

I think you wrote earlier than you had disabled
"Nagle algorithm". Are you sure that's a good idea?
Maybe you're saturating your RF-link with small fragments.

Just a thought since it's almost never a good idea to
turn off Nagle.

--
--gv


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



___
lwip-users mailing list
lwip-users@nongnu.org<mailto: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 tcp-stack reliability issue when using non-reliable network?

2017-11-07 Thread Noam Weissman
Hi,

Check that you have MEMP_NUM_PBUF 50 or more
that MEMP_NUM_TCP_PCB is 15 or more

The above may help, I think.

Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Itzik Levi
Sent: Tuesday, November 07, 2017 5:29 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Unfortunately, enabling Nagle did not do the trick, still got the same result. 
:(

On Tue, Nov 7, 2017 at 4:20 PM, Itzik Levi 
> wrote:
Thanks for the reply!

Actually, the end goal is to integrate the solution into rfcomm.

For now, the "physical layer" is being simulated by a single local host tcp 
connection(under Android OS).
The losses are simulated by simply randomly dropping data in lwip's pppos 
"output_cb".

I'll attempt to re-enable Nagle, see if there is any changes and report back.



On Tue, Nov 7, 2017 at 4:09 PM, Gisle Vanem 
> wrote:
Itzik Levi wrote:
I'll go over your lwipopts and see whether I missed something.
In addition, I will attempt to useSO_SNDTIMEO and SO_RCVTIMEO instead of 
polling in parallel to write and read(I understand by the samples its a more 
health way of using this api).

If you have anymore suggestions, that will be great!

I think you wrote earlier than you had disabled
"Nagle algorithm". Are you sure that's a good idea?
Maybe you're saturating your RF-link with small fragments.

Just a thought since it's almost never a good idea to
turn off Nagle.

--
--gv


___
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 tcp-stack reliability issue when using non-reliable network?

2017-11-07 Thread Noam Weissman
Hi Itzik,

I have never worked with Android so I cannot help in that area.

My options are defined for a small micro with limited resources so I hope I am 
not confusing you.

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Itzik Levi
Sent: Tuesday, November 07, 2017 11:17 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Hi Noam,

For the purpose of evaluation, I'm using Android OS, with lwip-port provided by 
contrib repo.

I'll go over your lwipopts and see whether I missed something.
In addition, I will attempt to use SO_SNDTIMEO and SO_RCVTIMEO instead of 
polling in parallel to write and read(I understand by the samples its a more 
health way of using this api).

If you have anymore suggestions, that will be great!

Thanks,
Itzik




On Tue, Nov 7, 2017 at 9:39 AM, Noam Weissman 
<n...@silrd.com<mailto:n...@silrd.com>> wrote:
Hi Itzik,

Ops I missed that ☺

I am attaching my own lwpopts.h

I am using FreeRTOS as OS on STMF32xx micro’s.

I am running several modules (SDDP, TCP terminal, HTTP, SSH etc… ) with the 
above settings
on the same platform.

What micro are you using and what OS ?


BR,
Noam.


From: lwip-users 
[mailto:lwip-users-bounces+noam<mailto:lwip-users-bounces%2Bnoam>=silrd@nongnu.org<mailto:silrd@nongnu.org>]
 On Behalf Of Itzik Levi
Sent: Tuesday, November 07, 2017 12:52 AM

To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Thanks Noam!

But I am running an OS.

NO_SYS is defined to 0 as you can see, and I AM using threads.

I will try reducing the memory usage and look at socket examples, maybe this 
will help.



On Nov 7, 2017 12:44 AM, "Noam Weissman" 
<n...@silrd.com<mailto:n...@silrd.com>> wrote:

Hi Itzik,



From participating the group here I have heard many complaining that the driver 
level

is the cause to problems like you are facing.



From my own experience I have noticed problems when using the RAW API. The RAW

API is NOT thread safe (I am using an OS) and therefore one needs to follow the 
guidelines

and understand how to use it.



LwIP is small and light weight. I have used it with ARM9 that had only 96K RAM. 
Actually TCP

stack was assigned less then 10K... 

If you have 50Mb why not run an OS and run it with threads etc...



I suggest looking for a nice example with Sockets + lwipopt.h and continue from 
there.



If you are using it to stream an unreliable connection you should probably add 
some protocol

to overcome this instability.



I do not see the reasoning for defining 8M for MEM_SIZE ?



You do not need so much. 100K is more then sufficient for your testing, I think.

You do not more PCB's... PCB is your control block... every block you send or 
receive is using one.

I am defining 80 TCP PCB's with 25K RAM for MEM_SIZE and I do not have so much 
RAM.



Check some examples and see if you can find more ideas...



Hope that helped,

Noam.





From: lwip-users 
<lwip-users-bounces+noam=silrd@nongnu.org<mailto:silrd@nongnu.org>> on 
behalf of Itzik Levi <levimad...@gmail.com<mailto:levimad...@gmail.com>>
Sent: Monday, November 6, 2017 11:45 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Hi Noam,

Thanks for the prompt response!

The actual link isn't serial. its a non-reliable rfcomm link, which is a stream 
based protocol.
Regarding ram available ram - up to 50MB I would say.

I'm attaching my entire lwipopts.h here.
https://pastebin.com/24AR5sYB
[https://pastebin.com/i/facebook.png]<https://pastebin.com/24AR5sYB>

lwipopts.h - Pastebin.com<https://pastebin.com/24AR5sYB>
pastebin.com<http://pastebin.com>



Regarding the socket API - I did not actually put lots of thought to it, it was 
trivial to implement and that's that. do you have a reason to believe the root 
cause is there? Although the only change between the 2 tests I ran was randomly 
dropping data in the physical layer output?
If you think that might be it, I can rewrite the socket layer and attempt to 
test again.


And regarding misusing the stack - I totally agree, I probably did misused it 
somehow, I'm new to lwip and that's why I'm here.
Question is, what did I do wrong, and how to pinpoint the problem.

Thanks,
Itzik.





On Mon, Nov 6, 2017 at 11:19 PM, Noam Weissman 
<n...@silrd.com<mailto:n...@silrd.com>> wrote:

Hi Itzik,



I see that you have defined:
TCP_WND=(100 * TCP_MSS)
TCP_SND_BUF=TCP_WND
MEMP_NUM_TCP_SEG=TCP_SND_QUEUELEN


If TCP_MSS is defined 536 (default) that means that your TCP_WND is 53,600 
bytes ?

and that is over a serial line ?



How much RAM do you have?, How much RAM is defined for TCP memory?



I never worked w

Re: [lwip-users] Lwip tcp-stack reliability issue when using non-reliable network?

2017-11-06 Thread Noam Weissman
Hi Itzik,

Ops I missed that ☺

I am attaching my own lwpopts.h

I am using FreeRTOS as OS on STMF32xx micro’s.

I am running several modules (SDDP, TCP terminal, HTTP, SSH etc… ) with the 
above settings
on the same platform.

What micro are you using and what OS ?


BR,
Noam.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Itzik Levi
Sent: Tuesday, November 07, 2017 12:52 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Thanks Noam!

But I am running an OS.

NO_SYS is defined to 0 as you can see, and I AM using threads.

I will try reducing the memory usage and look at socket examples, maybe this 
will help.



On Nov 7, 2017 12:44 AM, "Noam Weissman" 
<n...@silrd.com<mailto:n...@silrd.com>> wrote:

Hi Itzik,



From participating the group here I have heard many complaining that the driver 
level

is the cause to problems like you are facing.



From my own experience I have noticed problems when using the RAW API. The RAW

API is NOT thread safe (I am using an OS) and therefore one needs to follow the 
guidelines

and understand how to use it.



LwIP is small and light weight. I have used it with ARM9 that had only 96K RAM. 
Actually TCP

stack was assigned less then 10K... 

If you have 50Mb why not run an OS and run it with threads etc...



I suggest looking for a nice example with Sockets + lwipopt.h and continue from 
there.



If you are using it to stream an unreliable connection you should probably add 
some protocol

to overcome this instability.



I do not see the reasoning for defining 8M for MEM_SIZE ?



You do not need so much. 100K is more then sufficient for your testing, I think.

You do not more PCB's... PCB is your control block... every block you send or 
receive is using one.

I am defining 80 TCP PCB's with 25K RAM for MEM_SIZE and I do not have so much 
RAM.



Check some examples and see if you can find more ideas...



Hope that helped,

Noam.





From: lwip-users 
<lwip-users-bounces+noam=silrd@nongnu.org<mailto:silrd@nongnu.org>> on 
behalf of Itzik Levi <levimad...@gmail.com<mailto:levimad...@gmail.com>>
Sent: Monday, November 6, 2017 11:45 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Hi Noam,

Thanks for the prompt response!

The actual link isn't serial. its a non-reliable rfcomm link, which is a stream 
based protocol.
Regarding ram available ram - up to 50MB I would say.

I'm attaching my entire lwipopts.h here.
https://pastebin.com/24AR5sYB
[https://pastebin.com/i/facebook.png]<https://pastebin.com/24AR5sYB>

lwipopts.h - Pastebin.com<https://pastebin.com/24AR5sYB>
pastebin.com<http://pastebin.com>



Regarding the socket API - I did not actually put lots of thought to it, it was 
trivial to implement and that's that. do you have a reason to believe the root 
cause is there? Although the only change between the 2 tests I ran was randomly 
dropping data in the physical layer output?
If you think that might be it, I can rewrite the socket layer and attempt to 
test again.


And regarding misusing the stack - I totally agree, I probably did misused it 
somehow, I'm new to lwip and that's why I'm here.
Question is, what did I do wrong, and how to pinpoint the problem.

Thanks,
Itzik.





On Mon, Nov 6, 2017 at 11:19 PM, Noam Weissman 
<n...@silrd.com<mailto:n...@silrd.com>> wrote:

Hi Itzik,



I see that you have defined:
TCP_WND=(100 * TCP_MSS)
TCP_SND_BUF=TCP_WND
MEMP_NUM_TCP_SEG=TCP_SND_QUEUELEN


If TCP_MSS is defined 536 (default) that means that your TCP_WND is 53,600 
bytes ?

and that is over a serial line ?



How much RAM do you have?, How much RAM is defined for TCP memory?



I never worked with PPP so I am a bit on the dark here.



From my experience with LwIP (over 6 years) Almost always it was misusing the 
stack or

doing something wrong.



You have written that you are using the Socket API. Normally Socket API is used 
with different

threads/task. If you do not use an OS why not use the RAW API ?



BR,

Noam.



From: lwip-users 
<lwip-users-bounces+noam=silrd@nongnu.org<mailto:silrd@nongnu.org>> on 
behalf of Itzik Levi <levimad...@gmail.com<mailto:levimad...@gmail.com>>
Sent: Monday, November 6, 2017 7:07 PM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: [lwip-users] Lwip tcp-stack reliability issue when using non-reliable 
network?

Hi All,

Firstly, a bit of background:
I'm currently evaluating lwip stack in order to determine whether it can fit my 
needs.

The end-goal, is integrating Socket API --> TCP/IP --> PPPoS stack on both 
sides over a serial-like-interface(stream-based)  which isn't reliable.

I decided to unittest it before a

Re: [lwip-users] Lwip tcp-stack reliability issue when using non-reliable network?

2017-11-06 Thread Noam Weissman
Hi Itzik,


From participating the group here I have heard many complaining that the driver 
level

is the cause to problems like you are facing.


From my own experience I have noticed problems when using the RAW API. The RAW

API is NOT thread safe (I am using an OS) and therefore one needs to follow the 
guidelines

and understand how to use it.


LwIP is small and light weight. I have used it with ARM9 that had only 96K RAM. 
Actually TCP

stack was assigned less then 10K... 

If you have 50Mb why not run an OS and run it with threads etc...


I suggest looking for a nice example with Sockets + lwipopt.h and continue from 
there.


If you are using it to stream an unreliable connection you should probably add 
some protocol

to overcome this instability.


I do not see the reasoning for defining 8M for MEM_SIZE ?


You do not need so much. 100K is more then sufficient for your testing, I think.

You do not more PCB's... PCB is your control block... every block you send or 
receive is using one.

I am defining 80 TCP PCB's with 25K RAM for MEM_SIZE and I do not have so much 
RAM.


Check some examples and see if you can find more ideas...


Hope that helped,

Noam.






From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Itzik Levi <levimad...@gmail.com>
Sent: Monday, November 6, 2017 11:45 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Lwip tcp-stack reliability issue when using 
non-reliable network?

Hi Noam,

Thanks for the prompt response!

The actual link isn't serial. its a non-reliable rfcomm link, which is a stream 
based protocol.
Regarding ram available ram - up to 50MB I would say.

I'm attaching my entire lwipopts.h here.
https://pastebin.com/24AR5sYB
[https://pastebin.com/i/facebook.png]<https://pastebin.com/24AR5sYB>

lwipopts.h - Pastebin.com<https://pastebin.com/24AR5sYB>
pastebin.com



Regarding the socket API - I did not actually put lots of thought to it, it was 
trivial to implement and that's that. do you have a reason to believe the root 
cause is there? Although the only change between the 2 tests I ran was randomly 
dropping data in the physical layer output?
If you think that might be it, I can rewrite the socket layer and attempt to 
test again.


And regarding misusing the stack - I totally agree, I probably did misused it 
somehow, I'm new to lwip and that's why I'm here.
Question is, what did I do wrong, and how to pinpoint the problem.

Thanks,
Itzik.





On Mon, Nov 6, 2017 at 11:19 PM, Noam Weissman 
<n...@silrd.com<mailto:n...@silrd.com>> wrote:

Hi Itzik,


I see that you have defined:


TCP_WND=(100 * TCP_MSS)
TCP_SND_BUF=TCP_WND
MEMP_NUM_TCP_SEG=TCP_SND_QUEUELEN


If TCP_MSS is defined 536 (default) that means that your TCP_WND is 53,600 
bytes ?

and that is over a serial line ?


How much RAM do you have?, How much RAM is defined for TCP memory?


I never worked with PPP so I am a bit on the dark here.


From my experience with LwIP (over 6 years) Almost always it was misusing the 
stack or

doing something wrong.


You have written that you are using the Socket API. Normally Socket API is used 
with different

threads/task. If you do not use an OS why not use the RAW API ?


BR,

Noam.




From: lwip-users 
<lwip-users-bounces+noam=silrd@nongnu.org<mailto:silrd@nongnu.org>> on 
behalf of Itzik Levi <levimad...@gmail.com<mailto:levimad...@gmail.com>>
Sent: Monday, November 6, 2017 7:07 PM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: [lwip-users] Lwip tcp-stack reliability issue when using non-reliable 
network?

Hi All,

Firstly, a bit of background:
I'm currently evaluating lwip stack in order to determine whether it can fit my 
needs.

The end-goal, is integrating Socket API --> TCP/IP --> PPPoS stack on both 
sides over a serial-like-interface(stream-based)  which isn't reliable.

I decided to unittest it before actually integrating the stack.

Setup:
(This is done symmetrically on both "client" and "server")

  1.  Network Interface:
 *   The "physical layer" is currently a localhost connected tcp socket.
 *   Using pppapi in order to create the network interface.
 *   Its "output_cb" is the tcp connect socket(as mentioned before).
 *   Using "pppos_input_tcpip" which is fed by the same tcp socket.
  2.  Forming a TCP connection over the interface:
 *   Using lwip's bsd-like socket api.
 *   Single socket connection.
 *   Disabling Nagle.
 *   Working with a non-blocking sockets.
 *   Not writing and reading at the same time(mutex protected), but using 
lwip_poll in parallel to both.
  3.  Data validation:
 *   Transferring the same generated data client-->server and 
server-->client and validating at the same time.

Results:

  *   When not introducing 

Re: [lwip-users] Lwip tcp-stack reliability issue when using non-reliable network?

2017-11-06 Thread Noam Weissman
Hi Itzik,


I see that you have defined:


TCP_WND=(100 * TCP_MSS)
TCP_SND_BUF=TCP_WND
MEMP_NUM_TCP_SEG=TCP_SND_QUEUELEN


If TCP_MSS is defined 536 (default) that means that your TCP_WND is 53,600 
bytes ?

and that is over a serial line ?


How much RAM do you have?, How much RAM is defined for TCP memory?


I never worked with PPP so I am a bit on the dark here.


>From my experience with LwIP (over 6 years) Almost always it was misusing the 
>stack or

doing something wrong.


You have written that you are using the Socket API. Normally Socket API is used 
with different

threads/task. If you do not use an OS why not use the RAW API ?


BR,

Noam.




From: lwip-users  on behalf of 
Itzik Levi 
Sent: Monday, November 6, 2017 7:07 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] Lwip tcp-stack reliability issue when using non-reliable 
network?

Hi All,

Firstly, a bit of background:
I'm currently evaluating lwip stack in order to determine whether it can fit my 
needs.

The end-goal, is integrating Socket API --> TCP/IP --> PPPoS stack on both 
sides over a serial-like-interface(stream-based)  which isn't reliable.

I decided to unittest it before actually integrating the stack.

Setup:
(This is done symmetrically on both "client" and "server")

  1.  Network Interface:
 *   The "physical layer" is currently a localhost connected tcp socket.
 *   Using pppapi in order to create the network interface.
 *   Its "output_cb" is the tcp connect socket(as mentioned before).
 *   Using "pppos_input_tcpip" which is fed by the same tcp socket.
  2.  Forming a TCP connection over the interface:
 *   Using lwip's bsd-like socket api.
 *   Single socket connection.
 *   Disabling Nagle.
 *   Working with a non-blocking sockets.
 *   Not writing and reading at the same time(mutex protected), but using 
lwip_poll in parallel to both.
  3.  Data validation:
 *   Transferring the same generated data client-->server and 
server-->client and validating at the same time.

Results:

  *   When not introducing losses to the physical layer, the data is passed and 
validated successfully without any issues.
  *   When starting to randomly introduce losses to the physical 
layer(basically drop some data when output_cb is being called), it seems to go 
well for minutes, but eventually it appears that I'm loosing data when sending.

I'm sure I'm doing something wrong here, can you please help me figure this 
thing out?
Pointers to debug such a case is also welcome!

I'm attaching lwip's debug logs from both client and server, when losses are 
introduced to both physical layer ends.

In this specific case some data that was sent from the client --> server, and 
the server failed to validate the data.

The last received valid stream offset is 19008, the next 400 bytes were 
incorrect(future data), basically I got some skipped data.

lwip configuration:
SYS_LIGHTWEIGHT_PROT=1
NO_SYS =0
LWIP_TCPIP_CORE_LOCKING=1
LWIP_TCPIP_CORE_LOCKING_INPUT=1

TCP_WND=(100 * TCP_MSS)
TCP_SND_BUF=TCP_WND
MEMP_NUM_TCP_SEG=TCP_SND_QUEUELEN

I used lwip's repo commit: 5d8d21fcae63c36005baf1b15e91268836dec679.
(which is lwip 2.0.3 plus some..)


Please tell me if any more info is required.

Thanks,
Itzik



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

Re: [lwip-users] Problem with TCP write.

2017-10-23 Thread Noam Weissman
Gautam,

How much RAM do you have ??

You have defined 4K RAM for MEM_SIZE but all your other settings are not 
proportional (I think)

TCP_MSS is defined 1460 from 4K ?... please see default settings (set to 536)

Your mailbox size are high without RAM ?

Please check a working project and read memory settings documentation.

Change your code to have #define MEMP_NUM_TCP_SEGTCP_SND_QUEUELEN
>From previous problems It was different and caused me memory error's

Noam.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Gautam Kumar
Sent: Monday, October 23, 2017 11:58 AM
To: 'Mailing list for lwIP users'
Subject: Re: [lwip-users] Problem with TCP write.

Hi Noam,

Sorry I had attached the wrong file.

Please check this and help me out.

Thanks in Advance
Gautam

From: lwip-users 
[mailto:lwip-users-bounces+gautam.kumar=invendis@nongnu.org] On Behalf Of 
Noam Weissman
Sent: 23 October 2017 13:59
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Problem with TCP write.

Hi Gautam,

First of all you are not supposed to make changes in opt.h file...

For that you need to add lwipopts.h in your own code !

Have you started with an example or did you dive into it with seeing that a 
simple echo server is working ?

I suggest starting to read some documentations and continuing from there.

BR,
Noam.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Gautam Kumar
Sent: Monday, October 23, 2017 11:22 AM
To: 'Mailing list for lwIP users'
Subject: Re: [lwip-users] Problem with TCP write.

Hi Noam,

Please find the attached file.
Can you please help me out if you find anything not configured properly?

Regards,
Gautam


From: lwip-users 
[mailto:lwip-users-bounces+gautam.kumar=invendis@nongnu.org] On Behalf Of 
Noam Weissman
Sent: 23 October 2017 13:32
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Problem with TCP write.

Gautam,

Check err.h file !

/** Out of memory error. */
  ERR_MEM= -1,

You are doing something wrong in your code or did not properly defined your 
memory settings in lwipopts.h

If you show your code, it would help.


BR,
Noam.



From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Gautam Kumar
Sent: Monday, October 23, 2017 10:07 AM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: [lwip-users] Problem with TCP write.

Hi All,

I am using LWIP with ATSAME70. I am trying to send data over TCPIP, the port is 
getting opened successfully, but while send the data using TCP_Write(), it 
gives the error -1.

Please help me out in this regard.

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

Re: [lwip-users] Problem with TCP write.

2017-10-23 Thread Noam Weissman
Hi Gautam,

First of all you are not supposed to make changes in opt.h file...

For that you need to add lwipopts.h in your own code !

Have you started with an example or did you dive into it with seeing that a 
simple echo server is working ?

I suggest starting to read some documentations and continuing from there.

BR,
Noam.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Gautam Kumar
Sent: Monday, October 23, 2017 11:22 AM
To: 'Mailing list for lwIP users'
Subject: Re: [lwip-users] Problem with TCP write.

Hi Noam,

Please find the attached file.
Can you please help me out if you find anything not configured properly?

Regards,
Gautam


From: lwip-users 
[mailto:lwip-users-bounces+gautam.kumar=invendis@nongnu.org] On Behalf Of 
Noam Weissman
Sent: 23 October 2017 13:32
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Problem with TCP write.

Gautam,

Check err.h file !

/** Out of memory error. */
  ERR_MEM= -1,

You are doing something wrong in your code or did not properly defined your 
memory settings in lwipopts.h

If you show your code, it would help.


BR,
Noam.



From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Gautam Kumar
Sent: Monday, October 23, 2017 10:07 AM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: [lwip-users] Problem with TCP write.

Hi All,

I am using LWIP with ATSAME70. I am trying to send data over TCPIP, the port is 
getting opened successfully, but while send the data using TCP_Write(), it 
gives the error -1.

Please help me out in this regard.

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

Re: [lwip-users] Problem with TCP write.

2017-10-23 Thread Noam Weissman
Gautam,

Check err.h file !

/** Out of memory error. */
  ERR_MEM= -1,

You are doing something wrong in your code or did not properly defined your 
memory settings in lwipopts.h

If you show your code, it would help.


BR,
Noam.



From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Gautam Kumar
Sent: Monday, October 23, 2017 10:07 AM
To: lwip-users@nongnu.org
Subject: [lwip-users] Problem with TCP write.

Hi All,

I am using LWIP with ATSAME70. I am trying to send data over TCPIP, the port is 
getting opened successfully, but while send the data using TCP_Write(), it 
gives the error -1.

Please help me out in this regard.

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

Re: [lwip-users] ERR_MEM when sending large data, LWIP stats show no error

2017-09-15 Thread Noam Weissman
Hi Adrian,


I am using the STM32F765 and do not see real any problem. The driver and low 
level are

very similar to the F4.. There are some small changes in initializing code but 
there is a change

in descriptors location. For some reason they force it to be on a specific 
section. Maybe

a DMA limitation ?


I am out of my office now. If I will not forget I will post my drivers and low 
level first thing

next week.


Have a nice weekend,

Noam.


From: lwip-users  on behalf of 
Adrian Figueroa 
Sent: Friday, September 15, 2017 9:30 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] ERR_MEM when sending large data, LWIP stats show no 
error

That memcpy is also used on the F7. The drivers are probably the same:

/* Copy data to Tx buffer*/
memcpy( (uint8_t*)((uint8_t*)buffer + bufferoffset), 
(uint8_t*)((uint8_t*)q->payload + payloadoffset), (ETH_TX_BUF_SIZE - 
bufferoffset) );

Adrian


-Ursprüngliche Nachricht-
Von: lwip-users 
[mailto:lwip-users-bounces+adrian.figueroa=tu-dresden...@nongnu.org] Im Auftrag 
von goldsi...@gmx.de
Gesendet: Thursday, September 14, 2017 5:46 PM
An: Mailing list for lwIP users 
Betreff: Re: [lwip-users] ERR_MEM when sending large data, LWIP stats show no 
error

Adrian Figueroa wrote:
> I can see some errors in low_level_output() in ethernetif.c.
>
> This fails:
>
>if((DmaTxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET)
>{
>  errval = ERR_USE;
>  goto error;
>}

I don't know the F7 driver, but my F4 driver seems to have the same code lines.
It's worse there since they even memcpy from pbufs to the DMA descriptors... :-(

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
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory management fault in lwip_select.

2017-09-07 Thread Noam Weissman
Hi David,

Most of my code is RAW API so I have not seen any issues.

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of David Lockyer
Sent: Thursday, September 07, 2017 11:21 AM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory 
management fault in lwip_select.

Hi Noam,
Thanks for the files, they are not too dissimilar to what I have.

My sys_arch_protect / sys_arch_unprotect are slightly different:

sys_prot_t sys_arch_protect(void)
{
vPortEnterCritical();
return 1;
}

void sys_arch_unprotect(sys_prot_t pval)
{
( void ) pval;
vPortExitCritical();
}

I am using the GCC/ARM_CM4_MPU port:
void vPortEnterCritical( void )
{
BaseType_t xRunningPrivileged = xPortRaisePrivilege();

portDISABLE_INTERRUPTS();
uxCriticalNesting++;

vPortResetPrivilege( xRunningPrivileged );
}
/*---*/

void vPortExitCritical( void )
{
BaseType_t xRunningPrivileged = xPortRaisePrivilege();

configASSERT( uxCriticalNesting );
uxCriticalNesting--;
if( uxCriticalNesting == 0 )
{
portENABLE_INTERRUPTS();
}
vPortResetPrivilege( xRunningPrivileged );
}

But unless the PortEnterCritical() were to leave privilege raised I don't see 
how lwip_select() would not trigger the MPU?

I only see this being triggered when I have two separate threads handling 
different network traffic, i.e. TCP connection and UDP data transfer each 
handled by a separate thread.

BR,
David
On 07/09/17 07:25, Noam Weissman wrote:
Hi David,

Attached please find my own sys_arch files used in STM32F4xx with FreeRTOS.

Hope that helps in some way.

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of David Lockyer
Sent: Wednesday, September 06, 2017 5:13 PM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory 
management fault in lwip_select.


Hi,

I have a project that uses an STM32F MCU running FreeRTOS (cortex mpu port) & 
lwip, with the MPU enabled.

I'm upgrading to lwip 2.0.2 from lwip 1.4.1, that I had to customize to be 
compatible with the MPU, in particular in lwip_select().

The motivation was to use the LWIP_MPU_COMPATIBLE define, so a direct 
modification of the stack source was not required.  However for me it still 
appears to try to access another threads memory, triggering an exception.

The changes I had to make were:

Index: lib/lwip-2.0.2/src/api/sockets.c
===
--- lib/lwip-2.0.2/src/api/sockets.c(revision x)
+++ lib/lwip-2.0.2/src/api/sockets.c(working copy)
@@ -1428,7 +1428,9 @@
 /* Put this select_cb on top of list */
 select_cb.next = select_cb_list;
 if (select_cb_list != NULL) {
+  RAISE_PRIVILEGE();
   select_cb_list->prev = _cb;
+  RESET_PRIVILEGE();
 }
 select_cb_list = _cb;
 /* Increasing this counter tells event_callback that the list has changed. 
*/
@@ -1508,7 +1510,9 @@
 /* Take us off the list */
 SYS_ARCH_PROTECT(lev);
 if (select_cb.next != NULL) {
+  RAISE_PRIVILEGE();
   select_cb.next->prev = select_cb.prev;
+  RESET_PRIVILEGE();
 }
 if (select_cb_list == _cb) {
   LWIP_ASSERT("select_cb.prev == NULL", select_cb.prev == NULL);
@@ -1515,7 +1519,9 @@
   select_cb_list = select_cb.next;
 } else {
   LWIP_ASSERT("select_cb.prev != NULL", select_cb.prev != NULL);
+  RAISE_PRIVILEGE();
   select_cb.prev->next = select_cb.next;
+  RESET_PRIVILEGE();
 }
 /* Increasing this counter tells event_callback that the list has changed. 
*/
 select_cb_ctr++;

Is there something else I missed here that would remove the need for this 
modification?



Kind regards,

David Lockyer

__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
__

__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
__




___

lwip-users mailing list

lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>

https://lists.nongnu.org/mailman/listinfo/lwip-users


__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
__
___

Re: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory management fault in lwip_select.

2017-09-07 Thread Noam Weissman
Hi David,

Attached please find my own sys_arch files used in STM32F4xx with FreeRTOS.

Hope that helps in some way.

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of David Lockyer
Sent: Wednesday, September 06, 2017 5:13 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory 
management fault in lwip_select.


Hi,

I have a project that uses an STM32F MCU running FreeRTOS (cortex mpu port) & 
lwip, with the MPU enabled.

I'm upgrading to lwip 2.0.2 from lwip 1.4.1, that I had to customize to be 
compatible with the MPU, in particular in lwip_select().

The motivation was to use the LWIP_MPU_COMPATIBLE define, so a direct 
modification of the stack source was not required.  However for me it still 
appears to try to access another threads memory, triggering an exception.

The changes I had to make were:

Index: lib/lwip-2.0.2/src/api/sockets.c
===
--- lib/lwip-2.0.2/src/api/sockets.c(revision x)
+++ lib/lwip-2.0.2/src/api/sockets.c(working copy)
@@ -1428,7 +1428,9 @@
 /* Put this select_cb on top of list */
 select_cb.next = select_cb_list;
 if (select_cb_list != NULL) {
+  RAISE_PRIVILEGE();
   select_cb_list->prev = _cb;
+  RESET_PRIVILEGE();
 }
 select_cb_list = _cb;
 /* Increasing this counter tells event_callback that the list has changed. 
*/
@@ -1508,7 +1510,9 @@
 /* Take us off the list */
 SYS_ARCH_PROTECT(lev);
 if (select_cb.next != NULL) {
+  RAISE_PRIVILEGE();
   select_cb.next->prev = select_cb.prev;
+  RESET_PRIVILEGE();
 }
 if (select_cb_list == _cb) {
   LWIP_ASSERT("select_cb.prev == NULL", select_cb.prev == NULL);
@@ -1515,7 +1519,9 @@
   select_cb_list = select_cb.next;
 } else {
   LWIP_ASSERT("select_cb.prev != NULL", select_cb.prev != NULL);
+  RAISE_PRIVILEGE();
   select_cb.prev->next = select_cb.next;
+  RESET_PRIVILEGE();
 }
 /* Increasing this counter tells event_callback that the list has changed. 
*/
 select_cb_ctr++;

Is there something else I missed here that would remove the need for this 
modification?



Kind regards,

David Lockyer

__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
__
/*
 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *this list of conditions and the following disclaimer in the documentation
 *and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 * Author: Adam Dunkels 
 *
 */

//*
//
// Include OS functionality.
//
//*

/*  System architecture includes 
- */

/*  lwIP includes - */

#include "lwip/debug.h"
#include "lwip/def.h"
#include "lwip/sys.h"
#include "lwip/mem.h"
#include "lwip/stats.h"

/* Very crude mechanism used to determine if the critical section handling
functions are being called from an interrupt context or not.  This relies on
the interrupt handler setting this variable manually. */
volatile portBASE_TYPE xInsideISR = pdFALSE;

#if defined(LWIP_SOCKET_SET_ERRNO) && defined(LWIP_PROVIDE_ERRNO)
int errno;
#endif


Re: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory management fault in lwip_select.

2017-09-06 Thread Noam Weissman
Hi David,


I have upgraded LwIP from 1.41 to 2.02 and only handled the sys_arch.h/c files


The only thing I can remember that I had to change was the ip_addr variable 
definitions in

my own code. Beside that I have not mad any change to the LwIP code.


STM32F4 and also F7 with FreeRTOS...


Works like a charm.


BR,

Noam.


From: lwip-users  on behalf of 
David Lockyer 
Sent: Wednesday, September 6, 2017 5:12 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory 
management fault in lwip_select.


Hi,

I have a project that uses an STM32F MCU running FreeRTOS (cortex mpu port) & 
lwip, with the MPU enabled.

I'm upgrading to lwip 2.0.2 from lwip 1.4.1, that I had to customize to be 
compatible with the MPU, in particular in lwip_select().

The motivation was to use the LWIP_MPU_COMPATIBLE define, so a direct 
modification of the stack source was not required.  However for me it still 
appears to try to access another threads memory, triggering an exception.

The changes I had to make were:

Index: lib/lwip-2.0.2/src/api/sockets.c
===
--- lib/lwip-2.0.2/src/api/sockets.c(revision x)
+++ lib/lwip-2.0.2/src/api/sockets.c(working copy)
@@ -1428,7 +1428,9 @@
 /* Put this select_cb on top of list */
 select_cb.next = select_cb_list;
 if (select_cb_list != NULL) {
+  RAISE_PRIVILEGE();
   select_cb_list->prev = _cb;
+  RESET_PRIVILEGE();
 }
 select_cb_list = _cb;
 /* Increasing this counter tells event_callback that the list has changed. 
*/
@@ -1508,7 +1510,9 @@
 /* Take us off the list */
 SYS_ARCH_PROTECT(lev);
 if (select_cb.next != NULL) {
+  RAISE_PRIVILEGE();
   select_cb.next->prev = select_cb.prev;
+  RESET_PRIVILEGE();
 }
 if (select_cb_list == _cb) {
   LWIP_ASSERT("select_cb.prev == NULL", select_cb.prev == NULL);
@@ -1515,7 +1519,9 @@
   select_cb_list = select_cb.next;
 } else {
   LWIP_ASSERT("select_cb.prev != NULL", select_cb.prev != NULL);
+  RAISE_PRIVILEGE();
   select_cb.prev->next = select_cb.next;
+  RESET_PRIVILEGE();
 }
 /* Increasing this counter tells event_callback that the list has changed. 
*/
 select_cb_ctr++;

Is there something else I missed here that would remove the need for this 
modification?


Kind regards,

David Lockyer

__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
__
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] ERR_MEM when sending large data, LWIP stats show no error

2017-09-01 Thread Noam Weissman
Hi Adrian,


Are you using RAW, netcon or Socket API ?


I think that you have set a too large window size for the mem size you have.

You should not send 32K blocks in one go. You need to send smaller block, say 
1K or 1.5K,

check available memory of send buffer and if available send another chunk of 
data.


If you work with RAW API you can and probably need to use the sent call-back to 
synchronize

when to send more data.


I suggest checking some examples and incorporate ideas from them.


Memory errors are normally happening when one does not follow the LwIP threading

requirements. If you are using RAW API and your module is the client 
(initiating the connection)

you probably are sending data from outside the LwIP context, you are not using 
it as it should be.


Hope that helps,

Noam.



From: lwip-users  on behalf of 
Adrian Figueroa 
Sent: Friday, September 1, 2017 11:15 AM
To: lwip-users@nongnu.org
Subject: [lwip-users] ERR_MEM when sending large data, LWIP stats show no error


Hello all,



I am trying to send large amounts of data continuously. I use lwIP as a TCP 
client on an STM32F7 and Matlab on a PC as a TCP server.



I send blocks of 32768 bytes. Here are some settings for the memory sizes in 
lwIP:



#define MEM_ALIGNMENT 4

#define MEM_SIZE 17520

#define MEMP_NUM_TCP_SEG 65

#define PBUF_POOL_BUFSIZE 1516

#define TCP_WND 8760

#define TCP_MSS 1460

#define TCP_SND_BUF 8760



When sending with tcp_write(), I get ERR_MEM errors. So, I switched on 
LWIP_STATS for seeing memory statistics. When should I be using tcp_output()? 
Should I check for the remaining tcp_sndbuf and use tcp_output() if it gets low?



In Wireshark, I can see TCP Dup ACKs and “TCP Previous segment not captured” 
errors. Find the dump here:



https://sync.coda.pw/r/Z_uuIXRtl2#NT5OwZOSW4Nd8erfCRvLvSdAmMS1YODnWL3tP+dGRMk=



I send data every 2 seconds and it takes around 1.5 seconds to send it to the 
PC, which is too long.



Here are some of the results after ERR_MEM happened:

https://snip.coda.pw/?69c4627d150293fa#3cUX2gAqvAKaflXk8NTs7k+TxBAjQwmNT+IYu+GfiJE=



There is no Mem/Memp section that contains even one error. So, I am not sure 
where to look next.



Thank you in advance!

Adrian


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

Re: [lwip-users] Lwip on external ram

2017-08-16 Thread Noam Weissman
Hi Milan,

Check your system and see that the TCP stack task priority is one of the 
highest in the system.
Check that you have a small delay or system calls in your tasks, this avoids 
task starvation, etc...

In general LwIP 2.0x is better but if you have some basic problem in your 
system this will not eliminate
your problem.


Good luck,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Milan Vathoopan
Sent: Wednesday, August 16, 2017 9:24 AM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Lwip on external ram

Hello Noam,

Sorry that I forgot to include MEMP_NUM_PBUF, MEMP_NUM_TCP_SEG settings in the 
last post. I have them exactly the same as yours. I will try to update to lwip 
2.0.2 and continue debugging and update the results here. 

Thanks and Regards
Milan



--
View this message in context: 
http://lwip.100.n7.nabble.com/Lwip-on-external-ram-tp30498p30504.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] Lwip on external ram

2017-08-14 Thread Noam Weissman
Hi Milan,

I am working with STM32 + FreeRTOS + LwIP for more than 6 years now.

>From my own experience It works great and almost always if you have problems 
>it is
due to not using the library properly.

LwIP 1.41 is rather old and that suggest that the example you use is also a bit 
old. I can suggest
The following:
upgrade LwIP to 2.02
Check your interrupt definitions vs the OS definitions

I have not used any external RAM (so far) and was able to run several modules 
at the same time.

Cortex-M has a bit complicated interrupt mechanism and the FreeRTOS porting is 
confusing. If your
Interrupts are not properly defined it may cause slowness and even causing the 
system to stop
working. Check ST latest example and see how they defined the interrupts. It 
should be something
similar to this:

--

#define IRQ_SYS_PRIORITY_MODEL  NVIC_PriorityGroup_4


/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. 
*/
#define configPRIO_BITS 
__NVIC_PRIO_BITS
#else
#define configPRIO_BITS 4/* 
15 priority levels */
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 
   0xF

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY   5

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY( 
configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/*  configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero 
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY  ( 
configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )


#define ADC3_DMA_ISR_PRIO  (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 
6)
#define ETH_ISR_PRIO   (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 
5)
#define IR_TIMERS_ISR_PRIO (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 
2)
#define SERIAL_ISR_PRIO(configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 
1)

--
In the above code portion ETH and other interrupts have a priority LOWER than 
the OS time tick. If this
Is not kept any critical section in your code or the OS own code will not mask 
interrupts properly.

Another place to look for problems is your LwIP lwipopts.h file ... in short 
memory settings. You may have
sufficient memory in hardware but if you do not define it in the lwipopts its 
not usable.

Hope the above helped.

BR,
Noam.



From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Milan V K
Sent: Sunday, August 13, 2017 6:51 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] Lwip on external ram

Hi everyone,

I am trying to develop an Open 62541 OPC UA Server application using LwiP 
socket Interface. The socket binding works without issues, the Server set up 
without any issues. But as soon as a Client tries to connect with the Server, 
the Lwip response becomes slow.(TTL > ~2500). Could it be any memory issues on 
LwiP? I am not getting any hard fault or stack Overflow. But I wanted to make 
sure it is not a Memory related issue and tried assiging Attribute : 
_attribute_((section("External_Ram") for ram_heap in mem.h. But then it seems 
the allocations are not working. What else should I check in this case?

My platform Details: STM 32 + 128 K internal RAM + 2 MB external RAM
freeRTOS: 8.0.2 + Lwip 1.4.1(STM port)

Thanks in advance.

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

Re: [lwip-users] Advice on wifi module

2017-08-10 Thread Noam Weissman
Hi Sergio,

Murata, Microchip and all other readymade modules are a bit expensive. Around 
30-45$... 

Some time ago I have searched for such module and finally we chose ROVING 
RN-171... They may have a 
newer one, now.

ROVING module was also around $29 for small quantities but after talking with 
their representative they were
willing to drastically go down on price if we take large quantities (1K and 
more).

ROVING have a full TCP stack on their module + ability to write some code under 
their own micro. The second
option is using the module in PASS THROUGTH mode via fast RS232 920Kbit or 
something. In this mode one can
configure the WiFi and then send/get data over this serial connection. This is 
good for small systems that does
not need to send lots of data.

BR,
Noam.



-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Sergio R. Caprile
Sent: Thursday, August 10, 2017 5:38 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Advice on wifi module

> I recall having seen an asian SDIO module, but I can't remember the 
> part number.

Found it:
WF111 from BlueGiga, now Silicon Labs.

Atmel has a module series too, but I personally don't like Microship.
Murata is also building a number of modules, some based on the Cypress 
(formerly Broadcomm) chip mentioned in this thread.

Nice to know we do have some options these days.


___
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] dhcp behaviour

2017-07-11 Thread Noam Weissman
Hi Max,

I hope I am not confusing you or making an error here.

As far as I know DHCP client is handled almost completely by LwIP.

You should not worry about timers etc...

I have attached my DHCP task, take a look and I hope this helps...
This code is running with LwIP 1.41

BR,
Noam.


-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of massimiliano cialdi
Sent: Tuesday, July 11, 2017 11:50 AM
To: lwip-users@nongnu.org
Subject: [lwip-users] dhcp behaviour

Hallo,

I have some questions about dhcp behaviour:

- Do I have to call the functions dhcp_coarse_tmr() and
dhcp_coarse_tmr() explicitly?
I have this doubt because I have seen that these functions are already being 
declared as
   timer callbacks in file timeout.c

- if my dhcp server has 10s as lease time, should I lower 
DHCP_COARSE_TIMER_SECS and DHCP_FINE_TIMER_MSECS? And what values?

Best regards
Max

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

// Scheduler include files.
#include "FreeRTOS.h"
#include "task.h"


// lwIP includes
#include "dhcp.h"
#include "dns.h"

#include "DHCP_client.h"
#include "IP_Settings.h"

#include "UserInterface.h"


#ifndef LWIP_DNS
  #error "LWIP_DNS not defined, check your lwipopts.h file "
#endif 


// Private macro -

#ifndef MY_DHCP_DEBUG
#define MY_DHCP_DEBUG   LWIP_DBG_OFF //LWIP_DBG_ON //LWIP_DBG_OFF // 
LWIP_DBG_ON
#endif

#if (MY_DHCP_DEBUG == LWIP_DBG_ON)
  #define DHCP_BUFF_S  350
  static char lpbuf[DHCP_BUFF_S];
  #ifdef ATLONA_PROC
#ifdef ATLONA_PROC_WS_WSS
  #define DHCPP_DEBUG(x, ...) { snprintf(lpbuf, DHCP_BUFF_S, (char *)x, 
##__VA_ARGS__); streamPrint(AMS_RS232_ID, DefaultInterface, FALSE, "%s", 
lpbuf); }
#else
  #define DHCPP_DEBUG(x, ...) { snprintf(lpbuf, DHCP_BUFF_S, (char *)x, 
##__VA_ARGS__); streamPrint(DefaultInterface, FALSE, "%s", lpbuf); }
#endif  
  #else
#define DHCPP_DEBUG(x, ...) { snprintf(lpbuf, WSS_BUFF_S, (char *)x, 
##__VA_ARGS__); streamPrint(DefaultInterface, "%s", lpbuf); } 
  #endif
#else
  #define DHCPP_DEBUG(x, ...)
#endif


#define MAX_DHCP_TRIES  4

static DHCP_States DHCP_state = eDHCP_LinkDown;

bool DhcpAddressAssigned = FALSE;

//-

void SetDhcpState(DHCP_States NewState)
{
  DHCP_state = NewState;
  
#if (MY_DHCP_DEBUG == LWIP_DBG_ON)
  DHCPP_DEBUG("DHCP_NewState:\r\n");
  
  switch(NewState)
  {
case eDHCP_Start:   DHCPP_DEBUG("  eDHCP_Start\r\n");   
break;
case eDHCP_WaitAddress: DHCPP_DEBUG("  eDHCP_WaitAddress\r\n"); 
break;
case eDHCP_AddressAsigned:  DHCPP_DEBUG("  eDHCP_AddressAsigned\r\n");  
break;
case eDHCP_TimeOut: DHCPP_DEBUG("  eDHCP_TimeOut\r\n"); 
break;
case eDHCP_LinkDown:DHCPP_DEBUG("  eDHCP_LinkDown\r\n");
break;
  }   
#endif
}

//-

bool GetDhcpAddressAssignedState(void)
{
  return DhcpAddressAssigned;
}

//-

/**
  * @brief  DHCP Process
  * @param  argument: network interface
  * @retval None
  */
void vDHCP_thread( void *pvParameters )
{
DHCP_TaskParams_t *pDHCP_TaskParams = (DHCP_TaskParams_t*)pvParameters;
  __DwordOrBytes Addr;
  bool ShowNewAddress = FALSE;
struct ip_addr DnsIpAddr;

  

  while(1)
  {
switch(DHCP_state)
{
  case eDHCP_Start:
DhcpAddressAssigned = FALSE;
  
// Stop DHCP
netifapi_dhcp_stop(pDHCP_TaskParams->netif);

if(GetTcpIpMode() == TRUE)
{
  // init values to ZERO before starting DHCP
pDHCP_TaskParams->netif->ip_addr.addr = 
0;
  pDHCP_TaskParams->netif->netmask.addr = 0;
  pDHCP_TaskParams->netif->gw.addr = 0;
  Addr.Dword = 0;
  
  ShowNewAddress = FALSE;
  
  // start DHCP and wait for address
  netifapi_dhcp_start(pDHCP_TaskParams->netif);
  
  // change DHCP task state machine
  DHCP_state = eDHCP_WaitAddress;
#if ((defined ATLONA_PROC) || (defined ATLONA_PROC_WS_WSS))
  #ifdef ATLONA_PROC_WS_WSS
 streamPrint(AMS_DEBUG_PRINT, DefaultInterface, FALSE, "State: Looking 
for DHCP server ...\r\n");
  #else
 streamPrint(DefaultInterface, FALSE, "State: Looking for DHCP server 
...\r\n");
  #endif  
#else
 streamPrint(DefaultInterface, "State: Looking for DHCP server 
...\r\n");
#endif
}
else
{
  DHCP_state = eDHCP_TimeOut;
}
  break;
  //--- 
 
  case eDHCP_WaitAddress:
DHCPP_DEBUG(" 

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

2017-07-09 Thread Noam Weissman
Hi Max,

I just read your comments. In my case I have two tasks… one that poll the link 
and one handling
the application DHCP. The link task changes the DHCP task state when link is 
established and therefore
they are independent and no deadlock happens.

The link call back is used to update parameters or do special operations at the 
application level.
I am for example call announce for my discovery protocol.

BR,
Noam.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Krzysztof Wesolowski
Sent: Friday, July 07, 2017 8:22 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] how to set the link up


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<mailto: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<mailto: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] how to set the link up

2017-07-07 Thread Noam Weissman
Hi Max,


I am missing something here. TCP stack is software and has no direct access to 
the

physical part, the PHY.


The connection between the two from what I know is by DMA and nothing else.

Data collected by the low level is transferred to the TCP stack for processing 
and

any data sent from the TCP stack is passed to the physical layer. The two are 
encapsulated

by the driver.


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 !.


The MDIO interface between your micro and PHY has no relation with netif so why 
do you

pass it as argument ?


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.


The third option is what I suggested to read the PHY basic register and check 
for the link bit.


If you have a UART connected and can print out messages please add debug prints 
in your code.


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 ?


Noam.

From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
massimiliano cialdi <massimiliano.cia...@powersoft.it>
Sent: Friday, July 7, 2017 6:27 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] how to set the link up

I have implement a task to check phy status (similar to what you do),
and also I use netifapi_* functions:


static void PhyStatus_Task( struct netif *netif )
{
 phy_speed_t physpeed;
 phy_duplex_t phyduplex;
 bool linkstatus;
 status_t result;

 ETHSPDOFF();

 while(1)
 {
 result = ethernetif_GetLinkStatus(netif, );
 if(result == kStatus_Success)
 {
 if(linkstatus == true)
 {
 result = ethernetif_GetLinkSpeedDuplex(netif,
, );
 if(result == kStatus_Success)
 {
 ETHSPD(physpeed);
 }
 netifapi_netif_set_link_up(netif);
 }
 else
 {
 ETHSPDOFF();
 netifapi_netif_set_link_down(netif);
 }

 }
 else
 {
 ETHSPDOFF();
 netifapi_netif_set_link_down(netif);
 }

 vTaskDelay(100);
 }
}

unfortunately I have a problem: when netif_set_link_up() is finally
called always return immediately:


void
netif_set_link_up(struct netif *netif)
{
   if (!(netif->flags & NETIF_FLAG_LINK_UP)) {
 netif->flags |= NETIF_FLAG_LINK_UP;

#if LWIP_DHCP
 dhcp_network_changed(netif);
#endif /* LWIP_DHCP */

#if LWIP_AUTOIP
 autoip_network_changed(netif);
#endif /* LWIP_AUTOIP */

 if (netif->flags & NETIF_FLAG_UP) {
   netif_issue_reports(netif,
NETIF_REPORT_TYPE_IPV4|NETIF_REPORT_TYPE_IPV6);
 }
 NETIF_LINK_CALLBACK(netif);
   }
}


first 'if' is always false, and I wonder why


best regads

Max


On 05/07/2017 19:21, Noam Weissman wrote:
>
> Yes Sylvain 
>
> I already changed the code according to your comments 
>
>
> Thanks.
>
>
>
> 
> *From:* lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on
> behalf of Sylvain Rochet <grada...@gradator.net>
> *Sent:* Wednesday, July 5, 2017 8:08 PM
> *To:* Mailing list for lwIP users
> *Subject:* Re: [lwip-users] how to set the link up
> Hi,
>
> On Wed, Jul 05, 2017 at 04:55:24PM +, Noam Weissman wrote:
> >
> > My DHCP task calls dhcp_start and wait for an IP. If there is a
> > timeout the task will assign a static default IP. You can do something
> > similar.
>
> Erm, should I add that dhcp_start() is not thread safe ?
>
> Sylvain
>


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...

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

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

2017-07-06 Thread Noam Weissman
Dear Simon,


I was not offended buy any means. Your work and the input of every other

person here is appreciated.


You are all doing a wonderful work :-)

BR,
Noam.

From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsi...@gmx.de <goldsi...@gmx.de>
Sent: Thursday, July 6, 2017 10:36 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] how to set the link up

Have you read about the "not meant offensive" part?
Seriously, this project lives from people getting involved and sharing 
improvements!

Simon


Noam Weissman:

Hi Simon,


When something is working fine and does not cause any issues its overlooked.


I took ST example, modified it, made it general for our usage and it is running 
on

several device without seen problems.


When Silvayin pointed out on that I checked the code and modified my core !!.


Well I am not perfect 


Thanks,

Noam.



From: lwip-users 
<lwip-users-bounces+noam=silrd@nongnu.org><mailto:lwip-users-bounces+noam=silrd@nongnu.org>
 on behalf of goldsi...@gmx.de<mailto:goldsi...@gmx.de> 
<goldsi...@gmx.de><mailto:goldsi...@gmx.de>
Sent: Thursday, July 6, 2017 9:48 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] how to set the link up

Noam Weissman wrote:
> THANKS for pointing this out !!!.
>
> I am using the code I sent for several years and was not aware of that :-(

I must say now I'm a little bit shocked. You already pointed out lwIP
has threading requirements on this list more than once. And still you've
got it wrong. What can we do to better document or verify these
requirements? Really, I don't mean this offensive but I really want to
get this solved better.

We could move the include files, prefix functions or add runtime checks...

Someone's *got* to do something about this ;-)

> The base code was taken from ST example !!

Well, obviously not them *g*

> I could not find netifapi_netif_set_link_up ... did you mean 
> netifapi_netif_set_up ?

That one is new to 2.0.1 (thanks to Joel).

Cheers,
Simon

___
lwip-users mailing list
lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...





___
lwip-users mailing list
lwip-users@nongnu.org<mailto: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 set the link up

2017-07-06 Thread Noam Weissman
Hi Simon,


When something is working fine and does not cause any issues its overlooked.


I took ST example, modified it, made it general for our usage and it is running 
on

several device without seen problems.


When Silvayin pointed out on that I checked the code and modified my core !!.


Well I am not perfect 


Thanks,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsi...@gmx.de <goldsi...@gmx.de>
Sent: Thursday, July 6, 2017 9:48 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] how to set the link up

Noam Weissman wrote:
> THANKS for pointing this out !!!.
>
> I am using the code I sent for several years and was not aware of that :-(

I must say now I'm a little bit shocked. You already pointed out lwIP
has threading requirements on this list more than once. And still you've
got it wrong. What can we do to better document or verify these
requirements? Really, I don't mean this offensive but I really want to
get this solved better.

We could move the include files, prefix functions or add runtime checks...

Someone's *got* to do something about this ;-)

> The base code was taken from ST example !!

Well, obviously not them *g*

> I could not find netifapi_netif_set_link_up ... did you mean 
> netifapi_netif_set_up ?

That one is new to 2.0.1 (thanks to Joel).

Cheers,
Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

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

2017-07-05 Thread Noam Weissman
Yes Sylvain 

I already changed the code according to your comments 


Thanks.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Sylvain Rochet <grada...@gradator.net>
Sent: Wednesday, July 5, 2017 8:08 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] how to set the link up

Hi,

On Wed, Jul 05, 2017 at 04:55:24PM +, Noam Weissman wrote:
>
> My DHCP task calls dhcp_start and wait for an IP. If there is a
> timeout the task will assign a static default IP. You can do something
> similar.

Erm, should I add that dhcp_start() is not thread safe ?

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

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

2017-07-05 Thread Noam Weissman
Hi,


Yes I have two tasks... One polling the link and another handling the 
application side DHCP.


You can use one task but in my case as the code is shared between devices I 
have split it to

two separate tasks. In that case every device may be different. Sometimes the 
link task is a bit

different (local) because the network part is different... Sometimes it has 
just a PHY, sometimes

it has a switch etc...


My DHCP task calls dhcp_start and wait for an IP. If there is a timeout the 
task will assign a static

default IP. You can do something similar.


BR,

Noam.


From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
massimiliano cialdi <massimiliano.cia...@powersoft.it>
Sent: Wednesday, July 5, 2017 6:25 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] how to set the link up

So you have a task to manage link status an another to manage DHCP?

I have to make possible to change ip address or switch between static and 
dynamic ip without reboot.
I noticed that when the board has a DHCP assigned IP and the link goes down, 
the board do not change ip or switch in auto ip.

So I'm going to setup a task to poll PHY link status (and speed, to switch 
on/off speed led), and another task to manage ip assignment. These task should 
be under application layer.
I do not know if it's a good idea.

best regards
Max

On 05/07/2017 16:40, Noam Weissman wrote:

Hi Sylvian,

THANKS for pointing this out !!!.

I am using the code I sent for several years and was not aware of that :-(

The base code was taken from ST example !!

I could not find netifapi_netif_set_link_up ... did you mean 
netifapi_netif_set_up ?




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

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

2017-07-05 Thread Noam Weissman
Hi Sylvian,

THANKS for pointing this out !!!. 

I am using the code I sent for several years and was not aware of that :-(

The base code was taken from ST example !!

I could not find netifapi_netif_set_link_up ... did you mean 
netifapi_netif_set_up ?

BR,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Sylvain Rochet
Sent: Wednesday, July 05, 2017 4:35 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] how to set the link up

HI,

On Wed, Jul 05, 2017 at 03:01:49PM +0200, massimiliano cialdi wrote:
> On 05/07/2017 13:59, Noam Weissman wrote:
> >>From what I have seen the KSZ8081RNACA is an IEEE compliant PHY... that 
> >>means that the driver is standard.
> >
> >You need to read PHY_BSR register (1) and check bit 3 ... this is the link 
> >status. This is what I am doing in a task.
> >The reason for doing the above is that a PHY with RMII has no link 
> >interrupt and the simplest way is to read the basic status register.
> Yes, I know, but I wonder where, in the code, to poll that register. 
> Do I need to provide a task as you do? And netif_set_link_up() has to 
> be called only from this task?

netif_set_link_up() is not thread safe and as such *MUST* *NOT* be called 
outside the lwIP core thread. You can use
netifapi_netif_set_link_up() instead.

Anyway, this is purely optional, if you don't care how much time
DHCP/IPv6 recover from a link down condition, you can as well call
netif_set_link_up() just once in your netif init callback.

Same for administrative state, if your interface is never going to be 
administratively set down (which is the case for almost all cases unless you 
have to play with multiple interfaces and therefore may have to chose an 
outgoing path), then you only have to call netif_set_up() once in your netif 
init callback.

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


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

2017-07-05 Thread Noam Weissman
Hi,

Yes this is what I did... created a task. I have attached it here, I hope it 
will give you a clue to what I did.

BR,
Noam.


-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of massimiliano cialdi
Sent: Wednesday, July 05, 2017 4:02 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] how to set the link up


On 05/07/2017 13:59, Noam Weissman wrote:
> >From what I have seen the KSZ8081RNACA is an IEEE compliant PHY... that 
> >means that the driver is standard.
>
> You need to read PHY_BSR register (1) and check bit 3 ... this is the link 
> status. This is what I am doing in a task.
> The reason for doing the above is that a PHY with RMII has no link 
> interrupt and the simplest way is to read the basic status register.
Yes, I know, but I wonder where, in the code, to poll that register. Do I need 
to provide a task as you do? And netif_set_link_up() has to be called only from 
this task?

> Do you have a fully functional driver and initialize code that works for you ?
>
I have an implementation... Is the sample code provided by NXP in
KSDK2.2 (our board is very similar to FRDM K64). They do some strange things, 
but they have provided a task that only deals with receiving the data from 
network. PHY polling is done in an high level (application) task that deal with 
UDP packets.

best regards
Max

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
/*
  This file holds the code that checks for ETH link status
  This is part of the DHCP process
*/


#include "streamAtlona.h"

#include "UserInterface.h"
#include "SynchronizationTask.h"

#include "lwip/netif.h"

#include "phy_bsp.h"

#include "stm32f7xx_eth_conf.h"
#include "stm32f7xx_eth.h"

#include "DHCP_Client.h"


static xTaskHandle xLinkProcTaskHandle = NULL;

static bool RemoteLink = FALSE;


//***
// ETH Link task
//***
void vETH_LinkTask( void *pvParameters )
{   
  bool LinkStat = FALSE, SavedEthLinkStatus = FALSE;
  bool RemoteSavedEthLinkStatus = FALSE;
  struct netif *netif = (struct netif *)pvParameters;  
  
  xLinkProcTaskHandle = xTaskGetCurrentTaskHandle();

  
  while(1)
  {
if(PHY_GetLinkStatus(PHY3_ADDRESS, ) == TRUE)
{
  if((SavedEthLinkStatus != LinkStat) || (RemoteSavedEthLinkStatus != 
RemoteLink))
  {
if(SavedEthLinkStatus != LinkStat)
{
  // local ETH link status change
  streamPrint(DefaultInterface,FALSE, "TX ETH Link is: %s\r\n", 
(LinkStat == FALSE)? "OFF" : "ON");
}

if(RemoteSavedEthLinkStatus != RemoteLink)
{
  // remote ETH link status change
  streamPrint(DefaultInterface,FALSE, "RX ETH Link is: %s\r\n", 
(RemoteLink == FALSE)? "OFF" : "ON");
}
  
   
// update the devices ETH data
if((LinkStat == TRUE) || (RemoteLink == TRUE))
{
  // only if both sides were disconnected and one was connected 
  if((SavedEthLinkStatus == FALSE) && (RemoteSavedEthLinkStatus == 
FALSE))
  {
netif_set_link_up(netif);

#ifdef USE_DHCP 
SetDhcpState(eDHCP_Start);
#endif

SET_ETH_LINK_LED_ON();
  }  
}
else
{
  netif_set_link_down(netif);

#ifdef USE_DHCP 
  SetDhcpState(eDHCP_LinkDown);
#endif  

SET_ETH_LINK_LED_OFF(); 

}

SavedEthLinkStatus = LinkStat;
RemoteSavedEthLinkStatus = RemoteLink;
  }  
} 
   

vTaskDelay((100 / portTICK_RATE_MS));
  }
}

//-

void SuspendLinkTask(void)
{
  vTaskSuspend(xLinkProcTaskHandle);
} 

//-

void ResumeLinkTask(void)
{
  vTaskResume(xLinkProcTaskHandle);
} 

//-

bool IsEthLinkUp(void)
{
  bool RetVal = FALSE;
  bool LinkStat = FALSE;

  if(PHY_GetLinkStatus(PHY3_ADDRESS, ) == TRUE)
  {
RetVal = LinkStat;
  }
  
  return RetVal;  
}

//-
//

Re: [lwip-users] Porting lwIP to ERIKA enterprise RTOS

2017-07-05 Thread Noam Weissman
Hi Josip,

The files I sent you should not be compiled with your OS.

You must modify them to suit your needs. I am not familiar with ERIKA so I 
cannot help in that.

BR,
Noam.



-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of joa1101
Sent: Wednesday, July 05, 2017 3:29 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Porting lwIP to ERIKA enterprise RTOS

Noam, thank You for your quick response.

Your sys_arch.c file relies on functions from tasks.c, queue.c and other 
similar source files which are not provided along with ERIKA. Do you think that 
importing freeRTOS source files like these into ERIKA project would work 
correctly? 
I managed to import those and compile the project but some TRAP exceptions 
occured in runtime. I think that ERIKA needs its own mechanisms similar to 
these and I am looking for those. Someone working with ERIKA might help with 
that.

Cheers.
Josip



--
View this message in context: 
http://lwip.100.n7.nabble.com/Porting-lwIP-to-ERIKA-enterprise-RTOS-tp30062p30065.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] Porting lwIP to ERIKA enterprise RTOS

2017-07-05 Thread Noam Weissman
Hi Josip,

I would suggest taking a sys_arch files for FreeRTOS and modify it 

I have attached my own sys_arch files used with LwIP 2.0x and FreeRTOS

I have started creating my own sys_arch files for LwIP 1.41 but after finding a 
well written set I have used it instead.
The files were originally found on the net for LwIP 1.41. The attached files 
are my own modified files for LwIP 2.0x
I do not remember now were I found the original files so I cannot credit the 
author.

Take a look at the doc section of LwIP sys_arch.txt ...  use these files as 
templates for your own code.

Good luck,
Noam.


-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of joa1101
Sent: Wednesday, July 05, 2017 1:33 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] Porting lwIP to ERIKA enterprise RTOS

Hello 

I have issues while porting lwIP (lightweight IP) into ERIKA enterprise RTOS. 
lwIP stack requires semaphore and mailbox implementations written into 
sys_arch.c file. For other operating systems like freeRTOS there are plenty of 
solutions avaliable on web, but has anyone made sys_arch.c file for ERIKA 
enterprise RTOS? 
Do you have any hints on writing those architecture specific functions? 

Best regards,
Josip



--
View this message in context: 
http://lwip.100.n7.nabble.com/Porting-lwIP-to-ERIKA-enterprise-RTOS-tp30058.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
/*
 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *this list of conditions and the following disclaimer in the documentation
 *and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 * Author: Adam Dunkels 
 *
 */

//*
//
// Include OS functionality.
//
//*

/*  System architecture includes 
- */

/*  lwIP includes - */

#include "lwip/debug.h"
#include "lwip/def.h"
#include "lwip/sys.h"
#include "lwip/mem.h"
#include "lwip/stats.h"

/* Very crude mechanism used to determine if the critical section handling
functions are being called from an interrupt context or not.  This relies on
the interrupt handler setting this variable manually. */
volatile portBASE_TYPE xInsideISR = pdFALSE;

#if defined(LWIP_SOCKET_SET_ERRNO) && defined(LWIP_PROVIDE_ERRNO)
int errno;
#endif

/*---*
 * Routine:  sys_mbox_new
 *---*
 * Description:
 *  Creates a new mailbox
 * Inputs:
 *  int size-- Size of elements in the mailbox
 * Outputs:
 *  sys_mbox_t  -- Handle to new mailbox
 *---*/
err_t sys_mbox_new( sys_mbox_t *pxMailBox, int iSize )
{
  err_t xReturn = ERR_MEM;

*pxMailBox = xQueueCreate(iSize, sizeof(void*));

if(*pxMailBox != NULL)
{
xReturn = ERR_OK;

#if SYS_STATS
++lwip_stats.sys.mbox.used;
if(lwip_stats.sys.mbox.max < lwip_stats.sys.mbox.used) 
{
  lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used;
  }
#endif /* SYS_STATS */
}

return xReturn;
}



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

2017-07-05 Thread Noam Weissman
Hi,

>From what I have seen the KSZ8081RNACA is an IEEE compliant PHY... that means 
>that the driver is standard.

You need to read PHY_BSR register (1) and check bit 3 ... this is the link 
status. This is what I am doing in a task.
The reason for doing the above is that a PHY with RMII has no link interrupt 
and the simplest way is to read the
basic status register.

Do you have a fully functional driver and initialize code that works for you ?

BR,
Noam.



-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of massimiliano cialdi
Sent: Wednesday, July 05, 2017 2:24 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] how to set the link up

I haveKSZ8081RNACA as phy that has to be polled (interrupt signal is not
routed)

In LWIP documentation I read:

- netif_set_link_up(struct netif *netif)

   This is the hardware link state; e.g. whether cable is plugged for wired
   Ethernet interface. This function must be called even if you don't know
   the current state. Having link up and link down events is optional but
   DHCP and IPv6 discover benefit well from those events.

- netif_set_up(struct netif *netif)

   This is the administrative (= software) state of the netif, when the
   netif is fully configured this function must be called.


So I understand that netif_set_link_up() has to be called from phy driver? and 
what about netif_set_up()?


best regads


-- 

Powersoft logo 

*Massimiliano Cialdi |*Senior Firmware Engineer

*skype:*  mci.pws *| email:* massimiliano.cia...@powersoft.it 


*HQ Italy:* Via E. Conti, 5 *|* 50018 Scandicci (FI) Italy

*direct phone:*  +39 055 0153429 *| Fax:*  +39 055 735 6235

*web site:* www.powersoft.it 

Green Audio Power


___
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 complex example

2017-07-05 Thread Noam Weissman
Hi,

If you use RAW API it is not thread safe, if you use Socket API it is OK.

No problems running multiple modules with mixed API if you follow the rules.

I am running devices with several modules in RAW API + Socket API.


BR,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of massimiliano cialdi
Sent: Wednesday, July 05, 2017 9:41 AM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] lwip complex example

Ok but I wonder how to implement two sockets, because reading txt documentation 
provided it seems that only a subset of api are thread safe, and I use LWIP + 
FreeRTOS.

So I wonder if I can do this with two threads or I have to do with just one.

I have other doubts about initialization


best regards

Max

On 04/07/2017 17:53, Jan Menzel wrote:
> Hi Max!
>   It's the nature of the stack that you may combine any examples you 
> like suppose you can provide sufficient resources. Running eg. http 
> and sntp is quite easy you just need more udp pcbs for sntp and/or tcp 
> support for http...
>


___
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] A new users request for help with sending TCP Packets on Demand

2017-06-27 Thread Noam Weissman
Hi,


First of all great that you have been able to leap to 2.xx 


Keeping the connection open or not depends on your own needs. So there is no

simple reply to that.


As for buffering, it depends on your system design. Do you have an OS or are you

running without an OS, do you have sufficient RAM to create the buffering etc...


Do remember that while using RAW API, sending data not from the TCP own context

is not thread safe, that is if you use threads.


If you use an OS, one way is to use the poll call back and send all the data in 
the buffer

from within the poll call back. Meaning you add data to the buffer from one 
task and let

the poll call back check if that buffer has data to. This is a bit slow but 
easy to keep an eye...


To properly handle the data send you need to keep an eye on send window size 
etc..


I suggest checking the examples in the contribution section and especially the 
HTTP

server were you can see how you can send data and keep an eye on how much you

can send.


Another option that will be faster, is to create a call back function and call 
it from within the

tcp context by calling the sys_timeout function.


This way you set the timeout from your own code and when it is triggered it 
calls your function.

Your function will access the buffer or what other mechanism you use. You can 
also use the sent

call back to send more data when the last chunk was already sent, that is if 
the buffer has more data

to be sent.


I suggest first to think what you want to achieve and then design how.


Hope the above gave some ideas and helped.


BR,

Noam.


From: lwip-users  on behalf of 
mitchj 
Sent: Tuesday, June 27, 2017 9:06 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] A new users request for help with sending TCP Packets 
on Demand

Thank you,

I have read that page, and actually lept ahead to 2.0.0, it was an easier
upgrade than I expected. Further, I was able to get a basic example working
sending a string through a client. For now I have only a couple of questions
to help me in my design. I need to expand this so that I can send data from
anywhere in my full application.

So first off:
Is it best to attempt to keep the connection awake, or should this
connection be closed and opened for each transaction? Further, with a client
is there an equivalent of an accept callback that could open the connection
when the server decides to push data to the client? ... I'm probably
revealing how new I am at this.

Second:
How might some of you recommend queuing data to be sent from outside of the
lwip client. As in, my application wants to send data to the server, how
should it get that data into the client? I was thinking I'd write a function
that took raw data and added it to a buffer chain or something like that.

Am I on the wrong path?

Regards,



--
View this message in context: 
http://lwip.100.n7.nabble.com/A-new-users-request-for-help-with-sending-TCP-Packets-on-Demand-tp29868p29984.html
lwip-users - A new users request for help with sending TCP Packets on 
Demand
lwip.100.n7.nabble.com
A new users request for help with sending TCP Packets on Demand. Hi there lwip 
users, I've had success sending UDP packets on demand, but am not finding 
success doing the same with a TCP...


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 Info Page - 
non-GNU
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] internet over PPP and NAT issue

2017-06-21 Thread Noam Weissman
Asaf,

Cannot ?... The changes in function is limited. The code uses ip4_addr_t  
instead of struct ip_addr
and some defines for IPV6 or 4

>From working with LwIP for the last 6+ years I think that unless Marvel made 
>changes in
LwIP core you should not have any problems porting. I think it is worth to 
check.

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Asaf Manasse
Sent: Wednesday, June 21, 2017 2:41 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] internet over PPP and NAT issue


this is provided SDK by Marvell, I can't upgrade the version.



there wifi code depends on the LWIP .




From: lwip-users 
<lwip-users-bounces+asaf=roadtracktelematics@nongnu.org<mailto:lwip-users-bounces+asaf=roadtracktelematics@nongnu.org>>
 on behalf of Noam Weissman <n...@silrd.com<mailto:n...@silrd.com>>
Sent: Wednesday, June 21, 2017 2:38:38 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] internet over PPP and NAT issue

Hi Asaf,

I can suggest upgrading to LwIP 2.02

The porting is not complicated and the benefits are significant. I find that 
LwIP 2.02
Is better and has smaller footprint.

Good luck,
Noam W.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Asaf Manasse
Sent: Wednesday, June 21, 2017 1:18 PM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: [lwip-users] internet over PPP and NAT issue

LWIP team hallo,


I am trying to establish Access Point product based on Marvell MW302 WiFi MCU, 
using the SDK provided by Marvell.

Marvell SDK implement IP Stack using LWIP version 1.4.X ( last commit : 
88a57dc98d9793d74f8e1c52729b50188d5a0b4f ) , integrated with wifi.

I have established to implement PPPOS over USB to 3G modem.

These 2 network interfaces (PPP and wlan) are bridged using LWIP NAT 
implementation of Company called RT-Thread
(taken from 
https://github.com/RT-Thread/rt-thread/tree/master/components/net/lwip_nat , I 
have a permission from RT-Thread to use there code ).

at this point we have a internet connection to the wifi clients but with 
connectivity issues:
1. connection is not stable (from test I can may be guess it's unstable upload).
2. WireShark log reveals multiple Duplicated ACK and TCP RST.
3. tcp debug print:
[3236.092616] : -+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
[3236.096609] : tcp_input: no PCB match found, resetting.
[3236.111094] : tcp_rst: seqno 0 ackno 3423651674.
4. pbuf debug print:
pbuf_header: failed as xxx < yyy (not enough space for new header size)


configurations:
* disabled IP_FORWARD.
* set PPP MRU to be 1020 (USB connection bottlenech)

is there any additional information you need for better understanding of the 
issue?




Asaf Manasse




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

Re: [lwip-users] internet over PPP and NAT issue

2017-06-21 Thread Noam Weissman
Hi Asaf,

I can suggest upgrading to LwIP 2.02

The porting is not complicated and the benefits are significant. I find that 
LwIP 2.02
Is better and has smaller footprint.

Good luck,
Noam W.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Asaf Manasse
Sent: Wednesday, June 21, 2017 1:18 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] internet over PPP and NAT issue

LWIP team hallo,


I am trying to establish Access Point product based on Marvell MW302 WiFi MCU, 
using the SDK provided by Marvell.

Marvell SDK implement IP Stack using LWIP version 1.4.X ( last commit : 
88a57dc98d9793d74f8e1c52729b50188d5a0b4f ) , integrated with wifi.

I have established to implement PPPOS over USB to 3G modem.

These 2 network interfaces (PPP and wlan) are bridged using LWIP NAT 
implementation of Company called RT-Thread
(taken from 
https://github.com/RT-Thread/rt-thread/tree/master/components/net/lwip_nat , I 
have a permission from RT-Thread to use there code ).

at this point we have a internet connection to the wifi clients but with 
connectivity issues:
1. connection is not stable (from test I can may be guess it's unstable upload).
2. WireShark log reveals multiple Duplicated ACK and TCP RST.
3. tcp debug print:
[3236.092616] : -+-+-+-+-+-+-+-+-+-+-+-+-+-+ tcp_input: flags
[3236.096609] : tcp_input: no PCB match found, resetting.
[3236.111094] : tcp_rst: seqno 0 ackno 3423651674.
4. pbuf debug print:
pbuf_header: failed as xxx < yyy (not enough space for new header size)


configurations:
* disabled IP_FORWARD.
* set PPP MRU to be 1020 (USB connection bottlenech)

is there any additional information you need for better understanding of the 
issue?




Asaf Manasse




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

Re: [lwip-users] A new users request for help with sending TCP Packets on Demand

2017-06-20 Thread Noam Weissman
Hi,


I would suggest upgrading to lwip 1.41 and take a look at this:

http://download.savannah.nongnu.org/releases/lwip/


http://lwip.wikia.com/wiki/Raw/TCP

Raw/TCP | lwIP Wiki | Fandom powered by 
Wikia
lwip.wikia.com
Initialization Edit. lwip_init() must be called before any tcp functions are 
called. void tcp_tmr(void) After lwip_init() is called, you must call tcp_tmr 
...




NW


From: lwip-users  on behalf of 
mitchj 
Sent: Wednesday, June 21, 2017 12:32 AM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] A new users request for help with sending TCP Packets 
on Demand

Precisely, a TCP client is exactly what I need. I'm looking at both the lwip
src and contrib for LWIP 1.4.0 and did not find one instance of tcp_connect.
The only ones I see that is related to raw tcp at all is a server and does
tcp_accept(echo_pcb, echo_accept); ... and similar in the http server.

Regards,
MJ



--
View this message in context: 
http://lwip.100.n7.nabble.com/A-new-users-request-for-help-with-sending-TCP-Packets-on-Demand-tp29868p29918.html
lwip-users - A new users request for help with sending TCP Packets on 
Demand
lwip.100.n7.nabble.com
A new users request for help with sending TCP Packets on Demand. Hi there lwip 
users, I've had success sending UDP packets on demand, but am not finding 
success doing the same with a TCP...


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 Info Page - 
non-GNU
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] Simultaneous GET requests to HTTP Server

2017-06-16 Thread Noam Weissman
Hi,


Just a small addition to my earlier message. Because ETH communication normally 
uses

interrupts + DMA that means that some of the data transfer is not handled by 
the micro.

That said means that even that we have one simple micro it is capable of 
handling several

connections in "parallel".


Have a great weekend, all you out there 

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Simeon Trifonov <simeon.trifo...@amk-drives.bg>
Sent: Friday, June 16, 2017 2:45 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Simultaneous GET requests to HTTP Server


But my problems are not with slow reaction, but with hanging communication. For 
my point of view, the communication with my device runs quite fast, even if I 
limit the browser to send only one GET request at a time. So I don't search a 
possibility to accelerate the communication. I just want to give the 
possibility to the user to work with the default settings of the browser (that 
means 6 parallel connections for Firefox).


Simeon

On 16.6.2017 г. 14:18 ч., Noam Weissman wrote:

Hi Antonio,


RAW mode API is meant to be used in systems without an OS or if you use an OS

in one task, dedicated to TCP stack.


Sure one connection is handled at a time because you have one micro that is able

to run only one command at a time.


Using threads actually worsen the situation because you have the OS scheduler

that also needs some CPU time.


If your RAW API WEB server runs slow you have some configuration or code issue.

I do not think it should run much slower than a threaded server, maybe even 
faster.


I think that the only impact on performance comes from memory usage. If you run

a threaded server and do memory allocations (large buffers) you can definitely 
write

code that is much more deficient. The efficiency will come from simpler parsing 
of

data, less memory copying etc...


The LwIP RAW mode server that is spread around is able to run on systems with 
very

limited memory. It runs well but it is a bit slow.


The speed issues comes from the way it handles data (files) and the small 
buffers,

not because it uses call-backs instead of threads.


This is my observation 



BR,

Noam.




From: lwip-users 
<lwip-users-bounces+noam=silrd@nongnu.org><mailto:lwip-users-bounces+noam=silrd@nongnu.org>
 on behalf of Antonio Gonga <go...@kth.se><mailto:go...@kth.se>
Sent: Friday, June 16, 2017 1:54 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Simultaneous GET requests to HTTP Server

Hi Simeon,

I am not sure but I believe, the server does not send anything because it still 
processing the first request when the others arrive.

Q: Did you try to use threads in your server ? For example I had developed one 
multi-thread HTTP server using LWIP-1.4 and I was able to have many HTTP 
requests and high rate pings (ping -i 0.2 a.b.c.d), and the server was capable 
of handling my requests..
Essentially, for each accept return, you create a new thread to handle that 
request.


---
Best Regards,
António Gonga, KTH Sweden
-


From: lwip-users 
<lwip-users-bounces+gonga=kth...@nongnu.org><mailto:lwip-users-bounces+gonga=kth...@nongnu.org>
 on behalf of Simeon Trifonov 
<simeon.trifo...@amk-drives.bg><mailto:simeon.trifo...@amk-drives.bg>
Sent: Friday, June 16, 2017 11:08
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: [lwip-users] Simultaneous GET requests to HTTP Server

Hello,

I need some help about the usage of the HTTP Server. My current problem
is the following. I have some WEB pages that use some styles,
JavaScripts, pictures as usual. When I set an option to the WEB Browser
(up to now I use always Firefox) to make only one GET request at a time,
all works without any problems. But by default the simultaneous requests
of the browser are set to 6. In this case, index page is loaded correct,
then the browser generates simultaneous GET requests to read a style and
a JavaScript and at this point the communication brakes - I see that the
HTTP Server stops sending the next frames with the data of the files. It
happens the same if the simultaneous requests are even 2. So it works
only if the requests are following one after another. I suppose that
this is something in my code, or more usual in some settings of the
stack or HTTP Server, but I can't find out what is it. I'm using LWIP
stack V1.4.1. Can you give me an advice what I have to check, please?

Best regards!

--
Simeon Trifonov
Head of department "Development"

AMK Drives and Controls Ltd.
Bulgaria / Gabrovo

Phone:   +359 (0)66 819125
Fax: +359 (0)66 819101
E-Mail:  simeon.trifo...@amk-drives.bg<mailto:simeon.trifo...@amk-drives.bg>
Web: www.amk-drives.bg<http://www.amk-drives.bg&g

Re: [lwip-users] Simultaneous GET requests to HTTP Server

2017-06-16 Thread Noam Weissman
Hi Antonio,


RAW mode API is meant to be used in systems without an OS or if you use an OS

in one task, dedicated to TCP stack.


Sure one connection is handled at a time because you have one micro that is able

to run only one command at a time.


Using threads actually worsen the situation because you have the OS scheduler

that also needs some CPU time.


If your RAW API WEB server runs slow you have some configuration or code issue.

I do not think it should run much slower than a threaded server, maybe even 
faster.


I think that the only impact on performance comes from memory usage. If you run

a threaded server and do memory allocations (large buffers) you can definitely 
write

code that is much more deficient. The efficiency will come from simpler parsing 
of

data, less memory copying etc...


The LwIP RAW mode server that is spread around is able to run on systems with 
very

limited memory. It runs well but it is a bit slow.


The speed issues comes from the way it handles data (files) and the small 
buffers,

not because it uses call-backs instead of threads.


This is my observation 



BR,

Noam.




From: lwip-users  on behalf of 
Antonio Gonga 
Sent: Friday, June 16, 2017 1:54 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Simultaneous GET requests to HTTP Server

Hi Simeon,

I am not sure but I believe, the server does not send anything because it still 
processing the first request when the others arrive.

Q: Did you try to use threads in your server ? For example I had developed one 
multi-thread HTTP server using LWIP-1.4 and I was able to have many HTTP 
requests and high rate pings (ping -i 0.2 a.b.c.d), and the server was capable 
of handling my requests..
Essentially, for each accept return, you create a new thread to handle that 
request.


---
Best Regards,
António Gonga, KTH Sweden
-


From: lwip-users  on behalf of 
Simeon Trifonov 
Sent: Friday, June 16, 2017 11:08
To: lwip-users@nongnu.org
Subject: [lwip-users] Simultaneous GET requests to HTTP Server

Hello,

I need some help about the usage of the HTTP Server. My current problem
is the following. I have some WEB pages that use some styles,
JavaScripts, pictures as usual. When I set an option to the WEB Browser
(up to now I use always Firefox) to make only one GET request at a time,
all works without any problems. But by default the simultaneous requests
of the browser are set to 6. In this case, index page is loaded correct,
then the browser generates simultaneous GET requests to read a style and
a JavaScript and at this point the communication brakes - I see that the
HTTP Server stops sending the next frames with the data of the files. It
happens the same if the simultaneous requests are even 2. So it works
only if the requests are following one after another. I suppose that
this is something in my code, or more usual in some settings of the
stack or HTTP Server, but I can't find out what is it. I'm using LWIP
stack V1.4.1. Can you give me an advice what I have to check, please?

Best regards!

--
Simeon Trifonov
Head of department "Development"

AMK Drives and Controls Ltd.
Bulgaria / Gabrovo

Phone:   +359 (0)66 819125
Fax: +359 (0)66 819101
E-Mail:  simeon.trifo...@amk-drives.bg
Web: www.amk-drives.bg


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...



___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] Building mbedtls using LWIP library :: Handshake takes too long

2017-06-08 Thread Noam Weissman
Hi Antonio,

mbedTLS uses memory allocation (malloc, free...)

There are defines in mbedTLS code if you want to use system memory allocation 
or something else.
System allocation means malloc, free etc...

Another memory manager can be using LwIP memory allocation functions or OS 
memory allocation functions etc...
FreeRTOS normally uses their own memory manager.

If you use the default memory allocation function check that you have a heap 
sufficient for SSL .. sufficient means
minimum 40-45K RAM and up. I found that the hard way... did not work for me (at 
start).

Another problem that I had is that mbedTLS uses system IO... as we are using an 
embedded micro there is normally
no STDIO and you cannot use printf, gets functions etc.

ST is suppling a retarget.c file but you need to hook the functions to your 
UART or other device. See PUTCHAR_PROTOTYPE
macro for putc function.

I am using STM32F4xx and STM32F7xx ... these micro's have a main memory and a 
fast memory CCM/TCM .. I assigned
All of the CCM (64K) for heap.

Good luck,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Antonio Gonga
Sent: Thursday, June 08, 2017 4:53 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Building mbedtls using LWIP library :: Handshake 
takes too long


Hi Noam,



Thanks for your answer.

>>Do you use any external SDRAM or just the M3 own memory ?.



I do not have an external SDRAM yet. My application still uses the Demos 
/programs/ssl/ssl_server/client, which I believe is fairly simple. and need not 
much memory.

>>Have you been able to run the SSL server demo from mbedTLS ?

I am using the Demo examples. The connection is established, the handshake is 
what takes too much time.

The LWIP layer works since I can see TCP connection establishment messages on 
wireshark, and also the initial handshake messages.



once again thanks, I will keep debugging.




---
Best Regards,
/António, KTH Royal Institute of Technology/Sweden

-

From: lwip-users 
<lwip-users-bounces+gonga=kth...@nongnu.org<mailto:lwip-users-bounces+gonga=kth...@nongnu.org>>
 on behalf of Noam Weissman <n...@silrd.com<mailto:n...@silrd.com>>
Sent: Thursday, June 8, 2017 15:09
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Building mbedtls using LWIP library :: Handshake 
takes too long

Hi,

Do you use any external SDRAM or just the M3 own memory ?... If you do not have 
any extra RAM
I do not see how you can run HTTPS.. you need around 100-200K RAM to run HTTPS 
for one page.
The estimate is based that your page hase one or more JS files, one or more 
images, one or more
CSS files... in all you need 4-6 connections to load a single page and that 
needs lots of RAM.

Every SSL connection needs 16K for receive and 16K for transmit + some 
overhead. If you tweak
mbedTLS and use a smaller send buffer you may save on RAM but still need about 
20+K RAM for
a connection... multiply that by 4-6 that's a lot.

As for hardware acceleration... some M3 have DES, AES, SHA, CRC and RNG 
engines. This may help but
It is not related to big numbers, as far as I understand.

Have you been able to run the SSL server demo from mbedTLS ?... If not then I 
suggest first run the demo
And then work on your own code.

Good luck,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of antonio
Sent: Thursday, June 08, 2017 10:31 AM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: Re: [lwip-users] Building mbedtls using LWIP library :: Handshake 
takes too long

Hi all, I am trying to port mbedTLS to work with my embedded device. My problem 
is that the handshake procedure never completes, therefore, I am unable to have 
any HTTPS communication. Further debugging, I noticed that the math 
computations are taking too long (bignum.c). Is there a way to avoid such a 
mess ? I am using MC "arm-cortex-m3", which I believe can achieve fast 
computations. Any kind of optimizations etc is kindly welcome. /Antonio

View this message in context: Re: Building mbedtls using LWIP library :: 
Handshake takes too 
long<http://lwip.100.n7.nabble.com/Building-mbedtls-using-LWIP-library-tp29319p29856.html>
Sent from the lwip-users mailing list 
archive<http://lwip.100.n7.nabble.com/lwip-users-f3.html> at Nabble.com.
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Building mbedtls using LWIP library :: Handshake takes too long

2017-06-08 Thread Noam Weissman
Hi,

Do you use any external SDRAM or just the M3 own memory ?... If you do not have 
any extra RAM
I do not see how you can run HTTPS.. you need around 100-200K RAM to run HTTPS 
for one page.
The estimate is based that your page hase one or more JS files, one or more 
images, one or more
CSS files... in all you need 4-6 connections to load a single page and that 
needs lots of RAM.

Every SSL connection needs 16K for receive and 16K for transmit + some 
overhead. If you tweak
mbedTLS and use a smaller send buffer you may save on RAM but still need about 
20+K RAM for
a connection... multiply that by 4-6 that's a lot.

As for hardware acceleration... some M3 have DES, AES, SHA, CRC and RNG 
engines. This may help but
It is not related to big numbers, as far as I understand.

Have you been able to run the SSL server demo from mbedTLS ?... If not then I 
suggest first run the demo
And then work on your own code.

Good luck,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of antonio
Sent: Thursday, June 08, 2017 10:31 AM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Building mbedtls using LWIP library :: Handshake 
takes too long

Hi all, I am trying to port mbedTLS to work with my embedded device. My problem 
is that the handshake procedure never completes, therefore, I am unable to have 
any HTTPS communication. Further debugging, I noticed that the math 
computations are taking too long (bignum.c). Is there a way to avoid such a 
mess ? I am using MC "arm-cortex-m3", which I believe can achieve fast 
computations. Any kind of optimizations etc is kindly welcome. /Antonio

View this message in context: Re: Building mbedtls using LWIP library :: 
Handshake takes too 
long
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

Re: [lwip-users] LwIP 1.41 select does not return ?

2017-05-31 Thread Noam Weissman
Hi Arpit,


I am not sure I need to check.


I know that the code uses something called virtual file system for devices that 
do not have

a file system. Maybe you have a point there ... I will check that, thanks.


when I commented the call to select and left to code to block on accept it also 
did not return

when a connection was made.


In general a server code:

create socket,

set options,

bind,

listen,

accept


They do about the same but for some reason their code hangs ?.. so it should be 
something else

related to the porting or file system as you mentioned.


Thanks for everyone that made notes...


BR,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Arpit Agarwal <arpi...@alumni.iitg.ernet.in>
Sent: Wednesday, May 31, 2017 6:33 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?


Hi Noam,

Just to clarify another thing, is the environment where you are trying to use 
lwip_select also uses select for file descriptors ?
If yes then there is a possibility of malfunctioning as if I am not wrong 
lwip_select is not meant to be used with file descriptors as opposed normal BSD 
style select which is normally meant for both file and socket descriptors.

I used to face similar problems when porting lwip to an RTOS with POSIX 
compliance  / BSD-style API support.

If this is not the case, then probably I have no clue what might be causing 
this malfunctioning as I don't have the code and environment you are using.



--
Thanks & Regards,
ARPIT AGARWAL
Alumni, Department Of CSE
IIT Guwahati-781039 (INDIA)
M: (+91)-8792793063
E: arpi...@alumni.iitg.ernet.in
arpit0...@gmail.com

-
“ The greater part of progress is the desire to progress. ” — Seneca




From: lwip-users <lwip-users-bounces+arpit.a=alumni.iitg.ernet...@nongnu.org> 
on behalf of Noam Weissman <n...@silrd.com>
Sent: Wednesday, May 31, 2017 8:44 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?


Thanks I will check that tomorrow :-)



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsimon <goldsi...@gmx.de>
Sent: Wednesday, May 31, 2017 5:53 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?



Noam Weissman:
>Were is the semaphore released ?

In "event_callback()", if I remember correctly.

Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] LwIP 1.41 select does not return ?

2017-05-31 Thread Noam Weissman
Thanks I will check that tomorrow :-)



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsimon <goldsi...@gmx.de>
Sent: Wednesday, May 31, 2017 5:53 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?



Noam Weissman:
>Were is the semaphore released ?

In "event_callback()", if I remember correctly.

Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] LwIP 1.41 select does not return ?

2017-05-31 Thread Noam Weissman
Thanks Tim,


Its not a migration issue..


I am simply trying to run a socket based module that I have not written and I 
am encountering

issues that I am not finding whats wrong, so far 


Thanks,

Noam.



From: Tim Cussins <timcuss...@eml.cc>
Sent: Wednesday, May 31, 2017 4:30 PM
To: Noam Weissman; lwip-users@nongnu.org
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?

Hi Noam,

OK, cool. It sounds like you're on top of the whole raw/netconn thing. I
was really checking to see whether you'd failed to start the tcpip
thread,
or some other setup issue that might come about from migrating from raw
API to netconn for the first time.

So I agree that, in your case, switching off the raw API probably won't
change anything :)

Sorry I couldn't be of more help!

Cheers,
Tim

On Wed, May 31, 2017, at 02:10 PM, Noam Weissman wrote:
> Hi Tim,
>
>
> RAW API is used in multi threaded application with one limitation. All
> RAW API handling must be in the same context as the TCP stack. This
> limitation is kept and works fine.
>
>
> I am running a HTTP server + a TCP server both use the RAW API + a WSS
> client written with the socket API and have ZERO issues.
>
> In my original question I am talking on something else. I have no
> problems turning off the RAW API, comment the use of my TCP server and
> I will be very surprised if that will make any difference. I will test
> that tomorrow :-)
>
>
> Thanks,
>
> Noam.
>
> 
> From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf
> of Tim Cussins <timcuss...@eml.cc>
> Sent: Wednesday, May 31, 2017 1:43 PM
> To: lwip-users@nongnu.org
> Subject: Re: [lwip-users] LwIP 1.41 select does not return ?
>
> Hi Noam,
>
> On Wed, May 31, 2017, at 11:11 AM, Noam Weissman wrote:
>
> > I am using a base project that is used for testing. This base project
> > uses FreeRTOS 8.01 + LwIP 1.41
> > +  a few modules that work just fine. The base project has a DHCP client
> > and a TCP server (Raw API)
> > that work just fine.
> >
> >
> > I have enabled sockets and netcon in lwipopts.h ... in general it seems
> > to load properly and run.
>
> > My own TCP server that listens on port 23 and the rest of the system
> > works just fine
> >
> >
> > Any ideas what did I miss or what should I check ?
> >
>
> Just a quick check: The raw API is not meant to be used in a
> multi-threaded system. Is your working TCP server using this API? If so,
> I expect your TCP server would work, but your calls to the netconn API
> (or sockets, which uses netconn under the hood) would probably dead-end
> in the way you're seeing.
>
> Have a look at the first couple of paragraphs here:
>
> http://lwip.wikia.com/wiki/Netconn_API
Netconn API | lwIP Wiki | Fandom powered by 
Wikia<http://lwip.wikia.com/wiki/Netconn_API>
lwip.wikia.com
The netconn API is a sequential API designed to make the stack easier to use 
(compared to the event-driven raw API) while still preserving zero-copy 
functionality.


> Netconn API | lwIP Wiki | Fandom powered by
> Wikia<http://lwip.wikia.com/wiki/Netconn_API>
Netconn API | lwIP Wiki | Fandom powered by 
Wikia<http://lwip.wikia.com/wiki/Netconn_API>
lwip.wikia.com
The netconn API is a sequential API designed to make the stack easier to use 
(compared to the event-driven raw API) while still preserving zero-copy 
functionality.


> lwip.wikia.com
> The netconn API is a sequential API designed to make the stack easier to
> use (compared to the event-driven raw API) while still preserving
> zero-copy functionality.
>
>
>
> HTH,
> Tim
>
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] LwIP 1.41 select does not return ?

2017-05-31 Thread Noam Weissman
Hi Tim,


RAW API is used in multi threaded application with one limitation. All RAW API 
handling

must be in the same context as the TCP stack. This limitation is kept and works 
fine.


I am running a HTTP server + a TCP server both use the RAW API + a WSS client 
written

with the socket API and have ZERO issues.


In my original question I am talking on something else. I have no problems 
turning off the

RAW API, comment the use of my TCP server and I will be very surprised if that 
will make

any difference. I will test that tomorrow :-)


Thanks,

Noam.


From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Tim Cussins <timcuss...@eml.cc>
Sent: Wednesday, May 31, 2017 1:43 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?

Hi Noam,

On Wed, May 31, 2017, at 11:11 AM, Noam Weissman wrote:

> I am using a base project that is used for testing. This base project
> uses FreeRTOS 8.01 + LwIP 1.41
> +  a few modules that work just fine. The base project has a DHCP client
> and a TCP server (Raw API)
> that work just fine.
>
>
> I have enabled sockets and netcon in lwipopts.h ... in general it seems
> to load properly and run.

> My own TCP server that listens on port 23 and the rest of the system
> works just fine
>
>
> Any ideas what did I miss or what should I check ?
>

Just a quick check: The raw API is not meant to be used in a
multi-threaded system. Is your working TCP server using this API? If so,
I expect your TCP server would work, but your calls to the netconn API
(or sockets, which uses netconn under the hood) would probably dead-end
in the way you're seeing.

Have a look at the first couple of paragraphs here:

http://lwip.wikia.com/wiki/Netconn_API
Netconn API | lwIP Wiki | Fandom powered by 
Wikia<http://lwip.wikia.com/wiki/Netconn_API>
lwip.wikia.com
The netconn API is a sequential API designed to make the stack easier to use 
(compared to the event-driven raw API) while still preserving zero-copy 
functionality.



HTH,
Tim

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] LwIP 1.41 select does not return ?

2017-05-31 Thread Noam Weissman
Hi Arpit,


Thanks for the reply. I am not saying that lwip_select is the problem, I am 
using the socket API in

in another application that I wrote and have no problems. It works as expected.


The code I am trying to debug (not my code) is layered and is planed to 
portable to many systems

(different OS, different TCP stack etc...).


Just to clarify I do not have timeout on select, I just mentioned that I added 
time struct to select

function call instead of the NULL (original code) just to see if it returns at 
all, and it did as expected.


If I understand correctly lwip_select calls a function in sys_arch that creates 
a system semaphore. This

is probably added in some linked list and when a connection is made it is 
released etc..


For some reason it is never released for that code I am using.


It may be some define I missed, OS priority or something else that I am missing.



Thanks, any ideas ?

BR, Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Arpit Agarwal <arpi...@alumni.iitg.ernet.in>
Sent: Wednesday, May 31, 2017 2:30 PM
To: Tim Cussins; Mailing list for lwIP users
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?


Hi Noam,

I think lwip_select is not the problem. I have used it previously and it used 
to works with lwip 1.4.1 version.

However as per your saying that select gets timeout, I would recommend you to 
debug event_callback API

and verify if the socket descriptor you used in select has received the 
event_calback properly or not.
If there is no event_callback cming for the particular socket descriptor then 
select will not return and it eventually timeouts.



Thanks,

Arpit



--
Thanks & Regards,
ARPIT AGARWAL
Alumni, Department Of CSE
IIT Guwahati-781039 (INDIA)
M: (+91)-8792793063
E: arpi...@alumni.iitg.ernet.in
arpit0...@gmail.com

-
“ The greater part of progress is the desire to progress. ” — Seneca




From: lwip-users <lwip-users-bounces+arpit.a=alumni.iitg.ernet...@nongnu.org> 
on behalf of Noam Weissman <n...@silrd.com>
Sent: Wednesday, May 31, 2017 4:49 PM
To: Tim Cussins; Mailing list for lwIP users
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?


Hi Tim,


I am aware of that but that did not answer my question.


You can mix API's and I already have systems that use RAW API

and Socket API and they coexists when you know the limitations.


My question was simple ... does anyone have an idea why select

does not return when a connection to the correct port is initiated.


Just to clarify the last 3 parameter to select function are all NULL.

When I set the last parameter to a time struct (for testing) and defined

5 seconds timeout, select did return every 5 seconds with 0...


It should be something that I overlooked or maybe that lwip_select is not

100% BSD compliant as CypherBridge code is ?



Thanks and BR,

Noam.



From: Tim Cussins <timcuss...@eml.cc>
Sent: Wednesday, May 31, 2017 1:57 PM
To: Noam Weissman; Mailing list for lwIP users
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?

Hi Noam,

On Wed, May 31, 2017, at 11:11 AM, Noam Weissman wrote:

> I am using a base project that is used for testing. This base project
> uses FreeRTOS 8.01 + LwIP 1.41
> +  a few modules that work just fine. The base project has a DHCP client
> and a TCP server (Raw API)
> that work just fine.
>
>
> I have enabled sockets and netcon in lwipopts.h ... in general it seems
> to load properly and run.

> My own TCP server that listens on port 23 and the rest of the system
> works just fine
>
>
> Any ideas what did I miss or what should I check ?
>

Just a quick check: The raw API is not meant to be used in a
multi-threaded system. Is your working TCP server using this API? If so,
I expect your TCP server would work, but your calls to the netconn API
(or sockets, which uses netconn under the hood) would probably dead-end
in the way you're seeing.

Have a look at the first couple of paragraphs here:

http://lwip.wikia.com/wiki/Netconn_API
Netconn API | lwIP Wiki | Fandom powered by 
Wikia<http://lwip.wikia.com/wiki/Netconn_API>
lwip.wikia.com
The netconn API is a sequential API designed to make the stack easier to use 
(compared to the event-driven raw API) while still preserving zero-copy 
functionality.



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

Re: [lwip-users] LwIP 1.41 select does not return ?

2017-05-31 Thread Noam Weissman
Hi Tim,


I am aware of that but that did not answer my question.


You can mix API's and I already have systems that use RAW API

and Socket API and they coexists when you know the limitations.


My question was simple ... does anyone have an idea why select

does not return when a connection to the correct port is initiated.


Just to clarify the last 3 parameter to select function are all NULL.

When I set the last parameter to a time struct (for testing) and defined

5 seconds timeout, select did return every 5 seconds with 0...


It should be something that I overlooked or maybe that lwip_select is not

100% BSD compliant as CypherBridge code is ?



Thanks and BR,

Noam.



From: Tim Cussins <timcuss...@eml.cc>
Sent: Wednesday, May 31, 2017 1:57 PM
To: Noam Weissman; Mailing list for lwIP users
Subject: Re: [lwip-users] LwIP 1.41 select does not return ?

Hi Noam,

On Wed, May 31, 2017, at 11:11 AM, Noam Weissman wrote:

> I am using a base project that is used for testing. This base project
> uses FreeRTOS 8.01 + LwIP 1.41
> +  a few modules that work just fine. The base project has a DHCP client
> and a TCP server (Raw API)
> that work just fine.
>
>
> I have enabled sockets and netcon in lwipopts.h ... in general it seems
> to load properly and run.

> My own TCP server that listens on port 23 and the rest of the system
> works just fine
>
>
> Any ideas what did I miss or what should I check ?
>

Just a quick check: The raw API is not meant to be used in a
multi-threaded system. Is your working TCP server using this API? If so,
I expect your TCP server would work, but your calls to the netconn API
(or sockets, which uses netconn under the hood) would probably dead-end
in the way you're seeing.

Have a look at the first couple of paragraphs here:

http://lwip.wikia.com/wiki/Netconn_API
Netconn API | lwIP Wiki | Fandom powered by 
Wikia<http://lwip.wikia.com/wiki/Netconn_API>
lwip.wikia.com
The netconn API is a sequential API designed to make the stack easier to use 
(compared to the event-driven raw API) while still preserving zero-copy 
functionality.



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

[lwip-users] LwIP 1.41 select does not return ?

2017-05-31 Thread Noam Weissman
Hi All,


I am trying to run a CypherBridge uSSH server demo on STM3240-Eval board.


The original code was designed for ST discovery board with the same micro.

The original code uses FreeRTOS 6.01 and LwIP 1.32 ..


I am using a base project that is used for testing. This base project uses 
FreeRTOS 8.01 + LwIP 1.41

+  a few modules that work just fine. The base project has a DHCP client and a 
TCP server (Raw API)

that work just fine.


I have enabled sockets and netcon in lwipopts.h ... in general it seems to load 
properly and run.


The CypherBridge uSSH demo creates a task that initialize a socket with the 
board IP and start listening

on port 22. I have enabled debug messages for CypherBridge  and LwIP sockets 
and I see that all is

ok, no errors and the uSSH starts listening to port 22.


Inside CypherBridge code, after creating the socket, binding etc.. it calls 
listen and the code blocks on select.

After select it will call (never reached) accept etc...


I debugged the code and I see the lwip_select creates a system semaphore and 
blocks on it.


This semaphore does not get released and I could not find were it should get 
released ?


My own TCP server that listens on port 23 and the rest of the system works just 
fine


Any ideas what did I miss or what should I check ?



Thanks and BR,

Noam.


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

Re: [lwip-users] Raw api + multiple TCP Connections

2017-05-22 Thread Noam Weissman
Simon,

I did this while working on my own code, was not paying attention 

My mistake, I thought that pcb->local_port means working port while 
pcb->listenr->local_port is the server port

OK :-(


Noam.


-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Simon Goldschmidt
Sent: Monday, May 22, 2017 4:10 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Raw api + multiple TCP Connections

Noam Weissman wrote:
> If you use Lwip 1.41 the tcp_accepted function should accept the 
> SERVER pcb and not the new connection pcb

In the initial post, he said he's using 2.0.2, not 1.4.1 (what's that 1.41 
again?)
 
> Your accept function is wrong.

I fail to see the difference between your accept function and Werner's...

Werner,
In the end, I fully agree with Jan: lwIP does not produce hard faults on its 
own (if a hard fault is what you get, I can't tell from your mails). You can 
only debug that yourself at your board.

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] Raw api + multiple TCP Connections

2017-05-22 Thread Noam Weissman
Jan see his code. He was trying to compare listening port with working port 

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Jan Menzel
Sent: Monday, May 22, 2017 4:00 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Raw api + multiple TCP Connections

Hi Werner!
In you initial post you wrote, that your system catches a Hardfault. A 
Hardfault indicates are general MCU failure which can be something like memory 
corruption, stack problem, unaligned address, division by zero or even 
escalated from some other fault. The actual reason can usually be extracted 
from some system registers. To my limited understanding, this is very unlikely 
an Lwip problem.

Best regards
Jan

On 22.05.2017 13:38, Werner Motz wrote:
> U are right, but I don't know where the mistake is. I can debug it and 
> the breakpoints in myCallback1 and myCallback2 are hit.
> 
> The also debugged the init_Server and the binding or listen gave no 
> error. Both connections are initiated correctly.
> 
>  
> 
>  
> 
> I do init:
> 
>  
> 
> voidinit_Server(void)
> 
> {
> 
> structtcp_pcb*pcb_1;
> 
> structtcp_pcb*pcb_2;
> 
>  
> 
> pcb_1=tcp_new();
> 
> pcb_2=tcp_new();
> 
>  
> 
> tcp_bind(pcb_1,IP_ADDR_ANY,PortCAN1);
> 
> tcp_bind(pcb_2,IP_ADDR_ANY,PortCAN2);
> 
>  
> 
>pcb_1->flags|=TF_NODELAY;
> 
>pcb_1->flags|=TF_ACK_NOW;
> 
>  
> 
> pcb_2->flags|=TF_NODELAY;
> 
>pcb_2->flags|=TF_ACK_NOW;
> 
>  
> 
>tcp_arg(pcb_1,pcb_1);
> 
> tcp_arg(pcb_2,pcb_2);
> 
>  
> 
>pcb_1=tcp_listen(pcb_1);
> 
> pcb_2=tcp_listen(pcb_2);
> 
>  
> 
>tcp_accept(pcb_1,accept);
> 
> tcp_accept(pcb_2,accept);
> 
> }
> 
>  
> 
>  
> 
> staticerr_taccept(void*arg,structtcp_pcb*pcb,err_terr)
> 
> {
> 
>LWIP_UNUSED_ARG(arg);
> 
>LWIP_UNUSED_ARG(err);
> 
>  
> 
>// set the receive callback for this connection
> 
>if(pcb->local_port==PortCAN1)
> 
>{
> 
>  tcp_setprio(pcb,TCP_PRIO_MAX);
> 
>  tcp_recv(pcb,myCallback1);
> 
>}
> 
>elseif(pcb->local_port==PortCAN2)
> 
>{
> 
>  tcp_setprio(pcb,TCP_PRIO_MAX);
> 
>  tcp_recv(pcb,myCallback2);
> 
>}
> 
>   
> 
>// just use an integer number indicating the connection id as 
> the
> 
>// callback argument
> 
>tcp_arg(pcb,(void*)pcb);
> 
>  
> 
>  
> 
>// Inform lwIP that an incoming connection has been accepted.
> 
>tcp_accepted(pcb);
> 
>   
> 
>returnERR_OK;
> 
> }
> 
>  
> 
>  
> 
> staticerr_tmyCallback1(void*arg,structtcp_pcb*tpcb,structpbuf*p,err_te
> rr)
> 
> {
> 
>// avoid compiler warnings
> 
>(void)arg;
> 
>(void)err;
> 
>chardata[8]={1,2,3,4,5,6,7,8};
> 
>  
> 
>if(!p)//end of linked list
> 
>{
> 
>  tcp_close(tpcb);
> 
>  tcp_recv(tpcb,NULL);
> 
>  returnERR_OK;
> 
>}
> 
>  
> 
>tcp_recved(tpcb,p->tot_len);//Antwort
> 
>   
> 
>tcp_write(tpcb,[0],8,TCP_WRITE_FLAG_COPY);
> 
>tcp_output(tpcb);
> 
>pbuf_free(p);
> 
>   
> 
>returnERR_OK;
> 
> }
> 
>  
> 
>  
> 
> staticerr_tmyCallback2(void*arg,structtcp_pcb*tpcb,structpbuf*p,err_te
> rr)
> 
> {
> 
>// avoid compiler warnings
> 
>(void)arg;
> 
>(void)err;
> 
>chardata[8]={1,2,3,4,5,6,7,8};
> 
>  
> 
>if(!p)//end of linked list
> 
>{
> 
>  tcp_close(tpcb);
> 
>  tcp_recv(tpcb,NULL);
> 
>  returnERR_OK;
> 
>}
> 
>  
> 
>tcp_recved(tpcb,p->tot_len);//Antwort
> 
>   
> 
>tcp_write(tpcb,[0],8,TCP_WRITE_FLAG_COPY);
> 
>tcp_output(tpcb);
> 
>pbuf_free(p);
> 
>   
> 
>returnERR_OK;
> 
> }
> 
>  
> 
>  
> 
> 
> 
> ___
> 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] Raw api + multiple TCP Connections

2017-05-22 Thread Noam Weissman
Hi,

First of all read the lwip readme and every document you can find.

Check the echo server example and see how it is written.

1.
If both servers are the same write functions and simply pass parameters. You do 
not need
to copy and paste the same code. Use the arg parameter in the call backs

2.
If you use Lwip 1.41 the tcp_accepted function should accept the SERVER pcb and 
not the new connection pcb

When you write a TCP server and bind it to port_x it means that the server is 
listening on that port.
Listening means it can accept several connections at the same port.

The data transfer is not handled via the listening port but rather working 
port. Every connection gets a working
different port... that's TCP !!!.

Your accept function is wrong. Here is my fast created code based on yours. 
Check it and see if it helps

If you do not need two servers but rather two connections there is no need to 
create two servers !!!

// Define type
typdef struct
{
  struct tcp_pcb *ServerPcb;
  u16 ServerPort;

} MyServer_t;

//-

// define server variables at the same file you call init_Server function
static MyServer_t Server_1, Server_2;

// initialize server settings
Server_1.ServerPcb = NULL;
Server_1.ServerPort = PortCAN1;

Server_2.ServerPcb = NULL;
Server_1.ServerPort = PortCAN2;

//--

// function protoypes
static err_t myAccept(void *arg, struct tcp_pcb *pcb, err_t err);
static err_t myRecvCallback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, 
err_t err);


// code start in main or what ever...

init_Server(_1);
init_Server(_2);


//---
//---

// initialize servers
void init_Server(MyServer_t *Server)
{
  struct tcp_pcb *pcb;
  err_t err;


  // create new pcb
  pcb = tcp_new();

  if(pcb != NULL)
  {
// bind port
err = tcp_bind(pcb, IP_ADDR_ANY, Server->ServerPort);

if(err == ERR_OK)
{
  // save server pcb for later use, not the same !
  Server->ServerPcb = tcp_listen(pcb);

  // if needed ???
  tcp_setprio(Listening_pcb, TCP_PRIO_MIN);

  // save argument for later use
  tcp_arg(Server->ServerPcb, Server);

  // define accept call back
  tcp_accept(Server->ServerPcb, accept);
}
else
{
  // add error handling
}
  }
  else
  {
// add error handling
  }
}

//---

static err_t myAccept(void *arg, struct tcp_pcb *pcb, err_t err)
{
  MyServer_t *Server = (MyServer_t*) arg;


   // if needed 
   // disable nagle algorithm, improve performance with winxp.
   tcp_nagle_disable(pcb);


  // do you really need TCP_PRIO_MAX ???
  tcp_setprio(pcb, TCP_PRIO_MAX);

  // assign recv callback, only one function needed
  tcp_recv(pcb, myRecvCallback);


  // if you use Lwip 1.41
  tcp_accepted(Server->ServerPcb);

  return ERR_OK;
}

//---

static err_t myRecvCallback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, 
err_t err)
{
  char data[8] = {1,2,3,4,5,6,7,8};

  // avoid compiler warnings
  ( void ) arg;
  ( void ) err;

  if (!p) //end of linked list
  {
tcp_close(tpcb);
tcp_recv(tpcb, NULL);
return ERR_OK;
  }

  tcp_recved(tpcb, p->tot_len); //Antwort

  tcp_write(tpcb, [0], 8, TCP_WRITE_FLAG_COPY);
  tcp_output(tpcb);
  pbuf_free(p);

  return ERR_OK;
}


I hope I do not have errors... wrote it fast :).


BR,
Noam.




From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Werner Motz
Sent: Monday, May 22, 2017 2:38 PM
To: 'Mailing list for lwIP users'
Subject: Re: [lwip-users] Raw api + multiple TCP Connections

U are right, but I don't know where the mistake is. I can debug it and the 
breakpoints in myCallback1 and myCallback2 are hit.
The also debugged the init_Server and the binding or listen gave no error. Both 
connections are initiated correctly.


I do init:

void init_Server(void)
{
struct tcp_pcb *pcb_1;
struct tcp_pcb *pcb_2;

pcb_1 = tcp_new();
pcb_2 = tcp_new();

tcp_bind(pcb_1, IP_ADDR_ANY, PortCAN1);
tcp_bind(pcb_2, IP_ADDR_ANY, PortCAN2);

   pcb_1->flags |= TF_NODELAY;
   pcb_1->flags |= TF_ACK_NOW;

pcb_2->flags |= TF_NODELAY;
   pcb_2->flags |= TF_ACK_NOW;

   tcp_arg(pcb_1, pcb_1);
tcp_arg(pcb_2, pcb_2);

   pcb_1 = tcp_listen(pcb_1);
pcb_2 = tcp_listen(pcb_2);

   tcp_accept(pcb_1, accept);
tcp_accept(pcb_2, accept);
}


static err_t accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
   LWIP_UNUSED_ARG(arg);
   LWIP_UNUSED_ARG(err);

   // set the receive callback for this connection
   if(pcb->local_port == PortCAN1)
   {
 tcp_setprio(pcb, TCP_PRIO_MAX);
 tcp_recv(pcb, myCallback1);
   }
   else if(pcb->local_port == PortCAN2)
  

Re: [lwip-users] Raw api + multiple TCP Connections

2017-05-22 Thread Noam Weissman
So there are two separate servers with each handling one connection, correct ?

So what is the problem ?

Every server should have its own pcb and every connection has its own separate 
pcb

You are doing something wrong, check your code.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Werner Motz
Sent: Monday, May 22, 2017 1:58 PM
To: 'Mailing list for lwIP users'
Subject: Re: [lwip-users] Raw api + multiple TCP Connections

Hi,
I apologize myself.
I (uC) am the server and I initiate two connections with IP_ADDR_ANY but 
different ports.
The PC is the Client and from here I connect to the Server.



Hi,

Do you mean two connections that you initiate from your device to two different 
IP's
or two connections in a server ?

Your question is not clear ?

Noam.



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

Re: [lwip-users] Raw api + multiple TCP Connections

2017-05-22 Thread Noam Weissman
Hi,

Do you mean two connections that you initiate from your device to two different 
IP's
or two connections in a server ?

Your question is not clear ?

Noam.



From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Werner Motz
Sent: Monday, May 22, 2017 1:29 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] Raw api + multiple TCP Connections

Hello,
I am using lwip 2.0.2 RAW API and I have a question depending multiple TCP 
Connections.
I create two connections without problems. Over each of them I can send and 
receive data.
When a single client sends me data every 1ms, my receive callback function 
(tcp_recv(pcb, myCallback1)) gets periodically called.
In myCallback1 I handle the received data and answer. This works fine and on 
Wireshark I am able to reach a
communication rate of about 6Mbit/s without data loss. (lwip stats without 
errors or drops...)

Now if I try to receive data at the same time from the second client (every 
5ms) and using annother callback function
(tcp_recv(pcb, myCallback2)) my system crushes (Hard fault Handler).

My first thought was that a receive callback cannot be called from two clients 
at the same time so I did the following:
I synchronized the client's sending intervals (LabView) and changed the send 
timing to
Client_1 send ---> 3 ms delay ---> Client_2 send ---> 3ms delay ---> Client_1 
send.
Unfortunately this does not work either although I am sending slower with less 
data.

Now my question: How to handle received data from multiple connections?

1.)Is there a better way than using two different callback functions? 
Polling?

2.)What does lwip do if two clients send me data at the same time?

3.)Is the receive callback (myCallback1/2) blocking?

I debugged my lwip_stats but they show no errors.
I am looking forward to your answer(s).


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

Re: [lwip-users] HTTPS support in lwip

2017-05-18 Thread Noam Weissman
Hi Simon,

Is there a way to limit the number of concurrent HTTP connection, say to one ?

If this can be done we may be able to run HTTPS with an overhead of about 40K 
for SSL/TLS

BR,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Simon Goldschmidt
Sent: Thursday, May 18, 2017 3:07 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] HTTPS support in lwip

Sandeep wrote:
> Could you please give me a rough figure of how much RAM it may use, 
> just to know whether it is viable in the above said system?

The most consuming part is that TLS requires 16 kByte per direction and 
connection as encrypt/decrypt buffer.
As modern web browsers open multiple connections (~6?), that means you need >= 
192 Byte only for TLS.

Of course that can be stripped down, but that's additional work to do.

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] HTTPS support in lwip

2017-05-17 Thread Noam Weissman
Simon,


If I was not clear, my apologies... lots of RAM due to the use of SSL and not 
LwIP


BR,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsi...@gmx.de <goldsi...@gmx.de>
Sent: Wednesday, May 17, 2017 9:34 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] HTTPS support in lwip

Noam Weissman wrote:
First of all the code is still in development and secondly you need lots of RAM.

That "lots of RAM" is a limitation of TLS, not a limitation of mbed TLS or how 
lwIP uses it.
That code is still not finished though. And I have to come up with RAM/ROM 
numbers once it is finished...

Anyway, for devices where HTTPS is only one out of many services, that usage is 
far from ideal as it encrypts/decrypts data in the tcpip_thread. And during 
potentially slow/long encrypt/decrypt phases, nothing else can be done in lwIP 
(e.g. no packet processing, no ping, no ACKs...). A socket or netconn-based 
server might be a better idea for some...

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

Re: [lwip-users] HTTPS support in lwip

2017-05-17 Thread Noam Weissman
Hi,

There is a base code for HTTPS in the Lwip master code that works with mbedTLS.
I have been in contact with Simon regarding this. Simon was very helpful but I 
was not
able to use it.

First of all the code is still in development and secondly you need lots of RAM.

At some point I think it will be released…

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Antoine Zen-Ruffinen
Sent: Wednesday, May 17, 2017 2:55 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] HTTPS support in lwip

Hi Sandeep,

Not directly. HTTPS means HTTP+SSL/TLS. SSL/TSL is what bring you the 
encryption on top of TCP/IP and bellow HTTP. I think this is out of scope of 
LwIP, the LwIP source does not enable this. But you can use some SSL/TSL 
library together with lwIP to build HTTPS applications. I have used the” 
wolfSSL” library with LwIP with success to make HTTPS. They are other 
alternative such as mbed TLS, Cyclone SSL, etc.. They are plenty of example, 
just look at they support section.

Regards,

Antoine

From: lwip-users 
[mailto:lwip-users-bounces+antoine=riedonetworks@nongnu.org] On Behalf Of 
Sandeep V.L.
Sent: 17 May 2017 10:17
To: lwip-users@nongnu.org
Subject: [lwip-users] HTTPS support in lwip

Hi all,

Does lwip support HTTPS?

Is there any example HTTPS webserver application available? I saw an HTTP 
webserver example.

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

Re: [lwip-users] DHCP fails ?

2017-05-09 Thread Noam Weissman
Hi,


I will try to explain it better.


The base code was taken from an ST example. I basically took their DHCP client 
code and modified it

to suit my needs.


So in that respect I was not aware that I am doing something wrong 


The DHCP client is basically a task that calls dhcp_start, dhcp_stop etc..


After calling dhcp_start the task delays for some time, checks DHCP state etc...


If DHCP gets an address in a predefined time frame the task goes address 
assigned state and then

to idle state. If DHCP address is not received it about 10 seconds the DHCP 
task declares timeout...


The link task is a separate task that checks the ETH PHY link status. If the 
link task finds a change in

link state it does the following.


If link state changes from up to down it forces the DHCP task to go to idle.

If link is up again, it forces the DHCP task to check for new address again.


I did find a bug in the original ST code. The bug was that once DHCP got an 
address the original

code issued a call to dhcp_stop... This caused LwIP own code to fail to renew 
its address once

1/2 T happened.





The above worked with several devices with LwIP 1.41


For some reason the same code fails to work the same with LwIP 2.02


I hope now it is clear.


BR,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsi...@gmx.de <goldsi...@gmx.de>
Sent: Tuesday, May 9, 2017 10:11 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] DHCP fails ?

Noam Weissman wrote:
> I have a simple link task that checks the PHY for link, reads it. If
> link is up it starts the DHCP task and wait for address.
>
> If link is down the DHCP task is put into an idle state and waits for
> link to come back…
>
> [..]
>
> When board is reset, link is established and at the DHCP task this
> code returns with NULL ?
>
>  dhcp = (struct dhcp
> *)netif_get_client_data(pDHCP_TaskParams->netif,
> LWIP_NETIF_CLIENT_DATA_INDEX_DHCP);
>

Honestly, from how you write it, that sounds like a threading issue. You
must not use that function (as many
others) from any other context than tcpip_thread!

> Just to point out that this setup works for several years on several
> devices and never had any problems

The fact that it works on 1.4.1 (what's 1.41?) does *NOT* mean anything.
The code could be wrong and just work by chance...

Maybe I haven't understood your setup correctly. In that case, please
try to describe it better :-)

Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users Info Page - 
non-GNU<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

[lwip-users] DHCP fails ?

2017-05-09 Thread Noam Weissman
Hi,

I am testing LwIP 2.02 on STM32F769 evaluation board.

My simple code with LwIP 1.41 link task and DHCP tasks work fine.

I have a simple link task that checks the PHY for link, reads it. If link is up 
it starts the DHCP task and wait for address.
If link is down the DHCP task is put into an idle state and waits for link to 
come back...

I ported the LwIP code to 2.02 and I have problems getting IP with DHCP?

When board is reset, link is established and at the DHCP task this code returns 
with NULL ?

 dhcp = (struct dhcp *)netif_get_client_data(pDHCP_TaskParams->netif, 
LWIP_NETIF_CLIENT_DATA_INDEX_DHCP);


After device is running, if ETH cable is disconnected and reconnected I get IP 
address without problems.

After checking/debugging I found that if I add a call to function 
netif_set_link_down(netif); just before I check for link and
netif_set_link_up(netif); ... DHCP task will work fine

Just to point out that this setup works for several years on several devices 
and never had any problems

Am I missing something ??

Thanks and BR,
Noam.


[cid:image001.jpg@01D26A92.68494F10]

Noam Weissman

Software Engineer

SILORA R

p:

+972-4-9554915 m: +972-52-5786135

w:

www.silrd.com<http://www.silrd.com/>  e: n...@silrd.com<mailto:n...@silrd.com>

[cid:image002.png@01D26A92.68494F10]<https://www.facebook.com/SiloraRD/>  
[cid:image003.png@01D26A92.68494F10] <https://twitter.com/SiloraRD>   
[cid:image004.png@01D26A92.68494F10] 
<https://www.linkedin.com/company/silora-r>




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

Re: [lwip-users] Building mbedtls using LWIP library

2017-04-18 Thread Noam Weissman
Simon, 

I meant 1.41 ... my mistake :-(

As far as I know 1.41 was the stable version used for a long time before 2.xx

Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Simon Goldschmidt
Sent: Tuesday, April 18, 2017 5:04 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Building mbedtls using LWIP library

Noam Weissman wrote:
> I strongly suggest upgrading to LwIP 1.42 as a minimum. As far as I 
> know there were many fixes from 1.40 to 1.42

1.42? That version doesn't even exist...

> [..] the mbedTLS uses printf and standard IO.

Really? Last time I checked that was not the case (for me).


Shruti wrote:
> Could you please tell me how to integrate the two?

That's more an mbedTLS question (as long as you use it via sockets, at least: 
lwIP provides a standard socket layer and mbedTLS should just be able to use 
it).

If you want to use mbedTLS with lwIP's callback API, have a look into current 
git master, I'm just working on that. No way to integrate that back into 1.4.x 
though.


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] Building mbedtls using LWIP library

2017-04-18 Thread Noam Weissman
Hi Shruthi,

As a continuation to Jan mail...

I am using mbedTLS 2.42 + LwIP 2.02 and it works for me... after some 
straggling :-)

I strongly suggest upgrading to LwIP 1.42 as a minimum. As far as I know there 
were
many fixes from 1.40 to 1.42

mbetTLS has a net_socket.c+h file that is the "porting" file

I am working with ST micro and they have added a porting file named retarget.c 
... without it, it will not
work as the mbedTLS uses printf and standard IO.

What micro are you using ?, are you using Linux or another OS. You may need to 
add some files that are 
not part of the mbedTLS library ?


BR,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Jan Menzel
Sent: Tuesday, April 18, 2017 12:31 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Building mbedtls using LWIP library

Hi Shruthi!
I'm using mbedtls and lwip on an embedded devices so I can only help 
integration both if there are no other tcp/ip-stacks around.
Basically mbedtls interfaces to any tcp/ip-stack using bsd-socket API.
This is archived using the file net.c, which comes with mbedtls such, that it 
builds on multiple platforms. I'd suggest that you carefully check that all 
calls to open/close/read/write are correctly linked to lwip. There might be 
modifications needed - eventually also in lwip - to not use the Linux stack. I 
think that should be all. Please make sure to enable socked api. You might need 
to enable support for transmit/receive timeouts and you might wont to make 
sure, that lwips errno can be/is read insight net.c.
Please check the archive of this list as we had recently some 
discussions regarding mbedtls and the configuration of lwip.

Best regards
Jan

On 18.04.2017 11:02, shruthi wrote:
> Hi,
> 
> I am using the LWIP stack(1.4.0 version) as a *tap device (tap0)* on 
> my Linux system. I have a simple TCP server-client application running 
> on the LWIP stack. Now I want to add TLS over TCP, and I found that 
> mbedTLS is one of the recommended libraries to add TLS support on 
> LWIP. Could you please tell me how to integrate the two?
> 
> I want to make the mbedTLS library use the LWIP library APIs instead 
> of the Linux APIs. I am new to both these libraries and I am not sure 
> what changes to make in the Makefiles to build them together. Any 
> advice/suggestions would be appreciated.
> 
> Regards,
> Shruthi
> 
> 
> 
> 
> --
> View this message in context: 
> http://lwip.100.n7.nabble.com/Building-mbedtls-using-LWIP-library-tp29
> 319.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] Transfer Mibs of data over TCP

2017-04-04 Thread Noam Weissman
Hy Sylvain,


WTF ???


Sorry I meant netconn_recv etc...


Anyway that was rude of you so good luck []


Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Sylvain Rochet <grada...@gradator.net>
Sent: Tuesday, April 4, 2017 12:30 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Transfer Mibs of data over TCP

Hi,

On Mon, Apr 03, 2017 at 01:43:44PM +, Noam Weissman wrote:
> Hi,
>
> Why not use the RAW API server that is in the contribution ?
>
> I am not using it because am using my own modified code that was created 
> before the current version.
> As far as I know it works nicely and many are using it ☺
>
> I have no problems accepting a large file 1MB… never had to accept a larger 
> file but I  do not think it makes
> any difference.
>
> I think that if netbuf_next() fails you need to add some delay and try again.
> I mean add vTaskDelay(10) or similar and try again.
>
> When you transfer large amount of data you may get into cases that the 
> network has some lag.
> In that case your netbuf_next() call nay fail.
>
> Doing something like this:
>
> #define READ_ERROR_DELAY  10
> #define READ_ERROR_TIMEOUT500
>
> err_t MyRead( params )
> {
>Int RetVal , TotalTimeOut  = 0;
>
>Do
>{
>   RetVal = netbuf_next();
>
>   If(RetVal == (-1))
>   {
>   vTaskDelay(READ_ERROR_DELAY / portTICK_RATE_MS);
>   TotalTimeOut += READ_ERROR_DELAY;
>   }
>   else
>   {
>   break;
>   }
>
>} while(TotalTimeOut < READ_ERROR_TIMEOUT);
>
> }
>
>
> The above function will try to read from the socket and if fails it will 
> delay for about 10 ms… that way you give
> the TCP and other system tasks time to run.
>
> If the above is not an option due to system constrains you can adapt some 
> kind of state machine, per connection
> and use lwip own function sys_timeout to trigger for the above function or 
> similar.
>
> Hope that gives some ideas…

WTF. Did you even read what the netbuf_next() function actually does ?

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

Re: [lwip-users] Transfer Mibs of data over TCP

2017-04-03 Thread Noam Weissman
Hi,

Why not use the RAW API server that is in the contribution ?

I am not using it because am using my own modified code that was created before 
the current version.
As far as I know it works nicely and many are using it ☺

I have no problems accepting a large file 1MB… never had to accept a larger 
file but I  do not think it makes
any difference.

I think that if netbuf_next() fails you need to add some delay and try again.
I mean add vTaskDelay(10) or similar and try again.

When you transfer large amount of data you may get into cases that the network 
has some lag.
In that case your netbuf_next() call nay fail.

Doing something like this:

#define READ_ERROR_DELAY  10
#define READ_ERROR_TIMEOUT500

err_t MyRead( params )
{
   Int RetVal , TotalTimeOut  = 0;

   Do
   {
  RetVal = netbuf_next();

  If(RetVal == (-1))
  {
  vTaskDelay(READ_ERROR_DELAY / portTICK_RATE_MS);
  TotalTimeOut += READ_ERROR_DELAY;
  }
  else
  {
  break;
  }

   } while(TotalTimeOut < READ_ERROR_TIMEOUT);

}


The above function will try to read from the socket and if fails it will delay 
for about 10 ms… that way you give
the TCP and other system tasks time to run.

If the above is not an option due to system constrains you can adapt some kind 
of state machine, per connection
and use lwip own function sys_timeout to trigger for the above function or 
similar.

Hope that gives some ideas…

Good luck,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Tóth Norbert
Sent: Monday, April 03, 2017 4:03 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] Transfer Mibs of data over TCP

Hi Folks,

I develop a system based on the followings:

  *   TM4C1294 TI Cortex M4 CPU
  *   FreeRTOS 7.x
  *   TinyFS for FAT file system handling on SD card
  *   LwIP 1.4.1 netconn API
I have to receive files (20-40MB) via HTTP POST request and store them into SD 
card (basically it is a simple HTTP file server).
Due to the other design decisions and the FreeRTOS, using "netconn" API seems 
to be the most suitable for me.
My problem is that it only works well with small files (20~100B) not with the 
desired sizes. I implemented the following logic looks like:

  *   wait for an incoming connection
  *   parse the HTTP header (excluding resource name and method)
  *   write the rest of data from the current pbuf
  *   repeat the following while data can be read from the connection:

 *   acquire the next "part" of data by netbuf_next()
 *   if it results -1

*   delete the current netbuf by netbuf_delete()
*   call netconn_recv() on the connection

 *   store data (if all the above result success)

Can anybody help me, what should I fix?  What did I wrong?

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

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-26 Thread Noam Weissman
Hi Simon, Jan and everyone else that was following this,

I think I have found the problem I am facing with. This is not an LwIP or 
mbedTLS error.

It is a system design issue on my part. The problem is simple and I am sure 
many other
Developers have faced it or will face it.

The problem is a classic task starvation issue. Let me explain…

I have a task that has a priority 6 and the LwIP task is running at priority 10 
(higher).
FreeRTOS is in preemptive mode.

When my module (priority 6) calls mbedTLS mbedtls_ssl_read function, like this:
 Ret = mbedTLS mbedtls_ssl_read(, pData, ReadData);

It may return a value that is less than or equal ReadData.

The problem is that in contrast to a simple read call, the SSL library will 
first read the entire
SSL record that can be as much as 16K. Only after reading the entire record it 
will decipher
it and return to the calling code with the ReadData length that was requested 
from it.

Collecting the data and deciphering is a long process that is done in a loop. 
No OS functions
are used and as a result the TCP stack and other task are not running, they are 
starved !!!

Instead of defining that the code uses the mbedtls_net_recv function I changed 
it to
mbedtls_net_recv_timeout function.

I have modified the mbedTLS net_socket.c porting and added vTaskDelay calls 
inside the code
For function mbedtls_net_recv_timeout.

Original code:
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
 uint32_t 
timeout )
{
   return mbedtls_net_recv( ctx, buf, len );
}


Modified code:
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
 uint32_t 
timeout )
{
  int RetVal, TimeOutInc, AdvancedTimeOut;


  TimeOutInc = 10;
  AdvancedTimeOut = 0;

  // add a small delay before trying to read data
  vTaskDelay(5 / portTICK_RATE_MS);

  do
  {
// try to read data from connection
RetVal = mbedtls_net_recv( ctx, buf, len );

// if function returns with an error, put a small delay
// and try again...
if(RetVal < 0)
{
  AdvancedTimeOut += TimeOutInc;
  vTaskDelay(TimeOutInc / portTICK_RATE_MS);
}
else
{
  break;
}

  } while(AdvancedTimeOut < timeout);

  return RetVal;
}
-

Preliminary testing shows that the above code works. What the code does
Is by calling the vTaskDelay it triggers the OS scheduler and actually gives 
time
to the LwIP own task.

Thanks for everyone answering and giving ideas ☺

Great work LwIP team.

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Noam Weissman
Sent: Thursday, March 16, 2017 5:58 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Simon,

I am not saying that LwIP has bugs because I am not sure… It feels like that …

I asked you why when I set debug to on and all the printouts causes lots of 
delays …  file is transferred ?

I have set LwIP:

#define TCP_MSS 536
#define MEMP_NUM_PBUF   100
#define MEM_SIZE(25 * 1024)
#define MEMP_NUM_TCP_PCB20
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_WND (4 * TCP_MSS)
#define MEMP_NUM_TCP_SEGTCP_SND_QUEUELEN

As far as I see LwIP has sufficient RAM to read the data.

I added 100ms delay after every 4K read

I changed original code to read with timeout of 1000 ms

But with all the changes I made I still am able get just 8 x 1K blocks from 
calling the mbedtls_ssl_read function

For some reason I see TCP ZeroWindow in WireShark, attached here


BR,
Noam

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of goldsimon
Sent: Thursday, March 16, 2017 5:37 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

From all information given so far, I fail to see how this would be an lwip 
problem.

Did you test your SSL application on a different platform and it worked or what 
makes you think of an lwip problem instead of an application problem?

Don't get me wrong, lwip can have bugs. I just don't see that here and by now, 
an application problem seems much more likely to me ;-)

Simon
Am 16. März 2017 13:54:15 MEZ schrieb Noam Weissman 
<n...@silrd.com<mailto:n...@silrd.com>>:

Hi Jan,

No the error I am seeing is MBEDTLS_ERR_NET_RECV_FAILED

Actually I found something interesting in my code.

Normally when you call read (fd, buf, len) the underlying TCP will fetch the 
amount you need.

With the mbedtls_ssl_read it is a bit more complicated. As it internally 
collects a record to its
own buffer before it returns to the calling part with the requested block of 
data. If you read less
than the internal SSL buffer size you may have more data to read from the 
internal b

Re: [lwip-users] heap problem with chrome

2017-03-22 Thread Noam Weissman
Hi,

I am not familiar with netconn API but I will try..

Every browser implements the protocol a bit differently. The data fields in the 
HTTP may not be
In the same order and sometimes (IE) are very long… That leads to problems when 
your code
Is very optimized and unexpected.

I found that on the hard way when I was working on HTTP myself. Use Wireshark 
and maybe
debug printouts in your own code to see what is the difference.

I suggest using the RAW API HTTP server as it is used by many programmers.

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Mohamed Hnezli
Sent: Wednesday, March 22, 2017 10:42 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] heap problem with chrome

hello again,
I am using HTTP server example using the netconn API,
I have a strict memory constraint but what makes me confused
is that there is no problem with firefox


On 21 March 2017 at 18:44, goldsi...@gmx.de 
> wrote:
Mohamed Hnezli wrote:
when reloading a tab in chrome or adding new one the server crashs. Note
that the server runs well with firefox.
Any help please ?

Last time I tested those two browsers, chrome used more simultaneous 
connections to my server than firefox. That explains the difference. Your 
server shouldn't crash though. That's a bug in your port or application and you 
should fix it :-)

Simon

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



--
Mohamed HNEZLI
Computer Science Engineer Student
  NSCS_Tunisia
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] heap problem with chrome

2017-03-21 Thread Noam Weissman
Hi Mohamed,

Part of the LwIP contributions you have working HTTP servers. Have you used one 
of these or
created something of your own ?

What is the API that you are using: RAW, Netcon or Socket ?


BR,
Noam.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Mohamed Hnezli
Sent: Tuesday, March 21, 2017 12:51 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] heap problem with chrome

hello,
I'm cuurently using SmartFusion2 SoC and LwIP ontop of FreeRTOS,
I implemented a basic HTTP server over TCP, the problem I am facing is
when reloading a tab in chrome or adding new one the server crashs. Note
that the server runs well with firefox.
Any help please ?
Thank you in advance

--
Mohamed HNEZLI
Computer Science Engineer Student
  NSCS_Tunisia
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-16 Thread Noam Weissman
Simon,

I am not saying that LwIP has bugs because I am not sure… It feels like that …

I asked you why when I set debug to on and all the printouts causes lots of 
delays …  file is transferred ?

I have set LwIP:

#define TCP_MSS 536
#define MEMP_NUM_PBUF   100
#define MEM_SIZE(25 * 1024)
#define MEMP_NUM_TCP_PCB20
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_WND (4 * TCP_MSS)
#define MEMP_NUM_TCP_SEGTCP_SND_QUEUELEN

As far as I see LwIP has sufficient RAM to read the data.

I added 100ms delay after every 4K read

I changed original code to read with timeout of 1000 ms

But with all the changes I made I still am able get just 8 x 1K blocks from 
calling the mbedtls_ssl_read function

For some reason I see TCP ZeroWindow in WireShark, attached here


BR,
Noam

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of goldsimon
Sent: Thursday, March 16, 2017 5:37 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

From all information given so far, I fail to see how this would be an lwip 
problem.

Did you test your SSL application on a different platform and it worked or what 
makes you think of an lwip problem instead of an application problem?

Don't get me wrong, lwip can have bugs. I just don't see that here and by now, 
an application problem seems much more likely to me ;-)

Simon

Am 16. März 2017 13:54:15 MEZ schrieb Noam Weissman 
<n...@silrd.com<mailto:n...@silrd.com>>:

Hi Jan,

No the error I am seeing is MBEDTLS_ERR_NET_RECV_FAILED

Actually I found something interesting in my code.

Normally when you call read (fd, buf, len) the underlying TCP will fetch the 
amount you need.

With the mbedtls_ssl_read it is a bit more complicated. As it internally 
collects a record to its
own buffer before it returns to the calling part with the requested block of 
data. If you read less
than the internal SSL buffer size you may have more data to read from the 
internal buffer but NOT
from the socket !!.

Because in my code, after every mbedtls_ssl_read I called select it would have 
failed on the last
fragment even so that the SSL internal buffer still had some data. I added code 
to check that
ssl.in_msglen == 0 before I call select again. This solved one problem but NOT 
the overall reading
problem.

If I also added large delays in code so now I am able to read 8 x 1K chunks 
before I get again the
MBEDTLS_ERR_NET_RECV_FAILED

This is a combined problem... misunderstanding how the SSL works and probably 
something related
to the LwIP layer.

If I print LwIP debug messages I have no problems reading the file. ... delays 
???

I also changed the call to mbedtls_ssl_set_bio to use the 
mbedtls_net_recv_timeout instead of
mbedtls_net_recv function. With this change I am able to read the first SSL 
record without problems

Thanks for all the help so far :-)


BR,
Noam.

-Original Message-
From: lwip-users 
[mailto:lwip-users-bounces+noam=silrd.com<http://silrd.com>@nongnu.org] On 
Behalf Of Jan Menzel
Sent: Wednesday, March 15, 2017 10:54 PM
To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Hi Noam!
 Did you follow the error code through mbedtls's net.c? In my code its 
translated into "MBEDTLS_ERR_SSL_WANT_READ" as follows:

int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ) [...]
ret = (int) read( fd, buf, len );

if( ret < 0 )
{
if( net_would_block( ctx ) != 0 )
return( MBEDTLS_ERR_SSL_WANT_READ ); [...]

with

static int net_would_block( const mbedtls_net_context *ctx ) [...]
switch( errno )
{
#if defined EAGAIN
case EAGAIN:
#endif
#if defined EWOULDBLOCK && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
return( 1 );
}
    return( 0 );
}

 Jan

On 15.03.2017 20:30, Noam Weissman wrote:

 Hi Simon,

 I have triad debugging my code and added :
 #define LWIP_DEBUG LWIP_DBG_ON
 #define SOCKETS_DEBUG  LWIP_DBG_ON

 Strange that with this switches on I am able to get a file of about 38K but it 
fails at the last part, always?.

 Without the debug prints it never even starts, it fails on first read.

 I have attached my debug printout if that helps.

 The text is mixed with my own debug prints, sorry:

 File transfer starts at line 438 with:  From WssHandleReadData:
 PayloadLen = 38032, DataLen = 1020

 The server sends chunks of 4K, my code reads 1K at a time from the ssl layer 
hence the 1024 chunks.
 You can see that PayloadLen reduces by the DataLen chunk ...

 The last part received is PayloadLen 1172 DataLen 1024 ... on line
 1512

 It should read one 1024 block and then 148 bytes and finish... This
 never happens and it fails on last read This is consistent on every test I did 
?.

 If I turn off the two debug switches the file transfe

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-16 Thread Noam Weissman
Hi Jan,

No the error I am seeing is MBEDTLS_ERR_NET_RECV_FAILED

Actually I found something interesting in my code.

Normally when you call read (fd, buf, len) the underlying TCP will fetch the 
amount you need.

With the mbedtls_ssl_read it is a bit more complicated. As it internally 
collects a record to its
own buffer before it returns to the calling part with the requested block of 
data. If you read less 
than the internal SSL buffer size you may have more data to read from the 
internal buffer but NOT 
from the socket !!. 

Because in my code, after every mbedtls_ssl_read I called select it would have 
failed on the last
fragment even so that the SSL internal buffer still had some data. I added code 
to check that 
ssl.in_msglen == 0 before I call select again. This solved one problem but NOT 
the overall reading 
problem.

If I also added large delays in code so now I am able to read 8 x 1K chunks 
before I get again the 
MBEDTLS_ERR_NET_RECV_FAILED

This is a combined problem... misunderstanding how the SSL works and probably 
something related
to the LwIP layer.

If I print LwIP debug messages I have no problems reading the file. ... delays 
???

I also changed the call to mbedtls_ssl_set_bio to use the 
mbedtls_net_recv_timeout instead of 
mbedtls_net_recv function. With this change I am able to read the first SSL 
record without problems

Thanks for all the help so far :-)


BR,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Jan Menzel
Sent: Wednesday, March 15, 2017 10:54 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Hi Noam!
Did you follow the error code through mbedtls's net.c? In my code its 
translated into "MBEDTLS_ERR_SSL_WANT_READ" as follows:

int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ) [...]
ret = (int) read( fd, buf, len );

if( ret < 0 )
{
if( net_would_block( ctx ) != 0 )
return( MBEDTLS_ERR_SSL_WANT_READ ); [...]

with

static int net_would_block( const mbedtls_net_context *ctx ) [...]
switch( errno )
{
#if defined EAGAIN
case EAGAIN:
#endif
#if defined EWOULDBLOCK && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
return( 1 );
}
return( 0 );
}

Jan

On 15.03.2017 20:30, Noam Weissman wrote:
> Hi Simon,
> 
> I have triad debugging my code and added :
> #define LWIP_DEBUG LWIP_DBG_ON
> #define SOCKETS_DEBUG  LWIP_DBG_ON
> 
> Strange that with this switches on I am able to get a file of about 38K but 
> it fails at the last part, always?.
> 
> Without the debug prints it never even starts, it fails on first read. 
> 
> I have attached my debug printout if that helps.
> 
> The text is mixed with my own debug prints, sorry:
> 
> File transfer starts at line 438 with:  From WssHandleReadData: 
> PayloadLen = 38032, DataLen = 1020
> 
> The server sends chunks of 4K, my code reads 1K at a time from the ssl layer 
> hence the 1024 chunks.
> You can see that PayloadLen reduces by the DataLen chunk ...
> 
> The last part received is PayloadLen 1172 DataLen 1024 ... on line 
> 1512
> 
> It should read one 1024 block and then 148 bytes and finish... This 
> never happens and it fails on last read This is consistent on every test I 
> did ?.
> 
> If I turn off the two debug switches the file transfer never starts, 
> actually fails on first read and the lwip_recvfrom returns with -1 and 
> set_errno(EWOULDBLOCK); on line 773 in sockets.c (lwip ver 2.02)
> 
> 
> Any ideas ?
> 
> 
> Many thanks,
> Noam.
> 
> 
> 
> -Original Message-
> From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] 
> On Behalf Of Simon Goldschmidt
> Sent: Friday, March 10, 2017 10:36 AM
> To: lwip-users@nongnu.org
> Subject: Re: [lwip-users] PolarSSL and mbedTLS
> 
> Noam Weissman wrote:
>> I get a read error inside lwip_recvfrom function.
>> [..]
>> If anyone has any ideas on what more to check or test please respond.
> 
> 1: Get an idea of the error (if recvfrom returns -1, what's the 
> corrent errno?)
> 2: Get a debugger and try to find out why recvfrom returns an error. Without 
> that information, there's no way of knowing where the error is.
> 
> 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
> 

___
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] PolarSSL and mbedTLS

2017-03-15 Thread Noam Weissman
Hi Simon,

I have triad debugging my code and added :
#define LWIP_DEBUG LWIP_DBG_ON
#define SOCKETS_DEBUG  LWIP_DBG_ON

Strange that with this switches on I am able to get a file of about 38K but it 
fails at the last part, always?.

Without the debug prints it never even starts, it fails on first read. 

I have attached my debug printout if that helps.

The text is mixed with my own debug prints, sorry:

File transfer starts at line 438 with:  From WssHandleReadData: PayloadLen = 
38032, DataLen = 1020

The server sends chunks of 4K, my code reads 1K at a time from the ssl layer 
hence the 1024 chunks.
You can see that PayloadLen reduces by the DataLen chunk ...

The last part received is PayloadLen 1172 DataLen 1024 ... on line 1512

It should read one 1024 block and then 148 bytes and finish... This never 
happens and it fails on last read
This is consistent on every test I did ?.

If I turn off the two debug switches the file transfer never starts, actually 
fails on first read and the lwip_recvfrom
returns with -1 and set_errno(EWOULDBLOCK); on line 773 in sockets.c (lwip ver 
2.02)


Any ideas ?


Many thanks,
Noam.



-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Simon Goldschmidt
Sent: Friday, March 10, 2017 10:36 AM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Noam Weissman wrote:
> I get a read error inside lwip_recvfrom function.
> [..]
> If anyone has any ideas on what more to check or test please respond.

1: Get an idea of the error (if recvfrom returns -1, what's the corrent errno?)
2: Get a debugger and try to find out why recvfrom returns an error. Without 
that information, there's no way of knowing where the error is.

Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
ETH Link is: ON
State: Looking for DHCP server ...
IP address set to:  192.168.0.101
Net Mask value set to:  255.255.255.0
Gateway IP address set to:  192.168.0.1
DNS #1 IP set to:  192.168.7.3
DNS #2 IP set to:  192.168.7.4

The RTC time is:
  Wed Mar 15 2017  19:12:52


WSS : Start the connection

Connecting to tcp: 192.168.0.100, Port:8080...
lwip_socket(, SOCK_STREAM, 134343619) = 
536998620

lwip_connect(536999332, addr=
536999332.134339789.100.1677764800
 port=536999332)

lwip_connect(536999332) succeeded

 Ok !

Setting up the SSL/TLS structure... ok !
lwip_send(0, data=0801e735, size=0, flags=0x19a)

lwip_send(536967280) err=134342577 written=536908632

lwip_recvfrom(0, 0801e0fb, 0, 0x801e998, ..)

lwip_recvfrom: top while sock->lastdata=20017870

lwip_recvfrom: netconn_recv err=536967280, netbuf=0801e1ab

lwip_recvfrom: buflen=536967280 len=134341207 off=0 sock->lastoffset=134343064

lwip_recvfrom(536967280): addr=
536967280.134341457.100.134343064
 port=536967280 len=134341477

lwip_recvfrom: lastdata now netbuf=20017870

lwip_recvfrom(0, 0801e0fb, 0, 0x801e998, ..)

lwip_recvfrom: top while sock->lastdata=20017870

lwip_recvfrom: buflen=536967280 len=134341207 off=5 sock->lastoffset=134343064

lwip_recvfrom(536967280): addr=
536967280.134341457.100.134343064
 port=536967280 len=134341477

lwip_recvfrom: deleting netbuf=20017870

lwip_recvfrom(0, 0801e0fb, 0, 0x629fee1d, ..)

lwip_recvfrom: top while sock->lastdata=20017870

lwip_recvfrom: netconn_recv err=536967280, netbuf=0801e1ab

lwip_recvfrom: buflen=536967280 len=134341207 off=0 sock->lastoffset=1654648349

lwip_recvfrom(536967280): addr=
536967280.134341457.100.1654648349
 port=536967280 len=134341477

lwip_recvfrom: lastdata now netbuf=20017870

lwip_recvfrom(0, 0801e0fb, 0, 0x629fee1d, ..)

lwip_recvfrom: top while sock->lastdata=20017870

lwip_recvfrom: buflen=536967280 len=134341207 off=5 sock->lastoffset=1654648349

lwip_recvfrom: deleting netbuf=20017870

lwip_recvfrom: top while sock->lastdata=20017870

lwip_recvfrom: netconn_recv err=536967280, netbuf=0801e1ab

lwip_recvfrom: buflen=536967280 len=134341207 off=0 sock->lastoffset=1654648349

lwip_recvfrom(536967280): addr=
536967280.134341457.100.1654648349
 port=536967280 len=134341477

lwip_recvfrom: deleting netbuf=20017870

lwip_recvfrom(0, 0801e0fb, 0, 0x4, ..)

lwip_recvfrom: top while sock->lastdata=20017870

lwip_recvfrom: netconn_recv err=536967280, netbuf=0801e1ab

lwip_recvfrom: buflen=536967280 len=134341207 off=0 sock->lastoffset=4

lwip_recvfrom(536967280): addr=
536967280.134341457.100.4
 port=536967280 len=134341477

lwip_recvfrom: lastdata now netbuf=20017870

lwip_recvfrom(0, 0801e0fb, 0, 0x4, ..)

lwip_recvfrom: top while sock->lastdata=20017870

lwip_recvfrom: buflen=536967280 len=134341207 off=5 sock->lastoffset=4

lwip_recvfrom(536967280): addr=
536967280.134341457.100.4
 port=536967280 len=134341477

lwip_recvfrom: deleting netbuf=20017870

lwip_recvfrom(0, 0801e0fb, 0, 0x20009348, ..

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-14 Thread Noam Weissman
Hi Jan,

I have added parameter to the conf structure by using the function 
mbedtls_ssl_conf_max_frag_len

I have tested my client against a test server based on mbedTLS library and it 
worked !

When I triad my client side against the actual server it did not work. So it 
may not support
" Maximum Fragment Length Negotiation" option as you have mentioned.

In any case I need to integrate with the server continue the work.

Thanks,
Noam.



-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Jan Menzel
Sent: Tuesday, March 14, 2017 4:36 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Hi Noam!
IIRC this options is not widely implemented. Especially openssl seems 
to lack it. If you configure a short FRAGMENT_LENGTH and the other side does 
not respect the option, transfer of large data blocks (>~
FRAGMENT_LENGTH) will not be possible.

Jan

On 12.03.2017 10:05, Noam Weissman wrote:
> Hi Jan, Simon...
> 
>  
> 
> I have found a solution that seems to work J...
> 
>  
> 
> A college of mine working on the server side pointed me to RFC 6066 
> were there is an option to request
> 
> the server to limit the sent fragment size:
> 
> https://tools.ietf.org/html/rfc6066#page-8
> 
>  
> 
> The above is part of the RFC without the need to change anything in 
> LwIP or mbedTLS code. It's a simple
> 
> configuration issue.
> 
>  
> 
> I have added to my code the following:
> 
> 1.   I defined MBEDTLS_SSL_MAX_FRAGMENT_LENGTH in mbedtls_config.h
> 
> 2.   I added a call to mbedtls_ssl_conf_max_frag_len(,
> MBEDTLS_SSL_MAX_FRAG_LEN_1024);
> 
>  
> 
> The above adds an extra parameter in the SSL/TLS handshake... actually 
> adds it in the HELLO handshake.
> 
>  
> 
> I need to make a few more tests but it seems to work and have no 
> problems sending even a 600K binary file.
> 
>  
> 
> I still did not catch why lwip_recvfrom function failed but the above 
> seems to be working.
> 
>  
> 
> Thanks for everyone that puts their inputs J
> 
>  
> 
> If I will have an update I will update the group.
> 
>  
> 
> BR,
> 
> Noam.
> 
>  
> 
> *From:*lwip-users 
> [mailto:lwip-users-bounces+noam=silrd@nongnu.org]
> *On Behalf Of *Noam Weissman
> *Sent:* Sunday, March 12, 2017 12:39 AM
> *To:* Mailing list for lwIP users
> *Subject:* Re: [lwip-users] PolarSSL and mbedTLS
> 
>  
> 
> Hi Simon,
> 
>  
> 
> with SSL there is a read for 5 bytes record header and then reading 
> the data itself as a whole
> 
> or in parts (inside lwip_recvfrom).
> 
>  
> 
> My module is a single task that has a state machine. When the state is 
> in OPEN state it blocks
> 
> for 1 second on select, if select is returning with a timeout the task 
> is doing some house keeping
> 
> and returns to the OPEN state for another select etc...
> 
>  
> 
> If select is returning with 1, meaning there is data, the code issues 
> mbedtls_ssl_read etc...
> 
> The SSL code reads the 5 bytes header but fails after that. The fail 
> happens if the sending
> 
> record is more then a few K bytes. The strange thing is that it fails 
> on the first read ?
> 
>  
> 
> If it would have failed after a few blocks that were read then we 
> could assume that there
> 
> is another problem but it fails on the first read just after the 5 
> bytes header were read ?
> 
>  
> 
> My hunch is that its something stupid :-)
> 
>  
> 
> BR,
> 
> Noam.
> 
> --
> --
> 
> *From:*lwip-users <lwip-users-bounces+noam=silrd@nongnu.org
> <mailto:lwip-users-bounces+noam=silrd@nongnu.org>> on behalf of 
> goldsi...@gmx.de <mailto:goldsi...@gmx.de> <goldsi...@gmx.de 
> <mailto:goldsi...@gmx.de>>
> *Sent:* Saturday, March 11, 2017 11:29 PM
> *To:* Mailing list for lwIP users
> *Subject:* Re: [lwip-users] PolarSSL and mbedTLS
> 
>  
> 
> Noam,
> 
> that sounds a bit too complicatied...
> 
> My first thought is: you call select and it returns that there is data 
> to read, but that does not mean there is enough data to read for TLS, 
> so EWOULDBLOCK is not an error at all in this case.
> 
> Simon
> 
> ___
> lwip-users mailing list
> lwip-users@nongnu.org <mailto:lwip-users@nongnu.org> 
> https://lists.nongnu.org/mailman/listinfo/lwip-users
> 
> lwip-users -- Mailing list for lwIP users - lists.nongnu.org 
> <https://lists.nongnu.org/mailman/listinfo/lwip-users>

Re: [lwip-users] lwip 1.4.1 -> 2.0.1: problem with dhcp

2017-03-14 Thread Noam Weissman
Hi Markus,

As a skeleton there is no change. Maybe you need wait until you have a link
Or that your driver takes longer to finish initializing.

BR,
Noam.



From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of markus.l...@gmx.ch
Sent: Tuesday, March 14, 2017 4:08 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] lwip 1.4.1 -> 2.0.1: problem with dhcp

The upgrade from lwip 1.4.1 to 2.0.1 workes fine. Just with dhcp I've got some 
troubles.

With version 1.4.1 the following initialization was perfect:


static void InitEthernetAdapter(void)

{

netif_set_default(.);

netif_set_status_callback(.);

netif_set_link_callback(.);

// Start with dhcp

if (_useDhcp)

{

  dhcp_start(&_netif);

}

// Start with static ip address

else
{

  netif_set_up(&_netif);

}

}

With lwip 2.0.1 the network doesn't start with dhcp. Static ip is fine. Do I 
have to add something else to start with dhcp?

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

Re: [lwip-users] lwip_select never returns value > 0

2017-03-14 Thread Noam Weissman
Hi,

Try using:

tv.tv_sec = 1;
tv.tv_usec = 0;

It works for me

BR,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of pekez
Sent: Tuesday, March 14, 2017 2:19 PM
To: Mailing list for lwIP users
Subject: [lwip-users] lwip_select never returns value > 0

Hi people,

I am trying to use lwip_select in combination with lwip_recv. I have done it 
like this so far:

FD_ZERO();
FD_SET(new_sd, );
tv.tv_sec = 0;
tv.tv_usec = 20;

if (lwip_select(new_sd + 1, , NULL, NULL, ) > 0) {
 lwip_recv()

}

No matter what, timeout always exceeds. Am I doing anything wrong? 
Should I include some lwip option in order to use lwip_select()?
I am using lwip v1.4.1.

Regards,
Nenad


___
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] Upgrading from 1.4.x to 2.0.2

2017-03-14 Thread Noam Weissman
Hi Jeff,

Here are the changes I made:

Create a structured project and under LwIP leaf create:
Api
Core
IPv4
Netif

In 1.41 you have file named timers.c that collide with timers.c from 
FreeRTOS... I changed the file name but in 2.xx it was
changed from timers.c to timouts.c so there is no need change the file name.

Under Netif there was the etharp.c but that moved (logically) to IPv4 leaf

Under Netif two new files were added: ethernet.c  and  lowpan6.c

There are also some changes in sys_arch file. I have attached my own sys_arch 
files that are a mix from a file I found long
ago and my added new changes, based on ST files.

I suggest taking a cube project with the latest LwIP as the base line to 
compare.

The drivers are the same.


BR,
Noam.


From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Wormsley, Jeffrey (Jeff)
Sent: Tuesday, March 14, 2017 12:00 AM
To: lwip-users@nongnu.org
Subject: [lwip-users] Upgrading from 1.4.x to 2.0.2

I'm trying to upgrade a project from 1.4.x to 2.0.2.  The project is on 
STM32F417 generated from CubeMX using IAR, FreeRTOS and wolfSSL.  It's the demo 
WolfMQTT app if anyone has that to compare to.

I've managed to build all of the search paths and file structure for 2.0.2 ok, 
and the project compiles, but then fails to link.  At issue is changes 
revolving around etharp.c, ethernet.c and ethernetif.c.  The original project 
apparently uses etharp.c and a function called etharp_send_ip() in multiple 
places for sending packets, but the 2.0.2 code expects this to be done from 
ethernet_output(), which my project doesn't even have.  Other missing bits 
include ethzero, ethbroadcast and ethernet_input().  I think ethzero and 
ethbroadcast could be copied from the sample ethernet.c that came with 2.0.2.  
Or is that code expected to be the only ethernet.c in the project, and the 
ethernet.c that CubeMX generated should be renamed or something?

Not being the person who originally built this project, I'm somewhat at a loss 
as to where to proceed.  Anyone have any pointers for moving from 1.4.x to 
2.0.2 in a CubeMX STM32F4xx environment?

Thanks,
  Jeff.

/*
 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *this list of conditions and the following disclaimer in the documentation
 *and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 * Author: Adam Dunkels 
 *
 */

//*
//
// Include OS functionality.
//
//*

/*  System architecture includes 
- */

/*  lwIP includes - */

#include "lwip/debug.h"
#include "lwip/def.h"
#include "lwip/sys.h"
#include "lwip/mem.h"
#include "lwip/stats.h"

/* Very crude mechanism used to determine if the critical section handling
functions are being called from an interrupt context or not.  This relies on
the interrupt handler setting this variable manually. */
volatile portBASE_TYPE xInsideISR = pdFALSE;

#if defined(LWIP_SOCKET_SET_ERRNO) && defined(LWIP_PROVIDE_ERRNO)
int errno;
#endif

/*---*
 * Routine:  sys_mbox_new
 *---*
 * Description:
 *  Creates a new mailbox
 * Inputs:
 *  int size-- Size of elements in the mailbox
 * Outputs:
 *  sys_mbox_t  -- Handle to new mailbox
 

Re: [lwip-users] lwIP 2.0.2 released

2017-03-13 Thread Noam Weissman
Great,

Thanks for all the hard work :-)

BR,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Simon Goldschmidt
Sent: Monday, March 13, 2017 2:41 PM
To: lwip-users@nongnu.org; lwip-de...@nongnu.org
Subject: Re: [lwip-users] lwIP 2.0.2 released

Sorry Guys,

git tag has changed to "STABLE-2_0_2_RELEASE_VER" (I forgot to fix the 
LWIP_VERSION define).

Cheers,
Simon


Simon Goldschmidt wrote:
> lwIP 2.0.2 is now available from the lwIP download area on savannah or via 
> git (using the STABLE-2_0_2_RELEASE tag).
> This is a small step release only to fix some bugs since 2.0.1 (see 
> CHANGELOG). Contrib is not updated (contrib 2.0.1 is still valid).
> Thanks to all contributors!
> 
> 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] PolarSSL and mbedTLS

2017-03-12 Thread Noam Weissman
Hi Jan, Simon...

I have found a solution that seems to work :)...

A college of mine working on the server side pointed me to RFC 6066 were there 
is an option to request
the server to limit the sent fragment size:
https://tools.ietf.org/html/rfc6066#page-8

The above is part of the RFC without the need to change anything in LwIP or 
mbedTLS code. It's a simple
configuration issue.

I have added to my code the following:

1.   I defined MBEDTLS_SSL_MAX_FRAGMENT_LENGTH in mbedtls_config.h

2.   I added a call to mbedtls_ssl_conf_max_frag_len(, 
MBEDTLS_SSL_MAX_FRAG_LEN_1024);

The above adds an extra parameter in the SSL/TLS handshake... actually adds it 
in the HELLO handshake.

I need to make a few more tests but it seems to work and have no problems 
sending even a 600K binary file.

I still did not catch why lwip_recvfrom function failed but the above seems to 
be working.

Thanks for everyone that puts their inputs :)

If I will have an update I will update the group.

BR,
Noam.

From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Noam Weissman
Sent: Sunday, March 12, 2017 12:39 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS


Hi Simon,



with SSL there is a read for 5 bytes record header and then reading the data 
itself as a whole

or in parts (inside lwip_recvfrom).



My module is a single task that has a state machine. When the state is in OPEN 
state it blocks

for 1 second on select, if select is returning with a timeout the task is doing 
some house keeping

and returns to the OPEN state for another select etc...



If select is returning with 1, meaning there is data, the code issues 
mbedtls_ssl_read etc...

The SSL code reads the 5 bytes header but fails after that. The fail happens if 
the sending

record is more then a few K bytes. The strange thing is that it fails on the 
first read ?


If it would have failed after a few blocks that were read then we could assume 
that there

is another problem but it fails on the first read just after the 5 bytes header 
were read ?



My hunch is that its something stupid :-)



BR,

Noam.


From: lwip-users 
<lwip-users-bounces+noam=silrd@nongnu.org<mailto:lwip-users-bounces+noam=silrd@nongnu.org>>
 on behalf of goldsi...@gmx.de<mailto:goldsi...@gmx.de> 
<goldsi...@gmx.de<mailto:goldsi...@gmx.de>>
Sent: Saturday, March 11, 2017 11:29 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Noam,

that sounds a bit too complicatied...

My first thought is: you call select and it returns that there is data
to read, but that does not mean there is enough data to read for TLS, so
EWOULDBLOCK is not an error at all in this case.

Simon

___
lwip-users mailing list
lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users -- Mailing list for lwIP users - 
lists.nongnu.org<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-11 Thread Noam Weissman
Hi Simon,


with SSL there is a read for 5 bytes record header and then reading the data 
itself as a whole

or in parts (inside lwip_recvfrom).


My module is a single task that has a state machine. When the state is in OPEN 
state it blocks

for 1 second on select, if select is returning with a timeout the task is doing 
some house keeping

and returns to the OPEN state for another select etc...


If select is returning with 1, meaning there is data, the code issues 
mbedtls_ssl_read etc...

The SSL code reads the 5 bytes header but fails after that. The fail happens if 
the sending

record is more then a few K bytes. The strange thing is that it fails on the 
first read ?


If it would have failed after a few blocks that were read then we could assume 
that there

is another problem but it fails on the first read just after the 5 bytes header 
were read ?


My hunch is that its something stupid :-)


BR,

Noam.


From: lwip-users  on behalf of 
goldsi...@gmx.de 
Sent: Saturday, March 11, 2017 11:29 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Noam,

that sounds a bit too complicatied...

My first thought is: you call select and it returns that there is data
to read, but that does not mean there is enough data to read for TLS, so
EWOULDBLOCK is not an error at all in this case.

Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users -- Mailing list for lwIP users - 
lists.nongnu.org
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-11 Thread Noam Weissman
Hi Simon,


In my first mail regarding this situation I wrote the errno but hear it is 
again. It is EWOULDBLOCK


>From checking again the net_socket.c file from mbedTLS I see that they have 
>two function:

mbedtls_net_recv<https://tls.mbed.org/api/net_8h.html#a03af351ec420bbeb5e91357abcfb3663>
 and 
mbedtls_net_recv_timeout<https://tls.mbed.org/api/net_8h.html#a67810154d2328a80b146155d8cdecfd9>


The difference is that 
mbedtls_net_recv_timeout<https://tls.mbed.org/api/net_8h.html#a67810154d2328a80b146155d8cdecfd9>
 use select to block for a timeout and then

call mbedtls_net_recv function.


I use select in my own code and set the socket for no blocking before calling 
the underlaying

mbed_ssl_read that down the calling sequence calls the mbed_net_recv function 
... that

eventually calls lwip_recvfrom


I am planing to play with the socket option tomorrow (bloc, not blocking 
etc...) but I wonder

if the fact that I am setting the socket to none blocking can cause the read 
error I have.

Do remember that I only call the reading function after select returns with 1 
.. meaning there is

data to read.


BR,

Noam.




From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsi...@gmx.de <goldsi...@gmx.de>
Sent: Saturday, March 11, 2017 9:34 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Noam Weissman wrote:
I am not ignoring the fact that it may be the driver or definitions but I am 
simply asking

for leads...

That's what I thought I gave in the last mail. OTOH, for getting the errno set 
by recvfrom, you don't have to be an lwIP developer...

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

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-10 Thread Noam Weissman
Simon,


I did use a debugger and that is how I found that it is from within recvfrom ...


As I am only a user and not the developer of LwIP I am asking for tips on how 
to catch

the problem. I am not familiar with the low level internals of LwIP so that is 
difficult to

find the cause.


I am not ignoring the fact that it may be the driver or definitions but I am 
simply asking

for leads...


I will try to get more info on that next week.


Have a great weekend,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Simon Goldschmidt <goldsi...@gmx.de>
Sent: Friday, March 10, 2017 10:35 AM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Noam Weissman wrote:
> I get a read error inside lwip_recvfrom function.
> [..]
> If anyone has any ideas on what more to check or test please respond.

1: Get an idea of the error (if recvfrom returns -1, what's the corrent errno?)
2: Get a debugger and try to find out why recvfrom returns an error. Without 
that information, there's no way of knowing where the error is.

Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users -- Mailing list for lwIP users - 
lists.nongnu.org<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] SSH - Raw API

2017-03-10 Thread Noam Weissman
Hi Sergio,


Embedded Linux uses lots of RAM and is much more complicated from FreeRTOS.


Even is we eventually will add external RAM, say 16-32M or more I still prefer 
the

FreeRTOS [] .


As for all the apss that are running in the device its a a must, system 
requirements.


I am sure that eventually (like always) the problem will be solved, one way or 
another.


BR,

Noam.




From: lwip-users  on behalf of 
Sergio R. Caprile 
Sent: Friday, March 10, 2017 2:50 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] SSH - Raw API

As long as you have the memory and CPU resources, you can have an RTOS
and as many threads as you can, with all the apps you need. lwIP main
core and RAW API apps will run on a thread, other apps with their
netconn/socket APIs on their respective threads.

The point is... do you actually _NEED_ those apps ?

So many embedded needs can be solved with a web server running CGIs and
serving javascripts.
If you _DO_ need all the bells and whistles of a full fledged host, you
might consider running embedded Linux instead.


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users -- Mailing list for lwIP users - 
lists.nongnu.org
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] Telnet - Raw API

2017-03-10 Thread Noam Weissman
Hi Sergio,


Long time :-) ...


Yes I am aware of what you wrote. Inside the recvfrom function this is actually 
what the

function is doing... copying in parts from the chained buffers until it gets 
all the data it

needs.


LwIP has sufficient RAM (22K) and PCB's (80) so it should be ok ?


Will continue the testing next week. Hope to have some insight why it happens...


Have a nice weekend,

Noam.





From: lwip-users  on behalf of 
Sergio R. Caprile 
Sent: Friday, March 10, 2017 2:22 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] Telnet - Raw API

A pbuf can be a single one or a chain of them, and your app gets what
the rx driver got, so most likely you can't tell in advance and have to
be prepared to just deal with it.
If you can spare the memory, you can copy to a buffer and be happy. But
if you can't spare it, there are pbuf_ functions that provide some basic
operations for typical actions on typical application work; like
searching for a string.
In a web server, for example, you need to parse the host headers, but
they can come in several frames (due to TCP operation), and those frames
may themselves be chains of pbufs (due to memory fragmentation). A
common practice is to intentionally chain incoming pbufs until you get
the expected length, and then parse the pbuf chain for the expected
data. If memory is available, you might just copy everything to a big
enough buffer.




___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users -- Mailing list for lwIP users - 
lists.nongnu.org
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-10 Thread Noam Weissman
Hi Jan,


As a continuation to our previous correspondence we had so far.


Just to remind you all, I have an STM32F427 (192+64 K RAM) running FreeRTOS 9

LwIP 2.01 and mbedTLS 2.xx (do not remember) ... All of the 64K is dedicated for

compiler heap, actually for SSL as all other memory usage is static.


I have created a WebSocket client that works well but when I try to transfer a 
binary file

larger then a few K bytes I get a read error inside lwip_recvfrom function.


I have created a test server running mbedTLS on windows (unlimited resources). 
I am able to

transfer a large file (600K) when I send data in small chunks of 1K byte. If I 
try to to send 2K byte

chunks the client start receiving data but after some 10 blocks stops... If I 
try to send 4K blocks

the client fails on first block read.


>From what I see the SSL layer reads a record header (5 bytes). The header has 
>the record size,

then it calls lwip_recvfrom and inside it makes multiple reads in order to 
collect the requested

record data.


My MSS is 536 bytes, I have more then needed pBuf etc so It seems either a bug 
on LwIP code

or in the interrupt+DMA driver part.


If anyone has any ideas on what more to check or test please respond.



BR,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Noam Weissman <n...@silrd.com>
Sent: Friday, March 3, 2017 5:50 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS


Hi Jan,


Thanks for a super reply. I will check it first thing next week. You are correct

in regards to the errors. The error I have pointed out is actually the errno 
inside

lwip_recvfrom function.


The lwip_recvfrom returns (-1) and  ssl_read in net_socket returns with the 
error

you pointed out.


I will check all the points you mentioned.


Thanks again, have a great weekend,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Jan Menzel <men...@peperoni-light.de>
Sent: Friday, March 3, 2017 5:29 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Hi Noam! Hi Simon!
I'm using mbedtls v2.2.1 and lwip 2.0.0RC2 without problems. I can't
remember that I've ever seen the EWOULDBLOCK error. In the interface
code between mbedtls and lwip I found a few references to EWOULDBLOCK.
There are also a few fcntl() calls to enable/disable blocking. Maybe
thats where Noams problem is coming from.
In my lwipopts.h I've enabled LWIP_SO_RCVTIMEO, LWIP_SO_SNDTIMEO and
LWIP_SO_LINGER but that might be to send out data on the same socket
while no data has been received. I'm not sure it that was also needed to
set the socket non-blocking. I also defined "ERRNO" at the same place
and noted that this was required for mbedtls net.c (the interface to
lwip) to handle non-blocking sockets.
Noam, I'd suggest that you check if mbedtls_net_set_nonblock()/block()
(all in mbedtls's net.c) is used and if net_would_block() works
correctly. I had to undefine "errno" and make it a global variable of
type int to get it working. My mbedtls_net_recv() returns
MBEDTLS_ERR_SSL_WANT_READ if read() < 0 and net_would_block() != 0. This
probably overwrites lwips EWOULDBLOCK error.
Finally, I had lots of issues with the stack mbedtls is used in. Ok, my
LPC1768 has almost no memory, but IIRC I had to modify ctr_drbg.c
heavily to safe ~2k. This probably does not affect you as the F4xx has
IIRC a build-in hardware random number generator.

Jan

On 02.03.2017 13:11, Noam Weissman wrote:
> Hi Simon,
>
> I was able to catch the error inside function lwip_recvfrom, to remind you 
> this is read from
> PolarSSL
>
> It returns from here:
>LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", 
> s));
>
> The read buffer is large and it does have a problem, length is 14829 ?
>
> Any ideas ??
>
> BR,
> Noam.
>
> -Original Message-
> From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
> Behalf Of goldsi...@gmx.de
> Sent: Wednesday, March 01, 2017 9:27 PM
> To: Mailing list for lwIP users
> Subject: Re: [lwip-users] PolarSSL and mbedTLS
>
> I did have mbedTLS running against our httpd (no sockets) but the resource 
> usage was rather high.
> I'd imagine the problem could be lwIP's memory configurations here, too.
>
> Simon
>
>
> Jan Menzel wrote:
>> Hi Noam!
>>   I've designed a system with almost the same setup which works well
>> since a few years incl. firmware updates of a ~200kb.
>>   Did you checked the memory consumption of the ip stack and the ssl
>> max content length setting? The default max content length setting is
>> IIRC 16kb, which means that data is hashed and encrypte

Re: [lwip-users] Telnet - Raw API

2017-03-03 Thread Noam Weissman
Hi Nick,


I will answer you next week, I have a minimal telnet server but it is

not exactly what you need, you will have to change it to suit your need.


Please write to my work mail n...@silrd.com and we will continue from there.


BR,

Noam.



From: lwip-users  on behalf of 
nrichard 
Sent: Friday, March 3, 2017 10:54 PM
To: lwip-users@nongnu.org
Subject: [lwip-users] Telnet - Raw API

Hello everyone!

I'm looking to get a telnet application working using the RAW API for lwip.
My goal is to have a simple console-like menu where each menu option will do
something when selected.  When searching for an example, all I could really
find is the TCP echo server (in the lwip contrib folder), which is
relatively close to what I want.  Rather than echoing, I want it to print a
menu and I'm able to select whichever option I'd like.

I was able to modify it slightly to print my menu to the telnet client over
and over when I type a character, but I'm having trouble trying to read the
input (so I know which menu operation to do).  The input comes in as a
pbuf->payload which is a void*.  At first I wanted to use a switch, but the
payload isn't an integer.  I tried casting it as an integer as well and that
also did not work.  I then tried an if statement using it as a string since
I can print it as a string.  For example, if (payload == "1") and that did
not work either.

So I guess my question is, how could I be able to read the incoming
payload/character so that I could do something with it?  Or is there a
better way of doing this?  Are there better telnet application examples out
there somewhere that achieve what I'm trying to do?

Thanks
-Nick



--
View this message in context: 
http://lwip.100.n7.nabble.com/Telnet-Raw-API-tp28928.html
lwip-users - Telnet - Raw 
API
lwip.100.n7.nabble.com
Telnet - Raw API. Hello everyone! I'm looking to get a telnet application 
working using the RAW API for lwip. My goal is to have a simple console-like 
menu where each menu option will do something...


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 for lwIP users - 
lists.nongnu.org
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-03 Thread Noam Weissman
Hi Jan,


Thanks for a super reply. I will check it first thing next week. You are correct

in regards to the errors. The error I have pointed out is actually the errno 
inside

lwip_recvfrom function.


The lwip_recvfrom returns (-1) and  ssl_read in net_socket returns with the 
error

you pointed out.


I will check all the points you mentioned.


Thanks again, have a great weekend,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Jan Menzel <men...@peperoni-light.de>
Sent: Friday, March 3, 2017 5:29 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Hi Noam! Hi Simon!
I'm using mbedtls v2.2.1 and lwip 2.0.0RC2 without problems. I can't
remember that I've ever seen the EWOULDBLOCK error. In the interface
code between mbedtls and lwip I found a few references to EWOULDBLOCK.
There are also a few fcntl() calls to enable/disable blocking. Maybe
thats where Noams problem is coming from.
In my lwipopts.h I've enabled LWIP_SO_RCVTIMEO, LWIP_SO_SNDTIMEO and
LWIP_SO_LINGER but that might be to send out data on the same socket
while no data has been received. I'm not sure it that was also needed to
set the socket non-blocking. I also defined "ERRNO" at the same place
and noted that this was required for mbedtls net.c (the interface to
lwip) to handle non-blocking sockets.
Noam, I'd suggest that you check if mbedtls_net_set_nonblock()/block()
(all in mbedtls's net.c) is used and if net_would_block() works
correctly. I had to undefine "errno" and make it a global variable of
type int to get it working. My mbedtls_net_recv() returns
MBEDTLS_ERR_SSL_WANT_READ if read() < 0 and net_would_block() != 0. This
probably overwrites lwips EWOULDBLOCK error.
Finally, I had lots of issues with the stack mbedtls is used in. Ok, my
LPC1768 has almost no memory, but IIRC I had to modify ctr_drbg.c
heavily to safe ~2k. This probably does not affect you as the F4xx has
IIRC a build-in hardware random number generator.

    Jan

On 02.03.2017 13:11, Noam Weissman wrote:
> Hi Simon,
>
> I was able to catch the error inside function lwip_recvfrom, to remind you 
> this is read from
> PolarSSL
>
> It returns from here:
>LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", 
> s));
>
> The read buffer is large and it does have a problem, length is 14829 ?
>
> Any ideas ??
>
> BR,
> Noam.
>
> -Original Message-
> From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
> Behalf Of goldsi...@gmx.de
> Sent: Wednesday, March 01, 2017 9:27 PM
> To: Mailing list for lwIP users
> Subject: Re: [lwip-users] PolarSSL and mbedTLS
>
> I did have mbedTLS running against our httpd (no sockets) but the resource 
> usage was rather high.
> I'd imagine the problem could be lwIP's memory configurations here, too.
>
> Simon
>
>
> Jan Menzel wrote:
>> Hi Noam!
>>   I've designed a system with almost the same setup which works well
>> since a few years incl. firmware updates of a ~200kb.
>>   Did you checked the memory consumption of the ip stack and the ssl
>> max content length setting? The default max content length setting is
>> IIRC 16kb, which means that data is hashed and encrypted in chunks of
>> up to 16kb and can only be verified and decrypted once the entire
>> chunk has been received. The firmware update on my system only works
>> if the max content length is reduced. With the default setting I faced
>> memory issues on LPC1768 (which has just a fraction of your F4xx).
>>   I also had to fiddle around a little bit with errno in the interface
>> between mbedtls and lwip. One last advice: carefully check your stack
>> usage. mbedtls uses lots of function pointers which Keils static call
>> graph analysis can not see and does not warn about.
>>
>>   Jan
>>
>> On 01.03.2017 14:01, Noam Weissman wrote:
>>> Hi,
>>>
>>>
>>>
>>> I have a client, single task using the socket API using and also
>>> PolarSSL for SSL support.
>>>
>>>
>>>
>>> The client is WebSocket client and all seems to work ok.
>>>
>>>
>>>
>>> When I try to send small messages from the server to my client all is
>>> working ok but when I try to push a large
>>>
>>> message 6K and up my ssl_read function fails with a read error?.
>>>
>>>
>>>
>>> The ssl_read is actually calling lwip_read internally.
>>>
>>>
>>>
>>> For some reason the SSL code is trying to read a large buffer 8-16K
>>> bytes and t

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-02 Thread Noam Weissman
Hi Simon,

I was able to catch the error inside function lwip_recvfrom, to remind you this 
is read from
PolarSSL 

It returns from here:
   LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", 
s));

The read buffer is large and it does have a problem, length is 14829 ?

Any ideas ??

BR,
Noam.

-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of goldsi...@gmx.de
Sent: Wednesday, March 01, 2017 9:27 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

I did have mbedTLS running against our httpd (no sockets) but the resource 
usage was rather high.
I'd imagine the problem could be lwIP's memory configurations here, too.

Simon


Jan Menzel wrote:
> Hi Noam!
>   I've designed a system with almost the same setup which works well 
> since a few years incl. firmware updates of a ~200kb.
>   Did you checked the memory consumption of the ip stack and the ssl 
> max content length setting? The default max content length setting is 
> IIRC 16kb, which means that data is hashed and encrypted in chunks of 
> up to 16kb and can only be verified and decrypted once the entire 
> chunk has been received. The firmware update on my system only works 
> if the max content length is reduced. With the default setting I faced 
> memory issues on LPC1768 (which has just a fraction of your F4xx).
>   I also had to fiddle around a little bit with errno in the interface 
> between mbedtls and lwip. One last advice: carefully check your stack 
> usage. mbedtls uses lots of function pointers which Keils static call 
> graph analysis can not see and does not warn about.
>
>   Jan
>
> On 01.03.2017 14:01, Noam Weissman wrote:
>> Hi,
>>
>>   
>>
>> I have a client, single task using the socket API using and also 
>> PolarSSL for SSL support.
>>
>>   
>>
>> The client is WebSocket client and all seems to work ok.
>>
>>   
>>
>> When I try to send small messages from the server to my client all is 
>> working ok but when I try to push a large
>>
>> message 6K and up my ssl_read function fails with a read error?.
>>
>>   
>>
>> The ssl_read is actually calling lwip_read internally.
>>
>>   
>>
>> For some reason the SSL code is trying to read a large buffer 8-16K 
>> bytes and the read function fails.
>>
>>   
>>
>> Normally when we read from a socket more than is available the return 
>> value should be the number
>>
>> of bytes actually read and not an error ?.
>>
>>   
>>
>> The processor is STM32F427 using CCM for heap and Keil IDE
>>
>>   
>>
>> My main project uses Lwip 1.41, FreeRTOS 8.0.1 and PolarSSL 1.0.0
>>
>>   
>>
>> I have created two almost identical projects to the one I use. The 
>> first
>> uses:
>>
>> Lwip 2.01, FreeRTOS 9.0
>>
>>   
>>
>> The second project is the same as the one with Lwip 2.01 but instead 
>> of PolaSSL I switched to mbedTLS 2.4.0
>>
>>   
>>
>> In none secure mode everything works as expected and have no problems 
>> getting a large message (600K)
>>
>> In secured mode I get a read fail on the first packet ??
>>
>>   
>>
>> Anyone has an idea what I am doing wrong or what setting are not correct ??
>>
>>   
>>
>> A second question for Simon or anyone that can assist. I tried to set 
>> LWIP_DEBUG to 1 and my total used RAM (compiler) dropped
>>
>> about 30K ?? Why is that ?... I understood that debug should take 
>> more RAM not Less ?
>>
>>   
>>
>> Thanks,
>>
>> Noam.
>>
>>   
>>
>> cid:image001.jpg@01D26A92.68494F10
>>
>>  
>>
>> Noam Weissman
>>
>> Software Engineer
>>
>> SILORA R
>>
>> p:
>>
>>  
>>
>> +972-4-9554915 m: +972-52-5786135
>>
>> w:
>>
>>  
>>
>> www.silrd.com <http://www.silrd.com/>  e: n...@silrd.com 
>> <mailto:n...@silrd.com>
>>
>> cid:image002.png@01D26A92.68494F10
>> <https://www.facebook.com/SiloraRD/>  
>> cid:image003.png@01D26A92.68494F10
>> <https://twitter.com/SiloraRD>  cid:image004.png@01D26A92.68494F10
>> <https://www.linkedin.com/company/silora-r>
>>
>>   
>>
>>   
>>
>>
>>
>> ___
>> 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] PolarSSL and mbedTLS

2017-03-02 Thread Noam Weissman
Hi Simon,


I have not completely understood the code in lwip_recvfrom function as I am not 
familiar

with the underlying code.


If I understood it correctly the function is called when their some data. It 
reads one pBuf

at a time, copy the data from it to the buffer that is passed to it and after 
that it free's

the pBuf.


At the same time it handles the incommoding data, the interrupt handler reads 
data from

the DMA buffers to other pBuf's... this is going on until (or should) until all 
the data that

should have been read is collected or an error .


What happens inside the d <> while, does it not starve the rest of the code and 
are pBuf

freed so they can be reused inside the interrupt handler ?


I am not sure but it feels like a problem there, or a bug as you said.

I noticed that if I single step (debug the code) inside lwip_recvfrom it seems 
to work, so it

seems there is a raise condition or something else that happens when the code 
is running

without breakpoints.


I will do more testing next week and see if I make any progress.


BR,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsi...@gmx.de <goldsi...@gmx.de>
Sent: Thursday, March 2, 2017 11:24 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Noam Weissman wrote:
Same problem with either 1.41 or 2.01 tested on both

Up to now, EWOULDBLOCK is based on netconn callback events. I'm in the progress 
of changing this to be a result of a "tryget" operation on the recvmbox. If 
there should be a bug in the event callback handling, this should fix it. 
However, there are many more places where your error should come from, so I'm 
not convinced my change will fix your issue...

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

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-02 Thread Noam Weissman
Hi Simon,


Same problem with either 1.41 or 2.01 tested on both


This is the first project I ported to 2.01 with plans to port all the rest

of our projects to 2.01


Thanks for a great work :-)

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsi...@gmx.de <goldsi...@gmx.de>
Sent: Thursday, March 2, 2017 8:54 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Noam Weissman wrote:
> lwip_recvfrom is called.
>
> Inside this function there is a do <> while loop that is supposed to collect 
> the fragments into the 16K buffer
> and after getting it all return to the SSL for decryption etc...
>
> for some reason it always returns with EWOULDBLOCK error !

Which version of lwIP did you say you are using?

Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
lwip-users -- Mailing list for lwIP users - 
lists.nongnu.org<https://lists.nongnu.org/mailman/listinfo/lwip-users>
lists.nongnu.org
Welcome to the lwip-users mailing list. Use it to ask questions, share your 
experience and discuss new ideas. To see the collection of prior postings to 
the list ...


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

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-02 Thread Noam Weissman
Hi Jan,

I was able to trace were the error happens but I cannot figure a solution.

The SSL layer is allocation a buffer of 16K, transfers it to the underlying 
code and eventually

lwip_recvfrom is called.

Inside this function there is a do <> while loop that is supposed to collect 
the fragments into the 16K buffer
and after getting it all return to the SSL for decryption etc...

for some reason it always returns with EWOULDBLOCK error !

I changed my lwipopts and now I have 
#define MEMP_NUM_PBUF   80
#define MEM_SIZE(22 * 1024)

As far as I understand that should be ok but I still get the error on the first 
loop iteration ?

I am sure it is an LwIP setting issue and not lack of memory 


BR,
Noam.


-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Jan Menzel
Sent: Thursday, March 02, 2017 8:08 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Hi Noam!
With MAX_CONTENT_LEN set to 16k you have to provide more then 32k to 
the SSL stack. With 64k ssl memory pool, that should be fine. You'll need more 
memory for extensive math in case you enable enhanced features like DHE or 
certificate validation.
I'm not aware of any MSS related issues. Every time you call ssl_read() 
or ssl_write() some internal sm will check for any pending work to be done. If 
there is sufficient data available (in case of read) it will be returned to 
you. If not, lwips read() is called to check if new data has arrived. Data 
arrives as per TCP standard in any size and is buffered in the receive buffer 
of the SSL layer. Once a complete block (with respect to ssl) has been 
received, it is checked, decrypted and set as ready to be transferred to the 
application layer. If no data is available
ssl_read() will return something like WONT_READ. This just indicated that you 
shall try again later. So if large blocks do not arrive, you'll probably have 
to call ssl_read() a few times until all data is available. If thats not 
working for you, try if lwips read() is called in a non-blocking way. mbedtls 
default interface layer does some checking on the socked to detect if data is 
available and/or the read() call would block. I had to play a little bit around 
with errno to get it working.

Jan

On 01.03.2017 23:19, Noam Weissman wrote:
> Hi Jan,
> 
> 
> Let me see if I understand you...  MAX_CONTENT_LEN  is defined in my 
> system to the default 16K.
> 
> I have 64K of RAM available just for the SSL use.
> 
> 
> So memory limits are not at SSL layer, I think.
> 
> 
> The SSL layer is reading a record and then the data. Data is read into 
> its own buffers. If I understand
> 
> you correctly because it tries to read as it needs 4,8 or maybe even 
> 16k and because my MSS on
> 
> TCP stack is defined to be small it is a problem.
> 
> 
> But what if MSS has a normal size or even defined as jumbo frame (8K) 
> it still will not hold
> 
> a 16K frame in one pBuf if the sender is sending a large chank. So 
> there should be something else ?
> 
> 
> Noam.
> --
> --
> *From:* lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on 
> behalf of Jan Menzel <men...@peperoni-light.de>
> *Sent:* Wednesday, March 1, 2017 11:46 PM
> *To:* lwip-users@nongnu.org
> *Subject:* Re: [lwip-users] PolarSSL and mbedTLS
>  
> Hi Noam!
> SSL/TLS isn't that simple. Besides encryption the data is also 
> hashed to detect data integrity issues. This places strong resource 
> requirements on the block size that is used for hashing and this is 
> where MAX_CONTENT_LEN comes into play: mbedtls needs/reserves two 
> buffers of that size, one for RX and one for TX. So if RAM usage is an 
> issue for you, reduce MAX_CONTENT_LEN and make sure you have control 
> over the other side (MAX_CONTENT_LEN is not negotiated).
> From lwips memory concept it would be great if mbedtls would 
> just chain up pbufs until a block is complete and can be rehashed and 
> decrypted.
> I'd willing to assist in implementing this.
> 
> Jan
> 
> On 01.03.2017 21:46, Noam Weissman wrote:
>> Hi Simon,
>> 
>> 
>> Yes it may be an issue, any ideas or a change in the settings I 
>> placed here earlier ?
>> 
>> 
>> What I am puzzled about is that SSL/TLS transfer a key over RSA. Once 
>> the key has been
>> 
>> transferred (SSL handshake) the encryption/decryption are symmetric.
>> Either using AES, DES etc..
>> 
>> 
>> So if one side wants to send 100 bytes or 500 bytes the overhead is 
>> small. Normally AES, DES
>> 
>> etc can encrypt/decrypt IN PLACE so no need for a new buffe

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-01 Thread Noam Weissman
Hi Jan,


Let me see if I understand you...  MAX_CONTENT_LEN  is defined in my system to 
the default 16K.

I have 64K of RAM available just for the SSL use.


So memory limits are not at SSL layer, I think.


The SSL layer is reading a record and then the data. Data is read into its own 
buffers. If I understand

you correctly because it tries to read as it needs 4,8 or maybe even 16k and 
because my MSS on

TCP stack is defined to be small it is a problem.


But what if MSS has a normal size or even defined as jumbo frame (8K) it still 
will not hold

a 16K frame in one pBuf if the sender is sending a large chank. So there should 
be something else ?

Noam.

From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
Jan Menzel <men...@peperoni-light.de>
Sent: Wednesday, March 1, 2017 11:46 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] PolarSSL and mbedTLS

Hi Noam!
SSL/TLS isn't that simple. Besides encryption the data is also hashed
to detect data integrity issues. This places strong resource
requirements on the block size that is used for hashing and this is
where MAX_CONTENT_LEN comes into play: mbedtls needs/reserves two
buffers of that size, one for RX and one for TX. So if RAM usage is an
issue for you, reduce MAX_CONTENT_LEN and make sure you have control
over the other side (MAX_CONTENT_LEN is not negotiated).
From lwips memory concept it would be great if mbedtls would just chain
up pbufs until a block is complete and can be rehashed and decrypted.
I'd willing to assist in implementing this.

Jan

On 01.03.2017 21:46, Noam Weissman wrote:
> Hi Simon,
>
>
> Yes it may be an issue, any ideas or a change in the settings I placed
> here earlier ?
>
>
> What I am puzzled about is that SSL/TLS transfer a key over RSA. Once
> the key has been
>
> transferred (SSL handshake) the encryption/decryption are symmetric.
> Either using AES, DES etc..
>
>
> So if one side wants to send 100 bytes or 500 bytes the overhead is
> small. Normally AES, DES
>
> etc can encrypt/decrypt IN PLACE so no need for a new buffer. So memory
> usage should not be
>
> a big difference?
>
>
> Any ideas are welcomed 
>
>
> BR,
>
> Noam.
>
>
>
> 
> *From:* lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on
> behalf of goldsi...@gmx.de <goldsi...@gmx.de>
> *Sent:* Wednesday, March 1, 2017 9:26 PM
> *To:* Mailing list for lwIP users
> *Subject:* Re: [lwip-users] PolarSSL and mbedTLS
>
> I did have mbedTLS running against our httpd (no sockets) but the
> resource usage was rather high.
> I'd imagine the problem could be lwIP's memory configurations here, too.
>
> Simon
>
>
> Jan Menzel wrote:
>> Hi Noam!
>>I've designed a system with almost the same setup which works well
>> since a few years incl. firmware updates of a ~200kb.
>>Did you checked the memory consumption of the ip stack and the ssl max
>> content length setting? The default max content length setting is IIRC
>> 16kb, which means that data is hashed and encrypted in chunks of up to
>> 16kb and can only be verified and decrypted once the entire chunk has
>> been received. The firmware update on my system only works if the max
>> content length is reduced. With the default setting I faced memory
>> issues on LPC1768 (which has just a fraction of your F4xx).
>>I also had to fiddle around a little bit with errno in the interface
>> between mbedtls and lwip. One last advice: carefully check your stack
>> usage. mbedtls uses lots of function pointers which Keils static call
>> graph analysis can not see and does not warn about.
>>
>>Jan
>>
>> On 01.03.2017 14:01, Noam Weissman wrote:
>>> Hi,
>>>
>>>
>>>
>>> I have a client, single task using the socket API using and also
>>> PolarSSL for SSL support.
>>>
>>>
>>>
>>> The client is WebSocket client and all seems to work ok.
>>>
>>>
>>>
>>> When I try to send small messages from the server to my client all is
>>> working ok but when I try to push a large
>>>
>>> message 6K and up my ssl_read function fails with a read error?.
>>>
>>>
>>>
>>> The ssl_read is actually calling lwip_read internally.
>>>
>>>
>>>
>>> For some reason the SSL code is trying to read a large buffer 8-16K
>>> bytes and the read function fails.
>>>
>>>
>>>
>>> Normally when we read from a socket more than is available t

Re: [lwip-users] PolarSSL and mbedTLS

2017-03-01 Thread Noam Weissman
Hi Simon,


Yes it may be an issue, any ideas or a change in the settings I placed here 
earlier ?


What I am puzzled about is that SSL/TLS transfer a key over RSA. Once the key 
has been

transferred (SSL handshake) the encryption/decryption are symmetric. Either 
using AES, DES etc..


So if one side wants to send 100 bytes or 500 bytes the overhead is small. 
Normally AES, DES

etc can encrypt/decrypt IN PLACE so no need for a new buffer. So memory usage 
should not be

a big difference?


Any ideas are welcomed []


BR,

Noam.



From: lwip-users <lwip-users-bounces+noam=silrd@nongnu.org> on behalf of 
goldsi...@gmx.de <goldsi...@gmx.de>
Sent: Wednesday, March 1, 2017 9:26 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] PolarSSL and mbedTLS

I did have mbedTLS running against our httpd (no sockets) but the
resource usage was rather high.
I'd imagine the problem could be lwIP's memory configurations here, too.

Simon


Jan Menzel wrote:
> Hi Noam!
>I've designed a system with almost the same setup which works well
> since a few years incl. firmware updates of a ~200kb.
>Did you checked the memory consumption of the ip stack and the ssl max
> content length setting? The default max content length setting is IIRC
> 16kb, which means that data is hashed and encrypted in chunks of up to
> 16kb and can only be verified and decrypted once the entire chunk has
> been received. The firmware update on my system only works if the max
> content length is reduced. With the default setting I faced memory
> issues on LPC1768 (which has just a fraction of your F4xx).
>I also had to fiddle around a little bit with errno in the interface
> between mbedtls and lwip. One last advice: carefully check your stack
> usage. mbedtls uses lots of function pointers which Keils static call
> graph analysis can not see and does not warn about.
>
>Jan
>
> On 01.03.2017 14:01, Noam Weissman wrote:
>> Hi,
>>
>>
>>
>> I have a client, single task using the socket API using and also
>> PolarSSL for SSL support.
>>
>>
>>
>> The client is WebSocket client and all seems to work ok.
>>
>>
>>
>> When I try to send small messages from the server to my client all is
>> working ok but when I try to push a large
>>
>> message 6K and up my ssl_read function fails with a read error?.
>>
>>
>>
>> The ssl_read is actually calling lwip_read internally.
>>
>>
>>
>> For some reason the SSL code is trying to read a large buffer 8-16K
>> bytes and the read function fails.
>>
>>
>>
>> Normally when we read from a socket more than is available the return
>> value should be the number
>>
>> of bytes actually read and not an error ?.
>>
>>
>>
>> The processor is STM32F427 using CCM for heap and Keil IDE
>>
>>
>>
>> My main project uses Lwip 1.41, FreeRTOS 8.0.1 and PolarSSL 1.0.0
>>
>>
>>
>> I have created two almost identical projects to the one I use. The first
>> uses:
>>
>> Lwip 2.01, FreeRTOS 9.0
>>
>>
>>
>> The second project is the same as the one with Lwip 2.01 but instead of
>> PolaSSL I switched to mbedTLS 2.4.0
>>
>>
>>
>> In none secure mode everything works as expected and have no problems
>> getting a large message (600K)
>>
>> In secured mode I get a read fail on the first packet ??
>>
>>
>>
>> Anyone has an idea what I am doing wrong or what setting are not correct ??
>>
>>
>>
>> A second question for Simon or anyone that can assist. I tried to set
>> LWIP_DEBUG to 1 and my total used RAM (compiler) dropped
>>
>> about 30K ?? Why is that ?... I understood that debug should take more
>> RAM not Less ?
>>
>>
>>
>> Thanks,
>>
>> Noam.
>>
>>
>>
>> cid:image001.jpg@01D26A92.68494F10
>>
>>
>>
>> Noam Weissman
>>
>> Software Engineer
>>
>> SILORA R
>>
>> p:
>>
>>
>>
>> +972-4-9554915 m: +972-52-5786135
>>
>> w:
>>
>>
>>
>> www.silrd.com<http://www.silrd.com> <http://www.silrd.com/>  e: 
>> n...@silrd.com
SILORA R - The Vision of Innovation<http://www.silrd.com/>
www.silrd.com
SILORA R provides state of the art multimedia and switching solutions to 
leading companies in the ProAV industry. SILORA R is an innovative developer 
and ...

SILORA R - The Vision of Innovation<http://www.silrd.com/>
www.silrd.com
SILORA R provides state of the art multimedia and sw

[lwip-users] PolarSSL and mbedTLS

2017-03-01 Thread Noam Weissman
Hi,

I have a client, single task using the socket API using and also PolarSSL for 
SSL support.

The client is WebSocket client and all seems to work ok.

When I try to send small messages from the server to my client all is working 
ok but when I try to push a large
message 6K and up my ssl_read function fails with a read error?.

The ssl_read is actually calling lwip_read internally.

For some reason the SSL code is trying to read a large buffer 8-16K bytes and 
the read function fails.

Normally when we read from a socket more than is available the return value 
should be the number
of bytes actually read and not an error ?.

The processor is STM32F427 using CCM for heap and Keil IDE

My main project uses Lwip 1.41, FreeRTOS 8.0.1 and PolarSSL 1.0.0

I have created two almost identical projects to the one I use. The first uses:
Lwip 2.01, FreeRTOS 9.0

The second project is the same as the one with Lwip 2.01 but instead of PolaSSL 
I switched to mbedTLS 2.4.0

In none secure mode everything works as expected and have no problems getting a 
large message (600K)
In secured mode I get a read fail on the first packet ??

Anyone has an idea what I am doing wrong or what setting are not correct ??

A second question for Simon or anyone that can assist. I tried to set 
LWIP_DEBUG to 1 and my total used RAM (compiler) dropped
about 30K ?? Why is that ?... I understood that debug should take more RAM not 
Less ?

Thanks,
Noam.

[cid:image001.jpg@01D26A92.68494F10]

Noam Weissman

Software Engineer

SILORA R

p:

+972-4-9554915 m: +972-52-5786135

w:

www.silrd.com<http://www.silrd.com/>  e: n...@silrd.com<mailto:n...@silrd.com>

[cid:image002.png@01D26A92.68494F10]<https://www.facebook.com/SiloraRD/>  
[cid:image003.png@01D26A92.68494F10] <https://twitter.com/SiloraRD>   
[cid:image004.png@01D26A92.68494F10] 
<https://www.linkedin.com/company/silora-r>




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

Re: [lwip-users] TCPIP and MAC thread task priorities

2017-02-27 Thread Noam Weissman
Dear Sylvain,

If you issue portDISABLE_INTERRUPTS() it will mask all interrupts

If you issue portENTER_CRITICAL() it will only mask interrupts that have a 
priority
Lower than the FreeRTOS one interrupt.

See these:
   http://www.freertos.org/RTOS-Cortex-M3-M4.html

In this link check the paragraph that starts with Attention please!:
   http://www.freertos.org/portcortexiar.html


   
https://mcuoneclipse.com/2016/08/14/arm-cortex-m-interrupts-and-freertos-part-1/


BR,
Noam.




-Original Message-
From: lwip-users [mailto:lwip-users-bounces+noam=silrd@nongnu.org] On 
Behalf Of Sylvain Rochet
Sent: Monday, February 27, 2017 2:25 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] TCPIP and MAC thread task priorities

Hi,

On Mon, Feb 27, 2017 at 11:50:26AM +, Noam Weissman wrote:
> Hi All,
> 
> This comes from my own experience with STM micro that has Cortex-M 
> core Running with FreeRTOS. It does apply to STM9 etc...
> 
> TCP main task priority should be high priority. It should not be the 
> highest priority but it should not be lower than other tasks that 
> consume lots of time share.
> 
> The most misunderstood issue is interrupt priority levels in Cortext-M 
> and FreeRTOS.
> 
> First of all: A lower number in Coretex means a higher priority while 
> in FreeRTOS a higher number Means a higher priority.
> 
> Secondly Cortex use a nesting interrupt and a smart level... Assume 
> you set an interrupt to level 2 and try to run some critical section 
> code from RS232 but that RS232 has an interrupt level set at 5.
> 
> What happens is that the interrupt 2 (higher) will never be masked 
> because the issuer of the Critical section runs at a lower interrupt 
> level.
> 
> FreeRTOS has lots of sections like this one:
> 
>   portENTER_CRITICAL();
>   {   
>  // some code
>   }   
>   portEXIT_CRITICAL();
> 
> 
> If you set your interrupt level to be higher priority than the 
> FreeRTOS timer tick that part will never Be masked and your critical 
> section will not work as expected.

I don't understand any of this, portENTER_CRITICAL/portEXIT_CRITICAL
proper implementation is to disable *ALL* interrupts, therefore having a 
critical section which is not enforced for whatever reason can't happen at all.

By the way, FreeRTOS is not supposed to run with nested interrupts, you have to 
put all OS calls from interrupts (i.e. *FromISR() functions) in a critical 
section.

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


  1   2   3   >