Page MenuHomePhabricator

ATF v2.5-rc0 fails to build rk3399 support with gcc11
Open, Needs TriagePublic

Description

Seeing the following failure when building the rk3399 bl31 support with gcc11

CC      plat/rockchip/rk3399/drivers/dram/dram.c

plat/rockchip/rk3399/drivers/dram/dram.c:13:22: error: ignoring attribute 'section (".pmusram.data")' because it conflicts with previous 'section (".sram.data")' [-Werror=attributes]

13 | __pmusramdata struct rk3399_sdram_params sdram_config;
   |                      ^~~~~~~~~~~~~~~~~~~

In file included from plat/rockchip/rk3399/drivers/dram/dram.c:7:
plat/rockchip/rk3399/drivers/dram/dram.h:152:46: note: previous declaration here

152 | extern __sramdata struct rk3399_sdram_params sdram_config;
    |                                              ^~~~~~~~~~~~

cc1: all warnings being treated as errors

Event Timeline

nullr0ute created this task.May 4 2021, 9:08 PM
odeprez added a subscriber: odeprez.EditedMay 5 2021, 9:19 AM

Hi,

Can you please provide the link to the gcc11 toolchain you use?
AFAIK latest public Arm release of the cross compiler toolchains is 10.2 (https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads)

And also can you provide the TF-A build command line?
I tried with an internal gcc11 cross-compiler but facing another type of problem.

The rockhip platform port page does not seem up to date as it suggests building bl32 but not bl31:
https://trustedfirmware-a.readthedocs.io/en/latest/plat/rockchip.html

I suggest you bring this request to the TF-A ML with reference to this ticket to get Rk maintainers attention.

Thanks.

I'm using Fedora 34/35 with the distribution toolchain (gcc 11.1 GA)

This is the same build/boot process we've been using to support Rockchip rk3399 devices with ATF/U-Boot on Fedora for ever.

The BL32 you mention there is for aarch32 platforms, the rk3399 is an aarch64 platform which in 29.1 mentions:

Bootrom –> BL1/BL2 –> BL31 –> BL33 –> Linux kernel

