Why .bss section is placed in Flash?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why .bss section is placed in Flash?

5,119 Views
jtro
Contributor III

I observed that when I'm increase or decrease variable array size, flash size is also change.

I have seen in Flash Memory contents it shows .bss section which occupy considerable amount of Flash why .bss section comes in Flash?? It should be there in RAM section only.

I have even check linker setting in project setting but no option available?

I wonder why .bss section is mapped in SRAM and how to change it?

Labels (1)
Tags (1)
14 Replies

4,679 Views
BlackNight
NXP Employee
NXP Employee

Maybe you could share some details about what you see?

Maybe you see the problem described here: GNU Linker, can you NOT Initialize my Variable? | MCU on Eclipse 

I hope this helps,

Erich

0 Kudos
Reply

4,679 Views
jtro
Contributor III

No this is not like that.. I know basic concept of .data, .bss,..etc. If any data is initialized with any value then it considered as .data not .bss.

In my case

1) suppose array size is 256

uint8_t variable[256];

I got below memory usage in MXUXpresso

In Image Info ->  Memory Usage

Program Flash - 13.47 KB

SRAM - 4.52 KB

In console window after compilation

   text       data        bss        dec        hex    filename
   9311         64       4560      13935       366f    test.axf

2) Changed array size to 1024

uint8_t variable[1024];

I got below memory usage in MXUXpresso

In Image Info ->  Memory Usage

Program Flash - 14.23 KB  (increased by 768)

SRAM - 5.27 KB

In console window after compilation

 text       data        bss        dec        hex    filename
   9315         64       5328      14707       3973    test.axf

After compare above result i thought there may have some error in memory usage calculation in Image Info or something I'm missing not sure..

Result in console window is ok.

Why image Info show wrong memory usage??

0 Kudos
Reply

4,679 Views
1234567890
Contributor IV

Well, if you increase the array from 256 to 1024 the difference is 768. I can't see a fault neither in Image Info nor in console. Image Info has a very small difference because of the unit in kB (not really, but it looks like).

Obviously I don't understand the problem; please describe again more clearly.

0 Kudos
Reply

4,679 Views
BlackNight
NXP Employee
NXP Employee

I tried the same, but I have to say it is correct for me (using a K22 device):

With this

uint8_t var[256];

I get

Region    Start address        End address        Free    Used    Usage (%)
PROGRAM_FLASH    0x0        0x40000        262144    254436    7708    2.94%
SRAM_UPPER    0x20000000    0x20004000    16384    13880    2504    15.28%
SRAM_LOWER    0x1fffc000    0x20000000    16384    16384    0    0.00%
FLEX_RAM    0x14000000    0x14001000    4096    4096    0    0.00%

and with this

uint8_t var[256+1024];

I get

Region        Start address    End address        Free    Used    Usage (%)
PROGRAM_FLASH    0x0        0x40000        262144    254436    7708    2.94%
SRAM_UPPER    0x20000000    0x20004000    16384    12856    3528    21.53%
SRAM_LOWER    0x1fffc000    0x20000000    16384    16384    0    0.00%
FLEX_RAM    0x14000000    0x14001000    4096    4096    0    0.00%

which is what I expect.

Can you share your project here so the engineers could have a look?

0 Kudos
Reply

4,679 Views
jtro
Contributor III

Please check workspace..

Go to UART.h file and change buffer value.

0 Kudos
Reply

4,678 Views
FelipeGarcia
NXP Employee
NXP Employee

Hello,

 

I checked your project and did the following:

 

Build the project and got the following results

Memory region         Used Size  Region Size  %age Used

   PROGRAM_FLASH:        4612 B      24560 B     18.78%

    PRODUCT_INFO:          0 GB         16 B      0.00%

            SRAM:        4288 B        16 KB     26.17%

Finished building target: bss.axf

 

make --no-print-directory post-build

Performing post-build steps

arm-none-eabi-size "bss.axf" ; arm-none-eabi-objcopy -v -O binary "bss.axf" "bss.bin" ; # checksum -p LPC845 -d "bss.bin"

   text           data            bss            dec            hex        filename

   4608              4           4284           8896           22c0        bss.axf

Then, I increased txBuffer as you suggested:

pastedImage_2.png

And I got the results below:

 

Memory region         Used Size  Region Size  %age Used

   PROGRAM_FLASH:        4612 B      24560 B     18.78%

    PRODUCT_INFO:          0 GB         16 B      0.00%

            SRAM:        5312 B        16 KB     32.42%

Finished building target: bss.axf

 

make --no-print-directory post-build

Performing post-build steps

arm-none-eabi-size "bss.axf" ; arm-none-eabi-objcopy -v -O binary "bss.axf" "bss.bin" ; # checksum -p LPC845 -d "bss.bin"

   text           data            bss            dec            hex        filename

   4608              4           5308           9920           26c0        bss.axf

It seems the bss is increased correctly, could you please clarify if you are doing something differently or if I missed something?

 

Best regards,

Felipe

0 Kudos
Reply

4,679 Views
jtro
Contributor III

As i told in earlier post, Console shows correct value but Image Info shows wrong value. Please compare below images with different buffer size.

With 256:

256.jpg 

with 4096:

4096.jpg

Hope above image is enough to describe my issue.

0 Kudos
Reply

4,679 Views
converse
Senior Contributor V

May be worth trying v11.0.1. The release notes include the comment:

  • Fixed various issues with Image Info view
0 Kudos
Reply

4,679 Views
jtro
Contributor III

Tried with latest software v11.0.1. No difference. 

Getting same result.

0 Kudos
Reply

4,679 Views
converse
Senior Contributor V

I just had a quick look, using the 'bss' project that you provided previously.

First comment is that the figures provide in the Memory Usage tab are those that are output by the linker when using --print-memory-usage, so it is the linker that is generating her numbers.

So, using the 

U8 au8RxBuffer[4096];

I see

   PROGRAM_FLASH:        4612 B      24560 B     18.78%

    PRODUCT_INFO:          0 GB         16 B      0.00%

            SRAM:        4288 B        16 KB     26.17%

and when using 

U8 au8RxBuffer[256];

I see

   PROGRAM_FLASH:        4620 B      24560 B     18.81%

    PRODUCT_INFO:          0 GB         16 B      0.00%

            SRAM:         448 B        16 KB      2.73%

So the only significant difference is that SRAM increases by 3840 bytes (the difference being the increase in the buffer size (4096-256).

This is using the application that you posted, with the only change being the size of auRxBuffer. What is it that you are doing that is different?

[EDIT]

Comparing the numbers shown in the Image Info view - I DO see your problem. This looks like a bug in the ImageInfo viewer @NXP - can somebody look into this?

0 Kudos
Reply

4,679 Views
jtro
Contributor III

As I said in earlier post In console tab everything is OK only issue is in Image Info tab.

Image info.jpg

compare Usage (%) in previous post where i have shown you with memory usage with different buffer size.

Region PROGRAM_FLASH should not change if i change buffer value.

0 Kudos
Reply

4,679 Views
jtro
Contributor III

Any update on this??

0 Kudos
Reply

4,679 Views
jtro
Contributor III

No reply from NXP..!!

When problem is resolved?

I'm waiting for solution.

0 Kudos
Reply

4,679 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi,

 

It seems that the image info data is incorrect. I recommend you to see the console instead we will fix this in the next release.

 

Best regards,

Felipe