fix(romlib): make romlib file modification idempotent
The romlib run configs perform a find+replace on a file in TF-A.
However, that is written such that it is not idempotent - running the
configuration multiple times will stack changes on top of each other,
resulting in a file different to the one intended.
So convert this to a patch and use the regular apply_tf_patch
functionality. This has the benefit of not using the main tfa checkout
for parallel builds.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
Change-Id: Ic310c8b42d9f5a4cf8a1cf1c86198ea796202d94
diff --git a/fvp_utils.sh b/fvp_utils.sh
index 1bca9dd..7f72c6d 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -202,8 +202,6 @@
popd
}
-fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
-
fvp_romlib_runtime() {
local tmpdir="$(mktempdir)"
@@ -212,8 +210,7 @@
mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
# Patch index file
- cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
- sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
+ apply_tf_patch "fvp_romlib_runtime/jmptbl_i_patch.patch"
# Rebuild with patched file
echo "Building patched romlib:"
@@ -224,12 +221,6 @@
mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
}
-fvp_romlib_cleanup() {
- # Restore original index
- mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
-}
-
-
# Generates the final YAML-based LAVA job definition from a template file.
#
# The job definition template is expanded with visibility of all variables that
diff --git a/patch/fvp_romlib_runtime/jmptbl_i_patch.patch b/patch/fvp_romlib_runtime/jmptbl_i_patch.patch
new file mode 100644
index 0000000..ba58e50
--- /dev/null
+++ b/patch/fvp_romlib_runtime/jmptbl_i_patch.patch
@@ -0,0 +1,58 @@
+diff --git i/plat/arm/board/fvp/jmptbl.i w/plat/arm/board/fvp/jmptbl.i
+index a23de733d..dfd1dda83 100644
+--- i/plat/arm/board/fvp/jmptbl.i
++++ w/plat/arm/board/fvp/jmptbl.i
+@@ -12,30 +12,30 @@
+ # lib function [patch]
+ # Example:
+ # rom rom_lib_init
+-# fdt fdt_getprop_namelen patch
++# fdt fdt_getprop_namelen patch patch
+
+ rom rom_lib_init
+-fdt fdt_getprop
+-fdt fdt_get_property
+-fdt fdt_getprop_namelen
+-fdt fdt_setprop_inplace
+-fdt fdt_check_header
+-fdt fdt_node_offset_by_compatible
+-fdt fdt_node_offset_by_prop_value
+-fdt fdt_setprop_inplace_namelen_partial
+-fdt fdt_first_subnode
+-fdt fdt_next_subnode
+-fdt fdt_path_offset
+-fdt fdt_path_offset_namelen
+-fdt fdt_subnode_offset
+-fdt fdt_address_cells
+-fdt fdt_size_cells
+-fdt fdt_parent_offset
+-fdt fdt_stringlist_search
+-fdt fdt_get_alias_namelen
+-fdt fdt_get_name
+-fdt fdt_get_alias
+-fdt fdt_node_offset_by_phandle
+-fdt fdt_add_subnode
++fdt fdt_getprop patch
++fdt fdt_get_property patch
++fdt fdt_getprop_namelen patch
++fdt fdt_setprop_inplace patch
++fdt fdt_check_header patch
++fdt fdt_node_offset_by_compatible patch
++fdt fdt_node_offset_by_prop_value patch
++fdt fdt_setprop_inplace_namelen_partial patch
++fdt fdt_first_subnode patch
++fdt fdt_next_subnode patch
++fdt fdt_path_offset patch
++fdt fdt_path_offset_namelen patch
++fdt fdt_subnode_offset patch
++fdt fdt_address_cells patch
++fdt fdt_size_cells patch
++fdt fdt_parent_offset patch
++fdt fdt_stringlist_search patch
++fdt fdt_get_alias_namelen patch
++fdt fdt_get_name patch
++fdt fdt_get_alias patch
++fdt fdt_node_offset_by_phandle patch
++fdt fdt_add_subnode patch
+ c exit
+ c atexit
diff --git a/run_config/fvp-romlib b/run_config/fvp-romlib
index 6ae4bd4..b58a512 100644
--- a/run_config/fvp-romlib
+++ b/run_config/fvp-romlib
@@ -8,7 +8,3 @@
post_tf_build() {
fvp_romlib_runtime
}
-
-post_tf_archive() {
- fvp_romlib_cleanup
-}
diff --git a/run_config/fvp-spm+romlib b/run_config/fvp-spm+romlib
index 3b56f9a..4fa3f7a 100644
--- a/run_config/fvp-spm+romlib
+++ b/run_config/fvp-spm+romlib
@@ -10,10 +10,6 @@
build_fip BL33="$archive/tftf.bin" BL32="$archive/secure_hafnium.bin"
}
-post_tf_archive() {
- fvp_romlib_cleanup
-}
-
generate_lava_job_template() {
payload_type="tftf" gen_yaml_template
}
diff --git a/run_config/fvp-spm+romlib.bmcov b/run_config/fvp-spm+romlib.bmcov
index ffe1574..6500905 100644
--- a/run_config/fvp-spm+romlib.bmcov
+++ b/run_config/fvp-spm+romlib.bmcov
@@ -10,10 +10,6 @@
build_fip BL33="$archive/tftf.bin" BL32="$archive/secure_hafnium.bin"
}
-post_tf_archive() {
- fvp_romlib_cleanup
-}
-
generate_lava_job_template() {
payload_type="tftf" gen_yaml_template
}