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

   ## Summary
   
   Many different architectures re-implemented the exact same code for 
`up_udelay` because it was originally written as architecture dependent code. 
Busy-waiting can be done regardless of architecture, so this commit moves that 
duplicated implementation to a common file with weak definitions so that 
individual architectures (see tc32) are still able to override the definition 
if needed/desired.
   
   This closes #17069, and should be merged before #17011 so that there is one 
unified location where the configuration options for LOOPSPERMSEC can be 
asserted as calibrated.
   
   ## Impact
   
   This impacts all of the architectures that had their own implementation of 
`up_udelay`, listed in the files changed overview. These now pull their 
definitions from the `udelay.c` common implementation, which is always included.
   
   The `drivers/timers` directory is now a permanent dependency path since 
`udelay.c` is always linked.
   
   Any optimization/change to the base definition is now felt across all 
architectures.
   
   The `tc32` architecture still links against its own (differing) 
implementation, which overrides the weak references.
   
   ## Testing
   
   I was able to build two of the selected architectures normally after these 
changes were applied: `arm` and `avr`. The `udelay.c` file was properly linked.
   
   ARM:
   
   ```console
   $ ./tools/configure.sh raspberrypi-pico:usbnsh
   $ make -j
   Create version.h
   LN: platform/board to /home/linguini/coding/nuttx-space/apps/platform/dummy
   Register: hello
   Register: ostest
   Register: getprime
   Register: nsh
   Register: sh
   Register: dd
   LD: nuttx
   Memory region         Used Size  Region Size  %age Used
              flash:        152 KB         2 MB      7.42%
               sram:        8768 B       264 KB      3.24%
   Generating: nuttx.uf2
   Done.
   ```
   
   AVR:
   
   ```console
   $ ./tools/configure.sh arduino-mega2560:nsh
   $ make -j
   Create version.h
   LN: platform/board to /home/linguini/coding/nuttx-space/apps/platform/dummy
   Register: sh
   Register: nsh
   LD: nuttx
   Memory region         Used Size  Region Size  %age Used
              flash:       69165 B       256 KB     26.38%
               sram:        3302 B         8 KB     40.31%
             eeprom:           0 B         4 KB      0.00%
   ```
   
   I also found an application in the NuttX apps that uses up_udelay directly 
(`cpuhog`), so I enabled that for the Pico and built once more:
   
   ```console
   $ make -j
   Create version.h
   LN: platform/board to /home/linguini/coding/nuttx-space/apps/platform/dummy
   Register: hello
   Register: ostest
   Register: dd
   Register: nsh
   Register: sh
   Register: cpuhog
   Register: getprime
   LD: nuttx
   Memory region         Used Size  Region Size  %age Used
              flash:        156 KB         2 MB      7.62%
               sram:        8812 B       264 KB      3.26%
   Generating: nuttx.uf2
   Done.
   [linguini@pastabox nuttx]$ 
   ```
   
   No issues linking to the default implementation of `up_udelay`.


-- 
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