From 1874692d8182fbc73e72e9dd775dadc6b546f26b Mon Sep 17 00:00:00 2001 From: wyhong <30567533+wy-hh@users.noreply.github.com> Date: Wed, 12 Apr 2023 21:03:09 +0800 Subject: [PATCH] [Bouffalolab] Update lighting-app zap, partition table and flash download script (#26025) * Update lighting-app zap, partition table and flash download script * Fix restyled --- .../data_model/lighting-app-thread.matter | 40 +++++++- .../data_model/lighting-app-thread.zap | 51 +++++----- .../data_model/lighting-app-wifi.matter | 48 +++++++--- .../data_model/lighting-app-wifi.zap | 80 +++++----------- .../bl602/flash_config/partition_cfg_2M.toml | 25 +++-- .../bl602/flash_config/partition_cfg_4M.toml | 23 +++-- .../bl702/flash_config/partition_cfg_2M.toml | 30 ++++-- .../flashing/bouffalolab_firmware_utils.py | 92 ++++++++++++++++--- 8 files changed, 259 insertions(+), 130 deletions(-) diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter index e88b303e7d3c52..f8c8295607ab8f 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter @@ -1169,8 +1169,6 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; - - command ResetCounts(): DefaultSuccess = 0; } /** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices. @@ -1557,6 +1555,24 @@ server cluster ColorControl = 768 { readonly attribute enum8 colorMode = 8; attribute bitmap8 options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; + readonly attribute int16u primary1X = 17; + readonly attribute int16u primary1Y = 18; + readonly attribute nullable int8u primary1Intensity = 19; + readonly attribute int16u primary2X = 21; + readonly attribute int16u primary2Y = 22; + readonly attribute nullable int8u primary2Intensity = 23; + readonly attribute int16u primary3X = 25; + readonly attribute int16u primary3Y = 26; + readonly attribute nullable int8u primary3Intensity = 27; + readonly attribute int16u primary4X = 32; + readonly attribute int16u primary4Y = 33; + readonly attribute nullable int8u primary4Intensity = 34; + readonly attribute int16u primary5X = 36; + readonly attribute int16u primary5Y = 37; + readonly attribute nullable int8u primary5Intensity = 38; + readonly attribute int16u primary6X = 40; + readonly attribute int16u primary6Y = 41; + readonly attribute nullable int8u primary6Intensity = 42; readonly attribute int16u enhancedCurrentHue = 16384; readonly attribute enum8 enhancedColorMode = 16385; readonly attribute int8u colorLoopActive = 16386; @@ -2033,7 +2049,7 @@ endpoint 0 { } } endpoint 1 { - device type dimmablelight = 257, version 1; + device type extendedcolorlight = 269, version 1; server cluster Identify { ram attribute identifyTime default = 0x0000; @@ -2096,6 +2112,24 @@ endpoint 1 { ram attribute colorMode default = 0x01; ram attribute options default = 0x00; ram attribute numberOfPrimaries; + ram attribute primary1X; + ram attribute primary1Y; + ram attribute primary1Intensity; + ram attribute primary2X; + ram attribute primary2Y; + ram attribute primary2Intensity; + ram attribute primary3X; + ram attribute primary3Y; + ram attribute primary3Intensity; + ram attribute primary4X; + ram attribute primary4Y; + ram attribute primary4Intensity; + ram attribute primary5X; + ram attribute primary5Y; + ram attribute primary5Intensity; + ram attribute primary6X; + ram attribute primary6Y; + ram attribute primary6Intensity; ram attribute enhancedCurrentHue default = 0x0000; ram attribute enhancedColorMode default = 0x01; ram attribute colorLoopActive default = 0x00; diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap index 84e31ba4ae3212..3678fd16460206 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 95, "creator": "zap", "keyValuePairs": [ { @@ -3045,7 +3045,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 0 } ], @@ -5438,7 +5438,7 @@ ] }, { - "name": "MA-dimmablelight", + "name": "MA-extendedcolorlight", "deviceTypeName": "MA-dimmablelight", "deviceTypeCode": 257, "deviceTypeProfileId": 259, @@ -7471,7 +7471,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7487,7 +7487,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7503,7 +7503,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7519,7 +7519,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7535,7 +7535,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7551,7 +7551,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7567,7 +7567,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7583,7 +7583,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7599,7 +7599,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7615,7 +7615,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7631,7 +7631,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7647,7 +7647,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7663,7 +7663,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7679,7 +7679,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7695,7 +7695,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7711,7 +7711,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7727,7 +7727,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7743,7 +7743,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -8333,13 +8333,14 @@ "deviceIdentifier": 22 }, { - "endpointTypeName": "MA-dimmablelight", + "endpointTypeName": "MA-extendedcolorlight", "endpointTypeIndex": 1, "profileId": 259, "endpointId": 1, "networkId": 0, "endpointVersion": 1, - "deviceIdentifier": 257 + "deviceIdentifier": 269 } - ] -} \ No newline at end of file + ], + "log": [] +} diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter index b200f7dfdafb7b..d06449eb62ecd3 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter @@ -982,21 +982,12 @@ server cluster SoftwareDiagnostics = 52 { kWaterMarks = 0x1; } - struct ThreadMetricsStruct { - int64u id = 0; - optional char_string<8> name = 1; - optional int32u stackFreeCurrent = 2; - optional int32u stackFreeMinimum = 3; - optional int32u stackSize = 4; - } - info event SoftwareFault = 0 { INT64U id = 0; optional CHAR_STRING name = 1; optional OCTET_STRING faultRecording = 2; } - readonly attribute ThreadMetricsStruct threadMetrics[] = 0; readonly attribute int64u currentHeapFree = 1; readonly attribute int64u currentHeapUsed = 2; readonly attribute int64u currentHeapHighWatermark = 3; @@ -1465,6 +1456,24 @@ server cluster ColorControl = 768 { readonly attribute enum8 colorMode = 8; attribute bitmap8 options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; + readonly attribute int16u primary1X = 17; + readonly attribute int16u primary1Y = 18; + readonly attribute nullable int8u primary1Intensity = 19; + readonly attribute int16u primary2X = 21; + readonly attribute int16u primary2Y = 22; + readonly attribute nullable int8u primary2Intensity = 23; + readonly attribute int16u primary3X = 25; + readonly attribute int16u primary3Y = 26; + readonly attribute nullable int8u primary3Intensity = 27; + readonly attribute int16u primary4X = 32; + readonly attribute int16u primary4Y = 33; + readonly attribute nullable int8u primary4Intensity = 34; + readonly attribute int16u primary5X = 36; + readonly attribute int16u primary5Y = 37; + readonly attribute nullable int8u primary5Intensity = 38; + readonly attribute int16u primary6X = 40; + readonly attribute int16u primary6Y = 41; + readonly attribute nullable int8u primary6Intensity = 42; readonly attribute int16u enhancedCurrentHue = 16384; readonly attribute enum8 enhancedColorMode = 16385; readonly attribute int8u colorLoopActive = 16386; @@ -1817,7 +1826,6 @@ endpoint 0 { } server cluster SoftwareDiagnostics { - callback attribute threadMetrics; callback attribute currentHeapFree default = 0x0000000000000000; callback attribute currentHeapUsed default = 0x0000000000000000; callback attribute currentHeapHighWatermark default = 0x0000000000000000; @@ -1894,7 +1902,7 @@ endpoint 0 { } } endpoint 1 { - device type dimmablelight = 257, version 1; + device type extendedcolorlight = 269, version 1; server cluster Identify { ram attribute identifyTime default = 0x0000; @@ -1957,6 +1965,24 @@ endpoint 1 { ram attribute colorMode default = 0x01; ram attribute options default = 0x00; ram attribute numberOfPrimaries; + ram attribute primary1X; + ram attribute primary1Y; + ram attribute primary1Intensity; + ram attribute primary2X; + ram attribute primary2Y; + ram attribute primary2Intensity; + ram attribute primary3X; + ram attribute primary3Y; + ram attribute primary3Intensity; + ram attribute primary4X; + ram attribute primary4Y; + ram attribute primary4Intensity; + ram attribute primary5X; + ram attribute primary5Y; + ram attribute primary5Intensity; + ram attribute primary6X; + ram attribute primary6Y; + ram attribute primary6Intensity; ram attribute enhancedCurrentHue default = 0x0000; ram attribute enhancedColorMode default = 0x01; ram attribute colorLoopActive default = 0x00; diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap index fc2348e2cee121..cb6676170a79b3 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap @@ -1,5 +1,5 @@ { - "featureLevel": 94, + "featureLevel": 95, "creator": "zap", "keyValuePairs": [ { @@ -1795,22 +1795,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "AttributeList", "code": 65531, @@ -2956,7 +2940,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 1, + "included": 0, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -4386,22 +4370,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "AcceptedCommandList", - "code": 65529, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 0, - "storageOption": "External", - "singleton": 1, - "bounded": 1, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "FeatureMap", "code": 65532, @@ -5470,7 +5438,7 @@ ] }, { - "name": "MA-dimmablelight", + "name": "MA-extendedcolorlight", "deviceTypeName": "MA-dimmablelight", "deviceTypeCode": 257, "deviceTypeProfileId": 259, @@ -7503,7 +7471,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7519,7 +7487,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7535,7 +7503,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7551,7 +7519,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7567,7 +7535,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7583,7 +7551,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7599,7 +7567,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7615,7 +7583,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7631,7 +7599,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7647,7 +7615,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7663,7 +7631,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7679,7 +7647,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7695,7 +7663,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7711,7 +7679,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7727,7 +7695,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7743,7 +7711,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7759,7 +7727,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7775,7 +7743,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -8365,14 +8333,14 @@ "deviceIdentifier": 22 }, { - "endpointTypeName": "MA-dimmablelight", + "endpointTypeName": "MA-extendedcolorlight", "endpointTypeIndex": 1, "profileId": 259, "endpointId": 1, "networkId": 0, "endpointVersion": 1, - "deviceIdentifier": 257 + "deviceIdentifier": 269 } ], "log": [] -} \ No newline at end of file +} diff --git a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml index eb53723a9f8255..b7cf58abd724bc 100644 --- a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml +++ b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml @@ -29,7 +29,7 @@ len = 0 type = 3 name = "media" device = 0 -address0 = 0x1A2000 +address0 = 0x1A1000 size0 = 0x47000 address1 = 0 size1 = 0 @@ -40,7 +40,7 @@ len = 0 type = 4 name = "PSM" device = 0 -address0 = 0x1E9000 +address0 = 0x1E8000 size0 = 0x4000 address1 = 0 size1 = 0 @@ -51,7 +51,7 @@ len = 0 type = 5 name = "KEY" device = 0 -address0 = 0x1F1000 +address0 = 0x1F0000 size0 = 0x2000 address1 = 0 size1 = 0 @@ -62,7 +62,7 @@ len = 0 type = 6 name = "DATA" device = 0 -address0 = 0x1F3000 +address0 = 0x1F2000 size0 = 0x5000 address1 = 0 size1 = 0 @@ -74,16 +74,29 @@ len = 0 type = 7 name = "factory" device = 0 -address0 = 0x1F8000 +address0 = 0x1F7000 size0 = 0x7000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 len = 0 + +[[pt_entry]] +type = 8 +name = "MFD" +device = 0 +address0 = 0x1FE000 +size0 = 0x1000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + + #if user want to put RF calibration data on flash, uncomment following pt entry #[[pt_entry]] -#type = 8 +#type = 9 #name = "rf_para" #device = 0 #address0 = 0x1FF000 diff --git a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml index ceb90cc3cb27a2..8fcdd55f3b53c8 100644 --- a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml +++ b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml @@ -41,7 +41,7 @@ type = 4 name = "PSM" device = 0 address0 = 0x3C3000 -size0 = 0x4000 +size0 = 0x8000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 @@ -51,7 +51,7 @@ len = 0 type = 5 name = "KEY" device = 0 -address0 = 0x3F6000 +address0 = 0x3F0000 size0 = 0x2000 address1 = 0 size1 = 0 @@ -62,7 +62,7 @@ len = 0 type = 6 name = "DATA" device = 0 -address0 = 0x3F8000 +address0 = 0x3F2000 size0 = 0x5000 address1 = 0 size1 = 0 @@ -74,19 +74,30 @@ len = 0 type = 7 name = "factory" device = 0 -address0 = 0x3FD000 +address0 = 0x3F7000 size0 = 0x7000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 len = 0 +[[pt_entry]] +type = 8 +name = "MFD" +device = 0 +address0 = 0x3FE000 +size0 = 0x1000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + #if user want to put RF calibration data on flash, uncomment following pt entry #[[pt_entry]] -#type = 8 +#type = 9 #name = "rf_para" #device = 0 -#address0 = 0x1FF000 +#address0 = 0x3FF000 #size0 = 0x1000 #address1 = 0 #size1 = 0 diff --git a/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml b/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml index f6a22deaf30a27..71aacc8cf753b2 100644 --- a/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml +++ b/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml @@ -8,9 +8,9 @@ type = 0 name = "FW" device = 0 address0 = 0x3000 -size0 = 0x12b000 -address1 = 0x12e000 -size1 = 0xC9000 +size0 = 0x134000 +address1 = 0x137000 +size1 = 0xBB000 # compressed image must set len,normal image can left it to 0 len = 0 activeindex = 0 @@ -20,8 +20,8 @@ age = 0 type = 1 name = "mfg" device = 0 -address0 = 0x12A000 -size0 = 0xC9000 +address0 = 0x137000 +size0 = 0xBB000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 @@ -33,8 +33,8 @@ age = 0 type = 2 name = "PSM" device = 0 -address0 = 0x1F7000 -size0 = 0x4000 +address0 = 0x1F2000 +size0 = 0x8000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 @@ -46,7 +46,7 @@ age = 0 type = 3 name = "media" device = 0 -address0 = 0x1FB000 +address0 = 0x1FA000 size0 = 0x4000 address1 = 0 size1 = 0 @@ -57,6 +57,19 @@ age = 0 [[pt_entry]] type = 4 +name = "MFD" +device = 0 +address0 = 0x1FE000 +size0 = 0x1000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +activeindex = 0 +age = 0 + +[[pt_entry]] +type = 5 name = "factory" device = 0 address0 = 0x1FF000 @@ -67,4 +80,3 @@ size1 = 0 len = 0 activeindex = 0 age = 0 - diff --git a/scripts/flashing/bouffalolab_firmware_utils.py b/scripts/flashing/bouffalolab_firmware_utils.py index c968c90f2f839c..2e7596892da94a 100644 --- a/scripts/flashing/bouffalolab_firmware_utils.py +++ b/scripts/flashing/bouffalolab_firmware_utils.py @@ -86,6 +86,29 @@ 'type': pathlib.Path } }, + 'pk': { + 'help': 'public key to sign and encrypt firmware. Available for OTA image building.', + 'default': None, + 'argparse': { + 'metavar': 'path', + 'type': pathlib.Path + } + }, + 'sk': { + 'help': 'private key to sign and encrypt firmware. Available for OTA image building.', + 'default': None, + 'argparse': { + 'metavar': 'path', + 'type': pathlib.Path + } + }, + 'boot2': { + 'help': 'boot2 image.', + 'default': None, + 'argparse': { + 'metavar': 'path', + } + } }, } @@ -98,16 +121,20 @@ def __init__(self, **options): super().__init__(platform=None, module=__name__, **options) self.define_options(BOUFFALO_OPTIONS) - def get_boot_image(self, config_path): + def get_boot_image(self, config_path, boot2_image): boot_image_guess = None for root, dirs, files in os.walk(config_path, topdown=False): for name in files: - if name == "boot2_isp_release.bin": - return os.path.join(root, name) - elif not boot_image_guess and name.find("release") >= 0: - boot_image_guess = os.path.join(root, name) + print("get_boot_image", root, boot2_image) + if boot2_image: + return os.path.join(root, boot2_image) + else: + if name == "boot2_isp_release.bin": + return os.path.join(root, name) + elif not boot_image_guess and name.find("release") >= 0: + boot_image_guess = os.path.join(root, name) return boot_image_guess @@ -147,10 +174,17 @@ def actions(self): chip_name = None chip_config_path = None - boot_image = None + boot2_image = None dts_path = None xtal_value = None + is_for_ota_image_building = False + is_for_programming = False + has_private_key = False + has_public_key = False + + boot2_image = None + command_args = {} for (key, value) in dict(vars(self.option)).items(): @@ -164,6 +198,9 @@ def actions(self): if key == "application": key = "firmware" work_dir = os.path.dirname(os.path.join(os.getcwd(), str(value))) + elif key == "boot2": + boot2_image = value + continue elif key in options_keys: pass else: @@ -183,11 +220,32 @@ def actions(self): xtal_value = value elif key == "dts": dts_path = value + elif "port" == key: + if value: + is_for_programming = True + elif "build" == key: + if value: + is_for_ota_image_building = True + elif "pk" == key: + if value: + has_public_key = True + elif "sk" == key: + if value: + has_private_key = True arguments.append(arg) print(key, value) + if is_for_ota_image_building and is_for_programming: + print("ota imge build can't work with image programming") + return self + + if is_for_ota_image_building: + if (has_private_key is not has_public_key) and (has_private_key or has_public_key): + print("For ota image signature, key pair must be used together") + return self + print(dts_path, xtal_value) if not dts_path and xtal_value: chip_config_path = os.path.join(tool_path, "chips", chip_name, "device_tree") @@ -195,14 +253,20 @@ def actions(self): arguments.append("--dts") arguments.append(dts_path) - if self.option.erase: - arguments.append("--erase") - - if chip_name == "bl602": - chip_config_path = os.path.join(tool_path, "chips", chip_name, "builtin_imgs") - boot_image = self.get_boot_image(chip_config_path) - arguments.append("--boot2") - arguments.append(boot_image) + if boot2_image: + chip_config_path = os.path.join(tool_path, "chips", chip_name, "builtin_imgs") + boot2_image = self.get_boot_image(chip_config_path, boot2_image) + arguments.append("--boot2") + arguments.append(boot2_image) + else: + if self.option.erase: + arguments.append("--erase") + + if chip_name == "bl602": + chip_config_path = os.path.join(tool_path, "chips", chip_name, "builtin_imgs") + boot2_image = self.get_boot_image(chip_config_path, boot2_image) + arguments.append("--boot2") + arguments.append(boot2_image) os.chdir(work_dir) arguments[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', arguments[0])