This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Old Problem,Now no answer,please help me!

Other Parts Discussed in Thread: CC2530, CC2538, Z-STACK, CC2530EM

Old Problem is:

   I use zstack cc2530 2.5.1a for stellaris,I am  compiled the NV_RESTOR and NV_INIT flag for ZC,ZR,ZE,DZDAPP_CONFIG_PAN_ID=0xFFFF.

   I start coordinator,create zigbee network,router and end device join the network,  Then coordinator turn off,router and end device still power on. Wait for a minuter,turn on the coordinator,I find router and end device can't communicate to the coordinator, the coordinator creat a new zigbee network.

    This problem is old, happened for a long time,look these URL:

http://e2e.ti.com/support/wireless_connectivity/f/158/t/150235.aspx

http://e2e.ti.com/support/wireless_connectivity/f/158/t/128464.aspx

on and on.

Although someone give the suggested answer,but after testing I find the suggested answer can't s solve the problem,and many people meet this problem.

So someone can help me?thanks if you can.

 

 

  • Hi,

    the two posts are addressing two different use cases.

    In the first post, it is suggested to define NV_INIT and NV_RESTORE compilation flag. This is needed in order to restore the complete NWK database parameters.

    In the second post, a special use case is described where a coordinator, if reset before any device has joined its network, restarts creating a new network. The reason for this is because by design decision: it is assumed that if a coordinator has formed a network and no device has ever attached to it, then it would not save its network database.

    In your case, you have some devices joining the network formed by the coordinator. So we can eliminate the second hypothesis. I noticed however that you wrongly defined the compilation flag.

    It is NV_INIT and NV_RESTORE, not NV_INIT and NV_RESTOR as you indicated in the post.

    So please make sure there's no typo in your pre-processor defines.

    The right procedure is to define those compilation flags correctly, and have a device attached to the network. please start with only two devices (a coordinator and a router).

    This is working on 2.5.1a code base, on all CC2530 and MSP430+2520. The logic is the same on Stellaris platform, so it should work as well with the default code.

    I encourage you start afresh and repeat the experiment on TI dev platform.

    Please note, Z-Stack is not supported anymore on Stellaris platform. If this is a new design and you need a Cortex-M3 platform, we recommend you use the CC2538.

    In any case, if for some other reason like you are trying this on your board or you modified the standard code and it does not work, I will give you some pointer to debug.

    Simply, in your coordinator code, the decision whether to start afresh with a new network or to use the old NWK base, can be checked by setting a breakpoint in ZDO_StartDevice()

    In case the NWK is created from scratch, then the below branch is entered

    if ( startMode == MODE_HARD )
    {
    devState = DEV_COORD_STARTING;
    ret = NLME_NetworkFormationRequest( zgConfigPANID, zgApsUseExtendedPANID, zgDefaultChannelList,
    zgDefaultStartingScanDuration, beaconOrder,
    superframeOrder, false );
    }

    otherwise, the below branch is entered

    else if ( startMode == MODE_RESUME )
    {
    // Just start the coordinator
    devState = DEV_COORD_STARTING;
    ret = NLME_StartRouterRequest( beaconOrder, beaconOrder, false );

     }

    As you can see, the decision is conditioned by the variable startMode. MODE_RESUME is set in the function ZDApp_RestoreNetworkState(), if the restoration of the NWK NIB is successful.

    This function is called in ZDOInitDevice() function. This is the important part: if compilation flag NV_RESTORE is set, the ZDApp_RestoreNetworkState() function is called in case ZDApp_ReadNetworkRestoreState() returns ZDO_INITDEV_RESTORED_NETWORK_STATE.

    This happens if NV item ZCD_NV_STARTUP_OPTION has ZCD_STARTOPT_DEFAULT_NETWORK_STATE bit cleared.

    And this bit is cleared, as soon an entry in address device manager is made. Which means, a new device has joined the network formed by the coordinator.

    Thanks,

    TheDarkSide

  • thanks so much for reply !

    I am so sorry about that writing the wrong word "NV_RESTOR",in fact real word is "NV_RESTORE".

    In  fact  I know what you mean ,because i haved follow the code which coordinator start or resume a zigbee networt.

    first

     I do: I  don't modefy any code about the zstack cc2530.2.5.1a,I just test the code which is coordinator and  router with "NV_RESTORE" and "NV_INIT",download the hardword.And coordinator creat zigbee network ,two router join zigbee network,warting for a minuter ,restart the coordinator ,find the coordinator has the new PANID and router can't comnunicte to coordinator.

    the numbers test like this is over ten.so do you have test?

     

  • I am pretty sure Z-Stack 2.5.1a doesn't have this priblem. I had lots of test on it. Make sure you erase the flash when you download binary to your cc2530.

  • second:

       I want to know,that if coordinator and router which code has "NV_RESTORE" flag,then coordinator power down,the two router will connect each other,and they parent is't coordnator again,is each other.

    So when coordinator restart,the router will reconnect coordinator ? for the feather of "NV_RESTORE".so what will happen ?

  • lock at this picture:

  • ZR in mesh network doesn't need  polling  so it won't find new parent after you power down ZC. If you enable NV_RESTORE, it will help to route messages when you power on the router again.

  • thanks so much for reply!

    there are two questions about you reply.

    first 

    how do you know 2 router connect with coordinator in the zigbee network ,then the coordinator power down,what will happen about the 2 router,if  they do not find their new parents,they will be along and wait for coordinator power on?where are reasons above that you can find ?you take test or follow the code?

    as we know , coordinator is a router which one can creat zigbee network.

    second 

    why you say "it will help to route messages when you power on the router again."in fact I power on my coordinator.

    I do the test so many times.it 's so easy to get the result.and so many people put the problem on the net and waiting for answer.

    Look at the URL:

    http://bbs.feibit.com/thread-9614-1-1.html

    http://bbs.feibit.com/thread-3460-1-1.html

    http://bbs.feibit.com/thread-11166-1-1.html

    http://www.deyisupport.com/question_answer/wireless_connectivity/f/45/t/25124.aspx

    on and on

    So this problem is only my problem ,you know ?

  • The major job of ZC is to form a new network and allow ZR or ZED to join the network. After that, you doesn't need ZC unless your other ZR or ZED need to send message to ZC. This is the natural of Zigbee mesh network and you can check Zigbee spec to confirm it. By the way, can I know what EVM do you use for your test? 

  • thanks for your reply and what you know about ZC ,and for test,the tool is Ubiqua and Packet Sniffer. I think you know that.

  • Would you tell me what  EVM HW you use?  SmartRF05EB+CC2530EM or your own customized  PCB?

  • what you will want to tell me? 

  • I am trying to help you so I need to know your test HW and SW. I need the information to tell why you have this problem. Actually, I never suffer this problem with the same config of Z-Stack 2.5.1a on SmartRF05EB+CC2530EM.  Anyway, I would like to suggest you try the same test on Z-Stack Home 1.2

  • Hi,

    as Yikai said, the network can live without the coordinator, if you have couple of routers.

    Routers, once commissioned in the network, will live their life without the need of the coordinator there.

    Packets will be routed anyway and end devices, if parented to the coordinator that is off, will attach to one of the existing routers (provided of course, they are in radio distance).

    If you are trying with reference code from TI and reference SW the scenario you have tested works (coordinator started, then powered off and re-powered on again). When the coordinator starts up again, it won't form another network, if NV_INIT and NV_RESTORE are defined.

    So the only explanation is that when you re-power on the coordinator, you have accidentally erased the NV database area.

    How are you powering it on the coordinator: with the IDE and pressing 'download and debug'? If you do so, and have default setting, then it is cleared that the NV is erased during the download configuration.

    As for the other issues you were mentioning, though they seem to describe similar symptoms as yours, they are tied to different configurations and use cases which do not apply to yours. 

    Thanks,

    TheDarkSide

  • thanks so much  for reply .

    first 

    As Yikai suggest,I do the same test on zstack Home 1.2.0,the result is the same:after coordinator re-power,coordinator PANID change,can't communicate with router.

    Sencond

    "How are you powering it on the coordinator:"

    I download the coordinator hex through SmartRF Flash Programmer,download ok and take away the download line.the same way to download the router hex.

     I turn on coordinator and router,coordinator start up,creat zigbee network,routers join the zigbee network.then turn off the coordinator,wait for a minuter,power on coordinator.

    these are my test steps.so do you have question about the test steps and others?

    I follow the code with IDE,after router join the zigbee network,I press "debug ==>reset" button,not "download and debug",so I don't think I have accidentally erased the NV database area.

    so what is wrong with this problem? some one has this problem and some one is ok.really ok?I doubt .

     

     

  • We have tested it again and the SRF06+2530, with Z-Stack Home 1.2.0, behaves as expected.

    If we bring up a coordinator and a router, then power cycle the coordinator and turn it on again after 1 min, the coordinator does not form a new network but resumes operation in the old one.

    This is provided NV_INIT and NV_RESTORE are defined.

    So, unless you have erased the NV storage in between the two operations or you keep powering on the device pressing switch 5 (joystick center) at the same time (which clears out the NV), the behavior you are seeing happens only on your setup.

    Thanks,

    TheDarkSide

  • Thanks so much for your reply and doing the test for me.

           My test is a little different from your test: the router number is at least 2.

          I say again:I have define NV_INIT and NV_RESTORE in coordinator and router code.

         Through the test process,I don't press any key.

         Doing so much times testing, I find:

         that first time repower the coordinator,coordinator resumes the zigbee networt,

         the second time epower,coordinator form a new network.

         In fact maybe the third time,the fourth time repower,coordinator will form a new network.

        My coordinator code use ZNP ,and router code use HA ==>SampleSwitch.So what about you?

        As following the coordinator code in ZDapp.c, uint8 ZDApp_ReadNetworkRestoreState(void)

          zgReadStartupOptions() this function,which function determine resumes network or form new network.if zgReadStartupOptions() return 0x00 ,meaning resumes network,return 0x02 meaning form new network.

          The first time repower coordinator, it return 0x00,second time return 0x02.I don't konw why it will return 0x02,I have set breakpoint at the zgWriteStartupOptions(),and code don't execute zgWriteStartupOptions().

       In addition,in ZDapp.c uint8 ZDApp_RestoreNetworkState( void ), which also determine resumes network or form new network.look at the code:

    uint8 ZDApp_RestoreNetworkState( void )

    {   uint8 nvStat;

      // Initialize NWK NV items  

      nvStat = NLME_InitNV();

      if ( nvStat != NV_OPER_FAILED )  

    {    

    if ( NLME_RestoreFromNV() )    

      {       // Are we a coordinator      

    ZDAppNwkAddr.addr.shortAddr = NLME_GetShortAddr();      

    if ( ZDAppNwkAddr.addr.shortAddr == 0 )        

    ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_COORDINATOR;      

    devStartMode = MODE_RESUME;      

    osal_cpyExtAddr( ZDO_UseExtendedPANID, _NIB.extendedPANID );  

       }    

    else       nvStat = NV_ITEM_UNINIT;

        if ( ZG_SECURE_ENABLED )    

    {       nwkFrameCounterChanges = 0;

          if ( ZG_BUILD_COORDINATOR_TYPE && ZG_DEVICE_COORDINATOR_TYPE )     

      {         ZDApp_RestoreNwkKey();       }    

    }

        // The default for RxOnWhenIdle is true for Routers and false for end devices     // [setup in the NLME_RestoreFromNV()].  Change it here if you want something     // other than default.   }

            if ( nvStat == ZSUCCESS )    

           return ( ZDO_INITDEV_RESTORED_NETWORK_STATE );  

            else     return ( ZDO_INITDEV_NEW_NETWORK_STATE );

    }

     In the function: nvStat = NLME_InitNV();

         (Initialize the Nwk, Assoc device list, and binding NV Items returns ZSUCCESS if successful, NV_ITEM_UNINIT if item did not  exist in NV, NV_OPER_FAILED if failure.)

         I don't know why sometimes NLME_InitNV() return NV_ITEM_UNINIT,that make code to form a new network.this function code I can't follow

       When NLME_InitNV() return ZSUCCESS,but  NLME_RestoreFromNV() ==0,let nvStat = NV_ITEM_UNINIT,form the new network,NLME_RestoreFromNV() I also can't follow.

       Through following the code,I  think there are three reasons to make mistack:

         1.The code read NV data,return the wrong value.But the code we can't follow,and it so bad to find the bug.

         2.The data has not save in NV.But why the first time  repower the coordinator is OK,and the return value is right.

         3. NV storage has erased.but for the whole test process,I don't press anykey and set breakpoint at erase NV function but the code don't execute there,So how the NV storage has erased,who and when erases?

     

  • why????? the word I reply to DarkSide disappear,maybe it is a little long,but that use my two hours to write!!!!!!!

  • Reply again.

    In the short word.

    For the coordinator repower test,my test is a little different from your:the router number is at least two.

    And My coordinator and router Code has define  NV_INIT and NV_RESTORE.

    Through the test process, I don't press  any key!

    The fisrt time repower the coordiantor,coordinator resumes the network,but second or three time repower, coordinator form the new network.

     As following the coordinator code,there are three functions in ZDapp.c

           1.zgReadStartupOptions(),in uint8 ZDApp_ReadNetworkRestoreState( void ).

             this function will return 0x00 or 0x02.when it return 0x00,meaning resumes the network,and return 0x02 meaning form a new network. The first time coordinator repower,it return 0x00,and second time it return 0x02.I don't know why ? I have set the breakpoint at the zgWriteStartupOptions(),but the code don't run the function.

           2.  nvStat = NLME_InitNV();in uint8 ZDApp_RestoreNetworkState( void ).

            Initialize the Nwk, Assoc device list, and binding NV Items returns ZSUCCESS if successful, NV_ITEM_UNINIT if item did not  exist in NV, NV_OPER_FAILED if failure.

           sometimes the NLME_InitNV() return ZSUCCESS,sometimes return NV_ITEM_UNINIT.The code I can't follow the code so I don't know why .

          3.NLME_RestoreFromNV(),also in uint8 ZDApp_RestoreNetworkState( void ).

         When NLME_InitNV() return ZSUCCESS,NLME_RestoreFromNV()  return 0,meaning form a new network,and no 0,resume the network.

         sometime NLME_RestoreFromNV() returm 0, I also don't know why?the code I also can't follow.

         can you tell me why the functions return different ?

          

     

       

  • Is your SmarRF05EB+CC2530EM powered by battery or USB?

  • I am having same problem with 2.5.1a.  It only occurs with SECURITY=1.  With no security the coordinator re-joins network just fine.  With security, it doesn't work until after I send ten to twenty cluster commands from coordinator.  It is the same with each re-start.

    I've commented out the

    //    if(keyItems.frameCounter > 0)

    with no success.  In my case, I have coordinator leave the network to another channel, and then come back (it does thisvia reset).  With NV_INIT and NV_RESTORE I need to set the startup bit for new network join.  It almost works. Normally, the PANID increments by one in the coordinator after it gets the beacon ack from router.  I am over-riding this in ZDApp, preventing the PANID change. 

    I am wondering about this nwkframecounter sutf - not sure what it is doing.  From reading other posts, it appears the problem may be with the ZDApp_RestoreNwkKey() function. 

    Stull stuck...

  • I think the two scenarios are separate.

    For the scenario that happens with Z-Stack Home 1.2.0 where a new PANID is created by the coordinator when it is re-powered, the fact that you are using ZNP is new in this thread and needs to be understood.

    Please start first doing the test with a SRF05+2530 as a coordinator (not in ZNP mode, using the other example applications) and verify that is working because this is what we have tested.

    Then, when you move to ZNP, you need to clarify when you re-power the coordinator, whether you're running again the host code that sends command to the ZNP or not and what is the host code (or the script you are running).

    The second scenario described by Jim is different. In this scenario, the issue is not that coordinator when powered up is forming a new network, but rather that the coordinator though belonging to the same network can't send data anymore to an existing device. 

    This second scenario happens because when security is activated, the recipient of the frame (secured at NWK layer), will check that the NWK frame counter is higher or equal than the received frame counter for that device. This is to overcome reply attacks. 

    There was an issue with 2.5.1a where the NWK framcounter was not incremented correctly when the coordinator was reset and if only few frames were sent out by him. This has been fixed in Z-Stack Home 1.2.0 (please see Z-Stack Core release note, bug marked as 3406.

    Thanks,

    TheDarkSide

  • thanks for your reply.

    From your reply,I get some ideals,you check them right or no.

    1.Your test coordinator code is not the ZNP code,so we do the different test,and can you do the same test like me? then we discuss the same thing.

    2.there's a bug in zstack 2.5.1a,when SECURITY=1,and Home 1.2.0 fix this bug.

    3.you suggust we use Home 1.2.0 code,I guest,because it fix some bugs.

    when you move to ZNP, you need to clarify when you re-power the coordinator, whether you're running again the host code that sends command to the ZNP or not and what is the host code (or the script you are running).

    there are two mode to test.one is Debug mode,another is not Debug mode.

         first not Debug mode, I download ok the coordiantor hex(ZNP:CC2530-TVSA_HEX) and router hex(HA),

           I power on coordinator and router ,when coordinator form the zigbee network,router join the network and communicate with coordinator freely,I power off the coordinator,wait for a min,power on the coordinator.I find the first time repower,the network is ok,and the second time ,router can't not communicate with coordinator,through the soft Ubiqua, I see the coordinator PANID changge.

         second in Debug mode,the coordinator code is ZNP : CC2530-Debug.when routers communicate with coordinator free,I break the coordinator code running,and reset,wait for a min,run again the coordinator code.

  • Please clarify what you mean by ZNP CC2530-TVSA.hex.

    ZNP does not have any application running, it is just ZigBee as a modem. You need to run a combined host code for that.

    Also, there's no TVSA application in Z-Stack Home 1.2.0. So please describe the workspace of Z-Stack Home1.2.0 you used to generated the code running as coordinator. If you just used a ZNP binary, please make sure you are using the CC253xZNP-Pro-Secure_LinkKeyJoin.hex and make sure you share the host code application or you tell which workspace you used to generate the host code application.

    And yes, we always advise our customers to use the latest Z-Stack Home 1.2.0 because it is the latest and greatest.

    Thanks,

    TheDarkSIde

  • You don't know what is TVSA application? I doubt that.

    You can find TVSA instructions at Z-Stack User's Guide for CC2530 ZigBee-PRO Network Processor - Sample Applications.pdf,29 page,show like below:

    4.2 Temperature Voltage Sensor Application (TVSA)  

    The TVSA sample application is intended to show some basics of using the ZNP. In the TVSA network, several ZigBee nodes (ZigBee Routers or ZigBee End Devices) send temperature and voltage measurements at regular intervals to  a central device (ZigBee Coordinator), which is called the “Dongle”.  The Dongle collects this information and sends it to the PC, over a UART connection, for display.  The Dongle acts as the ZigBee coordinator and the data collector point; hence, it does not report its own temperature and voltage.  It interfaces over the UART connection to a PC tool called Z-Sensor Monitor Program (ZigBee Sensor Monitor) [14], which is available from the Texas Instruments Website (e.g. at www.ti.com/cc2530zdk). If desired the UART code on the dongle can easily be adjusted  to fit the UART formatting used by other PC tools. The following sections provide more details regarding the usage and modification of the TVSA sample application.

    You can find the project at c:\Texas Instruments\Z-Stack Home 1.2.0\zstack\ZNP\CC253x\znp.eww,and chose CC2530-TVSA_Hex,like the picture below:

     

  • Hi liang,

    ZNP, as TheDarkSide stated, is a network co-processor and cannot stand alone. To use ZNP, there should be something that can act as ZAP.

    If the ZNP is running on SRF05EB+CC2530EM, what's the ZAP communicating to the ZNP in your case? The ZNP cannot communicate to the PC application(ZigBee Sensor Monitor) directly without ZAP's involvement.

    NV_RESTORE and NV_INIT are basically defined in ZNP projects. However, ZAP is responsible for actually enabling/disabling NV_RESTORE on the ZNP. To enable it, please define ZAP_NV_RESTORE on the ZAP side.

    TVSA ZNP image is tailored for TVSA ZAP to enable source routing. So, please make sure that you build your ZAP based off of TVSA.eww workspace.

    - Cetri

  • Is there a download for zstack 2.6?  Or do I have to use the Home Automation 1.2 to fix this?  No simple code fix for 2.5.1a?

    Jim

  • Ok, I'm not sure this is a good idea - but I think I came up with a workaround for 2.5.1a...

    The idea is to save nwkFrameCounter to NV when coordinator leaves a channel.  When coordinator comes back to that channel, it reads the NV (in application space) for that channel frame counter and restores it inside ZDApp_SecInit / ZDApp.c. 

    So far it seems to work but I haven't done any rigorous testing.

  • thanks for you,Cetri!
    As you say,I think I maybe find why  my question happen.
    We have write a application on linux PC,as ZAP,then ZNP can through UART interface to communicate with linux PC.
    In the application we don't define the ZAP_NV_RESTORE,so coordinator will form a new network.
    I have some questions about ZAP,can you help me?


    1.As the ZNP User's Guide,the ZAP can run on MSP430 or Stellaris ARM Cortex-M3,so we let the ZAP run in linux PC or android PC ,it should be right?
    2.Is there a demo ZAP run on Stellaris ARM Cortex-M3,I can study.
    3.The compile option "ZAP_NV_RESTORE",should be difined in the ZAP,no matter I use the ZNP of zstack 2.5.1a or of zstack 2.3.0-1.4.0.In other word, if my ZNP is the zstack cc2530 2.3.0-1.4.0 ' ZNP,the ZAP also should be defined ZAP_NV_RESTORE,right?

    Best wish to you.

  • Nobody can help me?

  • 1&2. Yes, you can let the ZAP run in linux PC or android PC. However, TI only provides ZAP examples on MSP430 which means you need to do the porting by yourself.

    3. Yes.

  • Thanks for YiKai's reply.

      If YiKai'reply is right,i think there are two solutions to solve the question .

         The first solution need TI help.

          The first solution is:

        I have read the code which "ZAP_NV_RESTORE" haved been defined in the ZAP on MSP430,two place appear "ZAP_NV_RESTORE" :

        1.in zap_app.c,static void zapSync (void)

       #if ZAP_NV_RESTORE   pBuf[0] = ZCD_STARTOPT_AUTO_START;  

    (void)znp_nv_write(ZCD_NV_STARTUP_OPTION, 0, 1, pBuf);

    #else

    2.in zap_zdo.c,uint8 ZDOInitDevice(uint16 startDelay)

    #if ZAP_ZDO_STARTUP_AREQ  

    // Made into an AREQ after empirical results showed > 400 msec delay on SRSP.

    #if ZAP_NV_RESTORE  

    return ZDO_INITDEV_RESTORED_NETWORK_STATE;

    #else  

    return ZDO_INITDEV_NEW_NETWORK_STATE;

    So, if TI Employee can tell me where or when the two functions above I should put in the ZNP code,or in ZAP code ,I think the problem can be solve.

    Second solution:

         I don't use the ZNP code as the coordiantor code,I think I should use SerialApp code.But I find my  ZAP UART form has follow the ZNP uart form ,so I have to change the form and the work is large.

        I think the first solution I should do fewer than the second solution.

  • I just use SerialApp code as coordinator code, but  the repower test,is the same,And I repower second time,coordiantor PANID +1, so I don't know what I can do to lolve the problem.

    The thing is not going on we thinking  the way.

  • No TI Employee on line ? Or  skip here !

  • Hi liang,

    If you use SerialApp for the coordinator, defining NV_RESTORE should work. Did you define NV_RESTORE on the SerialApp coordinator?

    By the way, there is one condition that can clear the network information even if NV_RESTORE is defined. In ZDApp.c, there is ZDAppCheckForHoldKey() to check if the center key of the joystick is pressed during system initialization. If it's pressed, the network information will not be restored and the device will behave as if it's the first time running without stored network information. So please check if the center key is regarded as pressed somehow and devState becomes DEV_HOLD as a result.

    - Cetri