MCU/WISE-1510 SDK

From ESS-WIKI
Revision as of 18:49, 17 April 2017 by Thomas107.chen (talk | contribs)
Jump to: navigation, search

Introduction

WISE-1510 is a wireless module integrated with ARM Cortex-M4 Processor and LoRa / LoRaWAN connectivity. This technology is the best solution for Low-Power Wide-Area Network (LPWAN) Applications. LoRaWAN is defined to optimize the power consumption and wide range. Your sensors or applications with low data rate requirement can be achieved years battery lifetime and kilometers long distance connection. Advantech WISE-1510 also provides multi-interfaces for sensor and I/O control. With ARM mbed embedded microprocessor operating system and add-on software stacks, it's convenient to build the application software or sensor algorithm over mbed OS. Data can be quickly and easily acquired and transformed into a different format to communicate with WISE-PaaS or other cloud services. Developer can build their application backbone faster and focus on their applications, value-added services.

Quick Starter of WISE-1510

Debug Port Connection

  1. Connect debug port FPC cable to WISE-1510 debug port (CN1; on the back of PCB)
  2. Connect WISE-ED20 debug board to the FPC debug cable.
  3. Connect USB-to-microUSB cable from WISE-ED20 to the USB port on your PC.

RTENOTITLE

 

Debug Port Setting

WISE-1510 can communicate with a host server (Windows or Linux) by using serial cables. Common serial communication programs such as Hyper Terminal, Tera Term or PuTTY can be used in this case. The example below describes the serial terminal setup using Hyper Terminal on a Windows host:

  1. Connect WISE-ED20 with your Windows PC by using a serial cable.
  2. Open Hyper Terminal on your Windows PC, and select the settings as shown below.

RTENOTITLE

  1. Press reset (red-frame) button on ED-20.

RTENOTITLE

  1. Terminal will show the image version

RTENOTITLE

Development Environment Setup

Overview

ARM mbed is used for you to create applications running on WISE-1510. Your application code is written in C++. It uses the application programming interfaces (APIs) that mbed OS provides. These APIs allow your code to work on different microcontrollers in a uniform way. This reduces a lot of the challenges in getting started with microcontrollers and integrating large amounts of software. Besides, we also provide you node APIs which facilitates LoRa node development. Our offline development tool is the mbed CLI, a command-line tool. This requires having a toolchain installed on your computer. mbed CLI is the name of the ARM mbed command-line tool, packaged as mbed-cli, which enables the full mbed workflow: repositories version control, maintaining dependencies, publishing code, updating from remotely hosted repositories and invoking ARM mbed’s own build system and export functions, among other operations. The basic workflow for mbed CLI is to:

  1. Initialize a new repository, for either a new application (or library) or an imported one.
  2. Build the application code.
  3. Test your build.
  4. Publish your application.

 

Installation

