Commit 9a4b9ba1 authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

Add per platform mcuboot_logging.h files

New logging macros were added for all supported platforms, following the
documentation defined in the template config file.

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent 7d81786a
Loading
Loading
Loading
Loading
+3
Changes for boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@
#if MYNEWT_VAL(BOOTUTIL_OVERWRITE_ONLY_FAST)
#define MCUBOOT_OVERWRITE_ONLY_FAST 1
#endif
#if MYNEWT_VAL(BOOTUTIL_HAVE_LOGGING)
#define MCUBOOT_HAVE_LOGGING 1
#endif

#define MCUBOOT_MAX_IMG_SECTORS       MYNEWT_VAL(BOOTUTIL_MAX_IMG_SECTORS)

+82
Changes for boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_logging.h: 82 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 __MCUBOOT_LOGGING_H__
#define __MCUBOOT_LOGGING_H__

#include <syscfg/syscfg.h>
#include <stdio.h>

#define BOOTUTIL_LOG_LEVEL_OFF     1
#define BOOTUTIL_LOG_LEVEL_ERROR   2
#define BOOTUTIL_LOG_LEVEL_WARNING 3
#define BOOTUTIL_LOG_LEVEL_INFO    4
#define BOOTUTIL_LOG_LEVEL_DEBUG   5

#define MCUBOOT_LOG_LEVEL_OFF      BOOTUTIL_LOG_LEVEL_OFF
#define MCUBOOT_LOG_LEVEL_ERROR    BOOTUTIL_LOG_LEVEL_ERROR
#define MCUBOOT_LOG_LEVEL_WARNING  BOOTUTIL_LOG_LEVEL_WARNING
#define MCUBOOT_LOG_LEVEL_INFO     BOOTUTIL_LOG_LEVEL_INFO
#define MCUBOOT_LOG_LEVEL_DEBUG    BOOTUTIL_LOG_LEVEL_DEBUG

#ifndef MCUBOOT_LOG_LEVEL
#define MCUBOOT_LOG_LEVEL MYNEWT_VAL(BOOTUTIL_LOG_LEVEL)
#endif

#if !((MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_OFF) && \
      (MCUBOOT_LOG_LEVEL <= MCUBOOT_LOG_LEVEL_DEBUG))
#error "Invalid MCUBOOT_LOG_LEVEL config."
#endif

#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_ERROR
#define MCUBOOT_LOG_ERR(_fmt, ...)                                      \
    do {                                                                \
        printf("[ERR] " _fmt "\n", ##__VA_ARGS__);                      \
    } while (0)
#else
#define MCUBOOT_LOG_ERR(...) IGNORE(__VA_ARGS__)
#endif

#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_WARNING
#define MCUBOOT_LOG_WRN(_fmt, ...)                                      \
    do {                                                                \
        printf("[WRN] " _fmt "\n", ##__VA_ARGS__);                      \
    } while (0)
#else
#define MCUBOOT_LOG_WRN(...) IGNORE(__VA_ARGS__)
#endif

#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_INFO
#define MCUBOOT_LOG_INF(_fmt, ...)                                      \
    do {                                                                \
        printf("[INF] " _fmt "\n", ##__VA_ARGS__);                      \
    } while (0)
#else
#define MCUBOOT_LOG_INF(...) IGNORE(__VA_ARGS__)
#endif

#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_DEBUG
#define MCUBOOT_LOG_DBG(_fmt, ...)                                      \
    do {                                                                \
        printf("[DBG] " _fmt "\n", ##__VA_ARGS__);                      \
    } while (0)
#else
#define MCUBOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
#endif

#endif
+12
Changes for boot/mynewt/mcuboot_config/syscfg.yml: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -49,3 +49,15 @@ syscfg.defs:
    BOOTUTIL_MAX_IMG_SECTORS:
        description: 'Maximum number of sectors that are swapped.'
        value: 128
    BOOTUTIL_HAVE_LOGGING:
        description: 'Enable serial logging'
        value: 0
    BOOTUTIL_LOG_LEVEL:
        description: >
            Default console log level. Valid values are:
                BOOTUTIL_LOG_LEVEL_OFF
                BOOTUTIL_LOG_LEVEL_ERROR
                BOOTUTIL_LOG_LEVEL_WARNING
                BOOTUTIL_LOG_LEVEL_INFO
                BOOTUTIL_LOG_LEVEL_DEBUG
        value: 'BOOTUTIL_LOG_LEVEL_INFO'
+9
Changes for boot/zephyr/Kconfig: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -78,6 +78,15 @@ config ZEPHYR_TRY_MASS_ERASE

	  This is not available for all targets.

config BOOT_HAVE_LOGGING
	bool "MCUboot have logging enabled"
	default y
	select SYS_LOG
	help
	  If y, enables logging on the serial port. The log level can
	  be defined by setting `SYS_LOG_DEFAULT_LEVEL`.
	  If unsure, leave at the default value.

menuconfig MCUBOOT_SERIAL
	bool "MCUboot serial recovery"
	default n
+4
Changes for boot/zephyr/include/mcuboot_config/mcuboot_config.h: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@
#define MCUBOOT_OVERWRITE_ONLY_FAST
#endif

#ifdef CONFIG_BOOT_HAVE_LOGGING
#define MCUBOOT_HAVE_LOGGING 1
#endif

/*
 * Enabling this option uses newer flash map APIs. This saves RAM and
 * avoids deprecated API usage.
Loading