Commit 40c28e36 authored by Rajavardhan Gundi's avatar Rajavardhan Gundi Committed by Fabio Utzig
Browse files

Add support for intel_s1000 SoC which is based on Xtensa arch

parent 3b8b58dc
Loading
Loading
Loading
Loading
+5
Changes for boot/zephyr/CMakeLists.txt: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -36,6 +36,11 @@ else()
  set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/dts.overlay)
endif()

if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}.overlay)
  set(DTC_OVERLAY_FILE
      "${DTC_OVERLAY_FILE} ${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}.overlay")
endif()

# Enable Zephyr runner options which request mass erase if so
# configured.
#
+44
Changes for boot/zephyr/boards/intel_s1000_crb.conf: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y

CONFIG_CONSOLE_HANDLER=y
CONFIG_SYS_LOG=y
CONFIG_DEBUG=n
CONFIG_SYSTEM_CLOCK_DISABLE=y
CONFIG_SYS_POWER_MANAGEMENT=n

CONFIG_MAIN_STACK_SIZE=10240
CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"

CONFIG_BOOT_ENCRYPT_RSA=n

### Default to RSA
CONFIG_BOOT_SIGNATURE_TYPE_RSA=y
CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=n

### The bootloader generates its own signature verification based on a
### key file which needs to be provided and needs to match the selected signing
### algorithm (CONFIG_BOOT_SIGNATURE_TYPE_).
### The PEM files below are provided as examples.
CONFIG_BOOT_SIGNATURE_KEY_FILE="root-rsa-2048.pem"
#CONFIG_BOOT_SIGNATURE_KEY_FILE="root-ec-p256.pem"

### mbedTLS has its own heap
# CONFIG_HEAP_MEM_POOL_SIZE is not set

### We never want Zephyr's copy of tinycrypt.  If tinycrypt is needed,
### MCUboot has its own copy in tree.
# CONFIG_TINYCRYPT is not set
# CONFIG_TINYCRYPT_ECC_DSA is not set
# CONFIG_TINYCRYPT_SHA256 is not set

CONFIG_I2C=n
CONFIG_SPI=y
CONFIG_FLASH=y
CONFIG_BOOT_MAX_IMG_SECTORS=512
CONFIG_MULTITHREADING=y

### Various Zephyr boards enable features that we don't want.
# CONFIG_BT is not set
# CONFIG_BT_CTLR is not set
+13
Changes for boot/zephyr/boards/intel_s1000_crb.overlay: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright (c) 2018 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */
/ {
	sram0: memory@be000000 {
		device_type = "memory";
		compatible = "mmio-sram";
		reg = <0xbe000000 0x30000>;
	};
};
+7 −6
Changes for boot/zephyr/flash_map_extended.c: 7 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -15,14 +15,15 @@

#include "bootutil/bootutil_log.h"

/*
 * For now, we only support one flash device.
 *
 * Pick the SoC Flash driver ID.
 */
#if (!defined(CONFIG_XTENSA) && defined(DT_FLASH_DEV_NAME))
#define FLASH_DEVICE_ID SOC_FLASH_0_ID
#define FLASH_DEVICE_BASE CONFIG_FLASH_BASE_ADDRESS
#elif (defined(CONFIG_XTENSA) && defined(DT_SPI_NOR_DRV_NAME))
#define FLASH_DEVICE_ID SPI_FLASH_0_ID
#else
#error "FLASH_DEVICE_ID could not be determined"
#endif

#define FLASH_DEVICE_BASE CONFIG_FLASH_BASE_ADDRESS
static struct device *flash_dev;

struct device *flash_device_get_binding(char *dev_name)
+55 −1
Changes for boot/zephyr/main.c: 55 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -76,6 +76,54 @@ static void do_boot(struct boot_rsp *rsp)
    __set_MSP(vt->msp);
    ((void (*)(void))vt->reset)();
}

#elif defined(CONFIG_XTENSA)
#define SRAM_BASE_ADDRESS	0xBE030000

static void copy_img_to_SRAM(int slot, unsigned int hdr_offset)
{
    const struct flash_area *fap;
    int area_id;
    int rc;
    unsigned char *dst = (unsigned char *)(SRAM_BASE_ADDRESS + hdr_offset);

    BOOT_LOG_INF("Copying image to SRAM");

    area_id = flash_area_id_from_image_slot(slot);
    rc = flash_area_open(area_id, &fap);
    if (rc != 0) {
	BOOT_LOG_ERR("flash_area_open failed with %d\n", rc);
        goto done;
    }

    rc = flash_area_read(fap, hdr_offset, dst, fap->fa_size - hdr_offset);
    if (rc != 0) {
	BOOT_LOG_ERR("flash_area_read failed with %d\n", rc);
        goto done;
    }

done:
    flash_area_close(fap);
}

/* Entry point (.ResetVector) is at the very beginning of the image.
 * Simply copy the image to a suitable location and jump there.
 */
static void do_boot(struct boot_rsp *rsp)
{
    void *start;

    BOOT_LOG_INF("br_image_off = 0x%x\n", rsp->br_image_off);
    BOOT_LOG_INF("ih_hdr_size = 0x%x\n", rsp->br_hdr->ih_hdr_size);

    /* Copy from the flash to HP SRAM */
    copy_img_to_SRAM(0, rsp->br_hdr->ih_hdr_size);

    /* Jump to entry point */
    start = (void *)(SRAM_BASE_ADDRESS + rsp->br_hdr->ih_hdr_size);
    ((void (*)(void))start)();
}

#else
/* Default: Assume entry point is at the very beginning of the image. Simply
 * lock interrupts and jump there. This is the right thing to do for X86 and
@@ -108,12 +156,18 @@ void main(void)

    os_heap_init();

#ifdef DT_FLASH_DEV_NAME
#if (!defined(CONFIG_XTENSA) && defined(DT_FLASH_DEV_NAME))
    if (!flash_device_get_binding(DT_FLASH_DEV_NAME)) {
        BOOT_LOG_ERR("Flash device %s not found", DT_FLASH_DEV_NAME);
        while (1)
            ;
    }
#elif (defined(CONFIG_XTENSA) && defined(DT_SPI_NOR_DRV_NAME))
    if (!flash_device_get_binding(DT_SPI_NOR_DRV_NAME)) {
        BOOT_LOG_ERR("Flash device %s not found", DT_SPI_NOR_DRV_NAME);
        while (1)
            ;
    }
#endif

#ifdef CONFIG_MCUBOOT_SERIAL