Reputation: 173
Uninitialized variables are included in the BSS section.
First question : Will they stay there when they are assigned?
Second question/problem : I want to load this section in an external SDRAM. Variables are properly located in the memory map, but filled with strange values, and I can't store any other number into. Do you have an idea about this problem?
/* Memory Map */
MEMORY{
VECTORS (X) : origin=0x00000000 length=0x00000020
FLASH0 (RX) : origin=0x00000020 length=0x0017FFE0
FLASH1 (RX) : origin=0x00180000 length=0x00180000
STACKS (RW) : origin=0x08000000 length=0x00001500
RAM (RW) : origin=0x08001500 length=0x0003EB00
SDRAM (RW) : origin=0x80000000 length=0x00800000
}
/*----------------------------------------------------------------------------*/
/* Section Configuration */
SECTIONS{
.intvecs : {} > VECTORS
.text : {} > FLASH0 | FLASH1
.const : {} > FLASH0 | FLASH1
.cinit : {} > FLASH0 | FLASH1
.pinit : {} > FLASH0 | FLASH1
.bss : {} > SDRAM
.data : {} > RAM
.sysmem : {} > RAM
}
Upvotes: 1
Views: 2448
Reputation: 93556
Re Q2, you do have to make sure that your SDRAM memory controller is correctly initialised with the correct timings and mapping for your memory device before the .bss segment is zero initialised by the runtime start-up code. You also have to ensure that your runtime start-up code is explicitly initialising the .bss segment when located in SDRAM.
Upvotes: 2
Reputation: 81
Q2: Details of how this must be done depend on the system you're using (are you using Linux?)
To get the .bss section where you want it, you would have to modify the linker script. e.g. for the Linux kernel that would be vmlinux.lds.
Also in Linux, the .bss section is cleared to all-zero by the bootloader, e.g. Uboot, based on the information in the elf-file. Your .bss seems to be not cleared to zero. A good place to start debugging is the bootloader. Your SDRAM may not be properly mapped in memory at the time the bootloader is clearing it (can you do succesful write-read tests while you system is running?). Or the memory protection of your CPU may prevent access.
Upvotes: 0
Reputation: 5990
Q1: Yes, variables will be in .bss
section.
Q2: Can you try to move .sysmem
into SDRAM and check if you can read and write the values? I suspect that you don't have the requisite accesses.
Upvotes: 0
Reputation: 68074
Q1 : Yes, that's where they are. Why would they move (and why would you want them to?)
http://en.wikipedia.org/wiki/.bss
Q2: I don't understand the question fully, but are you sure your SDRAM is actualy working? Does your platform have a monitor to allow you to read and write memory?
Upvotes: 1