STM32/lwip/eth questions - can't compile - Page 1
Forum section: electronics / general

author: alank2
author_rank: Super Contributor
timestamp: September 12, 2017, 12:15:19 am
content: 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 bytesWith the MX_LWIP_init remarked out, it compiles at:text data bss dec hex filename204832 2696 193244 400772 61d8It 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.

author: westfw
author_rank: Super Contributor
timestamp: September 12, 2017, 12:40:14 am
content: QuoteYes, 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 '  '

author: alank2
author_rank: Super Contributor
timestamp: September 12, 2017, 12:54:57 am
content: Thanks westfw, I found 150K being used by some GUI code.

author: alank2
author_rank: Super Contributor
timestamp: September 12, 2017, 01:25:18 am
content: 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?

author: andyturk
author_rank: Frequent Contributor
timestamp: September 12, 2017, 02:03:09 am
content: Quote from: alank2 on September 12, 2017, 01:25:18 amThe 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.

author: dgtl
author_rank: Regular Contributor
timestamp: September 12, 2017, 12:38:26 pm
content: 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.

author: newbrain
author_rank: Super Contributor
timestamp: September 12, 2017, 12:41:46 pm
content: Quote from: alank2 on September 12, 2017, 12:54:57 amThat'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.

author: alank2
author_rank: Super Contributor
timestamp: September 12, 2017, 01:09:30 pm
content: Quote from: newbrain on September 12, 2017, 12:41:46 pmI think it is the framebuffer.

author: newbrain
author_rank: Super Contributor
timestamp: September 12, 2017, 01:34:24 pm
content: Quote from: alank2 on September 12, 2017, 01:09:30 pmTough 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...

author: stmdude
author_rank: Frequent Contributor
timestamp: September 12, 2017, 05:37:55 pm
content: 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.

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: September 12, 2017, 06:09:41 pm
content: Quote from: alank2 on September 12, 2017, 12:15:19 amThis 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.

author: hans
author_rank: Super Contributor
timestamp: September 12, 2017, 09:31:23 pm
content: 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 handledveryfast 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 dataon the flyin 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.

author: nctnico
author_rank: Super Contributor
timestamp: September 12, 2017, 10:33:27 pm
content: Quote from: westfw on September 12, 2017, 12:40:14 amEven 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.

author: westfw
author_rank: Super Contributor
timestamp: September 12, 2017, 10:41:45 pm
content: QuoteOuch.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.)

author: andyturk
author_rank: Frequent Contributor
timestamp: September 13, 2017, 05:09:08 am
content: Quote from: nctnico on September 12, 2017, 10:33:27 pmI use a makefile script that reports the top 50 items in RAM and flash. The output looks like this:Code:gmake reportCreating build/build_info.ccCompiling build_info.ccLinking build/program.elftextdatabssdechexfilename97004168152241123961b70cbuild/program.elfExtracting symbol data from build/program.elf into build/program_symbols.txtConverting build/program_symbols.txt to build/program_symbols.csvCreating build/program.db from build/program_symbols.csvCreating build/program.report from build/program.dbTotal RAM Used--------------15360size value Largest items in RAM---------- ---------- --------------------------------------------------------------------------------8192 20005780 idm_storage_array972 200028b8 anonymous::kernel924 200024d0 _ZL3mcu.lto_priv.559592 200033d4 rx_msg_mgr408 20003624 anonymous::msg_sender340 20003280 tx_msg_mgr328 20003138 rx_mgr312 20002310 m_im.lto_priv.631300 20003008 peripheral252 200037bc _ZL6lis2dh.lto_priv.561232 20002ca4 _ZL3idm.lto_priv.566224 200038e0 als208 20003ab0 m_pdb.lto_priv.536120 20003c3c nrf51::Pin::cb_120 20003d70 m_op_queue.lto_priv.620104 20003bd4 nrf51::peripherals96 20002298 impure_data88 20003a20 m_queue.lto_priv.61788 20002e80 _ZL9indicator.lto_priv.56784 20002dd4 _ZL12word_counter.lto_priv.56472 20002f6c word_counter_task72 20003cbc nrf51::BLEPeripheral::ble_stack_init(bool, unsigned int)::BLE_EVT_BUFFER72 20003de8 m_chunk_queue.lto_priv.62164 20002448 m_pi.lto_priv.63260 20002e34 button52 20002fd4 vm52 20003a78 m_bcs.lto_priv.53548 20002da4 afe48 2000286c nrf51::PWM::resources_47 200039f0 anonymous::VolumeMeter::buffer_44 20002f18 pm_task40 20002f44 adc_task40 200038b8 axl_task40 20002ef0 _ZL3psm.lto_priv.56832 20002494 m_pm32 20002268 m_sm32 20002fb4 _ZL12sync_manager.lto_priv.56532 20003ba4 m_pages.lto_priv.61832 200039d0 _ZN7anonymousL13kernel_testerE.lto_priv.56332 20003b80 m_pds.lto_priv.53732 20007790 nrf51::BLEPeripheral::device_name_28 2000289c anonymous::time24 20002ed8 power_monitor20 20002c84 anonymous::channel20 20002d8c analytics16 20002e70 rgb16 200039c0 anonymous::channel_buffer16 20003e30 m_gc.lto_priv.62216 20002300 fs_config.lto_priv.62312 200024bc desc.5700Total FLASH Used----------------105141size 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.370423312 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.5481858 0001ef45 queue_process.lto_priv.6191704 00030c95 __aeabi_dsub1624 0002fb1d __aeabi_dadd1624 0002ad05 anonymous::WordCounterTask::run(anonymous::Event)1580 00030175 __aeabi_ddiv1488 00020d19 im_peer_free.part.7.lto_priv.5431462 0002cb85 anonymous::ProductPeripheral::advertising_init()1380 0002d861 anonymous::ProductPeripheral::ble_sig_services_init()1340 000288a5 anonymous::LightSensor::run(anonymous::Event)1268 000307a1 __aeabi_dmul1084 00021d4d anonymous::Indicator::run(anonymous::Event)1036 000283ed anonymous::ProductPeripheral::run(anonymous::Event)1036 000283ed .LTHUNK27.lto_priv.481916 0001e7c5 pdb_write_buf_store.part.8.lto_priv.544836 00022189 kernel_preempt_820 0001db35 pdb_write_buf_release.part.5.lto_priv.547820 0002c825 anonymous::TxMessageManager::run(anonymous::Event)780 0002f6c1 __aeabi_fsub744 000215b5 anonymous::MessageSender::run(anonymous::Event)736 000296ed nrf51::BLECharacteristic::add()724 000270ad anonymous::WordCounter::transition_to(anonymous::WordCounter::state_t) [clone .const720 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.539580 0002ebd9 _printf_i568 00027c85 anonymous::LIS2DH::disable_stream() [clone .constprop.99]564 0002f265 __aeabi_fdiv560 0002df3d anonymous::Button::run(anonymous::Event)552 0002f499 __aeabi_fmul536 0002532d nrf51::SPIMaster::transaction(unsigned char const*, unsigned char*, unsigned int536 0002532d .LTHUNK5.lto_priv.461524 0002c619 anonymous::ADCTask::run(anonymous::Event)508 0002e901 _svfprintf_r508 0002e901 _svfiprintf_r504 0001e5cd write_or_update.lto_priv.552502 0002919d anonymous::Umm::malloc(unsigned int)496 0002189d anonymous::VolumeMeter::run(anonymous::Event)476 0002e369 write_enqueue.part.7.lto_priv.637464 0001eb95 gc_record_find_next464 00026c0d anonymous::Button::process() [clone .constprop.35]460 0002efcd __divsi3The script is attached.

author: alank2
author_rank: Super Contributor
timestamp: September 15, 2017, 01:34:40 pm
content: Thanks everyone. Project did have SDRAM and the framebuffer has been moved to it freeing up plenty of memory now. I appreciate the help!