You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "royfengsss (via GitHub)" <gi...@apache.org> on 2023/09/14 08:48:43 UTC
[GitHub] [nuttx] royfengsss opened a new pull request, #10626: esp32: Use newlib-esp32
royfengsss opened a new pull request, #10626:
URL: https://github.com/apache/nuttx/pull/10626
## Summary
When we are using newlib as libm, we can consider newlib-esp32 for esp32 hardware. An it contains some optimizations for esp32 hardware. Besides this change, two small issues has been fixed.
1. add the tar ball to .gitignore
2. Fix the some build warnings
## Impact
Using a seperated config option to switch and default is n. So no impact to normal case.
For enable newlib-esp32 case, it has a little performance improvement for float calculation.
## Testing
Write a piece of simple test code and update `example/hello` app as below:
```
int main(int argc, FAR char *argv[])
{
struct timespec ts0;
struct timespec ts1;
uint64_t elapsed;
char *endp;
long n = 10000;
double number = 0.0;
double sum = 0.0;
double result;
printf("Hello, World!!\n");
if (argc == 2)
{
n = (int)strtol(argv[1], &endp, 10);
if (argv[1] == endp)
{
printf("invalid parameter!\n");
exit(-1);
}
}
srand(time(0));
clock_gettime(CLOCK_REALTIME, &ts0);
for (int i = 1; i <= n; i++)
{
number = (double)(rand() % 9000001 + 1000000) + (double)(rand() % 10001) / 10000.0;
sum += 1.0 / sqrt(number);
}
result = sum / (double)n;
clock_gettime(CLOCK_REALTIME, &ts1);
elapsed = (((uint64_t)ts1.tv_sec * NSEC_PER_SEC) + ts1.tv_nsec);
elapsed -= (((uint64_t)ts0.tv_sec * NSEC_PER_SEC) + ts0.tv_nsec);
elapsed /= NSEC_PER_MSEC; /* msec */
printf("The %ld round result is %.7f\n", n, result);
printf("it took %" PRIu64 " msec\n", elapsed);
return 0;
}
```
Use esp32-devkitc:nsh config and enable below options
```
CONFIG_LIBM_NEWLIB=y
CONFIG_LIBM_USE_NEWLIB_ESP32=y
```
Here is the test result:
For the case of using default newlib (sourceware.org)
```
nsh> hello
Hello, World!!
The 10000 round result is 0.0004855
it took 180 msec
nsh> hello 100000
Hello, World!!
The 100000 round result is 0.0004858
it took 1820 msec
nsh> hello 1000000
Hello, World!!
The 1000000 round result is 0.0005035
it took 18190 msec
nsh> hello
Hello, World!!
The 10000 round result is 0.0004856
it took 180 msec
nsh> hello 100000
Hello, World!!
The 100000 round result is 0.0004858
it took 1820 msec
nsh> hello 1000000
Hello, World!!
The 1000000 round result is 0.0004858
it took 18190 msec
nsh>
```
For the case of using newlib-esp32:
```
nsh> hello
Hello, World!!
The 10000 round result is 0.0004854
it took 170 msec
nsh> hello 100000
Hello, World!!
The 100000 round result is 0.0004858
it took 1750 msec
nsh> hello 1000000
Hello, World!!
The 1000000 round result is 0.0004858
it took 17470 msec
nsh> hello
Hello, World!!
The 10000 round result is 0.0004848
it took 180 msec
nsh> hello 100000
Hello, World!!
The 100000 round result is 0.0005035
it took 1750 msec
nsh> hello 1000000
Hello, World!!
The 1000000 round result is 0.0004858
it took 17470 msec
nsh>
```
We can see the newlib-esp32 case is a little better in performance than the default.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] royfengsss commented on a diff in pull request #10626: esp32: Use newlib-esp32
Posted by "royfengsss (via GitHub)" <gi...@apache.org>.
royfengsss commented on code in PR #10626:
URL: https://github.com/apache/nuttx/pull/10626#discussion_r1325640967
##########
libs/libm/newlib/Make.defs:
##########
@@ -18,21 +18,31 @@
#
############################################################################
-NEWLIB_VERSION=4.3.0.20230120
+ifeq ($(CONFIG_LIBM_USE_NEWLIB_ESP32),y)
+ NEWLIB_VERSION=esp-4.1.0_20230425
+ NEWLIB_BASENAME=newlib-esp32
+ NEWLIB_URL_BASE=https://github.com/espressif/newlib-esp32/archive
+ NEWLIB_TARBALL=$(NEWLIB_VERSION).tar.gz
+else
+ NEWLIB_VERSION=4.3.0.20230120
Review Comment:
4.1.0 is the latest version of newlib-esp32 I can find.
I guess 4.3.0 is too new to start adaptation in Espressif.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #10626: esp32: Use newlib-esp32
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #10626:
URL: https://github.com/apache/nuttx/pull/10626#discussion_r1325636634
##########
libs/libm/newlib/Make.defs:
##########
@@ -18,21 +18,31 @@
#
############################################################################
-NEWLIB_VERSION=4.3.0.20230120
+ifeq ($(CONFIG_LIBM_USE_NEWLIB_ESP32),y)
+ NEWLIB_VERSION=esp-4.1.0_20230425
+ NEWLIB_BASENAME=newlib-esp32
+ NEWLIB_URL_BASE=https://github.com/espressif/newlib-esp32/archive
+ NEWLIB_TARBALL=$(NEWLIB_VERSION).tar.gz
+else
+ NEWLIB_VERSION=4.3.0.20230120
Review Comment:
I mean, do we know what is the gap between 4.1.0 from `sourceware.org` vs espressif one?
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] royfengsss commented on a diff in pull request #10626: esp32: Use newlib-esp32
Posted by "royfengsss (via GitHub)" <gi...@apache.org>.
royfengsss commented on code in PR #10626:
URL: https://github.com/apache/nuttx/pull/10626#discussion_r1326663196
##########
libs/libm/newlib/Make.defs:
##########
@@ -18,21 +18,31 @@
#
############################################################################
-NEWLIB_VERSION=4.3.0.20230120
+ifeq ($(CONFIG_LIBM_USE_NEWLIB_ESP32),y)
+ NEWLIB_VERSION=esp-4.1.0_20230425
+ NEWLIB_BASENAME=newlib-esp32
+ NEWLIB_URL_BASE=https://github.com/espressif/newlib-esp32/archive
+ NEWLIB_TARBALL=$(NEWLIB_VERSION).tar.gz
+else
+ NEWLIB_VERSION=4.3.0.20230120
Review Comment:
> I mean, do we know what is the gap between 4.1.0 from `sourceware.org` vs espressif one?
The mainly changes in newlib-esp32 is for RISCV. The change for Xtensa is not so much. as far as I can find, sqrt() and fmod() are different. I also can see some changes in sourceware.org newlib v4.3.0 were not picked into current newllib-esp32. We hope Espressif can bump the source to the latest soon.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 merged pull request #10626: esp32: Use newlib-esp32
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #10626:
URL: https://github.com/apache/nuttx/pull/10626
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] royfengsss commented on a diff in pull request #10626: esp32: Use newlib-esp32
Posted by "royfengsss (via GitHub)" <gi...@apache.org>.
royfengsss commented on code in PR #10626:
URL: https://github.com/apache/nuttx/pull/10626#discussion_r1325642800
##########
libs/libm/newlib/Kconfig:
##########
@@ -3,6 +3,14 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
+config LIBM_USE_NEWLIB_ESP32
+ bool "Use Espressif ported newlib-esp32"
+ depends on LIBM_NEWLIB
Review Comment:
Updated. Directly used `CONFIG_ARCH_CHIP_ESP32` to decide what newlib package will be used.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10626: esp32: Use newlib-esp32
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10626:
URL: https://github.com/apache/nuttx/pull/10626#discussion_r1325614689
##########
libs/libm/newlib/Kconfig:
##########
@@ -3,6 +3,14 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
+config LIBM_USE_NEWLIB_ESP32
+ bool "Use Espressif ported newlib-esp32"
+ depends on LIBM_NEWLIB
Review Comment:
remove, don't need in this Kconfig
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #10626: esp32: Use newlib-esp32
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #10626:
URL: https://github.com/apache/nuttx/pull/10626#discussion_r1325634315
##########
libs/libm/newlib/Make.defs:
##########
@@ -18,21 +18,31 @@
#
############################################################################
-NEWLIB_VERSION=4.3.0.20230120
+ifeq ($(CONFIG_LIBM_USE_NEWLIB_ESP32),y)
+ NEWLIB_VERSION=esp-4.1.0_20230425
+ NEWLIB_BASENAME=newlib-esp32
+ NEWLIB_URL_BASE=https://github.com/espressif/newlib-esp32/archive
+ NEWLIB_TARBALL=$(NEWLIB_VERSION).tar.gz
+else
+ NEWLIB_VERSION=4.3.0.20230120
Review Comment:
So 4.1.0 performs better than 4.3.0?
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org