mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #14334 from hugueskamba/hk_cmake_remove_app_target_post_build_calls
CMake: Remove references of APP_TARGETpull/14363/head
commit
1f28e6e7dd
|
|
@ -17,6 +17,7 @@
|
|||
#
|
||||
|
||||
import argparse
|
||||
import pathlib
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
|
@ -59,6 +60,12 @@ class AddSignatureError(Exception):
|
|||
adding signature to Secure Boot image
|
||||
"""
|
||||
|
||||
|
||||
class ArtefactsError(Exception):
|
||||
"""An exception to indicate that the artefact(s) needed for processing
|
||||
ave not been found."""
|
||||
|
||||
|
||||
# Base class for all configuration exceptions
|
||||
class ConfigException(Exception):
|
||||
"""Config system only exception. Makes it easier to distinguish config
|
||||
|
|
@ -306,13 +313,29 @@ def complete(message_func, elf0, hexf0, hexf1=None):
|
|||
|
||||
def merge_action(args):
|
||||
"""Entry point for the "merge" CLI command."""
|
||||
try:
|
||||
elf_file = list(pathlib.Path(args.artefacts_location).glob("*.elf"))[0]
|
||||
m4hex_file = list(pathlib.Path(args.artefacts_location).glob("*.hex"))[0]
|
||||
except IndexError:
|
||||
raise ArtefactsError(
|
||||
f"Could not find elf and/or hex file in {args.artefacts_location}"
|
||||
)
|
||||
|
||||
complete_func(
|
||||
print, args.elf, args.m4hex, args.m0hex
|
||||
print, elf_file, m4hex_file, args.m0hex
|
||||
)
|
||||
|
||||
|
||||
def sign_action(args):
|
||||
"""Entry point for the "sign" CLI command."""
|
||||
try:
|
||||
elf_file = list(pathlib.Path(args.artefacts_location).glob("*.elf"))[0]
|
||||
m4hex_file = list(pathlib.Path(args.artefacts_location).glob("*.hex"))[0]
|
||||
except IndexError:
|
||||
raise ArtefactsError(
|
||||
f"Could not find elf and/or hex file in {args.artefacts_location}"
|
||||
)
|
||||
|
||||
sign_hex(
|
||||
args.build_dir,
|
||||
args.m0hex_filename,
|
||||
|
|
@ -322,8 +345,8 @@ def sign_action(args):
|
|||
args.boot_scheme,
|
||||
args.cm0_img_id,
|
||||
args.cm4_img_id,
|
||||
args.elf,
|
||||
args.m4hex,
|
||||
elf_file,
|
||||
m4hex_file,
|
||||
args.m0hex
|
||||
)
|
||||
|
||||
|
|
@ -340,10 +363,7 @@ def parse_args():
|
|||
"merge", help="Merge Cortex-M4 and Cortex-M0 HEX files."
|
||||
)
|
||||
merge_subcommand.add_argument(
|
||||
"--elf", required=True, help="the application ELF file."
|
||||
)
|
||||
merge_subcommand.add_argument(
|
||||
"--m4hex", required=True, help="the path to the Cortex-M4 HEX to merge."
|
||||
"--artefacts-location", required=True, help="the path to the application artefacts."
|
||||
)
|
||||
merge_subcommand.add_argument(
|
||||
"--m0hex", help="the path to the Cortex-M0 HEX to merge."
|
||||
|
|
@ -375,10 +395,7 @@ def parse_args():
|
|||
"--cm4-img-id", type=int, help="the Cortex-M4 image ID."
|
||||
)
|
||||
sign_subcommand.add_argument(
|
||||
"--elf", required=True, help="the application ELF file."
|
||||
)
|
||||
sign_subcommand.add_argument(
|
||||
"--m4hex", required=True, help="the path to the Cortex-M4 HEX to merge."
|
||||
"--artefacts-location", required=True, help="the path to the application artefacts."
|
||||
)
|
||||
sign_subcommand.add_argument(
|
||||
"--m0hex", help="the path to the Cortex-M0 HEX to merge."
|
||||
|
|
|
|||
|
|
@ -22,16 +22,14 @@ function(mbed_post_build_psoc6_merge_hex mbed_target_name)
|
|||
set(post_build_command
|
||||
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/PSOC6.py
|
||||
merge
|
||||
--elf $<TARGET_FILE:${APP_TARGET}>
|
||||
--m4hex ${CMAKE_BINARY_DIR}/${APP_TARGET}.hex
|
||||
--artefacts-location ${CMAKE_BINARY_DIR}
|
||||
--m0hex ${cortex_m0_hex}
|
||||
)
|
||||
else()
|
||||
set(post_build_command
|
||||
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/PSOC6.py
|
||||
merge
|
||||
--elf $<TARGET_FILE:${APP_TARGET}>
|
||||
--m4hex ${CMAKE_BINARY_DIR}/${APP_TARGET}.hex
|
||||
--artefacts-location ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
@ -63,8 +61,7 @@ function(mbed_post_build_psoc6_sign_image
|
|||
--boot-scheme ${boot_scheme}
|
||||
--cm0-img-id ${cm0_img_id}
|
||||
--cm4-img-id ${cm4_img_id}
|
||||
--elf $<TARGET_FILE:${APP_TARGET}>
|
||||
--m4hex ${CMAKE_BINARY_DIR}/${APP_TARGET}.hex
|
||||
--artefacts-location ${CMAKE_BINARY_DIR}
|
||||
--m0hex ${cortex_m0_hex}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,17 @@ causes the checksum of the first 8 table entries to be 0. The boot loader code c
|
|||
the first 8 locations in sector 0 of the flash. If the result is 0, then execution control is
|
||||
transferred to the user code.
|
||||
"""
|
||||
import pathlib
|
||||
import os
|
||||
import sys
|
||||
from struct import unpack, pack
|
||||
|
||||
|
||||
class ArtefactsError(Exception):
|
||||
"""An exception to indicate that the artefact(s) needed for processing
|
||||
ave not been found."""
|
||||
|
||||
|
||||
def patch(bin_path):
|
||||
with open(bin_path, 'r+b') as bin:
|
||||
# Read entries 0 through 6 (Little Endian 32bits words)
|
||||
|
|
@ -47,6 +53,14 @@ def is_patched(bin_path):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
binary = sys.argv[1]
|
||||
artefacts_location = sys.argv[1]
|
||||
|
||||
try:
|
||||
binary = list(pathlib.Path(artefacts_location).glob("*.bin"))[0]
|
||||
except IndexError:
|
||||
raise ArtefactsError(
|
||||
f"Could not find binary file in {artefacts_location}"
|
||||
)
|
||||
|
||||
print("LPC Patch: %s" % os.path.split(binary)[1])
|
||||
patch(binary)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function(mbed_post_build_lpc_patch_vtable mbed_target_name)
|
|||
|
||||
set(post_build_command
|
||||
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_NXP/scripts/LPC.py
|
||||
${CMAKE_BINARY_DIR}/${APP_TARGET}.bin
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
mbed_set_post_build_operation()
|
||||
|
|
|
|||
Loading…
Reference in New Issue