The gcc line is:
<pre>
gcc -DDEBUG=0 -DENABLE_BACKTRACE=0 -DGICV3_SUPPORT_GIC600=0 -DGIC_ENABLE_V4_EXTN=0 -DGIC_EXT_INTID=0 -DCOREBOOT=0 -DPLAT_EXTRA_LD_SCRIPT -DRK3399M0FW=\"/builddir/build/BUILD/arm-trusted-firmware-2.5-rc0/build/rk3399/release/m0/rk3399m0.bin\" -DRK3399M0PMUFW=\"/builddir/build/BUILD/arm-trusted-firmware-2.5-rc0/build/rk3399/release/m0/rk3399m0pmu.bin\" -DA57_ENABLE_NONCACHEABLE_LOAD_FWD=0 -DSKIP_A57_L1_FLUSH_PWR_DWN=0 -DA53_DISABLE_NON_TEMPORAL_HINT=1 -DA57_DISABLE_NON_TEMPORAL_HINT=1 -DWORKAROUND_CVE_2017_5715=1 -DWORKAROUND_CVE_2018_3639=1 -DDYNAMIC_WORKAROUND_CVE_2018_3639=0 -DNEOVERSE_Nx_EXTERNAL_LLC=0 -DERRATA_A9_794073=0 -DERRATA_A15_816470=0 -DERRATA_A15_827671=0 -DERRATA_A17_852421=0 -DERRATA_A17_852423=0 -DERRATA_A35_855472=0 -DERRATA_A53_819472=0 -DERRATA_A53_824069=0 -DERRATA_A53_826319=0 -DERRATA_A53_827319=0 -DERRATA_A53_835769=0 -DERRATA_A53_836870=0 -DERRATA_A53_843419=0 -DERRATA_A53_855873=1 -DERRATA_A53_1530924=0 -DERRATA_A55_768277=0 -DERRATA_A55_778703=0 -DERRATA_A55_798797=0 -DERRATA_A55_846532=0 -DERRATA_A55_903758=0 -DERRATA_A55_1221012=0 -DERRATA_A55_1530923=0 -DERRATA_A57_806969=0 -DERRATA_A57_813419=0 -DERRATA_A57_813420=0 -DERRATA_A57_814670=0 -DERRATA_A57_817169=0 -DERRATA_A57_826974=0 -DERRATA_A57_826977=0 -DERRATA_A57_828024=0 -DERRATA_A57_829520=0 -DERRATA_A57_833471=0 -DERRATA_A57_859972=0 -DERRATA_A57_1319537=0 -DERRATA_A72_859971=0 -DERRATA_A72_1319367=0 -DERRATA_A73_852427=0 -DERRATA_A73_855423=0 -DERRATA_A75_764081=0 -DERRATA_A75_790748=0 -DERRATA_A76_1073348=0 -DERRATA_A76_1130799=0 -DERRATA_A76_1220197=0 -DERRATA_A76_1257314=0 -DERRATA_A76_1262606=0 -DERRATA_A76_1262888=0 -DERRATA_A76_1275112=0 -DERRATA_A76_1286807=0 -DERRATA_A76_1791580=0 -DERRATA_A76_1165522=0 -DERRATA_A76_1868343=0 -DERRATA_A76_1946160=0 -DERRATA_A77_1508412=0 -DERRATA_A77_1925769=0 -DERRATA_A77_1946167=0 -DERRATA_A78_1688305=0 -DERRATA_A78_1941498=0 -DERRATA_A78_1951500=0 -DERRATA_N1_1043202=0 -DERRATA_N1_1073348=0 -DERRATA_N1_1130799=0 -DERRATA_N1_1165347=0 -DERRATA_N1_1207823=0 -DERRATA_N1_1220197=0 -DERRATA_N1_1257314=0 -DERRATA_N1_1262606=0 -DERRATA_N1_1262888=0 -DERRATA_N1_1275112=0 -DERRATA_N1_1315703=0 -DERRATA_N1_1542419=0 -DERRATA_N1_1868343=0 -DERRATA_N1_1946160=0 -DERRATA_DSU_798953=0 -DERRATA_DSU_936184=0 -DSTACK_PROTECTOR_ENABLED=0 -DCRASH_REPORTING=0 -DEL3_EXCEPTION_HANDLING=0 -DSDEI_SUPPORT=0 -DALLOW_RO_XLAT_TABLES=0 -DAMU_RESTRICT_COUNTERS=0 -DARM_ARCH_MAJOR=8 -DARM_ARCH_MINOR=0 -DARM_IO_IN_DTB=0 -DBL2_AT_EL3=0 -DBL2_INV_DCACHE=1 -DBL2_IN_XIP_MEM=0 -DCOLD_BOOT_SINGLE_CPU=0 -DCOT_DESC_IN_DTB=0 -DCTX_INCLUDE_AARCH32_REGS=1 -DCTX_INCLUDE_EL2_REGS=0 -DCTX_INCLUDE_FPREGS=0 -DCTX_INCLUDE_MTE_REGS=0 -DCTX_INCLUDE_NEVE_REGS=0 -DCTX_INCLUDE_PAUTH_REGS=0 -DDECRYPTION_SUPPORT_none -DDISABLE_MTPMU=0 -DEL3_EXCEPTION_HANDLING=0 -DENABLE_AMU=0 -DENABLE_ASSERTIONS=0 -DENABLE_BTI=0 -DENABLE_FEAT_RNG=0 -DENABLE_FEAT_SB=0 -DENABLE_MPAM_FOR_LOWER_ELS=0 -DENABLE_PAUTH=0 -DENABLE_PIE=0 -DENABLE_PMF=0 -DENABLE_PSCI_STAT=0 -DENABLE_RUNTIME_INSTRUMENTATION=0 -DENABLE_SPE_FOR_LOWER_ELS=1 -DENABLE_SVE_FOR_NS=0 -DENCRYPT_BL31=0 -DENCRYPT_BL32=0 -DERRATA_SPECULATIVE_AT=0 -DERROR_DEPRECATED=0 -DFAULT_INJECTION_SUPPORT=0 -DGICV2_G0_FOR_EL3=0 -DHANDLE_EA_EL3_FIRST=0 -DHW_ASSISTED_COHERENCY=0 -DLOG_LEVEL=20 -DMEASURED_BOOT=0 -DNS_TIMER_SWITCH=0 -DPL011_GENERIC_UART=0 -DPLAT_rk3399 -DPROGRAMMABLE_RESET_ADDRESS=0 -DPSCI_EXTENDED_STATE_ID=0 -DRAS_EXTENSION=0 -DRAS_TRAP_LOWER_EL_ERR_ACCESS=0 -DRECLAIM_INIT_CODE=0 -DRESET_TO_BL31=0 -DSDEI_IN_FCONF=0 -DSEC_INT_DESC_IN_FCONF=0 -DSEPARATE_CODE_AND_RODATA=0 -DSEPARATE_NOBITS_REGION=0 -DSPD_none -DSPIN_ON_BL1_EXIT=0 -DSPMD_SPM_AT_SEL2=1 -DSPM_MM=0 -DTRNG_SUPPORT=0 -DTRUSTED_BOARD_BOOT=0 -DUSE_COHERENT_MEM=1 -DUSE_DEBUGFS=0 -DUSE_ROMLIB=0 -DUSE_SP804_TIMER=0 -DUSE_SPINLOCK_CAS=0 -DUSE_TBBR_DEFS=1 -DWARMBOOT_ENABLE_DCACHE_EARLY=0 -Iinclude -Iinclude/arch/aarch64 -Iinclude/lib/cpus/aarch64 -Iinclude/lib/el3_runtime/aarch64 -Iplat/rockchip/common/ -Iplat/rockchip/common/include/ -Iplat/rockchip/common/aarch64/ -Iplat/rockchip/common/drivers/pmu/ -Iplat/rockchip/rk3399/ -Iplat/rockchip/rk3399/drivers/pmu/ -Iplat/rockchip/rk3399/drivers/pwm/ -Iplat/rockchip/rk3399/drivers/secure/ -Iplat/rockchip/rk3399/drivers/soc/ -Iplat/rockchip/rk3399/drivers/dram/ -Iplat/rockchip/rk3399/drivers/dp/ -Iplat/rockchip/rk3399/include/ -Iplat/rockchip/rk3399/include/shared/ -Iinclude/lib/libfdt -Iinclude/lib/libc -Iinclude/lib/libc/aarch64 -nostdinc -Werror -Wall -Wmissing-include-dirs -Wunused -Wdisabled-optimization -Wvla -Wshadow -Wno-unused-parameter -Wredundant-decls -Wunused-but-set-variable -Wmaybe-uninitialized -Wpacked-bitfield-compat -Wshift-overflow=2 -Wlogical-op -Wno-error=deprecated-declarations -Wno-error=cpp -march=armv8-a -mgeneral-regs-only -mstrict-align -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -fno-common -Os -std=gnu99 -fno-stack-protector -DIMAGE_AT_EL3 -DIMAGE_BL31 -Wp,-MD,/builddir/build/BUILD/arm-trusted-firmware-2.5-rc0/build/rk3399/release/bl31/dram.d -MT /builddir/build/BUILD/arm-trusted-firmware-2.5-rc0/build/rk3399/release/bl31/dram.o -MP -c plat/rockchip/rk3399/drivers/dram/dram.c -o /builddir/build/BUILD/arm-trusted-firmware-2.5-rc0/build/rk3399/release/bl31/dram.o
plat/rockchip/rk3399/drivers/dram/dram.c:13:22: error: ignoring attribute 'section (".pmusram.data")' because it conflicts with previous 'section (".sram.data")' [-Werror=attributes]

