Commit Graph

165 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
Brian Daniels 4f5a199336 Fix bad print message in test 2017-06-10 15:14:28 +01:00
Brian Daniels 94b4160347 Fixing bad asserts 2017-06-10 15:14:28 +01:00
Brian Daniels c38b709685 Cleaning up udp tests 2017-06-10 15:14:28 +01:00
Brian Daniels ccad027fa7 Adding comments describing buffer prep functions 2017-06-10 15:14:28 +01:00
Brian Daniels 388968f76b Simplifying assert statements 2017-06-10 15:14:28 +01:00
Brian Daniels 6e76fce4fc Specifying default length of UUID for Greentea
This creates a macro for the UUID length used by Greentea. This cuts
down on the use of "magic numbers" in test cases that use
the GREENTEA_SETUP_UUID function.
2017-06-10 15:14:28 +01:00
Christopher Haster d451d1795e Moved network test buffers into heap
This is a workaround for IAR's lack of flexibility with memory regions.
Otherwise these tests would use very little heap and be mostly global
allocations.
2017-06-10 15:14:28 +01:00
Christopher Haster 467eb342f0 lwip: Migrated to utest framework
per @bridadan
2017-06-10 15:14:28 +01:00
Christopher Haster 0887683a13 lwip: Fixed count of udp iterations to reflect attempts 2017-06-10 15:14:28 +01:00
Christopher Haster 036f1cdfd4 lwip: Added udp buffer flushing after dropped packets
Avoids getting stuck in loop where the device always picks
up the previous test's packets
2017-06-10 15:14:28 +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
Brian Daniels 70dd7cc273 Fixing some issues in the tcp/udp tests 2017-06-10 15:14:28 +01:00
Brian Daniels f313bc2988 Arranging logic in test to prevent left-over behavior 2017-06-10 15:14:28 +01:00
Brian Daniels dc87aaad1c Making udp_echo_parallel test more robust against network issues.
Making the test more forgiven for minor networking issues. Also adding
more debug prints to make it easier to see which packets are coming from
where.
2017-06-10 15:14:28 +01:00
Brian Daniels acaf435d64 Making UDP test less strict on dropped/mismatched packets.
Before, the UDP test was very strict on the number of packets it would
try to match before failing. Now it will keep trying for the whole test
to get enough passing packets. It also includes the test's UUID so you
can validate which packets are being received.
2017-06-10 15:14:28 +01:00
Brian Daniels 98a5262361 Adding failure logs to TCP echo test.
This adds some extra logs to the test for debugging purposes. Also
allows the test to fail immediately if it fails to obtain an IP address.
2017-06-10 15:14:28 +01:00
Brian Daniels 26eafd9958 Allowing dtls test to retry correctly.
The dtls test already has the ability to retry upon a UDP failure.
However the sockets are currently configured to be blocking and to wait
forever. I added a timeout of 1.5 seconds in order the test to correctly
timeout.
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