Tool/software:
We are working on a typical ZCL on/off output switch (router) and are experiencing a problem where groups can't be removed from NV flash.
The problem occurs both when adding/removing groups over the network, or calling add/remove zstack functions from our own firmware on the device.
To confirm no issue without our firmware, we flashed the zr_light_LP_CC2652R7_tirtos7_ticlang light sample app from the SDK with no changes, but still see the same behavior.
For example, when sending ZCL commands from the coordinator:
SEND ZCL command groups_get_group_membership: > > { capacity: 16, groupcount: 0, grouplist: [] } SEND ZCL command add_group { groupid: 0x01, groupname: "group a" }: SEND ZCL command groups_get_group_membership: > > { capacity: 15, groupcount: 1, grouplist: [ 1 ] } SEND ZCL command groups_remove_group { groupid: 0x01}: SEND ZCL command groups_get_group_membership: > > { capacity: 16, groupcount: 0, grouplist: [] }
This is as expected. But after rebooting the device (CPU reset, board reset, or hard power cycle), the group returns:
SEND ZCL command groups_get_group_membership: > > { capacity: 15, groupcount: 1, grouplist: [ 1 ] }
The same behavior is seen when using Zstackapi_ApsAddGroupReq / Zstackapi_ApsRemoveGroupReq / Zstackapi_ApsFindGroupReq locally on the device. The group functionality works fine, but removed groups persist after reboot. Zstackapi_ApsRemoveAllGroupsReq has the same result.
The issue occurs both when the device is connected to the debugger and when running standalone.
It seems the deletion is happening within the groups table in memory (the group can even be re-added after removal), but the changes are not written to NV, and so are loaded into memory again on reboot.
The only function that does remove them is Zstackapi_bdbResetLocalActionReq, which does a full NV clear (via bdb_setFN, which calls zgWriteStartupOptions)
It's not possible to debug further, since aps_RemoveGroup source is not available.
Does the lib cache flash writes to reduce wear? Is there perhaps an API call we missed to "flush" the changes to NV flash?
Environment:
- Device: CC2652R7
- Board: RF-star RF-BM-2652B2
- SDK: simplelink_cc13xx_cc26xx_sdk_7_41_00_17
- CCS: v12.7.1.00001
- Compiler: ti_cgt_tiarmclang_3.2.0.LTS
EDIT:
I note that someone had a similar (same?) issue, which was determined to be a bug in the SDK. See here:
That was two years ago, so I'm assuming it was fixed...?