13 | __pmusramdata struct rk3399_sdram_params sdram_config;
   |                      ^~~~~~~~~~~~~~~~~~~

In file included from plat/rockchip/rk3399/drivers/dram/dram.c:7:
plat/rockchip/rk3399/drivers/dram/dram.h:152:46: note: previous declaration here

152 | extern __sramdata struct rk3399_sdram_params sdram_config;
    |                                              ^~~~~~~~~~~~

cc1: all warnings being treated as errors

CC      plat/rockchip/rk3399/drivers/dram/dram.c

plat/rockchip/rk3399/drivers/dram/dram.c:13:22: error: ignoring attribute 'section (".pmusram.data")' because it conflicts with previous 'section (".sram.data")' [-Werror=attributes]

13 | __pmusramdata struct rk3399_sdram_params sdram_config;
   |                      ^~~~~~~~~~~~~~~~~~~

In file included from plat/rockchip/rk3399/drivers/dram/dram.c:7:
plat/rockchip/rk3399/drivers/dram/dram.h:152:46: note: previous declaration here

152 | extern __sramdata struct rk3399_sdram_params sdram_config;
    |                                              ^~~~~~~~~~~~

cc1: all warnings being treated as errors
</pre>

odeprez added a comment.EditedMay 5 2021, 9:31 AM

