Commit Graph

117 Commits (1403dfc086b406650d4b3b38b38835b415cc55c9)

Author SHA1 Message Date
Sam Grove 109269da9c Merge pull request #4414 from tkaman/master
Enable CM3DS_MPS2 target
2017-06-15 11:20:09 -05:00
Russ Butler 9620b0fc7f STM32 - fix bug were sockets stop receiving data
The function _eth_arch_low_level_input() is meant to pass data into
LWIP and to prepare the ethernet buffers to receive more data.
If the LWIP heap is empty and the call to pbuf_alloc() in
_eth_arch_low_level_input returns null, the ethernet receive buffers
are not updated to receive data. Because of this the ethernet RX
interrupt will not fire. Since the RX interrupt is the only thing that
triggers a call to _eth_arch_low_level_input(), the receive buffers
will never get cleared, and the device stops receiving data.

To prevent this from happening, this patch ensures that the function
_eth_arch_low_level_input() clears the receive buffers even if a new
pbuf for the data couldn't be allocated.

This issue can be reproduce by running the test
"features-feature_lwip-tests-mbedmicro-net-udp_echo_parallel"
and on the same machine running the below python script to flood the
device with UDP broadcast packets:

MY_IP = #ADD your local IP here
from socket import *
s = socket(AF_INET, SOCK_DGRAM)
s.bind((MY_IP, 1234))
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
for _ in range(1000):
    s.sendto("test data", ('255.255.255.255', 1234))
print("Message sent")
2017-06-12 22:18:04 -05:00
Martin Kojtal d0d7c6f4f6 lwip: fix stm32f4 eth conf file
This file is moved to targets that support eth. It can't be common for any F4, as
not all targets from this family support eth.
2017-06-10 15:20:30 +01:00
Christopher Haster f11f2b35e0 lwip: Increased DHCP timeout to 60 seconds
This matches the timeout used in linux:
https://linux.die.net/man/5/dhclient.conf

This resolves several issues noticed during testing when we
have a very large number of devices that try to get an IP address
around the same time.
2017-06-10 15:14:28 +01:00
gabker01 fb6a2c075c Implement low-level Ethernet interface for lwIP
Based on lwip_ethernetif.c skeleton file,
use init, receive and transfer
functionality of SMSC9220 Ethernet driver
for the lightweight IP stack.

Receive mechanism is interrupt driven.

HW buffer sizes:
Tx = 4608 bytes (MTU)
Rx = 10560 bytes

lwIP fine tuning:
mbed-os/features/FEATURE_LWIP/lwip-interface/lwip/src/include/lwip/opt.h

Change-Id: I0ea95650c65fb32cafb5c2d3dde11420c61dba66
Signed-off-by: Gabor Kertesz <gabor.kertesz@arm.com>
2017-06-09 14:58:31 +01:00
Mika Leppänen ee30df993a Disabled lwip ethernet ipv6 multicast filter for STM boards 2017-06-09 11:57:24 +03:00
Sam Grove 1afb23bdd8 Merge pull request #4441 from tung7970/fix-mbedos
lwip - fix typo and cleanup coding style
2017-06-08 16:30:16 -05:00
Russ Butler e57869039e Fix semaphore usage on lpc1768 emac
The semaphore xTXDCountSem had the count to match the number of
resources available, but was being used as a binary semaphore in a
loop to listen for events. This patch updates the logic to make use of
the resource count.

