gAppimage is not allocated to the intended section defined in the linker command files

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Medium
    • SITSW-8456
    • 11.01.00
    • 11.02.00
    • Hide
      am62xx-sk
      am62xx-sk-lp
      am62x-sip-sk
      am62a-sk
      am62p-sk
      am62d-evm
      Show
      am62xx-sk am62xx-sk-lp am62x-sip-sk am62a-sk am62p-sk am62d-evm

      The `gAppimage` variable, used in the SBLs as a scratch buffer for authentication and loading of the image, is intended to be allocated to the `.bss.app` section defined in the linker command files.

      However, the following files allocate `gAppimage` to section `.app` which is different from the section `.bss.app`.

      ❯ rg -l "gAppimage.*section.*\".app\""
      examples/hello_world/am62dx-evm/r5fss0-0_freertos/main.c
      test/drivers/boot/sbl_ospi_linux_multistage_ddr_ecc/sbl_ospi_linux_stage1/am62px-sk/wkup-r5fss0-0_nortos/main.c
      test/drivers/boot/sbl_emmc_linux_multistage_falcon_mode/am62px/sbl_emmc_linux_stage2.c
      examples/drivers/boot/sbl_emmc_multistage/sbl_emmc_stage1/am62dx-evm/r5fss0-0_nortos/main.c
      examples/drivers/boot/sbl_emmc_multistage/sbl_emmc_stage2/am62dx-evm/r5fss0-0_freertos/main.c
      examples/drivers/boot/sbl_null/j722s-evm/wkup-r5fss0-0_nortos/main.c
      examples/drivers/boot/common/soc/am62dx/sbl_ospi_stage2.c
      examples/drivers/boot/common/soc/am62dx/sbl_emmc_stage2.c
      examples/drivers/boot/common/soc/am62px/sbl_ospi_linux_stage2.c
      examples/drivers/boot/common/soc/am62px/sbl_emmc_linux_stage2.c
      examples/drivers/safety/reset_isolation/am62dx-evm/r5fss0-0_freertos/main.c
      examples/drivers/boot/sbl_ospi_multistage/sbl_ospi_stage1/am62dx-evm/r5fss0-0_nortos/main.c
      examples/drivers/boot/sbl_ospi_multistage/sbl_ospi_stage2/am62dx-evm/r5fss0-0_freertos/main.c
      examples/drivers/ipc/ipc_notify_echo/am62dx-evm/r5fss0-0_freertos/main.c
      examples/drivers/ipc/ipc_rpmsg_echo/am62dx-evm/r5fss0-0_freertos/main.c 

      The allocation in the default SBLs work just because of the linker internal logic.

      If the following patch is applied that reduces the memory region by 1MB where the `.bss.app` is mapped

      diff --git a/examples/drivers/boot/sbl_emmc_linux_multistage/sbl_emmc_linux_stage2/am62px-sk/wkup-r5fss0-0_freertos/ti-arm-clang/linker.cmd b/examples/drivers/boot/sbl_emmc_linux_multistage/sbl_emmc_linux_stage2/am62px-sk/wkup-r5fss0-0_freertos/ti-arm-clang/linker.cmd
      index 90afe7352..94b501770 100644
      --- a/examples/drivers/boot/sbl_emmc_linux_multistage/sbl_emmc_linux_stage2/am62px-sk/wkup-r5fss0-0_freertos/ti-arm-clang/linker.cmd
      +++ b/examples/drivers/boot/sbl_emmc_linux_multistage/sbl_emmc_linux_stage2/am62px-sk/wkup-r5fss0-0_freertos/ti-arm-clang/linker.cmd
      @@ -162,5 +162,5 @@ MEMORY
           DDR                         : ORIGIN = 0x9CAA0000 LENGTH = 0x1B68000
       
           /* This section is used by the SBL to temporarily load the appimage for authentication */
      -    APPIMAGE  : ORIGIN = 0x84000000 , LENGTH = 0x1900000
      +    APPIMAGE  : ORIGIN = 0x84000000 , LENGTH = 0x1800000
       }
       

      one would expect the linker to throw the error as the `gAppimage` cannot anymore fit in the APPIMAGE. However, it does not throw an error and allocates the `gAppimage` to wherever it could find the required memory as shown

      ❯ rg gAppimage -- ./examples/drivers/boot/sbl_emmc_linux_multistage/sbl_emmc_linux_stage2/am62px-sk/wkup-r5fss0-0_freertos/ti-arm-clang/sbl_emmc_linux_stage2.release.map
      3507:9cafb000  gAppimage
      5111:9cafb000  gAppimage 

      If the following patch is applied which allocated `gAppimage` to `.bss.app`

      diff --git a/examples/drivers/boot/common/soc/am62px/sbl_emmc_linux_stage2.c b/examples/drivers/boot/common/soc/am62px/sbl_emmc_linux_stage2.c
      index 115134010..51cee1ae8 100644
      --- a/examples/drivers/boot/common/soc/am62px/sbl_emmc_linux_stage2.c
      +++ b/examples/drivers/boot/common/soc/am62px/sbl_emmc_linux_stage2.c
      @@ -54,7 +54,7 @@
        *  image authentication
        *  The size of the buffer should be large enough to accomodate the appimage
        */
      -uint8_t gAppimage[0x1900000] __attribute__ ((section (".app"), aligned (4096)));
      +uint8_t gAppimage[0x1900000] __attribute__ ((section (".bss.app"), aligned (4096)));
       uint32_t gImageSize = 0U;
       
       /*  In this sample bootloader, we load appimages for RTOS/Baremetal and Linux at different offset
       

      the linker expectedly throws the error

      Linking: am62px:wkup-r5fss0-0:freertos:ti-arm-clang sbl_emmc_linux_stage2.release.out ...
      "linker.cmd", line 145: error: program will not fit into available memory, or
         the section contains a call site that requires a trampoline that can't be
         generated for this section, or the section contains padded functions. run
         placement with alignment fails for section ".bss.app" size 0x1900000.
         Available memory ranges:
         APPIMAGE     size: 0x1800000    unused: 0x1800000    max hole: 0x1800000
      error: errors encountered during linking; "sbl_emmc_linux_stage2.release.out"
         not built
      tiarmclang: error: tiarmlnk command failed with exit code 1 (use -v to see invocation)
      make: *** [makefile:194: sbl_emmc_linux_stage2.release.out] Error 1 

       

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Connection: Intermediate to External PROD System
                EXTSYNC-6114 - gAppimage is not allocated to the i...
                SYNCHRONIZED
                • Last Sync Date: