This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Flash usage of examples (bare metal vs FreeRTOS based)

I'm working with nRF52832 and playing around with some peripheral examples from SDK 16.0.

The FreeRTOS based heart rate sensor example (ble_app_hrs_freertos) seems to work nice out of the box and I've done some small modifications to it, no problem so far.  However, the flash footprint of the sample app looks a bit odd to me.

The size of my FreeRTOS based app (excluding the softdevice, just the app itself) is around 110kB. I've added only some very basic functionality to the HRS example, very minimal stuff.

Does this sound reasonable? For comparison, I built the ble_app_blinky sample app that does not use any RTOS. Size of that app is only 22kB which sounds small enough to me.

I'm using the s132 soft device, if that makes any difference.

I would expect the FreeRTOS flash footprint to be only few tens of kilobytes. Any ideas where to look? I can of course start digging into the *.map output file to see exactly what the binary is built of, but any pointers are appreciated at this point.

  • Some more info: I tried to get detailed breakdown of the flash usage by running command

    nm ble_app_hrs_freertos_pca10040_s132.elf --print-size --size-sort --radix=d

    The output is attached as text file (sorted by size in descending order, including only flash objects).

    size(dec)  name
    1004 T nrf_fprintf_fmt
    976 t bsp_led_indication
    932 T nrf_log_frontend_dequeue
    812 T pm_handler_flash_clean
    804 T pm_handler_pm_evt_log
    800 T gcm_ble_evt_handler
    736 T GPIOTE_IRQHandler
    724 T SystemInit
    576 t pages_init
    570 T ble_advertising_start
    568 t auth_status_success_process
    552 T ble_dis_init
    548 T characteristic_add
    528 T pm_pdb_evt_handler
    510 T ble_advdata_encode
    478 t uart_irq_handler
    452 T nrf_fstorage_write
    440 T evt_handle
    440 t init_execute
    412 T HardFault_c_handler
    400 T ble_advertising_init
    396 t uarte_irq_handler
    372 T pm_init
    372 T pm_peer_ranks_get
    370 t sec_params_verify
    368 t write_enqueue
    364 t _conn_secure
    360 t fds_evt_handler
    356 T pm_peer_rank_highest
    356 t sec_info_request_process
    348 T fds_stat
    344 t uuid_list_sized_encode
    340 T xQueueGenericSend
    336 t name_encode
    336 t link_secure
    332 t hrm_encode
    324 T xQueueReceive
    324 t service_changed_send_in_evt
    322 T nrf_log_std_entry_process
    320 T vPortSuppressTicksAndSleep
    320 t ble_evt_handler
    320 T pdb_write_buf_get
    316 t ble_evt_handler
    316 T im_ble_evt_handler
    316 T smd_params_reply
    316 T ble_bas_battery_level_update
    312 T xTaskIncrementTick
    312 T write_buf_store
    308 t buf_prealloc
    308 T ble_hrs_init
    304 t unsigned_print
    304 T nrf_fstorage_erase
    304 t bsp_button_event_handler
    300 T nrfx_uarte_tx
    296 r nrf_strerror_array
    292 T nrf_log_backend_serial_put
    292 t sec_keyset_fill
    288 T fds_init
    284 t int_print
    284 T xTaskResumeAll
    280 T gscm_local_db_cache_apply
    276 t services_init
    276 T gscm_local_db_cache_update
    276 T pds_peer_data_store
    272 T app_button_init
    272 t write_execute
    264 t service_data_encode
    264 t local_db_apply_in_evt
    260 t log_skip
    260 T vTaskSuspend
    260 t prvProcessReceivedCommands
    260 T nrf_ble_gatt_on_ble_evt
    256 t memobj_op
    252 t queue_process
    248 t local_db_update_in_evt
    248 T sm_conn_sec_status_get
    246 T im_is_duplicate_bonding_data
    244 T app_timer_start
    244 t battery_level_char_add
    242 T nrf_sdh_ble_default_cfg_set
    240 T nrf_log_hexdump_entry_process
    240 T gcm_init
    236 t prvInitialiseNewTask
    236 t peer_manager_init
    236 t peer_data_delete_process
    234 t sys_id_encode
    232 T nrfx_gpiote_in_event_enable
    232 T pm_peers_delete
    228 t record_find
    228 t set_security_req
    228 T pdb_peer_free
    224 t records_stat
    224 T nrfx_gpiote_in_init
    224 t manuf_specific_data_encode
    224 T descriptor_add
    224 T gcm_pdb_evt_handler
    220 t event_prepare
    220 t data_length_update
    220 t pnp_id_encode
    216 T nrfx_uart_tx
    216 T bsp_init
    216 t timers_init
    212 t write_space_reserve
    212 t prvAddNewTaskToReadyList
    212 T ble_conn_params_init
    212 t on_connected_evt
    210 t prvCopyDataToQueue
    210 t ble_device_addr_encode
    210 T pds_peer_data_read
    208 T vTaskNotifyGiveFromISR
    208 t service_changed_pending_set
    208 t on_exchange_mtu_request_evt
    204 t events_send_from_err_code
    204 t sec_req_process
    202 T pm_buffer_block_acquire
    200 T xTaskPriorityDisinherit
    200 t prvAddCurrentTaskToDelayedList
    200 t reattempt_previous_operations
    198 t apply_config
    198 t apply_config
    198 T ble_advdata_search
    196 t conn_int_encode
    194 t string_print
    194 t is_conn_params_ok
    192 T nrf_drv_uart_init
    192 T nrfx_uart_init
    190 t service_changed_cccd
    188 t queue_process
    188 T nrf_fstorage_sys_evt_handler
    188 T nrfx_uarte_init
    188 T main
    180 t record_find_by_desc
    180 T xQueueGenericReset
    176 t prefix_process
    176 t gap_params_init
    176 t update_timeout_handler
    174 T nrf_memobj_alloc
    174 t prvUnlockQueue
    172 T app_timer_create
    172 T xTaskRemoveFromEventList
    172 T nrfx_uarte_uninit
    172 t application_timers_start
    172 t pairing_failure
    172 t char_add
    168 T pds_peer_data_iterate
    168 T pdb_pds_evt_handler
    168 T nrf_sdh_enable_request
    164 t page_scan
    164 t prvSwitchTimerLists
    164 T nrfx_gpiote_init
    164 T bsp_event_to_button_action_assign
    164 T store_car_value
    162 T nrf_ble_qwr_on_ble_evt
    160 t record_find_next
    160 T vTaskResume
    160 t appearance_encode
    160 T ah
    158 T nrf_atflags_find_and_set_flag
    156 t std_header_set
    156 t gc_execute
    156 t claim
    154 T xQueueGenericSendFromISR
    154 t adv_mode_next_avail_get
    152 t state_set
    152 T fds_record_close
    152 t prvProcessTimerOrBlockTask
    152 t interrupts_enable
    152 t heart_rate_meas_timeout_handler
    148 T nrf_drv_clock_lfclk_request
    148 T ble_hrs_heart_rate_measurement_send
    148 t nrf_sdh_ble_evts_poll
    146 t on_exchange_mtu_rsp_evt
    146 t on_rw_authorize_request
    144 t std_n
    144 T app_timer_stop
    144 t gc_page_next
    144 T nrf_fstorage_init
    144 T RTC1_IRQHandler
    144 T ulTaskNotifyTake
    144 T gscm_service_changed_ind_send
    140 t detection_delay_timeout_handler
    140 T xTaskCheckForTimeOut
    140 t bsp_event_handler
    140 t sec_proc_start
    140 t sd_nvic_EnableIRQ
    138 t pins_to_default
    138 t pins_to_default
    136 T pvPortMalloc
    136 t ble_evt_handler
    136 t set_adv_mode_fast
    136 t set_adv_mode_slow
    136 T pds_init
    134 t event_send
    134 T xTaskCreate
    132 t prvInsertTimerInActiveList
    132 t sensor_simulator_init
    132 t on_connect
    132 t conn_sec_update_process
    132 T smd_ble_evt_handler
    132 T nrf_sdh_disable_request
    128 t uart_init
    128 t write_buf_store_in_event
    128 T pdb_write_buf_store
    128 T smd_init
    128 R __RAL_ascii_ctype_map
    126 t flags_encode
    126 t tx_power_level_encode
    126 t write_buffer_record_find
    124 T fds_record_open
    124 T nrf_balloc_alloc
    124 T vTaskSwitchContext
    124 t prvInitialiseTaskLists
    124 t sd_state_evt_handler
    124 t channel_port_alloc
    124 t advertising_init
    124 t conn_params_negotiation
    124 t on_write
    124 t on_data_length_update_evt
    124 t conn_sec_failure
    124 t flags_set_from_err_code
    120 W app_error_fault_handler
    120 t page_from_record
    120 T fds_file_delete
    120 t on_operation_success
    120 T xTimerGenericCommand
    120 t conn_int_check
    120 T im_conn_handle_get
    120 t on_write
    118 W memcmp
    116 T nrf_log_init
    116 t sd_nvic_critical_region_enter
    116 t erase
    116 t sd_nvic_critical_region_enter
    116 T pdb_init
    114 T nrf_memobj_free
    112 T nrf_log_color_id_get
    112 T nrf_log_backend_add
    112 t gc_swap_pages
    112 t gc_state_advance
    112 t write
    112 T vTaskStartScheduler
    112 T nrfx_prs_acquire
    112 T ble_advertising_restart_without_whitelist
    112 t nrf_sdh_soc_evts_poll
    110 t invalid_packets_omit
    110 t uuid_list_encode
    110 t peer_data_find
    110 T ble_bas_init
    108 t gc_init
    108 t gc_page_erase
    108 t prvGetExpectedIdleTime
    108 t prvCheckForValidListAndQueue
    108 t interrupts_enable
    108 t conn_params_init
    108 t record_purge_disconnected
    108 t sd_nvic_DisableIRQ
    108 T nrf_sdh_freertos_init
    106 t delete_execute
    104 t backend_id_assign
    104 t gpiote_event_handler
    104 t page_has_space
    104 T nrf_strerror_find
    104 T vListInsert
    104 T POWER_CLOCK_IRQHandler
    104 t on_adv_evt
    104 t peer_ids_load
    104 T peer_id_get_next_used
    104 T pm_handler_on_pm_evt
    104 T sm_sec_is_sufficient
    104 T sm_init
    102 T nrf_atfifo_init
    102 T vQueueWaitForMessageRestricted
    102 t write_buf_length_words_set
    100 t nrf_drv_uart_tx
    100 t serial_tx
    100 t module_idx_get
    100 T fds_gc
    100 t prvProcessExpiredTimer
    100 T nrf_drv_clock_init
    100 t nrf_gpiote_event_configure
    100 T conn_handle_list_get
    100 t car_update_pending_handle
    100 t link_secure_failure
    100 t sdh_request_observer_notify
    98 t nrf_gpio_cfg
    98 t nrf_gpio_cfg
    98 t nrf_gpio_cfg
    98 t nrf_gpio_cfg
    98 t connection_buttons_configure
    98 t advertising_buttons_configure
    98 T ble_srv_report_ref_encode
    98 T im_address_resolve
    98 T pm_buffer_ptr_get
    96 t postfix_process
    96 t record_find_and_delete
    96 T pxPortInitialiseStack
    96 t battery_level_update
    96 T ble_conn_state_user_flag_get
    96 T ble_conn_state_user_flag_set
    96 T im_ble_addr_get
    96 T next_id_get
    96 t smd_params_reply_perform
    94 T PendSV_Handler
    94 T ble_hrs_rr_interval_add
    92 T eTaskConfirmSleepModeStatus
    92 t nrf_gpio_cfg_sense_set
    92 T nrfx_uart_uninit
    92 t nrf_gpio_cfg_sense_set
    92 t ble_stack_init
    92 t buttons_leds_init
    92 t for_each_set_flag
    92 t link_secure_pending_handle
    92 T sm_sec_params_set
    90 t write_execute
    90 T xQueueGenericCreate
    90 T pm_buffer_init
    88 t record_header_flag_dirty
    88 t gc_record_copy
    88 t errata_12
    88 t errata_31
    88 t errata_36
    88 t errata_108
    88 t errata_136
    88 t prvIdleTask
    88 t prvCheckTasksWaitingTermination
    88 T addr_compare
    88 T im_peer_free
    88 t write_buffer_record_find_next
    88 t rank_vars_update
    88 T pm_buffer_release
    88 t __sd_nvic_app_accessible_irq
    88 t sdh_state_observer_notify
    88 R __RAL_c_locale_data
    87 R __RAL_c_locale_month_names
    86 t nrf_atfifo_rspace_req
    86 T nrf_balloc_init
    86 t nrfx_power_clock_irq_init
    86 t on_terminated
    86 T im_peer_id_get_by_master_id
    86 T nrf_ble_gatt_init
    84 t sd_nvic_critical_region_exit
    84 t nrf_atfifo_wspace_req
    84 t sd_nvic_critical_region_exit
    84 t nrfx_clock_anomaly_132
    84 t on_disconnected
    84 t on_conn_params_update
    84 T ble_conn_state_role
    84 T ble_conn_state_status
    84 T im_find_duplicate_bonding_data
    84 t new_evt
    82 t tx_blocking
    82 t set_adv_mode_directed
    82 T im_master_ids_compare
    82 t peer_data_id_is_valid
    80 t page_can_tag
    80 t write_space_free
    80 t record_header_write_id
    80 t record_header_write_finalize
    80 t flash_end_addr
    80 t NVIC_SetPriority
    80 t NVIC_SetPriority
    80 t prvTaskIsTaskSuspended
    80 t uarte_evt_handler
    80 t uart_evt_handler
    80 t NVIC_SetPriority
    80 t NVIC_SetPriority
    80 t pin_in_use_by_te_set
    80 t NVIC_SetPriority
    80 t NVIC_SetPriority
    80 t sleep_mode_enter
    80 t flags_set
    80 t instance_get
    80 T ble_conn_state_for_each_set_user_flag
    80 t on_data_length_update_request_evt
    80 T pm_register
    80 T pm_conn_secure
    80 T sm_pdb_evt_handler
    78 t nrf_gpio_ports_read
    78 t rx_byte
    78 t sec_params_request_process
    76 t state_get
    76 t button_get
    76 t buffer_add
    76 t init
    76 T xPortStartScheduler
    76 t clock_clk_started_notify
    76 t _NRFX_IRQ_IS_ENABLED
    76 T ble_advdata_parse
    76 t ble_evt_handler
    76 T im_peer_id_get_by_conn_handle
    76 t write_buffer_record_find_stored
    76 t write_buffer_record_acquire
    76 T peer_id_delete
    76 T nrf_sdh_evts_poll
    74 T uxListRemove
    74 t prvCopyDataFromQueue
    74 t pairing_success_evt_send
    74 t on_hrm_cccd_write
    72 t address_is_valid
    72 t page_identify
    72 t file_find_and_delete
    72 t record_write_data
    72 t nrf_atfifo_space_clear
    72 T vPortSetupTimerInterrupt
    72 T vQueueAddToRegistry
    72 T bsp_board_led_state_get
    72 T bsp_board_button_state_get
    72 t user_mem_reply
    72 t NVIC_GetPriority
    70 t header_check
    70 T nrf_atflags_fetch_set
    70 t prvInitialiseNewTimer
    70 t wakeup_button_cfg
    70 t on_disconnect
    70 T gscm_service_changed_ind_needed
    70 t peer_data_point_to_buffer
    70 t sec_start_send
    70 T smd_link_secure
    68 t nrf_drv_uart_uninit
    68 t usr_event
    68 T app_button_enable
    68 T nrf_fstorage_sdh_state_handler
    68 T xTimerCreateTimerTask
    68 t nrf_gpio_pin_toggle
    68 t delete_bonds
    68 t advertising_start
    68 T ble_advertising_on_ble_evt
    68 t evt_send
    68 t car_update_needed
    68 t update_pending_flags_check
    68 t evt_send
    68 T nrf_ble_qwr_init
    68 t write_buffer_record_release
    68 t key_is_lesc
    68 T ble_hrs_on_ble_evt
    66 T nrf_balloc_free
    66 t mutex_lock
    64 T nrf_log_module_name_get
    64 t gc_next_page
    64 T fds_register
    64 t prvResetNextTaskUnblockTime
    64 t prvGetNextExpireTime
    64 T bsp_board_pin_to_button_idx
    64 T nrf_drv_clock_lfclk_release
    64 t clock_irq_handler
    64 t nrf_bitmask_bit_set
    64 t tx_byte
    64 T bsp_btn_ble_init
    64 t rr_interval_timeout_handler
    64 t sensor_contact_detected_timeout_handler
    64 t send_update_request
    64 t record_activate
    64 t record_invalidate
    64 t sc_send_pending_handle
    64 T sm_ble_evt_handler
    64 T SWI2_EGU2_IRQHandler
    62 T vListInsertEnd
    62 t prvInitialiseNewQueue
    62 T bsp_btn_ble_sleep_mode_prepare
    62 t use_whitelist
    62 t write_buffer_record_invalidate
    62 T pdb_write_buf_release
    60 T nrf_log_panic
    60 t event_send
    60 t page_offsets_update
    60 t record_header_write_begin
    60 T nrf_section_iter_next
    60 T sensorsim_increment
    60 T sensorsim_decrement
    60 t prvSampleTimeNow
    60 t pin_in_use_by_te
    60 t leds_off
    60 t startup_event_extract
    60 t flag_toggle
    60 t send_unexpected_error
    60 t db_update_pending_handle
    60 T gcm_im_evt_handler
    60 T im_master_id_is_valid
    60 t send_unexpected_error
    60 t evt_send
    60 t evt_send
    60 t send_unexpected_error
    60 t send_params_req
    58 T nrf_ringbuf_init
    58 t set_adv_mode_directed_high_duty
    58 W __aeabi_memmove
    58 W __aeabi_memmove4
    58 W __aeabi_memmove8
    58 W memmove
    58 R __RAL_c_locale_day_names
    56 t app_timer_callback
    56 t gc_record_find_next
    56 t errata_16
    56 t errata_32
    56 t errata_37
    56 t errata_57
    56 t errata_66
    56 T vTaskPlaceOnEventListRestricted
    56 T xTimerCreate
    56 t item_enqueue
    56 t nrf_gpio_cfg_watcher
    56 t channel_free
    56 t on_conn_params_evt
    56 T ble_conn_state_encrypted
    56 T ble_conn_state_mitm_protected
    56 T ble_conn_state_lesc
    56 t service_changed_needed
    56 T im_new_peer_id
    56 t internal_state_reset
    56 t ble_evt_handler
    56 T pm_conn_sec_status_get
    56 T nrf_sdh_request_continue
    56 T nrf_sdh_ble_enable
    54 T HardFault_Handler
    54 T vListInitialise
    54 t nrf_gpiote_event_clear
    54 t pm_evt_handler
    54 t config_is_valid
    54 t send_storage_full_evt
    54 T ble_bas_on_ble_evt
    52 t gc_swap_promote
    52 t addr_is_within_bounds
    52 T nrf_memobj_put
    52 T xTaskGetSchedulerState
    52 t bsp_board_leds_init
    52 t bsp_board_buttons_init
    52 T nrfx_clock_init
    52 t tx_done_event
    52 t tx_done_event
    52 T bsp_indication_set
    52 t instance_claim
    52 t pds_evt_send
    52 T peer_id_free
    52 T pm_peer_delete
    52 t send_config_req
    52 t disconnect_process
    52 t params_req_send
    52 t new_context_get
    50 T nrf_atfifo_item_alloc
    50 T nrf_atfifo_item_get
    50 T sensorsim_init
    50 t cccd_written
    50 T sm_smd_evt_handler
    49 R __RAL_c_locale_abbrev_month_names
    48 T nrf_log_frontend_std_4
    48 t page_tag_write_swap
    48 t gc_swap_erase
    48 t gc_update_swap_offset
    48 T nrf_atflags_clear
    48 T nrf_atflags_get
    48 T nrf_atomic_u32_fetch_or
    48 T nrf_atomic_u32_or
    48 T nrf_atomic_u32_fetch_and
    48 T nrf_atomic_u32_and
    48 T nrf_atomic_u32_fetch_add
    48 T nrf_atomic_u32_add
    48 T nrf_atomic_u32_sub
    48 T nrf_fprintf_buffer_flush
    48 T nrf_fprintf
    48 t queue_load_next
    48 T nrf_section_iter_init
    48 t NVIC_ClearPendingIRQ
    48 t NVIC_DisableIRQ
    48 t nrf_bitmask_bit_is_set
    48 t NVIC_DisableIRQ
    48 t interrupts_disable
    48 t NVIC_DisableIRQ
    48 t interrupts_disable
    48 T nrfx_uarte_tx_in_progress
    48 t adv_mode_next_get
    48 T ble_conn_state_valid
    48 t local_db_update
    48 T gscm_db_change_notification_done
    48 t evt_send
    48 T nrf_ble_qwr_conn_handle_assign
    48 t on_user_mem_request
    48 t file_id_within_pm_range
    48 t record_key_within_pm_range
    48 t pdb_evt_send
    48 T peer_id_is_allocated
    48 T peer_id_is_deleted
    48 T pm_sec_params_set
    48 t rank_highest
    48 t encryption_failure
    48 t NVIC_DisableIRQ
    46 t header_has_next
    46 T nrf_atflags_set
    46 T nrf_atomic_u32_fetch_store
    46 T sensorsim_measure
    46 t prvIsQueueFull
    46 t rx_done_event
    46 t rx_done_event
    46 t addr_is_valid
    46 T is_valid_irk
    46 t link_init
    46 T pds_peer_id_free
    46 t link_secure_authenticate
    46 t link_secure_peripheral
    46 t send_unexpected_error
    46 T sm_link_secure
    44 T nrf_log_default_backends_init
    44 T nrf_log_frontend_std_3
    44 t queue_buf_get
    44 t flash_bounds_set
    44 T fds_record_find
    44 t queue_start
    44 t on_operation_failure
    44 t uninit
    44 t NVIC_EnableIRQ
    44 T vTaskPlaceOnEventList
    44 T xTimerIsTimerActive
    44 t nrf_gpio_cfg_input
    44 t NVIC_EnableIRQ
    44 t NVIC_EnableIRQ
    44 t nrf_gpiote_event_enable
    44 t nrf_gpio_cfg_input
    44 t nrf_gpio_pin_sense_get
    44 t NVIC_EnableIRQ
    44 t nrf_gpio_cfg_input
    44 T nrfx_uart_tx_in_progress
    44 t NVIC_EnableIRQ
    44 t nrf_gpio_cfg_input
    44 t leds_timer_handler
    44 t gatt_init
    44 t log_init
    44 t uint16_encode
    44 T ble_srv_is_notification_enabled
    44 T pdb_peer_data_ptr_get
    44 t evt_send
    44 t uint16_encode
    44 t uint16_encode
    44 t NVIC_EnableIRQ
    44 t softdevice_task
    42 T fds_record_update
    42 t nrf_rtc_event_clear
    42 t prvIsQueueEmpty
    42 t nrf_gpio_pin_read
    42 t nrf_gpio_pin_out_read
    42 T bsp_board_init
    42 t _NRFX_IRQ_PRIORITY_SET
    42 t _NRFX_IRQ_PRIORITY_SET
    42 t nrf_gpiote_event_is_set
    42 t nrf_gpio_pin_read
    42 t _NRFX_IRQ_PRIORITY_SET
    42 t nrf_uart_event_clear
    42 t nrf_uart_configure
    42 t _NRFX_IRQ_PRIORITY_SET
    42 t nrf_uarte_event_clear
    42 t nrf_uarte_configure
    42 t conn_secure
    42 t on_write
    40 t nrf_log_backend_uart_put
    40 t dropped_sat16_get
    40 T nrf_log_frontend_std_2
    40 t timer_start
    40 T app_error_handler_bare
    40 t page_tag_write_data
    40 T fds_record_id_from_desc
    40 T nrf_atfifo_clear
    40 T nrf_atfifo_item_put
    40 T nrf_atfifo_item_free
    40 T nrf_fstorage_sdh_req_handler
    40 T nrf_memobj_write
    40 T nrf_memobj_read
    40 T nrf_strerror_get
    40 T vPortExitCritical
    40 t nrf_gpio_pin_set
    40 t nrf_gpio_pin_clear
    40 t soc_evt_handler
    40 t nrf_clock_event_clear
    40 T nrfx_prs_release
    40 t nrf_gpio_pin_set
    40 t nrf_gpio_pin_set
    40 T ble_conn_state_user_flag_acquire
    40 t nrf_mtx_trylock
    40 t peer_data_const_point_to_buffer
    40 t release
    40 T pm_handler_flash_clean_on_return
    40 t sec_procedure
    40 t pairing
    40 t bonding
    40 t allow_repairing
    40 t auth_status_failure_process
    38 T fds_record_find_by_key
    38 T fds_record_find_in_file
    38 t adv_set_data_size_max_get
    38 t auth_status_process
    38 t __sd_nvic_is_app_accessible_priority
    36 t NVIC_SystemReset
    36 t NVIC_SystemReset
    36 t NVIC_SystemReset
    36 t errata_182
    36 T vTaskInternalSetTimeOutState
    36 t nrf_gpio_pin_write
    36 T bsp_board_led_on
    36 T bsp_board_led_off
    36 T bsp_board_leds_off
    36 T bsp_board_leds_on
    36 t nrf_gpiote_event_polarity_get
    36 t pin_in_use_by_port
    36 t pin_in_use_by_gpiote
    36 t nrf_uart_event_check
    36 t nrf_uarte_event_check
    36 t send_error_evt
    36 t record_set_disconnected
    36 t user_flag_is_acquired
    36 T ble_srv_ascii_to_utf8
    36 T gscm_pdb_evt_handler
    36 T peer_id_allocate
    36 T peer_id_get_next_deleted
    36 t battery_notification_send
    36 t softdevices_evt_irq_enable
    36 t softdevice_evt_irq_disable
    36 T nrf_sdh_ble_app_ram_start_get
    36 T __RAL_ascii_mbtowc
    34 T nrf_log_frontend_std_1
    34 t nrf_balloc_idx2block
    34 t addr_is_page_aligned
    34 t read
    34 T vPortStartFirstTask
    34 T pvTimerGetTimerID
    34 t nrf_gpio_cfg_output
    34 t nrf_clock_event_check
    34 t nrf_gpio_cfg_output
    34 t nrf_gpio_cfg_default
    34 t nrf_gpio_cfg_output
    34 t nrf_gpio_cfg_default
    34 t clock_init
    34 t on_disconnected_evt
    34 t flag_id_init
    34 t flag_id_init
    32 t nrf_log_backend_uart_panic_set
    32 t queue_load
    32 t queue_has_next
    32 t queue_start
    32 t flash_subsystem_init
    32 t nrf_atfifo_wspace_close
    32 t nrf_atfifo_rspace_close
    32 t erase_execute
    32 T vPortEnterCritical
    32 t prvTimerTask
    32 T bsp_board_led_invert
    32 t item_dequeue
    32 t nrf_gpiote_event_pin_get
    32 T nrfx_gpiote_in_is_set
    32 t prs_box_get
    32 t nrf_uart_int_enable_check
    32 T bsp_button_is_pressed
    32 t phy_is_valid
    32 T ble_conn_state_conn_handles
    32 t uint16_decode
    32 t params_reply_pending_handle
    32 R nrf_fstorage_sd
    32 r app_buttons
    32 R __RAL_codeset_ascii
    30 T fds_record_write
    30 t nrf_balloc_block2idx
    30 T nrf_memobj_get
    30 T SVC_Handler
    30 t ulPortRaiseBASEPRI
    30 t nrf_rtc_task_trigger
    30 t ulPortRaiseBASEPRI
    30 t ulPortRaiseBASEPRI
    30 t prvDeleteTCB
    30 T nrfx_clock_lfclk_start
    30 t nrf_uart_txrx_pins_set
    30 t nrf_uart_hwfc_pins_set
    30 t nrf_uarte_shorts_disable
    30 t nrf_uarte_txrx_pins_set
    30 t nrf_uarte_hwfc_pins_set
    30 t nrf_uarte_tx_buffer_set
    30 t on_connected
    30 t apply_pending_handle
    30 T pds_peer_id_is_allocated
    30 T pds_next_peer_id_get
    30 T pds_next_deleted_peer_id_get
    30 t mutex_lock_status_get
    30 t params_req_process
    29 R __RAL_c_locale_abbrev_day_names
    28 T nrf_log_backend_uart_init
    28 t nrf_log_backend_put
    28 T nrf_log_frontend_std_0
    28 T buffer_is_empty
    28 T app_util_critical_region_exit
    28 t queue_buf_store
    28 t queue_free
    28 t gc_tag_new_swap
    28 t queue_init
    28 t is_busy
    28 t nrf_rtc_cc_set
    28 T vTaskStepTick
    28 t _NRFX_IRQ_ENABLE
    28 t nrf_clock_lf_is_running
    28 t _NRFX_IRQ_ENABLE
    28 t pin_in_use_clear
    28 t pin_configured_set
    28 t channel_port_get
    28 t _NRFX_IRQ_ENABLE
    28 t _NRFX_IRQ_DISABLE
    28 t nrf_uart_errorsrc_get_and_clear
    28 t nrf_uart_txrx_pins_disconnect
    28 t nrf_uart_hwfc_pins_disconnect
    28 t nrf_uart_task_trigger
    28 t nrfx_is_in_ram
    28 t _NRFX_IRQ_ENABLE
    28 t _NRFX_IRQ_DISABLE
    28 t nrf_uarte_errorsrc_get_and_clear
    28 t nrf_uarte_txrx_pins_disconnect
    28 t nrf_uarte_hwfc_pins_disconnect
    28 t nrf_uarte_task_trigger
    28 t apply_pending_flags_check
    28 t service_changed_pending_flags_check
    28 t internal_state_reset
    28 T pm_sm_evt_handler
    28 t internal_state_reset
    28 t mutex_unlock
    28 t __RAL_ascii_isctype
    28 t __RAL_ascii_iswctype
    26 t nrf_log_backend_id_set
    26 t is_word_aligned
    26 t addr_is_aligned32
    26 t nrf_clock_task_trigger
    26 t nrf_gpiote_event_addr_get
    26 t nrf_uart_txd_set
    26 t button_timer_handler
    26 t logger_thread
    26 T ble_advertising_conn_cfg_tag_set
    26 t peer_data_id_to_record_key
    26 T ble_hrs_sensor_contact_detected_update
    24 t uart_evt_handler
    24 t nrf_log_backend_panic_set
    24 t nrf_log_backend_flush
    24 t fs_event_handler
    24 T nrf_atomic_flag_set_fetch
    24 T nrf_atomic_flag_set
    24 T nrf_atomic_flag_clear_fetch
    24 t queue_free
    24 t vPortEnableVFP
    24 T xTaskGetTickCountFromISR
    24 T bsp_board_button_idx_to_pin
    24 T nrfx_clock_lfclk_stop
    24 t nrf_gpiote_int_enable
    24 t nrf_gpiote_int_is_enabled
    24 t channel_handler_get
    24 T nrfx_gpiote_is_init
    24 T nrfx_uart_0_irq_handler
    24 T nrfx_uarte_0_irq_handler
    24 T bsp_wakeup_button_enable
    24 T gscm_init
    24 t peer_id_to_file_id
    24 t file_id_to_peer_id
    24 t internal_state_reset
    22 t __sd_nvic_irq_disable
    22 t header_jump
    22 T nrf_memobj_pool_init
    22 t __sd_nvic_irq_disable
    20 T nrf_log_module_cnt_get
    20 T app_util_critical_region_enter
    20 t record_id_new
    20 T SystemCoreClockUpdate
    20 t nrf_rtc_int_enable
    20 t nrf_rtc_int_disable
    20 t nrf_rtc_prescaler_set
    20 t nrf_rtc_event_enable
    20 T vTaskSuspendAll
    20 T xTaskGetTickCount
    20 t nrf_gpio_port_out_set
    20 t nrf_gpio_port_out_clear
    20 t lfclk_stop
    20 t nrf_clock_int_enable
    20 t nrf_clock_int_disable
    20 t nrf_clock_lf_src_set
    20 t nrf_uart_int_enable
    20 t nrf_uart_int_disable
    20 t nrf_uart_baudrate_set
    20 t nrf_gpio_port_out_set
    20 t nrf_uarte_int_enable
    20 t nrf_uarte_int_disable
    20 t nrf_uarte_baudrate_set
    20 t nrf_gpio_port_out_set
    20 t alert_timer_handler
    20 t nrf_qwr_error_handler
    20 t conn_params_error_handler
    20 T vApplicationIdleHook
    20 t nrf_mtx_init
    20 t nrf_mtx_unlock
    20 t record_key_to_peer_data_id
    20 T pds_peer_data_iterate_prepare
    20 T pm_gcm_evt_handler
    20 T pm_gscm_evt_handler
    20 T pm_im_evt_handler
    20 t evt_forward
    20 t on_connect
    20 t on_disconnect
    20 T __RAL_isctype
    20 R log_mempool
    19 r __func__.7738
    19 r __func__.7745
    19 r m_unknown_str
    18 t nrf_log_backend_enable
    18 t nrf_log_backend_enable
    18 W HardFault_process
    18 t nrf_uart_enable
    18 t nrf_uart_disable
    18 t nrf_uart_rxd_get
    18 t nrf_uarte_enable
    18 t nrf_uarte_disable
    18 t battery_level_meas_timeout_handler
    18 t instance_free
    18 t write_buffer_record_find_unused
    18 r __func__.7717
    16 t nrf_log_backend_id_get
    16 t nrf_log_backend_is_enabled
    16 T vListInitialiseItem
    16 t nrf_rtc_counter_get
    16 T vTaskMissedYield
    16 t nrf_gpio_port_in_read
    16 t nrf_gpio_port_out_read
    16 t nrfx_get_irq_number
    16 T nrfx_clock_enable
    16 t nrf_gpio_port_in_read
    16 T UARTE0_UART0_IRQHandler
    16 t nrfx_get_irq_number
    16 t nrf_uart_tx_pin_get
    16 t nrf_uart_rx_pin_get
    16 t nrf_uart_rts_pin_get
    16 t nrf_uart_cts_pin_get
    16 t nrfx_get_irq_number
    16 t nrf_uarte_tx_pin_get
    16 t nrf_uarte_rx_pin_get
    16 t nrf_uarte_rts_pin_get
    16 t nrf_uarte_cts_pin_get
    16 t nrf_uarte_tx_amount_get
    16 t nrf_uarte_rx_amount_get
    16 t whitelist_has_entries
    16 t internal_state_reset
    16 T pds_peer_id_allocate
    16 T peer_id_init
    16 r uart_log_backend
    16 r _aV2C.7544
    16 r m_evt_handlers
    16 r __func__.10745
    16 r __func__.10440
    15 R __RAL_c_locale_date_time_format
    14 t rmap
    14 t wmap
    14 t prvTaskExitError
    14 t nrf_gpio_pin_port_decode
    14 t nrf_gpio_pin_port_decode
    14 t nrf_gpio_pin_port_decode
    14 t nrf_gpio_pin_port_decode
    14 t nrf_gpio_pin_port_decode
    14 t nrf_section_iter_get
    14 t nrf_section_iter_get
    14 t nrf_section_iter_get
    14 T __RAL_ascii_wctomb
    13 r __RAL_ascii_ctype_mask
    12 t timestamp_print
    12 t on_user_mem_release
    12 T nrf_sdh_is_enabled
    12 t __RAL_ascii_toupper
    12 t __RAL_ascii_tolower
    12 t __RAL_ascii_towupper
    12 t __RAL_ascii_towlower
    12 R nrf_log_backend_uart_api
    12 r m_log_push_ringbuf
    12 r m_flash_info
    12 r sdh_req_observers
    12 r sdh_state_observers
    12 r sdh_stack_observers
    12 r sdh_ble_observers
    12 r sdh_soc_observers
    12 R __RAL_c_locale
    10 t nrf_log_backend_uart_flush
    10 T vPortFree
    10 t rank_init
    10 W isprint
    9 R __RAL_c_locale_date_format
    9 R __RAL_c_locale_time_format
    8 t sd_flash_write
    8 t sd_flash_page_erase
    8 t sd_app_evt_wait
    8 t sd_ble_gap_disconnect
    8 t sd_ble_gap_appearance_set
    8 t sd_ble_gap_ppcp_set
    8 t sd_ble_gap_device_name_set
    8 t sd_ble_gap_phy_update
    8 t sd_power_system_off
    8 t sd_ble_gap_addr_get
    8 t sd_ble_gap_appearance_get
    8 t sd_ble_gap_device_name_get
    8 t sd_ble_uuid_encode
    8 t sd_ble_gap_adv_set_configure
    8 t sd_ble_gap_adv_start
    8 t sd_ble_gap_adv_stop
    8 t sd_ble_gap_conn_param_update
    8 t sd_ble_gap_disconnect
    8 t sd_ble_gap_ppcp_set
    8 t sd_ble_gap_ppcp_get
    8 t sd_ble_gatts_characteristic_add
    8 t sd_ble_gatts_descriptor_add
    8 t sd_ble_gattc_char_value_by_uuid_read
    8 t sd_ble_gattc_read
    8 t sd_ble_gatts_value_get
    8 t sd_ble_gatts_initial_user_handle_get
    8 t sd_ble_gatts_attr_get
    8 t sd_ble_gatts_service_changed
    8 t sd_ble_gatts_sys_attr_set
    8 t sd_ble_gatts_sys_attr_get
    8 t sd_ble_gatts_initial_user_handle_get
    8 t sd_ecb_block_encrypt
    8 t sd_ble_gap_data_length_update
    8 t sd_ble_gattc_exchange_mtu_request
    8 t sd_ble_gatts_exchange_mtu_reply
    8 t sd_ble_gatts_rw_authorize_reply
    8 t sd_ble_user_mem_reply
    8 t sd_ble_gap_disconnect
    8 t sd_ble_gap_authenticate
    8 t sd_ble_gap_sec_params_reply
    8 t sd_ble_gap_sec_info_reply
    8 t sd_ble_gatts_service_add
    8 t sd_ble_gatts_value_set
    8 t sd_ble_gatts_hvx
    8 t sd_ble_gatts_service_add
    8 t sd_ble_gatts_service_add
    8 t sd_ble_gatts_hvx
    8 t sd_softdevice_enable
    8 t sd_softdevice_disable
    8 t sd_ble_enable
    8 t sd_ble_cfg_set
    8 t sd_ble_evt_get
    8 t sd_evt_get
    8 r m_sys_obs
    8 r m_soc_evt_observer
    8 r m_ble_evt_observer
    8 r m_ble_observer
    8 r m_gatt_obs
    8 r m_advertising_ble_obs
    8 r m_ble_observer
    8 r m_ble_evt_observer
    8 r m_bas_obs
    8 r m_hrs_obs
    8 r m_qwr_obs
    8 r m_ble_observer.12567
    8 r m_state_obs
    8 r m_sd_state_observer
    8 r m_nrf_sdh_ble_evts_poll
    8 r m_nrf_sdh_soc_evts_poll
    8 R m_req_obs
    8 R m_nrf_log_CLOCK_logs_data_const
    8 R m_nrf_log_GPIOTE_logs_data_const
    8 R m_nrf_log_PRS_logs_data_const
    8 R m_nrf_log_UART_logs_data_const
    8 R m_nrf_log_UARTE_logs_data_const
    8 R m_nrf_log_app_logs_data_const
    8 R m_nrf_log_app_button_logs_data_const
    8 R m_nrf_log_ble_bas_logs_data_const
    8 R m_nrf_log_clock_logs_data_const
    8 R m_nrf_log_hardfault_logs_data_const
    8 R m_nrf_log_nrf_ble_gatt_logs_data_const
    8 R m_nrf_log_nrf_fstorage_logs_data_const
    8 R m_nrf_log_nrf_sdh_logs_data_const
    8 R m_nrf_log_nrf_sdh_ble_logs_data_const
    8 R m_nrf_log_nrf_sdh_freertos_logs_data_const
    8 R m_nrf_log_nrf_sdh_soc_logs_data_const
    8 R m_nrf_log_peer_manager_logs_data_const
    8 R m_nrf_log_peer_manager_gcm_logs_data_const
    8 R m_nrf_log_peer_manager_gscm_logs_data_const
    8 R m_nrf_log_peer_manager_handler_logs_data_const
    8 R m_nrf_log_peer_manager_im_logs_data_const
    8 R m_nrf_log_peer_manager_pdb_logs_data_const
    8 R m_nrf_log_peer_manager_pds_logs_data_const
    8 R m_nrf_log_peer_manager_sm_logs_data_const
    8 R m_nrf_log_peer_manager_smd_logs_data_const
    8 r page_tag_swap.8646
    8 r page_tag_data.8650
    8 r m_evt_handlers
    8 r __func__.10559
    7 R __RAL_c_locale_am_pm_indicator
    6 T app_timer_init
    6 t __sd_nvic_irq_enable
    6 t __sd_nvic_irq_enable
    4 r m_detection_delay_timer_id
    4 r dirty_header.8777
    4 r m_board_led_list
    4 r m_board_btn_list
    4 r irq_handlers.8950
    4 r irq_handlers.8992
    4 r m_bsp_leds_tmr
    4 r m_bsp_alert_tmr
    4 r m_bsp_button_tmr
    4 r car_value_true.10477
    4 r car_value_false.10478
    4 r service_changed_pending.10179
    4 r service_changed_pending.10236
    2 R __RAL_data_utf8_period
    1 R __RAL_data_empty_string
    

    Sum of the sizes is around 95 kB and this was generated from the original FreeRTOS HRS example from SDK 16.0.0, built for devkit pca10040.

    I can't spot from the list any obvious things that would be consuming lots of flash. There's just a very long list of small stuff that eventually creates a rather big image.

    Should I be looking into compiler/linker settings? Possibly the linker is not dropping unused functions but keeping everything which would explain why the resulting image is a bit bloated. Any ideas?

  • Any comments? It's been a week and I doubt that I'm the only one experimenting with the FreeRTOS based example for nRF52. Is it normal for the simple HRS app to be > 100kB in size??

    I'm relatively new to Nordic parts so don't know exactly what to expect...

  • sorry for the late reply. Seems like you are including NRF_LOG_ENABLED in your sdk_config.h file. That would increase a log of foot print. This also makes the BACKEDEND (seems uart in your case) included which includes uart libraries and drivers

  • Thanks for the tip. Changing NRF_LOG_ENABLED to 0 made the flash footprint ~31kB smaller. This is a good start.

    After disabling log, the size of the HRS sample app is still 70+ kB which seems a bit large, considering it is a very simple app. Is there perhaps some other options that I may need to adjust?

    The 70kB app size is not a showstopper as such. However, I am in the process of setting up the template for a project that will go into production use eventually and I would like to strip off all the unnecessary fat from the project right from the start (instead of trying to shave it off few days before the deadline...)

    This project is FreeRTOS based and the OS obviously adds some bulk to the image. So basically I have two follow-up questions:

    1) What settings should I be looking at to optimize the flash consumed by FreeRTOS

    2) How to minimize the footprint of the BLE application itself (excluding the OS)

    Regarding question 2: the softdevice is a fixed binary with fixed size, so that cannot be optimized. I'm new to Nordic BLE stack so it's a bit unclear how I can optimize my app footprint, considering that I only need a (relatively small) subset of the features that are available in the s132 stack. If there are some appnotes, blogs etc on this topic then please let me know.

  • I would highly recommend you to understand the sdk_config.h file. This knowledge is quite useful for you in the future, so it will be a good investment in time. After that disable all those things that are not needed in your project. When you start to think about the best performance/lowest power/smallest foot print, then you need to have control on these variables and select them accordingly. 

    TylerD said:
    1) What settings should I be looking at to optimize the flash consumed by FreeRTOS

     The flash size directly is impacted by what features are included in your project. By default we add all the drivers and libraries into your project and hope/expect that you select their inclusion wisely by enabling or disabling them in sdk_config.h file. 

    Please start to disable the things in sdk_config that you think are definitely not needed in your production version. I am sure you will get  better results. It is quite hard from our perspective to suggest what to disable and what to keep enabled. Since these are given as template example for making this functionality work and leaving the footprint engineering to the experts like you by selecting them from sdk_config.h

Related