To install mbed CLI, related tools are required to be installed first. Please refer to the video tutorial. ( https://www.youtube.com/watch?v=cM0dFoTuU14 )

Please follow the steps described in the tutorial video to install mbed CLI.

 

  1. Install Python

mbed CLI supports Windows, Linux and Mac OS X operating systems. You can select the OS you prefer to work with. mbed CLI is a Python script, so you’ll need Python to use it. The version 2.7.11 of Python has been verified with mbed CLI.

https://www.python.org/downloads/release/python-2711/

Note: mbed CLI is incompatible with Python 3.

 

  1. (Optional) Install Git or Mercurial

If you would like to maintain your source code in repositories, you can continue with the next step. mbed CLI supports both Git and Mercurial repositories, you can install which one you prefer:

Git - version 1.9.5 or later ( https://git-scm.com/ ).

Mercurial - version 2.2.2 or later ( https://www.mercurial-scm.org/ ).

If you don’t want to use repositories, you can just skip it.

 

  1. Install gcc

mbed CLI invokes the mbed OS 5 tools for various features, such as compiling, testing and exporting to industry standard toolchains. To compile your code, you will need either a compiler or an IDE:

  • Compilers: GCC ARM, ARM Compiler 5, IAR.
  • IDE: Keil uVision, DS-5, IAR Workbench.

We select GCC ARM Embedded, so you can install version 4.9 of GCC ARM Embedded ( https://launchpad.net/gcc-arm-embedded ).

Note: Version 5.0 or any other versions above may be incompatible with the tools.

 

  1.  Install mbed CLI

You can get the latest stable version of mbed CLI from PyPI

<code>$ pip </code>'''install''' mbed-cli

Note: On Linux or Mac, you may need to run with sudo.

 

Finally, you’ve to extract the source code to the working directory from the SDK we released. The structure of the working directory is as below:

docs/                                     <-- Documents for SDK

            loranode_L443_sdk_R1_0_02/mbed-os/         <-- mbed os

            loranode_L443_sdk_R1_0_02/libHLLoraNode.a   <-- Harmony Link Lora Node library

            loranode_L443_sdk_R1_0_02/node_api.h       <-- Node API header file

            loranode_L443_sdk_R1_0_02/main.cpp         <-- Sample code

 

Configuration

After the installation of required tool chains, please set up the directory of mbed CLI to link the folder of toolchains which you want to use for compiling the source tree.

You can set the GCC ARM Embedded location via the command as below:

 

<code>$ mbed config '''--'''</code>'''global''' GCC_ARM_PATH "C:\Program Files\GCC_ARM"
<code>[mbed] C:\</code>Program<code> Files\GCC_ARM now </code>set as global GCC_ARM_PATH

 

 

 

Next, you can select the tool chain and target platform which mbed CLI uses to build applications. Change directory to target mbed program.

 

<code>$ mbed config target NUCLEO_L443RC </code>
<code>[mbed] NUCLEO_L443RC now set as default target in program "xxxxx" </code>

 

<code>$ mbed config toolchain GCC_ARM </code>
<code>[mbed] GCC_ARM now set as default toolchain in program "xxxx" </code>

 

You can see the active mbed CLI configuration via:

<code>$ mbed config --</code>'''list'''
<code>[mbed] </code>'''Global'''<code> config:</code>
GCC_ARM_PATH<code> =C:\</code>'''Program'''<code> Files\GCC_ARM</code> 
<code>[mbed] Local config (xxxx):</code>
<code>TOOLCHAIN=GCC_ARM</code>
<code>TARGET=NUCLEO_L443RC</code>

 

Compilation

mbed CLI uses the current directory as a working context. This means that before calling any mbed CLI command, you must first change to the working directory containing the code. Then, Use the mbed compile command to compile your code:

$ mbed compile -c

Building project xxxxx (NUCLEO_L443RC, GCC_ARM)

Scan: .

Scan: mbed

Scan: env

Compile [  0.5%]: base64.cpp

Compile [  1.0%]: oslmic.cpp

Compile [100.0%]: node_sapi.cpp

Link: xxxxx

Elf2Bin: xxxxx

+--------------------+--------+-------+-------+

| Module             |  .text | .data |  .bss |

+--------------------+--------+-------+-------+

| Fill               |    223 |    16 |    41 |

| Misc               | 104316 |  7804 |  5017 |

| drivers            |   3592 |     4 |   224 |

| hal                |    802 |     0 |     8 |

| platform           |   1782 |     4 |   297 |

| rtos               |    910 |     4 |     4 |

| rtos/rtx           |   7369 |    20 |  6870 |

| targets/TARGET_STM |  19944 |     4 |  1719 |

| Subtotals          | 138938 |  7856 | 14180 |

+--------------------+--------+-------+-------+

Allocated Heap: unknown

Allocated Stack: unknown

Total Static RAM memory (data + bss): 22036 bytes

Total RAM memory (data + bss + heap + stack): 22036 bytes

Total Flash memory (text + data + misc): 146794 bytes

 

Image: ./BUILD/NUCLEO_L443RC/GCC_ARM/xxxxx.bin

Now, you have your application in binary format ready for flashing.

 

Memory Layout

A basic overview of mbed memory model is as below:

Each thread of execution in the RTOS has a separate stack. When you use the RTOS, before explicitly initializing any additional thread, you will have four separate stacks:

•       The stack of the main thread (executing the main function).

•       The idle thread executed each time all the other threads are waiting for external or scheduled events. This is particularly useful for implementing energy saving strategies (like sleep).

•       The timer thread that executes all the time-scheduled tasks (periodic and nonperiodic).

•       The stack of OS scheduler itself (also used by the ISRs).

Stack checking is turned on for all threads, and the kernel will error if an overflow condition is detected.

 RTENOTITLE

Partitioning

The content of flash is portioned by boot loader as below: 

RTENOTITLE

Boot Loader occupies the first 16 kilo-bytes starting at 0x8000000. LoRa Config partition is used to store LoRa parameters, which occupies no more than 4 kilo-bytes. All user own parameters should be written into User Config partition, for which another 4 kilo-bytes are reserved. Application (Runtime image) partition is where users’ application is stored, up to 224 kilo-bytes can be used.


 

Flashing Application (Runtime Image)

To flash runtime image, your terminal program needs to support “Y-Modem”.

Tera Term is used for demonstration here.

 

'Step 1:'UART port connect via debug board

Connect USB-to-microUSB cable from WISE-ED20 to the USB port on your Windows PC.

Open the corresponding COM port in serial program, ex: Tera Term.

Set baud rate to 115200.

RTENOTITLE

Step 2: Runtime image upgrade mode

Press ‘u’ on the PC keyboard and press reset button on ED-20 debug board.

The terminal will show messages as below.

RTENOTITLE

Press "1" to “Download image to the internal Flash”.

RTENOTITLE

Step 3: Start upgrading via Y modem

Select the run-time image ".bin" file via Y-Modem.

RTENOTITLE

Waiting for run-time image transmission is complete.

RTENOTITLE

After downloading completed, the terminal will show as below.

RTENOTITLE

 

Step 4: Reset device

Press reset button on ED-20 debug board to reset device.

 

Testing

Now, you’re ready to test your WISE-1510. The sample application we created is to send sensor data every 5 seconds via LoRa if values are changed. To observe it, you can connect the debug port as described earlier. After reset WISE-1510, the result is shown on your Terminal as below:

RTENOTITLE