2017年12月26日 星期二

Create Silicon lab NCP project on ZNET6.0.0

This article describes how to build EFR32 ncp chip side FW via SSV4 on ZNET 6.0.0

1.create a ZNET6.0.0project with customizable NCP FW.



2.If use BRD4001A's mini usb to PC,only support HW flow contorl.
On this test,i use HW flow control.


3.Set EFR32 chip part number,if use BRD4151 or other demo board can input the part number on "Boards".
compile tool can use IAR or GCC. 


4.After generate .isc file,we can check the board header is use HWCONF here:




5.check the NCP-UART plugin


We use HW flow control here and enable the Uart on USART0.

6.Check the Serial plugin as below:




7. generate and open HWCONF
check the CMU, if you don't use LFXO ,here we set False.



If we don't have DCDC on board,you need disable it here:
If we need PTI function,enable it here.


 Because we use BRD4001 to change the uart to USB,so we needenable the virtual com here and set at PA5.

8.After save HWCOF open hal-config.h and set the PTA code here. 


9.Save and compile as below:

If compile succeed we can see the message :


10.After update the FW on EFR32 and test via cygwin:



2017年12月18日 星期一

Silicon lab OTA test on virtual gateway

On this article we  will try to use zigbee OTA on silicon lab reference design virtual gateway and BRD4151A.

We need to prepare two BRD4151A board.
one we load ncp FW and one we load Z3Occupancy sample code.
About the virtual gateway we can refer this document to build it.

UG129: zigbee® Gateway Reference Design User's Guide (RD-0001-0201, RD-0002-0201)

Here is my step:
1.Following UG129 to download "Oracle VM" and install the Virtual gateway.
2.I met a MQTT version error when i try to input “$ sudo apt-get install silabs-zigbee-gateway”
   you can use following command to install MQTT before you use the
 “$ sudo apt-get install silabs-     zigbee-gateway” command.

   $ sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
   $ sudo apt-get update
   $ sudo apt-get install mosquitto


3.Create a Z3Occupancy Sample on ZNET5.10.0 and you can find the OTA version on following plugin.
Generate and compile on version 46.(save the s37 name to "Z3OccupancySensorSoc_V46.s37")
Change the version bigger than 46 (ex:52)and generate ,compile again.

The OTA server will use following three value to verify the OTA image.
The detail description please refer this document.
AN728-OTAClientServerSetup

Manufacturer ID
Image Type ID
OTA version

4.put the version 52 Z3OccupancySensorSoc.ota file to the following folder.
5.Uplaod ncp FW on another BRD4151A

6.upload Z3OccupancySensorSoc.ebl V46 on BRD4151A.

7.Open the Firefox on VM and add Z3OccupancySensorSoc to VM ,you will see following picture

8.You can find there will show OTA file version as below:
9.If you clock the load item ,ZC will send a "ZCL image notify" command to ZED and will start OTA.
If start OTA ,we will see the update bar as below:
10.After finish,we can find the version change to V52



2017年12月15日 星期五

How to use sniffer (Packet Trace ) base on EFR32

此篇討論如何使用EFR32 sniffer 功能(packet trace)
使用usb線 SOC mode篇

優點:
1.Silicon lab packet trace承襲至ember,使用者買了zigbee 開發套件就會附加有相關功能,不需要額外付費

2.可以透過此功能,確定設備本身真的有收到封包,一般有經驗的RD會發現,旁邊的sniffer收到但自己寫的設備不見得收得到,狀況有很多種,例如設備其實已經睡著了,用此功能可以釐清此問題

3.設備本身有sniffer功能,收到封包的RSSI LQI是真實的,如果是旁邊的sniffer收到,RSSI,LQI只能拿來當參考依據.

4.packet trace功能可以在多片板子同時開啟,甚至可以跟ember Em35x系列同時使用,抓封包會更完善

缺點:
1.EFR32目前無法單純當sniffer,亦即必須搭配zigbee FW,只能解出本身的封包,詳細可以參考這一篇文章
EFR32 be a sniffer

準備工具:
EFR32 底板BRD4151A
準備兩塊BRD4151A板子,
然後分別燒錄 HaSampleGateway and HaSampleLight
此兩個sample只有在ZNET5.9.x以及之前的版本才有,在之後的版本進化到Z3Light.




















古老的HaSample code 影片Demo...純分享
HaSample Demo

分別燒錄至兩塊板子



燒錄完成後開啟SSV4在如下位置圈選兩塊板子點選connect,
接著再選擇Launch Console



圈選兩塊板子選擇Start Capture


畫面稍微調整一下...

可以嘗試在console輸入help, or info,確認console可以work

我們先在Gateway端形成zigbee 網路
指令如下
network form [channel:1] [power:1] [panId:2]
  • Create a network on the given channel, power and panId.
    • channel - INT8U - The channel on which to form the network
    • power - INT8S - One byte signed value indicating the TX power that the radio should be set to
    • panId - INT16U - Two byte pan id for the network


接著 gateway permit join
network pjoin [seconds:1]
  • Permit joining on the network for a given number of seconds
    • seconds - INT8U - Number of seconds during which devices will be allowed to join the network. A value of 0xff turns permit joining on permanently

最後HaSampleLight找網路
network find joinable
  • Begin a search for a joinable network. Will automatically attempt to join the first network that it finds.
看到如下圖
Sniffer分成三個主要畫面,上半段為淺顯易懂的圖形化,
下面為單獨的封包,包含802.15.4的ack
中間為下層整理過的封包

如果單獨點選下層一個封包可以觀察到每個byte代表的意思

下圖,例如我們可以由這邊確定設備因為看到permit association 所以才會接著做association 的動作.

要觀察封包RSSI以及收發狀態,可以參考下圖開啟"Radio info"功能,
下圖觀察此Beacon是由誰送誰收


此檔案也可以分享給原廠或相關人員進一步debug
在存檔前必須再做一個動作將NWK key加入

這樣存檔給對方對方才可以解開加密過的message
存的附檔名為.isd

silicon lab packet trace 功能在debug上蠻實用的!!

Silicon lab Zigbee solution EFR32 two Usart tx test

此篇測試使用Silicon lab EFR32 晶片,透過ZNET stack 使用兩組UART 在SOC project上
 測試TX 部分
ZNET5.10.1.0
SOC mode
BRD4151A
Sample code : Z3Switch
Zigbee Type : Sleep end device
USART0 :TX PA0, RX PA1
USART1:TX PC9 ,RX PC 10


Step as below:


We use Z3SwitchSample


We use BRD4151A for the test


Set a event for test


chose maininit callback,and copy it to callback.c file.

not overwrite callback.c when we generate a project.

Default the USART1 on BRD4151A is use for external flash.
So if we want use USART1 we need take off EEPROM plugin .



Generate the project 


Setting the USART 1 to PC9,PC10
The location can be check on datasheet

We don't use the ncp ,so disable here


Disable the SPI to external flash pin define
We try to initial the USART1 on maininit callback.


Fix a ZNET5.10.1 bug ,lose the ","

We print some message on event and set it print every 5 seconds


compile and upload the FW to EFR32


We use the BRD4001A Expansion Header Pinout to connect to CP2104,and connect to PC.



After upload FW ,we can use tera term  to open CP2104 console and can find the TX message fromUSART1  tx PC9 data

Here is the USAR0 from PA0 data

Here is the related UART API .