Filter results by

Using gcc or IAR with ARTIK 030

The latest Simplicity ZigBee stacks (6.x and newer) offer the option of using the GNU compiler (gcc) in addition to the IAR compiler. The advantage is price – gcc is free – but the downside is that the output image size is typically ~20% larger than that of IAR.

Here we demonstrate a project where we get around the size issue for a particularly simple case. You can use this procedure with the IAR compiler as well, without the size limitations; you just need to choose between compilers when you create the project.

Prerequisites

This tutorial makes use of the ZigBee software stack that is part of the Simplicity Studio® 4.0 development installation. The Simplicity tool generates custom source code according to the features you select.

You need to start out with at least one cross-compile toolchain installed prior to loading Simplicity Studio. You can also install both and switch between them.

Once you have a toolchain installed, download and install the Simplicity Studio environment. Follow the Silicon Labs instructions.

The time for completing this tutorial is under an hour, including the download and installation time for necessary software.

If you're not yet familiar with ZigBee fundamentals, we recommend you start with the introductory article first and use the pre-compiled binaries to play with your ARTIK 030 boards.

Creating Z3Light Project

The ZigBee 3.0 Light project is a good starting point. You can use it on most any ZigBee network.

Start out with your ARTIK 030 board connected by USB. The project will not be created correctly if you don't.

Step 1. Create a base project

Here we will create the Z3Light example project provided in the Simplicity ZigBee stack.

  1. Click File » New » Project and select Appbuilder Project.

  2. Select "ZCL Applicant Framework V2" as the application type.

  3. Select SoC for the application stack. Simplicity applications can run either stand-alone (SoC) or as the controller (Host) to a network co-processor (NCP).

  4. Select the Z3Light project.

  5. Rename it or accept the default name.

  6. Verify that the correct SoC part was found as shown in the image, select only the compiler you intend to use, and click Finish.

    The board is ARTIK-030 Mesh Module Radio Board (BRD4300D).
    Make sure you select this board if it does not appear by default.

Step 2. Generate the Z3Light source files

Simplicity Studio has multiple perspectives – Launcher, Simplicity IDE, Configurator, etc. – and it is initially challenging to determine where you need to be. The large red arrow below points to the button that lets you choose.

  1. Go to the Simplicity IDE perspective. You should see a page similar to that below. If you don't see the .isc tab, double-click the .isc file (small red arrow on the left).

  2. Once you can see it, click the Generate button. Simplicity creates the source files for the project and part you have selected.

The file set you have generated is a complete, working solution. However, it lacks one feature for our demonstration: an output to indicate whether the light is "on" or "off".

Step 3. Configure the hardware pins

Let's make a minor change to enable the onboard LEDs to act as our on/off indication when a ZigBee message is received.

