Author Topic: STM32/lwip/eth questions - can't compile  (Read 2969 times)

0 Members and 1 Guest are viewing this topic.

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
STM32/lwip/eth questions - can't compile
« on: September 12, 2017, 12:15:19 am »
I'm working on an STM32 project for someone else.  Trying to get LWIP/ethernet working.  They are using freertos.  They even said that they got it working at some point to test the hardware.  I found where some functions were remarked out in the code and tried to enable only the MX_LWIP_Init() function (I found it in the StartDefaultTask function).  When I do this I get an error saying that:

section '.bss' will not fit in region 'RAM'
region 'RAM' overflowed by 13960 bytes

With the MX_LWIP_init remarked out, it compiles at:

   text      data       bss       dec       hex   filename
 204832      2696    193244    400772     61d8

It is an STM32F429II.

Any thoughts on what I am doing wrong?

Is 193244 pretty big for the bss?  Is that for variables?  what is data for?  I thought that would be sram.

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: STM32/lwip/eth questions - can't compile
« Reply #1 on: September 12, 2017, 12:40:14 am »
Quote
Is 193244 pretty big for the bss?  Is that for variables?  what is data for?  I thought that would be sram.
Yes, that's pretty huge for an embedded chip (especially since that's without some of the LWIP stuff.)
bss is uninitialized data - your STM32F429 should have 256k total.
It sounds like you might have some huge user array or something; try using "nm" on it to see what's using the space:

arm-none-eabi-nm -C *.elf | grep ' [bB] '
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: STM32/lwip/eth questions - can't compile
« Reply #2 on: September 12, 2017, 12:54:57 am »
Thanks westfw, I found 150K being used by some GUI code.
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: STM32/lwip/eth questions - can't compile
« Reply #3 on: September 12, 2017, 01:25:18 am »
The STM32F429II says it has 256K of sram, but it talks about it in sections:

#define CCMDATARAM_BASE       0x10000000U /*!< CCM(core coupled memory) data RAM(64 KB) base address in the alias region  */
#define SRAM1_BASE            0x20000000U /*!< SRAM1(112 KB) base address in the alias region                             */
#define SRAM2_BASE            0x2001C000U /*!< SRAM2(16 KB) base address in the alias region                              */
#define SRAM3_BASE            0x20020000U /*!< SRAM3(64 KB) base address in the alias region                              */

Is this why it is reporting I am out of ram at 192K?  Is it not using the CCM area?  Can I make it include that somehow?  What is the point of having different memory sections?
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: STM32/lwip/eth questions - can't compile
« Reply #4 on: September 12, 2017, 02:03:09 am »
What is the point of having different memory sections?

The actual hardware is different between those SRAM chunks. The CCM is "faster" than other sections because it's optimized for the ARM core itself, so it's a good place to put code and data that you want to run very fast. However, the CCM can't be used with DMA.
 

Offline dgtl

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ee
Re: STM32/lwip/eth questions - can't compile
« Reply #5 on: September 12, 2017, 12:38:26 pm »
The different regions are connected to the bus matrix with separate connections. This way, all can be used at the same time. If the only user is CPU, this does not matter, but as you start using DMA channels, the cpu has to wait on dma and dma has to wait for cpu, unless you are not sharing an interface.
Keep in mind that the SRAM1-3 segments are after each other in address space. You can just define one segment in your linker script and use that as one large chunk if the separation is not needed for you.
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: STM32/lwip/eth questions - can't compile
« Reply #6 on: September 12, 2017, 12:41:46 pm »
Thanks westfw, I found 150K being used by some GUI code.
That's quite a lot, for an MCU.
You might want to check whether that is fixed data (e.g. backgrounds, icons, buttons etc.), that is missing a "const" in its declaration.
With const, only the copy in flash will exist.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: STM32/lwip/eth questions - can't compile
« Reply #7 on: September 12, 2017, 01:09:30 pm »
That's quite a lot, for an MCU.
You might want to check whether that is fixed data (e.g. backgrounds, icons, buttons etc.), that is missing a "const" in its declaration.
With const, only the copy in flash will exist.

