adafruit / Adafruit_WICED_Arduino

Adafruit WICED Feather Arduino BSP
https://www.adafruit.com/products/3056
27 stars 19 forks source link

Adafruit WICED Feather Arduino BSP

This repository contains files used for the Adafruit WICED Feather WiFi board, and allows the WICED Feather to be used within the Arduino IDE.

These files should be placed in the hardware folder of the Arduino IDE, as detailed below:

Manual Arduino BSP Setup

The preferred method of installing the WICED Feather BSP is to use the Adafruit WICED package from the Arduino Board Manager, but if you wish to maintain the git repo to contribute pull requests you can manually install this BSP with the following setup procedure:

Flashing the Bootloader (Optional)

This library requires the USB DFU bootloader to have previously been flashed to the device.

All devices ship from Adafruit with the bootloader in place and you should almost never have to worry about flashing this yourself, but if necessary you can reflash the bootloader using a Segger J-Link or an ST ST-Link/V2:

Note that this will also perform a full flash erase, which may take some time.

For internal development (if you have access to the NDA restricted Adafruit_BroadcomWiFi_Core repo), go to the development branch, and run make clean all flash-all in the projects/adafruittest folder with a Segger J-Link connected. Be sure to connect VTRef to 3.3V on the WICED development board in addition to the SWDIO, SWCLK and Reset pins

Flashing featherlib

Once the bootloader is in place, you need to flash featherlib which contains the Adafruit WiFi library. It resides on a different flash bank than the Arduino sketch and only needs to be flashed once, unless an update is available at which point it should be flashed again.

It will take a moment to upload featherlib due to the file size.

Building a Project

Sketch uses 15,148 bytes (1%) of program storage space. Maximum is 1,048,576 bytes.
Global variables use 12,952 bytes of dynamic memory.
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 239a:0008
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
DfuSe interface name: "Internal Flash   "
Downloading to address = 0x080C0000, size = 22020

Download    [                         ]   0%            0 bytes
Download    [                         ]   0%            0 bytes
Download    [=                        ]   4%         1024 bytes
Download    [==                       ]   9%         2048 bytes
Download    [===                      ]  13%         3072 bytes
Download    [====                     ]  18%         4096 bytes
Download    [=====                    ]  23%         5120 bytes
Download    [======                   ]  27%         6144 bytes
Download    [========                 ]  32%         7168 bytes
Download    [=========                ]  37%         8192 bytes
Download    [==========               ]  41%         9216 bytes
Download    [===========              ]  46%        10240 bytes
Download    [============             ]  51%        11264 bytes
Download    [=============            ]  55%        12288 bytes
Download    [===============          ]  60%        13312 bytes
Download    [================         ]  65%        14336 bytes
Download    [=================        ]  69%        15360 bytes
Download    [==================       ]  74%        16384 bytes
Download    [===================      ]  79%        17408 bytes
Download    [====================     ]  83%        18432 bytes
Download    [======================   ]  88%        19456 bytes
Download    [=======================  ]  93%        20480 bytes
Download    [======================== ]  97%        21504 bytes
Download    [=========================] 100%        22020 bytes
Download done.
File downloaded successfully
dfu-util: Error during download get_status

Note: The error at the end can be ignored, and is related to a problem with the dfu utility.

Updating Windows Binaries

The script to upload to the board is written in Python and located in the tools/source/feather_dfu folder. For Windows users a pre-built binary version is included and used by the Arduino IDE so that Python and other dependencies do not need to be installed. However this means any time the feather_dfu script is modified a new Windows binary will need to be generated. Follow the steps below on a Windows machine with the 32-bit version of Python (for maximum compatibility with all Windows versions, since 32-bit executables can run on 64-bit Windows too).

First you need to install the dependencies of the script. This is only done once (unless the dependencies change). From inside the tools/source/feather_dfu folder run:

pip install -r requirements.txt --pre

Now to generate a new executable and its related files use the setup.py script and its build_exe action. Internally this is using the cx_Freeze module to embed the script with a Python interpretor and all its depenedencies.

python setup.py build_exe

The output of this command will be in the build subdirectory. Inside will be a subdirectory for the current platform (like exe.win32-2.7), and inside of that folder will be all of the necessary files for the feather_dfu binary. Copy all of these files over the files in the tools/win32-x86/feather_dfu folder to update the binaries.

Note that inside tools/win32-x86/feather_dfu there will be one extra file that is not included in the build steps above, libusb-1.0.dll. This is the 32-bit version of libusb-1.0.dll which can be downloaded from http://libusb.info. The DLL must be located inside the feather_dfu directory next to the executable.

Windows 32-bit Python side-by-side 64-bit Python

Typically on Windows you will install the 64-bit version of Python, however this presents a challenge when building binaries with cx_Freeze since it will use this 64-bit version of Python exclusively. To generate a 32-bit binary you will need to install a 32-bit version of Python side-by-side the 64-bit version. Unfortunately this is a tricky process but it can be simplified using the virtualenv tool.

The steps below outline a general process for installing 64-bit Python as the main Python interpretor and using a 32-bit Python virtualenv side-by-side to build 32-bit executables with cx_Freeze.

First install Python 2.7 x64 in its normal C:\Python27 location.

Next install Python 2.7 x86 but override the location to be something unique like C:\Python27-x86. Also you must set the register extensions option in the installer to disabled/not installed (this will prevent the 32-bit version taking over the default path, etc.).

Now open a command window and navigate to the path that Python 32bit was installed and run the scripts/pip.exe to install virtualenv in 32bit python:

c:\Python27-x86\Scripts\pip.exe install virtualenv

To create a virtualenv use the virtualenv.exe (also installed in the Scripts folder) like normal. For example to create a new virtual environment called py32 open a terminal in your home directory and run:

c:\Python27-x86\Scripts\virtualenv.exe py32

The created virtualenv will have a Scripts subdirectory with an activate.bat. When this bat file is run it will setup the environment to use Python 32-bit. For example from your home directory run in a command terminal:

.\py32\Scripts\activate.bat

Now Python, pip, etc. should all be using the 32-bit Python virtual environment. You can build software with cx_Freeze etc and it will use this 32-bit version of Python.

Frequently Asked Questions

Q1

Q: When I try to build I'm getting Cannot run program "{runtime.tools.arm-none-eabi-gcc.path}\bin\arm-none-eabi-g++" (in directory "."): CreateProcess error=2, The system cannot find the file specified?

A: This is probably because you don't have the ARM Cortex M3 toolchain installed. Install the necessary GCC toolchain for ARM from the Arduino Board Manager via: Tools->Board->Board Manager then download Arduino SAM Boards (32-bits ARM Cortex-M3)

Q2

Q: When I try to flash using USB DFU I get the following error from feather_dfu.py: Traceback (most recent call last): File "...\hardware\Adafruit_WICED_Arduino/tools/feather_dfu.py", line 1, in <module> import usb.backend.libusb1?

A: This is probably caused by an old version of pysub. Update your pyusb version to 1.0b or higher via the following command:

pip install --upgrade pyusb

Also make sure that you have installed the proper Windows driver .inf files so that libusb can access the device via the correct USB VID and PID combinations.