Re: [lwip-users] TFTP init

2017-01-18 Thread nrichard
Stephen Cowell wrote
> Some confusion... your board, your design, is an FTP server?  You are 
> pushing files from a PC client to an embedded server.
> I'm assuming no OS... raw, in other words.

FTP, TFTP, HTTP, doesn't matter to me.  I just want to transfer a file from
my PC, an image file, to my board over the network. I only plan on
transferring 1 image file, maybe a config file too, but just the image file
is fine.  No OS is running and preferably no file system either.


Stephen Cowell wrote
> Do you have the SAM4E-EK?  or the Explained? kit?  Or are you already on 
> custom hardware?   Always easiest to start with a kit.

I'm using a SAM4E Xplained Pro (Evaluation Kit).


Stephen Cowell wrote
> Looking at fatfs's conf_access.h file, I see this entry:
> 
> <>
> 
> /*! \name Activation of Logical Unit Numbers
>   */
> //! @{
> #ifdef VIRTUAL_MEMORY_ENABLE
> #define LUN_0ENABLE   //!< Enable On-Chip Virtual Memory.
> #else
> #define LUN_0DISABLE  //!< Disable On-Chip Virtual Memory.
> #endif
> 
> .. so it looks like FatFS will do virtual memory.  I don't expect that 
> you'll be able to get on-chip flash working easily... this seems more 
> designed for RAM.  How big are the files you're moving? You say 
> 'image'... these are bitmaps, or iso's?  Using on-chip flash is 
> complicated.  Use RAM if at all possible.  Open the fatfs docs (you'll 
> have to tell AtmelStudio to use a browser, this is silly of course) and 
> find the f_mount() function... follow what it does. They have a user
> forum,
> 
> http://elm-chan.org/fsw/ff/bd/

Correct, the example project from Atmel is using virtual memory on RAM,
which was causing my original problem (I ran out of memory).  I'd eventually
want my image file to be on the flash.  The image file is an iso file. ex:
image_file.bin and once finished will probably be less than 500KB.  I will
boot to the file upon reset (thus why it needs to be in flash).  I'll check
out the docs / forums.


Stephen Cowell wrote
> I created an example project for LWIP using the 
> THIRDPARTY_RAW_BASIC_HTTP example, then I created other example projects 
> for SD Card, then diffed the projects and added the pieces into my first 
> project.  Now I have an SD card that is an FTP server with NTP-based 
> clock.  It was not easy... use every cheat you can find.  If you have to 
> add a USB stick or an SD card to get it going, do so.
> __
> Steve

That's what I started to do.  I used the same exact example to get my other
network protocols up and running, and the same example project to port over
the FatFs.  I'll check out the documentation again to see if there's
something missing.

