mirror of https://github.com/wolfSSL/wolfBoot.git
Add support for PowerPC 32-bit SHA256 assembly speedups. Minor fix for ELF loading to set entry point before copying sections (resolves issue with loading on top of current location). Rename elf_load_image_mmu argument `entry` to `pentry` to avoid confusion with GET_H64 macro's use of header member "entry".
parent
865c681254
commit
1712edc136
32
arch.mk
32
arch.mk
|
|
@ -561,6 +561,19 @@ ifeq ($(ARCH),PPC)
|
|||
LDFLAGS+=-Wl,--gc-sections
|
||||
|
||||
OBJS+=src/boot_ppc_start.o src/boot_ppc.o
|
||||
|
||||
ifeq ($(SPMATH),1)
|
||||
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o
|
||||
endif
|
||||
|
||||
ifneq ($(NO_ASM),1)
|
||||
# Use the SHA256 and SP math all assembly accelerations
|
||||
CFLAGS+=-DWOLFSSL_SP_PPC
|
||||
CFLAGS+=-DWOLFSSL_PPC32_ASM -DWOLFSSL_PPC32_ASM_INLINE
|
||||
#CFLAGS+=-DWOLFSSL_PPC32_ASM_SMALL
|
||||
#CFLAGS+=-DUSE_SLOW_SHA256
|
||||
OBJS+=./lib/wolfssl/wolfcrypt/src/port/ppc32/ppc32-sha256-asm_c.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),kinetis)
|
||||
|
|
@ -788,12 +801,7 @@ ifeq ($(TARGET),nxp_t1024)
|
|||
OBJS+=src/pci.o
|
||||
CFLAGS+=-DWOLFBOOT_USE_PCI
|
||||
UPDATE_OBJS:=src/update_ram.o
|
||||
ifeq ($(SPMATH),1)
|
||||
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o
|
||||
else
|
||||
# Use the SP math all assembly accelerations
|
||||
CFLAGS+=-DWOLFSSL_SP_PPC
|
||||
endif
|
||||
|
||||
SPI_TARGET=nxp
|
||||
OPTIMIZATION_LEVEL=0 # using default -Os causes issues with alignment
|
||||
endif
|
||||
|
|
@ -811,12 +819,6 @@ ifeq ($(TARGET),nxp_t2080)
|
|||
LDFLAGS+=-Wl,--as-needed # remove weak functions not used
|
||||
UPDATE_OBJS:=src/update_ram.o
|
||||
OBJS+=src/fdt.o
|
||||
ifeq ($(SPMATH),1)
|
||||
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o
|
||||
else
|
||||
# Use the SP math all assembly accelerations
|
||||
CFLAGS+=-DWOLFSSL_SP_PPC
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),nxp_p1021)
|
||||
|
|
@ -835,12 +837,6 @@ ifeq ($(TARGET),nxp_p1021)
|
|||
# Use PPC stdlib for memcpy, etc.
|
||||
#CFLAGS+=-DWOLFBOOT_USE_STDLIBC
|
||||
|
||||
ifeq ($(SPMATH),1)
|
||||
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o
|
||||
else
|
||||
# Use the SP math all assembly accelerations
|
||||
CFLAGS+=-DWOLFSSL_SP_PPC
|
||||
endif
|
||||
SPI_TARGET=nxp
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ SIGN?=ECC384
|
|||
HASH?=SHA384
|
||||
IMAGE_HEADER_SIZE?=512
|
||||
DEBUG?=0
|
||||
DEBUG_SYMBOLS?=1
|
||||
DEBUG_UART?=1
|
||||
VTOR?=1
|
||||
CORTEX_M0?=0
|
||||
|
|
@ -16,12 +17,13 @@ ALLOW_DOWNGRADE?=0
|
|||
NVM_FLASH_WRITEONCE?=0
|
||||
WOLFBOOT_VERSION?=0
|
||||
NO_MPU?=0
|
||||
SPMATH?=0
|
||||
SPMATHALL?=1
|
||||
SPMATH?=1
|
||||
SPMATHALL?=0
|
||||
RAM_CODE?=0
|
||||
DUALBANK_SWAP?=0
|
||||
WOLFTPM?=0
|
||||
ELF?=1
|
||||
DEBUG_ELF?=0
|
||||
|
||||
# Flash Sector (Block) Size (16KB)
|
||||
WOLFBOOT_SECTOR_SIZE=0x4000
|
||||
|
|
|
|||
|
|
@ -1990,12 +1990,15 @@ make DEBUG=1 wolfboot.bin
|
|||
# OR
|
||||
make wolfboot.bin
|
||||
|
||||
# Sign application
|
||||
# Build test app
|
||||
make test-app/image.bin
|
||||
|
||||
# Sign the ELF32 application
|
||||
# 1=version (can be any 32-bit value)
|
||||
./tools/keytools/sign \
|
||||
IMAGE_HEADER_SIZE=512 ./tools/keytools/sign \
|
||||
--ecc384 \
|
||||
--sha384 \
|
||||
test-app/image.bin \
|
||||
test-app/image.elf \
|
||||
wolfboot_signing_private_key.der \
|
||||
1
|
||||
|
||||
|
|
@ -2003,7 +2006,7 @@ make wolfboot.bin
|
|||
factory.bin \
|
||||
0x0 hal/nxp_p1021_stage1.bin \
|
||||
0x8000 wolfboot.bin \
|
||||
0x200000 test-app/image.bin \
|
||||
0x200000 test-app/image_v1_signed.bin \
|
||||
0x01F00000 fsl_qe_ucode_1021_10_A.bin
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -514,6 +514,48 @@ static void udelay(uint32_t delay_us)
|
|||
wait_ticks(delay_us * DELAY_US);
|
||||
}
|
||||
|
||||
#if 0 /* useful timer code */
|
||||
|
||||
uint64_t hal_timer_ms(void)
|
||||
{
|
||||
uint64_t val;
|
||||
/* time base is updated every 8 CCB clocks */
|
||||
uint64_t cntfrq = hal_get_bus_clk() / 8;
|
||||
uint64_t cntpct = get_ticks();
|
||||
val = (cntpct * 1000ULL) / cntfrq;
|
||||
return val;
|
||||
}
|
||||
|
||||
/* example usage */
|
||||
//uint64_t start = hal_get_tick_count();
|
||||
// do some work
|
||||
//wolfBoot_printf("done (%lu ms)\n", (uint32_t)hal_elapsed_time_ms(start));
|
||||
|
||||
/* Calculate elapsed time in milliseconds, handling timer overflow properly */
|
||||
uint64_t hal_elapsed_time_ms(uint64_t start_ticks)
|
||||
{
|
||||
uint64_t current_ticks, elapsed_ticks;
|
||||
uint64_t cntfrq = hal_get_bus_clk() / 8;
|
||||
|
||||
current_ticks = get_ticks();
|
||||
|
||||
/* Handle timer overflow using unsigned arithmetic
|
||||
* This works correctly even if the timer has rolled over,
|
||||
* as long as the elapsed time is less than the full timer range
|
||||
*/
|
||||
elapsed_ticks = current_ticks - start_ticks;
|
||||
|
||||
/* Convert elapsed ticks to milliseconds */
|
||||
return (elapsed_ticks * 1000ULL) / cntfrq;
|
||||
}
|
||||
|
||||
/* Get current tick count for use with hal_elapsed_time_ms() */
|
||||
uint64_t hal_get_tick_count(void)
|
||||
{
|
||||
return get_ticks();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ---- eSPI Driver ---- */
|
||||
#ifdef ENABLE_ESPI
|
||||
void hal_espi_init(uint32_t cs, uint32_t clock_hz, uint32_t mode)
|
||||
|
|
|
|||
|
|
@ -498,6 +498,7 @@
|
|||
/* Hardware Implementation-Dependent Registers */
|
||||
#define SPRN_HID0 0x3F0
|
||||
#define HID0_TBEN (1 << 14) /* Time base enable */
|
||||
#define HID0_TBCLK (1 << 13) /* select clock: 0=every 8 ccb clocks, 1=rising edge of RTC */
|
||||
#define HID0_ENMAS7 (1 << 7) /* Enable hot-wire update of MAS7 register */
|
||||
#define HID0_EMCP (1 << 31) /* Enable machine check pin */
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ typedef struct elf64_program_header {
|
|||
#define GET_E32(name) (is_elf32 ? GET32(e32->name) : GET32(e64->name))
|
||||
|
||||
typedef int (*elf_mmu_map_cb)(uint64_t, uint64_t, uint32_t);
|
||||
int elf_load_image_mmu(uint8_t *image, uintptr_t *entry, elf_mmu_map_cb mmu_cb);
|
||||
int elf_load_image_mmu(uint8_t *image, uintptr_t *pentry, elf_mmu_map_cb mmu_cb);
|
||||
int elf_load_image(uint8_t *image, uintptr_t *entry, int is_ext);
|
||||
int64_t elf_hdr_pht_combined_size(const unsigned char* ehdr);
|
||||
int elf_open(const unsigned char *ehdr, int *is_elf32);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 2151a1b8a1f8f81c4dba985429d50b76db7307e5
|
||||
Subproject commit f30c54abdddf0ffee7a45ed7c89d9007a0a7c54e
|
||||
|
|
@ -54,7 +54,7 @@ static int check_scatter_format(const unsigned char* ehdr, int is_elf32);
|
|||
/* Loader for elf32 or elf64 format program headers
|
||||
* Returns the entry point function
|
||||
*/
|
||||
int elf_load_image_mmu(uint8_t *image, uintptr_t *entry, elf_mmu_map_cb mmu_cb)
|
||||
int elf_load_image_mmu(uint8_t *image, uintptr_t *pentry, elf_mmu_map_cb mmu_cb)
|
||||
{
|
||||
elf32_header* h32 = (elf32_header*)image;
|
||||
elf64_header* h64 = (elf64_header*)image;
|
||||
|
|
@ -86,6 +86,9 @@ int elf_load_image_mmu(uint8_t *image, uintptr_t *entry, elf_mmu_map_cb mmu_cb)
|
|||
is_elf32 ? 32 : 64, is_le ? "little" : "big");
|
||||
#endif
|
||||
|
||||
/* set entry point */
|
||||
*pentry = GET_H64(entry);
|
||||
|
||||
/* programs */
|
||||
entry_off = image + GET_H32(ph_offset);
|
||||
entry_size = GET_H16(ph_entry_size);
|
||||
|
|
@ -144,9 +147,8 @@ int elf_load_image_mmu(uint8_t *image, uintptr_t *entry, elf_mmu_map_cb mmu_cb)
|
|||
#endif
|
||||
}
|
||||
|
||||
*entry = GET_H64(entry);
|
||||
#ifdef DEBUG_ELF
|
||||
wolfBoot_printf("Entry point %p\r\n", (void*)*entry);
|
||||
wolfBoot_printf("Entry point %p\r\n", (void*)*pentry);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue