jlaitine opened a new pull request, #19024:
URL: https://github.com/apache/nuttx/pull/19024

   ## Summary
   
   This adds 3 configuration options for the lib_strftime, which can be used to 
save flash memory when all the formatters are not needed by an embedded 
application.
   
   There is always a minimal set of formatters supported: "%a, %b/%h, %d, %H, 
%m, %M, %S, %Y, %%". To add on top of that one can specify:
   
   - LIBC_STRFTIME_C_STANDARD_FORMATS  : All ISO-C conversion specifiers
   - LIBC_STRFTIME_POSIX_FORMATS       : Additional posix formats
   - LIBC_STRFTIME_NONSTANDARD_FORMATS : Additional GNU nonstandard formats
   
   All of these are enabled by default unless building for 
CONFIG_DEFAULT_SMALL. Disabling these options can save over 3KB of flash on an 
32-bit ARM system, when all the format specifiers are not needed.
   
   I have grouped the switch-cases according to the flags, thinking that it was 
nicer. Now looking at this, I realize that it is quite difficult to review. I 
can also keep the switch-cases in order, and just scatter the ifdefs around, if 
that would be preferable, just let me know!
   
   ## Impact
   
   No impact, unless building for CONFIG_BUILD_SMALL (in which case the 
formatters needs to be enabled specifically), or if formatters are specifically 
disabled in the configuration.
   
   ## Testing
   
   Compilation has been tested on nucleo-f767zi:nsh:
   
   1) get https://github.com/apache/nuttx/pull/19023 so that BBSRAM can be used
   2) Enable the following to pull in strftime (it is used bv boards crashdump 
saving code):
   
   boards/arm/stm32f7/nucleo-f767zi/configs/nsh/defconfig:
   
   CONFIG_STM32F7_BKPSRAM=y
   CONFIG_STM32F7_BBSRAM=y
   CONFIG_STM32F7_PWR=y
   CONFIG_STM32F7_SAVE_CRASHDUMP=y
   
   3) Build and monitor flash size:
   
   ```
   ./tools/configure.sh nucleo-f767zi:make
   make
   
   LD: nuttx              
   Memory region         Used Size  Region Size  %age Used
               itcm:          0 GB         2 MB      0.00%
              flash:      142492 B         2 MB      6.79%
               dtcm:          0 GB       128 KB      0.00%
              sram1:        6032 B       368 KB      1.60%
              sram2:          0 GB        16 KB      0.00%
   
   ```
   
   4) Disable un-used format specifiers (leave only minimal set):
   
   boards/arm/stm32f7/nucleo-f767zi/configs/nsh/defconfig:
   
   # CONFIG_LIBC_STRFTIME_C_STANDARD_FORMATS is not set
   # CONFIG_LIBC_STRFTIME_NONSTANDARD_FORMATS is not set
   # CONFIG_LIBC_STRFTIME_POSIX_FORMATS is not set
   
   5) Build and  monitor flash size
   
   ```
   make distclean
   ./tools/configure.sh nucleo-f767zi:make
   make
   
   LD: nuttx              
   Memory region         Used Size  Region Size  %age Used
               itcm:          0 GB         2 MB      0.00%
              flash:      139208 B         2 MB      6.64%
               dtcm:          0 GB       128 KB      0.00%
              sram1:        6032 B       368 KB      1.60%
              sram2:          0 GB        16 KB      0.00%
   ```
   
   Diff: 3284 bytes smaller image
   
   In addition, functionality is checked with "date" on Pixhawk4 board, using 
only minimal set of formatters:
   ```
   
   nsh> date
   Thu, Jan 13 15:11:49 2000
   nsh> date -s "Jun 2 15:40:00 2026"
   nsh> date
   Tue, Jun 02 15:40:01 2026
   nsh> 
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to