How to bring up the network in Spresense?



  • Dear all,

    I am working on a project which requires to capture images and store for neural network training purposes. I am using the camera example to do it. But the limitation I have at the moment is that I cannot go on capturing images for long time, e.g. leave the Spresense for couple of days to capture huge number of image samples because of the SD card cannot accommodate that huge number of files. Hence, I am thinking of writing an external script which runs remotely to the Spresense, and connects to the Spresense time to time, log into it (ssh), copies the images off to a network drive and hence make space in the SD card. To start with I need to bring up the network in the Spresense, assign an IP (or maybe it gets an IP from the DHCP??) and then try log in into the Spresense remotely to see if that works. Has anyone tried this already? Please share your thoughts and point me to any documentation(s) if available.

    Thanks and regadrs,
    Vivek



  • I just noticed that there is no network driver in the Spresense tree (master branch) right now. I did the below:
    $ make menuconfig
    and the below screen comes up which has no Network driver option:

    Screenshot from 2019-10-22 13-58-29.png image url)

    So the question is how to integrate the network support in Spresense. Please point out if I am missing something here.



  • Ok I just realized there no Ethernet on the board. Hence, installing net driver is not an option. Is there any known wifi extension board which works with Spresense? If yes, please point me towards that. Thanks again.





  • Hello @vivekbhadra Sorry for getting in the middle, I am working with Cameras and AI too (for inferencing and to store a few selected ones). Your post caught my attention. Sending the images over WiFi is a good option and it will give you some freedom, BLE to another device for cleaning purposes could be good too, you have several cores, one of them could manage the cleaning process behind the scenes (Just guessing, I don't know what you are doing). Now, if you don't need the images all the time, you could replace the old ones by the new ones.

    Cheers and good luck with your project.


  • DeveloperWorld

    Hi @vivekbhadra

    I think that the best way would to have Spresense send pictures over Wifi to free up the SD card.

    To get the wifi to work:
    https://developer.sony.com/develop/spresense/tutorials-sample-projects/spresense-tutorials/how-to-equip-spresense-with-wifi-connectivity

    I have a set of drivers for ESP8266 that have been ported to Spresense SDK. I will have to email them to you since I can't upload them here.

    BR



  • @TE-KarlKomierowski Thanks a lot Karl for sending the ESP8266 drivers. I will try integrating it in the Spresense SDK. Just to double check, has it already been integrated in the Spresense SDK? In that case I would not spend time on integrating it. But if not, do you have the Kconfig file for the drivers? Thanks again.


  • DeveloperWorld

    @vivekbhadra said in How to bring up the network in Spresense?:

    @TE-KarlKomierowski Thanks a lot Karl for sending the ESP8266 drivers. I will try integrating it in the Spresense SDK. Just to double check, has it already been integrated in the Spresense SDK? In that case I would not spend time on integrating it. But if not, do you have the Kconfig file for the drivers? Thanks again.

    Hi, no they have not been integrated. I simply add them to my makefile to compile to object files to be linked together.



  • @TE-KarlKomierowski ok thanks. I tried compiling the drivers source file and I am getting the below errors:

    esp8266/esp8266_main.c:23:18: fatal error: wifi.h: No such file or directory
     #include "wifi.h"
                      ^
    compilation terminated.
    ERROR: arm-none-eabi-gcc failed: 1
           command: arm-none-eabi-gcc -M -fno-builtin -mabi=aapcs -Wall -Wstrict-prototypes -Wshadow -Wundef -g -Os -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -I. -isystem /home/vbhadra/spresense/sdk/../nuttx/include -D__KERNEL__ -pipe -gdwarf-3 -isystem /home/vbhadra/spresense/sdk/bsp/include -isystem /home/vbhadra/spresense/sdk/modules/include -I /home/vbhadra/spresense/sdk/drivers/lcd -I /home/vbhadra/spresense/sdk/../nuttx/drivers/video -I /home/vbhadra/spresense/sdk/drivers/esp8266 esp8266/esp8266_main.c
    make[1]: *** [.depend] Error 1
    esp8266/esp8266_main.c:23:18: fatal error: wifi.h: No such file or directory
     #include "wifi.h"
                      ^
    compilation terminated.
    

    I guess you might have grabbed the wifi.h from the nuttx tree? In case you still have the same header file, would you mind pass it to me please?

    Cheers


  • DeveloperWorld

    Hi,

    The wifi.h file was just a plain header file holding my wifi credentials.
    Just remove it, or create it, and add the missing defines you will get when you build next time.
    SSID and password probably.

    @vivekbhadra said in How to bring up the network in Spresense?:

    @TE-KarlKomierowski ok thanks. I tried compiling the drivers source file and I am getting the below errors:

    esp8266/esp8266_main.c:23:18: fatal error: wifi.h: No such file or directory
     #include "wifi.h"
                      ^
    compilation terminated.
    ERROR: arm-none-eabi-gcc failed: 1
           command: arm-none-eabi-gcc -M -fno-builtin -mabi=aapcs -Wall -Wstrict-prototypes -Wshadow -Wundef -g -Os -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -I. -isystem /home/vbhadra/spresense/sdk/../nuttx/include -D__KERNEL__ -pipe -gdwarf-3 -isystem /home/vbhadra/spresense/sdk/bsp/include -isystem /home/vbhadra/spresense/sdk/modules/include -I /home/vbhadra/spresense/sdk/drivers/lcd -I /home/vbhadra/spresense/sdk/../nuttx/drivers/video -I /home/vbhadra/spresense/sdk/drivers/esp8266 esp8266/esp8266_main.c
    make[1]: *** [.depend] Error 1
    esp8266/esp8266_main.c:23:18: fatal error: wifi.h: No such file or directory
     #include "wifi.h"
                      ^
    compilation terminated.
    

    I guess you might have grabbed the wifi.h from the nuttx tree? In case you still have the same header file, would you mind pass it to me please?

    Cheers



  • @TE-KarlKomierowski I have now integrated it into the SPRESENSE SDK. I have attached the patch for the changes I had to make for integrating it into the sdk. Also, I have taken out the source code from the patch file.

    From 3918a7c826016c307fc5b3af0012aff766c372bd Mon Sep 17 00:00:00 2001
    From: Vivek Bhadra <vivek.bhadra@sony.com>
    Date: Wed, 23 Oct 2019 14:02:16 +0100
    Subject: [PATCH] Integrating the esp8266 wifi module in SPRESENSE sdk.
    
    ---
     sdk/drivers/Kconfig                |   1 +
     sdk/drivers/Makefile               |   1 +
     sdk/drivers/esp8266/Kconfig        |  18 +
     sdk/drivers/esp8266/Make.defs      |  48 ++
     sdk/drivers/esp8266/esp8266.c      | 799 +++++++++++++++++++++++++++++
     sdk/drivers/esp8266/esp8266.h      |  88 ++++
     sdk/drivers/esp8266/esp8266_main.c | 121 +++++
     sdk/drivers/esp8266/esp8266_main.h |  26 +
     sdk/drivers/esp8266/license.txt    |  12 +
     sdk/drivers/esp8266/wifi.h         |   7 +
     10 files changed, 1121 insertions(+)
     create mode 100644 sdk/drivers/esp8266/Kconfig
     create mode 100644 sdk/drivers/esp8266/Make.defs
     create mode 100644 sdk/drivers/esp8266/esp8266.c
     create mode 100644 sdk/drivers/esp8266/esp8266.h
     create mode 100644 sdk/drivers/esp8266/esp8266_main.c
     create mode 100644 sdk/drivers/esp8266/esp8266_main.h
     create mode 100644 sdk/drivers/esp8266/license.txt
     create mode 100644 sdk/drivers/esp8266/wifi.h
    
    diff --git a/sdk/drivers/Kconfig b/sdk/drivers/Kconfig
    index b4b87157..ca4247a7 100644
    --- a/sdk/drivers/Kconfig
    +++ b/sdk/drivers/Kconfig
    @@ -5,5 +5,6 @@ source "$SDKDIR/drivers/sensors/Kconfig"
     source "$SDKDIR/drivers/lcd/Kconfig"
     source "$SDKDIR/drivers/video/Kconfig"
     source "$SDKDIR/drivers/modem/Kconfig"
    +source "$SDKDIR/drivers/esp8266/Kconfig"
     
     endmenu
    diff --git a/sdk/drivers/Makefile b/sdk/drivers/Makefile
    index f5256112..4f843a3d 100644
    --- a/sdk/drivers/Makefile
    +++ b/sdk/drivers/Makefile
    @@ -44,6 +44,7 @@ include sensors$(DELIM)Make.defs
     include lcd$(DELIM)Make.defs
     include video$(DELIM)Make.defs
     include modem$(DELIM)Make.defs
    +include esp8266$(DELIM)Make.defs
     
     AOBJS = $(ASRCS:.S=$(OBJEXT))
     COBJS = $(CSRCS:.c=$(OBJEXT))
    diff --git a/sdk/drivers/esp8266/Kconfig b/sdk/drivers/esp8266/Kconfig
    new file mode 100644
    index 00000000..b5e97470
    --- /dev/null
    +++ b/sdk/drivers/esp8266/Kconfig
    @@ -0,0 +1,18 @@
    +#
    +# For a description of the syntax of this configuration file,
    +# see the file kconfig-language.txt in the NuttX tools repository.
    +#
    +
    +menuconfig WIFI
    +	bool "WIFI drivers"
    +	---help---
    +		WIFI device drivers.
    +
    +if WIFI
    +
    +config CONFIG_WIFI_ESP8266
    +	bool "ESP8266 Wifi support"
    +	default y
    +	---help---
    +		Enable driver for the ESP8266 Wifi
    +endif
    diff --git a/sdk/drivers/esp8266/Make.defs b/sdk/drivers/esp8266/Make.defs
    new file mode 100644
    index 00000000..abe37fbd
    --- /dev/null
    +++ b/sdk/drivers/esp8266/Make.defs
    @@ -0,0 +1,48 @@
    +############################################################################
    +# lte/drivers/Make.defs
    +#
    +#   Copyright 2018 Sony Semiconductor Solutions Corporation
    +#
    +# 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. Neither the name of Sony Semiconductor Solutions Corporation nor
    +#    the names of its contributors may be used to endorse or promote
    +#    products derived from this software without specific prior written
    +#    permission.
    +#
    +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    +# "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
    +# COPYRIGHT OWNER OR CONTRIBUTORS 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.
    +#
    +############################################################################
    +
    +ifeq ($(CONFIG_WIFI),y)
    +
    +#ifeq ($(CONFIG_WIFI_ESP8266),y)
    +CSRCS += esp8266.c
    +CSRCS += esp8266_main.c
    +#endif
    +
    +DEPPATH += --dep-path esp8266
    +VPATH += :esp8266
    +CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(SDKDIR)$(DELIM)drivers$(DELIM)esp8266)
    +
    +endif
    diff --git a/sdk/drivers/esp8266/wifi.h b/sdk/drivers/esp8266/wifi.h
    new file mode 100644
    index 00000000..bb087e06
    --- /dev/null
    +++ b/sdk/drivers/esp8266/wifi.h
    @@ -0,0 +1,7 @@
    +#ifndef __WIFI__
    +#define __WIFI__
    +#define SSID "1234"
    +#define PASSWORD "1234"
    +#define HOST_NAME "SPRESENSE"
    +#define HOST_PORT 1234
    +#endif 
    -- 
    2.17.1