With RTX5 the OS traps with an error if the a semaphore is released
more times than its count with an error similar to
"Semaphore 10000e6c error -17". Because xTXDCountSem is being used
as a binary semaphore it triggered this trap. With this patch the
semaphore is no longer used as a binary semaphore and no longer traps.
2017-06-05 11:37:06 -05:00
Tony Wu af3d6a52d1 lwip - fix typo and cleanup coding style
Signed-off-by: Tony Wu <tung7970@gmail.com>
2017-06-05 16:26:30 +08:00
Yuguo Zou f000eb3401 Restore TCPIP_THREAD_STACKSIZE and thread_stack_main
move some TCPIP stack data to heap;
switch off GDMA for SPI (only for SPI);
TCPIP_THREAD_STACKSIZE and thread_stack_main are identical to ARMmbed
2017-06-03 20:15:01 +01:00
Yuguo Zou 15d58690e9 fold static variables in RTWInterface.cpp to .h, modify lwipopts.h TCPIP_THREAD_STACKSIZE 2017-06-03 20:14:59 +01:00
Archcady 6a47d01c4a Rename Lwipopts_conf.h to lwipopts_conf.h 2017-06-03 20:14:51 +01:00
Archcady d0488c1076 Rename features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/target_realtek/Lwipopts_conf.h to features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_Realtek/Lwipopts_conf.h 2017-06-03 20:14:50 +01:00
Archcady 3d59643061 Add lwipopts_conf.h 2017-06-03 20:14:45 +01:00
Martin Kojtal 533e6f0feb Merge pull request #4431 from kjbracey-arm/mbed_lwip_api_compat
Restore mbed OS 5.4 mbed_lwip_ function prototypes
2017-06-03 08:28:52 +02:00
Sam Grove 5f138810a9 Merge pull request #4294 from ARMmbed/feature_cmsis5
Update CMSIS-Core and RTX to version 5
2017-06-02 23:44:32 -05:00
Kevin Bracey 284843fdb3 Restore mbed OS 5.4 mbed_lwip_ function prototypes
External EMAC drivers are currently directly attaching to lwip_stack.c
via mbed_lwip_bringup et al. Restore the original prototypes to avoid
compatibility breakage.
2017-06-02 14:30:25 +03:00
Kevin Bracey 42cd1e1fac Make lwip_stack.c include its header
Fix some type mismatches that this revealed.
2017-06-02 14:29:34 +03:00
Hasnain Virk 24de27c989 Major Refactoring & extensions
For keep supporting external APIs with the same name (supposedly there are a larger
number of users of those APIs), BufferedSerial and ATParser are being renamed.
BufferedSerial becomes UARTSerial, will complement a  future USBSerial etc.
ATParser becomes ATCmdParser.

* UARTSerial moves to /drivers

* APN_db.h is moved from platform to cellular/util/.

* Original CellularInterface is restored for backward compatability (again, supposedly there
  are users of that).

* A new file, CellularBase is added which will now servce as the base class for all
  upcoming drivers.

* Special restructuring for the driver has been undertaken. This makes a clear cut distinction
  between an on-board or an off-board implementation.
  	- PPPCellularInterface is a generic network interface that works with a generic FileHandle
          and PPP. A derived class is needed to pass that FileHandle.
        - PPPCellularInterface provides some base functionality like network registration, AT setup,
          PPP connection etc. Lower level job is delegated to the derived classes and various modem
          specific APIs are provided which are supposed to be overridden.
        - UARTCellularInterface is derived from PPPCellularInterface. It constructs a FileHandle and
          passes it back to PPPCellularInterface as well as provides modem hangupf functionality.
          In future we could proive a USBInterface that would derive from PPPCellularInterface and could
          pass the FileHandle back.
	- OnboardCellularInterface is derived from UARTCellularInterfae and provides hooks to
          the target provided implementation of onbard_modem_api.h. An off-board modem, i.e, a modem on
          a shield has to override the modem_init(), modem_power_up() etc as it cannot use
          onboard_modem_api.h.
2017-05-31 15:02:11 +03:00
Hasnain Virk b51fbe817b mbedtls md5 or lwip internal crypt Fudge
Some targets define MBEDTLS_md5_C in targets.json in order to force the system to use
external mbedtls instead of lwip internal crypt, i.e.,  polarssl.
LWIP's internal md5 mechanism is tied to PPP  for some reason. In a previosly merged commit
an attempt was made to steal md5 functions by faking that PPP was turned on. However
that solution was broken in case of really turning on PPP  functionality.

This commit fixes the breakage and also corrects the logic in case a target decides to use
external md5 implementation from mbedtls or otherwise (i.e, wants to stick to the internal
implementation).
2017-05-31 15:02:11 +03:00
Hasnain Virk 658ddf7c30 ARMCC link errors fixed, nsapi_ppp glue layer changed
GCC have not been capable enough to catch some linker errors which arose when
ethernet support for LWIP was disabled. Checks have been added to make sure that
unrefrenced code is not linked in.

nsapi_ppp glue layer is made more transparent to public cellular API. Storage of IP
addresses is removed. PPP layer already stores the addresses, so we pass the pointer back
to the upper layers.

