cboot compilation errors

Hi.

I tried downloading and compiling the CBoot sources, but the code has errors:

compiling platform/t186/../../../../common/drivers/display/sor/tegrabl_sor.c
In file included from platform/t186/../../../../common/drivers/display/sor/tegrabl_sor.c:20:0:
platform/t186/../../../../common/drivers/display/sor/tegrabl_sor.c: In function ‘sor_config_pwm’:
../../common/include/tegrabl_drf.h:77:27: error: result of ‘31 << 31’ requires 37 bits to represent, but ‘int’ only has 32 bits [-Werror=shift-overflow=]
  ((d##_##r##_0_##f##_##c) << NV_FIELD_SHIFT(d##_##r##_0_##f##_RANGE))
                           ^
platform/t186/../../../../common/drivers/display/sor/tegrabl_sor.c:401:4: note: in expansion of macro ‘NV_DRF_DEF’
    NV_DRF_DEF(SOR_NV_PDISP, SOR_PWM_CTL, SETTING_NEW, SHIFT),
    ^~~~~~~~~~
platform/t186/../../../../common/drivers/display/sor/tegrabl_sor.c: In function ‘sor_power_lanes’:
platform/t186/../../../../common/drivers/display/sor/tegrabl_sor.c:192:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
    val = NV_FLD_SET_DRF_DEF(SOR_NV_PDISP, SOR_DP_PADCTL0, PD_TXD_1, NO,
platform/t186/../../../../common/drivers/display/sor/tegrabl_sor.c:194:3: note: here
   case 1:
   ^~~~
cc1: all warnings being treated as errors

The first error is because of the expression

NV_DRF_DEF(SOR_NV_PDISP, SOR_PWM_CTL, SETTING_NEW, SHIFT)

on line 401. “SHIFT” (31) is not a valid value for the SETTING_NEW field (which is 1 bit in size), I’m pretty sure this is supposed to say “PENDING” (1), or possibly “TRIGGER” (also 1)…

The second one is just a missing “/* fall through */” comment on line 194.

After fixing this file, the next one with errors is:

compiling platform/t186/../../../../common/lib/tegrabl_bootloader_update/tegrabl_bootloader_update.c
platform/t186/../../../../common/lib/tegrabl_bootloader_update/tegrabl_bootloader_update.c: In function ‘tegrabl_check_and_update_bl_payload’:
platform/t186/../../../../common/lib/tegrabl_bootloader_update/tegrabl_bootloader_update.c:460:27: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
  tegrabl_blob_handle bh = NULL;
                           ^~~~
cc1: all warnings being treated as errors

tegrabl_blob_handle is a numeric type (uintptr_t), not a pointer type, so it should be intialized with 0, not NULL.

Hope this helps.

marcus_c,

Have you followed the instructions in “CBoot_Standalone_Readme.txt”?

Yes. They say to use “A recent 64-bit ARM toolchain”; I used gcc 7.3.0. I hope that is recent enough.

marcus_c,

Unfortunately, I think gcc 7.3.0 is not supported yet. To be more precisely, we didn’t build our cboot on it.

Our internal test was still use 4.8.5 toolchain and you can download it from below link.

Used 4.8.5 tool chain from https://developer.nvidia.com/embedded/downloads#?search=tool%20chain

The 4.8 series is not recent. It’s so old, in fact, that it’s not even maintained anymore.

Also, compiling with a toolchain which fails to spot the mistakes does not make them not mistakes. :-)
I can compile the code by fixing the mistakes in my local copy of the code, just giving you guys a QA heads-up here.

(The “fall through” comment bit is not actually mandated by the C standard, but since you are using the comments it would be nice if they were consistent. :-)

marcus_c,

Yes, I understand your concern. This problem has been there for long time and we are still working on updating the toolchain.

Thanks for this info.

Just a “+1” smiley face for the thought of supporting a 7.x series compiler.

I was solved this issue. as the below
$ LANG=/usr/lib/locale/en_US
$ make -C ./sources/cboot/bootloader/partner/t18x/cboot TEGRA_TOP=./sources/cboot PROJECT=t186 TOOLCHAIN_PREFIX=./prebuilts/gcc/bsp/install/bin/aarch64-unknown-linux-gnu- DEBUG=2 BUILDROOT=./out/CBOOT NV_TARGET_BOARD=t186ref NV_BUILD_SYSTEM_TYPE=l4t NOECHO=@ -j4