@ -73,12 +73,25 @@ function(zephyr_mcuboot_tasks)
@@ -73,12 +73,25 @@ function(zephyr_mcuboot_tasks)
return ( )
endif ( )
# B a s i c ' w e s t s i g n ' c o m m a n d a n d o u t p u t f o r m a t i n d e p e n d e n t a r g u m e n t s .
separate_arguments ( west_sign_extra UNIX_COMMAND ${ CONFIG_MCUBOOT_CMAKE_WEST_SIGN_PARAMS } )
set ( west_sign ${ WEST } sign ${ west_sign_extra }
- - t o o l i m g t o o l
- - t o o l - p a t h " $ { i m g t o o l _ p a t h } "
- - b u i l d - d i r " $ { A P P L I C A T I O N _ B I N A R Y _ D I R } " )
# F e t c h d e v i c e t r e e d e t a i l s f o r f l a s h a n d s l o t i n f o r m a t i o n
dt_chosen ( flash_node PROPERTY "zephyr,flash" )
dt_nodelabel ( slot0_flash NODELABEL "slot0_partition" )
dt_prop ( slot_size PATH "${slot0_flash}" PROPERTY "reg" INDEX 1 )
dt_prop ( write_block_size PATH "${flash_node}" PROPERTY "write-block-size" )
# I f s i n g l e s l o t m o d e , o r i f i n f i r m w a r e u p d a t e r m o d e a n d t h i s i s t h e f i r m w a r e u p d a t e r i m a g e ,
# u s e s l o t 0 i n f o r m a t i o n
if ( NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP AND ( NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER OR CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER ) )
# S l o t 1 s i z e i s u s e d i n s t e a d o f s l o t 0 s i z e
set ( slot_size )
dt_nodelabel ( slot1_flash NODELABEL "slot1_partition" )
dt_prop ( slot_size PATH "${slot1_flash}" PROPERTY "reg" INDEX 1 )
endif ( )
# B a s i c ' i m g t o o l s i g n ' c o m m a n d w i t h k n o w n i m a g e i n f o r m a t i o n .
set ( imgtool_sign ${ PYTHON_EXECUTABLE } ${ imgtool_path } sign
- - v e r s i o n $ { C O N F I G _ M C U B O O T _ I M G T O O L _ S I G N _ V E R S I O N } - - h e a d e r - s i z e $ { C O N F I G _ R O M _ S T A R T _ O F F S E T }
- - s l o t - s i z e $ { s l o t _ s i z e } )
# A r g u m e n t s t o i m g t o o l .
if ( NOT CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS STREQUAL "" )
@ -87,102 +100,90 @@ function(zephyr_mcuboot_tasks)
@@ -87,102 +100,90 @@ function(zephyr_mcuboot_tasks)
#
# U s e U N I X _ C O M M A N D s y n t a x f o r u n i f o r m r e s u l t s a c r o s s h o s t
# p l a t f o r m s .
separate_arguments ( imgtool_extra UNIX_COMMAND ${ CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS } )
separate_arguments ( imgtool_args UNIX_COMMAND ${ CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS } )
else ( )
set ( imgtool_extra )
set ( imgtool_args )
endif ( )
if ( NOT "${keyfile}" STREQUAL "" )
set ( imgtool_extra --key "${keyfile}" ${ imgtool_extra } )
set ( imgtool_args --key "${keyfile}" ${ imgtool_args } )
endif ( )
# U s e o v e r w r i t e - o n l y i n s t e a d o f s w a p u p g r a d e s .
if ( CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY )
set ( imgtool_extra --overwrite-only --align 1 ${ imgtool_extra } )
set ( imgtool_args --overwrite-only --align 1 ${ imgtool_args } )
else ( )
set ( imgtool_args --align ${ write_block_size } ${ imgtool_args } )
endif ( )
set ( imgtool_args -- ${ imgtool_extra } )
# E x t e n s i o n l e s s p r e f i x o f a n y o u t p u t f i l e .
set ( output ${ ZEPHYR_BINARY_DIR } / ${ KERNEL_NAME } )
# L i s t o f a d d i t i o n a l b u i l d b y p r o d u c t s .
set ( byproducts )
# ' w e s t s i g n ' a r g u m e n t s f o r c o n f i r m e d , u n c o n f i r m e d a n d e n c r y p t e d i m a g e s .
set ( unconfirmed_args )
set ( confirmed_args )
set ( encrypted_args )
# S e t u p . b i n o u t p u t s .
if ( CONFIG_BUILD_OUTPUT_BIN )
list ( APPEND unconfirmed_args --bin --sbin ${ output } .signed.bin )
list ( APPEND byproducts ${ output } .signed.bin )
zephyr_runner_file ( bin ${ output } .signed.bin )
set ( BYPRODUCT_KERNEL_SIGNED_BIN_NAME "${output}.signed.bin"
C A C H E F I L E P A T H " S i g n e d k e r n e l b i n f i l e " F O R C E
)
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { i m g t o o l _ s i g n } $ { i m g t o o l _ a r g s } $ { o u t p u t } . b i n $ { o u t p u t } . s i g n e d . b i n )
if ( CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE )
list ( APPEND confirmed_args --bin --sbin ${ output } .signed.confirmed.bin )
list ( APPEND byproducts ${ output } .signed.confirmed.bin )
set ( BYPRODUCT_KERNEL_SIGNED_CONFIRMED_BIN_NAME "${output}.signed.confirmed.bin"
C A C H E F I L E P A T H " S i g n e d a n d c o n f i r m e d k e r n e l b i n f i l e " F O R C E
)
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { i m g t o o l _ s i g n } $ { i m g t o o l _ a r g s } - - p a d - - c o n f i r m $ { o u t p u t } . b i n
$ { o u t p u t } . s i g n e d . c o n f i r m e d . b i n )
endif ( )
if ( NOT "${keyfile_enc}" STREQUAL "" )
list ( APPEND encrypted_args --bin --sbin ${ output } .signed.encrypted.bin )
list ( APPEND byproducts ${ output } .signed.encrypted.bin )
set ( BYPRODUCT_KERNEL_SIGNED_ENCRYPTED_BIN_NAME "${output}.signed.encrypted.bin"
C A C H E F I L E P A T H " S i g n e d a n d e n c r y p t e d k e r n e l b i n f i l e " F O R C E
)
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { i m g t o o l _ s i g n } $ { i m g t o o l _ a r g s } - - e n c r y p t " $ { k e y f i l e _ e n c } " $ { o u t p u t } . b i n
$ { o u t p u t } . s i g n e d . e n c r y p t e d . b i n )
endif ( )
endif ( )
# S e t u p . h e x o u t p u t s .
if ( CONFIG_BUILD_OUTPUT_HEX )
list ( APPEND unconfirmed_args --hex --shex ${ output } .signed.hex )
list ( APPEND byproducts ${ output } .signed.hex )
zephyr_runner_file ( hex ${ output } .signed.hex )
set ( BYPRODUCT_KERNEL_SIGNED_HEX_NAME "${output}.signed.hex"
C A C H E F I L E P A T H " S i g n e d k e r n e l h e x f i l e " F O R C E
)
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { i m g t o o l _ s i g n } $ { i m g t o o l _ a r g s } $ { o u t p u t } . h e x $ { o u t p u t } . s i g n e d . h e x )
if ( CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE )
list ( APPEND confirmed_args --hex --shex ${ output } .signed.confirmed.hex )
list ( APPEND byproducts ${ output } .signed.confirmed.hex )
set ( BYPRODUCT_KERNEL_SIGNED_CONFIRMED_HEX_NAME "${output}.signed.confirmed.hex"
C A C H E F I L E P A T H " S i g n e d a n d c o n f i r m e d k e r n e l h e x f i l e " F O R C E
)
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { i m g t o o l _ s i g n } $ { i m g t o o l _ a r g s } - - p a d - - c o n f i r m $ { o u t p u t } . h e x
$ { o u t p u t } . s i g n e d . c o n f i r m e d . h e x )
endif ( )
if ( NOT "${keyfile_enc}" STREQUAL "" )
list ( APPEND encrypted_args --hex --shex ${ output } .signed.encrypted.hex )
list ( APPEND byproducts ${ output } .signed.encrypted.hex )
set ( BYPRODUCT_KERNEL_SIGNED_ENCRYPTED_HEX_NAME "${output}.signed.encrypted.hex"
C A C H E F I L E P A T H " S i g n e d a n d e n c r y p t e d k e r n e l h e x f i l e " F O R C E
)
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { i m g t o o l _ s i g n } $ { i m g t o o l _ a r g s } - - e n c r y p t " $ { k e y f i l e _ e n c } " $ { o u t p u t } . h e x
$ { o u t p u t } . s i g n e d . e n c r y p t e d . h e x )
endif ( )
endif ( )
# A d d t h e w e s t s i g n c a l l s a n d t h e i r b y p r o d u c t s t o t h e p o s t - p r o c e s s i n g
# s t e p s f o r z e p h y r . e l f .
#
# C M a k e g u a r a n t e e s t h a t m u l t i p l e C O M M A N D s g i v e n t o
# add_custom_command ( ) a r e r u n i n o r d e r , s o a d d i n g t h e ' w e s t s i g n '
# c a l l s t o t h e " e x t r a _ p o s t _ b u i l d _ c o m m a n d s " p r o p e r t y e n s u r e s t h e y r u n
# a f t e r t h e c o m m a n d s w h i c h g e n e r a t e t h e u n s i g n e d v e r s i o n s .
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { w e s t _ s i g n } $ { u n c o n f i r m e d _ a r g s } $ { i m g t o o l _ a r g s } )
if ( confirmed_args )
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { w e s t _ s i g n } $ { c o n f i r m e d _ a r g s } $ { i m g t o o l _ a r g s } - - p a d - - c o n f i r m )
endif ( )
if ( encrypted_args )
set_property ( GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
$ { w e s t _ s i g n } $ { e n c r y p t e d _ a r g s } $ { i m g t o o l _ a r g s } - - e n c r y p t " $ { k e y f i l e _ e n c } " )
endif ( )
set_property ( GLOBAL APPEND PROPERTY extra_post_build_byproducts ${ byproducts } )
endfunction ( )