Kenning platforms¶
Kenning platforms were created to automatically provide board-specific arguments and parameters required for various stages of Kenning pipelines. It is used to:
Provide information on platforms’ constraints, such as RAM size
Provide information for optimizing the model using compilers such as TVM or IREE
Provide information on supported target runtime (Linux-based, bare metal or Zephyr-based)
Provide information on building the target evaluation application
Provide information on interfacing with the target platform (e.g. via UART)
Specification¶
Platforms’ definitions should be written in YAML or JSON file representing a dictionary, where:
keys are the unique boards’ IDs
values are dictionaries with board-specific parameters.
The example specification of platforms looks as follows:
max32690evkit/max32690/m4:
display_name: MAX32690 Evaluation Kit
flash_size_kb: 3072
ram_size_kb: 128
uart_port_wildcard: /dev/serial/by-id/usb-FTDI_FT231X_USB_UART_*-if00-port0
uart_baudrate: 115200
uart_log_baudrate: 115200
compilation_flags:
- "-keys=arm_cpu,cpu"
- "-device=arm_cpu"
- "-march=armv7e-m"
- "-mcpu=cortex-m4"
- "-model=max32690"
openocd_flash_cmd:
- source [find interface/cmsis-dap.cfg]
- source [find target/max32690.cfg]
- init
- targets
- reset init
- flash write_image erase {binary_path}
- reset run
- shutdown
platform_resc_path: gh://antmicro:kenning-zephyr-runtime/renode/scripts/max32690evkit.resc;branch=main
default_platform: ZephyrPlatform
max32690fthr/max32690/m4:
display_name: MAX32690FTHR
flash_size_kb: 3072
ram_size_kb: 128
uart_baudrate: 115200
uart_log_baudrate: 115200
compilation_flags:
- "-keys=arm_cpu,cpu"
- "-device=arm_cpu"
- "-march=armv7e-m"
- "-mcpu=cortex-m4"
- "-model=max32690"
platform_resc_path: gh://antmicro:kenning-zephyr-runtime/renode/scripts/max32690fthr.resc;branch=main
default_platform: ZephyrPlatform
rv32-springbok:
display_name: RISC-V 32-bit Springbok
runtime_binary_path: kenning:///renode/springbok/iree_runtime
platform_resc_path: gh://antmicro:kenning-bare-metal-iree-runtime/sim/config/springbok.resc;branch=main
resc_dependencies:
- gh://antmicro:kenning-bare-metal-iree-runtime/sim/config/platforms/springbok.repl;branch=main
- gh://antmicro:iree-rv32-springbok/sim/config/infrastructure/SpringbokRiscV32.cs;branch=repo-as-submodule
post_start_commands:
- sysbus.vec_controlblock WriteDoubleWord 0xc 0
runtime_log_init_msg: Runtime started
default_platform: BareMetalPlatform
stm32f746g_disco:
display_name: STM32F746G Discovery
flash_size_kb: 1024
ram_size_kb: 256
uart_baudrate: 115200
platform_resc_path: gh://antmicro:kenning-zephyr-runtime/renode/scripts/stm32f746g_disco.resc;branch=main
default_platform: ZephyrPlatform
hifive_unmatched/fu740/s7:
display_name: HiFive Unmatched
uart_baudrate: 115200
platform_resc_path: gh://antmicro:kenning-zephyr-runtime/renode/scripts/hifive_unmatched.resc;branch=main
default_platform: ZephyrPlatform
Looking at MAX32690 platform there are fields for:
TVM compilation (
compilation_flags
),flashing to HW (
openocd_flash_cmd
),simulation (
platform_resc_path
),defining model constrains (
flash_size_kb
,ram_size_kb
),automatically finding its UART port (
uart_port_wildcard
) and specifying its baud rate (uart_baudrate
,uart_log_baudrate
),choosing the platform type (
default_platform
).
Other parameters with descriptions can be found e.g. in:
kenning.platforms.bare_metal.BareMetalPlatform
encapsulating platforms running bare metal runtimekenning.platforms.zephyr.ZephyrPlatform
encapsulating platforms running Kenning Zephyr Runtime
Generating definitions for boards supported by Zephyr RTOS¶
Kenning provides a generate-platforms
subcommand that allows to generate definitions of platforms based on given sources.
Currently, the only supported sources of information are Zephyr RTOS device trees.
In order to generate definitions, fully set-up Zephyr repository with SDK is required. For detailed information on how to set up the SDK, follow Zephyr documentation.
Based on Docker image for Kenning Zephyr Runtime, it boils down to:
docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) ghcr.io/antmicro/kenning-zephyr-runtime:latest /bin/bash
git clone https://github.com/antmicro/kenning-zephyr-runtime
cd kenning-zephyr-runtime/
./scripts/prepare_zephyr_env.sh
# Install additional ARM toolchain
~/.local/opt/zephyr-sdk/setup.sh -t aarch64-zephyr-elf
source .venv/bin/activate
pip3 install 'kenning[zephyr] @ git+https://github.com/antmicro/kenning.git'
Note
Using existing Zephyr repository can be achieved by exporting ZEPHYR_BASE
variable or providing --zephyr-base
flag to the script.
It can potentially require additional dependencies from kenning[zephyr]
.
Platform generation can be triggered with a following command:
kenning generate-platforms zephyr \
--zephyr-base ../zephyr \
--platforms ./platforms.yml
The script:
generates flat device trees using Zephyr CMake rules,
parses received device trees with dts2repl,
tries to find baudrate based on chosen console output,
tries to find compilation flags for ARM CPUs based on their names (from
compatible
parameter) and architectures returned by GCC for ARM (arm-zephyr-eabi-gcc
andaarch64-zephyr-elf-gcc
from Zephyr SDK),calculates size of the flash based on chosen flash registers,
calculates size of the RAM based on chose sram and Zephyr’s memory-regions,
finds URL to the board image.
To use newly generated platforms, provide its path to the --platform-definitions
flag in kenning
command or directly in the scenario:
platform:
type: ZephyrPlatform
parameters:
# Chooses the file with platform definition
platforms_definitions: [./platforms.yml]
# Chooses MAX32690 Evaluation Kit
name: max32690evkit/max32690/m4