Filter results by

General Update Procedure

Within the ARTIK ecosystem, ARTIK Cloud provides a mechanism for over-the-air (OTA) firmware updates to ARTIK 0 devices. Wi-Fi®-equipped edge devices use an LWM2M connection direct to ARTIK Cloud, bypassing the gateway (no connection to Edge Node Manager).

Update A05X via Wi-Fi

OTA update of an ARTIK 05x board happens directly from ARTIK Cloud, not using any intermediate gateway. You should be comfortable with the On-boarding process before starting this procedure. The steps are as follows.

  1. Prepare a device type in ARTIK Cloud

  2. Flash the board with an OTA-ready firmware

  3. Configure the board

  4. On-board the board to ARTIK Cloud

  5. Prepare an update package

  6. Upload the package to ARTIK Cloud

  7. Trigger the update

OTA update is available on all levels of ARTIK Cloud service – an Enterprise account is not required.

1. Prepare a device type in ARTIK Cloud

Owning Device Type. Create your own Device Type. You must own the Device Type in order to do OTA updates.

Log into ARTIK Cloud and go to the developer portal. Under the Device Types section, create a new device type (or reuse an existing one) that will be used for testing Device Management and OTA from a device manufacturer's point of view. Make sure the device type has properties enabled by clicking the Device Management tab of the device type.

Make sure the properties are enabled, otherwise click the button to enable them.

On-boarding gateway. On-board your gateway before starting, since at least one device of your device type must be registered with ARTIK Cloud to enable Device Properties.

Activating Device Type. Enable Device Properties for your device type in ARTIK Cloud. Create a corresponding manifest for it as well.

2. Flash the board with an OTA-ready firmware

First flash the A05X board with a firmware that contains the necessary client code for OTA and DM with ARTIK Cloud.

  • If using the ARTIK IDE, you can use the “Artik Onboarding” example with the procedure here.

  • If compiling from source code, follow the usual procedures here to build and load the apps/examples/artik_onboarding code.

Verify that the certificate is the current one for ARTIK Cloud. It should match the one shown here for keys.h.

3. Configure the board

In order for the services running on the A05X to be properly configured to connect to ARTIK Cloud, a few parameters need to be changed. This needs to be done only once as parameters will be stored and reused across reboots.

Type the commands below to specify the ARTIK Cloud Device Type ID that you chose for the device (the one that has properties enabled), then configure the address of an NTP server that operates well in your region.

 TASH>> onboard dtid <device type ID>    
 TASH>> onboard ntp <NTP server address>  
 TASH>> onboard reset   

You can check that your parameters are correct with the following command.

 TASH>> onboard config 

Finally reset the board to put it in onboarding mode. Click to see sample output.

 TASH>> reboot                                               
 U-Boot 2017.01-00065-g11a594a84763 (May 04 2017 - 21:26:44 +0900)  
 CPU: Exynos200 @ 320 MHz                                           
 Model: ARTIK-053 based on Exynos T20                               
 DRAM: 722 KiB                                                      
 WARNING: Caches not enabled                                        
 BL1 released at 2017-3-13 15:00                                    
 Flash: 8 MiB                                                       
 *** Warning - bad CRC, using default environment                
 In: serial@80180000                                                
 Out: serial@80180000                                               
 Err: serial@80180000                                               
 Hit any key to stop autoboot: 0                                    
 gpio: pin gpg16 (gpio 46) value is 1                               
 ## Starting application at 0x040C8020 ...                        
 s5j_sflash_init: FLASH Quad Enabled                              
 uart_register: Registering /dev/console                           
 uart_register: Registering /dev/ttyS0                             
 uart_register: Registering /dev/ttyS1                             
 uart_register: Registering /dev/ttyS2                             
 uart_register: Registering /dev/ttyS3                             
 uart_register: Registering /dev/ttyS4                             
 System Information:                                                
 Version: 1.0                                                       
 Commit Hash: fde09b8ec2a969c4a53b2c3eb6b416d9476aeb40              
 Build User: artik@samsung                                          
 Build Time: 2017-06-07 15:33:09                                    
 System Time: 01 Jan 2010, 00:00:00 \[s\] UTC Hardware RTC Support  
 TASH>>Onboarding service version 1.5.2                       
 Starting supplicant in foreground...                               
 Starting AP ARTIK_286d97400b11                                    
 Web server started                                                 
 ARTIK Onboarding Service started                                   

