Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[K32W0] SDK 2.6.9 platform updates (#24691)
* Upstream K32W0 SDK 2.6.9 changes [K32W0] Enable hardware SHA256 usage * port/matter/ksdk_mbedtls is now used, which is a lightweight version of port/ksdk/ksdk_mbedtls that contains only AES/SHA ALT implementations. Another difference is that all calls are redirected through SecLib, to protect access to hardware modules through mutexes. * Added flag gSecLibUseSha256Alt_d, which enables correct usage of SecLib switch mechanism between sw/hw SHA256. It also enables the correct overwrite of mbedtls_sha256_context structure in sha256_alt.h * Matter is using lengthy SHA256 operations during CASE/PASE sessions. If hardware SHA256 is used in these cases, subsequent calls to SecLib API will switch to software SHA256. Updated Hash_SHA256_stream:: API to use software SHA256 explicitly. * Bypassed mbedtls_entropy_func in both Matter and Openthread by creating a strong_entropy_func that uses hardware TRNG to generate a seed. Under ot-nxp, a new file was added: crypto.c, which overwrites otPlatRandom* API. The main issue with mbedtl_ entropy_func was that it starts a SHA256 process for the accumulator and another SHA256 process for the final seed. The current SHA256 for the accumulator is finished at the next mbedtls_entropy_func call. This could block the hardware SHA256 indefinitely or over a long period of time (if a SHA256 process is started, but mbedlts_entropy_func is not called anymore). Signed-off-by: Marius Tache <[email protected]> [K32W0] Enable OTA usage of AES through SecLib Ota module uses AES ROM API to access the hardware AES module. Flag gOTA_UseSecLibAes was introduced to redirect all AES calls through SecLib, which protects AES hardware against two situations: - concurrent access through the AES mutex. - ISR interruption through restarting the AES operation if an interrupt occurred (which means the AES key was overwritten). Signed-off-by: Marius Tache <[email protected]> Fix compile issue when chip_enable_ble=false Signed-off-by: Doru Gucea <[email protected]> Enable build time option for FRO32K enablement If a custom board doesn't have a 32KHz crystal fitted, one can use instead the on chip 32 KHz free running oscillator. This is less precise than the crystal but allows for recalibration at certain time intervals, so the drift is reduced. This patch adds the `use_fro_32k` GN option to the build system. If set to 1, this will switch the clock source for 32KHz from crystal to FRO. By default, it is set to 0, so the crystal is used. Also as part of this patch is documenting the option for the relevant NXP K32W0 examples i.e. lighting-app, lock-app & contact-sensor-app Signed-off-by: Alex Porosanu <[email protected]> [K32W0] Add instructions to disable logging for low power Logging is enabled by default (chip_logging set to true), but can be overwritten by setting chip_logging=false in the build arguments. Additionally, a user can disable/enable logging levels/flavors in src/platform/nxp/k32w/k32w0/args.gni. Updated README files for contact-sensor and lock-app to take into account logging disabling. Signed-off-by: Marius Tache <[email protected]> [K32W0] Fix build errors Signed-off-by: Marius Tache <[email protected]> Fix compilation issue: duplicate definition vDynStopAll was introduced in FWK. Signed-off-by: Doru Gucea <[email protected]> Fix undefined function reference ECP256 functions were moved. Signed-off-by: Doru Gucea <[email protected]> Update doc for contact sensor Contact sensor led change Doc update [K32W0] Add correct commissioning flow flag The default value for onboarding commissioning flow is standard (0). Updated the applications to set the correct commissioning flow flag, which is kUserActionRequired (1), since the user has to press a button for the BLE advertising to start. Signed-off-by: Marius Tache <[email protected]> k32w0: Use the new API for Save-on-Idle functionality Signed-off-by: Doru Gucea <[email protected]> k32w0: Early init for OT Settings Early initialization for OT Settings is needed in PDM_SAVE_IDLE context where calibration data callbacks may be called before OT full initialization. Signed-off-by: Doru Gucea <[email protected]> [K32W0] Fix onboarding info call Signed-off-by: Marius Tache <[email protected]> [K32W0] Fix BLE advertising interval The fast/slow advertising macros are expressed in units of 0.625ms, so the macro values should be multiplied by the unit to obtain the actual interval in ms. Signed-off-by: Marius Tache <[email protected]> [K32W0] Set BLE own address type to random Old implementation was using gBleAddrTypePublic_c (0) as own address type, which caused the BLE address to always be set to the value fixed into the Controller by the manufacturer. Setting own address type to gBleAddrTypeRandom_c (1) should ensure that a random BLE address is generated at least on every boot. Signed-off-by: Marius Tache <[email protected]> Updating script/readme to allow to encrypt manufacturing data Signed-off-by: Gatien Chapon <[email protected]> [K32W0] Add spake2p verifier option If --spake2p_verifier option is used, the script will not generate a new verifier using the spake2p tool. Instead, it will directly encode SPAKE2+ inputs in the final binary. Signed-off-by: Marius Tache <[email protected]> [k32w0] add code to generate, store and return Unique ID Update python script that generates the factory data binary to include length and 4byte SHA value for integrity check on embedded [k32w0] Fix python script and add code on embedded to read hash and data length, calculate and compare hashes [K32W0] Add support for custom factory data provider A user can inherit `K32W0FactoryDataProvider` to provide additional functionality (such as parsing custom factory data fields) that is customer specific. Enable usage of custom factory data provider: * Set both `chip_with_factory_data=1` and `use_custom_factory_provider=1`. By setting `use_custom_factory_provider`, a flag is set to 1 in order to select the correct provider at compile time (the default or the custom one): CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER * Implement `IsIdInvalid` method to offer a way of checking the validity of custom IDs. Added an example of a custom factory data provider that can be used by any application, alongside with a README with more details. Signed-off-by: Marius Tache <[email protected]> [K32W0] Add custom factory data provider for lock/contact Signed-off-by: Marius Tache <[email protected]> [K32W0] Add support for rotating device ID Support for C3 characteristic (additional data containing rotating device ID) can be enabled by setting chip_enable_additional_data_advertising and chip_enable_rotating_device_id to 1 in the build gn args. C3 value is computed in EncodeAdditionalDataTlv, each time StartAdvertising is called. The attribute is registered with the GATT server through GattServer_RegisterHandlesForReadNotifications. Once a read event is received, if the handle is equal to the C3 handle, the attribute will be updated in the GATT database with the latest additional data, then the application will call GattServer_SendAttributeReadStatus to send the response to the client. Signed-off-by: Marius Tache <[email protected]> [K32W0] Format GATT database config Signed-off-by: Marius Tache <[email protected]> [K32W0] Simplify fetching next OTA block Fetching next block is scheduled inside the callback that is called once room for next block is available. Old implementation was notifying the AppTask, which notified back the platform to start fetching a new block. Signed-off-by: Marius Tache <[email protected]> [K32W0] Support new ram buffer modifications Signed-off-by: Marius Tache <[email protected]> [K32W0] Fix NotifyUpdateApplied Signed-off-by: Marius Tache <[email protected]> [K32W0] temporary fix for factory reset delete records Signed-off-by: Marius Tache <[email protected]> low power: fix allow/dissalow app functions Don't use PWR_PreventEnterLowPower() since it has global effect and can corrupt the app state when used more than once. Use PWR_AllowDeviceToSleep() / PWR_DisallowDeviceToSleep() Signed-off-by: George Stefan <[email protected]> [K32W0] Fix order of application sections Invert the order of image signature and factory data sections in order to avoid unwanted owerwrites. Also rename pFlash to flash_config. Signed-off-by: Doru Gucea <[email protected]> [K32W0] Keep FRO32K active when gClkUseFro32K is defined This is just an work-around, future clean solution is to move vOptimizeConsumption() to custom board files. Signed-off-by: Doru Gucea <[email protected]> Allow redefinition of the sleep/wakeup callbacks Signed-off-by: Doru Gucea <[email protected]> [K32W0] Refactor factory data generator tool Redesigned the tool to follow an OOP approach. The updated tool can be found in the new folder factory_data_generator and is split into three files: * generate.py - new version of the old implementation. * default.py - defines some default classes that describe arguments. * custom.py - deines custom classes that derive from the default classes. Added README that offers some tool implementation details. It also references the manufacturing flow README for tool usage. Added docstrings to files/classes to offer additional details. Removed previous factory data tool. Add support for the following options: * Vendor ID * Product ID * Certification Declaration * Vendor Name * Product Name * Serial Number * Manufacturing Date * Hardware Version * Hardware Version String * Unique ID A new flag is introduced which sets the number of custom provider IDs: CHIP_DEVICE_CONFIG_CUSTOM_PROVIDER_NUMBER_IDS Custom factory data providers should now implement SetCustomIds instead of IsIdInvalid. This method should set the max lengths of each custom field. The validity check is done in SearchForId and it's the same for default/custom IDs. Signed-off-by: Marius Tache <[email protected]> Signed-off-by: Ethan Tan <[email protected]> [K32W0] Update first image run checking Old version was using a PDM key to check if a new image is applied. Removed this key and updated the check process to actually check the software version that is embedded in the binary. User can overwrite a software version by using chip_software_version gn arg. Signed-off-by: Marius Tache <[email protected]> [K32W0] Remove app_config.h [K32W0] Fix factory data start address in docs Signed-off-by: Marius Tache <[email protected]> Rework tickless code to be in sync with SDK examples and add allow/disallow low power in BLE commissioning when FRO32K is used k32w0: low power: fix state machine - use new API: - remove App_PostCallbackMessage(), call directly dm_lp_processEvent() - in dm_switch_init15_4AfterWakeUp() set the correct state: 15.4 inactive, BLE active - remove stopM2(), sched_disable() since they are called from dm_lp_preSleep() - disabling the scheduler must be done before calling vMMAC_Disable() so it works correctly - use otSysEventSignalPending() since we're called form ISR context - kThreadWarmNotInitializedValue = 1000; /* 1 ms */ - clean up Signed-off-by: George Stefan <[email protected]> [K32W0] Fix compile fail when rotating + factory data are enabled Signed-off-by: Marius Tache <[email protected]> k32w0: include NXP platform generic platform config file There's a common NXP platform config file that's shared across all platforms. K32W0 should also include it, especially since it contains a fix for the max # of retransmissions (CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS) Signed-off-by: Alex Porosanu <[email protected]> (cherry picked from commit 0e156a32ee28b7b1202c08da2aa0e975ceb2b0fa) [K32W0] Update cluster config for lock-app lock-app is now a Door Lock device type. Removed OnOff cluster and added DoorLock cluster. Updated app ZCL callbacks. Signed-off-by: Marius Tache <[email protected]> [K32W0] Call InitOTA after Dnssd is initialized Previous implementation was using a timer to detect if the Dnssd intialized event was received, then it initialized the OTA requestor. New implementation removes this timer and directly initializes OTA when the event is received in MatterEventHandler. Signed-off-by: Marius Tache <[email protected]> [K32W0] Add software version logging for contact sensor Signed-off-by: Marius Tache <[email protected]> Remove tinycrypt from common stack Update openthread and ot-nxp submodules [K32W0] Add tinycrypt on k32w0 platform Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Define internal storage variables in linker script Signed-off-by: Marius Tache <[email protected]> [K32W0] Add NXP-Ultrafast-P256 on k32w0 platform Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Enable PDM encryption Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Update RamStorage API * RamStorage is no longer a static class. * Split K32WConfig and KVS common RAM buffer into five smaller RAM buffers that are managed by RamStorage instances. * Decoupled KVS from K32WConfig API. It now uses RamStorage API. * Moved PDM initialization in PlatformManagerImpl. * ConfigurationManager deletes the not-retained K32WConfig storages and KVS storages upon factory resetting. Signed-off-by: Marius Tache <[email protected]> [K32W0] Move RAM storage key in a separate header Signed-off-by: Marius Tache <[email protected]> [K32W0] Simplify RAM storage key usage Define a RamStorageKey API for key operations that redirects calls to the corresponding RamStorage instance. Signed-off-by: Marius Tache <[email protected]> [K32W0] Create header file for Ram storage metadata Add base key IDs and NVM IDs in a separate header file. Application should be able to overwrite the IDs. Signed-off-by: Marius Tache <[email protected]> [K32W0] Reset state on image authentication failed. CancelImageUpdate should be called at requestor level to make sure the state is correctly reset upon: * image authentication fail. * process header fail. Signed-off-by: Marius Tache <[email protected]> [K32W0] Remove CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER Signed-off-by: Marius Tache <[email protected]> [K32W0] Fix setting software version in gn arg Move chip_software_version in application build layer. The actual software version can be changed in two ways: * directly by the application by overwriting CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION. This should be the go-to option for clients. * by specifying chip_software_version gn arg with a value != 0. This is mainly used for OTA image generation in automation testing. Signed-off-by: Marius Tache <[email protected]> [K32W0] Consider about new memory map planning reserve more space for Application [K32W0] Remove connection when ble disconnect [K32W0] Fix public key casting when using factory data Signed-off-by: Andrei Menzopol <[email protected]> Add ADC read on idle task, add init of ADC for low power and non low power apps, remove BLE call [K32W0] Enable idle hook for lock app Set lock-app FreeRTOS configuration to be similar to lighting-app: enable idle hook and set minimal stack size to a decent value. Removed ISR check from button handler, since all keyboard events are sent from the TMR_Task, so the app is never in ISR context. Signed-off-by: Marius Tache <[email protected]> [k32w0] add hash id for k32w0 factory data implementation, move to TLV form (type is hash id, after which comes length then the actual hash) [K32W0] remove code that is not needed, move code to app level, add config when not using fro32k [K32W0] Add print-memory-usage flag Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Remove DAC PK when using factory data When using factory data, DAC certificate parsing and PK are not needed because the signing function uses only the private key. This results in a considerable flash usage decrease due to many mbedtls functions not being used anymore. Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Update SDK 2.6.9 link in readme files Signed-off-by: Andrei Menzopol <[email protected]> [COMMON] Add CHIPNXPPlatformDefaultConfig.h Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Fix P256Keypair::Initialize declaration Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] fix "gn gen --check" error when factory data function enabled [K32W0] Clear advertising flag after starting advertising failure Signed-off-by: Doru Gucea <[email protected]> lock-app: regenereate zap files, include cluster-id.h Signed-off-by: Andrei Menzopol <[email protected]> lighting-app: regenerate zap-files Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Move PDM defines to sdk config file Some PDM-related flags were placed in openthread config file, which is not intuitively. Move them to a general sdk config file. Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Update CHIPCryptoPALNXPUltrafastP256.cpp Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Fix lock-app Fix door-lock cluster id reference and ZclCallbacks function signatures Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Remove SDK patching Signed-off-by: Andrei Menzopol <[email protected]> [K32W0] Update tinycrypt paths Signed-off-by: Andrei Menzopol <[email protected]> Co-authored-by: Marius Tache [email protected] Co-authored-by: Doru Gucea [email protected] Co-authored-by: Alex Porosanu [email protected] Co-authored-by: Gatien Chapon [email protected] Co-authored-by: George Stefan [email protected] Co-authored-by: Ethan Tan [email protected] Co-authored-by: Mihai Ignat [email protected] * Update ot-nxp submodule Signed-off-by: Andrei Menzopol <[email protected]> * [K32W0] Update build Signed-off-by: Andrei Menzopol <[email protected]> * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-markdown * Restyled by autopep8 * Restyled by isort * Fix misspell Signed-off-by: Andrei Menzopol <[email protected]> * Fix k32w builder Signed-off-by: Andrei Menzopol <[email protected]> * Remove nxp/zap-generated files Signed-off-by: Andrei Menzopol <[email protected]> * Restyled by gn * Fix ZAP templates generation Signed-off-by: Andrei Menzopol <[email protected]> * Fix readme files Signed-off-by: Andrei Menzopol <[email protected]> * Fix lints Signed-off-by: Andrei Menzopol <[email protected]> * Increase k32w0 build timeout Signed-off-by: Andrei Menzopol <[email protected]> * Fix DoorLock attribute Signed-off-by: Andrei Menzopol <[email protected]> * Add orphan sphinx tag Signed-off-by: Andrei Menzopol <[email protected]> --------- Signed-off-by: Andrei Menzopol <[email protected]> Co-authored-by: Restyled.io <[email protected]>
- Loading branch information