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

Multiple conflicting errno.h libraries

Working with nRF9160 in Zephyr, I've recently noticed that there are multiple conflicting definition of the errno.h values available, and I'm pretty sure I've seen both in use at various times.

Most of Zephyr appears to use the ones available in zephyr/lib/libc/minimal/include/errno.h

The NRFX library politely defines it's own variants with NRF_ prefixes in nrfxlib/bsdlib/include/nrf_errno.h

However, the gnuarmemb toolchain provides it's own version in gnuarmemb2018q2/arm-none-eabi/include/sys/errno.h which DON'T MATCH and I've seen evidence of some libraries using them, including the NRFX BSD library.

For example, ETIMEDOUT is 60 in the Zephyr's variants, but 116 in the gnuarmemb variant, and I just had a NRFX offloaded recv() call fail with errno=116.  (Specifically in the download_client library)

This needs to be rectified...

Parents
  • Hi,

     

    I made a small routine to print your libc wrt. errno's:

    #define ERRNO_STRINGIFY(ERR) \
    do {printk("Errno %s has value %d\n", #ERR, ERR);} \
    while (0)
    
    void errno_checker(void)
    {
    	#if defined(CONFIG_NEWLIB_LIBC) && defined(_NEWLIB_VERSION)
    	printk("Newlib version %s\n", _NEWLIB_VERSION);
    	#elif defined(ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_ERRNO_H_)
    	printk("Zephyr Minimal libc\n");
    	#else
    	printk("Not able to resolve libc used\n");
    	#endif
    
        ERRNO_STRINGIFY(EPERM          );
        ERRNO_STRINGIFY(ENOENT         );
        ERRNO_STRINGIFY(ESRCH          );
        ERRNO_STRINGIFY(EINTR          );
        ERRNO_STRINGIFY(EIO            );
        ERRNO_STRINGIFY(ENXIO          );
        ERRNO_STRINGIFY(E2BIG          );
        ERRNO_STRINGIFY(ENOEXEC        );
        ERRNO_STRINGIFY(EBADF          );
        ERRNO_STRINGIFY(ECHILD         );
        ERRNO_STRINGIFY(EAGAIN         );
        ERRNO_STRINGIFY(ENOMEM         );
        ERRNO_STRINGIFY(EACCES         );
        ERRNO_STRINGIFY(EFAULT         );
        ERRNO_STRINGIFY(ENOTEMPTY      );
        ERRNO_STRINGIFY(EBUSY          );
        ERRNO_STRINGIFY(EEXIST         );
        ERRNO_STRINGIFY(EXDEV          );
        ERRNO_STRINGIFY(ENODEV         );
        ERRNO_STRINGIFY(ENOTDIR        );
        ERRNO_STRINGIFY(EISDIR         );
        ERRNO_STRINGIFY(EINVAL         );
        ERRNO_STRINGIFY(ENFILE         );
        ERRNO_STRINGIFY(EMFILE         );
        ERRNO_STRINGIFY(ENOTTY         );
        ERRNO_STRINGIFY(ENAMETOOLONG   );
        ERRNO_STRINGIFY(EFBIG          );
        ERRNO_STRINGIFY(ENOSPC         );
        ERRNO_STRINGIFY(ESPIPE         );
        ERRNO_STRINGIFY(EROFS          );
        ERRNO_STRINGIFY(EMLINK         );
        ERRNO_STRINGIFY(EPIPE          );
        ERRNO_STRINGIFY(EDEADLK        );
        ERRNO_STRINGIFY(ENOLCK         );
        ERRNO_STRINGIFY(ENOTSUP        );
        ERRNO_STRINGIFY(EMSGSIZE       );
        ERRNO_STRINGIFY(EDOM           );
        ERRNO_STRINGIFY(ERANGE         );
        ERRNO_STRINGIFY(EDESTADDRREQ   );
        ERRNO_STRINGIFY(EPROTOTYPE     );
        ERRNO_STRINGIFY(ENOPROTOOPT    );
        ERRNO_STRINGIFY(EPROTONOSUPPORT);
        ERRNO_STRINGIFY(ESOCKTNOSUPPORT);
        ERRNO_STRINGIFY(EOPNOTSUPP     );
        ERRNO_STRINGIFY(EPFNOSUPPORT   );
        ERRNO_STRINGIFY(EAFNOSUPPORT   );
        ERRNO_STRINGIFY(EADDRINUSE     );
        ERRNO_STRINGIFY(EADDRNOTAVAIL  );
        ERRNO_STRINGIFY(ENOTSOCK       );
        ERRNO_STRINGIFY(ENETUNREACH    );
        ERRNO_STRINGIFY(ENETRESET      );
        ERRNO_STRINGIFY(ECONNABORTED   );
        ERRNO_STRINGIFY(ECONNRESET     );
        ERRNO_STRINGIFY(ENOBUFS        );
        ERRNO_STRINGIFY(EISCONN        );
        ERRNO_STRINGIFY(ENOTCONN       );
        ERRNO_STRINGIFY(ESHUTDOWN      );
        ERRNO_STRINGIFY(ETOOMANYREFS   );
        ERRNO_STRINGIFY(ETIMEDOUT      );
        ERRNO_STRINGIFY(ECONNREFUSED   );
        ERRNO_STRINGIFY(ENETDOWN       );
        ERRNO_STRINGIFY(ETXTBSY        );
        ERRNO_STRINGIFY(ELOOP          );
        ERRNO_STRINGIFY(EHOSTUNREACH   );
        ERRNO_STRINGIFY(ENOTBLK        );
        ERRNO_STRINGIFY(EHOSTDOWN      );
        ERRNO_STRINGIFY(EINPROGRESS    );
        ERRNO_STRINGIFY(EALREADY       );
        ERRNO_STRINGIFY(EWOULDBLOCK    );
        ERRNO_STRINGIFY(ENOSYS         );
        ERRNO_STRINGIFY(ECANCELED      );
    /*  Not defined in newlib
        ERRNO_STRINGIFY(ERRMAX         );*/
        ERRNO_STRINGIFY(ENOSR          );
        ERRNO_STRINGIFY(ENOSTR         );
        ERRNO_STRINGIFY(EPROTO         );
        ERRNO_STRINGIFY(EBADMSG        );
        ERRNO_STRINGIFY(ENODATA        );
        ERRNO_STRINGIFY(ETIME          );
        ERRNO_STRINGIFY(ENOMSG         );
        ERRNO_STRINGIFY(EILSEQ         );	
    }

    Are you certain that this is related to the codebase? Newlib has different definitions of errno, compared to zephyrs minimal libc, and ETIMEDOUT is 116 in newlib v3.0.0:

    Newlib version 3.0.0
    Errno EPERM has value 1
    Errno ENOENT has value 2
    Errno ESRCH has value 3
    Errno EINTR has value 4
    Errno EIO has value 5
    Errno ENXIO has value 6
    Errno E2BIG has value 7
    Errno ENOEXEC has value 8
    Errno EBADF has value 9
    Errno ECHILD has value 10
    Errno EAGAIN has value 11
    Errno ENOMEM has value 12
    Errno EACCES has value 13
    Errno EFAULT has value 14
    Errno ENOTEMPTY has value 90
    Errno EBUSY has value 16
    Errno EEXIST has value 17
    Errno EXDEV has value 18
    Errno ENODEV has value 19
    Errno ENOTDIR has value 20
    Errno EISDIR has value 21
    Errno EINVAL has value 22
    Errno ENFILE has value 23
    Errno EMFILE has value 24
    Errno ENOTTY has value 25
    Errno ENAMETOOLONG has value 91
    Errno EFBIG has value 27
    Errno ENOSPC has value 28
    Errno ESPIPE has value 29
    Errno EROFS has value 30
    Errno EMLINK has value 31
    Errno EPIPE has value 32
    Errno EDEADLK has value 45
    Errno ENOLCK has value 46
    Errno ENOTSUP has value 134
    Errno EMSGSIZE has value 122
    Errno EDOM has value 33
    Errno ERANGE has value 34
    Errno EDESTADDRREQ has value 121
    Errno EPROTOTYPE has value 107
    Errno ENOPROTOOPT has value 109
    Errno EPROTONOSUPPORT has value 123
    Errno ESOCKTNOSUPPORT has value 124
    Errno EOPNOTSUPP has value 95
    Errno EPFNOSUPPORT has value 96
    Errno EAFNOSUPPORT has value 106
    Errno EADDRINUSE has value 112
    Errno EADDRNOTAVAIL has value 125
    Errno ENOTSOCK has value 108
    Errno ENETUNREACH has value 114
    Errno ENETRESET has value 126
    Errno ECONNABORTED has value 113
    Errno ECONNRESET has value 104
    Errno ENOBUFS has value 105
    Errno EISCONN has value 127
    Errno ENOTCONN has value 128
    Errno ESHUTDOWN has value 110
    Errno ETOOMANYREFS has value 129
    Errno ETIMEDOUT has value 116
    Errno ECONNREFUSED has value 111
    Errno ENETDOWN has value 115
    Errno ETXTBSY has value 26
    Errno ELOOP has value 92
    Errno EHOSTUNREACH has value 118
    Errno ENOTBLK has value 15
    Errno EHOSTDOWN has value 117
    Errno EINPROGRESS has value 119
    Errno EALREADY has value 120
    Errno EWOULDBLOCK has value 11
    Errno ENOSYS has value 88
    Errno ECANCELED has value 140
    Errno ENOSR has value 63
    Errno ENOSTR has value 60
    Errno EPROTO has value 71
    Errno EBADMSG has value 77
    Errno ENODATA has value 61
    Errno ETIME has value 62
    Errno ENOMSG has value 35
    Errno EILSEQ has value 138
    

    Which looks consistent with the errno in sys (this file is old, but seems to be unchanged compared to the sourceware git repo):

    https://github.com/eblot/newlib/blob/master/newlib/libc/include/sys/errno.h#L147

     

    Does your prj.conf/.config set "CONFIG_NEWLIB_LIBC=y"?

     

    Kind regards,

    Håkon

  • Does your prj.conf/.config set "CONFIG_NEWLIB_LIBC=y"?

    Yep.  I forgot we *just* added it for lwm2m_carrier, and that's probably why this looked out of place to me.  The socket offload layer is probably converting from NRF_ETIMEDOUT to the newlib ETIMEDOUT just like it's supposed to..

    Thank you for the hint.

Reply Children
No Data
Related