[INFO] lwIP version 2.0 Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [INFO] lwIP version 2.0

Postby Giovanni » Sat Dec 03, 2016 8:05 am

Hi,

I prefer to keep chprintf minimal, it is not meant to be a full implementation, it has to be as small as possible. It is not like you can't print 8/16 bits values using the normal formatters.

Giovanni

Marco
Posts: 128
Joined: Tue Apr 16, 2013 8:22 pm
Has thanked: 4 times
Been thanked: 11 times

Re: [INFO] lwIP version 2.0

Postby Marco » Sat Dec 03, 2016 12:38 pm

Hi Giovanni,

I agree, then i think we can just keep chprintf as it is now. Adding the 16-bit support also makes it bigger.

Marco

User avatar
quanghgx
Posts: 6
Joined: Sun Nov 20, 2016 5:02 pm
Location: Hanoi, Vietnam
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: [INFO] lwIP version 2.0

Postby quanghgx » Sun Dec 04, 2016 1:28 pm

Dear Marco,
The nice thing about the pppos netif would be that you can choose between the SerialDriver or Serial over USB driver as interface.

Yes, this also means, we can make a fully functional ChibiOS - LWIP 2.0 integration without either GPRS modem or even USB to TTL adapter.

Btw, this is already done on David Albert's article long time ago. And I did lot of LWIP test (Unix port) only with PPPD before moving to real GPRS modem.
[2] David Albert wonderful article about ChibiOS, PPP new and Linux PPPD

I did put other two very useful references on the readme file: https://bitbucket.org/quanghgx/rt-stm32 ... y-lwip-ppp

Thank you Marco.

User avatar
quanghgx
Posts: 6
Joined: Sun Nov 20, 2016 5:02 pm
Location: Hanoi, Vietnam
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: [INFO] lwIP version 2.0

Postby quanghgx » Thu Dec 15, 2016 2:04 am

Dear Marco,

I've just updated the "minimal change" LWIP 2.0 binding version:
    Using USB Serial instead of Serial.
    Using actual ChibiOS mutex as LWIP_TCPIP_CORE_LOCK is default in LWIP 2.0 (recommended by LWIP document)

STM32F4 Discovery default usb port (OTG-FS) only has 4 end-points, so cannot have dual USB Serials. The logging remain using SD2. Btw, people now can test LWIP 2.0 PPPoS integration without anything other than a STM32F4 Discovery board itself.

I did successful running a fully integrated LWIP 2.0 and MQTT (paho C client) with ChibiOS on a STM32F103 with 48KB of RAM. It has been running smoothly for almost a week now.

Todo: make lwip.mk like original ChibiOS LWIP binding, handling PPP reconnection and link status on STM32F4 Discovery demo.

Here is the link again.
https://bitbucket.org/quanghgx/rt-stm32 ... y-lwip-ppp

Thank you Marco.

Marco
Posts: 128
Joined: Tue Apr 16, 2013 8:22 pm
Has thanked: 4 times
Been thanked: 11 times

Re: [INFO] lwIP version 2.0

Postby Marco » Thu Dec 15, 2016 10:51 am

Hi quanghgx,

Thanks for the new update!

Yesterday i also got pppos working (using SerialDriver) with pppd on ubuntu so my idea works. It is very easy to start a network interface like ethernet or pppos or even two pppos interfaces. They also run simultaneously. I will try to put my work so far on Github tonight so you can also review it.

Marco

Marco
Posts: 128
Joined: Tue Apr 16, 2013 8:22 pm
Has thanked: 4 times
Been thanked: 11 times

Re: [INFO] lwIP version 2.0

Postby Marco » Thu Dec 15, 2016 11:13 pm

Hi,

I put my work so far for the lwip bindings here on Github: https://github.com/marcoveeneman/ChibiO ... wip_update

I only tested it on a modified demo for the Tiva TM4C1294 Launchpad but it should be easy to adapt for other boards as long as they support the MAC and SD drivers. In this demo there are two network interfaces; Ethernet and PPPoS.

SD1 is used for lwip debug output and SD4 is used for the pppos connection.

Here is the modified main.c file from the contrib repository on github.

Code: Select all