To me right now it seems like if I want to use FatFs (which I don't), I need
to figure out what my problem is with memory; as in I run out of it and the
FTP server does not turn on.  I don't think it's a leak, rather it's LWIP or
FatFs taking up the majority.  That doesn't seem right to me.

If I want to use an FTP server without FatFs or the provided LWIP TFTP
server, either one is the goal, I have to figure out how to modify them. 
Modify them so that I FTP the image.bin over and then load it into flash
somehow.



--
View this message in context: 
http://lwip.100.n7.nabble.com/TFTP-init-tp28231p28436.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


Re: [lwip-users] TFTP init

2017-01-18 Thread Stephen Cowell
Nick... I'm using the same ftp... and the same processor... I wrote sftp 
but it's actually ftpd, from toelke.


Some confusion... your board, your design, is an FTP server?  You are 
pushing files from a PC client to an embedded server.

I'm assuming no OS... raw, in other words.

Do you have the SAM4E-EK?  or the Explained? kit?  Or are you already on 
custom hardware?   Always easiest to start with a kit.


Looking at fatfs's conf_access.h file, I see this entry:

<>

/*! \name Activation of Logical Unit Numbers
 */
//! @{
#ifdef VIRTUAL_MEMORY_ENABLE
#define LUN_0ENABLE   //!< Enable On-Chip Virtual Memory.
#else
#define LUN_0DISABLE  //!< Disable On-Chip Virtual Memory.
#endif



.. so it looks like FatFS will do virtual memory.  I don't expect that 
you'll be able to get on-chip flash working easily... this seems more 
designed for RAM.  How big are the files you're moving? You say 
'image'... these are bitmaps, or iso's?  Using on-chip flash is 
complicated.  Use RAM if at all possible.  Open the fatfs docs (you'll 
have to tell AtmelStudio to use a browser, this is silly of course) and 
find the f_mount() function... follow what it does. They have a user forum,


http://elm-chan.org/fsw/ff/bd/

I created an example project for LWIP using the 
THIRDPARTY_RAW_BASIC_HTTP example, then I created other example projects 
for SD Card, then diffed the projects and added the pieces into my first 
project.  Now I have an SD card that is an FTP server with NTP-based 
clock.  It was not easy... use every cheat you can find.  If you have to 
add a USB stick or an SD card to get it going, do so.

__
Steve
.

On 1/18/2017 9:20 AM, nrichard wrote:

Stephen Cowell wrote

What ftp library are you using?  I successfully used sftp with lwip
1.4.1 and fatFS, no OS needed, to be an FTP server for an SD card.

Are you being a server or a client?  Sounds like client.  Pretty sure
all the ftp things need a file system to work.

Using a file system is going to be easier than hacking an FTP client I
think.  Your goal is to use as much already-done code as possible.
Choose hardware with a rich set of example projects... Atmel SAM4E
helped me a lot.

--
Stephen Cowell

I'm actually using a SAM4E myself (specifically Sam4e16e).  I'm using this
library for FTP: https://github.com/toelke/lwip-ftpd
You are correct, I am the client on my local PC and the board will be the
server running elsewhere.  I would like to avoid using an SD card and have
the FTP server transfer to flash memory.  I only need to transfer 2 image
files to 2 locations in memory, nothing else.
With the library above, FatFs wants to use up all my memory for some reason,
so I need to figure out how I can not use up all my memory, or be able to
modify the vfs files to not use FatFs at all.

-Nick



--
View this message in context: 
http://lwip.100.n7.nabble.com/TFTP-init-tp28231p28409.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] Server TCP RST prevents client code from draining the receive buffer.

2017-01-18 Thread Tim Cussins
Hi all,

We've encountered a couple of interesting http servers in the wild that
redirect, then send a TCP RST immediately.

Some http servers do this to avoid the TIME_WAIT state. Viz:

  https://support.microsoft.com/en-gb/kb/272933

In our case, the data for the redirect appears to make it into LWIP, but
the subsequent RST causes the pcb to be discarded before we have an
opportunity to read it. See tcp_in.c:377

Linux, Windows, and FreeBSD network stacks all /appear/ to make
available to client code any data received before the server RST.

Has anyone encountered this issue before?

Any thoughts on the cleanest modification to LWIP that would allow the
receive buffer to be drained?

Thanks in advance,
Tim

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


Re: [lwip-users] TFTP init

2017-01-18 Thread nrichard
Jan Menzel wrote
> Hi Ajay!
>   If sending an image is all you wont to do, you might consider using
> tftp. tftp is especially designed for this purpose, requires only udp
> but lacks features like authentication. Many bootloaders use tftp to
> boot using an image located on the network.
> 
>   Jan

Yes, I only plan on transferring an image file, maybe a config file too, but
nothing else.  This is a rather simple so I don't care about transfer speed,
authentication, etc.  I'll try checking out the built in TFTP server from
LWIP again.  I was looking at it earlier and had a compilation error with
fopen(), which I found odd.

-Nick



--
View this message in context: 
http://lwip.100.n7.nabble.com/TFTP-init-tp28231p28411.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


Re: [lwip-users] TFTP init

2017-01-18 Thread nrichard
Stephen Cowell wrote
> What ftp library are you using?  I successfully used sftp with lwip 
> 1.4.1 and fatFS, no OS needed, to be an FTP server for an SD card.
> 
> Are you being a server or a client?  Sounds like client.  Pretty sure 
> all the ftp things need a file system to work.
> 
> Using a file system is going to be easier than hacking an FTP client I 
> think.  Your goal is to use as much already-done code as possible.  
> Choose hardware with a rich set of example projects... Atmel SAM4E 
> helped me a lot.
> 
> -- 
> Stephen Cowell

I'm actually using a SAM4E myself (specifically Sam4e16e).  I'm using this
library for FTP: https://github.com/toelke/lwip-ftpd
You are correct, I am the client on my local PC and the board will be the
server running elsewhere.  I would like to avoid using an SD card and have
the FTP server transfer to flash memory.  I only need to transfer 2 image
files to 2 locations in memory, nothing else.
With the library above, FatFs wants to use up all my memory for some reason,
so I need to figure out how I can not use up all my memory, or be able to
modify the vfs files to not use FatFs at all.

-Nick



--
View this message in context: 
http://lwip.100.n7.nabble.com/TFTP-init-tp28231p28409.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


Re: [lwip-users] TFTP init

2017-01-18 Thread Ajay Bhargav
It's not me but Nicholas is looking for an ftp server. I am not quite sure
what's his exact requirements.

-- Ajay


On Jan 18, 2017 10:31 PM, "Jan Menzel"  wrote:

Hi Ajay!
If sending an image is all you wont to do, you might consider using
tftp. tftp is especially designed for this purpose, requires only udp
but lacks features like authentication. Many bootloaders use tftp to
boot using an image located on the network.

Jan

On 18.01.2017 14:21, nrichard wrote:
> Ajay Bhargav wrote
>> I guess you need to check memory configuration. How much RAM do you have?
>> Are you using memory pool or malloc?
>> One thing to note here, I have written modified vfs layer for both my
>> systems as none of them use FatFS. I don’t know if that will have any
>> impact as such. You better check your lwIP options for memory settings.
>>
>> - Ajay B.
>
> Ideally I'd like to not use FatFs, I just don't know how to go about
> modifying the vfs layer myself (junior developer, still learning!).  All I
> need is the capability to FTP an image file over to a location in flash
> memory, so I don't need an entire file system.  Do you mind if I send you
a
> private email to ask a couple questions? Don't want to get too off topic
in
> the public mailing list.
>
>
>
> --
> View this message in context: http://lwip.100.n7.nabble.com/
TFTP-init-tp28231p28406.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] TFTP init