Hi

Is this building natively on arm64 host?

Section 29.2 has:
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl32

So probably a typo there.
I'm looking for a similar command line targeting bl31, maybe without CROSS_COMPILE in your case.

Thanks.

It's native aarch64, the command line I'm using is:
make HOSTCC="gcc $RPM_OPT_FLAGS" CROSS_COMPILE="" PLAT=rk3399 bl31

Where the Fedora distro aarch64 gcc flags are:
-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection

Ok thanks.

I'm now reproducing by cross compiling on x86.

make M0_CROSS_COMPILE=<path-to-gcc-9.2>/arm-none-eabi- CROSS_COMPILE=<path-to-gcc-11>/bin/aarch64-none-elf- PLAT=rk3399 bl31

CJKay added a subscriber: CJKay.EditedMay 5 2021, 1:14 PM

I can only assume GCC <11 simply didn't have this warning, but it looks legitimate.

When compiling dram.c GCC is seeing the extern declaration first, which tells it to place sram_config in the .sram.data section:

/* plat/rockchip/common/include/plat_private.h:19 */

#define __sramdata __attribute__((section(".sram.data")))
/* plat/rockchip/rk3399/drivers/dram/dram.h:152 */

extern __sramdata struct rk3399_sdram_params sdram_config;

However, it then comes across the definition, which tries to place it in the .pmusram.data section:

/* plat/rockchip/common/include/plat_private.h:23 */

#define __pmusramdata __attribute__((section(".pmusram.data")))
/* plat/rockchip/rk3399/drivers/dram/dram.c:13 */

__pmusramdata struct rk3399_sdram_params sdram_config;

It's warning that it's ignoring all but the first section attribute, because sram_config can only be placed in one section. The section placement should probably be left up to the definition, so I think the (untested) fix would be:

diff --git a/plat/rockchip/rk3399/drivers/dram/dram.h b/plat/rockchip/rk3399/drivers/dram/dram.h
index 0eb12cf29..5572b1612 100644
--- a/plat/rockchip/rk3399/drivers/dram/dram.h
+++ b/plat/rockchip/rk3399/drivers/dram/dram.h
@@ -149,7 +149,7 @@ struct rk3399_sdram_params {
        uint32_t rx_cal_dqs[2][4];
 };
 
-extern __sramdata struct rk3399_sdram_params sdram_config;
+extern struct rk3399_sdram_params sdram_config;
 
 void dram_init(void);

That should ensure sram_config is placed in .pmusram.data. If it should instead be in .sram.data as the extern declaration suggests, then you'd also need:

diff --git a/plat/rockchip/rk3399/drivers/dram/dram.c b/plat/rockchip/rk3399/drivers/dram/dram.c
index 42b62945a..c5757b38f 100644
--- a/plat/rockchip/rk3399/drivers/dram/dram.c
+++ b/plat/rockchip/rk3399/drivers/dram/dram.c
@@ -10,7 +10,7 @@
 #include <secure.h>
 #include <soc.h>
 
-__pmusramdata struct rk3399_sdram_params sdram_config;
+__sramdata struct rk3399_sdram_params sdram_config;
 
 void dram_init(void)
 {
jwerner added a subscriber: jwerner.May 5 2021, 5:52 PM

Yes, the __sramdata in the declaration is a mistake, the correct target section for that global needs to be .pmusram.data. This used to be in .sram.data once upon a time but then the suspend.c stuff got added and required it to be moved to PMUSRAM. I guess they forgot to update that part in the declaration and since the old GCC seemed to silently prefer the attribute in the definition, nobody noticed. Please apply CJKay's first patch to fix the warning.

Thanks, I submitted the following based on CJKay's patch above:
https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/9990