mirror of https://github.com/wolfSSL/wolfBoot.git
Progress with cross-compiling wolfBoot. Will also be creating CCS project.
parent
a7b61db9e1
commit
31b785fe7e
23
Makefile
23
Makefile
|
|
@ -9,9 +9,10 @@ include tools/config.mk
|
|||
|
||||
## Initializers
|
||||
WOLFBOOT_ROOT?=$(PWD)
|
||||
CFLAGS+=-D__WOLFBOOT -DWOLFBOOT_VERSION=$(WOLFBOOT_VERSION)UL -ffunction-sections -fdata-sections
|
||||
LSCRIPT:=config/target.ld
|
||||
LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles
|
||||
CFLAGS:=-D"__WOLFBOOT" -D"WOLFBOOT_VERSION=$(WOLFBOOT_VERSION)UL"
|
||||
LSCRIPT:=
|
||||
LDFLAGS:=
|
||||
|
||||
OBJS:= \
|
||||
./hal/$(TARGET).o \
|
||||
./src/loader.o \
|
||||
|
|
@ -28,11 +29,13 @@ include arch.mk
|
|||
# Parse config options
|
||||
include options.mk
|
||||
|
||||
CFLAGS+=-Wall -Wextra -Wno-main -ffreestanding -Wno-unused \
|
||||
-I. -Iinclude/ -Ilib/wolfssl -nostartfiles \
|
||||
-DWOLFSSL_USER_SETTINGS \
|
||||
-DWOLFTPM_USER_SETTINGS \
|
||||
-DPLATFORM_$(TARGET)
|
||||
# -Wall -Wextra -Wno-main -ffreestanding -Wno-unused -nostartfiles
|
||||
|
||||
CFLAGS+= \
|
||||
-I"." -I"include/" -I"lib/wolfssl" \
|
||||
-D"WOLFSSL_USER_SETTINGS" \
|
||||
-D"WOLFTPM_USER_SETTINGS" \
|
||||
-D"PLATFORM_$(TARGET)"
|
||||
|
||||
MAIN_TARGET=factory.bin
|
||||
|
||||
|
|
@ -156,11 +159,11 @@ check_config:
|
|||
|
||||
%.o:%.c
|
||||
@echo "\t[CC-$(ARCH)] $@"
|
||||
$(Q)$(CC) $(CFLAGS) -c -o $@ $^
|
||||
$(Q)$(CC) $(CFLAGS) -c --output_file $@ $^
|
||||
|
||||
%.o:%.S
|
||||
@echo "\t[AS-$(ARCH)] $@"
|
||||
$(Q)$(CC) $(CFLAGS) -c -o $@ $^
|
||||
$(Q)$(CC) $(CFLAGS) -c --output_file $@ $^
|
||||
|
||||
FORCE:
|
||||
|
||||
|
|
|
|||
77
arch.mk
77
arch.mk
|
|
@ -21,6 +21,20 @@ UART_TARGET=$(TARGET)
|
|||
# Include SHA256 module because it's implicitly needed by RSA
|
||||
WOLFCRYPT_OBJS+=./lib/wolfssl/wolfcrypt/src/sha256.o
|
||||
|
||||
# Host OS Detection
|
||||
OS_DET=UNKNOWN
|
||||
ifeq ($(OS),Windows_NT)
|
||||
OS_DET=WIN32
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
OS_DET=LINUX
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
OS_DET=OSX
|
||||
endif
|
||||
endif
|
||||
|
||||
## ARM
|
||||
ifeq ($(ARCH),AARCH64)
|
||||
CROSS_COMPILE:=aarch64-none-elf-
|
||||
|
|
@ -158,15 +172,15 @@ endif
|
|||
ifeq ($(TARGET),imx_rt)
|
||||
ARCH_FLASH_OFFSET=0x60000000
|
||||
CFLAGS+=-I$(MCUXPRESSO_DRIVERS)/drivers -I$(MCUXPRESSO_DRIVERS) -I$(MCUXPRESSO)/middleware/mflash/mimxrt1062 \
|
||||
-I$(MCUXPRESSO_DRIVERS)/utilities/debug_console/ \
|
||||
-I$(MCUXPRESSO_DRIVERS)/utilities/str/ \
|
||||
-I$(MCUXPRESSO)/components/uart/ \
|
||||
-I$(MCUXPRESSO)/components/flash/nor \
|
||||
-I$(MCUXPRESSO)/components/flash/nor/flexspi \
|
||||
-I$(MCUXPRESSO)/components/serial_manager/ \
|
||||
-DCPU_$(MCUXPRESSO_CPU) -I$(MCUXPRESSO_CMSIS)/Include -DDEBUG_CONSOLE_ASSERT_DISABLE=1 -I$(MCUXPRESSO_DRIVERS)/project_template/ \
|
||||
-I$(MCUXPRESSO)/boards/evkmimxrt1060/xip/ -DXIP_EXTERNAL_FLASH=1 -DDEBUG_CONSOLE_ASSERT_DISABLE=1 -DPRINTF_ADVANCED_ENABLE=1 \
|
||||
-DSCANF_ADVANCED_ENABLE=1 -DSERIAL_PORT_TYPE_UART=1 -DNDEBUG=1
|
||||
-I$(MCUXPRESSO_DRIVERS)/utilities/debug_console/ \
|
||||
-I$(MCUXPRESSO_DRIVERS)/utilities/str/ \
|
||||
-I$(MCUXPRESSO)/components/uart/ \
|
||||
-I$(MCUXPRESSO)/components/flash/nor \
|
||||
-I$(MCUXPRESSO)/components/flash/nor/flexspi \
|
||||
-I$(MCUXPRESSO)/components/serial_manager/ \
|
||||
-DCPU_$(MCUXPRESSO_CPU) -I$(MCUXPRESSO_CMSIS)/Include -DDEBUG_CONSOLE_ASSERT_DISABLE=1 -I$(MCUXPRESSO_DRIVERS)/project_template/ \
|
||||
-I$(MCUXPRESSO)/boards/evkmimxrt1060/xip/ -DXIP_EXTERNAL_FLASH=1 -DDEBUG_CONSOLE_ASSERT_DISABLE=1 -DPRINTF_ADVANCED_ENABLE=1 \
|
||||
-DSCANF_ADVANCED_ENABLE=1 -DSERIAL_PORT_TYPE_UART=1 -DNDEBUG=1
|
||||
OBJS+= $(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o $(MCUXPRESSO_DRIVERS)/drivers/fsl_flexspi.o
|
||||
ifeq ($(PKA),1)
|
||||
PKA_EXTRA_OBJS+= \
|
||||
|
|
@ -176,10 +190,39 @@ ifeq ($(TARGET),imx_rt)
|
|||
endif
|
||||
endif
|
||||
|
||||
# ARM Big Endian
|
||||
ifeq ($(ARCH),ARM_BE)
|
||||
OBJS+=src/boot_arm.o
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),ti_hercules)
|
||||
# HALCoGen Source and Include?
|
||||
CORTEX_R5=1
|
||||
CFLAGS+=-D"CORTEX_R5"
|
||||
|
||||
ifeq ($(OS_DET),WIN32)
|
||||
CROSS_COMPILE=C:/ti/ccs1030/ccs/tools/compiler/ti-cgt-arm_20.2.4.LTS/
|
||||
else
|
||||
ifeq ($(OS_DET),OSX)
|
||||
CROSS_COMPILE=/Applications/ti/ccs1020/ccs/tools/compiler/ti-cgt-arm_20.2.4.LTS/
|
||||
else
|
||||
CROSS_COMPILE=/opt/ti-cgt-arm_20.2.4.LTS/
|
||||
endif
|
||||
endif
|
||||
|
||||
CC=$(CROSS_COMPILE)bin/armcl
|
||||
LD=$(CROSS_COMPILE)bin/armcl
|
||||
AS=$(CROSS_COMPILE)bin/armasm
|
||||
OBJCOPY=$(CROSS_COMPILE)bin/armobjcopy
|
||||
SIZE=$(CROSS_COMPILE)bin/armsize
|
||||
|
||||
|
||||
ARCH_FLAGS=-mv7R5 --code_state=32 --float_support=VFPv3D16 --enum_type=packed --abi=eabi --include_path="$(CROSS_COMPILE)include"
|
||||
CFLAGS+=$(ARCH_FLAGS)
|
||||
LDFLAGS+=$(ARCH_FLAGS) --be32
|
||||
|
||||
LSCRIPT=hal/ti_hercules.cmd
|
||||
OPTIMIZATION_LEVEL=2
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),lpc)
|
||||
|
|
@ -239,12 +282,18 @@ endif
|
|||
|
||||
CFLAGS+=-DARCH_FLASH_OFFSET=$(ARCH_FLASH_OFFSET)
|
||||
|
||||
# Setup default optimizations (for GCC)
|
||||
ifeq ($(CC),)
|
||||
CFLAGS+=-ffunction-sections -fdata-sections
|
||||
LDFLAGS+=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles
|
||||
endif
|
||||
|
||||
## Toolchain setup
|
||||
CC=$(CROSS_COMPILE)gcc
|
||||
LD=$(CROSS_COMPILE)gcc
|
||||
AS=$(CROSS_COMPILE)gcc
|
||||
OBJCOPY:=$(CROSS_COMPILE)objcopy
|
||||
SIZE:=$(CROSS_COMPILE)size
|
||||
CC?=$(CROSS_COMPILE)gcc
|
||||
LD?=$(CROSS_COMPILE)gcc
|
||||
AS?=$(CROSS_COMPILE)gcc
|
||||
OBJCOPY?=$(CROSS_COMPILE)objcopy
|
||||
SIZE?=$(CROSS_COMPILE)size
|
||||
BOOT_IMG?=test-app/image.bin
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
ARCH?=ARM
|
||||
ARCH?=ARM_BE
|
||||
TARGET?=ti_hercules
|
||||
SIGN?=ECC256
|
||||
HASH?=SHA256
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
/* ti_hercules.c
|
||||
*
|
||||
* Copyright (C) 2021 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfBoot.
|
||||
*
|
||||
* wolfBoot is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfBoot is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <target.h>
|
||||
#include "image.h"
|
||||
|
||||
#ifndef CORTEX_R5
|
||||
# error "wolfBoot TI Hercules HAL: wrong architecture selected. Please compile with TARGET=ti_hercules."
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* public HAL functions */
|
||||
void hal_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void hal_prepare_boot(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RAMFUNCTION hal_flash_unlock(void)
|
||||
{
|
||||
}
|
||||
|
||||
void RAMFUNCTION hal_flash_lock(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* Linker Settings */
|
||||
|
||||
--retain="*(.intvecs)"
|
||||
|
||||
/* USER CODE BEGIN (1) */
|
||||
/* USER CODE END */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Memory Map */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
VECTORS (X) : origin=0x00000000 length=0x00000020
|
||||
KERNEL (RX) : origin=0x00000020 length=0x00008000
|
||||
FLASH0 (RX) : origin=0x00008020 length=0x001F7FE0
|
||||
FLASH1 (RX) : origin=0x00200000 length=0x00200000
|
||||
STACKS (RW) : origin=0x08000000 length=0x00000800
|
||||
KRAM (RW) : origin=0x08000800 length=0x00000800
|
||||
RAM (RW) : origin=(0x08000800+0x00000800) length=(0x0007F800 - 0x00000800)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Section Configuration */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.intvecs : {} > VECTORS
|
||||
/* FreeRTOS Kernel in protected region of Flash */
|
||||
.kernelTEXT align(32) : {} > KERNEL
|
||||
.cinit align(32) : {} > KERNEL
|
||||
.pinit align(32) : {} > KERNEL
|
||||
/* Rest of code to user mode flash region */
|
||||
.text align(32) : {} > FLASH0 | FLASH1
|
||||
.const align(32) : {} > FLASH0 | FLASH1
|
||||
/* FreeRTOS Kernel data in protected region of RAM */
|
||||
.kernelBSS : {} > KRAM
|
||||
.kernelHEAP : {} > RAM
|
||||
.bss : {} > RAM
|
||||
.data : {} > RAM
|
||||
.sysmem : {} > RAM
|
||||
FEE_TEXT_SECTION align(32) : {} > FLASH0 | FLASH1
|
||||
FEE_CONST_SECTION align(32): {} > FLASH0 | FLASH1
|
||||
FEE_DATA_SECTION : {} > RAM
|
||||
}
|
||||
14
options.mk
14
options.mk
|
|
@ -20,7 +20,7 @@ ifeq ($(SIGN),ECC256)
|
|||
ifeq ($(WOLFTPM),0)
|
||||
CFLAGS+=-Wstack-usage=3888
|
||||
else
|
||||
CFLAGS+=-Wstack-usage=6680
|
||||
#CFLAGS+=-Wstack-usage=6680
|
||||
endif
|
||||
PUBLIC_KEY_OBJS=./src/ecc256_pub_key.o
|
||||
endif
|
||||
|
|
@ -137,7 +137,7 @@ ifeq ($(ALLOW_DOWNGRADE),1)
|
|||
endif
|
||||
|
||||
ifeq ($(NVM_FLASH_WRITEONCE),1)
|
||||
CFLAGS+= -DNVM_FLASH_WRITEONCE
|
||||
CFLAGS+= -D"NVM_FLASH_WRITEONCE"
|
||||
endif
|
||||
|
||||
ifeq ($(DISABLE_BACKUP),1)
|
||||
|
|
@ -148,7 +148,11 @@ endif
|
|||
ifeq ($(DEBUG),1)
|
||||
CFLAGS+=-O0 -g -ggdb3 -DDEBUG=1
|
||||
else
|
||||
CFLAGS+=-Os
|
||||
ifeq ($(OPTIMIZATION_LEVEL),)
|
||||
CFLAGS+=-Os
|
||||
else
|
||||
CFLAGS+=-O$(OPTIMIZATION_LEVEL)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(V),0)
|
||||
|
|
@ -156,7 +160,7 @@ ifeq ($(V),0)
|
|||
endif
|
||||
|
||||
ifeq ($(NO_MPU),1)
|
||||
CFLAGS+=-DWOLFBOOT_NO_MPU
|
||||
CFLAGS+=-D"WOLFBOOT_NO_MPU"
|
||||
endif
|
||||
|
||||
ifeq ($(VTOR),0)
|
||||
|
|
@ -194,7 +198,7 @@ endif
|
|||
|
||||
## Hash settings
|
||||
ifeq ($(HASH),SHA256)
|
||||
CFLAGS+=-DWOLFBOOT_HASH_SHA256
|
||||
CFLAGS+=-D"WOLFBOOT_HASH_SHA256"
|
||||
endif
|
||||
|
||||
ifeq ($(HASH),SHA3)
|
||||
|
|
|
|||
|
|
@ -300,7 +300,9 @@ static uint16_t get_header(struct wolfBoot_image *img, uint16_t type, uint8_t **
|
|||
return wolfBoot_find_header(img->hdr + IMAGE_HEADER_OFFSET, type, ptr);
|
||||
}
|
||||
|
||||
#ifdef EXT_FLASH
|
||||
static uint8_t ext_hash_block[WOLFBOOT_SHA_BLOCK_SIZE];
|
||||
#endif
|
||||
static uint8_t digest[WOLFBOOT_SHA_DIGEST_SIZE];
|
||||
static uint8_t *get_sha_block(struct wolfBoot_image *img, uint32_t offset)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue