# ----- ALL ----- # # GENERAL #Allows to serialize and deserialize state in memory into and from non-volatile memory CONFIG_SETTINGS=y #Enables the compiler o optimize source code based on size or speed CONFIG_NO_OPTIMIZATIONS=n #This flag assures the compiler will optimize for size CONFIG_SIZE_OPTIMIZATIONS=y #Disable Serial Peripheral Interface (used to send data between microcontrollers and small peripherals such as shift registers, sensors, and SD cards) CONFIG_SPI=n #Disable building suitible for debugging CONFIG_DEBUG=n #Disable de __ASSERT() macro. Disabling this option will cause assertions to compile to nothing, improving performance and system footprint CONFIG_ASSERT=n #Disables the printk function, which is often used for debugging. Like disabling logging, this reduces size and overhead. CONFIG_PRINTK=n #Disables the printing of the boot banner at startup. This contributes to a faster startup time and a smaller binary size by removing the need to store and print the boot message. CONFIG_BOOT_BANNER=n #Disables the early console feature, which is typically used for debugging purposes before the main console is initialized. This can reduce the size and potentially speed up the initialization process. CONFIG_EARLY_CONSOLE=n #Disables the dumping of fault information. This can lead to a smaller binary size and potentially faster fault handling, but at the expense of losing detailed information when a fault occurs. CONFIG_FAULT_DUMP=0 #This option forces the use of frame pointers even if the default compiler optimization settings would omit them. While this may slightly increase the size of the binary, it is crucial for debugging and ensuring stack traces are accurate, which can be important for security and hardening purposes. CONFIG_OVERRIDE_FRAME_POINTER_DEFAULT=y #Disables the use of SEGGER's Real Time Transfer (RTT) logging. RTT can be useful for debugging, but disabling it can reduce the binary size and remove the overhead associated with this logging method. #This config needs to be disabled in the nrf52840dk_defconfig file #Não sei se podemos apagar a definição de lá e meter só aqui #CONFIG_USE_SEGGER_RTT=n #Configures the build system to generate a stripped output binary, which removes all debug information from the binary. This significantly reduces the size of the firmware. CONFIG_BUILD_OUTPUT_STRIPPED=y #Enables the stack sentinel feature, which helps detect stack overflows. This is a security feature that can slightly increase the binary size but is crucial for catching stack overflows early. CONFIG_STACK_SENTINEL=y # POWER MANAGEMENT #Enables extra power management options, when the kernel is idle saves power CONFIG_PM=y #Enables the device power management interface, needed to declare CONFIG_PM_DEVICE_RUNTIME CONFIG_PM_DEVICE=y #Enable Runtime Power Management to save power. devices can be suspended or resumed based on the device usage even while the CPU or system is running. CONFIG_PM_DEVICE_RUNTIME=y #Enable use of ADC to read battery power CONFIG_ADC=y # BLUETOOTH # Info extra # https://developerhelp.microchip.com/xwiki/bin/view/applications/ble/introduction/bluetooth-architecture/bluetooth-controller-layer/bluetooth-link-layer/Packet-Types/ # https://en.wikipedia.org/wiki/Asynchronous_connection-oriented_logical_transport #Enable Bluetooth support CONFIG_BT=y #Enable HCI drivers. Specifies all interactions between a host and a Bluetooth radio controller. Needed to enable next configurations. CONFIG_BT_HCI=y #Set the role of the board as a Peripheral CONFIG_BT_PERIPHERAL=y #Disable the role of central CONFIG_BT_CENTRAL=n #Disable the role of observer CONFIG_BT_OBSERVER=n #Enable device as a bluetooth broadcaster CONFIG_BT_BROADCASTER=y #Enable Extended Advertising API support. Mainly extends advertising data. CONFIG_BT_EXT_ADV=y #Sets the bluetooth buffer to maximum 512 bytes(Maximum transmission unit) CONFIG_BT_L2CAP_TX_MTU=512 #Sets the ACL size data packets transfered from Controller to Host to a maximum of 540 bytes CONFIG_BT_BUF_ACL_RX_SIZE=540 #Sets the ACL size data packets transfered from Host to Controller to a maximum of 240 bytes CONFIG_BT_BUF_ACL_TX_SIZE=240 #Set the size of PDU(Protocol Data Unit) to maximum CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 #Set the size of the recieving bluetooth thread stack CONFIG_BT_RX_STACK_SIZE=2200 #Enable to be able to use the update data lengh procedure CONFIG_BT_USER_DATA_LEN_UPDATE=y #Set device name CONFIG_BT_DEVICE_NAME="Teste1" #Set maximum number of devices simultaneously paired CONFIG_BT_MAX_PAIRED=1 # LOGGING #Disables the logging subsystem. This reduces the firmware size and eliminates the processing overhead associated with logging. CONFIG_LOG=n # FLASH / OTA / BOOT #Enable flash drivers CONFIG_FLASH=y #Enable support of flash map abstraction CONFIG_FLASH_MAP=y #Enable data to be writen to flash partition CONFIG_STREAM_FLASH=y #Enable DFU CONFIG_IMG_MANAGER=y #Enable support for non volatile storage CONFIG_NVS=y #Enable MPU(memory protection unit) to access flash memory (Enable MPU faults on flash write) CONFIG_MPU_ALLOW_FLASH_WRITE=y #Enable sys_reboot() CONFIG_REBOOT=y #Use mcuboot loader to reboot device CONFIG_BOOTLOADER_MCUBOOT=y #CONFIG_SECURE_BOOT=y #Signature keys for security, used to sign the app_update.bin file #CONFIG_SB_SIGNING_KEY_FILE="keys/priv.pem" #CONFIG_SB_PUBLIC_KEY_FILES="keys/pub_a.pem,keys/pub_b.pem" # I2C #Enable I2C for communication with slaves CONFIG_I2C=y #Timeout between i2c transfer CONFIG_I2C_NRFX_TRANSFER_TIMEOUT=2000 #Sets size of RAM that main thread can use CONFIG_MAIN_STACK_SIZE=4096 #Sets size of RAM for system work queue CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 #Extra info para analizar threads # Analize thread memory usage on j-link #CONFIG_THREAD_ANALYZER=y #CONFIG_THREAD_ANALYZER_USE_PRINTK=y #CONFIG_THREAD_ANALYZER_AUTO=y #CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=30
Hello Nordic community,
I’m working on a project that primarily uses GPIO for controlling locks, Bluetooth communication, and is powered by a battery. I’ve attached the configuration file I’m currently using for the release build, but I’m trying to reduce the binary size further. Could you help me identify which configurations might be unnecessary for my use case? Additionally, are there any configurations I should add or adjust to optimize for binary size without affecting the core functionalities?
Here’s a summary of what my project uses:
- GPIO for controlling electronic locks.
- Bluetooth for communication.
- Battery as the power source.
I’d appreciate any suggestions on what to trim down or adjust. Thank you!