Skip to content

Commit

Permalink
_targets: use metaelf to embedd integrity metadata
Browse files Browse the repository at this point in the history
`metaelf` is utilized to add integrity checksums to all apps and
the kernel if it is intended to load as an ELF file (using the
"kernel" command instead of "kernelimg" which is for binary image
of kernel) and only when `phoenix-host-utils/metaelf` is available
(e.g., i.MXRT) or in custom projects.

JIRA: RTOS-296
  • Loading branch information
Gerard Swiderski committed May 8, 2024
1 parent 6f87c3f commit 5fc7f25
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions _targets/build.common
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ b_add2img() {
}


b_signelf() {
# use metaelf to sign, embedd crc only when metaelf is build by project
if [ -f "$PREFIX_BUILD_HOST/prog.stripped/metaelf" ] && [[ "$1" != *.bin ]]; then
printf "Signing %s " "$1"
"$PREFIX_BUILD_HOST/prog.stripped/metaelf" -w "$1"
fi
}


b_prod_image() {
b_log "Creating production images"

Expand All @@ -217,10 +226,12 @@ b_prod_image() {

# Kernel
OFFSET="$KERNEL_OFFS"
b_signelf "${PREFIX_PROG_STRIPPED}$KERNEL_FILE"
b_add2img "${PREFIX_PROG_STRIPPED}$KERNEL_FILE" "$PHOENIX_DISK"

# Programs
for prog in "${PROGS[@]}"; do
b_signelf "${PREFIX_PROG_STRIPPED}$prog"
b_add2img "${PREFIX_PROG_STRIPPED}$prog" "$PHOENIX_DISK"
done

Expand All @@ -237,10 +248,12 @@ b_kernel_image() {
rm -f "$IMG"

OFFSET="$KERNEL_OFFS"
b_signelf "${PREFIX_PROG_STRIPPED}/$KERNEL_FILE"
b_add2img "${PREFIX_PROG_STRIPPED}/$KERNEL_FILE" "$IMG"

# Programs
for prog in "${PROGS[@]}"; do
b_signelf "${PREFIX_PROG_STRIPPED}$prog"
b_add2img "${PREFIX_PROG_STRIPPED}$prog" "$IMG"
done
}
Expand Down Expand Up @@ -286,10 +299,12 @@ b_dev_image() {
# Kernel
KERNEL_OFFS=$((KERNEL_OFFS - OFFS_USER_SCRIPT))
OFFSET="$KERNEL_OFFS"
b_signelf "${PREFIX_PROG_STRIPPED}/$KERNEL_FILE"
b_add2img "${PREFIX_PROG_STRIPPED}$KERNEL_FILE" "$PHOENIX_DEV_IMG"

# Programs
for prog in "${PROGS[@]}"; do
b_signelf "${PREFIX_PROG_STRIPPED}$prog"
b_add2img "${PREFIX_PROG_STRIPPED}$prog" "$PHOENIX_DEV_IMG"
done
}

0 comments on commit 5fc7f25

Please sign in to comment.