summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eda2c58)
raw | patch | inline | side by side (parent: eda2c58)
author | SR <s-ramakurthi@ti.com> | |
Wed, 4 May 2022 11:47:10 +0000 (17:17 +0530) | ||
committer | Rishabh Garg <rishabh@ti.com> | |
Mon, 9 May 2022 09:17:41 +0000 (04:17 -0500) |
Signed-off-by: Sai Ramakurthi <s-ramakurthi@ti.com>
diff --git a/packages/ti/boot/sbl/board/src/sbl_image_copy.c b/packages/ti/boot/sbl/board/src/sbl_image_copy.c
index e946d16a16173d7674deadcd321510f0232a4da3..8362f0f754a92886fe1c6c985e2cc77cb460a8fe 100644 (file)
#include "sbl_qspi.h"
#elif defined(BOOT_MMCSD)
#include "sbl_mmcsd.h"
+#elif defined(BOOT_EMMC)
+#include "sbl_emmc.h"
#elif defined(BOOT_SPI)
#include "sbl_spi.h"
#endif
#if defined(BOOT_MMCSD)
/* MMCSD Boot Mode Image Copy function. */
if (SBL_MMCBootImage(pEntry) != 1U)
+#elif defined(BOOT_EMMC)
+ if (SBL_eMMCBootImage(pEntry) != 1U)
#elif defined(BOOT_QSPI)
if (SBL_QSPIBootImage(pEntry) != 1U)
#elif defined(BOOT_SPI)
}
return retval;
-}
\ No newline at end of file
+}
index 160dc30d20d2ef4249120b2f27e5310725ac862a..0916242c14e3cbbc38ab6a0549acdee5eeb5d877 100644 (file)
SBL_CFLAGS += -DBOOT_MMCSD
endif # ifeq ($(BOOTMODE), mmcsd)
+ifeq ($(BOOTMODE), emmc)
+ SBL_CFLAGS += -DBOOT_EMMC
+endif # ifeq ($(BOOTMODE), emmc)
+
ifeq ($(BOOTMODE), ospi)
SBL_CFLAGS += -DBOOT_OSPI
endif # ifeq ($(BOOTMODE), ospi)
COMP_LIST_COMMON += mmcsd fatfs_indp
endif # ifeq ($(filter $(SBL_CFLAGS), -DBOOT_MMCSD), -DBOOT_MMCSD)
+ifeq ($(filter $(SBL_CFLAGS), -DBOOT_EMMC), -DBOOT_EMMC)
+ COMP_LIST_COMMON += mmcsd fatfs_indp
+endif # ifeq ($(filter $(SBL_CFLAGS), -DBOOT_EMMC), -DBOOT_EMMC)
+
ifeq ($(filter $(SBL_CFLAGS), -DBOOT_HYPERFLASH), -DBOOT_HYPERFLASH)
COMP_LIST_COMMON += spi
endif # ifeq ($(filter $(SBL_CFLAGS), -DBOOT_HYPERFLASH), -DBOOT_HYPERFLASH)
index 64ce8194b3b8967eecaebd95b4ff8588cb0c7108..687dfcb6042d02f7af7aa920c31b8ed7e8f65004 100644 (file)
INCDIR += $(PDK_SBL_COMP_PATH)/src/ospi
INCDIR += $(PDK_SBL_COMP_PATH)/src/hyperflash
INCDIR += $(PDK_SBL_COMP_PATH)/src/mmcsd
+INCDIR += $(PDK_SBL_COMP_PATH)/src/emmc
INCDIR += $(PDK_SBL_COMP_PATH)/src/uart
ifeq ($(SOC),$(filter $(SOC), tpr12 awr294x))
INCDIR += $(PDK_SBL_COMP_PATH)/soc/tpr12
SRCDIR +=$(PDK_SBL_COMP_PATH)/src/ospi
SRCDIR +=$(PDK_SBL_COMP_PATH)/src/hyperflash
SRCDIR +=$(PDK_SBL_COMP_PATH)/src/mmcsd
+SRCDIR +=$(PDK_SBL_COMP_PATH)/src/emmc
SRCDIR +=$(PDK_SBL_COMP_PATH)/src/uart
ifeq ($(SOC),$(filter $(SOC), tpr12 awr294x))
SBL_CFLAGS += -DBOOT_MMCSD
endif # ifeq ($(BOOTMODE), mmcsd)
+ifeq ($(BOOTMODE), emmc)
+ SBL_CFLAGS += -DBOOT_EMMC
+endif # ifeq ($(BOOTMODE), emmc)
+
ifeq ($(BOOTMODE), ospi)
SBL_CFLAGS += -DBOOT_OSPI
endif # ifeq ($(BOOTMODE), ospi)
SRCS_COMMON += sbl_mmcsd.c
endif # ifeq ($(filter $(SBL_CFLAGS), -DBOOT_MMCSD), -DBOOT_MMCSD)
+ifeq ($(filter $(SBL_CFLAGS), -DBOOT_EMMC), -DBOOT_EMMC)
+ SRCS_COMMON += sbl_emmc.c
+endif # ifeq ($(filter $(SBL_CFLAGS), -DBOOT_EMMC), -DBOOT_EMMC)
+
ifeq ($(filter $(SBL_CFLAGS), -DBOOT_OSPI), -DBOOT_OSPI)
SRCS_COMMON += sbl_ospi.c
endif # ifeq ($(filter $(SBL_CFLAGS), -DBOOT_OSPI), -DBOOT_OSPI)
index 26d1a97b373774da297ae18a2c5ab38e2edc89bc..39cebd79af84011cea03ae8e09268df71c5d9ddf 100644 (file)
sbl_LIB_LIST += sbl_lib_mmcsd_hlos_hs sbl_lib_ospi_hlos_hs sbl_lib_hyperflash_hlos_hs
sbl_LIB_LIST += sbl_lib_ospi_nondma_hs sbl_lib_ospi_nondma_hlos_hs
endif
+ ifeq ($(SOC), $(filter $(SOC), j721e))
+ sbl_LIB_LIST += sbl_lib_emmc
+ endif
endif
############################
sbl_EXAMPLE_LIST += sbl_mmcsd_img_hs sbl_ospi_img_hs sbl_hyperflash_img_hs sbl_uart_img_hs
sbl_EXAMPLE_LIST += sbl_mmcsd_img_hlos_hs sbl_ospi_img_hlos_hs sbl_hyperflash_img_hlos_hs
endif
+ ifeq ($(SOC), $(filter $(SOC), j721e))
+ sbl_EXAMPLE_LIST += sbl_emmc_img
+ endif
endif
sbl_lib_mmcsd_hlos_hs_$(SOC)_CORELIST = mcu1_0
export sbl_lib_mmcsd_hlos_hs_$(SOC)_CORELIST
+# SBL EMMC LIB
+sbl_lib_emmc_COMP_LIST = sbl_lib_emmc
+sbl_lib_emmc_RELPATH = ti/boot/sbl
+export sbl_lib_emmc_OBJPATH = ti/boot/sbl/emmc
+sbl_lib_emmc_LIBNAME = sbl_lib_emmc
+sbl_lib_emmc_PATH = $(PDK_SBL_COMP_PATH)
+sbl_lib_emmc_LIBPATH = $(PDK_SBL_COMP_PATH)/lib/emmc
+sbl_lib_emmc_MAKEFILE = -f$(PDK_SBL_COMP_PATH)/build/sbl_lib.mk BOOTMODE=emmc SBL_USE_DMA=yes
+export sbl_lib_emmc_MAKEFILE
+export sbl_lib_emmc_LIBNAME
+export sbl_lib_emmc_LIBPATH
+sbl_lib_emmc_BOARD_DEPENDENCY = yes
+sbl_lib_emmc_SOC_DEPENDENCY = yes
+sbl_lib_emmc_CORE_DEPENDENCY = no
+export sbl_lib_emmc_COMP_LIST
+export sbl_lib_emmc_BOARD_DEPENDENCY
+export sbl_lib_emmc_CORE_DEPENDENCY
+sbl_lib_emmc_PKG_LIST = sbl_lib_emmc
+sbl_lib_emmc_INCLUDE = $(sbl_lib_emmc_PATH)
+sbl_lib_emmc_SOCLIST = j721e
+sbl_lib_emmc_BOARDLIST = j721e_evm
+export sbl_lib_emmc_SOCLIST
+export sbl_lib_emmc_BOARDLIST
+sbl_lib_emmc_$(SOC)_CORELIST = mcu1_0
+export sbl_lib_emmc_$(SOC)_CORELIST
+
# SBL OSPI LIB
sbl_lib_ospi_COMP_LIST = sbl_lib_ospi
sbl_lib_ospi_RELPATH = ti/boot/sbl
export sbl_mmcsd_img_hlos_hs_$(SOC)_CORELIST = mcu1_0
export sbl_mmcsd_img_hlos_hs_SBL_IMAGEGEN = yes
+# SBL EMMC Image
+sbl_emmc_img_COMP_LIST = sbl_emmc_img
+sbl_emmc_img_RELPATH = ti/boot/sbl/board/k3
+sbl_emmc_img_CUSTOM_BINPATH = $(PDK_SBL_COMP_PATH)/binary/$(BOARD)/emmc/bin
+sbl_emmc_img_PATH = $(PDK_SBL_COMP_PATH)/board/k3
+sbl_emmc_img_MAKEFILE = -f$(PDK_SBL_COMP_PATH)/build/sbl_img.mk BOOTMODE=emmc SBL_USE_DMA=yes BUILD_HS=no
+export sbl_emmc_img_MAKEFILE
+export sbl_emmc_img_SBL_CERT_KEY=$(SBL_CERT_KEY)
+sbl_emmc_img_BOARD_DEPENDENCY = yes
+sbl_emmc_img_SOC_DEPENDENCY = yes
+sbl_emmc_img_CORE_DEPENDENCY = no
+export sbl_emmc_img_COMP_LIST
+export sbl_emmc_img_BOARD_DEPENDENCY
+export sbl_emmc_img_SOC_DEPENDENCY
+export sbl_emmc_img_CORE_DEPENDENCY
+sbl_emmc_img_PKG_LIST = sbl
+sbl_emmc_img_INCLUDE = $(sbl_emmc_img_PATH)
+sbl_emmc_img_BOARDLIST = j721e_evm
+export sbl_emmc_img_BOARDLIST
+sbl_emmc_img_$(SOC)_CORELIST = mcu1_0
+export sbl_emmc_img_$(SOC)_CORELIST
+sbl_emmc_img_SBL_IMAGEGEN = yes
+export sbl_emmc_img_SBL_IMAGEGEN
# SBL OSPI Image
sbl_ospi_img_COMP_LIST = sbl_ospi_img
diff --git a/packages/ti/boot/sbl/soc/k3/sbl_slave_core_boot.c b/packages/ti/boot/sbl/soc/k3/sbl_slave_core_boot.c
index fa056964209d9b1429c9db206192d537902f48cb..56de32c0488b13c6da47dacc4aab2e2fe28d8164 100755 (executable)
#include "sbl_mmcsd.h"
#endif
+#if defined(BOOT_EMMC)
+#include "sbl_emmc.h"
+#endif
+
#if defined(BOOT_UART)
#include "sbl_uart.h"
#endif
#if defined(BOOT_MMCSD)
/* MMCSD Boot Mode Image Copy function. */
if (SBL_MMCBootImage(pEntry) != E_PASS)
+#elif defined(BOOT_EMMC)
+ if (SBL_eMMCBootImage(pEntry) != E_PASS)
#elif defined(BOOT_OSPI)
if (SBL_OSPIBootImage(pEntry) != E_PASS)
#elif defined(BOOT_UART)
diff --git a/packages/ti/boot/sbl/src/emmc/sbl_emmc.c b/packages/ti/boot/sbl/src/emmc/sbl_emmc.c
--- /dev/null
@@ -0,0 +1,476 @@
+/**
+ * \file sbl_emmc.c
+ *
+ * \brief This file contains functions for eMMC File read operations for SBL
+ *
+ */
+
+/*
+ * Copyright (C) 2015 - 2022 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/* ========================================================================== */
+/* Include Files */
+/* ========================================================================== */
+#include <stdint.h>
+
+/* TI-RTOS Header files */
+#include <ti/drv/uart/UART_stdio.h>
+#include <ti/drv/mmcsd/MMCSD.h>
+#include <ti/drv/mmcsd/soc/MMCSD_soc.h>
+#include <ti/drv/mmcsd/src/MMCSD_osal.h>
+
+/* SBL Header files. */
+#include "sbl_rprc_parse.h"
+#include "sbl_emmc.h"
+
+/* K3 Header files */
+#ifdef BUILD_MCU
+#include <sbl_sci_client.h>
+#endif
+
+#ifdef SECURE_BOOT
+#include "sbl_sec.h"
+#endif
+
+/**
+ * \brief SBL_FileRead function reads N bytes from eMMC and
+ * advances the cursor.
+ *
+ * \param buff - Pointer to data buffer
+ * \param fileptr - Read head pointer
+ * \param size - Number of bytes to read
+ *
+ * \return Error code on file error
+ */
+int32_t SBL_FileRead(void *buff,
+ void *fileptr,
+ uint32_t size);
+
+/**
+ * \brief SBL_FileSeek function to move the read head by n bytes
+ *
+ * \param srcAddr - Read head pointer
+ * \param location - Move the read head pointer by n bytes
+ *
+ * \return none
+ */
+void SBL_FileSeek(void *fileptr, uint32_t location);
+
+
+
+int32_t SBL_loadMMCSDBootFile(FIL * fp);
+
+/* ========================================================================== */
+/* Global Variables */
+/* ========================================================================== */
+/* FATFS function table for eMMC implementation */
+FATFS_DrvFxnTable FATFS_drvFxnTable = {
+ &MMCSD_close,
+ &MMCSD_control,
+ &MMCSD_init,
+ &MMCSD_open,
+ &MMCSD_write,
+ &MMCSD_read
+};
+
+/* FATFS configuration structure */
+FATFS_HwAttrs FATFS_initCfg[_VOLUMES] =
+{
+ {
+#if defined(iceK2G) || defined(am65xx_evm) || defined(am65xx_idk) || defined(j721e_evm) || defined(j7200_evm) || defined(j721s2_evm) || defined(am64x_evm)
+ 0U
+#else
+ 1U
+#endif
+ },
+ {
+#if defined(iceK2G) || defined(am65xx_evm) || defined(am65xx_idk) || defined(j721e_evm) || defined(j7200_evm) || defined(j721s2_evm) || defined(am64x_evm)
+ 0U
+#else
+ 1U
+#endif
+ },
+ {
+#if defined(iceK2G) || defined(am65xx_evm) || defined(am65xx_idk) || defined(j721e_evm) || defined(j7200_evm) || defined(j721s2_evm) || defined(am64x_evm)
+ 0U
+#else
+ 1U
+#endif
+ },
+ {
+#if defined(iceK2G) || defined(am65xx_evm) || defined(am65xx_idk) || defined(j721e_evm) || defined(j7200_evm) || defined(j721s2_evm) || defined(am64x_evm)
+ 0U
+#else
+ 1U
+#endif
+ }
+};
+
+/* FATFS objects */
+FATFS_Object FATFS_objects[_VOLUMES];
+
+/* FATFS Handle */
+FATFS_Handle sbl_fatfsHandle = NULL;
+
+/* FATFS configuration structure */
+const FATFS_Config FATFS_config[_VOLUMES + 1] = {
+ {
+ &FATFS_drvFxnTable,
+ &FATFS_objects[0],
+ &FATFS_initCfg[0]
+ },
+
+ {
+ &FATFS_drvFxnTable,
+ &FATFS_objects[1],
+ &FATFS_initCfg[1]
+ },
+
+ {
+ &FATFS_drvFxnTable,
+ &FATFS_objects[2],
+ &FATFS_initCfg[2]
+ },
+
+ {NULL, NULL, NULL},
+
+ {NULL, NULL, NULL}
+};
+
+#ifdef iceK2G
+extern MMCSD_v1_HwAttrs MMCSDInitCfg[];
+#endif
+
+#if defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_J721S2)
+#define SBL_WKUP_DEVSTAT_PRIMARY_BOOT_MASK (0x78U)
+#define SBL_WKUP_DEVSTAT_PRIMARY_BOOT_MMCSD (0x1U)
+#define SBL_MAIN_DEVSTAT_PRIMARY_BUS_WIDTH_MASK (0x20U)
+#define SBL_MAIN_DEVSTAT_BACKUP_BOOT_MASK (0xEU)
+#define SBL_MAIN_DEVSTAT_BACKUP_BOOT_MMCSD (0xAU)
+#define SBL_MAIN_DEVSTAT_PRIMARY_BOOT_B_MASK (0x1U)
+#endif
+
+#ifdef SECURE_BOOT
+extern SBL_incomingBootData_S sblInBootData;
+#endif
+
+#ifdef BUILD_MCU
+int32_t SBL_ReadSysfwImage(void **pBuffer, uint32_t num_bytes)
+{
+ int32_t retVal = CSL_PASS;
+#if defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_J721S2)
+ const TCHAR *fileName = "0:/tifs.bin";
+#else
+ const TCHAR *fileName = "0:/sysfw.bin";
+#endif
+ FIL fp = {0};
+ FRESULT fresult;
+ uint32_t bytes_read = 0;
+ void *sysfw_ptr = *pBuffer;
+ MMCSD_v2_HwAttrs hwAttrsConfig;
+
+ if(MMCSD_socGetInitCfg(FATFS_initCfg[0].drvInst,&hwAttrsConfig)!=0) {
+ UART_printf("\nUnable to get config.Exiting. TEST FAILED.\r\n");
+ retVal = E_FAIL;
+ }
+
+#if defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_J721S2)
+ uint32_t wkupCtrlDevstat = (*((volatile uint32_t *)(CSL_WKUP_CTRL_MMR0_CFG0_BASE + CSL_WKUP_CTRL_MMR_CFG0_WKUP_DEVSTAT)));
+ uint32_t mainCtrlDevstat = (*((volatile uint32_t *)(CSL_CTRL_MMR0_CFG0_BASE + CSL_MAIN_CTRL_MMR_CFG0_MAIN_DEVSTAT)));
+
+ if(((wkupCtrlDevstat & SBL_WKUP_DEVSTAT_PRIMARY_BOOT_MASK) == SBL_WKUP_DEVSTAT_PRIMARY_BOOT_MMCSD) &&
+ ((mainCtrlDevstat & SBL_MAIN_DEVSTAT_PRIMARY_BOOT_B_MASK) == SBL_MAIN_DEVSTAT_PRIMARY_BOOT_B_MASK))
+ {
+ /* eMMC as primary bootmode */
+ /* Check MAIN CTRL MMR DEVSTAT register for Primary boot mode Bus Width */
+ if((mainCtrlDevstat & SBL_MAIN_DEVSTAT_PRIMARY_BUS_WIDTH_MASK) == SBL_MAIN_DEVSTAT_PRIMARY_BUS_WIDTH_MASK)
+ {
+ hwAttrsConfig.supportedBusWidth = MMCSD_BUS_WIDTH_1BIT;
+ }
+ else
+ {
+ hwAttrsConfig.supportedBusWidth = MMCSD_BUS_WIDTH_8BIT;
+ }
+ }
+ else if((mainCtrlDevstat & SBL_MAIN_DEVSTAT_BACKUP_BOOT_MASK) == SBL_MAIN_DEVSTAT_BACKUP_BOOT_MMCSD)
+ {
+ /* eMMC as backup bootmode only supports 1-bit bus width, as set by ROM code */
+ hwAttrsConfig.supportedBusWidth = MMCSD_BUS_WIDTH_1BIT;
+ }
+ else
+ {
+ hwAttrsConfig.supportedBusWidth = MMCSD_BUS_WIDTH_8BIT;
+ }
+#endif
+
+ hwAttrsConfig.enableInterrupt = ((uint32_t)(0U));
+ hwAttrsConfig.configSocIntrPath=NULL;
+
+ if(MMCSD_socSetInitCfg(FATFS_initCfg[0].drvInst,&hwAttrsConfig)!=0) {
+ UART_printf("\nUnable to set config.Exiting. TEST FAILED.\r\n");
+ retVal = E_FAIL;
+ }
+
+ /* Initialization of the driver. */
+ FATFS_init();
+
+ /* eMMC FATFS initialization */
+ FATFS_open(0U, NULL, &sbl_fatfsHandle);
+
+ fresult = f_open(&fp, fileName, ((BYTE)FA_READ));
+ if (fresult != FR_OK)
+ {
+#if defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_J721S2)
+ UART_printf("\n eMMC Boot - tifs File open fails \n");
+#else
+ UART_printf("\n eMMC Boot - sysfw File open fails \n");
+#endif
+ retVal = E_FAIL;
+ }
+ else
+ {
+ fresult = f_read(&fp, sysfw_ptr, num_bytes, &bytes_read);
+ if (fresult != FR_OK)
+ {
+#if defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_J721S2)
+ UART_printf("\n eMMC Boot - tifs read fails \n");
+#else
+ UART_printf("\n eMMC Boot - sysfw read fails \n");
+#endif
+ retVal = E_FAIL;
+ }
+
+ f_close(&fp);
+ }
+
+ FATFS_close(sbl_fatfsHandle);
+ sbl_fatfsHandle = NULL;
+
+ return retVal;
+}
+#endif
+
+int32_t SBL_eMMCBootImage(sblEntryPoint_t *pEntry)
+{
+ int32_t retVal = E_PASS;
+ const TCHAR *fileName = "0:/app";
+ FIL fp = {0};
+ FRESULT fresult;
+
+
+#ifdef SECURE_BOOT
+ uint32_t authenticated = 0;
+ uint32_t srcAddr = 0;
+ uint32_t imgOffset = 0;
+#endif
+
+#ifdef iceK2G
+ MMCSDInitCfg[1].cardType = MMCSD_CARD_SD;
+#endif
+
+ /* Initialization of the driver. */
+ FATFS_init();
+
+ /* eMMC FATFS initialization */
+ FATFS_open(0U, NULL, &sbl_fatfsHandle);
+
+ fresult = f_open(&fp, fileName, ((BYTE)FA_READ));
+ if (fresult != FR_OK)
+ {
+ UART_printf("\n SD Boot - File open fails \n");
+ retVal = E_FAIL;
+ }
+ else
+ {
+
+#ifndef SECURE_BOOT
+ fp_readData = &SBL_FileRead;
+ fp_seek = &SBL_FileSeek;
+
+#if defined(SBL_ENABLE_HLOS_BOOT) && (defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_J721S2))
+ retVal = SBL_MulticoreImageParse((void *) &fp, 0, pEntry, SBL_SKIP_BOOT_AFTER_COPY);
+#else
+ retVal = SBL_MulticoreImageParse((void *) &fp, 0, pEntry, SBL_BOOT_AFTER_COPY);
+#endif
+
+#else
+
+ fp_readData = &SBL_MemRead;
+ fp_seek = &SBL_MemSeek;
+
+
+ /* handling secure boot image */
+ if (E_PASS == SBL_loadMMCSDBootFile(&fp))
+ {
+ /* successfully loading boot image */
+ /* authentiate it */
+ authenticated = SBL_authentication(sblInBootData.sbl_boot_buff);
+ if (authenticated == 0)
+ {
+ /* fails authentiation */
+ UART_printf("\n SD Boot - fail authentication\n");
+
+ retVal = E_FAIL;
+ }
+ else
+ {
+ /* need to skip the TOC headers */
+ imgOffset = ((uint32_t*)sblInBootData.sbl_boot_buff)[0];
+ srcAddr = (uint32_t)(sblInBootData.sbl_boot_buff) + imgOffset;
+#if defined(SBL_ENABLE_HLOS_BOOT) && (defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_J721S2))
+ retVal = SBL_MulticoreImageParse((void *)srcAddr, 0, pEntry, SBL_SKIP_BOOT_AFTER_COPY);
+#else
+ retVal = SBL_MulticoreImageParse((void *)srcAddr, 0, pEntry, SBL_BOOT_AFTER_COPY);
+#endif
+
+ }
+ }
+ else
+ {
+ UART_printf("\n SD sec Boot - incorrect image\n");
+
+ retVal = E_FAIL;
+ }
+
+#endif
+
+ f_close(&fp);
+ }
+
+ FATFS_close(sbl_fatfsHandle);
+ sbl_fatfsHandle = NULL;
+
+#ifdef SECURE_BOOT
+ /* install RAM Secure Kernel to overwrite DSP secure server*/
+ UART_printf("\n Starting Secure Kernel on DSP...\n");
+ SBL_startSK();
+#endif
+
+ return retVal;
+}
+
+#ifndef SECURE_BOOT
+int32_t SBL_FileRead(void *buff,
+ void *fileptr,
+ uint32_t size)
+{
+ FIL *fp = (FIL *) (fileptr);
+ uint8_t *tmp_buff_ptr = (uint8_t *)buff;
+ uint32_t i = 0;
+ uint32_t bytes_read = 0;
+ uint32_t Max_read = 0x400U; /*setting a fatfs read size of 1k */
+ FRESULT fresult = FR_OK;
+ int32_t retVal = E_FAIL;
+
+ for (i = ((uint32_t)0U); i < (size / Max_read); ++i)
+ {
+ fresult = f_read(fp, (void *)tmp_buff_ptr, Max_read, &bytes_read);
+ tmp_buff_ptr = tmp_buff_ptr + bytes_read;
+ if (fresult != FR_OK)
+ {
+ break;
+ }
+ }
+ if (fresult == FR_OK)
+ {
+ fresult = f_read(fp, (void *)tmp_buff_ptr, (UINT) (size % Max_read), &bytes_read);
+ }
+
+ if (fresult == FR_OK)
+ {
+ retVal = E_PASS;
+ }
+
+ return retVal;
+}
+
+void SBL_FileSeek(void *fileptr, uint32_t location)
+{
+ FIL *fp = (FIL *) (fileptr);
+ f_lseek(fp, location);
+}
+
+#else
+
+/* load signed boot image from MMCSD */
+int32_t SBL_loadMMCSDBootFile(FIL * fp)
+{
+ int32_t retVal = E_PASS;
+ uint32_t bytes_read;
+ uint32_t doneRead = 0;
+ uint32_t buff_idx = 0;
+ FRESULT fresult = FR_OK;
+
+
+ /* reading entire boot image into memory */
+ buff_idx = 0;
+ while ((doneRead == 0) &&
+ ((buff_idx + READ_BUFF_SIZE) < SBL_MAX_BOOT_BUFF_SIZE))
+ {
+ fresult = f_read(fp, (sblInBootData.sbl_boot_buff + buff_idx),
+ READ_BUFF_SIZE, &bytes_read);
+
+ if (fresult == FR_OK)
+ {
+ if (bytes_read < READ_BUFF_SIZE)
+ {
+ doneRead = 1;
+ }
+
+ buff_idx += bytes_read;
+ }
+ else
+ {
+ doneRead = 1;
+
+ /* fail read */
+ retVal = E_FAIL;
+ }
+
+ if ((doneRead == 0) &&
+ ((buff_idx + READ_BUFF_SIZE)>=SBL_MAX_BOOT_BUFF_SIZE))
+ {
+ /* boot image is bigger than reserved buffer. Error */
+ doneRead = 1;
+ retVal = E_FAIL;
+ }
+ }
+
+ sblInBootData.sbl_boot_size = buff_idx;
+ sblInBootData.sbl_boot_buff_idx = 0; /* reset the read pointer */
+
+ return retVal;
+}
+#endif
+
+
diff --git a/packages/ti/boot/sbl/src/emmc/sbl_emmc.h b/packages/ti/boot/sbl/src/emmc/sbl_emmc.h
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+ * \file sbl_emmc.h
+ *
+ * \brief This file contains function prototypes for EMMC Boot functionality
+ * of SBL.
+ *
+ */
+
+/*
+ * Copyright (C) 2015-2022 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef SBL_EMMC_H
+#define SBL_EMMC_H
+
+/* FATFS header file */
+#include <ti/fs/fatfs/ff.h>
+#include <ti/fs/fatfs/FATFS.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const FATFS_Config FATFS_config[_VOLUMES + 1];
+
+/* ========================================================================== */
+/* Include Files */
+/* ========================================================================== */
+
+/*
+ * \brief SBL_MMCBootImage function initializes the MMCSD driver and copies
+ * the application image from the SD card to the DDR memory and
+ * gives control to the processor core.
+ *
+ * \param pointer to the structure holding the entry pointers for different
+ * cores.
+ *
+ * \return error status.If error has occured it returns a non zero value.
+ * If no error has occured then return status will be zero.
+ *
+ */
+int32_t SBL_eMMCBootImage(sblEntryPoint_t *pEntry);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/packages/ti/boot/sbl/src/mmcsd/sbl_mmcsd.c b/packages/ti/boot/sbl/src/mmcsd/sbl_mmcsd.c
index befc8af09c8dedec28857e8bd6fb2d7143d7d96d..f7694276824e95b271ce25f803ee0f9f3cb637ec 100755 (executable)
};
/* FATFS configuration structure */
-#if defined(BOOT_EMMC)
-FATFS_HwAttrs FATFS_initCfg[_VOLUMES] =
-{
- {
-#if defined(iceK2G) || defined(am65xx_evm) || defined(am65xx_idk) || defined(j721e_evm) || defined(j7200_evm) || defined(j721s2_evm) || defined(am64x_evm)
- 0U
-#else
- 1U
-#endif
- },
- {
-#if defined(iceK2G) || defined(am65xx_evm) || defined(am65xx_idk) || defined(j721e_evm) || defined(j7200_evm) || defined(j721s2_evm) || defined(am64x_evm)
- 0U
-#else
- 1U
-#endif
- },
- {
-#if defined(iceK2G) || defined(am65xx_evm) || defined(am65xx_idk) || defined(j721e_evm) || defined(j7200_evm) || defined(j721s2_evm) || defined(am64x_evm)
- 0U
-#else
- 1U
-#endif
- },
- {
-#if defined(iceK2G) || defined(am65xx_evm) || defined(am65xx_idk) || defined(j721e_evm) || defined(j7200_evm) || defined(j721s2_evm) || defined(am64x_evm)
- 0U
-#else
- 1U
-#endif
- }
-};
-#else
FATFS_HwAttrs FATFS_initCfg[_VOLUMES] =
{
{
#endif
}
};
-#endif
/* FATFS objects */
FATFS_Object FATFS_objects[_VOLUMES];
index 7265095ff173e1e07221913deb010aea82178647..926de7996c498419b989ecdede586464a15d850c 100644 (file)
SBL_IMAGE_PATH=$(SBL_BIN_PATH)
SBL_IMAGE_PATH_SIGNED=$(SBL_BIN_PATH_SIGNED)
SECURE_IMAGE_TYPE=X-LOADER
-ifeq ($(BOOTMODE),$(filter $(BOOTMODE), sd))
+ifeq ($(BOOTMODE),$(filter $(BOOTMODE), sd emmc))
SBL_IMAGE_PATH=$(SBL_MLO_PATH)
SBL_IMAGE_PATH_SIGNED=$(SBL_MLO_PATH_SIGNED)
SECURE_IMAGE_TYPE=MLO
ifeq ($(BOOTMODE),$(filter $(BOOTMODE), qspi qspi_sd))
SBL_ENDIAN=BE
endif
-ifeq ($(BOOTMODE),$(filter $(BOOTMODE), sd))
+ifeq ($(BOOTMODE),$(filter $(BOOTMODE), sd emmc))
SBL_ENDIAN=LE
endif
SBL_MCU_STARTUP_MODE=EFUSE_DEFAULT
$(SBL_IMAGE_PATH): $(SBL_BIN_FILE)
ifeq ($(SOC),$(filter $(SOC), tda2xx tda2ex tda2px tda3xx dra78x))
-ifeq ($(BOOTMODE),$(filter $(BOOTMODE), sd qspi qspi_sd))
+ifeq ($(BOOTMODE),$(filter $(BOOTMODE), sd qspi qspi_sd emmc))
$(CHMOD) a+x $(SBL_TIIMAGE)
#For HS build don't append GP Header at the top of SBL
ifeq ($(BUILD_HS),yes)
endif
endif
endif
- ifeq ($(BOOTMODE),$(filter $(BOOTMODE), sd))
+ ifeq ($(BOOTMODE),$(filter $(BOOTMODE), sd emmc))
ifneq ($(BUILD_PROFILE_$(CORE)),release)
$(MKDIR) -p $(BINDIR)/$(BUILD_PROFILE_$(CORE))
endif