Tuesday, March 31, 2015

It Worked for Me - An Webserver under FreeRTOS on an ESP8266

If you are looking for a webserver to run on an ESP8266 using the FreeRTOS SDK the httpserver_raw server in the contrib-1.4.1.zip file is worth a look.

It compiles and runs using the Unofficial Development Kit for Espressif ESP8266 under Cygwin64 on Windows 7.

The zip file is located at: http://download.savannah.gnu.org/releases/lwip/.

image

Sunday, March 22, 2015

ESP8266 Program Examples

Back in December I had ordered and received an Olimex MOD-WIFI-ESP8266-DEV.  I posted some overview and setup information.

Now I have developed some examples that demonstrate native programming of the ESP8266 in c. The examples were built on Windows using Cygwin64 and the Unofficial Development Kit for Expressif ESP8266.

The examples contain a good bit of documentation in the hopes that they will help other people with their projects.

The basic flow of an ESP8266 program using the Espressif SDK is an event / callback model.  The user defines a set of callbacks in user_init.c.  The callbacks are triggered when events such as a timer also setup in user_init.c expires. 

Another example is a callback that is triggered when a connection is made to the ESP8266 by a client.  This callback can take action based on the connection and may in turn setup additional callbacks.

The example code is on GitHub at digitalhack / dhESP8266.

Hello Digitalhack Example

The first example is a take on the standard helloworld.  I demonstrates use of the user_init.c function for setting up the program, a timer and timer callback function ands printing output to UART0 and UART1.

UART0 is a full UART with both TX and RX that is used to load your code to the ESP8266.  UART1 only has a TX signal and is used for debug messages.

Screen capture from Cygwin of make and flashing the code to the esp8266.

image

UART0 Output from Example

image

UART1 Output from Example

image

Basic Connect Example

This example shows how to setup the ESP8266 to connect to a wireless access point.  The ssid and password for the wireless network are in user_config.h in the examples include file.

UART1 Output from Example

image

Once you see the ip address the EXP8266 has acquired on the debug line (UART1) you should be able to ping the ip address and get a response.

image

Simple Server Example

This example shows how to setup a very simple server.  When a user telnets to the ESP8266 they are prompted for a name.  Once this is entered it is echoed name back to the user before disconnecting.  It demonstrates the callbacks necessary to for TCP communication.

UART1 Output from Example

image

Cygwin screen capture of a session.

image

The example code is on GitHub at digitalhack / dhESP8266.

Saturday, March 7, 2015

pcDuino3 Nano / OpenMediaVault - Setup Windows File Sharing

This is another in the series documenting my setup of a new home server with the Linksprite pcDuino3 Nano.  A listing for the entire series can be found here.  More information on the pcDuino3 Nano can be found at Linksprite’s website and the pcDuino website.

Once you have successfully installed OpenMediaVault you will need a basic configuration to be able to use it. Below is a set of steps that will provide you with basic file sharing for Windows.  You will setup a share named testshare which can be accessed by user testuser using password test123. 

These steps are just to get you started.  The resulting configuration isn’t secure and shouldn’t be used except as a starting point.

To get started enter the IP address of your pcDuino3 Nano OpenMediaVault server.  You will get prompted to login.  Enter username: admin and password: openmediavault and then select the Login button.

image

The page that will come up provides basic information about your OpenMediaServer.  The first thing to do is set the Hostname and Domain name.  Select Network (1) from the menu on the left.

image

Enter the Hostname (1): testshares and Domain name (2): testnet.local.  The select Save (3).

image

Anytime you change a parameter in OpenMediaVault it will ask you to apply the changes.  To do this  you will select Apply (1) and then Yes (2).

image

A message box informing you that the changes are being applied will be shown.  When that message box goes away the changes will have been applied. 

Note that for the steps subsequent to this I will be omitting these two web pages from the instructions as they are always the same.

image

Once the changes have been applied we will next add a user.  To add users select User (1) from the menu on the left.

image

On the next page select +Add (1) and then Add (2).

image

Enter a Username (1): testuser, Password (2): test123, and Confirm password (3): test123.  Make sure that the users Group is selected as that will give you read and write access to the share we create.  Finally select Save (4).  As stated above you will need to Apply the change, select Yes, and wait for the change to be applied.

image 

After you have applied the changes your user will be show.  The next step is to create a file system on our SATA drive.  To do this select File Systems (1) from the menu on the left.

image

On the web page the appears you will select +Create (1)

image

In the box that is displayed select your device (1).  Your SATA device will likely be the only device to select.  Enter a Label (2): Data and select OK (3).

image

After selecting OK you will be warned that all your data on the device will be lost.  Make sure you don’t have anything on the device you care about and select Yes (2).

image

When the device completes formatting you will be returned to the device page and you will need to mount your device.  Select your device (1) and then select Mount (2).  Next select Apply the changes and select Yes.

image

Your device should now show that it is mounted (1).  Next we will create a shared folder.  To do this select Shared Folders (2).

image

On the Shared Folders page select +Add (1).

image

On the Add shared folder box enter the Name (1): testshare, Volume (2): Data and let everything else default.  Select 3 to create the share.

image

The Shared Folders page will now show you shared folder.  The next step is to enable and configure SMB/CIFS.  To do this select SMB/CIFS from the menu on the left.

image

On the SMB/CIFS Setting Tab Enable (1), enter your Workgroup (2): WORKGROUP and then select Save (3).  You will need to Apply the settings and select Yes to apply.

image

The next step is to setup the share.  On the Shares Tab select +Add (1).

image

Check the Enable box (1) and then select you Shared folder (2): testshares and let the rest default.  Finally select Save, the Apply and Yes.

image

The Shares Tab should now show you Shared folder (1).

image

From your windows host browse your network and you should see the TESTSHARES server (1).  Select the server and logon using Username:testuser and Password: test123.

image

After you authenticate you should be able to see the share you created from your Windows PC.

image

You can find more information on OpenMediaVault at http://www.openmediavault.org/.  The Wiki is especially helpful.

Monday, March 2, 2015

pcDuino3 Nano - Home Server NAS Performance

This is another in the series documenting my setup of a new home server with the Linksprite pcDuino3 Nano.  A listing for the entire series can be found here.  More information on the pcDuino3 Nano can be found at Linksprite’s website and the pcDuino website.

Last week I got a comment on my pcDuino3 Nano – NAS or ??? posting where the commenter had found the pcDuino3 Nano unusable as a NAS due to slow performance and lockups.  As I hadn’t done any testing I decided to run some tests.

For testing I used OpenMediaVault running on Debian Wheezy.  The test machine and the pcDuino3 Nano were connected via Gig LAN ports.  On the pcDuino2 Nano I was using a 2.5 inch SATA drive rated at 72000 RPM and 3.0 Gb/s.  For running the tests I used the Intel NAS Performance Toolkit

I ran 8 passes of the full test suite.  The system never locked up and response time was in line with what I would expect from the board.  It will not win any competitions for speed but it is quite usable.

For comparison I ran 4 passes of the full test suite on my Raspberry PI OpenMediaServer.  The Pi also ran all the tests successfully but with much slower response times.

Below is a summary of the results of the tests.

  pcDiuno3 Nano Raspberry PI
HD Video Playback 18.1 4.1
2x HD Video Playback 16.8 4.3
4x HD Video Playback 16.1 4.5
HD Video Record 24.4 9.4
HD Playback and Record 23.0 5.9
Content Creation 3.9 1.2
Office Productivity 25.3 12.9
File copy to NAS 13.1 6.0
File copy from NAS 30.3 3.9
Dir copy to NAS 3.4 2.8
Dir copy from NAS 6.6 2.9
Photo Album 4.1 2.2

I am working on some posts about configuring OpenMediaVault on the pcDuino3 Nano. I should have them posted in a week or two.

Monday, February 16, 2015

pcDuino3 Nano - OpenMediaVault Install

This is another in the series documenting my setup of a new home server with the Linksprite pcDuino3 Nano.  A listing for the entire series can be found here.  More information on the pcDuino3 Nano can be found at Linksprite’s website and the pcDuino website.

Now that I had a clean Debian root file system the next step was to install OpenMediaVault. This was accomplished by following the steps below.

Install the pre-requisite packages.

root@pcduino3-nano:~# apt-get install build-essential git u-boot-tools texinfo texlive ccache zlib1g-dev gawk bison flex gettext uuid-dev libusb-1.0-0-dev

Add openmediavault to your sources.

root@pcduino3-nano:~# echo "deb http://packages.openmediavault.org/public kralizec main" > /etc/apt/sources.list.d/openmediavault.list

root@pcduino3-nano:~# wget -O - http://packages.openmediavault.org/public/archive.key | apt-key add -

root@pcduino3-nano:~# apt-get update

root@pcduino3-nano:~# apt-get install openmediavault

After you answer Y to the install there will be five screens that will require you to provide input.

Package configuration

┌────────────────────────┤ Postfix Configuration ├────────────────────────┐
│                                                                         │
│ Please select the mail server configuration type that best meets your
│ needs.

│  No configuration:
│   Should be chosen to leave the current configuration unchanged.
│  Internet site:
│   Mail is sent and received directly using SMTP.
│  Internet with smarthost:
│   Mail is received directly using SMTP or by running a utility such
│   as fetchmail. Outgoing mail is sent using a smarthost.
│  Satellite system:
│   All mail is sent to another machine, called a 'smarthost', for
│   delivery.
│  Local only:

│                                 <Ok>
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘

 

Package configuration

                    ┌──────┤ Postfix Configuration ├───────┐
                    │ General type of mail configuration:  │
                    │                                      │
                    │       No configuration               │
                    │       Internet Site                  │
                    │       Internet with smarthost        │
                    │       Satellite system               │
                    │       Local only                     │
                    │                                      │
                    │                                      │
                    │       <Ok>           <Cancel>        │
                    │                                      │
                    └──────────────────────────────────────┘

 

Package configuration

┌───────────────────────────┤ Configuring mdadm ├───────────────────────────┐
│                                                                           │
│ If the system's root file system is located on an MD array (RAID), it
│ needs to be started early during the boot sequence. If it is located on
│ a logical volume (LVM), which is on MD, all constituent arrays need to
│ be started.

│ If you know exactly which arrays are needed to bring up the root file
│ system, and you want to postpone starting all other arrays to a later
│ point in the boot sequence, enter the arrays to start here.
│ Alternatively, enter 'all' to simply start all available arrays.

│ If you do not need or want to start any arrays for the root file system,
│ leave the answer blank (or enter 'none'). This may be the case if you
│ are using kernel autostart or do not need any arrays to boot.


│                                  <Ok>
│                                                                           │
└───────────────────────────────────────────────────────────────────────────┘

 

Package configuration

                ┌────────────┤ Configuring mdadm ├────────────┐
                │ MD arrays needed for the root file system:  │
                │                                             │
                │ all________________________________________ │
                │                                             │
                │                   <Ok>                      │
                │                                             │
                └─────────────────────────────────────────────┘

 

Package configuration

┌─────────────────────────┤ ProFTPD configuration ├─────────────────────────┐
│ ProFTPD can be run either as a service from inetd, or as a standalone     │
│ server. Each choice has its own benefits. With only a few FTP             │
│ connections per day, it is probably better to run ProFTPD from inetd in   │
│ order to save resources.                                                  │
│                                                                           │
│ On the other hand, with higher traffic, ProFTPD should run as a           │
│ standalone server to avoid spawning a new process for each incoming       │
│ connection.                                                               │
│                                                                           │
│ Run proftpd:                                                              │
│                                                                           │
│                                from inetd                                 │
│                                standalone                                 │
│                                                                           │
│                                                                           │
│                                  <Ok>                                     │
│                                                                           │
└───────────────────────────────────────────────────────────────────────────┘

Once the install completes initialize OpenMediaVault.

root@pcduino3-nano:~# omv-initsystem

Now reboot the system.  When is has rebooted from a web browser on another machine you should be able to login with Username: admin and Password: openmediavault.

Wednesday, February 11, 2015

pcDuino3 Nano - u-boot, kernel, rootfs and sdcard build instructions

This is another in the series documenting my setup of a new home server with the Linksprite pcDuino3 Nano.  A listing for the entire series can be found here.  More information on the pcDuino3 Nano can be found at Linksprite’s website and the pcDuino website.

I have developed a set of instructions for building u-boot, the sunxi kernel, a debian rootfs and putting it all on an sdcard for the pcDuino3 Nano.

The instructions and the files to support them are on Github.  The manual instructions are derived from Igor Pecovnik’s shell scripts.  I broke them out so that I could get a better idea of everything that was going on and more easily make changes.

Hopefully these will help someone who is looking to build Debian for the pcDuino3 Nano.  If you find any problems with them log an issue on Github or post a comment below.

Thursday, January 29, 2015

pcDuino3 Nano - Debian / OpenMediaVault

This is another in the series documenting my setup of a new home server with the Linksprite pcDuino3 Nano.  A listing for the entire series can be found here.  More information on the pcDuino3 Nano can be found at Linksprite’s website and the pcDuino website.

Back in December when I started my pcDuino3 Nano Home Server Project I outlined how I was replacing my current home server which uses OpenMediaVault running on a Raspberry Pi.  In my pcDuino3 Nano – NAS or ??? post I talked about deciding to use something else as OMV neither OMV nor Debian the flavor of Linux that it runs on has a large installed base on the pcDuino.

As I moved forward with the project and started pulling together the software that I wanted to use for my home server I decided that while a home server could certainly be built from scratch the integration that you get with OMV was worth seeing if I could get it up and running on the pcDuino3 Nano.

Thanks to the excellent build scripts from Igor Pecovnik I have had some initial success and now have OMV running on the pcDuino3 Nano.  I plan to document the build and install process in future posts but I wanted to pass along what I have working in case anyone else is looking to run Debian on the pcDuino3 Nano.

Here are some links:

If you have any feedback please post it in the comments section below.  I will attempt to address any questions as quickly as possible.