The Simplicity "Hardware Configurator" allows you to define and utilize both the specialized pins and the GPIO pins of the device without doing direct coding.

  1. Go to the HAL configuration tab and scroll down until you can click on the Open Hardware Configurator button.

  2. In the Outline view (right-click on the canvas if you don't see it), expand Peripherals and select LED.

  3. In the Properties view, set:
    • Number of LEDs to initialize to 1
    • List of LED indices to initialize to 0
  4. Select the DefaultMode Peripherals tab, and un-check Button. The Button and LED GPIO pins are shared and can conflict.

  5. Use Ctrl-S to save your changes. You'll notice that Simplicity automatically regenerates the files.

  6. Close the Configurator tab and go back to the Simplicity IDE view.

Step 4. Remove unneeded plugins

Most of the Simplicity example projects are designed to fit easily within the available memory space on the processor when optimally compiled using the IAR compiler. With the gcc compiler, code space is limited as compilation is less efficient and produces images about 20% larger than those from the IAR compiler.

If you are using the gcc compiler for this project, you'll need to disable some optional features to make the image fit. Here we choose to remove the Green Power plugins, which are optional for an end device.

  1. Go to the Plugins tab and scroll to the Green Power category.

  2. Un-check all plugins (usually just Client and Common need to be un-checked).

  3. Scroll to the Stack Libraries category.

  4. Un-check the Green Power Library selection.

  5. Click Generate to regenerate the source files with Green Power removed.

If you actually needed Green Power, you could instead remove something else, like the CLI support or router support, in your final project.

Step 5. Compile source files to binary image

As long as you have selected any file within the project, you'll see the Build icon. Click it to begin compilation.

Uploading Images

You will initially upload two different images to your ARTIK 030 development board.

  • Bootloader image (specific to ZigBee or Thread)

  • Project image (specific to your project and changes each time)

All binary files we'll use here end in .s37 as the format type.

After you have uploaded the bootloader once, you won't need to do it again unless you change protocols (say, from ZigBee to Thread). So if you already followed the introductory article and loaded pre-compiled binaries to your board, you can skip reloading the bootloader image.

General Procedure

  • Go to the Simplicity IDE view.

  • Connect the board to your PC using the USB cable. Make sure the board switch is set to AEM.

  • Check that connected devices appear on the left of the screen with identifier numbers. Use these numbers to distinguish between boards/applications.

  • Find the binary file locations for both bootloader and main image files.

  • Right-click on the selected adapter, choose Upload applications…, and enter the binary file locations to start the upload.

Board hang issue. Depending on LED configuration, you may find that the board JTAG circuit hangs – the board doesn't work and doesn't allow you to flash a new image. Workaround: HOLD the reset button while attaching the USB cable, then release. Operation will always be reliable this way.

Find the binary file location

  1. Under your open project, expand the Binaries category.
  2. Right-click on the file ending in ".s37", which is the format used for flash loading.
  3. Select Properties.

  4. Highlight and copy the Location including the full path, then [Esc] or hit Cancel.

Upload binary image using IDE

You can use this method or the next one according to your preference.

  1. Right-click on your adapter and select Upload application….

    Selection grayed out? Once you launch the console, Simplicity automatically connects to a debugger. To upload an image later, hit Disconnect to again make the Upload application… selection clickable.

  2. Under Application Image Path, do not paste your path here – instead, click the Browse button to the far right.

  3. Paste your copied binary path in the File name: box and click Open.

  4. For the initial loading of a new device, also load a bootloader.

    1. Click the "Bootloader" checkbox.
    2. For a bootloader, enter the location of either the file you created or a pre-compiled image if you have one.

    3. Click Erase chip so that the chip will be cleared before upload.
    4. Click OK.
  5. Click Okay to flash-upload the binary file.

Upload binary image using Simplicity Commander

If you prefer a separate tool, try out Simplicity Commander.

From the Launcher perspective, click the Compatible Tools header and then click to highlight your adapter from the list at the left. One of the tools you'll see is Simplicity Commander.

Operation of this tool for flash-loading binaries is intuitive, so we'll just bring it to your attention here. The advantage is that you can leave it open, as it is a separate application from the integrated development environment.

Creating a Bootloader

The procedure for creating a bootloader image is very similar to creating any other application.

  1. Click File » New » Project and select Appbuilder Project.

  2. Select "Gecko Bootloader" as the application type.

  3. Select the bootloader that has "gecko_sdk_suite" in the path.

  4. Select "Internal Storage Bootloader (single image on 512kB device)" to match the 512kB storage of the ARTIK 030 device.

  5. Accept the default name or rename.

  6. Choose the compiler and click Finish.

  7. Generate the files and build the image as usual.

Testing

You can use your Z3 Light project with any ZigBee coordinator.

  1. Connect the A030 board to your development system by USB as always.

  2. Launch the serial console and open Serial 1.

  3. Hit Enter to get a prompt, then type
    net leave

  4. Disconnect the board.

You're now ready to join any network. Just plug it in or insert the battery (set switch to BAT) – the project continuously scans for available networks and joins the first it finds available.

For the coordinator side, if you have an ARTIK gateway development kit, we encourage you to try one of these two options.

  • libzigbee offers a simple and neat way to join your Z3 Light to an IAS Zone device (like a smart button, door contact or motion sensor). Package installation and building the sample programs takes under 5 minutes.

  • Home Assistant provides a higher-level platform to connect your light to Z-Wave, Bluetooth LE, and MQTT-based endpoints (like ARTIK Cloud). Package installation is a little more challenging, so set aside a half hour if you want to go this route.

Troubleshooting

Problem Possible reason Workaround
Z3 device will not join a network There is an HA-compliant coordinator/router in the network that does not follow the Z3 security protocols. Go to the Znet stack tab, click on "ZigBee 3.0 Security", and change it to "Home Automation Security". Then re-generate and re-compile as always.
SiLabs 7021 Temp Sensor not accessible The I2C jumper on the radio board is in the wrong position. Resolder Sensor Enable resistor to the ON position.

Creating Z3Switch Project

Now that you have a working Z3Light, you can create a Z3Switch that will bind with it. This project is a good demonstration of ZigBee binding, which is explained in greater detail in the libzigbee article.

You'll follow a shorter version of the same procedural steps you did for Creating Z3Light Project.

  1. Create a base project – use the Z3Switch project this time.

  2. Generate the Z3Switch source files.

  3. Change the device type to a more basic on/off switch (the project default is a dimmer switch).
    • Click on ZCL clusters tab
    • Highlight Endpoint 1
    • Change ZCL device type to LO On/Off Light Switch
    • Repeat for Endpoint 2
  4. You can skip the hardware pin configuration and removal of unused plugins tasks.

  5. Compile source files to binary image.

Upload your bootloader and image to your second ARTIK 030 board.

Last updated on: