Skip to content

Commit

Permalink
Enabled the ihex file for SM
Browse files Browse the repository at this point in the history
Signed-off-by: y <hui1.teng.lim@intel.com>
  • Loading branch information
hui1teng authored and FelixWongSiewAn committed Mar 28, 2024
1 parent c9f048a commit 564589c
Show file tree
Hide file tree
Showing 6 changed files with 564 additions and 0 deletions.
60 changes: 60 additions & 0 deletions sm_soc_devkit_ghrd/software/hps_debug/Makefile
@@ -0,0 +1,60 @@
################################################
#
# SPDX-License-Identifier: MIT-0
# Copyright(c) 2023 Intel Corporation.
#
################################################
#
# Makefile for HPS Wipe Firmware
#
################################################

#COMPILER ?= GCC
#COMPILER ?= ARMCLANG

WHICH = which

#Check GCC Version
GCCVERSION_7 := $(shell $(WHICH) aarch64-linux-gnu-gcc 2>/dev/null)
GCCVERSION_9 := $(shell $(WHICH) aarch64-none-linux-gnu-gcc 2>/dev/null)

ifneq ($(GCCVERSION_9),)
CROSS_COMPILE ?= "aarch64-none-linux-gnu-"
else ifneq ($(GCCVERSION_7),)
CROSS_COMPILE ?= "aarch64-linux-gnu-"
else
CROSS_COMPILE = "NOT_FOUND"
endif

ifndef COMPILER
#If no COMPILER defined Try GCC First, then try ARMCLANG

ifneq ($(CROSS_COMPILE), "NOT_FOUND")
include Makefile_GCC.inc
else ifneq ($(shell $(WHICH) armclang 2>/dev/null),)
include Makefile_ARMCLANG.inc
else
$(error "ERROR :: GCC or ARMCLANG Compiler not found, please install either one of the compiler to continue")
endif

else ifeq ("$(COMPILER)","GCC")

ifneq ($(CROSS_COMPILE), "NOT_FOUND")
include Makefile_GCC.inc
else
$(error "ERROR :: COMPILER=GCC is chosen, please install gcc compiler to continue or try COMPILER=ARMCC")
endif

else ifeq ("$(COMPILER)","ARMCLANG")

ifneq ("$(shell $(WHICH) armclang 2>/dev/null)", "")
include Makefile_ARMCLANG.inc
else
$(error "ERROR :: COMPILER=ARMCLANG is chosen, please install arm compiler to continue or try COMPILER=GCC")
endif

else

$(error "ERROR :: Invalid Compiler option, choose only GCC or ARMCLANG")

endif
53 changes: 53 additions & 0 deletions sm_soc_devkit_ghrd/software/hps_debug/Makefile_ARMCLANG.inc
@@ -0,0 +1,53 @@
################################################
#
# SPDX-License-Identifier: MIT-0
# Copyright(c) 2017-2023 Intel Corporation.
#
################################################
#
# Makefile for HPS Wipe Firmware ARMCLANG
#
################################################

AS := armasm
CC := armclang
LD := armlink
OD := fromelf
OBJCOPY := objcopy

TARGET_PROCESSOR := aarch64-arm-none-eabi

AXF := hps_wipe.axf
IHEX := $(patsubst %.axf,%.ihex,$(AXF))
OBJDUMP_FILE := $(patsubst %.axf,%.objdump,$(AXF))

SRC := hps_wipe.s
SCATTER_FILE := scatter.scat

CC_FLAGS := -g --target=$(TARGET_PROCESSOR) -mcpu=Cortex-A53
LD_FLAGS := --scatter=$(SCATTER_FILE) --entry=0x0

OBJ.s := $(patsubst %.s,%.o,$(filter %.s,$(SRC)))

OBJ := $(OBJ.s)

RM := rm -rf

.PHONY: all
all: $(AXF) $(IHEX) $(OBJDUMP_FILE)

clean:
$(RM) *.o
$(RM) $(AXF) $(IHEX) $(OBJDUMP_FILE)

$(AXF): $(OBJ) $(SCATTER_FILE)
$(LD) $(LD_FLAGS) $(OBJ) -o $@

$(OBJDUMP_FILE): %.objdump: %.axf
$(OD) -s -t --disassemble $< > $@

$(IHEX): %.ihex: %.axf
$(OBJCOPY) -O ihex $< $@

$(OBJ.s): %.o: %.s
$(CC) -c $(CC_FLAGS) $< -o $@
44 changes: 44 additions & 0 deletions sm_soc_devkit_ghrd/software/hps_debug/Makefile_GCC.inc
@@ -0,0 +1,44 @@
################################################
#
# SPDX-License-Identifier: MIT-0
# Copyright(c) 2023 Intel Corporation.
#
################################################
#
# Makefile for HPS Wipe Firmware GCC
#
################################################

CC:= $(CROSS_COMPILE)as
OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump

SRC := hps_wipe.s
ENTRY_POINT:=0x0

IHEX := $(patsubst %.s,%.ihex,$(SRC))
ELF := $(patsubst %.s,%.elf,$(SRC))
BIN := $(patsubst %.s,%.bin,$(SRC))
OBJDUMP_FILE = $(patsubst %.s,%.objdump,$(SRC))

OBJ_FLAG := -I binary -O ihex --change-address $(ENTRY_POINT)

RM := rm -rf

.PHONY: all
all: $(ELF) $(BIN) $(IHEX) $(OBJDUMP_FILE)

clean:
$(RM) $(ELF) $(IHEX) $(BIN) $(OBJDUMP_FILE)

$(ELF): $(SRC)
$(CC) $(SRC) -o $@

$(BIN): $(ELF)
$(OBJCOPY) -O binary $< $@

$(IHEX): $(BIN)
$(OBJCOPY) $(OBJ_FLAG) $< $@

$(OBJDUMP_FILE): $(ELF)
$(OBJDUMP) --disassemble $< > $@
44 changes: 44 additions & 0 deletions sm_soc_devkit_ghrd/software/hps_debug/README.md
@@ -0,0 +1,44 @@
# HPS Content Wipe Program

The HPS content wipe program is a small program that is invoked by SDM when there is a security breach event detected or during a cold reset. The intention of this program is to clear HPS content, especially in cache. This memory might contain sensitive data.

## How to build
User can build the HPS wipe with two different compilers, which are GCC and ARMCLANG

### GCC compiler
> $make COMPILER=GCC
User can specify the CROSS_COMPILE option, since in linaro version 9, the binary name of the compiler changed.
> $make COMPILER=GCC CROSS_COMPILE=aarch64-linux-gnu-
> $make COMPILER=GCC CROSS_COMPILE=aarch64-none-linux-gnu-
### ARMCLANG Compiler
> $make COMPILER=ARMCLANG
## To clean
> $make clean COMPILER=GCC
> $make clean COMPILER=ARMCLANG

## Prerequisite
### Compile with GCC
Please download GCC compiler from
https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/aarch64-linux-gnu/

### Compile with ARMCLANG
Please download ARM Development Studio from
https://www.arm.com/

### For Windows user
Please download MSYS2 from
https://www.msys2.org/

### Export Environment
Please export the installation path of the bin folder for the compilers
Examples:

GCC
> export PATH=$PATH:/c/gcc-linaro-7.5.0-2019.12-i686-mingw32_aarch64-linux-gnu/gcc/bin
ARMCLANG
> export PATH=$PATH:/c/Program\ Files/Arm/Development\ Studio\ 2021.0/sw/ARMCompiler6.16/bin

0 comments on commit 564589c

Please sign in to comment.