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 Reply Children
  • 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

  • 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