Variables are not initialized (RAM with address 0x10000000)

Sysprogs forums Forums VisualGDB Variables are not initialized (RAM with address 0x10000000)

This topic contains 15 replies, has 2 voices, and was last updated by  support 1 month, 2 weeks ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #27034

    Maria
    Participant

    Hi,

    I have an issue that is described here https://visualgdb.com/tutorials/arm/linkerscripts/

    The variables that has addresses from 0x10000000 are not initialized properly. It is RAM, so they should.

    I’m using ARMCC Keil toolchain and I have a scatter file for Keil, so the solution with NOLOAD is not relevant for me.

     

    Also I tried to add this part of RAM to Additional memories, but when I press OK, I catch VS Exception “Value cannot be null. Parameter name: path2”

    I’m not sure how should I fix it with all this conditions.

    I will be happy for any help.

    Maria

    #27060

    support
    Keymaster

    Hi,

    Sorry, the Additional Memories window only works for GCC-based projects, however we can help you configure your Keil-based project to achieve similar results.

    Please make sure that the CCM memory in your scatter file (e.g. RW_IRAM2 shown below) is inside the main load region (LR_IROM in the example below). It will ensure that its contents get programmed into the FLASH memory and the Keil startup code copies them into the actual CCMRAM before calling main().

    Below is an example of a Keil scatter file defining both RAM and CCMRAM memories:

    You can place a specific variable into the CCM memory by declaring it with the section attribute:

    If this still doesn’t work, please let us know and we will help.

    #27062

    Maria
    Participant

    Hi!

    Thank you for your response!

    Here is my scatter file. I woks fine when I run the project from Keil. All my RAM sections is inside LR_IROM1 block.

    I’m using attribute section only for SPI DMA buffers. In all other cases I rely on the linker and I have no preferences where to put other variables.

    Should I make any changes in my scatter to make it work in VS?

    LR_IROM1 0x08000000 0x00200000 { ; load region size_region
    ER_IROM1 0x08000000 0x00200000 { ; load address = execution address
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)
    .ANY (+XO)
    }
    DMA_BUFFER 0x20000000 0x500 {
    *(.dma_buffer)
    }
    RW_IRAM1 0x20000500 0x00030000 { ; RW data
    .ANY (+RW +ZI)
    }
    RW_IRAM2 0x10000000 0x00010000 {
    .ANY (+RW +ZI)
    }
    }

    • This reply was modified 2 months, 2 weeks ago by  Maria.
    #27076

    support
    Keymaster

    Sorry, we tried reproducing the problem with your scatter file (we reduced IRAM1 size to 0x4000 and IRAM2 size to 0x8000), but it did work as expected with the following variable:

    It did get placed into IRAM2 and got initialized correctly. Most likely, some other project setting is interfering with this on your side.

    If it still doesn’t work for you, please try reproducing the problem on a clean project and share the exact repro steps that we could follow on our side (see our problem reporting guidelines). If we could reproduce the problem in our environment, we should be able to suggest a workaround, or release a hotfix resolving it.

    #27145

    Maria
    Participant

    I created a new project as you described, and yes, it works.

    But I still didnt succeed to make my big project work. I checked all settings and I don’t see any difference that could lead to this problem. Furthermore, after all my attempts my project starts to fall into hard fault immediately after the start (Received a SIGTRAP: Trace/breakpoint trap).

    I attached my scatter and my map file (I only change it to txt).

    Also here is command like for compilation:

    -I”..\master\console\console\Middlewares\Third_Party\FatFs\src\drivers” -I”..\master\console\console\Middlewares\ST\STM32_USB_Device_Library\Core\Inc” -I”..\master\console\console\Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc” -I”..\master\console\console\Middlewares\ST\STM32_USB_Host_Library\Core\Inc” -I”..\master\console\console\Middlewares\ST\STM32_USB_Host_Library\Class\MSC\Inc” -I”..\master\console\console\Middlewares\Third_Party\FatFs\src” -I”..\master\console\console\Console\Drivers” -I”..\master\console\console\Console\Drivers\wifi\winc1500\host_drv” -I”..\master\console\console\Console\Drivers\wifi\winc1500\host_drv\driver\source” -I”..\master\console\console\Console\Source” -I”..\master\console\console\Console\Source\GUI” -I”..\master\console\console\Console\Source\GUI\Screens” -I”..\master\console\console\Console\Source\GUI\Fonts” -I”..\master\console\console\lwip\src\include” -I”..\master\console\console\lwip\src\include\ipv4″ -I”..\master\console\console\lwip\system” -I”..\..\Packs\CMSIS-FreeRTOS\10.2.0\CMSIS\RTOS2\FreeRTOS\Include” -I”..\..\Packs\CMSIS-FreeRTOS\10.2.0\CMSIS\RTOS2\FreeRTOS\Include1″ -I”..\..\Packs\CMSIS-FreeRTOS\10.2.0\Source\include” -I”.\RTE\RTOS” -I”..\..\Packs\CMSIS-FreeRTOS\10.2.0\Source\portable\RVDS\ARM_CM4F” -I”..\..\Packs\CMSIS\5.6.0\CMSIS\RTOS2\Include” -I”..\..\Packs\CMSIS\5.6.0\CMSIS\Core\Include” -I”..\master\console\console\Inc” -I”..\..\Packs\CMSIS\5.6.0\CMSIS\Core_A\Include” -I”D:\playground\VS_import_playground\master\console\Packs\CMSIS\5.6.0\CMSIS\Core\Include” -I”RTE” -I”../master/console/Packs/CMSIS/5.6.0/CMSIS/RTOS2/Include” -I”D:\playground\VS_import_playground\master\console\Packs\CMSIS-FreeRTOS\10.2.0\CMSIS\RTOS2\FreeRTOS\Include1″ -I”../master/console/console/MDK-ARM/RTE/RTOS” -I”../master/console/Packs/CMSIS-FreeRTOS/10.2.0/CMSIS/RTOS2/FreeRTOS/Include” -I”../master/console/Packs/CMSIS-FreeRTOS/10.2.0/Source/include” -I”..\master\console\console\Drivers\STM32F4xx_HAL_Driver\Inc” -I”..\master\console\console\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy” -I”D:\playground\VS_import_playground\master\console\Packs\CMSIS-FreeRTOS\10.2.0\Source” -I”..\master\console\Packs\CMSIS-FreeRTOS\10.2.0\Source\portable\RVDS\ARM_CM4F” –apcs=interwork -O0 -g -D”USE_HAL_DRIVER” -D”STM32F429xx” -D”DEBUG=1″ –gnu –c99 –split-sections “VisualGDB\Debug\”

    And command line for the linker:

    -o “D:\playground\VS_import_playground\Attempt3\VisualGDB\Debug\Attempt3” –info unused –info sizes –scatter “Clear_for_Keil.sct” –xref –info summarysizes –map –info totals “RMS_Console_map” –symbols –strict –callgraph –emit_relocs –info veneers

    I really need your help. Thank you.

    • This reply was modified 2 months, 2 weeks ago by  Maria.
    Attachments:
    You must be logged in to view attached files.
    #27155

    support
    Keymaster

    Hi,

    Sorry, in order to troubleshoot a specific project that doesn’t come from us, we would need to charge a consulting fee, as it takes non-trivial time to go through all the settings and source code and find the exact cause of the problem. If you would like to go ahead, please contact our sales to get a quote.

    An alternative would be to create a new project from scratch and then move your existing code to it step-by-step, verifying that the additional memory loading works after each step (consider creating a local git repository and checking in the changes after each step to track them better). This would require some time, but should help you find the root cause of the problem on your side.

    #27317

    Maria
    Participant

    Hi

    I still didn’t succeed to make the project work.

    These are my steps:

    1. I generated from stm32Cube project for my board stm32f429IITx (the project was generated for Keil) – without any special settings. I just chose stm32f429IITx from the list of MCUs.
    2. I imported this newly generated project to VS with VisualGDB
    3. It works fine (without scatter and without any other manipulations)
    4. I add my scatter
    5. Project run fails to hardfault
    6. I defined entry point to main
    7. Project runs, but all variables are not initialized (not only from RW_IRAM2  area but all of them)
    8. I wanted to examine map file, but it doesn’t exist even that option is set and in the Build window I see these notes:

    Linking VisualGDB/Debug/Attempt8…
    Program Size: Code=3226 RO-data=486 RW-data=24592 ZI-data=1632
    Map file saved to file://D:\playground\VS_import_playground\Attempt8\proj.map

    So there is nothing special in the particular project. There is a problem how VisualGBD works with the scatter. Could you please try to follow my steps and check if it works or not.

    #27318

    support
    Keymaster

    No problem, we will try to help you. The steps you provided should normally work, hence the issue is likely caused by some combination of settings that were not explicitly mentioned. Hence, following the generic steps on our side will very likely not reproduce the problem.

    We can still help you resolve this, however we would need you to do the following additional steps on your side:

    1. Locate the project generated by STM32CubeMX that you imported into VisualGDB. Open it using the Keil IDE.
    2. Add the same scatter file to it. Make sure it is exactly the same as the scatter file you used with the VisualGDB project.
    3. Build the project with the Keil IDE and make sure it works as expected.
    4. Try comparing the memory layouts and symbols of the 2 projects using VisualGDB’s Memory Explorer (you can choose the .axf file produced by Keil as a reference).
    5. If the comparison doesn’t point to a specific cause, please create a .7z archive of the VisualGDB project (including all relevant sources and the output file) and the equivalent Keil project (including all the relevant sources and the .axf file) and attach it here. If the archive is too large, please try using a file hosting service, such as Google Drive.

    If we could build both projects on our side and confirm that they behave differently despite using the same sources, we should be able to update VisualGDB to replicate the output of the Keil IDE.

    #27319

    Maria
    Participant

    Hi,

    here are my two projects.

    https://drive.google.com/open?id=1zU5aPyfcMHL-xBK1Fz7J7pPQbcfmwWQN

     

    I really hope that the problem will be reproduced on your side and we will find the solution.

    #27324

    support
    Keymaster

    Hi,

    Thanks for providing the repro files. It looks like the imported project is missing a reference to the startup file (startup_stm32f429xx.s), hence it indeed won’t work.

    Most likely, this happened because you did not select to use the Keil compiler when importing the project (see below). Please double-check both first and the second pages of the wizard have the Keil compiler selected (sorry, those settings are currently separate due to backward compatibility):

    Another difference between the projects is that the Keil project is built with full optimization, while VisualGDB project has the Debug configuration selected. It should normally not cause any problems, but some project-specific bugs can only be triggered in one of configurations, but not the other one. Hence if adding the startup file doesn’t solve the problem, please try checking whether the Release configuration of the VisualGDB project works as expected.

    Attachments:
    You must be logged in to view attached files.
    #27329

    Maria
    Participant

    Hi,

    I did all steps of import again and checked that Keil compiler is selected.

    Now I have startup file in the build. I changed configuration to Release.

    But the result is the same. When I add scatter, there is a hardfault. Then I add entry point (main), and the program runs, but variables has junk inside.

    I packed new imported project to 7z.

    https://drive.google.com/file/d/1nYkUik1OgJfQLrksJanHTo1wyBuvOZQW/view?usp=sharing

    #27346

    support
    Keymaster

    No problem, we have compared the 2 projects and found the following differences:

    1. The VisualGDB project did not specify the scatter file and was using the default one.
    2. The VisualGDB project used the regular C library, while the Keil project used microlib.

    After updating both settings and building the release configuration, the output produced by both projects appears identical (when using the release configuration).

    Please try re-importing the project using the following VisualGDB build: VisualGDB-5.5.3.3493.msi .

    It will automatically import the scatter file setting from the Keil project and will also hide the GCC toolchains when selecting the Keil toolchain on the first wizard page and vice versa.

    The microlib setting needs to be configured manually as shown in the attached file (please use the Keil Settings page, as the setting affects both compiler and linker).

    If the file produced by VisualGDB still doesn’t work, please confirm that you are using the Release configuration (the project you attached had the Debug configuration built) and try replacing the VisualGDB’s ELF file (VisualGDB\Release\<Project Name>) with the axf file produced by Keil (ensure you disable automatic project rebuilding via Tools->Options->Projects and Solutions->Build and Run). This should help understand whether the problem is still triggered by some differences between the ELF files, or by debugger settings.

    Attachments:
    You must be logged in to view attached files.
    #27391

    Maria
    Participant

    Hi!

    I’m continue working on the import.

    I did what you said and it started to work, but only when g_Test1[0x6000] is placed in  RW_IRAM2

    If I place it to RW_IRAM1, it is not initialized.

    This is scatter:

    LR_IROM1 0x08000000 0x00200000 { ; load region size_region
    ER_IROM1 0x08000000 0x00200000 { ; load address = execution address
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)
    .ANY (+XO)
    }

    DMA_BUFFER 0x20000000 0x400 {
    *(.dma_buffer)
    }
    RW_IRAM1 0x20000400 0x0002FC00 {
    .ANY (RAM2)
    }
    RW_IRAM2 0x10000000 0x00010000 {
    .ANY (+RW +ZI)
    }
    }

     

    And this is the definition of the variable

    char __attribute__((section(“RAM2”))) g_Test1[0x6000] = {
    1,
    2,
    3
    };
    RW_IRAM2 0x10000000 0x00010000 {
    .ANY (+RW +ZI)
    }
    }

     

    • This reply was modified 1 month, 2 weeks ago by  Maria.
    #27393

    support
    Keymaster

    Hi,

    If you believe the VisualGDB-based project is still working differently from the project built directly with Keil, please attach the updated projects (including the relevant AXF/ELF files) and we will help you compare them.

    #27394

    Maria
    Participant
Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.