/*
    Copyright (C) 2014..2016 Marco Veeneman

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

#include "ch.h"
#include "hal.h"
#include "lwipthread.h"
#include "lwip_ethernetif.h"
#include "lwip_ppposif.h"
#include "web/web.h"

#define LWIP_ETHADDR_0                      0xC2
#define LWIP_ETHADDR_1                      0xAF
#define LWIP_ETHADDR_2                      0x51
#define LWIP_ETHADDR_3                      0x03
#define LWIP_ETHADDR_4                      0xCF
#define LWIP_ETHADDR_5                      0x46

#define LWIP_IFNAME0                        'm'
#define LWIP_IFNAME1                        's'

static uint8_t mac_address[ETHARP_HWADDR_LEN] = { LWIP_ETHADDR_0,
                                                  LWIP_ETHADDR_1,
                                                  LWIP_ETHADDR_2,
                                                  LWIP_ETHADDR_3,
                                                  LWIP_ETHADDR_4,
                                                  LWIP_ETHADDR_5 };

static const MACConfig mac_config = {
  mac_address
};

static const LwIPEthernetIFConfig ethernet_config = {
  &ETHD1,
  &mac_config,
  { LWIP_IFNAME0, LWIP_IFNAME1 },
  IPADDR4_INIT(PP_HTONL(0xC0A8010AUL)), /* 192.168.1.10 */
  IPADDR4_INIT(PP_HTONL(0xC0A80101UL)), /* 192.168.1.1 */
  IPADDR4_INIT(PP_HTONL(0xFFFFFF00UL))  /* 255.255.255.0 */
};

static LwIPEthernetIFDriver ethernet;


static const LwIPPPPoSIFConfig pppos_config = {
  &SD4,
  NULL,
  "aa"
};

static LwIPPPPoSIFDriver pppos;

#define LINE_UART3_RX           PAL_LINE(GPIOA, 4U)
#define LINE_UART3_TX           PAL_LINE(GPIOA, 5U)

/*
 * Application entry point.
 */
int main(void)
{
  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   * - lwIP subsystem initialization.
   */
  halInit();
  chSysInit();

  /* Configure RX and TX pins for UART0.*/
  palSetLineMode(LINE_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
  palSetLineMode(LINE_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));

  /* Configure RX and TX pins for UART1.*/
  palSetLineMode(LINE_UART3_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
  palSetLineMode(LINE_UART3_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
  /*
   * Start the serial driver with the default configuration.
   * Used for debug output of LwIP.
   */
  sdStart(&SD1, NULL);

  /* Initialize LwIP */
  lwipInit();

  /*
   * Initialize and start the LwIP ethernet interface.
   */
  lwipEthernetIFObjectInit(&ethernet);
  lwipEthernetIFStart(&ethernet, &ethernet_config);

  /*
   * Initialize and start the LwIP PPPoS interface.
   */
  lwipPPPoSIFObjectInit(&pppos);
  lwipPPPoSIFStart(&pppos, &pppos_config);

  /*
   * Creates the HTTP thread (it changes priority internally).
   */
  chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
                    http_server, NULL);

  while (1) {
    osalThreadSleepMilliseconds(500);
  }

  return 0;
}


Note that this is still a very early draft version so please comment :)

Marco

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [INFO] lwIP version 2.0

Postby Giovanni » Fri Dec 16, 2016 3:35 pm

I see you are encapsulating the application-facing functions in a ChibiOS-like APIs, good idea, will help users feel at home :)

Giovanni

Marco
Posts: 128
Joined: Tue Apr 16, 2013 8:22 pm
Has thanked: 4 times
Been thanked: 11 times

Re: [INFO] lwIP version 2.0

Postby Marco » Fri Dec 16, 2016 11:14 pm

Giovanni wrote:I see you are encapsulating the application-facing functions in a ChibiOS-like APIs, good idea, will help users feel at home :)

Giovanni


Correct :) I realy like this API style, once you understand the object oriented approach you can use it for (almost) anything i think.

This also makes it very easy to start and stop a network interface on the fly. I will try to improve the code a bit and maybe add a PPPoE network interface driver.

Marco

Marco
Posts: 128
Joined: Tue Apr 16, 2013 8:22 pm
Has thanked: 4 times
Been thanked: 11 times

Re: [INFO] lwIP version 2.0

Postby Marco » Thu Jan 12, 2017 9:50 am

Hi quanghgx,

FYI LwIP just added a MQTT client implementation to their git repo.

Marco

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

LWIP bug fix releases

Postby steved » Thu Jan 12, 2017 3:07 pm

Versions 1.4.1 and 2.0.1 of LWIP have just been released.
Mostly bug fixes; also an MQTT client added (in V2 at least).


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 10 guests