Apache NuttX and small systems - core OS size

[IMAGE]

today we will look at the core nuttx size. we go to absolute minimum in resources consumption to see how much nuttx core is. and look what nuttx core looks like.

[what OS interfaces don't use files ? zobaczyc syscale raczej nie widze nic co dziala bez plikow]

[ewentualna mozliwosc to no-posix way, czyli uzywanie arch/board logic bezposrendio w main jest to nawet mozliwe jak impelemntujemy logike po stronie board]

[think if something can be done about that, maybe files interface optimization]

  1. get defconfig from the previous but without hello and with dummy enabled. don't analyse defconfig here but reference to the previous post. compile and show results here as reference

    [verify this] no printf used, but most of the code should be not optimised ?

  2. first experiment, check size without serial port but with DEV_CONSOLE enabled show result

  3. then also disable DEV_CONSOLE - note about new warning, note that this breaks stdio etc and some interfaces

    may break sisytem

    • show result

  4. look at symbols and look at objdump? look at symbols if there is something left that is not used but not optimized for sure signals, maybe something from filesystem ? I remember there was some functions not called but also not optimized ?

    Maybe its possible somehow to disable signals ? maybe force signal allocated tables to 0 and maybe they be optimized ? play with some hacks

  5. maybe use some tool to compare both images ?

maybe bloaty can do a nice comparation ?

compare simbols sizes etc

  1. also show some screens from puncover present in some table what is the distribution of consumed memeory what components need what

  1. write some conclusions and possible optmisations note that support for VFS costs much because we need sprintf

[VERIFY THIS IF COMPILER OPTIMISE SPRINTF WHEN PRINTF NOT USED: what is interesting here, nuttx include support for whole lib_vsprintf to support fs_heap_asprintf which is used in file system implementation, but its used only for string in format %s/%s. It seems to be a waste of flash to support huge vsprintf when we need it only for such a simple operation]

8. last part - simple application that not use vfs simple application ? blinky on interrupts ? or something more interesting ? look at interfaces that can be used without filesyste: low level ops ? spi/i2c slaves ? timers, adc, pwm?, dac ? usb ?

app that use interrupts not POSIX interface - experiment, probably not recomended practice not portable solution, we lose POSIX and portability, but it is possible

NuttX core image size

***************check this paragraph**************

Before I finish this post, we can do one more experiment. Let's see what is the size of the "NuttX core" image [DESCRIBE WHAT IT MEANS].

Now, we apply all the optimization from above but also disable serial port support completely and use an empty main as entry point.

CONFIG_SERIAL=n
CONFIG_STM32_USART2=n
CONFIG_DEV_CONSOLE=n

Also change our main to a simple while(1) so we don't include any additional OS code:

int main(int argc, FAR char *argv[])
  {
    while(1);
  }

Memory usage with complete symbol list looks like this:

Memory region         Used Size  Region Size  %age Used
           flash:        7452 B        64 KB     11.37%
            sram:         916 B        16 KB      5.59%

[or maybe output from puncover ???? and screenshots ?] [then we have more informations ?]

arm-none-eabi-nm --size-sort build/nuttx

00000001 b g_nx_initstate
00000002 b g_ino
00000002 t hello_main
00000004 b g_errno
00000004 t g_idle_topstack
00000004 d g_irqmap_count
00000004 b g_lastpid
00000004 b g_mmheap
00000004 b g_npidhash
00000004 b g_pidhash
00000004 b g_reboot_notifier_list
00000004 b g_root_inode
00000004 b g_running_tasks
00000004 b g_system_ticks
00000006 T abort
00000008 b g_inactivetasks
00000008 b g_pendingtasks
00000008 b g_readytorun
00000008 b g_sigpendingaction
00000008 b g_sigpendingirqaction
00000008 b g_sigpendingirqsignal
00000008 b g_sigpendingsignal
00000008 b g_waitingforsignal
00000008 d g_wdactivelist
0000000a t start
0000000c T __assert
0000000c d g_sync_nb
0000000c t mm_unlock
0000000c t tls_get_info
00000010 t panic_notifier_call_chain
00000010 t strlen
00000012 t memset.constprop.0
00000014 t __errno
00000014 t free
00000014 t memcpy.isra.0
00000014 t sq_remfirst
00000016 t file_close.isra.0
00000018 t irq_unexpected_isr
00000018 t sched_lock.isra.0
0000001c t arm_svcall
0000001c t nxsched_gettid
0000001e t inode_free
00000020 t malloc
00000020 t nxmutex_unlock.isra.0
00000020 t strlcpy.isra.0
00000022 t file_close_without_clear
00000024 t nxmutex_lock
00000024 t up_release_stack.isra.0
00000026 t files_fget_by_index
00000026 t wd_cancel.isra.0
00000028 b g_irqvector
0000002c T arm_doirq
0000002c t up_mdelay.constprop.0
0000002c t zalloc
0000002e t inode_release
00000030 T up_saveusercontext
00000034 t mm_lock
00000038 t group_postinitialize
00000038 b g_tasklisttable
00000038 t irq_dispatch
0000003e t tls_init_info
00000040 t exception_direct
00000040 t files_putlist.part.0
00000040 t nxtask_start
0000004c t nxsig_release_pendingsigaction
0000004c t sync_reboot_handler
00000050 b g_last_regs
00000050 t group_initialize
00000050 t irq_attach.constprop.0.isra.0
00000050 t stm32_timerisr
00000054 t arm_hardfault
00000054 t nxsched_release_tcb.isra.0
00000054 t nxsched_remove_readytorun
00000056 t file_ioctl.constprop.0
0000005c t sched_unlock.isra.0
00000060 t nxsched_merge_pending
00000062 T exception_common
00000062 b g_irqmap
0000006c t up_initial_state
0000007c b g_idletcb
0000008c t task_fssync
000000a0 t nxsched_add_readytorun
000000a8 b g_kthread_group
000000b8 t files_extend
000000c2 t file_dup3.constprop.0
000000c4 t nxsem_post
000000d0 b g_sigpool
000000d4 t nxsem_wait
000000e0 t _exit.isra.0
000000e8 T _assert
000000fa t mm_delayfree.constprop.0
00000110 t mm_malloc
0000013c t group_leave
00000180 T __start
00000188 T _vectors
00000738 t nx_start

[analyse this more !!!! ]

[probably this doesn't have much sense] [we dropped logic responsible for file system, which saves us much flash. In real life application this probably never happen, as most likle we need somehow interact from apllication with outside world which happens with files. or maybe it possible to develop app that do all in interrupts and dont need files. of course then POSIX doesnt make sense here] [or it has sense ? for some custom implementations that not need to be portable] [when we create portable code, we most likely add some abstraction which cost resources]

Comments