Add Z-Stack 3.0.x firmware.

This commit is contained in:
Koen Kanters 2019-04-07 22:15:13 +02:00
parent e98e0e8c2b
commit cbdba4fe8c
17 changed files with 203 additions and 4 deletions

View File

@ -1,5 +1,6 @@
# Z-Stack-firmware
This reposistory contains:
- Compiled Z-Stack firmwares (`.hex` files)
- If you want to use these to flash to your CC253X (using the [Flash Programmer (not v2)](http://www.ti.com/tool/FLASH-PROGRAMMER) for example), make sure you save the __`raw`__ file (`.hex` file should be around 600kb when saved, not 3.5mb)
- If you want to use these to flash to your CC253X (using the [Flash Programmer (not v2)](http://www.ti.com/tool/FLASH-PROGRAMMER) for example).
- If you want to use these to flash to your CC2652R (using the [Flash Programmer v2](http://www.ti.com/tool/FLASH-PROGRAMMER) for example).
- Instructions on how to compile them

View File

@ -23,6 +23,3 @@ In order to make a good choice, it's recommended to first read [the Zigbee2mqtt
## Compiling the firmware
In case you want to compile the firmware yourself, read [COMPILE.md](./COMPILE.md).
## Notes
- The CC2530_CC2591 firmware is also compatible with CC2530 + RFX2401 devices like the GBA GB2530S Zigbee USB-Stick.

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,2 @@
# 20190417
- Initial version.

View File

@ -0,0 +1,22 @@
# Compiling the firmware
## Setup development environment
1. Download and install [Z-STACK-3.0.2](http://www.ti.com/tool/Z-STACK).
2. Download and install [IAR Embedded Workbench for 8051](https://www.iar.com/iar-embedded-workbench/#!?architecture=8051).
*NOTE: For IAR Embedded Workbench for 8051 you need either the full (paid) version or the 30-days evaluation version.*
## Compiling
1. Copy `firmware.patch` to `Z-Stack 3.0.2`
2. Open Git Bash, go to `Z-Stack 3.0.2` and apply the patch using `git apply firmware.patch`.
3. Open `Z-Stack 3.0.2\Projects\zstack\ZNP\CC253x\znp.eww` with IAR Embedded workbench for 8051.
4. Select the correct target:
- For CC2531 select *CC2531 - ZNP-without-SBL*
- For CC2530 or CC2530_CC2591 select *CC2530 - ZNP-without-SBL*
5. Right-click on your target and press options. Go to C/C++ compiler -> preprocessor. Depending on what you want to compile, add one of the following symbols to *Defined symbols*:
- `FIRMWARE_CC2530` (TODO)
- `FIRMWARE_CC2530_CC2531` (TODO)
- `FIRMWARE_CC2531`
6. Press OK.
7. Right-click on your target and click *Rebuild all*.
8. Once finished, you can find the `CC253(0|1)ZNP-Prod.(hex|bin)` file in `Z-Stack 3.0.2\Projects\zstack\ZNP\CC253x\dev`.

View File

@ -0,0 +1,8 @@
# Z-Stack 3.0.2 coordinator firmwares
This directory contains CC2530 (TODO), CC2530_CC2591 (TODO) and CC2531 Z-Stack 3.0.2 coordinator firmware.
## Description
This firmware supports Zigbee 3.0 and allows for 10 **directly** connected devices to the coordinator.
## Compiling the firmware
In case you want to compile the firmware yourself, read [COMPILE.md](./COMPILE.md).

View File

@ -0,0 +1,169 @@
diff --git a/Components/mt/MT_VERSION.c b/Components/mt/MT_VERSION.c
index f374554..720a8fe 100644
--- a/Components/mt/MT_VERSION.c
+++ b/Components/mt/MT_VERSION.c
@@ -21,7 +21,7 @@
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
- PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+ PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
@@ -69,7 +69,7 @@
*****************************************************************************/
const uint8 MTVersionString[] = {
2, /* Transport protocol revision */
- 0, /* Product ID */
+ 2, /* Product ID */
2, /* Software major release number */
7, /* Software minor release number */
2, /* Software maintenance release number */
diff --git a/Components/mt/revision_info.h b/Components/mt/revision_info.h
new file mode 100644
index 0000000..f3887eb
--- /dev/null
+++ b/Components/mt/revision_info.h
@@ -0,0 +1 @@
+#define CODE_REVISION_NUMBER 20190407
\ No newline at end of file
diff --git a/Components/stack/af/AF.c b/Components/stack/af/AF.c
index 5e54237..988416f 100644
--- a/Components/stack/af/AF.c
+++ b/Components/stack/af/AF.c
@@ -405,10 +405,18 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16 Src
#if !defined ( APS_NO_GROUPS )
// Find the first endpoint for this group
grpEp = aps_FindGroupForEndpoint( aff->GroupID, APS_GROUPS_FIND_FIRST );
- if ( grpEp == APS_GROUPS_EP_NOT_FOUND )
- return; // No endpoint found
+ if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) {
+ // No endpoint found, default to endpoint 1.
+ // In the original source code there is a return here.
+ // This prevent the messags from being forwarded.
+ // For our use-case we want to capture all messages.
+ // Even if the coordinator is not in the group.
+ epDesc = afFindEndPointDesc( 1 );
+ }
+ else {
+ epDesc = afFindEndPointDesc( grpEp );
+ }
- epDesc = afFindEndPointDesc( grpEp );
if ( epDesc == NULL )
return; // Endpoint descriptor not found
@@ -425,6 +433,12 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16 Src
epDesc = pList->epDesc;
}
}
+ else if ( aff->DstEndPoint == 10 || aff->DstEndPoint == 11 ) {
+ if ( (epDesc = afFindEndPointDesc( 1 )) )
+ {
+ pList = afFindEndPointDescList( epDesc->endPoint );
+ }
+ }
else if ( (epDesc = afFindEndPointDesc( aff->DstEndPoint )) )
{
pList = afFindEndPointDescList( epDesc->endPoint );
diff --git a/Components/stack/zdo/ZDApp.c b/Components/stack/zdo/ZDApp.c
index 4947bd8..83a590c 100644
--- a/Components/stack/zdo/ZDApp.c
+++ b/Components/stack/zdo/ZDApp.c
@@ -3676,7 +3676,7 @@ void ZDApp_NVUpdate( void )
*/
uint16 ZDApp_CoordStartPANIDConflictCB( uint16 panid )
{
- return ( panid + 1 );
+ return ( panid );
}
/*********************************************************************
diff --git a/Projects/zstack/ZNP/Source/preinclude.h b/Projects/zstack/ZNP/Source/preinclude.h
new file mode 100644
index 0000000..8f8aebf
--- /dev/null
+++ b/Projects/zstack/ZNP/Source/preinclude.h
@@ -0,0 +1,70 @@
+// Shared accross all firmwares
+#define TC_LINKKEY_JOIN
+#define FAKE_CRC_SHDW
+#define ASSERT_RESET
+#define INCLUDE_REVISION_INFORMATION
+#define SECURE 1
+#define BDB_FINDING_BINDING_CAPABILITY_ENABLED 0
+#define ZDSECMGR_TC_DEVICE_MAX 27
+#define DISABLE_GREENPOWER_BASIC_PROXY
+
+// Save memory
+#undef NWK_MAX_BINDING_ENTRIES
+#define NWK_MAX_BINDING_ENTRIES 1
+#undef APS_MAX_GROUPS
+#define APS_MAX_GROUPS 1
+
+// Disabling MULTICAST is required in order for proper group support.
+// If MULTICAST is not disabled, the group adress is not included in the APS header
+#define MULTICAST_ENABLED FALSE
+
+// Save memory, see swra635.pdf
+#define HAL_LCD FALSE
+#define HAL_ADC FALSE
+
+/**
+ * Reduce BCAST_DELIVERY_TIME and increase MAX_BCAST time.
+ * BCAST_DELIVERY_TIME is the length of time a broadcast message is kept in the broadcast table
+ * MAX_BCAST is the max number of messages that are in the broadcast table
+ * If e.g. BCAST_DELIVERY_TIME = 1 second and MAX_BCAST = 10; 10 broadcast messages per second can be send.
+ *
+ * Zigbee2mqtt has a fixed delay of 170ms between each command.
+ * Therefore a BCAST_DELIVERY_TIME = 20 (= 2 seconds) and MAX_BCAST = 12 allows us to send
+ * 2 / 12 = 1 group command per 166ms, which is just below the zigbee2mqtt delay.
+ * Therefore the broadcast table will never get full.
+ */
+#define BCAST_DELIVERY_TIME 20
+#undef MAX_BCAST // avoids incompatible redefinition of macro warning
+#define MAX_BCAST 12
+
+/**
+ * Enable MTO concentrator
+ */
+#define CONCENTRATOR_ENABLE TRUE
+#define CONCENTRATOR_ROUTE_CACHE TRUE
+#define CONCENTRATOR_DISCOVERY_TIME 120
+#define MAX_RTG_SRC_ENTRIES 35
+#define SRC_RTG_EXPIRY_TIME 0
+
+/**
+ * CC2531
+ */
+#if defined FIRMWARE_CC2531
+ #define CC2531ZNP
+ #define NWK_MAX_DEVICE_LIST 5
+ #define MAX_NEIGHBOR_ENTRIES 8
+ #define MAXMEMHEAP 3189
+
+/**
+ * CC2530
+ */
+#elif defined FIRMWARE_CC2530
+ #define TODO 1
+
+/**
+ * CC2530 + CC2591
+ */
+#elif defined FIRMWARE_CC2530_CC2591
+ #define TODO 1
+
+#endif
\ No newline at end of file
diff --git a/Projects/zstack/ZNP/Source/znp.cfg b/Projects/zstack/ZNP/Source/znp.cfg
index 2b8d56d..adb5e42 100644
--- a/Projects/zstack/ZNP/Source/znp.cfg
+++ b/Projects/zstack/ZNP/Source/znp.cfg
@@ -107,3 +107,4 @@
-DMT_APP_FUNC
-DMT_APP_CNF_FUNC
+--preinclude=preinclude.h
\ No newline at end of file