From 1c67ab77f2bcaa5e16ed1e30be98d26803737e2f Mon Sep 17 00:00:00 2001 From: Grzegorz Latosinski Date: Mon, 8 Apr 2024 09:49:26 +0200 Subject: [PATCH] [#57693] app: Added files for testing hifive_unmatched by Kenning Signed-off-by: Grzegorz Latosinski Signed-off-by: Maciej Torhan --- app/boards/hifive_unleashed.overlay | 7 ++- app/boards/hifive_unmatched.overlay | 10 +++++ ...magic-wand-inference-hifive-unmatched.json | 44 +++++++++++++++++++ lib/kenning_inference_lib/Kconfig | 1 + renode/scripts/hifive_unmatched.resc | 30 +++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 app/boards/hifive_unmatched.overlay create mode 100644 kenning-scenarios/renode-zephyr-tflite-magic-wand-inference-hifive-unmatched.json create mode 100644 renode/scripts/hifive_unmatched.resc diff --git a/app/boards/hifive_unleashed.overlay b/app/boards/hifive_unleashed.overlay index d265b85..21d7668 100644 --- a/app/boards/hifive_unleashed.overlay +++ b/app/boards/hifive_unleashed.overlay @@ -1,5 +1,10 @@ +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + / { aliases { - kcomms = &uart0; + kcomms = &uart1; }; }; diff --git a/app/boards/hifive_unmatched.overlay b/app/boards/hifive_unmatched.overlay new file mode 100644 index 0000000..21d7668 --- /dev/null +++ b/app/boards/hifive_unmatched.overlay @@ -0,0 +1,10 @@ +&uart1 { + status = "okay"; + current-speed = <115200>; +}; + +/ { + aliases { + kcomms = &uart1; + }; +}; diff --git a/kenning-scenarios/renode-zephyr-tflite-magic-wand-inference-hifive-unmatched.json b/kenning-scenarios/renode-zephyr-tflite-magic-wand-inference-hifive-unmatched.json new file mode 100644 index 0000000..2ec0a78 --- /dev/null +++ b/kenning-scenarios/renode-zephyr-tflite-magic-wand-inference-hifive-unmatched.json @@ -0,0 +1,44 @@ +{ + "dataset": { + "type": "kenning.datasets.magic_wand_dataset.MagicWandDataset", + "parameters": { + "dataset_root": "./build/MagicWandDataset" + } + }, + "model_wrapper": { + "type": "kenning.modelwrappers.classification.tflite_magic_wand.MagicWandModelWrapper", + "parameters": { + "model_path": "kenning:///models/classification/magic_wand.h5" + } + }, + "optimizers": + [ + { + "type": "kenning.optimizers.tflite.TFLiteCompiler", + "parameters": + { + "compiled_model_path": "./build/tflite-magic-wand.tflite", + "inference_input_type": "float32", + "inference_output_type": "float32" + } + } + ], + "runtime": { + "type": "kenning.runtimes.renode.RenodeRuntime", + "parameters": { + "runtime_binary_path": "build/zephyr/zephyr.elf", + "platform_resc_path": "renode/scripts/hifive_unmatched.resc", + "runtime_log_uart": "/tmp/uart-log", + "runtime_log_init_msg": "I: Inference server started", + "profiler_dump_path": "build/profiler.dump" + } + }, + "protocol": { + "type": "kenning.protocols.uart.UARTProtocol", + "parameters": { + "port": "/tmp/uart", + "baudrate": 115200, + "endianness": "little" + } + } +} diff --git a/lib/kenning_inference_lib/Kconfig b/lib/kenning_inference_lib/Kconfig index 582450e..bf254d5 100644 --- a/lib/kenning_inference_lib/Kconfig +++ b/lib/kenning_inference_lib/Kconfig @@ -43,6 +43,7 @@ config KENNING_COMMUNICATION_PROTOCOL_NONE config KENNING_COMMUNICATION_PROTOCOL_UART bool prompt "UART protocol" + select UART_SIFIVE_PORT_1 if UART_SIFIVE endchoice diff --git a/renode/scripts/hifive_unmatched.resc b/renode/scripts/hifive_unmatched.resc new file mode 100644 index 0000000..2a33a9f --- /dev/null +++ b/renode/scripts/hifive_unmatched.resc @@ -0,0 +1,30 @@ +mach create "hifive_unmatched" + +machine LoadPlatformDescription $ORIGIN/../../build/hifive_unmatched.repl + +# Enable UART connection +emulation CreateUartPtyTerminal "term-log" "/tmp/uart-log" +connector Connect sysbus.uart0 term-log + +emulation CreateUartPtyTerminal "term" "/tmp/uart" +connector Connect sysbus.uart1 term + +sysbus.cpu0 EnableRiscvOpcodesCounting +sysbus.cpu0 EnableVectorOpcodesCounting + +sysbus.cpu1 EnableVectorOpcodesCounting +sysbus.cpu2 EnableVectorOpcodesCounting +sysbus.cpu3 EnableVectorOpcodesCounting +sysbus.cpu4 EnableVectorOpcodesCounting + +sysbus.u74_1 EnableRiscvOpcodesCounting +sysbus.u74_2 EnableRiscvOpcodesCounting +sysbus.u74_3 EnableRiscvOpcodesCounting +sysbus.u74_4 EnableRiscvOpcodesCounting + +sysbus.u74_1 EnableVectorOpcodesCounting +sysbus.u74_2 EnableVectorOpcodesCounting +sysbus.u74_3 EnableVectorOpcodesCounting +sysbus.u74_4 EnableVectorOpcodesCounting + +sysbus LoadELF $bin