### Download Armino SDK using Git Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/get-started/index.rst Demonstrates cloning the Armino SDK repository from both GitLab and GitHub. Ensure you have Git installed and the necessary permissions for GitLab. ```bash mkdir -p ~/armino cd ~/armino git clone https://gitlab.bekencorp.com/armino/bk_idk.git ``` ```bash mkdir -p ~/armino cd ~/armino git clone https://github.com/bekencorp/bk_idk.git ``` -------------------------------- ### Run Blynk Example Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/wipy/tutorial/blynk.rst Execute the uploaded Blynk example script on your WiPy device. This command assumes the script has been correctly uploaded and configured. ```python execfile('sync_virtual.py') ``` -------------------------------- ### WebREPL Setup and Start Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/esp32/quickref.rst Details on setting up and starting the WebREPL service for remote interactive access via a web browser. It includes running the setup script and starting the daemon, optionally with a password. ```python # Run this once to configure WebREPL import webrepl_setup ``` ```python # Start WebREPL daemon on demand import webrepl webrepl.start() ``` ```python # Start WebREPL daemon with a specific password webrepl.start(password='mypass') ``` -------------------------------- ### Build MicroPython Documentation Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/develop/gettingstarted.rst Generates the project's HTML documentation using Sphinx. This involves setting up a Python virtual environment, installing Sphinx via pip, navigating to the docs directory, and running the make html command. The output can be viewed in docs/build/html/index.html. ```bash $ python3 -m venv env $ source env/bin/activate $ pip install sphinx $ cd docs $ make html ``` -------------------------------- ### Install Linux Build Dependencies Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/develop/gettingstarted.rst Installs essential build tools and libraries required for compiling MicroPython on a Linux system. Includes packages like build-essential, libffi-dev, git, and pkg-config. ```bash sudo apt-get install build-essential libffi-dev git pkg-config ``` -------------------------------- ### Setup TF-M Documentation Environment on Windows Source: https://github.com/2093854679/bk/blob/main/components/tfm/tfm/docs/technical_references/instructions/documentation_generation.rst Guides on downloading and installing necessary tools like Doxygen, Graphviz, Java, PlantUML, and MikTeX for PDF generation. It also covers setting environment variables and installing Python dependencies. ```bash set PLANTUML_JAR_PATH=\plantuml.jar set PATH=$PATH;\sw\java\bin # Install the required Python modules pip3 install --upgrade pip cd trusted-firmware-m pip3 install -r tools\requirements_docs.txt ``` -------------------------------- ### Setup Armino Build Environment (Ubuntu) Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/get-started/env-manual.rst Installs the necessary compilation environment for the Armino project on Ubuntu 20.04 LTS or above using a provided script. This script automates the installation of dependencies required for building the project. ```shell cd ~/armino/bk_idk sudo bash tools/env_tools/setup/armino_env_setup.sh ``` -------------------------------- ### Upload Blynk WiPy Example Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/wipy/tutorial/blynk.rst Obtain the Blynk example script for WiPy, edit its network configuration settings, and then upload the modified script to the `/flash/` directory on your WiPy via FTP. ```text Download PyCom_WiPy.py, edit network settings, and upload to "/flash/" via FTP. ``` -------------------------------- ### Install Sphinx and Doxygen for Documentation Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/get-started/manual_install.rst Installs Python packages required for Sphinx-based documentation generation and the doxygen software tool for API documentation. ```bash sudo pip3 install Sphinx sphinx-rtd-theme breathe blockdiag sphinxcontrib-blockdiag sphinxcontrib-seqdiag sphinxcontrib-actdiag sphinxcontrib-nwdiag Pillow sudo apt install doxygen -y ``` -------------------------------- ### Build Command Example Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/developer-guide/bootloader_ota/ab_position_independent_ota/bk_ab_bootloader_imag_update_introduction.rst Example command to build the bk7258 project with a specific configuration, demonstrating how to trigger the build process after partition modifications. ```shell make bk7258 PROJECT=customization/config_ab ``` -------------------------------- ### Install Ubuntu/Debian Dependencies Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/get-started/manual_install.rst Updates package lists and installs essential build tools and Python packages for Ubuntu or Debian operating systems using apt. ```bash sudo apt update sudo apt install make cmake python3 python3-pip ninja-build -y ``` -------------------------------- ### Install Archlinux Dependencies Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/get-started/manual_install.rst Updates package lists and installs essential build tools and Python packages for Archlinux operating systems using pacman. ```bash sudo pacman -Syyu sudo pacman -S --noconfirm make wget git cmake python3 python-pip python-setuptools ninja ``` -------------------------------- ### Wi-Fi IPERF Example Setup and Usage Source: https://github.com/2093854679/bk/blob/main/projects/wifi/iperf/README.md This snippet outlines the steps to run the Armino Wi-Fi IPERF example. It covers connecting the device to an AP, running iPerf as a server on the AP side, and running iPerf as a client on the BK device. It also shows example console output. ```shell 3. Run the demo as station mode and join the target AP sta ssid password 4. Run iperf as server on AP side iperf -s -i1 5. Run iperf as client on bk7256 side iperf -c 192.168.0.1 -i -t60 Console Output Example: cmd: ap bk_test cmd: sta bk_test netif(sta) ip4=192.168.0.100 mask=255.255.255.0 gate=192.168.0.1 dns=192.168.0.1 >iperf> iperf -s -i -t1000 iperf: new client connected from (192.168.0.100, 61285) [0-1] sec bandwidth: 15865 Kbits/sec. [1-2] sec bandwidth: 17908 Kbits/sec. [2-3] sec bandwidth: 17434 Kbits/sec. [3-4] sec bandwidth: 18688 Kbits/sec. [4-5] sec bandwidth: 18765 Kbits/sec. [5-6] sec bandwidth: 21490 Kbits/sec. [6-7] sec bandwidth: 21765 Kbits/sec. [7-8] sec bandwidth: 21095 Kbits/sec. [8-9] sec bandwidth: 20800 Kbits/sec. ``` -------------------------------- ### Install Python Modules for Compilation Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/get-started/manual_install.rst Installs required Python 3 modules for document compilation and general use. Ensure Python 3.8 or higher is the default. ```bash sudo pip3 install pycryptodome click future click_option_group cryptography jinja2 PyYAML cbor2 intelhex ``` -------------------------------- ### AP Example: Main Log Output Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Sample log output from the AP example, showing the Wi-Fi initialization, SoftAP configuration, and successful startup of the access point. ```log wifi:I(310):wifi inited(1) ret(0) example:I(312):ssid:myssid key:mypassword wifi:I(314):ap configuring wifi:I(316):ap configured wifi:I(318):ap starting wifi:I(320):init 1st vif hitf:I(544):start apm success, vif0, channel0, bcmc2 ``` -------------------------------- ### Install esptool.py Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/esp8266/tutorial/intro.rst Installs the esptool.py utility, which is used for flashing MicroPython firmware onto ESP8266 devices. Requires Python and pip. ```Python pip install esptool ``` -------------------------------- ### Install ARM Cross-Compiler for STM32 Port Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/develop/gettingstarted.rst Installs the ARM GNU toolchain necessary for compiling MicroPython for STM32 microcontrollers. This includes the GCC compiler, binutils, and newlib. ```bash sudo apt-get install arm-none-eabi-gcc arm-none-eabi-binutils arm-none-eabi-newlib ``` -------------------------------- ### Install Python Dependencies (Linux) Source: https://github.com/2093854679/bk/blob/main/components/tfm/tfm/docs/getting_started/tfm_getting_started.rst Installs the Python dependencies required by TF-M, as listed in the 'tools/requirements.txt' file, using pip3. It also upgrades pip itself. ```bash pip3 install --upgrade pip cd trusted-firmware-m pip3 install -r tools/requirements.txt ``` -------------------------------- ### Meson Build Setup and Execution Source: https://github.com/2093854679/bk/blob/main/components/unity/examples/example_4/readme.txt This snippet covers the initial setup of a project using Meson and how to build it with the Ninja build system. It includes commands for project configuration and execution. ```shell meson setup ``` ```shell ninja -C ``` -------------------------------- ### Install Python Dependencies (Windows) Source: https://github.com/2093854679/bk/blob/main/components/tfm/tfm/docs/getting_started/tfm_getting_started.rst Installs the Python dependencies required by TF-M, as listed in the 'tools/requirements.txt' file, using pip3. This command is executed after cloning the repository. ```bash cd trusted-firmware-m pip3 install -r tools\requirements.txt ``` -------------------------------- ### BEKEN Wi-Fi AP/SoftAP Setup Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/developer-guide/wifi/bk_wifi_get_started.rst Demonstrates setting up a BEKEN Wi-Fi module as a SoftAP. Includes the compile command, file path for the binary, and configuration parameters for SSID, password, IP address, and network mask. Also shows sample log output during AP configuration. ```kconfig menu "Example Configuration" config EXAMPLE_WIFI_SSID string "WiFi SSID" default "myssid" //SoftAP SSID config EXAMPLE_WIFI_PASSWORD string "WiFi Password" default "12345678" //SoftAP Password config EXAMPLE_IP string "IP4 Address of AP" default "192.168.10.1" //Default IP Address config EXAMPLE_MASK string "Network mask of AP" default "255.255.255.0" //Default value can be customized config EXAMPLE_GW string "Gateway address of AP" default "192.168.10.1" config EXAMPLE_DNS string "DNS address of AP" default "192.168.10.1" endmenu ``` ```shell make bk7236 PROJECT=examples/wifi/ap ``` ```log wifi:I(310):wifi inited(1) ret(0) example:I(312):ssid:myssid key:mypassword wifi:I(314):ap configuring wifi:I(316):ap configured wifi:I(318):ap starting wifi:I(320):init 1st vif hitf:I(544):start apm success, vif0, channel0, bcmc2 ``` -------------------------------- ### BEKEN Wi-Fi AP/SoftAP Setup Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/en/developer-guide/wifi/bk_wifi_get_started.rst Demonstrates setting up a BEKEN Wi-Fi module as a SoftAP. Includes the compile command, file path for the binary, and configuration parameters for SSID, password, IP address, and network mask. Also shows sample log output during AP configuration. ```kconfig menu "Example Configuration" config EXAMPLE_WIFI_SSID string "WiFi SSID" default "myssid" //SoftAP SSID config EXAMPLE_WIFI_PASSWORD string "WiFi Password" default "12345678" //SoftAP Password config EXAMPLE_IP string "IP4 Address of AP" default "192.168.10.1" //Default IP Address config EXAMPLE_MASK string "Network mask of AP" default "255.255.255.0" //Default value can be customized config EXAMPLE_GW string "Gateway address of AP" default "192.168.10.1" config EXAMPLE_DNS string "DNS address of AP" default "192.168.10.1" endmenu ``` ```shell make bk7236 PROJECT=examples/wifi/ap ``` ```log wifi:I(310):wifi inited(1) ret(0) example:I(312):ssid:myssid key:mypassword wifi:I(314):ap configuring wifi:I(316):ap configured wifi:I(318):ap starting wifi:I(320):init 1st vif hitf:I(544):start apm success, vif0, channel0, bcmc2 ``` -------------------------------- ### STA Connect Example: Main Log Output Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Sample log output from the STA Connect example, showing successful Wi-Fi initialization, connection attempt with specified credentials, and IP address acquisition. ```log wifi:I(308):wifi inited(1) ret(0) //开机后初始化完成 example:I(310):ssid:aclsemi password:ACL8semi //连接指定SSID、Password example:I(3618):STA connected to aclsemi //连接成功 example:I(3658):STA got ip //获取IP地址 ``` -------------------------------- ### Install esptool.py Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/esp32/tutorial/intro.rst Installs the esptool.py utility, a Python-based script for interacting with Espressif devices. It is a prerequisite for flashing firmware onto ESP32 boards. Requires Python 2.7 or 3.4+. ```bash pip install esptool ``` -------------------------------- ### Setup TF-M Documentation Environment on Linux Source: https://github.com/2093854679/bk/blob/main/components/tfm/tfm/docs/technical_references/instructions/documentation_generation.rst Installs essential tools like Doxygen, Graphviz, and Java, downloads PlantUML, and installs Python dependencies required for TF-M documentation generation. ```bash sudo apt-get install -y doxygen graphviz default-jre mkdir ~/plantuml curl -L http://sourceforge.net/projects/plantuml/files/plantuml.jar/download --output ~/plantuml/plantuml.jar export PLANTUML_JAR_PATH=~/plantuml/plantuml.jar # For PDF generation sudo apt-get install -y doxygen-latex # Install the required Python modules pip3 install --upgrade pip cd trusted-firmware-m pip3 install -r tools/requirements_docs.txt ``` -------------------------------- ### STA Connect Example: Build Command Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Command to compile the STA Connect example for the Beken Wi-Fi chip. This example allows the device to automatically connect to a pre-configured Wi-Fi network upon startup. ```make make bk7236 PROJECT=examples/wifi/sta_connect PROJECT_LIBS=bk7236_app ``` -------------------------------- ### AP Example: Kconfig Parameters Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Configuration options for the AP example, allowing customization of the SoftAP's SSID, password, IP address, network mask, gateway, and DNS server. ```kconfig menu "Example Configuration" config EXAMPLE_WIFI_SSID string "WiFi SSID" default "myssid" //SoftAP SSID config EXAMPLE_WIFI_PASSWORD string "WiFi Password" default "12345678" //SoftAP Password config EXAMPLE_IP string "IP4 Address of AP" default "192.168.10.1" //Default IP Address config EXAMPLE_MASK string "Network mask of AP" default "255.255.255.0" //Default参数可以自定义 config EXAMPLE_GW string "Gateway address of AP" default "192.168.10.1" config EXAMPLE_DNS string "DNS address of AP" default "192.168.10.1" endmenu ``` -------------------------------- ### Install Older esptool.py Version Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/esp8266/tutorial/intro.rst This command installs a specific older version of esptool.py (v1.0.1). This might be necessary for compatibility with older ESP8266 modules or specific flashing algorithms. It requires pip to be installed and may need pip2 for Python 2.7. ```shell pip install esptool==1.0.1 ``` -------------------------------- ### Verify Remote Repository Configuration Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/develop/gettingstarted.rst Displays the current remote repository configurations ('origin' and 'upstream'). This command helps verify that the remote repositories have been set up correctly for fetching and pushing code. ```bash git remote -v ``` -------------------------------- ### Install Linux Build Dependencies Source: https://github.com/2093854679/bk/blob/main/components/tfm/tfm/docs/getting_started/tfm_getting_started.rst Installs essential packages required for building TF-M on Ubuntu 18.04 x64 and later. This includes git, curl, wget, build-essential, libssl-dev, python3, pip, cmake, and make. ```bash sudo apt-get install -y git curl wget build-essential libssl-dev python3 \ python3-pip cmake make ``` -------------------------------- ### Scan Example: Build Command Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Command to compile the Wi-Fi scan example for the Beken Wi-Fi chip. This enables testing of network scanning functionalities. ```make make bk7236 PROJECT=examples/wifi/scan ``` -------------------------------- ### Import lcd160cr Driver Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/pyboard/tutorial/lcd160cr_skin.rst This snippet shows how to import the necessary driver module for the LCD160CR display. Ensure the driver is installed in your MicroPython environment. ```python import lcd160cr ``` -------------------------------- ### AP Example: Build Command Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Command to compile the AP (SoftAP) example for the Beken Wi-Fi chip. This command specifies the target project and chip for the build process. ```make make bk7236 PROJECT=examples/wifi/ap ``` -------------------------------- ### Verify CMake Version (Linux) Source: https://github.com/2093854679/bk/blob/main/components/tfm/tfm/docs/getting_started/tfm_getting_started.rst Checks the currently installed version of CMake on the Linux system. It's recommended to use CMake 3.15 or later. ```bash cmake --version ``` -------------------------------- ### Scan Example: Main Log Output Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Sample log output from the Wi-Fi scan example, demonstrating results for both specific SSID scans and full channel scans, including details like RSSI and security type. ```log wifi:I(1134):scan found 4 AP //指定SSID扫描 SSID BSSID RSSI chan security -------------------------------- ----------------- ---- ---- --------- aclsemi 74:50:4e:3f:48:b0 -29 6 WPA2-AES aclsemi 74:50:4e:3f:84:d0 -32 1 WPA2-AES aclsemi 74:50:4e:3f:99:50 -33 6 WPA2-AES aclsemi 74:50:4e:3f:82:50 -58 11 WPA2-AES wifi:I(1136):scan found 32 AP //全信道扫描 SSID BSSID RSSI chan security -------------------------------- ----------------- ---- ---- --------- Redmi_253C 24:cf:24:3a:25:3e -24 4 WPA2-MIX TP-LINK-1 18:f2:2c:74:1d:dd -30 1 WPA2-AES aclsemi 74:50:4e:3f:48:b0 -31 6 WPA2-AES aclsemi 74:50:4e:3f:99:50 -33 6 WPA2-AES TP-LINK_6C28 50:fa:84:8f:6c:28 -34 1 WPA2-AES Xiaomi_0296 8c:de:f9:b6:07:c2 -35 6 WPA2-MIX aclsemi 74:50:4e:3f:84:d0 -36 1 WPA2-AES PowerTest c8:3a:35:7f:7e:e0 -38 11 WPA2-AES MP c0:61:18:2b:82:b4 -44 11 WPA2-AES ChinaNet-HeLg cc:c2:e0:6e:0f:a9 -45 13 WPA2-MIX ``` -------------------------------- ### MicroPython REPL Prompt Example Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/renesas-ra/tutorial/intro.rst The expected output when successfully connecting to the MicroPython REPL via a serial terminal. It displays the MicroPython version and board information. ```MicroPython MicroPython v1.18-293-g339aa09b8-dirty on 2022-03-26; RA6M2_EK with RA6M2 Type "help()" for more information. >>> ``` -------------------------------- ### Write MicroPython Firmware to ESP8266 Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/esp8266/tutorial/intro.rst Writes the MicroPython firmware binary file to the ESP8266 device using esptool.py. Adjust the port, baudrate, and filename as needed for your setup. ```Shell esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 esp8266-20170108-v1.8.7.bin ``` -------------------------------- ### Clone MicroPython Repository Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/develop/gettingstarted.rst Clones the MicroPython source code repository from a specified GitHub URL. This command is essential for obtaining a local copy of the project to begin development or building. ```bash $ git clone https://github.com//micropython ``` -------------------------------- ### Install Blynk Library Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/wipy/tutorial/blynk.rst Download the Blynk library file and place it in the `/flash/lib/` directory on your WiPy device via FTP. This makes the library available for use in your Python scripts. ```text Download BlynkLib.py and place it in "/flash/lib/" via FTP. ``` -------------------------------- ### STA Connect Example: Kconfig Parameters Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Configuration options for the STA Connect example, where users specify the target Wi-Fi SSID and password for automatic connection. ```kconfig menu "Example Configuration" config EXAMPLE_WIFI_SSID string "Wi-Fi SSID" default "aclsemi" //目标SSID config EXAMPLE_WIFI_PASSWORD string "Wi-Fi Password" default "ACL8semi" //目标SSID密码 endmenu ``` -------------------------------- ### Accessing MicroPython REPL using picocom Source: https://github.com/2093854679/bk/blob/main/components/micropython/docs/renesas-ra/tutorial/intro.rst Example command to open a serial connection to the MicroPython REPL using the picocom terminal emulator on Linux. This assumes the USB-Serial adapter is recognized as /dev/ttyACM0. ```Shell $ picocom /dev/ttyACM0 ``` -------------------------------- ### BKFILL.exe Download URL Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/get-started/index.rst Provides the official URL to download the latest version of the BKFILL.exe flashing tool, which is used for serial port burning of firmware onto Beken devices. ```url http://dl.bekencorp.com/tools/flash/ ``` -------------------------------- ### PSA Cipher Decryption Example Source: https://github.com/2093854679/bk/blob/main/components/tfm_mbedtls/mbedtls/docs/getting_started.md Demonstrates the complete process of decrypting data using PSA Crypto, including initializing the crypto library, importing a key, setting up the decryption operation, processing ciphertext, and cleaning up resources. ```C void psa_decrypt_example() { size_t output_len; psa_key_id_t key_id; psa_status_t status; psa_key_attributes_t attributes; psa_cipher_operation_t operation; const uint8_t *key; size_t key_len; psa_algorithm_t alg; const uint8_t *iv; const uint8_t *ciphertext; size_t ciphertext_len; uint8_t *output; size_t output_size; printf("Decrypt with cipher...\t"); fflush(stdout); /* Initialize PSA Crypto */ status = psa_crypto_init(); if (status != PSA_SUCCESS) { printf("Failed to initialize PSA Crypto\n"); return; } /* Import a key */ psa_reset_key_attributes(&attributes); psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_DECRYPT); psa_set_key_algorithm(&attributes, alg); psa_set_key_type(&attributes, PSA_KEY_TYPE_AES); psa_set_key_bits(&attributes, 128); status = psa_import_key(&attributes, key, key_len, &key_id); if (status != PSA_SUCCESS) { printf("Failed to import a key\n"); return; } psa_reset_key_attributes(&attributes); /* Decrypt the ciphertext */ status = psa_cipher_decrypt_setup(&operation, key_id, alg); if (status != PSA_SUCCESS) { printf("Failed to begin cipher operation\n"); return; } status = psa_cipher_set_iv(&operation, iv, sizeof(iv)); if (status != PSA_SUCCESS) { printf("Failed to set IV\n"); return; } status = psa_cipher_update(&operation, ciphertext, sizeof(ciphertext), output, sizeof(output), &output_len); if (status != PSA_SUCCESS) { printf("Failed to update cipher operation\n"); return; } status = psa_cipher_finish(&operation, output + output_len, sizeof(output) - output_len, &output_len); if (status != PSA_SUCCESS) { printf("Failed to finish cipher operation\n"); return; } printf("Decrypted ciphertext\n"); /* Clean up cipher operation context */ psa_cipher_abort(&operation); /* Destroy the key */ psa_destroy_key(key_id); mbedtls_psa_crypto_free(); } ``` -------------------------------- ### Mbed Crypto Hashing API Reference Source: https://github.com/2093854679/bk/blob/main/components/tfm_mbedtls/mbedtls/docs/getting_started.md Provides details on Mbed Crypto's hashing functions and macros, including setup, update, finish, verify, and abort operations, along with context management and helper macros. ```APIDOC PSA Hashing API: Prerequisites: - Initialize the library with a successful call to `psa_crypto_init()`. Core Hashing Workflow: 1. Allocate an operation structure (`psa_hash_operation_t`). 2. Initialize the operation structure (e.g., `PSA_HASH_OPERATION_INIT`). 3. Call `psa_hash_setup()` to specify the hash algorithm. 4. Call `psa_hash_update()` with message fragments. Can be called multiple times. 5. Call `psa_hash_finish()` to compute the hash, or `psa_hash_verify()` to compare with an expected hash. 6. Call `psa_hash_abort()` to clean up resources. Key Functions and Macros: `psa_hash_setup(psa_hash_operation_t *operation, psa_algorithm_t alg)` - Initializes a hash operation context for a specified algorithm. - Parameters: - `operation`: Pointer to the hash operation structure. - `alg`: The PSA algorithm identifier (e.g., `PSA_ALG_SHA_256`). - Returns: `PSA_SUCCESS` on success, or an error code. `psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, size_t input_length)` - Feeds a fragment of the message into the hash operation. - Parameters: - `operation`: Pointer to the hash operation structure. - `input`: Pointer to the message fragment. - `input_length`: The size of the message fragment. - Returns: `PSA_SUCCESS` on success, or an error code. `psa_hash_finish(psa_hash_operation_t *operation, uint8_t *output, size_t output_size, size_t *output_length)` - Computes the final hash value of the message. - Parameters: - `operation`: Pointer to the hash operation structure. - `output`: Buffer to store the computed hash. - `output_size`: The size of the output buffer. - `output_length`: Pointer to a variable that will store the actual hash length. - Returns: `PSA_SUCCESS` on success, or an error code. `psa_hash_verify(psa_hash_operation_t *operation, const uint8_t *hash, size_t hash_len)` - Verifies the computed hash against an expected hash value. - Parameters: - `operation`: Pointer to the hash operation structure. - `hash`: The expected hash value. - `hash_len`: The length of the expected hash value. - Returns: `PSA_SUCCESS` if the hash matches, `PSA_ERROR_INVALID_ARGUMENT` if lengths mismatch, or other error codes. `psa_hash_abort(psa_hash_operation_t *operation)` - Terminates a hash operation and frees associated resources. - Parameters: - `operation`: Pointer to the hash operation structure. - Returns: `PSA_SUCCESS` on success, or an error code. - Note: This function is called implicitly by `psa_hash_update()`, `psa_hash_finish()`, and `psa_hash_verify()` upon failure or completion. It must be called explicitly for operations initialized by `psa_hash_setup()`. `PSA_HASH_LENGTH(alg)` - Macro that returns the expected hash length (in bytes) for the specified algorithm. - Example: `size_t sha256_len = PSA_HASH_LENGTH(PSA_ALG_SHA_256);` Handling Hash Operation Contexts: - After a successful `psa_hash_setup()`, the operation structure is valid. - `psa_hash_abort()` frees resources but the structure can be reused after re-initialization with `psa_hash_setup()`. - Implicit aborts occur on errors or completion of `psa_hash_update()`, `psa_hash_finish()`, or `psa_hash_verify()`. - Multiple sequential calls to `psa_hash_abort()` are safe. ``` -------------------------------- ### Conditional Compilation for Multi-Core Systems Source: https://github.com/2093854679/bk/blob/main/docs/bk7258/en/get-started/index.rst Example code demonstrating how to use preprocessor macros (e.g., CONFIG_TRNG) to isolate functionality for specific CPUs in a multi-core system like BK7258. This ensures modules are executed on the intended core. ```c #if CONFIG_TRNG #Uses module macro to seperate CPUx software whether enable TRNG #include "driver/trng.h" #endif ... #if CONFIG_TRNG #Uses module macro to seperate CPUx software whether enable TRNG bk_rand(); #endif ``` -------------------------------- ### JavaScript Page Initialization and Search Setup Source: https://github.com/2093854679/bk/blob/main/components/lwip_intf_v2_1/lwip-2.1.2/doc/doxygen/output/html/dir_b0856f6b0d80ccb263b2f415c91f9e17.html This snippet contains common JavaScript patterns used for initializing web pages, setting up search functionality, and managing navigation trees, often found in documentation generated by tools like Doxygen. ```JavaScript $(document).ready(initResizable); var searchBox = new SearchBox("searchBox", "search",false,'Search'); $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); ``` ```JavaScript $(document).ready(function(){initNavTree('dir_b0856f6b0d80ccb263b2f415c91f9e17.html','');}); ``` -------------------------------- ### Scan Example: Kconfig Parameters Source: https://github.com/2093854679/bk/blob/main/docs/bk7236/zh_CN/developer-guide/wifi/bk_wifi_get_started.rst Configuration options for the Wi-Fi scan example. Users can choose between scanning all SSIDs across all channels or scanning for a specific SSID. ```kconfig menu "Example Configuration" config EXAMPLE_SCAN_ALL_SSID bool "Scan All SSID" default y //全信道扫描 config EXAMPLE_WIFI_SSID string "WiFi SSID" depends on !EXAMPLE_SCAN_ALL_SSID default "aclsemi" //指定SSID扫描 endmenu ```