I think it is the framebuffer.
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: STM32/lwip/eth questions - can't compile
« Reply #8 on: September 12, 2017, 01:34:24 pm »
I think it is the framebuffer.
:-// Tough luck then!
If it's using 16 to 32 bits per pixel for colour, it might be possible to exploit the Chrom-ART DMA2D accelerator and move it to a 1 byte per pixel + CLUT (Colour Look Up Table), but that means probably quite a lot of rework...
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline stmdude

  • Frequent Contributor
  • **
  • Posts: 479
  • Country: se
Re: STM32/lwip/eth questions - can't compile
« Reply #9 on: September 12, 2017, 05:37:55 pm »
Most STM32 boards I've worked with that has a display with any respectable resolution have a extra SDRAM just because of the issues you're having. Framebuffers _love_ RAM. And everything you'd want to blit _into_ the framebuffer also loves RAM.

Your STM32F429II has a handy FMC. It'll cost you a boatload of pins on the STM32 though.
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: STM32/lwip/eth questions - can't compile
« Reply #10 on: September 12, 2017, 06:09:41 pm »
I'm working on an STM32 project for someone else...

Is 193244 pretty big for the bss?  Is that for variables?  what is data for?  I thought that would be sram...

I think it is the framebuffer.
This is what I hate about working on other peoples' projects. That 'someone else' should have given you the full design specs and implementation details, then you wouldn't have to guess.
 

Online hans

  • Super Contributor
  • ***
  • Posts: 1640
  • Country: nl
Re: STM32/lwip/eth questions - can't compile
« Reply #11 on: September 12, 2017, 09:31:23 pm »
What you could still do is review the ethernet DMA buffer sizes. I think by default it allocates quite a lot of buffer space, like room for up to 2*5 (TX/RX) frames each almost 1600 bytes. If you can garantuee either that frames arrive slowly (e.g. fix Phy to 10Mbit speed) and/or frames are handled very fast you could perhaps get away with less DMA buffers.

Still best is to attach some external S(D)RAM for framebuffers, though. You can't beat how fast uncompressed video data explodes in size.
OT: No wonder NVIDIA GPU's are squeezing more memory bandwidth out of GDDR5 by compressing video data on the fly in hardware. The information 'density' of RAW videodata, by even most lossless video codec standards, is just so incredibly low. A pity you can't do much about it in MCU land without sacraficing quality.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: STM32/lwip/eth questions - can't compile
« Reply #12 on: September 12, 2017, 10:33:27 pm »
Quote
Is 193244 pretty big for the bss?  Is that for variables?  what is data for?  I thought that would be sram.
Yes, that's pretty huge for an embedded chip (especially since that's without some of the LWIP stuff.)
bss is uninitialized data - your STM32F429 should have 256k total.
It sounds like you might have some huge user array or something; try using "nm" on it to see what's using the space:

arm-none-eabi-nm -C *.elf | grep ' [bB] '
Even better: let the linker create a list file. Even though linking fails it will generate a list file which shows how much space each object (variables, functions, etc) is using.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: STM32/lwip/eth questions - can't compile
« Reply #13 on: September 12, 2017, 10:41:45 pm »
Quote
I found 150K being used by some GUI code.
Ouch.

Some linker scripts I found in an old STMCube looked like it tried to put bss in CCM and data in regular RAM (or vis versa?), but I'm not familiar enough to be certain, or to have been able to tell whether things would automatically switch over to the other memory region.  You can probably change individual memory allocations with the "section" attribute.

One of the excuses for the seldom-recommended dynamic allocation of memory in embedded systems is that it can be pretty easy to add multiple different chunks of memory to the total pool (or have separate pools.)
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: STM32/lwip/eth questions - can't compile
« Reply #14 on: September 13, 2017, 05:09:08 am »
Even better: let the linker create a list file. Even though linking fails it will generate a list file which shows how much space each object (variables, functions, etc) is using.
I use a makefile script that reports the top 50 items in RAM and flash. The output looks like this:

Code: [Select]
gmake report
Creating build/build_info.cc
Compiling build_info.cc
Linking build/program.elf
   text    data     bss     dec     hex filename
  97004     168   15224 112396   1b70c build/program.elf
Extracting symbol data from build/program.elf into build/program_symbols.txt
Converting build/program_symbols.txt to build/program_symbols.csv
Creating build/program.db from build/program_symbols.csv
Creating build/program.report from build/program.db
Total RAM Used
--------------
15360         
size        value       Largest items in RAM                                                           
----------  ----------  --------------------------------------------------------------------------------
8192        20005780    idm_storage_array                                                               
972         200028b8    anonymous::kernel                                                                 
924         200024d0    _ZL3mcu.lto_priv.559                                                           
592         200033d4    rx_msg_mgr                                                                     
408         20003624    anonymous::msg_sender                                                             
340         20003280    tx_msg_mgr                                                                     
328         20003138    rx_mgr                                                                         
312         20002310    m_im.lto_priv.631                                                               
300         20003008    peripheral                                                                     
252         200037bc    _ZL6lis2dh.lto_priv.561                                                         
232         20002ca4    _ZL3idm.lto_priv.566                                                           
224         200038e0    als                                                                             
208         20003ab0    m_pdb.lto_priv.536                                                             
120         20003c3c    nrf51::Pin::cb_                                                                 
120         20003d70    m_op_queue.lto_priv.620                                                         
104         20003bd4    nrf51::peripherals                                                             
96          20002298    impure_data                                                                     
88          20003a20    m_queue.lto_priv.617                                                           
88          20002e80    _ZL9indicator.lto_priv.567                                                     
84          20002dd4    _ZL12word_counter.lto_priv.564                                                 
72          20002f6c    word_counter_task                                                               
72          20003cbc    nrf51::BLEPeripheral::ble_stack_init(bool, unsigned int)::BLE_EVT_BUFFER       
72          20003de8    m_chunk_queue.lto_priv.621                                                     
64          20002448    m_pi.lto_priv.632                                                               
60          20002e34    button                                                                         
52          20002fd4    vm                                                                             
52          20003a78    m_bcs.lto_priv.535                                                             
48          20002da4    afe                                                                             
48          2000286c    nrf51::PWM::resources_                                                         
47          200039f0    anonymous::VolumeMeter::buffer_                                                   
44          20002f18    pm_task                                                                         
40          20002f44    adc_task                                                                       
40          200038b8    axl_task                                                                       
40          20002ef0    _ZL3psm.lto_priv.568                                                           
32          20002494    m_pm                                                                           
32          20002268    m_sm                                                                           
32          20002fb4    _ZL12sync_manager.lto_priv.565                                                 
32          20003ba4    m_pages.lto_priv.618                                                           
32          200039d0    _ZN7anonymousL13kernel_testerE.lto_priv.563                                       
32          20003b80    m_pds.lto_priv.537                                                             
32          20007790    nrf51::BLEPeripheral::device_name_                                             
28          2000289c    anonymous::time                                                                   
24          20002ed8    power_monitor                                                                   
20          20002c84    anonymous::channel                                                               
20          20002d8c    analytics                                                                       
16          20002e70    rgb                                                                             
16          200039c0    anonymous::channel_buffer                                                         
16          20003e30    m_gc.lto_priv.622                                                               
16          20002300    fs_config.lto_priv.623                                                         
12          200024bc    desc.5700                                                                       
Total FLASH Used
----------------
105141         
size        value       Largest items in FLASH                                                         
----------  ----------  --------------------------------------------------------------------------------
6948        0001bdb1    nrf51::BLEPeripheral::wrapper_ble_evt_dispatch(ble_evt_t*)                     
4772        0001f895    global constructors keyed to 65535_0_nrf_delay.o.37042                         
3312        0001b0c1    nrf51::Reset_Handler()                                                         
2352        00025f8d    application_shutdown() [clone .lto_priv.364]                                   
2204        0002bd7d    anonymous::AccelerometerTask::run(anonymous::Event)                                 
1944        00025545    anonymous::RxMessage::run(anonymous::Event)                                         
1892        0001de69    pdb_write_buf_get.part.4.lto_priv.548                                           
1858        0001ef45    queue_process.lto_priv.619                                                     
1704        00030c95    __aeabi_dsub                                                                   
1624        0002fb1d    __aeabi_dadd                                                                   
1624        0002ad05    anonymous::WordCounterTask::run(anonymous::Event)                                   
1580        00030175    __aeabi_ddiv                                                                   
1488        00020d19    im_peer_free.part.7.lto_priv.543                                               
1462        0002cb85    anonymous::ProductPeripheral::advertising_init()                                 
1380        0002d861    anonymous::ProductPeripheral::ble_sig_services_init()                           
1340        000288a5    anonymous::LightSensor::run(anonymous::Event)                                       
1268        000307a1    __aeabi_dmul                                                                   
1084        00021d4d    anonymous::Indicator::run(anonymous::Event)                                         
1036        000283ed    anonymous::ProductPeripheral::run(anonymous::Event)                               
1036        000283ed    .LTHUNK27.lto_priv.481                                                         
916         0001e7c5    pdb_write_buf_store.part.8.lto_priv.544                                         
836         00022189    kernel_preempt_                                                                 
820         0001db35    pdb_write_buf_release.part.5.lto_priv.547                                       
820         0002c825    anonymous::TxMessageManager::run(anonymous::Event)                                 
780         0002f6c1    __aeabi_fsub                                                                   
744         000215b5    anonymous::MessageSender::run(anonymous::Event)                                     
736         000296ed    nrf51::BLECharacteristic::add()                                                 
724         000270ad    anonymous::WordCounter::transition_to(anonymous::WordCounter::state_t) [clone .const
720         00024a69    nrf51::PWM::set_duty_cycle(unsigned char)                                       
676         00028149    anonymous::PSM::run(anonymous::Event)                                               
632         000268d9    nrf51::Battery::read_in_mv()                                                   
616         00027a1d    anonymous::LIS2DH::disable_click() [clone .constprop.102]                         
608         0001d8d5    peer_ids_init.lto_priv.539                                                     
580         0002ebd9    _printf_i                                                                       
568         00027c85    anonymous::LIS2DH::disable_stream() [clone .constprop.99]                         
564         0002f265    __aeabi_fdiv                                                                   
560         0002df3d    anonymous::Button::run(anonymous::Event)                                           
552         0002f499    __aeabi_fmul                                                                   
536         0002532d    nrf51::SPIMaster::transaction(unsigned char const*, unsigned char*, unsigned int
536         0002532d    .LTHUNK5.lto_priv.461                                                           
524         0002c619    anonymous::ADCTask::run(anonymous::Event)                                           
508         0002e901    _svfprintf_r                                                                   
508         0002e901    _svfiprintf_r                                                                   
504         0001e5cd    write_or_update.lto_priv.552                                                   
502         0002919d    anonymous::Umm::malloc(unsigned int)                                             
496         0002189d    anonymous::VolumeMeter::run(anonymous::Event)                                       
476         0002e369    write_enqueue.part.7.lto_priv.637                                               
464         0001eb95    gc_record_find_next                                                             
464         00026c0d    anonymous::Button::process() [clone .constprop.35]                               
460         0002efcd    __divsi3                                                                       


The script is attached.
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: STM32/lwip/eth questions - can't compile
« Reply #15 on: September 15, 2017, 01:34:40 pm »
Thanks everyone.  Project did have SDRAM and the framebuffer has been moved to it freeing up plenty of memory now.  I appreciate the help!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf