Commit f6d14c23 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

zephyr: Add simple benchmark support to Zephyr

This adds a Kconfig feature CONFIG_BOOT_USE_BENCH, which when enabled
will print the simple benchmarking output as log messages.

Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent 590a3103
Loading
Loading
Loading
Loading
+9 −0
Changes for boot/zephyr/Kconfig: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -206,6 +206,15 @@ config ZEPHYR_TRY_MASS_ERASE

	  This is not available for all targets.

config BOOT_USE_BENCH
        bool "Enable benchmark code"
        default n
        help
          If y, adds support for simple benchmarking that can record
          time intervals between two calls.  The time printed depends
          on the particular Zephyr target, and is generally ticks of a
          specific board-specific timer.

module = MCUBOOT
module-str = MCUBoot bootloader
source "subsys/logging/Kconfig.template.log_config"
+4 −0
Changes for boot/zephyr/include/mcuboot_config/mcuboot_config.h: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -75,6 +75,10 @@
#define MCUBOOT_BOOTSTRAP 1
#endif

#ifdef CONFIG_BOOT_USE_BENCH
#define MCUBOOT_USE_BENCH 1
#endif

#ifdef CONFIG_UPDATEABLE_IMAGE_NUMBER
#define MCUBOOT_IMAGE_NUMBER    CONFIG_UPDATEABLE_IMAGE_NUMBER
#else
+40 −0
Changes for boot/zephyr/include/platform-bench.h: 40 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright (c) 2019 Linaro Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef H_ZEPHYR_BENCH_H__
#define H_ZEPHYR_BENCH_H__

#include <inttypes.h>
#include <stdint.h>
#include "zephyr.h"
#include "bootutil/bootutil_log.h"

/* TODO: Unclear if this can be here (redundantly). */
MCUBOOT_LOG_MODULE_DECLARE(mcuboot);

typedef uint32_t bench_state_t;

#define plat_bench_start(_s) do { \
    BOOT_LOG_ERR("start benchmark"); \
    *(_s) = k_cycle_get_32(); \
} while (0)

#define plat_bench_stop(_s) do { \
    uint32_t _stop_time = k_cycle_get_32(); \
    BOOT_LOG_ERR("bench: %" PRId32 " cycles", _stop_time - *(_s)); \
} while (0)

#endif /* not H_ZEPHYR_BENCH_H__ */