2017-01-18 Thread Stephen Cowell
What ftp library are you using?  I successfully used sftp with lwip 
1.4.1 and fatFS, no OS needed, to be an FTP server for an SD card.


Are you being a server or a client?  Sounds like client.  Pretty sure 
all the ftp things need a file system to work.


Using a file system is going to be easier than hacking an FTP client I 
think.  Your goal is to use as much already-done code as possible.  
Choose hardware with a rich set of example projects... Atmel SAM4E 
helped me a lot.


--
Stephen Cowell

On 1/18/2017 7:21 AM, nrichard wrote:

Ajay Bhargav wrote

I guess you need to check memory configuration. How much RAM do you have?
Are you using memory pool or malloc?
One thing to note here, I have written modified vfs layer for both my
systems as none of them use FatFS. I don’t know if that will have any
impact as such. You better check your lwIP options for memory settings.

- Ajay B.

Ideally I'd like to not use FatFs, I just don't know how to go about
modifying the vfs layer myself (junior developer, still learning!).  All I
need is the capability to FTP an image file over to a location in flash
memory, so I don't need an entire file system.  Do you mind if I send you a
private email to ask a couple questions? Don't want to get too off topic in
the public mailing list.



--
View this message in context: 
http://lwip.100.n7.nabble.com/TFTP-init-tp28231p28406.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] TFTP init

2017-01-18 Thread nrichard
Ajay Bhargav wrote
> I guess you need to check memory configuration. How much RAM do you have?
> Are you using memory pool or malloc?
> One thing to note here, I have written modified vfs layer for both my
> systems as none of them use FatFS. I don’t know if that will have any
> impact as such. You better check your lwIP options for memory settings.
> 
> - Ajay B.

Ideally I'd like to not use FatFs, I just don't know how to go about
modifying the vfs layer myself (junior developer, still learning!).  All I
need is the capability to FTP an image file over to a location in flash
memory, so I don't need an entire file system.  Do you mind if I send you a
private email to ask a couple questions? Don't want to get too off topic in
the public mailing list.



--
View this message in context: 
http://lwip.100.n7.nabble.com/TFTP-init-tp28231p28406.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

Re: [lwip-users] TFTP init

2017-01-18 Thread contact
I guess you need to check memory configuration. How much RAM do you have? Are 
you using memory pool or malloc?
One thing to note here, I have written modified vfs layer for both my systems 
as none of them use FatFS. I don’t know if that will have any impact as such. 
You better check your lwIP options for memory settings.

- Ajay B.

From: nrichard
Sent: Wednesday, January 18, 2017 7:39 PM
To: lwip-users@nongnu.org
Subject: Re: [lwip-users] TFTP init

Ajay Bhargav wrote
> I am using this FTP server on two of my devices (ARM board and ESP8266)
> and it works perfectly fine. Can you enable FTP debug prints and see where
> exactly it is failing?
> 
> Regards,
> Ajay Bhargav

I turned on TCP as well as FTP debugging, and low and behold, it tells me
I'm out of memory...

/TCP header:
+---+
|22271  |   21  | (src port, dest port)
+---+
|   0032031823  | (seq no)
+---+
|   00  | (ack no)
+---+
|  8 |   |10|  8192 | (hdrlen, flags (SYN), win)
+---+
|0xe60a | 0 | (chksum, urgp)
+---+
tcp_input: packed for LISTENing connection.
TCP connection request 22271 -> 21.
tcp_parseopt: MSS
tcp_parseopt: NOP
tcp_parseopt: other
tcp_parseopt: NOP
tcp_parseopt: NOP
tcp_parseopt: other
tcp_enqueue_flags: queuelen: 0
tcp_enqueue_flags: queueing 6510:6511 (0x12)
tcp_enqueue_flags: 1 (after enqueued)
tcp_output: snd_wnd 8192, cwnd 1, wnd 1, effwnd 0, seq 6510, ack 6510
tcp_output: snd_wnd 8192, cwnd 1, wnd 1, effwnd 0, seq 6510, ack 6510, i 0
tcp_output_segment: rtseq 6510
tcp_output_segment: 6510:6510
TCP header:
+---+
|22271  |   21  | (src port, dest port)
+---+
|   0032031824  | (seq no)
+---+
|   006511  | (ack no)
+---+
|  5 |   |01|  8192 | (hdrlen, flags (ACK), win)
+---+
|0x0d59 | 0 | (chksum, urgp)
+---+
+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ACK
-+-+-+-+-+-+-+-+-+-+-+-+-+-+
State: SYN_RCVD
TCP connection established 22271 -> 21.
ftpd_msgaccept: Out of memory
tcp_pcb_purge
tcp_pcb_purge: data left on ->unacked
tcp_abandon: sending RST
tcp_rst: seqno 6511 ackno 32031824.
tcp_slowtmr: no active pcbs/

I'm trying to get this working on an ARM board as well, a Sam4e.  Not to get
into too much detail because this is an LWIP mailing list, not an ARM
mailing list, but I imported the FatFs module from the ASF Wizard and used
an example to replicate the FatFs setup.  Seems like one of the #defines
they have me do, "VMEM_NB_SECTOR" determines whether I have enough memory or
not.  The example wants me to set it at 128, whereas the default was 8. At
128 FatFs creates, writes, and reads a file, anything below 128 and FatFs
does not work, however FTP connects but can't do any operations (I get FTP
server error messages).



--
View this message in context: 
http://lwip.100.n7.nabble.com/TFTP-init-tp28231p28404.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] Problem with sending UDP packets in LwIP & FreeRTOS

2017-01-18 Thread bachehkaraji
Hello

I work on a project which use FreeRTOS and Lwip v 1.4.1. I'm using a
LandTiger board which is made on an NXP LPC1768. My project is based on
LPCOpen 2.10 and derivated from the “lwip_tcpecho_freertos” example. I'm
only using the Socket API. 

In TCP, everything is OK! but in UDP doesn't...

I modified the “lwip_tcpecho_freertos” example to send UDP packets to my PC.
I have the problem that lwip_sendto stops working after sending one packet.

/* Send some data on a RAW or UDP pcb contained in a netconn
 * Called from netconn_send */