Note the version number of the firmware that is displayed in the console at startup.

4. Onboard the board to ARTIK Cloud

Use the ARTIK on-board app as described here to on-board the device.

5. Prepare an update package

Before a firmware is ready to be uploaded to ARTIK Cloud for deployment, a few steps are needed to generate a proper header.

First make sure you set the version of the firmware you want, in the following file.

apps/examples/artik_onboarding/artik_onboarding.h

 #ifndef _ARTIK_ONBOARDING_H_    
 #define _ARTIK_ONBOARDING_H_     
 #define ONBOARDING_VERSION "1.5.2"  
 /*                                   
 * Service states                     
 */                                   
 ...                                   

Change the ONBOARDING_VERSION definition to the version you want to set. Rebuild the firmware to generate the tinyara_head.bin-signed binary (or tinyara_head.bin for A053 non-secure module).

Now create a script (tested in Ubuntu and macOS) with the following content:

gen-ota-header.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /bin/bash
 
INPUT=$1
OUTPUT=$2
 
if [ $# -ne 2 ]; then
    echo -n -e "Wrong number of parameters\n"
    echo -n -e "Usage: ${BASH_SOURCE} <input file> <output file>\n"
    exit 1;
fi
 
rm -f ${INPUT}.gz
rm -f ${OUTPUT}
 
gzip -k ${INPUT}
 
CRC32=$(crc32 ${INPUT}.gz)
SIZE=$(printf %08x $(wc -c ${INPUT}.gz | awk '{print $1}'))
 
dd if=${INPUT}.gz of=${OUTPUT} bs=1024 seek=4
echo -n -e "\x${CRC32:6:2}\x${CRC32:4:2}\x${CRC32:2:2}\x${CRC32:0:2}" | dd of=${OUTPUT} bs=1 seek=4 conv=notrunc
echo -n -e "\x${SIZE:6:2}\x${SIZE:4:2}\x${SIZE:2:2}\x${SIZE:0:2}" | dd of=${OUTPUT} bs=1 seek=0 conv=notrunc

Run these commands to use the script against the generated firmware to create a compressed OTA package with a proper header.

chmod +x gen-ota-header.sh ./gen-ota-header.sh tinyara_head.bin ota-a05x-firmware-X.Y.Z.bin
(use tinyara_head.bin-signed for A053s and A055s secure modules)

Version number (X.Y.Z) is not mandatory in the filename but it is better to keep track of the firmwares you generate.

Using a modified bl2.bin image? Use this script instead.

"Bad start magic image!" message. If you have modified a binary such as your BL2 code, your signature will be different. Use this script to correct for the changes.


#! /bin/bash

INPUT=$1
OUTPUT=$2

if [ $# -ne 2 ]; then
    echo -n -e "Wrong number of parameters\n"
    echo -n -e "Usage: ${BASH_SOURCE} <input file> <output file>\n"
    exit 1;
fi

rm -f ${INPUT}.gz
rm -f ${OUTPUT}

gzip -k ${INPUT}

# zero padding
TRGSIZE=$(cat ${INPUT}.gz | wc -c)
dd if=/dev/zero bs=1 count=`expr $(expr $(expr $(expr $TRGSIZE + 3) / 4) \* 4) - $TRGSIZE` >> ${INPUT}.gz
OBJSIZE=$(cat ${INPUT}.gz | wc -c)

# add binary
dd if=${INPUT}.gz of=${OUTPUT} bs=1024 seek=4;

# add start magic
echo -n $(printf "TIZE") | \
dd of=${OUTPUT} bs=1 seek=0 conv=notrunc

# add size
echo -n $(printf "%08x" $OBJSIZE) | tac -rs .. | xxd -r -p | \
dd of=${OUTPUT} bs=1 seek=4 conv=notrunc

# add crc
echo -n $(crc32 ${INPUT}.gz) | tac -rs .. | xxd -r -p | \
dd of=${OUTPUT} bs=1 seek=8 conv=notrunc

# add end magic
echo -n $(printf "NRTA") | dd of=${OUTPUT} bs=1 seek=`expr $OBJSIZE + 4096` conv=notrunc
rm -rf ${INPUT}.gz


6. Upload the package to ARTIK Cloud

In ARTIK Cloud's developer portal, go to the Device Management tab of the relevant device type, then click the OTA Updates subtab, then click the Upload new image button.

In the upload window, select Edge Node as the image type then enter the version for the package, this string must exactly match the one you set earlier with ONBOARDING_VERSION. Use the browse button to select the prepared package to upload.

Click the Upload button to finalize the uploading. Note that after uploading a firmware, it is impossible to delete it from ARTIK Cloud portal.

7. Trigger the update

Go to ARTIK Cloud's developer portal, and browse to the device type's Device Management pane. In the devices list, identify the currently connected board by its device ID.

Check the device (or devices) you want to update, click Execute then OTA update.

Select the package you want to update, then click Next.

In the next window, you can select a date to schedule the update, or leave empty to launch the update right now. Click Perform OTA Update when ready.

To follow the update process from ARTIK Cloud's portal, go to the Tasks subtab under your device type's Device Management pane. Identify the OTA update task from the list then click it to get the details.

On the device side, it should download the OTA package, reboot, flash the new firmware then boot it. Click to see sample output.

...
LWM2M connection started
LWM2M resource changed: /5/0/1
Downloading firmware from https://api.artik.cloud/v1.1/updates/urls/36f57e4a00ac4c38b425545a69001a82?tk=lsa3FeadCy1bM9ZIJaD8jzpCccXgMGoQEUe7fQP5t5HqnySailkCNwHBhoEG%2BUAxbvsW%2FCTxhAffXCs6sdBdqSLxsxSvXQRzKwsnBZNSO%2B8%3D
with_tls='1', hostname='api.artik.cloud' filename='/v1.1/updates/urls/36f57e4a00ac4c38b425545a69001a82?tk=lsa3FeadCy1bM9ZIJaD8jzpCccXgMGoQEUe7fQP5t5HqnySailkCNwHBhoEG%2BUAxbvsW%2FCTxhAffXCs6sdBdqSLxsxSvXQRzKwsnBZNSO%2B8%3D'
New hostname='ota-updates.artik.cloud' filename='/prod/dtb362449d247e4eceb260dbc599e3eae5/0259b1121fb64389a617f91da065ce5b?&Expires=1497953238&Signature=G7gXZGl7U0z17ySPREXu17YKHp5jVhkBVIp8zpzS5MZ-N1Nh~s-88ty1qh0ofZLjDIIrXFzyxQ7MRpWPnFdSMTpc8Sh32JIyEmkAeTG2L8ey8WJcjc8XZYLI4t7O0dXM4CTWVI501c~ITF7UUP55eFbuZzW41Wtw5tzT4J5PmPLbZwu6SAM0LaZ1fXZbRuRX~fr3Si5IeV~Wgp52l8nnwThw5nrtOtre73jZ6vikRfFHM~YuGGDo7jLXO~IFqjLF27SEhBYzZwXgDiBoFk0an8HN95-WG7KmQTwVwANo6dQ2dSacwAly62C3DTBoCIe8si7OvcrYI4TV2a5gB1YGzw__&Key-Pair-Id=APKAIX7CUHNYD7CJPXOA'
wget_tls_handshake: TLS Init Success
wget_tls_handshake: TLS Handshake Success
Skip OTA header (header_size 0, len 0, remaining_header_size 4096)
Skip OTA header (header_size 4096, len 0, remaining_header_size 0)
wget_tls_handshake: TLS Init Success
wget_tls_handshake: TLS Handshake Success
input_irq_handler: input_irq_handler: Bad sync in header: header=0x96690002
input_irq_handler: input_irq_handler: Bad sync in header: header=0x00f35aa1
wget_base: Connection lost
LWM2M resource execute: /5/0/2
Rebooting in 3 seconds
 
U-Boot 2017.01-00065-g11a594a84763 (May 04 2017 - 21:26:44 +0900)
 
CPU:   Exynos200 @ 320 MHz
Model: ARTIK-053 based on Exynos T20
DRAM:  722 KiB
WARNING: Caches not enabled
BL1 released at 2017-3-13 15:00
Flash: 8 MiB
*** Warning - bad CRC, using default environment
 
In:    serial@80180000
Out:   serial@80180000
Err:   serial@80180000
Hit any key to stop autoboot:  0
gpio: pin gpg16 (gpio 46) value is 1
CRC32 for 044a1000 ... 0452dffa ==> 35890cc1
Found an update image downloaded.
 
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ done
Erased 600 sectors
Updating boot partition...
Uncompressed size: 1154048 = 0x119C00
 
................................................................................................................................................................................................................................................................................................................................................................................................ done
Erased 384 sectors
Done
resetting ...
 
U-Boot 2017.01-00065-g11a594a84763 (May 04 2017 - 21:26:44 +0900)
 
CPU:   Exynos200 @ 320 MHz
Model: ARTIK-053 based on Exynos T20
DRAM:  722 KiB
WARNING: Caches not enabled
BL1 released at 2017-3-13 15:00
Flash: 8 MiB
*** Warning - bad CRC, using default environment
 
In:    serial@80180000
Out:   serial@80180000
Err:   serial@80180000
Hit any key to stop autoboot:  0
gpio: pin gpg16 (gpio 46) value is 1
## Starting application at 0x040C8020 ...
s5j_sflash_init: FLASH Quad Enabled
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS0
uart_register: Registering /dev/ttyS1
uart_register: Registering /dev/ttyS2
uart_register: Registering /dev/ttyS3
uart_register: Registering /dev/ttyS4
System Information:
        Version: 1.0
        Commit Hash: 6a4f3e4bc40db0541ece3cf1cb4ad52007e5e680
        Build User: artik@samsung
        Build Time: 2017-06-19 08:43:22
        System Time: 01 Jan 2010, 00:00:00 [s] UTC Hardware RTC Support
TASH>>Onboarding service version 1.5.4
Starting supplicant in foreground...
Connected to Access Point
Start DHCP client
Start NTP client
Start websocket to ARTIK Cloud
Websocket successfully connected
Start LWM2M connection to ARTIK Cloud
ARTIK Cloud connection started

You can check the device log to see whether the new firmware has been properly booted by looking at the new version string. On the ARTIK Cloud portal side, the task status will be updated after a bit (usually a couple minutes) to reflect the success of the OTA update.

Congratulations, you successfully updated your ARTIK053 board Over-The-Air!

Troubleshooting

If you are using a modified bl2.bin file, you will likely run into these issues.

Signature not found

For IDE v2.0.0 and later: If you are using a modified bl2.bin file and are getting

    "Failed to download firmware: Signature not found"

it is because the newer SDKs implement signature verification. You can disable this feature at the ARTIK 05X board.

First, check to determine whether OTA signature verification is enabled.

TASH» onboard config
Wifi:
    ssid: my_wifi
    passphrase: 159159159
    .
    .
Lwm2m:
    is_ota_update: 0
ota_signature_verification: 1
    signing_time: 17/8/2018
    signing_time_tmp: 17/8/2018
TASH»

To disable verification:

TASH» onboard ota-sig-verif disable

then re-run the onboard config command to make sure you see
ota_signature_verification: 0

Bad start magic image error

The header package must be signed correctly for a modified bl2.bin image. Use this script.

gen-ota-header.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /bin/bash

INPUT=$1
OUTPUT=$2

if [ $# -ne 2 ]; then
    echo -n -e "Wrong number of parameters\n"
    echo -n -e "Usage: ${BASH_SOURCE} <input file> <output file>\n"
    exit 1;
fi

rm -f ${INPUT}.gz
rm -f ${OUTPUT}

gzip -k ${INPUT}

# zero padding
TRGSIZE=$(cat ${INPUT}.gz | wc -c)
dd if=/dev/zero bs=1 count=`expr $(expr $(expr $(expr $TRGSIZE + 3) / 4) \* 4) - $TRGSIZE` >> ${INPUT}.gz
OBJSIZE=$(cat ${INPUT}.gz | wc -c)

# add binary
dd if=${INPUT}.gz of=${OUTPUT} bs=1024 seek=4;

# add start magic
echo -n $(printf "TIZE") | \
dd of=${OUTPUT} bs=1 seek=0 conv=notrunc

# add size
echo -n $(printf "%08x" $OBJSIZE) | tac -rs .. | xxd -r -p | \
dd of=${OUTPUT} bs=1 seek=4 conv=notrunc

# add crc
echo -n $(crc32 ${INPUT}.gz) | tac -rs .. | xxd -r -p | \
dd of=${OUTPUT} bs=1 seek=8 conv=notrunc

# add end magic
echo -n $(printf "NRTA") | dd of=${OUTPUT} bs=1 seek=`expr $OBJSIZE + 4096` conv=notrunc
rm -rf ${INPUT}.gz

Last updated on: