09-16-2019 12:03 AM
Hi,
I want to change the compiler options in petalinux for FSBL. I know how to modify compile options in the SDK IDE, and I also know how to add Patch for FSBL in petalinux. But how to patch the compiler's configuration? For example, I want to remove the compile option "-Os -flto -ffat-lto-objects". I searched everywhere in embeddedsw, then comment them and make a patch, but it doesn't work.
First two patches work.
0001-sw_apps-zynqmp_fsbl-add-SI5338-configuration.patch 0002-sw_apps-zynqmp_fsbl-add-ethernet-reset.patch 0003-sw_apps-zynqmp_fsbl-fix-XFSBL_ERROR_PH_CHECKSUM_FAIL.patch
From 207de132a0a160dc6d24d28a4a31d27c466ef54f Mon Sep 17 00:00:00 2001 From: dongkesi <skd2278@gmail.com> Date: Mon, 16 Sep 2019 10:45:48 +0800 Subject: [PATCH 3/3] sw_apps: zynqmp_fsbl: fix XFSBL_ERROR_PH_CHECKSUM_FAILED issue --- XilinxProcessorIPLib/drivers/cpu_cortexa53/data/cpu_cortexa53.tcl | 2 +- XilinxProcessorIPLib/drivers/cpu_cortexr5/data/cpu_cortexr5.tcl | 2 +- lib/sw_apps/zynqmp_fsbl/data/zynqmp_fsbl.tcl | 6 +++--- lib/sw_apps/zynqmp_fsbl/misc/makefile | 2 +- lib/sw_apps/zynqmp_fsbl/src/Makefile | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/XilinxProcessorIPLib/drivers/cpu_cortexa53/data/cpu_cortexa53.tcl b/XilinxProcessorIPLib/drivers/cpu_cortexa53/data/cpu_cortexa53.tcl index 0b08beb..cb8bc1c 100644 --- a/XilinxProcessorIPLib/drivers/cpu_cortexa53/data/cpu_cortexa53.tcl +++ b/XilinxProcessorIPLib/drivers/cpu_cortexa53/data/cpu_cortexa53.tcl @@ -115,7 +115,7 @@ proc xdefine_cortexa53_params {drvhandle} { set extra_flags [common::get_property CONFIG.extra_compiler_flags [hsi::get_sw_processor]] #Append LTO flag in EXTRA_COMPILER_FLAGS if not exist previoulsy. if {[string first "-flto" $extra_flags] == -1 } { - append extra_flags " -Os -flto -ffat-lto-objects" + #append extra_flags " -Os -flto -ffat-lto-objects" common::set_property -name {EXTRA_COMPILER_FLAGS} -value $extra_flags -objects [hsi::get_sw_processor] } } diff --git a/XilinxProcessorIPLib/drivers/cpu_cortexr5/data/cpu_cortexr5.tcl b/XilinxProcessorIPLib/drivers/cpu_cortexr5/data/cpu_cortexr5.tcl index 6dcb8b7..a7db1c2 100644 --- a/XilinxProcessorIPLib/drivers/cpu_cortexr5/data/cpu_cortexr5.tcl +++ b/XilinxProcessorIPLib/drivers/cpu_cortexr5/data/cpu_cortexr5.tcl @@ -139,7 +139,7 @@ proc xdefine_cortexr5_params {drvhandle} { set extra_flags [common::get_property CONFIG.extra_compiler_flags [hsi::get_sw_processor]] #Append LTO flag in EXTRA_COMPILER_FLAGS if not exist previoulsy. if {[string first "-flto" $extra_flags] == -1 } { - append extra_flags " -Os -flto -ffat-lto-objects" + #append extra_flags " -Os -flto -ffat-lto-objects" common::set_property -name {EXTRA_COMPILER_FLAGS} -value $extra_flags -objects [hsi::get_sw_processor] } } diff --git a/lib/sw_apps/zynqmp_fsbl/data/zynqmp_fsbl.tcl b/lib/sw_apps/zynqmp_fsbl/data/zynqmp_fsbl.tcl index 20b5d58..037ebde 100644 --- a/lib/sw_apps/zynqmp_fsbl/data/zynqmp_fsbl.tcl +++ b/lib/sw_apps/zynqmp_fsbl/data/zynqmp_fsbl.tcl @@ -327,7 +327,7 @@ proc swapp_generate {} { file delete -force $trans_tbl_a53_64 file delete -force $trans_tbl_a53_32 - set new_flags "-Wall -fmessage-length=0 -mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 -DARMR5 -Os -flto -ffat-lto-objects $def_flags" + set new_flags "-Wall -fmessage-length=0 -mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 -DARMR5 $def_flags" } else { set compiler [common::get_property CONFIG.compiler $proc_instance] @@ -339,7 +339,7 @@ proc swapp_generate {} { file delete -force $trans_tbl_a53_64 file rename -force $trans_tbl_a53_32 $trans_tbl_a53 - set new_flags "-Wall -fmessage-length=0 -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -DARMA53_32 -Os -flto -ffat-lto-objects $def_flags" + set new_flags "-Wall -fmessage-length=0 -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -DARMA53_32 $def_flags" } else { #A53 64-bit set ld_file "lscript.ld" @@ -352,7 +352,7 @@ proc swapp_generate {} { file delete -force $trans_tbl_a53_32 file rename -force $trans_tbl_a53_64 $trans_tbl_a53 - set new_flags "-Wall -fmessage-length=0 -DARMA53_64 -Os -flto -ffat-lto-objects $def_flags" + set new_flags "-Wall -fmessage-length=0 -DARMA53_64 $def_flags" } } diff --git a/lib/sw_apps/zynqmp_fsbl/misc/makefile b/lib/sw_apps/zynqmp_fsbl/misc/makefile index e8ad2a7..1085af3 100755 --- a/lib/sw_apps/zynqmp_fsbl/misc/makefile +++ b/lib/sw_apps/zynqmp_fsbl/misc/makefile @@ -9,7 +9,7 @@ endif ifeq "${PROC}" "r5" PROCESSOR = zynqmp_fsbl_bsp/psu_cortexr5_0 endif -LTO_FLAGS = -Wall -Wextra -Os -flto -ffat-lto-objects +LTO_FLAGS = -Wall -Wextra OTHER_FLAGS = -mfpu=vfpv3 -mfloat-abi=hard LIBRARIES = ${PROCESSOR}/lib/libxil.a diff --git a/lib/sw_apps/zynqmp_fsbl/src/Makefile b/lib/sw_apps/zynqmp_fsbl/src/Makefile index 6ca5077..4722d53 100644 --- a/lib/sw_apps/zynqmp_fsbl/src/Makefile +++ b/lib/sw_apps/zynqmp_fsbl/src/Makefile @@ -55,7 +55,7 @@ AS := $(CROSS)armr5-none-eabi-gcc LINKER := $(CROSS)armr5-none-eabi-gcc DUMP := $(CROSS)armr5-none-eabi-objdump -xSD CFLAGS := -Wall -O0 -g3 -fmessage-length=0 -ECFLAGS := -g -DARMR5 -Wall -Wextra -mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 -Os -flto -ffat-lto-objects +ECFLAGS := -g -DARMR5 -Wall -Wextra -mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 LSCRIPT := -Tlscript.ld EXEC := ron_r5_fsbl.elf INCLUDEPATH := -I$(BSP_DIR)/psu_cortexr5_0/include -I. -I../misc/$(BOARD)/$(PROC) -I../misc/$(BOARD) @@ -77,7 +77,7 @@ CC := $(CROSS)aarch64-none-elf-gcc AS := $(CROSS)aarch64-none-elf-gcc LINKER := $(CROSS)aarch64-none-elf-gcc DUMP := $(CROSS)aarch64-none-elf-objdump -xSD -ECFLAGS = -march=armv8-a -DARMA53_$(A53_STATE) -Os -flto -ffat-lto-objects +ECFLAGS = -march=armv8-a -DARMA53_$(A53_STATE) LSCRIPT := -Tlscript_a53.ld LDFLAGS := -Wl,--start-group,-lxil,-lxilffs,-lxilsecure,-lxilpm,-lgcc,-lc,--end-group -L$(LIBPATH) -L./ -Wl,--build-id=none else @@ -85,7 +85,7 @@ CC := $(CROSS)arm-none-eabi-gcc AS := $(CROSS)arm-none-eabi-gcc LINKER := $(CROSS)arm-none-eabi-gcc DUMP := $(CROSS)arm-none-eabi-objdump -xSD -ECFLAGS := -Wextra -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -DARMA53_$(A53_STATE) -Os -flto -ffat-lto-objects +ECFLAGS := -Wextra -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -DARMA53_$(A53_STATE) LSCRIPT := -Tlscript.ld LDFLAGS := -Wl,--start-group,-lxil,-lxilffs,-lxilsecure,-lxilpm,-lgcc,-lc,--end-group -L$(LIBPATH) -L./ -Wl,--build-id=none -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3 -- 2.7.4
Thanks.
09-16-2019 12:33 AM
Hi @dongkesi
Can you try adding this to <plnx-proj-root>/project-spec/meta-user/recipes-bsp/fsbl/fsbl_%.bbappend
YAML_COMPILER_FLAGS_remove =
" -Os -flto -ffat-lto-objects"
09-16-2019 12:56 AM
Hi @shabbirk
Thanks for your reply. It doesn't work. My ultimate goal is to remove this option from .cproject, and then the entire project will have no this option.
components/plnx_workspace/fsbl/fsbl/.cproject
01-23-2021 01:36 PM - edited 01-24-2021 08:05 AM
A little late, but in case anyone is in the same situation I think that, after looking at the embeddedsw bb classes, I've found a way to remove those flags doing this on the bbappend file.
do_compile_prepend() {
echo "Reconfiguring compiler flags"
# Do not know why these two exports, but they are also in the other invocations to xsct of the
# inherited recipes
export RDI_PLATFORM=lnx64
export SWT_GTK3=0
# In the do_compile of xsctapp.bbclass, xsct is executed with eval; but that doesn't work for me.
xsct -eval "setws ${XSCTH_WS}; configapp -app fsbl -set compiler-misc {-c -fmessage-length=0 -MT"$@" -Os}"
}
Here I let the xsctapp bb class to create the fsbl project with the -Os -flto -ffat-lto-objects, then I remove them before compiling. I don't know how to prevent them to be added in the first time, I also thought zynqmp_fsbl.tcl would be the place, but it isn't. I don't know what that file accomplish though, because it definitely seems related to creating the fsbl project in the sdk.
By the way, I want to do that because for some reason the fsbl fails like commented in the first posts here if compiled with link time optimizations (-flto -ffat-lto-objects). @dongkesi maybe you were in the same situation ?
EDIT: SDK has its own copy of embeddedsw, with its zynqmp_fsbl.tcl. I suppose that is the one used to create the fsbl project in the first time, with the lto flags. That would explain why patching the downloaded zynqmp_fsbl.tcl is useless.