Adding CONFIG_LOG=y causes Flash overflow error

This is my environment

  • IDE: VSC
  • SDK: NCS v2.2.0
  • nRF52-DK

I've got a couple of different sets of firmware for different applications, and I am seeing this issue with all of them.

They all use Bluetooth and have the MCU Boot manager enabled, as I need the OTA Firmware Update functionality.

Setup like that, I can't enable logging.  The moment I do, I get this error:

c:/nordic/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: region `FLASH' overflowed by 23716 bytes

I've got no idea why this is occuring and whether its actually something I can get around somehow.

In the past, I've resolved this by simply printing debug statements out using printk(), and having a bunch of #ifdef DEBUG #end statements around the printk() statement so I can enable/disable those as I move through the firmware development.

But it would be good to get the logging working

Does anyone know how I can fix this?

Regards,

Mike

Parents
  • Hi Mike,

    In which file do you enable logging?

    How large was your project before enabling logging?

    A common trick is to set CONFIG_LOG_DEFAULT_LEVEL to 0 and then configure the log level for the specific module you need logging from.

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    I've got logging enabled in my proj.conf file via CONFIG_LOG=y

    With this set to  "=n", I can get my code to build.  This is the report on Flash useage:

    [31/31] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       25274 B        48 KB     51.42%
                 RAM:       23680 B        64 KB     36.13%
            IDT_LIST:          0 GB         2 KB      0.00%
    [266/287] Linking C executable zephyr\zephyr_pre0.elf
    
    [270/287] Linking C executable zephyr\zephyr_pre1.elf
    
    [279/287] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:      217844 B     224768 B     96.92%
                 RAM:       59686 B        64 KB     91.07%
            IDT_LIST:          0 GB         2 KB      0.00%
    [282/287] Generating ../../zephyr/app_update.bin
    sign the payload
    [284/287] Generating ../../zephyr/app_signed.hex
    sign the payload
    [285/287] Generating ../../zephyr/app_test_update.hex
    sign the payload
    [287/287] Generating zephyr/merged.hex

    So, I'm certainly pushing the limits of my available flash.

    This is my memory report - not sure if there is any scope to reduce how much flash I'm currently using.

    I did a quick test with a project that doesn't use Bluetooth - looks like adding the logging requires nearly 11k of Flash - does that seem right?

    I tried using the CONFIG_LOG_DEFAULT_LEVEL = 0, but its still needing way more flash that I have spare - I've only got about 7kB left at the moment

    Regards,

    Mike

  • I have.

    So, this is my proj.conf

    And in every single .c file where I may want to use logging, I have this set:

    If I then build my code, this is how much flash I'm consuming (running pretty close to the limit, I know)

    If I then just change my proj.conf to this:

    But leave everything else as is, I get this error:

    So, by my calculations, I am adding 16,760 kB (= 224768 + 5684 - 213692) from somewhere!

  • Huh, that is odd.

    Can you verify from build/zephyr/.config that those configurations are set as expected?

    Can you try the same with some of our samples and see if you get similar results, or if it is only your app?

  • Yeah, its got me baffled!

    OK, this is my proj.conf settings for logging:

    And this is the relevant section of the .config file:

    That won't fit into my available flash space, so bombs out.  This is the full error message:

    I tried with a few samples, and other code I have.  I can definitely see a difference in the total amount of Flash consumed between having CONFIG_LOG_MODE_MINIMAL=y compared to CONFIG_LOG_MODE_MINIMAL=n

    Interestingly, if I set CONFIG_LOG_MODE_MINIMAL=y, I'm over-sized by 2148 bytes, but if I set 
    CONFIG_LOG_MODE_MINIMAL=n, I've oversized by 12784 bytes, which is about the 11kB difference I've been seeing.  Just can't work out why I'm going over my Flash limit in the first place.
    Putting CONFIG_LOG=n, means I'm about 16kB less in total Flash than if I set CONFIG_LOG=y and CONFIG_LOG_MINIMAL=y.
    I do have a child image with this application, as I am using MCUBoot for OTA firmware updates, so thought perhaps I had to do the same in the mcuboot.conf file as I do for prog.conf, but any attempts I made to set CONFIG_LOG=n there had no impact on total flash space required once I set things up in my proj.conf.
  • Mike Austin (LPI) said:
    Putting CONFIG_LOG=n, means I'm about 16kB less in total Flash than if I set CONFIG_LOG=y and CONFIG_LOG_MINIMAL=y.

    I guess that if logging in the mode minimal uses 16kB data, it uses 16kB data. I do not have any tables with numbers for each driver or such, so I can not confirm nor deny exact numbers here.
    I guess the best you can do is to check the same configs for other samples and see if they use the same space.

    Mike Austin (LPI) said:
    s I am using MCUBoot for OTA firmware updates

    You can also make MCUboot smaller. Here are some keywords to search for

    And also see https://github.com/nrfconnect/sdk-mcuboot/blob/main/boot/zephyr/prj_minimal.conf

    And specifically CONFIG_CBPRINTF_NANO=y makes MCUboot ca 10kB smaller I think

  • Hi Sigurd,

    I implemented a bunch of those CONFIG settings, and stumbled across this ticket which gave me a few more to try out.

    I was able to reduce my MCUBoot by about the 10kB you indicated, and also my firmware image by about 4kB.  So, now I can enable logging and still stay within the size limits.

    I did notice this warning pop up when I was building though:

    warning: The choice symbol LOG_MODE_MINIMAL (defined at subsys/logging\Kconfig.mode:28) was selected
    (set =y), but no symbol ended up as the choice selection. See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_MODE_MINIMAL and/or look up
    LOG_MODE_MINIMAL in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    

    Seems to be suggesting that even though I'm setting CONFIG_LOG_MODE_MINNAL=y, its not actually being set to that.

    But in my .config under build/zephyr I see this:

    which is suggesting its been set to what I want.

    Testing on a more simple example I have (its basically just a LED blinky for testing new hardware), I'm seeing this:

    CONFIG_LOG=n
    Code size = 20948
    
    CONFIG_LOG=y
    CONFIG_LOG_MINIMAL=y
    Code size = 22938
    
    CONFIG_LOG=y
    Code size = 30972

    So, minimal logging is adding 2kB and full logging is adding 10kB.  Yet in the firmware I am working with at the moment, those figures are:

    CONFIG_LOG=n
    Code size = 206992
    
    CONFIG_LOG=y
    CONFIG_LOG_MINIMAL=y
    Code size = 223336
    
    CONFIG_LOG=y
    Code size = 223336

    So, somehow the minimal logging is not being set and full logging is adding 16kB.

    Regards,

    Mike

Reply
  • Hi Sigurd,

    I implemented a bunch of those CONFIG settings, and stumbled across this ticket which gave me a few more to try out.

    I was able to reduce my MCUBoot by about the 10kB you indicated, and also my firmware image by about 4kB.  So, now I can enable logging and still stay within the size limits.

    I did notice this warning pop up when I was building though:

    warning: The choice symbol LOG_MODE_MINIMAL (defined at subsys/logging\Kconfig.mode:28) was selected
    (set =y), but no symbol ended up as the choice selection. See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_MODE_MINIMAL and/or look up
    LOG_MODE_MINIMAL in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    

    Seems to be suggesting that even though I'm setting CONFIG_LOG_MODE_MINNAL=y, its not actually being set to that.

    But in my .config under build/zephyr I see this:

    which is suggesting its been set to what I want.

    Testing on a more simple example I have (its basically just a LED blinky for testing new hardware), I'm seeing this:

    CONFIG_LOG=n
    Code size = 20948
    
    CONFIG_LOG=y
    CONFIG_LOG_MINIMAL=y
    Code size = 22938
    
    CONFIG_LOG=y
    Code size = 30972

    So, minimal logging is adding 2kB and full logging is adding 10kB.  Yet in the firmware I am working with at the moment, those figures are:

    CONFIG_LOG=n
    Code size = 206992
    
    CONFIG_LOG=y
    CONFIG_LOG_MINIMAL=y
    Code size = 223336
    
    CONFIG_LOG=y
    Code size = 223336

    So, somehow the minimal logging is not being set and full logging is adding 16kB.

    Regards,

    Mike

Children
  • Mike Austin (LPI) said:
    Seems to be suggesting that even though I'm setting CONFIG_LOG_MODE_MINNAL=y, its not actually being set to that.

    Since you verify that this is set for the application, this warning is likely related to a child image.

    That you can verify in, for example, build/mcuboot/zephyr/.config.

    To debug this, I often do

    cd build/mcuboot
    ninja menuconfig
    

    And then search( / ) for the related configuration, then look at its info ( ? ), to see why it is set as "n", cause this let you view its depenedncies and how they are set.

    Mike Austin (LPI) said:
    So, somehow the minimal logging is not being set and full logging is adding 16kB.

    Hmmm. I dont quite remember now. From previous debugging, did you verify that the 16kB is from the application, or could it be from a child image?

Related