Skip to contentSkip to conversation

Add Newlib as a C library for baremetal

PATCH In review Alejandro Enedino Hernandez Samaniego 3 participants 6 messages May 23, 2018 – May 25, 2018

lore
Share & tools
lore
#2 lore raw

PATCH 2/3 insane.bbclass: Adds powerpc to elf headers machine dictionary

In reply to Alejandro Enedino Hernandez Samaniego

This patch adds makes it possible to build elf for powerpc by adding this combination to the elf headers machine dictionary, this can be useful when trying to build baremetal applications where the TARGET_OS=elf

---
 meta/classes/insane.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes/insane.bbclass +1 -0
index fa15460..bd7f519 100644
@@ -71,6 +71,7 @@ def package_qa_get_machine_dict(d):
                         "microblaze":  (189,   0,    0,          False,         32),
                         "microblazeeb":(189,   0,    0,          False,         32),
                         "microblazeel":(189,   0,    0,          True,          32),
+                        "powerpc":    (20,     0,    0,          False,         32),
                         "riscv32":    (243,    0,    0,          True,          32),
                         "riscv64":    (243,    0,    0,          True,          64),
                       },

--
2.7.4

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#0 lore raw

cover Add Newlib as a C library for baremetal

Newlib is a widely used C library for embedded systems, its mainly used for resource constrained devices which run baremetal applications.

It provides basic C library functionality, and it is meant to be extended by design, it contains several stubs for core functions that can be later overriden with the symbols provided from another library at linking time.

Libgloss is the BSP part of the library which follows the same principle, where a BSP layer can override functionality or even application runtime depending on the processor architecture.

These patches add both the libgloss and newlib recipes, provide functionality to make them extendable by other libraries if required, and also create a new TCLIBC variant, which can now be set to newlib to build the toolchain for applications where its suitable.

Newlib is also usually used by vendors to provide embedded toolchains, which is interesting since, this enables OE to build such toolchains in a somewhat automated way.

These patches have been tested on my end in the following ways:

- meta-toolchain builds successfully on qemux86, qemux86-64, qemuarm, qemuarm64, qemuppc, qemumips.
- A helloworld application that lays in another layer was built for qemux86, qemux86-64 qemuarm, qemuarm64, qemuppc, qemumips, and it seems to have been built correctly.
- The hardware that I have available is from Xilinx, where Xilinx already had a baremetal application they ran on it, I was able to build the same application with a recipe, that used the toolchain coming from these patches (TCLIBC=newlib). I ran the application on hardware and confirmed that it was built and working correctly.
- meta-toolchain builds successfully for the previously mentioned HW MACHINE as well.
- I also have a meta-freertos (its a possibility) layer that builds a FreeRTOS application that runs on qemuarm, and instead of using the provided ARM Embedded Toolchain, I used the one coming from these patches and was able to obtain the same result.
- I built world for all the previously mentioned MACHINES (qemus and HW) just to make sure that this did not affect other OE components, and it did not seem to be the case.

The following changes since commit 7897fb35a3420c2555ab59dfa438217ada4a9784:

libnss-mdns: fix postinst and postrm (2018-05-22 13:13:33 +0100)

are available in the git repository at:

git://push.yoctoproject.org/poky-contrib aehs29/newlib

Alejandro Enedino Hernandez Samaniego (3):
newlib: Adds newlib and libgloss recipes insane.bbclass: Adds powerpc to elf headers machine dictionary
tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C
library

 meta/classes/cross-canadian.bbclass                |  2 +-
 meta/classes/insane.bbclass                        |  1 +
 meta/conf/distro/include/tclibc-newlib.inc         | 47 ++++++++++++++++++
 .../newlib/libgloss/fix-rs6000-crt0.patch          | 41 +++++++++++++++
 .../libgloss/fix_makefile_include_arm_h.patch      | 30 +++++++++++
 meta/recipes-core/newlib/libgloss_3.0.0.bb         | 32 ++++++++++++
 meta/recipes-core/newlib/newlib.inc                | 58 ++++++++++++++++++++++
 meta/recipes-core/newlib/newlib_3.0.0.bb           | 19 +++++++
 meta/recipes-devtools/gcc/gcc-cross.inc            |  1 +
 meta/recipes-devtools/gcc/libgcc-common.inc        |  5 ++
 10 files changed, 235 insertions(+), 1 deletion(-)
 create mode 100644 meta/conf/distro/include/tclibc-newlib.inc
 create mode 100644 meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch
 create mode 100644 meta/recipes-core/newlib/libgloss/fix_makefile_include_arm_h.patch
 create mode 100644 meta/recipes-core/newlib/libgloss_3.0.0.bb
 create mode 100644 meta/recipes-core/newlib/newlib.inc
 create mode 100644 meta/recipes-core/newlib/newlib_3.0.0.bb

