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 do some tests with hello_world.

    No changes:

    CONFIG_LOG=y

    So yes 11k as you observe.

    CONFIG_LOG_DEFAULT_LEVE=0

    7-8k

    CONFIG_LOG_MODE_MINIMAL=y

    That is probably what you are looking for I recon.

Reply Children
  • Thanks Sigurd.

    I had tried the CONFIG_LOG_MODE_MINIMAL setting, but I get the following message if I only set that without first setting CONFIG_LOG = y

    CONFIG_LOG_MODE_MINIMAL was assigned the value y, but got the value n. Missing dependencies:
    <choice LOG_MODE>

    And of course if I set CONFIG_LOG = y, I run out of Flash memory

    Any ideas what I'm doing wrong?

    Regards,

    Mike

  • Have you tried to set both?

    CONFIG_LOG enables the logging module.
    Then the logging mode can have several modes: Deferred, Minimal or immediate.
    So you set CONFIG_LOG_MODE_MINIMAL to use that mode.
    Then you also set CONFIG_LOG_DEFAULT_LEVEL=0 to turn of logging in all other modules, and set log level for only the things you need.

  • 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.
Related