If PPP is not used, we provide dummy functions.
2017-05-31 15:02:11 +03:00
Hasnain Virk 01088647b9 Finalizing the public API for Cellular
* state machine corrections
* adding various standard API methods
* Addition/revision/enhancement of the nsapi_ppp glue layer
* Turning off debug by default
2017-05-31 15:02:11 +03:00
Hasnain Virk f602c936ff Redirecting LWIP debug trace to mbed-trace
This piece of code redirects LWIP debug trace to mbed-trace if configured.
This enables us to have universal traces.
2017-05-31 15:02:11 +03:00
Hasnain Virk 3b44f4758d Adding support for APN lookup
Mainly reutilizing code from ublox C027 support lib.
As we are using external PDP context, i.e., an external IP stack,
we will pass username and password to underlying stack running PPP.
We only support CHAP as the authentication protocol.
2017-05-31 15:02:11 +03:00
Hasnain Virk 93f436ebe0 Using DCD line to invoke poll() HUP
POSIX poll() provides a mechanism to attach a POLL_HUP event
if the modem or device hangs up on you. POLL_HUP and POLL_OUT are
mutually exclusive. We poll in the PPP_input() routine if the modem
hung up. If it did we stop the data consumption, close PPP and go back
to the driver for reserruction of AT parser and subsequent retries or
application specific actions.
This is achieved by attaching an interrupt to the DCD line of the modem.
When DCD line goes high (off), we have lost the carrier. So we record an
POLLHUP event using _poll_change().
2017-05-31 15:02:11 +03:00
Hasnain Virk 87a4580e5f Bug fixes & state machine corrections
In case of carrier lost, we would like to inform PPP data pump.
That involved setting up link status flag down semaphores.
mbed_lwip_bringup() and mbed_lwip_bringdown() had been Ethernet specific only.
We extend these routines to support PPP as well. Currently we support only one interface
at a time. However, future enhancement to multi interface support should be trivial.
2017-05-31 15:02:11 +03:00
Kevin Bracey 7e3c529d21 Unify LWIP Ethernet and PPP initialisation 2017-05-31 15:02:11 +03:00
Hasnain Virk 2abb078f27 Adding PPP link status callback
mbed_ppp_init() is extended to take a function ptr.
ppp_lwip will call this callback upon a change in ppp link status.
in the beginning, the Ublox driver waits until the PPP link is established properly.
2017-05-31 15:02:11 +03:00
Hasnain Virk 091396defe Adding mbed_trace to ppp_lwip
We introduce here mbed_trace to ppp_lwip shim layer.
If for some reason, FEATURE_COMMON_PAL is not included in the build,
dummies for trace functions are provided.
2017-05-31 15:02:11 +03:00
Kevin Bracey be00c1720b Separate LWIP core and Ethernet interface initialisation
Will allow LWIP to be initialised for PPP use.
2017-05-31 15:02:11 +03:00
Kevin Bracey ae7fd61d65 RAM optimizations
Trying to save RAM wherever possible for Ublox C027 platform
2017-05-31 15:02:11 +03:00
Kevin Bracey f37f265ed5 Add more LWIP JSON configuration, including PPP
Add configuration to control Ethernet, PPP and TCP support.

Replaces LWIP_TRANSPORT_ETHERNET/PPP defines formerly used by targets.

Ethernet and PPP can be enabled simultaneously.

DHCPv4 is now only enabled if IPv4 and Ethernet are both enabled - we
assume PPP uses IPCP for configuration.

PPP configuration adjusted to cope with LWIP 2.0 changes, and
optimised for RAM a little.
2017-05-31 15:02:11 +03:00
Kevin Bracey d0820d1ed3 Cope with different LWIP configurations 2017-05-31 15:02:11 +03:00
Kevin Bracey 7f136d5a35 PPP Interface for LWIP using FileHandle stream
This is a glue layer between LWIP PPP implementation and a device type FileHandle
stream. This enables an external interface which has a FileHandle, utilize LWIP network
stack via PPP, e.g., Cellular device, WiFi chips etc.
Its totally transparent to external device. Only thing this layer is interested in, is a
FileHandle. Similar is true for for the external device, it just hands over its stream to this
PPP layer and rest of the magic is done by this layer.
2017-05-31 15:02:11 +03:00
Bartek Szatkowski a8229b5351 Make sure all RTOS attribute structures are 0-ed before use 2017-05-30 18:55:56 +01:00
Bartek Szatkowski b01f13d1a0 Make sure all system threads and mutexes have clear names 2017-05-30 18:55:55 +01:00
Bartek Szatkowski b793a3fb89 Update codebase for CMSIS5/RTX5
Update all of mbed-os to use RTX5.
2017-05-30 18:55:52 +01:00
Sam Grove 6a96481d4d Merge pull request #4311 from kjbracey-arm/lwip_cksum
Disable lwIP checksum-on-copy
2017-05-18 09:28:10 -05:00
Kevin Bracey 69ec30b7b9 Disable lwIP checksum-on-copy
Current version of lwIP has a bug in its checksum-on-copy code - see

      https://github.com/ARMmbed/mbed-os/issues/4140
  and https://savannah.nongnu.org/bugs/?50914

Pending a fix from lwIP, set LWIP_CHECKSUM_ON_COPY to 0 to work around.
Will impact performance.
2017-05-12 10:24:17 +03:00
Mika Leppänen 55753be8ef lwip corrected coverity and compiler warnings
Coverity ids: 1373147 and 1374442.
2017-05-10 10:20:44 +03:00
Mika Leppänen 053139b85d lwip added support for random library and TCP ISN initialisation
lwip now uses mbed client random library under common pal when available.
Ported lwip reference TCP initial sequence number handling to mbed-os
lwip stack. Handling is based on RFC 6528.
2017-05-10 10:20:44 +03:00
Jimmy Brisson 3b11b23371 Merge pull request #4238 from tung7970/fix-mbedos
lwip - power up emac before reading its settings
2017-05-08 11:15:45 -05:00
0x6d61726b acf18ac9c7 removed warning: unused variable 'ethhdr' [-Wunused-variable] 2017-04-30 16:29:47 +02:00
Tony Wu 0b2bfca6da lwip - delay mbed_lwip_set_mac_address until device is inited
mbed_lwip_set_mac_address calls mbed_mac_address to get hwaddr
from device, but device may not be accessible until it is powered
up and initialized.

This patch delays mbed_lwip_set_mac_address call until device is
ready.

Signed-off-by: Tony Wu <tonywu@realtek.com>
2017-04-28 00:30:40 +08:00
Tony Wu cdc40ff3bb lwip - power up emac before reading its settings
emac settings are only available after powered up.

Signed-off-by: Tony Wu <tonywu@realtek.com>
2017-04-28 00:15:07 +08:00
Tony Wu e9d3cf4468 lwip - make lwip thread stack size configurable
Define tcpip-thread-stacksize and default-thread-stacksize in
lwip's mbed_lib.json, and use them accordingly in lwipopts.h.

Signed-off-by: Tony Wu <tonywu@realtek.com>
2017-04-10 17:09:27 +08:00
Sam Grove 8af190f550 Merge pull request #4112 from adamgreen/fixLpc17xxEthernetIsrAlwaysLinkedIn
Only link in LPC17xx ethernet ISR as needed
2017-04-06 11:16:10 -05:00
Sam Grove 7a35a4df51 Merge pull request #3992 from u-blox/c030-dev
Introducing UBLOX_C030 platform.
2017-04-06 11:07:58 -05:00
Adam Green be0bab3f40 Only link in LPC17xx ethernet ISR as needed
Originally the ethernet ISR would be linked in to all mbed-os based
firmware because it was named ENET_IRQHandler() so that it would be
automatically placed in the FLASH image's interrupt vector table. This
meant that programs which made no use of the lwIP stack still pulled in
this ISR.

This commit changes the name of the routine so that the ISR isn't
automatically placed in the interrupt vector table at link time but is
instead dynamically placed in the interrupt vector table at runtime
when the lwIP stack is initialized. Now the ethernet ISR is only linked
in when it is actually needed.

Example arm-none-eabi-size output for a simple LED blinking program
showing the before and after size results:
   text	   data	    bss	    dec	    hex	filename
  13208	    148	   7784	  21140	   5294	LPC1768/HelloWorld.elf

   text	   data	    bss	    dec	    hex	filename
  12700	    148	   7468	  20316	   4f5c	LPC1768/HelloWorld.elf
2017-04-04 14:42:21 -07:00
Rob Meades 7387c09872 Introducing UBLOX_C030 platform. 2017-04-04 16:22:50 +01:00