Compile cboot

While compiling cboot_src_t19x I saw these warning errors:

/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c: In function ‘tegrabl_module_to_bpmp_id’:
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:570:3: error: this statement may fall through [-Werror=implicit-fallthrough=]
570 | switch (clk_or_rst) {
| ^~~~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:576:2: note: here
576 | case TEGRABL_MODULE_SATA_OOB:
| ^~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:578:3: error: this statement may fall through [-Werror=implicit-fallthrough=]
578 | switch (clk_or_rst) {
| ^~~~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:584:2: note: here
584 | case TEGRABL_MODULE_PCIE:
| ^~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:586:3: error: this statement may fall through [-Werror=implicit-fallthrough=]
586 | switch (clk_or_rst) {
| ^~~~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:592:2: note: here
592 | case TEGRABL_MODULE_PCIEXCLK:
| ^~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:594:3: error: this statement may fall through [-Werror=implicit-fallthrough=]
594 | switch (clk_or_rst) {
| ^~~~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:600:2: note: here
600 | case TEGRABL_MODULE_AFI:
| ^~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:602:3: error: this statement may fall through [-Werror=implicit-fallthrough=]
602 | switch (clk_or_rst) {
| ^~~~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:608:2: note: here
608 | case TEGRABL_MODULE_MPHY:
| ^~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:666:3: error: this statement may fall through [-Werror=implicit-fallthrough=]
666 | switch (clk_or_rst) {
| ^~~~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.c:679:2: note: here
679 | case TEGRABL_MODULE_PCIE_APB:
| ^~~~
cc1: all warnings being treated as errors
make[1]: *** [make/compile.mk:45: /data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/out/build-t194/bootloader/partner/t19x/common/drivers/soc/t194/clocks/tegrabl_clk_bpmp.o] Error 1
make[1]: Leaving directory ‘/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t18x/cboot’
make: *** [makefile:13: _top] Error 2
make: Leaving directory ‘/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t18x/cboot’

After tried to put flag “-Wno-implicit-fallthrough”, it could by pass this kind of error but then another error came:

/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/lib/linuxboot/t194/linuxboot_helper.c: In function ‘bom_compare’:
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/lib/linuxboot/t194/linuxboot_helper.c:1069:15: error: taking address of packed member of ‘struct tboot_cpubl_params’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1069 | p_carveout = boot_params->carveout_info;
| ^~~~~~~~~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/lib/linuxboot/t194/linuxboot_helper.c: In function ‘calculate_free_dram_regions’:
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/lib/linuxboot/t194/linuxboot_helper.c:1126:15: error: taking address of packed member of ‘struct tboot_cpubl_params’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1126 | p_carveout = boot_params->carveout_info;
| ^~~~~~~~~~~
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/lib/linuxboot/t194/linuxboot_helper.c: In function ‘calculate_unscrubbed_dram_regions’:
/data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/t19x/common/lib/linuxboot/t194/linuxboot_helper.c:1424:15: error: taking address of packed member of ‘struct tboot_cpubl_params’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1424 | p_carveout = boot_params->carveout_info;
| ^~~~~~~~~~~
cc1: all warnings being treated as errors

I continued putting flag " -Wno-address-of-packed-member", it still could by pass this such kind of compiling error but then I was stuck with this linking error:

aarch64-linux-gnu-ld: /data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/common/lib/fs/ext4/ext4.c:658: undefined reference to __stack_chk_guard' aarch64-linux-gnu-ld: /data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/common/lib/fs/ext4/ext4.c:692: undefined reference to __stack_chk_guard’
aarch64-linux-gnu-ld: /data/nvidia/build/JetPack_4.5.1_Linux_JETSON_XAVIER_NX_DEVKIT/cboot_src_t19x/bootloader/partner/common/lib/fs/ext4/ext4.c:692: undefined reference to `__stack_chk_fail’

Here is my build script, I follow your “CBoot_Standalone_Readme_t194.txt” to make it:

#!/bin/bash

export TEGRA_TOP=$PWD
export TOP=$PWD

export CROSS_COMPILE=aarch64-linux-gnu-

export PATH=$PATH:/data/nvidia/toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin

make -C ./bootloader/partner/t18x/cboot PROJECT=t194 TOOLCHAIN_PREFIX="{CROSS_COMPILE}" DEBUG=2 BUILDROOT="{PWD}"/out NV_TARGET_BOARD=t194ref NV_BUILD_SYSTEM_TYPE=l4t NOECHO=@

Please help!

I found the root cause. My OS is Ubuntu 20.04, after run Nvidia SDK Manager & flash Jetson Xavier NX board, aarch64-linux-gnu (Ubuntu) is installed with in system (/usr/bin, /usr/lib, etc…) so export PATH like I did above will not work. Because OS will always choose the gnu-gcc (Ubuntu) first not the linaro.

/usr/bin/aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

/data/nvidia/toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Linaro GCC 7.3-2018.05) 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Hey did you find a solution for using the linario version instead?

All you needs are download linaro gcc & follow the read me file. My last time error because I had default aarch64-linux-gnu-gcc in PATH.