--
2.7.4

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#3 lore raw

PATCH 3/3 tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library

This patch adds the posibility to build using TCLIBC=newlib.

It allows users to build baremetal applications with the use of a C library.

Newlib is a lightweight C library meant to be used on embedded systems, it is meant to be easily portable for new platforms and to provide basic functionality on them, by design, it provides stubs for some of these core functions declared as weak, so they can be built correctly and then linked against some other library which provides specifics about the platform being used if need be, libgloss takes care of these in some cases, but it can also be extended, this patch also allows the user to easily add other libraries to it by adding them to NEWLIB_EXTENDED for this specific reason.

---
 meta/classes/cross-canadian.bbclass         |  2 +-
 meta/conf/distro/include/tclibc-newlib.inc  | 47 +++++++++++++++++++++++++++++
 meta/recipes-core/newlib/newlib_3.0.0.bb    |  3 ++
 meta/recipes-devtools/gcc/libgcc-common.inc |  5 +++
 4 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 meta/conf/distro/include/tclibc-newlib.inc
meta/classes/cross-canadian.bbclass +1 -1
index ee8aa61..7f9a69b 100644
@@ -30,7 +30,7 @@ python () {
     if d.getVar("MODIFYTOS") != "1":
         return
 
-    if d.getVar("TCLIBC") == "baremetal":
+    if (d.getVar("TCLIBC") == "baremetal") or (d.getVar("TCLIBC") == "newlib"):
         return
 
     tos = d.getVar("TARGET_OS")
meta/conf/distro/include/tclibc-newlib.inc new file +47 -0

47 lines not on this page · raw message

meta/recipes-core/newlib/newlib_3.0.0.bb +3 -0
index 3380576..09238fe 100644
@@ -14,3 +14,6 @@ do_install_append() {
        # Remove original directory
        rmdir ${D}${prefix}/${TARGET_SYS}
 }
+
+# No rpm package is actually created but -dev depends on it, avoid dnf error
+RDEPENDS_${PN}-dev_libc-newlib = ""
meta/recipes-devtools/gcc/libgcc-common.inc +5 -0
index 848a476..d959566 100644
@@ -47,8 +47,13 @@ do_install () {
 do_install_append_libc-baremetal () {
        rmdir ${D}${base_libdir}
 }
+do_install_append_libc-newlib () {
+       rmdir ${D}${base_libdir}
+}
 
+# No rpm package is actually created but -dev depends on it, avoid dnf error
 RDEPENDS_${PN}-dev_libc-baremetal = ""
+RDEPENDS_${PN}-dev_libc-newlib = ""
 
 BBCLASSEXTEND = "nativesdk"
 

--
2.7.4

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#1 lore raw

PATCH 1/3 newlib: Adds newlib and libgloss recipes

In reply to Alejandro Enedino Hernandez Samaniego

Newlib is a C library that is intended to be used on embedded systems. It is a conglomeration of several library parts, all under free software licenses that make them easily usable on embedded products.

Newlib provides a C library alternative that can run on baremetal, mainly for resource constrained devices.

Libgloss is the BSP part of the C library, which can be easily modified to port for new hardware platforms.

---
 .../newlib/libgloss/fix-rs6000-crt0.patch          | 41 +++++++++++++++
 .../libgloss/fix_makefile_include_arm_h.patch      | 30 +++++++++++
 meta/recipes-core/newlib/libgloss_3.0.0.bb         | 32 ++++++++++++
 meta/recipes-core/newlib/newlib.inc                | 58 ++++++++++++++++++++++
 meta/recipes-core/newlib/newlib_3.0.0.bb           | 16 ++++++
 meta/recipes-devtools/gcc/gcc-cross.inc            |  1 +
 6 files changed, 178 insertions(+)
 create mode 100644 meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch
 create mode 100644 meta/recipes-core/newlib/libgloss/fix_makefile_include_arm_h.patch
 create mode 100644 meta/recipes-core/newlib/libgloss_3.0.0.bb
 create mode 100644 meta/recipes-core/newlib/newlib.inc
 create mode 100644 meta/recipes-core/newlib/newlib_3.0.0.bb
meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch new file +41 -0
new file mode 100644
index 0000000..c220fb8
@@ -0,0 +1,41 @@
+Upstream-Status: Inappropriate  [OE-Specific]
+
+Make install tries to perform install for all variants, but some of them use the same
+name for crt0 in specific, so performing all of them results in an error during
+do_install, we simply modify the name of the objects so the installation can proceed
+and leave it to the user to select which object files to use.
+
+Signed-off-by: Alejandro Enedino Hernandez Samaniego <[email protected]>
+
+Index: newlib-3.0.0/libgloss/rs6000/Makefile.in
+===================================================================
+--- newlib-3.0.0.orig/libgloss/rs6000/Makefile.in
++++ newlib-3.0.0/libgloss/rs6000/Makefile.in
+@@ -358,7 +358,7 @@ install-sim:
+       set -e; for x in ${SIM_CRT0} ${SIM_BSP} ${SIM_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-mvme:
+-      set -e; for x in ${MVME_CRT0} ${MVME_BSP} ${MVME_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
++      set -e; for x in ${MVME_CRT0} ${MVME_BSP} ${MVME_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/mvme-$$x; done
+
+ install-solaris:
+       set -e; for x in ${SOLARIS_CRT0} ${SOLARIS_BSP} ${SOLARIS_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+@@ -367,15 +367,15 @@ install-linux:
+       set -e; for x in ${LINUX_CRT0} ${LINUX_BSP} ${LINUX_SCRIPTS}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-yellowknife:
+-      set -e; for x in ${YELLOWKNIFE_CRT0} ${YELLOWKNIFE_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
++      set -e; for x in ${YELLOWKNIFE_CRT0} ${YELLOWKNIFE_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/yellowknife-$$x; done
+       set -e; for x in ${YELLOWKNIFE_SCRIPTS}; do ${INSTALL_DATA} $(srcdir)/$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-ads:
+-      set -e; for x in ${ADS_CRT0} ${ADS_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
++      set -e; for x in ${ADS_CRT0} ${ADS_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/ads-$$x; done
+       set -e; for x in ${ADS_SCRIPTS}; do ${INSTALL_DATA} $(srcdir)/$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-mbx:
+-      set -e; for x in ${MBX_CRT0} ${MBX_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
++      set -e; for x in ${MBX_CRT0} ${MBX_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/mbx-$$x; done
+       set -e; for x in ${MBX_SCRIPTS} ${MBX_SPECS}; do ${INSTALL_DATA} $(srcdir)/$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
+
+ install-xil:
meta/recipes-core/newlib/libgloss/fix_makefile_include_arm_h.patch new file +30 -0
new file mode 100644
index 0000000..7645be7
@@ -0,0 +1,30 @@
+Upstream-Status: Inappropriate  [OE-Specific]
+
+When trying to build libgloss for an arm target, the build system
+complains about missing some include files:
+
+| fatal error: acle-compiat.h: No such file or directory
+|  #include "acle-compat.h"
+|           ^~~~~~~~~~~~~~~
+| compilation terminated.
+
+These include files come from the newlib source, but since we
+are building libgloss separately from newlib, libgloss is unaware
+of where they are, this patch fixes the INCLUDES so the build system
+can find such files.
+
+Signed-off-by: Alejandro Enedino Hernandez Samaniego <[email protected]>
+
+Index: newlib-3.0.0/libgloss/config/default.mh
+===================================================================
+--- newlib-3.0.0.orig/libgloss/config/default.mh
++++ newlib-3.0.0/libgloss/config/default.mh
+@@ -1,7 +1,7 @@
+ NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
+ NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
+
+-INCLUDES = -I. -I$(srcdir)/..
++INCLUDES = -I. -I$(srcdir)/.. -I$(srcdir)/../newlib/libc/machine/arm
+ # Note that when building the library, ${MULTILIB} is not the way multilib
+ # options are passed; they're passed in $(CFLAGS).
+ CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
meta/recipes-core/newlib/libgloss_3.0.0.bb new file +32 -0
new file mode 100644
index 0000000..664a922
@@ -0,0 +1,32 @@
+require newlib.inc
+
+DEPENDS += "newlib"
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/libgloss:"
+
+SRC_URI_append_powerpc = " file://fix-rs6000-crt0.patch"
+SRC_URI_append_arm = " file://fix_makefile_include_arm_h.patch"
+
+do_configure() {
+       ${S}/libgloss/configure ${EXTRA_OECONF}
+}
+
+do_install_prepend() {
+       # install doesn't create this itself, avoid install error
+       install -d ${D}${prefix}/${TARGET_SYS}/lib
+}
+
+do_install_append() {
+       # Move libs to default directories so they can be picked up later
+       mv -v ${D}${prefix}/${TARGET_SYS}/lib ${D}${libdir}
+
+       # Remove original directory
+       rmdir ${D}${prefix}/${TARGET_SYS}
+}
+
+# Split packages correctly
+FILES_${PN} += "${libdir}/*.ld ${libdir}/*.specs"
+FILES_${PN}-dev += "${libdir}/cpu-init/*"
+
+INHIBIT_PACKAGE_STRIP = "1"
+INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
meta/recipes-core/newlib/newlib.inc new file +58 -0

58 lines not on this page · raw message

meta/recipes-core/newlib/newlib_3.0.0.bb new file +16 -0
new file mode 100644
index 0000000..3380576
@@ -0,0 +1,16 @@
+require newlib.inc
+
+PROVIDES += "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc virtual/libiconv virtual/libintl"
+
+do_configure() {
+       ${S}/configure ${EXTRA_OECONF}
+}
+
+do_install_append() {
+       # Move include files and libs to default directories so they can be picked up later
+       mv -v ${D}${prefix}/${TARGET_SYS}/lib ${D}${libdir}
+       mv -v ${D}${prefix}/${TARGET_SYS}/include ${D}${includedir}
+
+       # Remove original directory
+       rmdir ${D}${prefix}/${TARGET_SYS}
+}
meta/recipes-devtools/gcc/gcc-cross.inc +1 -0
index 1e184a6..95f5968 100644
@@ -35,6 +35,7 @@ EXTRA_OECONF += "\
 DEPENDS_remove_libc-baremetal := "virtual/${TARGET_PREFIX}libc-for-gcc"
 EXTRA_OECONF_append_libc-baremetal = " --without-headers"
 EXTRA_OECONF_remove_libc-baremetal = "--enable-threads=posix"
+EXTRA_OECONF_remove_libc-newlib = "--enable-threads=posix"
 
 EXTRA_OECONF_PATHS = "\
     --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \

--
2.7.4

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#4 lore raw

Re: [PATCH 3/3] tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C library

In reply to Alejandro Enedino Hernandez Samaniego
Quoted 29 lines · Alejandro Enedino Hernandez Samaniego

This patch adds the posibility to build using TCLIBC=newlib.

It allows users to build baremetal applications with the use of a C library.

Newlib is a lightweight C library meant to be used on embedded systems, it is meant to be easily portable for new platforms and to provide basic functionality on them, by design, it provides stubs for some of these core functions declared as weak, so they can be built correctly and then linked against some other library which provides specifics about the platform being used if need be, libgloss takes care of these in some cases, but it can also be extended, this patch also allows the user to easily add other libraries to it by adding them to NEWLIB_EXTENDED for this specific reason.

---
 meta/classes/cross-canadian.bbclass         |  2 +-
 meta/conf/distro/include/tclibc-newlib.inc  | 47 +++++++++++++++++++++++++++++
 meta/recipes-core/newlib/newlib_3.0.0.bb    |  3 ++
 meta/recipes-devtools/gcc/libgcc-common.inc |  5 +++
 4 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 meta/conf/distro/include/tclibc-newlib.inc
meta/classes/cross-canadian.bbclass +0 -0
index ee8aa61..7f9a69b 100644

meta/classes/cross-canadian.bbclass python () { · line 33

Quoted 5 lines
meta/classes/cross-canadian.bbclass +1 -1
@@ -30,7 +30,7 @@ python () {
     if d.getVar("MODIFYTOS") != "1":
         return
 
-    if d.getVar("TCLIBC") == "baremetal":
+    if (d.getVar("TCLIBC") == "baremetal") or (d.getVar("TCLIBC") == "newlib"):

Or maybe:

if d.getVar("TCLIBC") in [ 'baremetal', 'newlib' ]:

Quoted 9 lines
meta/classes/cross-canadian.bbclass +0 -0
         return
 
     tos = d.getVar("TARGET_OS")
meta/conf/distro/include/tclibc-newlib.inc new file +0 -0
new file mode 100644
index 0000000..a5e63d0

meta/conf/distro/include/tclibc-newlib.inc line 9

Quoted 9 lines
meta/conf/distro/include/tclibc-newlib.inc new file +9 -0
@@ -0,0 +1,47 @@
+#
+# Newlib configuration
+#
+
+LIBCEXTENSION = "-newlib"
+
+# Add newlib libc overrides to the overrides.
+LIBCOVERRIDE = ":libc-newlib"
+OVERRIDES .= "${LIBCOVERRIDE}"

This will need to be updated to align with recent changes in master:

http://git.openembedded.org/openembedded-core/commit/?id=b3598b8f1ed1cdc7849e1e4f30d618e87e1bf582

Quoted 15 lines
meta/conf/distro/include/tclibc-newlib.inc new file +15 -0
+PREFERRED_PROVIDER_virtual/libc ?= "newlib"
+PREFERRED_PROVIDER_virtual/libiconv ?= "newlib"
+PREFERRED_PROVIDER_virtual/libintl ?= "newlib"
+PREFERRED_PROVIDER_virtual/nativesdk-libintl ?= "nativesdk-glibc"
+PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?= "nativesdk-glibc"
+
+DISTRO_FEATURES_BACKFILL_CONSIDERED += "ldconfig"
+
+#USE_NLS ?= "no"
+
+IMAGE_LINGUAS = ""
+
+LIBC_DEPENDENCIES = "\
+    newlib-dbg \
+    newlib-dev \

meta/conf/distro/include/tclibc-newlib.inc line 35

Quoted 10 lines
meta/conf/distro/include/tclibc-newlib.inc new file +10 -0
+    libgloss \
+    libgloss-dev \
+    libgloss-dbg \
+    libgcc-dev \
+    libgcc-dbg \
+    "
+
+# compilerlibs defaults to gcc-runtime, but we get runtime from libgloss
+# we set ASSUME_PROVIDED because we cant set PREFERRED_PROVIDER
+# for compilerlibs since its overriden by tcmode-default

overriden -> overridden

Quoted 50 lines
meta/conf/distro/include/tclibc-newlib.inc new file +12 -0
+ASSUME_PROVIDED += "virtual/${TARGET_PREFIX}compilerlibs virtual/crypt"
+
+# Its useful to be able to extend newlib, but we dont provide a native variant of libgloss
+NEWLIB_EXTENDED ?=  "libgloss libgcc"
+BASE_DEFAULT_DEPS_append_class-target = " ${NEWLIB_EXTENDED}"
+
+TARGET_OS = "elf"
+TARGET_OS_arm = "eabi"
+
+TOOLCHAIN_HOST_TASK ?= "packagegroup-cross-canadian-${MACHINE}"
+TOOLCHAIN_TARGET_TASK ?= "${LIBC_DEPENDENCIES}"
+TOOLCHAIN_NEED_CONFIGSITE_CACHE_remove = "zlib ncurses"
meta/recipes-core/newlib/newlib_3.0.0.bb +3 -0
index 3380576..09238fe 100644
@@ -14,3 +14,6 @@ do_install_append() {
        # Remove original directory
        rmdir ${D}${prefix}/${TARGET_SYS}
 }
+
+# No rpm package is actually created but -dev depends on it, avoid dnf error
+RDEPENDS_${PN}-dev_libc-newlib = ""
meta/recipes-devtools/gcc/libgcc-common.inc +5 -1
index 848a476..d959566 100644
@@ -47,8 +47,13 @@ do_install () {
 do_install_append_libc-baremetal () {
        rmdir ${D}${base_libdir}
 }
+do_install_append_libc-newlib () {
+       rmdir ${D}${base_libdir}
+}
 
+# No rpm package is actually created but -dev depends on it, avoid dnf error
 RDEPENDS_${PN}-dev_libc-baremetal = ""
+RDEPENDS_${PN}-dev_libc-newlib = ""
 
 BBCLASSEXTEND = "nativesdk"
 
--

2.7.4

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately. --
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Acked-by Manjukumar Matha on the v1 series
#5 lore raw
In reply to Alejandro Enedino Hernandez Samaniego
Quoted 41 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Alejandro Enedino Hernandez Samaniego
Sent: Wednesday, May 23, 2018 4:09 PM
To: [email protected]
Subject: [OE-core] [PATCH 0/3] Add Newlib as a C library for baremetal

Newlib is a widely used C library for embedded systems, its mainly used for resource constrained devices which run baremetal applications.

It provides basic C library functionality, and it is meant to be extended by design, it contains several stubs for core functions that can be later overriden with the symbols provided from another library at linking time.

Libgloss is the BSP part of the library which follows the same principle, where a BSP layer can override functionality or even application runtime depending on the processor architecture.

These patches add both the libgloss and newlib recipes, provide functionality to make them extendable by other libraries if required, and also create a new TCLIBC variant, which can now be set to newlib to build the toolchain for applications where its suitable.

Newlib is also usually used by vendors to provide embedded toolchains, which is interesting since, this enables OE to build such toolchains in a somewhat automated way.

These patches have been tested on my end in the following ways:

- meta-toolchain builds successfully on qemux86, qemux86-64, qemuarm, qemuarm64,
qemuppc, qemumips.
- A helloworld application that lays in another layer was built for qemux86, qemux86-64
qemuarm, qemuarm64, qemuppc, qemumips, and it seems to have been built
correctly.
- The hardware that I have available is from Xilinx, where Xilinx already had a baremetal application they ran on it, I was able to build the same application

Quoted 8 lines

with a recipe, that used the toolchain coming from these patches
(TCLIBC=newlib).
I ran the application on hardware and confirmed that it was built and working
correctly.
- meta-toolchain builds successfully for the previously mentioned HW MACHINE as well.
- I also have a meta-freertos (its a possibility) layer that builds a FreeRTOS application

Can we put out this layer on github for evaluation? Community member is interested in such a layer?

Quoted 32 lines

that runs on qemuarm, and instead of using the provided ARM Embedded
Toolchain, I used
the one coming from these patches and was able to obtain the same result.
- I built world for all the previously mentioned MACHINES (qemus and HW) just to make sure
that this did not affect other OE components, and it did not seem to be the case.

The following changes since commit
7897fb35a3420c2555ab59dfa438217ada4a9784:

libnss-mdns: fix postinst and postrm (2018-05-22 13:13:33 +0100)

are available in the git repository at:

git://push.yoctoproject.org/poky-contrib aehs29/newlib

Alejandro Enedino Hernandez Samaniego (3):
newlib: Adds newlib and libgloss recipes insane.bbclass: Adds powerpc to elf headers machine dictionary
tclibc-newlib: Adds a new TCLIBC variant to build with newlib as C
library

 meta/classes/cross-canadian.bbclass                |  2 +-
 meta/classes/insane.bbclass                        |  1 +
 meta/conf/distro/include/tclibc-newlib.inc         | 47 ++++++++++++++++++
 .../newlib/libgloss/fix-rs6000-crt0.patch          | 41 +++++++++++++++
 .../libgloss/fix_makefile_include_arm_h.patch      | 30 +++++++++++
 meta/recipes-core/newlib/libgloss_3.0.0.bb         | 32 ++++++++++++
 meta/recipes-core/newlib/newlib.inc                | 58 ++++++++++++++++++++++
 meta/recipes-core/newlib/newlib_3.0.0.bb           | 19 +++++++
 meta/recipes-devtools/gcc/gcc-cross.inc            |  1 +
 meta/recipes-devtools/gcc/libgcc-common.inc        |  5 ++
Quoted 9 lines
 10 files changed, 235 insertions(+), 1 deletion(-)  create mode 100644
meta/conf/distro/include/tclibc-newlib.inc
 create mode 100644 meta/recipes-core/newlib/libgloss/fix-rs6000-crt0.patch
 create mode 100644 meta/recipes-
core/newlib/libgloss/fix_makefile_include_arm_h.patch
 create mode 100644 meta/recipes-core/newlib/libgloss_3.0.0.bb
 create mode 100644 meta/recipes-core/newlib/newlib.inc
 create mode 100644 meta/recipes-core/newlib/newlib_3.0.0.bb

Thanks,
Manju