Commit 386b5921 authored by Andrzej Puzdrowski's avatar Andrzej Puzdrowski Committed by Carles Cufí
Browse files

use zephyr tincybor instead of mcuboot build-in tinycbor

Zephyr has build-in tinycbor code of version which doesn't
require newlib-c by default. Also the cborattr module is now
taken form the zephyr code.

This patch decrease flash consumption by 10 KB for serial recovery build.

Signed-off-by: default avatarAndrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
parent 520e31ca
Loading
Loading
Loading
Loading
+1
Changes for .gitignore: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -10,3 +10,4 @@ rusty-tags.*
/project.state
/bin/
/targets/
**/build/**/*
+5
Changes for boot/boot_serial/src/CMakeLists.txt: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
zephyr_sources(boot_serial.c)

zephyr_include_directories(${BOOT_DIR}/bootutil/include)

zephyr_include_directories($ENV{ZEPHYR_BASE}/ext/lib/mgmt/mcumgr/cborattr/include)
zephyr_sources($ENV{ZEPHYR_BASE}/ext/lib/mgmt/mcumgr/cborattr/src/cborattr.c)

zephyr_link_libraries_ifdef(CONFIG_TINYCBOR TINYCBOR)
+11 −2
Changes for boot/boot_serial/src/boot_serial.c: 11 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <crc16.h>
#include <serial_adapter/serial_adapter.h>
#include <base64.h>
#include <cbor.h>
#else
#include <bsp/bsp.h>
#include <hal/hal_system.h>
@@ -43,10 +44,10 @@
#include <console/console.h>
#include <crc/crc16.h>
#include <base64/base64.h>
#endif /* __ZEPHYR__ */

#include <tinycbor/cbor.h>
#include <tinycbor/cbor_buf_reader.h>
#endif /* __ZEPHYR__ */

#include <cborattr/cborattr.h>

#include <flash_map/flash_map.h>
@@ -216,7 +217,11 @@ bs_upload(char *buf, int len)

    memset(img_data, 0, sizeof(img_data));
    cbor_buf_reader_init(&reader, (uint8_t *)buf, len);
#ifdef __ZEPHYR__
    cbor_parser_cust_reader_init(&reader.r, 0, &parser, &value);
#else
    cbor_parser_init(&reader.r, 0, &parser, &value);
#endif
    rc = cbor_read_object(&value, attr);
    if (rc || off == UINT_MAX) {
        rc = MGMT_ERR_EINVAL;
@@ -326,7 +331,11 @@ boot_serial_input(char *buf, int len)
    buf += sizeof(*hdr);
    len -= sizeof(*hdr);
    bs_writer.bytes_written = 0;
#ifdef __ZEPHYR__
    cbor_encoder_cust_writer_init(&bs_root, &bs_writer, 0);
#else
    cbor_encoder_init(&bs_root, &bs_writer, 0);
#endif

    /*
     * Limited support for commands.
−3
Changes for boot/zephyr/CMakeLists.txt: 0 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -229,7 +229,4 @@ if (CONFIG_MCUBOOT_SERIAL)
zephyr_sources(${BOOT_DIR}/zephyr/serial_adapter.c)

add_subdirectory(${BOOT_DIR}/boot_serial ./boot/boot_serial)
add_subdirectory(${BOOT_DIR}/zephyr/tinycbor)
add_subdirectory(${BOOT_DIR}/zephyr/cborattr)

endif()
+1 −1
Changes for boot/zephyr/Kconfig: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ menuconfig MCUBOOT_SERIAL
	select UART_INTERRUPT_DRIVEN
	select SERIAL
	select BASE64
	select NEWLIB_LIBC
	select TINYCBOR
	help
	  Enable serial recovery feature in mcuboot.

Loading