This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM263P4-Q1: Issue with image generation in CCS THEIA - bin and .tiimage are huge !

Part Number: AM263P4-Q1
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi

I'm having trouble with CCS THEIA and the image generation.

The project I'm working on should easily fit in a 384kB size.

When building, the memory allocation in CCS show this is all ok:

But, the .out generated is 2MB, the .bin and .appimage are nearly 2GB !

Attached the SysConfig file. 

I tried to change the initialisation model from RAM to ROM but could not see any change.

Attached the .out with the bin and appimage file

2063.Debug.zip

This is blocking the development as I can't debug.

Thanks in advance for your help.

Regards

Seb

  • /**
     * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
     * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
     * @cliArgs --device "AM263Px" --part "AM263P4" --package "ZCZ_C" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM263Px@10.00.00"
     * @v2CliArgs --device "AM263P4" --package "NFBGA (ZCZ-C)" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM263Px@10.00.00"
     * @versions {"tool":"1.21.0+3721"}
     */
    
    /**
     * Import the modules used in this configuration.
     */
    const flash       = scripting.addModule("/board/flash/flash", {}, false);
    const flash1      = flash.addInstance();
    const bootloader  = scripting.addModule("/drivers/bootloader/bootloader", {}, false);
    const bootloader1 = bootloader.addInstance();
    const gpio        = scripting.addModule("/drivers/gpio/gpio", {}, false);
    const gpio1       = gpio.addInstance();
    const hsmclient   = scripting.addModule("/drivers/hsmclient/hsmclient", {}, false);
    const hsmclient1  = hsmclient.addInstance();
    const debug_log   = scripting.addModule("/kernel/dpl/debug_log");
    const dpl_cfg     = scripting.addModule("/kernel/dpl/dpl_cfg");
    const mpu_armv7   = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false);
    const mpu_armv71  = mpu_armv7.addInstance();
    const mpu_armv72  = mpu_armv7.addInstance();
    const mpu_armv73  = mpu_armv7.addInstance();
    const mpu_armv74  = mpu_armv7.addInstance();
    const mpu_armv75  = mpu_armv7.addInstance();
    const mpu_armv76  = mpu_armv7.addInstance();
    const mpu_armv77  = mpu_armv7.addInstance();
    const timer       = scripting.addModule("/kernel/dpl/timer", {}, false);
    const timer1      = timer.addInstance();
    const general     = scripting.addModule("/memory_configurator/general", {}, false);
    const general1    = general.addInstance();
    const region      = scripting.addModule("/memory_configurator/region", {}, false);
    const region1     = region.addInstance();
    const section     = scripting.addModule("/memory_configurator/section", {}, false);
    const section1    = section.addInstance();
    const section2    = section.addInstance();
    const section3    = section.addInstance();
    const section4    = section.addInstance();
    const section5    = section.addInstance();
    const section6    = section.addInstance();
    const section7    = section.addInstance();
    
    /**
     * Write custom configuration values to the imported modules.
     */
    bootloader1.$name          = "CONFIG_BOOTLOADER0";
    bootloader1.appImageOffset = "0x00081000";
    
    bootloader1.flashDriver                   = flash1;
    flash1.$name                              = "CONFIG_FLASH0";
    flash1.strDtr_isAddrReg                   = true;
    flash1.strDtr_cmdRegRd                    = "0x85";
    flash1.strDtr_cmdRegWr                    = "0x81";
    flash1.strDtr_mask                        = "255";
    flash1.xspiWipRdCmd                       = "0x05";
    flash1.strDtr_shift                       = 255;
    flash1.protocol                           = "8d_8d_8d";
    flash1.fourByteEnableSeq                  = "0";
    flash1.cmdRd                              = "0x7c";
    flash1.dummy_mask                         = "0xff";
    flash1.peripheralDriver.$name             = "CONFIG_OSPI0";
    flash1.peripheralDriver.dmaEnable         = true;
    flash1.peripheralDriver.OSPI.CLK.$assign  = "OSPI0_CLK";
    flash1.peripheralDriver.OSPI.CSn0.$assign = "OSPI0_CSn0";
    flash1.peripheralDriver.OSPI.DQS.$assign  = "UART1_TXD";
    flash1.peripheralDriver.OSPI.D7.$assign   = "MCAN1_TX";
    flash1.peripheralDriver.OSPI.D6.$assign   = "MCAN1_RX";
    flash1.peripheralDriver.OSPI.D5.$assign   = "MCAN0_TX";
    flash1.peripheralDriver.OSPI.D4.$assign   = "MCAN0_RX";
    flash1.peripheralDriver.OSPI.D3.$assign   = "OSPI0_D3";
    flash1.peripheralDriver.OSPI.D2.$assign   = "OSPI0_D2";
    flash1.peripheralDriver.OSPI.D1.$assign   = "OSPI0_D1";
    flash1.peripheralDriver.OSPI.D0.$assign   = "OSPI0_D0";
    
    const edma                         = scripting.addModule("/drivers/edma/edma", {}, false);
    const edma1                        = edma.addInstance({}, false);
    edma1.$name                        = "CONFIG_EDMA0";
    flash1.peripheralDriver.edmaDriver = edma1;
    edma1.edmaRmDmaCh[0].$name         = "CONFIG_EDMA_RM0";
    edma1.edmaRmQdmaCh[0].$name        = "CONFIG_EDMA_RM1";
    edma1.edmaRmTcc[0].$name           = "CONFIG_EDMA_RM2";
    edma1.edmaRmParam[0].$name         = "CONFIG_EDMA_RM3";
    
    gpio1.pinDir         = "OUTPUT";
    gpio1.$name          = "GPIO_OSPI_RST";
    gpio1.defaultValue   = "1";
    gpio1.GPIO_n.$assign = "EPWM11_B";
    
    hsmclient1.$name = "CONFIG_HSMCLIENT0";
    
    debug_log.enableUartLog            = true;
    debug_log.uartLog.$name            = "CONFIG_UART0";
    debug_log.uartLog.intrEnable       = "DISABLE";
    debug_log.uartLog.UART.RXD.$assign = "UART0_RXD";
    debug_log.uartLog.UART.TXD.$assign = "UART0_TXD";
    debug_log.uartLog.child.$name      = "drivers_uart_v2_uart_v2_template0";
    
    mpu_armv71.$name             = "CONFIG_MPU_REGION0";
    mpu_armv71.size              = 31;
    mpu_armv71.attributes        = "Device";
    mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD";
    mpu_armv71.allowExecute      = false;
    
    mpu_armv72.$name             = "CONFIG_MPU_REGION1";
    mpu_armv72.size              = 15;
    mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD";
    
    mpu_armv73.$name             = "CONFIG_MPU_REGION2";
    mpu_armv73.baseAddr          = 0x80000;
    mpu_armv73.size              = 15;
    mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD";
    
    mpu_armv74.$name             = "CONFIG_MPU_REGION3";
    mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD";
    mpu_armv74.baseAddr          = 0x70000000;
    mpu_armv74.size              = 21;
    mpu_armv74.attributes        = "Cached+Sharable";
    
    mpu_armv75.$name        = "CONFIG_MPU_REGION4";
    mpu_armv75.allowExecute = false;
    mpu_armv75.attributes   = "Device";
    mpu_armv75.baseAddr     = 0xCE000000;
    mpu_armv75.size         = 24;
    
    mpu_armv76.$name             = "FLASH_RGN";
    mpu_armv76.baseAddr          = 0x80000000;
    mpu_armv76.size              = 27;
    mpu_armv76.attributes        = "Device";
    mpu_armv76.accessPermissions = "Supervisor RD+WR, User RD";
    
    mpu_armv77.$name      = "CONFIG_MPU_REGION5";
    mpu_armv77.baseAddr   = 0x88000000;
    mpu_armv77.attributes = "Device";
    mpu_armv77.size       = 27;
    
    timer1.$name         = "CONFIG_TIMER0";
    timer1.usecPerTick   = 100;
    timer1.startTimer    = true;
    timer1.timerCallback = "TimerTickCallback";
    timer1.RTI.$assign   = "RTI1";
    
    general1.$name          = "CONFIG_GENERAL0";
    general1.irq_stack_size = 4096;
    general1.stack_size     = 8192;
    general1.heap_size      = 8192;
    general1.linker.$name   = "TIARMCLANG0";
    
    region1.$name                               = "MEMORY_REGION_CONFIGURATION";
    region1.memory_region.create(10);
    region1.memory_region[0].type               = "TCMA";
    region1.memory_region[0].$name              = "R5F_VECS";
    region1.memory_region[0].auto               = false;
    region1.memory_region[0].size               = 0x100;
    region1.memory_region[1].type               = "TCMA";
    region1.memory_region[1].$name              = "R5F_TCMA";
    region1.memory_region[1].auto               = false;
    region1.memory_region[1].manualStartAddress = 0x100;
    region1.memory_region[1].size               = 0x7F00;
    region1.memory_region[2].type               = "TCMB";
    region1.memory_region[2].size               = 0x8000;
    region1.memory_region[2].$name              = "R5F_TCMB0";
    region1.memory_region[2].manualStartAddress = 0x41010000;
    region1.memory_region[3].$name              = "MSRAM_VECS";
    region1.memory_region[3].auto               = false;
    region1.memory_region[3].manualStartAddress = 0x70002000;
    region1.memory_region[3].size               = 0x100;
    region1.memory_region[4].$name              = "MSRAM_0";
    region1.memory_region[4].auto               = false;
    region1.memory_region[4].manualStartAddress = 0x70002100;
    region1.memory_region[4].size               = 0x60000;
    region1.memory_region[5].$name              = "MSRAM_HSMRT";
    region1.memory_region[5].manualStartAddress = 0x70032000;
    region1.memory_region[5].size               = 0x40000;
    region1.memory_region[6].type               = "CUSTOM";
    region1.memory_region[6].$name              = "MAILBOX_HSM";
    region1.memory_region[6].auto               = false;
    region1.memory_region[6].manualStartAddress = 0x44000000;
    region1.memory_region[6].size               = 0x3CE;
    region1.memory_region[7].type               = "CUSTOM";
    region1.memory_region[7].size               = 0x3CE;
    region1.memory_region[7].$name              = "MAILBOX_R5F";
    region1.memory_region[7].auto               = false;
    region1.memory_region[7].manualStartAddress = 0x44000400;
    region1.memory_region[8].type               = "FLASH";
    region1.memory_region[8].auto               = false;
    region1.memory_region[8].manualStartAddress = 0x60080000;
    region1.memory_region[8].size               = 0x1000;
    region1.memory_region[8].$name              = "FLASH_BOOTINFO_SECTOR";
    region1.memory_region[9].last_sym           = "__TI_SBL_FLASH_BOOTINFO_SECTOR_START";
    region1.memory_region[9].auto               = false;
    region1.memory_region[9].type               = "CUSTOM";
    region1.memory_region[9].$name              = "BOOT_SECTOR_INFO";
    region1.memory_region[9].manualStartAddress = 0x80080000;
    region1.memory_region[9].size               = 0x1000;
    
    section1.load_memory                              = "MSRAM_VECS";
    section1.group                                    = false;
    section1.$name                                    = "Sbl Initialization Code";
    section1.output_section.create(1);
    section1.output_section[0].$name                  = ".sbl_init_code";
    section1.output_section[0].input_section.create(1);
    section1.output_section[0].input_section[0].$name = "*(.vectors). = align(8);";
    
    section2.load_memory                  = "MSRAM_0";
    section2.$name                        = "Text Segments";
    section2.output_section.create(7);
    section2.output_section[0].$name      = ".text";
    section2.output_section[0].palignment = true;
    section2.output_section[1].$name      = ".text.hwi";
    section2.output_section[1].palignment = true;
    section2.output_section[2].$name      = ".text.cache";
    section2.output_section[2].palignment = true;
    section2.output_section[3].$name      = ".text.mpu";
    section2.output_section[3].palignment = true;
    section2.output_section[4].$name      = ".text.boot";
    section2.output_section[4].palignment = true;
    section2.output_section[5].$name      = ".data";
    section2.output_section[5].palignment = true;
    section2.output_section[6].$name      = ".rodata";
    section2.output_section[6].palignment = true;
    
    section3.load_memory                             = "MSRAM_0";
    section3.group                                   = false;
    section3.$name                                   = "Memory Segments";
    section3.output_section.create(3);
    section3.output_section[0].$name                 = ".bss";
    section3.output_section[0].output_sections_start = "__BSS_START";
    section3.output_section[0].output_sections_end   = "__BSS_END";
    section3.output_section[0].palignment            = true;
    section3.output_section[1].$name                 = ".sysmem";
    section3.output_section[1].palignment            = true;
    section3.output_section[2].$name                 = ".stack";
    section3.output_section[2].palignment            = true;
    
    section4.load_memory                              = "MSRAM_0";
    section4.$name                                    = "Stack Segments";
    section4.output_section.create(5);
    section4.output_section[0].$name                  = ".irqstack";
    section4.output_section[0].output_sections_start  = "__IRQ_STACK_START";
    section4.output_section[0].output_sections_end    = "__IRQ_STACK_END";
    section4.output_section[0].input_section.create(1);
    section4.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;";
    section4.output_section[1].$name                  = ".fiqstack";
    section4.output_section[1].output_sections_start  = "__FIQ_STACK_START";
    section4.output_section[1].output_sections_end    = "__FIQ_STACK_END";
    section4.output_section[1].input_section.create(1);
    section4.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;";
    section4.output_section[2].$name                  = ".svcstack";
    section4.output_section[2].output_sections_start  = "__SVC_STACK_START";
    section4.output_section[2].output_sections_end    = "__SVC_STACK_END";
    section4.output_section[2].input_section.create(1);
    section4.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;";
    section4.output_section[3].$name                  = ".abortstack";
    section4.output_section[3].output_sections_start  = "__ABORT_STACK_START";
    section4.output_section[3].output_sections_end    = "__ABORT_STACK_END";
    section4.output_section[3].input_section.create(1);
    section4.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;";
    section4.output_section[4].$name                  = ".undefinedstack";
    section4.output_section[4].output_sections_start  = "__UNDEFINED_STACK_START";
    section4.output_section[4].output_sections_end    = "__UNDEFINED_STACK_END";
    section4.output_section[4].input_section.create(1);
    section4.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;";
    
    section5.load_memory             = "MSRAM_HSMRT";
    section5.group                   = false;
    section5.$name                   = "Hsmrt";
    section5.output_section.create(1);
    section5.output_section[0].$name = ".rodata.hsmrt";
    
    section6.load_memory                 = "MAILBOX_HSM";
    section6.type                        = "NOLOAD";
    section6.group                       = false;
    section6.$name                       = "SIPC HSM Queue Memory";
    section6.output_section.create(1);
    section6.output_section[0].$name     = ".bss.sipc_hsm_queue_mem";
    section6.output_section[0].alignment = 0;
    
    section7.load_memory                 = "MAILBOX_R5F";
    section7.type                        = "NOLOAD";
    section7.group                       = false;
    section7.$name                       = "SIPC R5F Queue Memory";
    section7.output_section.create(1);
    section7.output_section[0].$name     = ".bss.sipc_secure_host_queue_mem";
    section7.output_section[0].alignment = 0;
    
    /**
     * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
     * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
     * re-solve from scratch.
     */
    flash1.peripheralDriver.OSPI.$suggestSolution = "OSPI0";
    debug_log.uartLog.UART.$suggestSolution       = "UART0";
    

    Attaching the sysConfig file under a . text format.

  • Hello Seb,

    But, the .out generated is 2MB, the .bin and .appimage are nearly 2GB !

    Please note that the .out is not just the code that gets loaded to your target. It includes all the debug symbol information that only gets loaded to the debugger. Only a fraction of that 2MB would get loaded to the target.

    I notified the compiler experts of this thread for further information if needed.

    I can't comment on the .bin and .appimage since I am not familair with how those were generated.

    Thanks

    ki

  • Hi

    I know that the .out is inflated with debug info ... As it is a bootloader project even if all the code works in RAM, I cana't seem to be able to launch a debug session normally with CCS. I tried with the bootloader example projects as well and I get the same behaviour.

    The only way to debug seems to be via flashing the SW which is a bit of a FAF each time putting the board in serial boot mode, launching the flashing script and back to OSPI mode and load a debug session with no GEL file....

    But the problem is the size of the .tiimage file. I can't flash the board with this.

    Therefore I'm blocked for debugging.

    Looking forward to reading from you about a resolution for this.

    Thanks

    Regards

    Seb

  • I can shed some light to increase your understanding.  But I am unable to tell you the best way to fix the problem.

    Please read the article An Introduction to Binary Files.  Focus on the part titled Holes in a Binary File. Based on that, the next step is to see whether there is a large gap in memory between the initialized sections.

    Earlier in the thread, you posted a zip with some files.  One of those files is the .out file.  Use the utility tiarmreadelf to inspect the sections in the file.  It is located in the same \bin directory as the compiler tiarmclang.  Use this command ...

    % tiarmreadelf --sections UDS_sbl_ospi_multicore_elf_am263px-lp_r5fss0-0_nortos_ti-arm-clang.out
    There are 40 section headers, starting at offset 0x1f67b4:
    
    Section Headers:
      [Nr] Name              Type            Address  Off    Size   ES Flg Lk Inf Al
      [ 0]                   NULL            00000000 000000 000000 00      0   0  0
      [ 1] .sbl_init_code    PROGBITS        70002000 0005b8 000040 00  AX  0   0  8
      [ 2] .text             PROGBITS        70002100 000600 04ed40 00  AX  0   0 32
     
    <...>

    Filter the output to view only the initialized sections.  Such sections are type PROGBITS, and the Flg column contains AX or A.  Use this command ...

    % tiarmreadelf --sections UDS_sbl_ospi_multicore_elf_am263px-lp_r5fss0-0_nortos_ti-arm-clang.out | findstr PROGBITS | findstr /c:" A"
      [ 1] .sbl_init_code    PROGBITS        70002000 0005b8 000040 00  AX  0   0  8
      [ 2] .text             PROGBITS        70002100 000600 04ed40 00  AX  0   0 32
      [ 3] .text.hwi         PROGBITS        70050e40 04f340 000dd0 00  AX  0   0 16
      [ 4] .text.cache       PROGBITS        70051c10 050110 0004a0 00  AX  0   0 16
      [ 5] .text.mpu         PROGBITS        700520b0 0505b0 0002d0 00  AX  0   0 16
      [ 6] .text.boot        PROGBITS        70052380 050880 0001c0 00  AX  0   0 16
      [ 8] .rodata           PROGBITS        70053890 050a40 003c90 00   A  0   0  8
      [17] .rodata.hsmrt     PROGBITS        70062100 0546d0 0066c3 00   A  0   0  8
      [26] .boot_info        PROGBITS        00000000 000034 000004 00   A  0   0  1
      [27] .cinit            PROGBITS        00000100 000038 00057c 00   A  0   0  4

    Note findstr is a Windows command.  Use findstr /? to understand how it works. If you are on a Linux system, use some variant of grep instead.

    Remember the first column after PROGBITS is the base address of the section.  Notice how .boot_info and .cinit are very far away from the rest.  That gap is why the binary file is so large.

    Unfortunately, I don't know enough about your build to tell you the best way to change it so those two sections are close to the rest.

    Thanks and regards,

    -George

  • As George mentioned, the key to reducing the bin size is to (re)move .cinit and boot_info sections.

    I believe .cinit is there because you have changed it to ROM init model. If you change it back to RAM init model as per the original SBL examples then .cinit should disappear.

    The remaining section .boot_info is perhaps something you have added specific to your application. Can you locate this next to rodata perhaps? In any case, load address for boot_info (0x0) doesn't sound correct since this is where the vector table should be.

  • Hi George and Kier

    Thanks a lot for your answer. This is really useful information.

    I'll have a look into this and see how I can fix my problem but definitely good pointers.

    I'll come back to mark the issue resolved if experiments are conclusive.

    Thanks for your help.

    Regards

    Seb

  • Hi

    To follow up on the post from this morning, following your advices, the image is much reduced. Thanks a lot for your tips.

    I can flash the board OK.

    However, I'm struggling to have a reliable debug start. For the bootloader project, start debugging starts more reliably after flashing the SW in flash and debug starting using a config with no initialisation gel, connect to target and load symbols.

    It is very cumbersome though. Is there better / quicker of starting a debug session reliably  ?

    Also, even with this method it sometimes takes a number of board reset (using the button on the board) to have a proper start and avoid the SW crashing during the execution of Bootloader_socLoadHsmRtFw function.

    I'm keen to understand how to reliably start debugging after a build as it will speed up the process quite a lot.

    I'm also keen to understand the image structure when some part of the code executes in XIP and the other does not.

    It is looking we need to flash 2 files at the moment but normal classic flashing procedure expect just a single hex file. I'm keen to understand how to get to this point.

    Looking forward reading from you.

    Regards

    Seb

  • I think it is better a raise a separate ticket for each of the issues above.

    It is very cumbersome though. Is there better / quicker of starting a debug session reliably  ?

    The best way for debugging is through Dev Boot mode and init GEL scripts but you say this is unreliable. Perhaps in a separate ticket expand on why it's unreliable for you.