void
do_send(struct api_msg_msg *msg)
{
  if (ERR_IS_FATAL(msg->conn->last_err)) {
msg->err = msg->conn->last_err;
  } else {
...
  }
  TCPIP_APIMSG_ACK(msg);
}
lwip_sendto calls netconn_send, which calls tcpip_apimsg, which returns an
error.

...lwip_write -> lwip_send -> lwip_sendto -> netconn_send -> do_send ->
tcpip_apimsg...

err_t
tcpip_apimsg(struct api_msg *apimsg)
{
  struct tcpip_msg msg;
#ifdef LWIP_DEBUG
  /* catch functions that don't set err */
  apimsg->msg.err = ERR_VAL;
#endif
  
  if (sys_mbox_valid()) {
msg.type = TCPIP_MSG_API;
msg.msg.apimsg = apimsg;
sys_mbox_post(, );
sys_arch_sem_wait(>msg.conn->op_completed, 0);
return apimsg->msg.err;
  }
  return ERR_VAL;
}
 
As the problem occurs, The Ping keeps working normaly. 

If you have any idea, it'll be great as i'm really stuck on this problem
 
Bacheh Karaji




--
View this message in context: 
http://lwip.100.n7.nabble.com/Problem-with-sending-UDP-packets-in-LwIP-FreeRTOS-tp28403.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

Re: [lwip-users] TFTP init

2017-01-18 Thread nrichard
Ajay Bhargav wrote
> I am using this FTP server on two of my devices (ARM board and ESP8266)
> and it works perfectly fine. Can you enable FTP debug prints and see where
> exactly it is failing?
> 
> Regards,
> Ajay Bhargav

I turned on TCP as well as FTP debugging, and low and behold, it tells me
I'm out of memory...

/TCP header:
+---+
|22271  |   21  | (src port, dest port)
+---+
|   0032031823  | (seq no)
+---+
|   00  | (ack no)
+---+
|  8 |   |10|  8192 | (hdrlen, flags (SYN), win)
+---+
|0xe60a | 0 | (chksum, urgp)
+---+
tcp_input: packed for LISTENing connection.
TCP connection request 22271 -> 21.
tcp_parseopt: MSS
tcp_parseopt: NOP
tcp_parseopt: other
tcp_parseopt: NOP
tcp_parseopt: NOP
tcp_parseopt: other
tcp_enqueue_flags: queuelen: 0
tcp_enqueue_flags: queueing 6510:6511 (0x12)
tcp_enqueue_flags: 1 (after enqueued)
tcp_output: snd_wnd 8192, cwnd 1, wnd 1, effwnd 0, seq 6510, ack 6510
tcp_output: snd_wnd 8192, cwnd 1, wnd 1, effwnd 0, seq 6510, ack 6510, i 0
tcp_output_segment: rtseq 6510
tcp_output_segment: 6510:6510
TCP header:
+---+
|22271  |   21  | (src port, dest port)
+---+
|   0032031824  | (seq no)
+---+
|   006511  | (ack no)
+---+
|  5 |   |01|  8192 | (hdrlen, flags (ACK), win)
+---+
|0x0d59 | 0 | (chksum, urgp)
+---+
+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ACK
-+-+-+-+-+-+-+-+-+-+-+-+-+-+
State: SYN_RCVD
TCP connection established 22271 -> 21.
ftpd_msgaccept: Out of memory
tcp_pcb_purge
tcp_pcb_purge: data left on ->unacked
tcp_abandon: sending RST
tcp_rst: seqno 6511 ackno 32031824.
tcp_slowtmr: no active pcbs/

I'm trying to get this working on an ARM board as well, a Sam4e.  Not to get
into too much detail because this is an LWIP mailing list, not an ARM
mailing list, but I imported the FatFs module from the ASF Wizard and used
an example to replicate the FatFs setup.  Seems like one of the #defines
they have me do, "VMEM_NB_SECTOR" determines whether I have enough memory or
not.  The example wants me to set it at 128, whereas the default was 8. At
128 FatFs creates, writes, and reads a file, anything below 128 and FatFs
does not work, however FTP connects but can't do any operations (I get FTP
server error messages).



--
View this message in context: 
http://lwip.100.n7.nabble.com/TFTP-init-tp28231p28404.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