Merge ~dirk.zimoch/epics-base:raspberryPi into ~epics-core/epics-base/+git/epics-base:7.0

Proposed by Dirk Zimoch
Status: Rejected
Rejected by: Andrew Johnson
Proposed branch: ~dirk.zimoch/epics-base:raspberryPi
Merge into: ~epics-core/epics-base/+git/epics-base:7.0
Diff against target: 92 lines (+80/-0)
2 files modified
configure/os/CONFIG.Common.raspbian-arm (+11/-0)
configure/os/CONFIG_SITE.Common.raspbian-arm (+69/-0)
Reviewer Review Type Date Requested Status
Andrew Johnson Disapprove
mdavidsaver Disapprove
Review via email: mp+367256@code.launchpad.net

Description of the change

Configuration file for raspberryPi added.

To post a comment you must log in.
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

Do you have references to upstream bug reports?

I've never encountered problems like this with the hosted compiler.

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

I hadn't come across https://github.com/raspberrypi/tools previously. Having seen it, I don't think I would ever use it!

Judging by the (3 year old) commit message, these binaries are from a crosstool-ng built, not the native raspbian. ABI mis-matches with the raspian toolchain are to be expected.

fyi. seeing linking issues involving libtinfo.so is a sign of mixing debian and non-debian builds of readline.

If you use this toolchain then imo. full static linking (including libc) is a must!

If interop with raspbian libs is desirable, then I'd suggest looking at QEMU user mode emulation to run the hosted toolchain.

https://wiki.debian.org/RaspberryPi/qemu-user-static

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

> Do you have references to upstream bug reports?
>
> I've never encountered problems like this with the hosted compiler.

What problem? This is no bugfix. I just wanted to share my setup to cross-compile for raspberryPi. Maybe it is useful for others wanting to use EPICS on a pi.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

> I hadn't come across https://github.com/raspberrypi/tools previously. Having
> seen it, I don't think I would ever use it!
>
> Judging by the (3 year old) commit message, these binaries are from a
> crosstool-ng built, not the native raspbian. ABI mis-matches with the raspian
> toolchain are to be expected.

There is a comment about readline in the file.

>
> fyi. seeing linking issues involving libtinfo.so is a sign of mixing debian
> and non-debian builds of readline.
>
> If you use this toolchain then imo. full static linking (including libc) is a
> must!
>
> If interop with raspbian libs is desirable, then I'd suggest looking at QEMU
> user mode emulation to run the hosted toolchain.
>
> https://wiki.debian.org/RaspberryPi/qemu-user-static

This was the "official" cross tool chain, AFAIK.

Revision history for this message
Andrew Johnson (anj) wrote :

Is this configuration intended for cross-building? Have you used it for building native as well?

The EPICS build system was designed so that end-users should never have to modify any CONFIG.* files to build Base, they should only edit CONFIG_SITE.* files, so your SDK_TARGET value should get in a CONFIG_SITE.* file. If this configuration is used for cross-building only then it really belongs in a CONFIG_SITE.<host-arch>.raspbian-arm file, the CONFIG.Common.<target-arch> files are for things that really are specific to the target irrespective of where the code is being compiled.

I have asked Pete Jemian who has lots of experience with running EPICS on the Pi for his comments too.

Revision history for this message
Andrew Johnson (anj) wrote :

There seem to be a number of possibilities for Raspbian cross-building, the various answers to the stack-overflow question at https://stackoverflow.com/questions/19162072/how-to-install-the-raspberry-pi-cross-compiler-on-my-linux-host-machine show several options. The Github tool-chain that Dirk is using does seem to be the "official" one. A fairly comprehensive alternative set with more recent versions is available at https://github.com/abhiTronix/raspberry-pi-cross-compilers

There is also a post on Medium at https://medium.com/@au42/the-useful-raspberrypi-cross-compile-guide-ea56054de187 that covers resolving library issues using the official tool-chain, but it's configuring application builds using CMAKE and I haven't looked at it in detail.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

> Is this configuration intended for cross-building? Have you used it for
> building native as well?

This is for cross build. Native builds do not need to care for SDK locations. But I like to cross build for all our archs.

> The EPICS build system was designed so that end-users should never have to
> modify any CONFIG.* files to build Base, they should only edit CONFIG_SITE.*
> files, so your SDK_TARGET value should get in a CONFIG_SITE.* file. If this
> configuration is used for cross-building only then it really belongs in a
> CONFIG_SITE.<host-arch>.raspbian-arm file, the CONFIG.Common.<target-arch>
> files are for things that really are specific to the target irrespective of
> where the code is being compiled.

This is simply how I got it working. I‘ll try to separate it into user config and generic settings.

>
> I have asked Pete Jemian who has lots of experience with running EPICS on the
> Pi for his comments too.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

> There seem to be a number of possibilities for Raspbian cross-building, the
> various answers to the stack-overflow question at
> https://stackoverflow.com/questions/19162072/how-to-install-the-raspberry-pi-
> cross-compiler-on-my-linux-host-machine show several options. The Github tool-
> chain that Dirk is using does seem to be the "official" one. A fairly
> comprehensive alternative set with more recent versions is available at
> https://github.com/abhiTronix/raspberry-pi-cross-compilers
>
> There is also a post on Medium at https://medium.com/@au42/the-useful-
> raspberrypi-cross-compile-guide-ea56054de187 that covers resolving library
> issues using the official tool-chain, but it's configuring application builds
> using CMAKE and I haven't looked at it in detail.

I‘ll try to support them as well. I had stopped looking for alternatives once I had a working solution.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :
Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

I could build from cross-pi-gcc-8.3.0-1 with readline but had to manually copy the readline headers, readline library and tinfo library (plus links) to the cross toolchain.

~dirk.zimoch/epics-base:raspberryPi updated
56a4bb5... by Dirk Zimoch

moved user configuration to CONFIG_SITE file and support cross-pi-gcc tool chain

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

> There seem to be a number of possibilities for Raspbian cross-building

Actually, there are few options for cross-compiling for Raspbian. I'm specifically referring to the Debian derived distro. Raspbian doesn't provide any "official" cross-compiler binaries. Variations on the qemu-user approach are the only ones I would expect to produce guaranteed ABI compatible binaries. There are docker/lxc approaches which might be more palatable than the manual chroot() recipe I linked.

If you aren't willing/able to use qemu-user, then I would advising using buildroot to replace the raspbian image entirely.

When evaluating a particular recipe. Look for mentions of a specific Raspbian release name/version, or copying from a live Pi. Anything else is likely to be a variation on crosstool-ng, and have the same ABI issues you've encountered.

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

Maybe a wiki page or blog post would be a more appropriate place to document this build recipe?

review: Needs Fixing
Revision history for this message
Andrew Johnson (anj) wrote :

I heard back from Pete Jemian, who wrote:

----------------------- 8< -----------------------

Agree that Dirk references the official RPi tools for cross-compile. I have very little experience with getting that tool chain to work and only rely on native builds for EPICS base. (Those are easy and do not require any custom files.) The abhiTronix/raspberry-pi-cross-compilers repo is very new (August 2018) with one contributor. Haven't tried this yet. This tool chain might be much easier to assemble than the official one.

The proposed changes benefit those who use cross-compilers for the RPi. If merged, the changes should not affect native builds.

----------------------- 8< -----------------------

I like Michael's suggestion that a lot of this information might make more sense as a Wiki, blog or tech-talk post. Updating it then wouldn't have to synchronize with Base releases.

You might also consider splitting your CONFIG_SITE file into CONFIG_SITE.linux-x86.raspbian-arm and CONFIG_SITE.linux-x86_64.raspbian-arm where you would put all the parts specific to a 32-bit host into the first file and the 64-bit parts into the second.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

The 32 bit tool chains work on 64 bit hosts as well (as long as 32 bit libs are installed).
Much here depends on the host. I have tried to hive as much information as possible that the user has a choice. I doubt that it is possible to split the configuration in way that makes it more easy to get the correct settings. It only makes information harder to find.

Any suggestions as to where the documentation may go? I found something here: http://prjemian.github.io/epicspi/ (linked from https://wiki-ext.aps.anl.gov/epics/index.php/HowTo_Documents). It says: "EPICS Base is very easy to build. The wheezy-raspbian distribution already has all the tools necessary to build EPICS Base. All that is necessary is to define the host architecture and then build it." But it does not say how. And it seems it refers to a native build not a cross build.

I can add an article to https://wiki-ext.aps.anl.gov/epics about how to cross compile for raspberry pi. (If you create a login for me). Then all this information including an the example config file can go there and we can leave this here out of EPICS base.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

Seems I already had an account for the EPICS wiki.

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

I still don't think that configure/ is the right place to document this recipe.

Also, I dusted off my pi3 and tried a buildroot image. It worked on the first go.

https://github.com/buildroot/buildroot/tree/master/board/raspberrypi

review: Disapprove
Revision history for this message
Andrew Johnson (anj) wrote :

Group 10/4: Disapprove this solution.

review: Disapprove

Unmerged commits

56a4bb5... by Dirk Zimoch

moved user configuration to CONFIG_SITE file and support cross-pi-gcc tool chain

9866f3e... by Dirk Zimoch

support for raspberryPi addedconfigure/os/CONFIG.Common.raspbian-arm

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/configure/os/CONFIG.Common.raspbian-arm b/configure/os/CONFIG.Common.raspbian-arm
0new file mode 1006440new file mode 100644
index 0000000..206d984
--- /dev/null
+++ b/configure/os/CONFIG.Common.raspbian-arm
@@ -0,0 +1,11 @@
1# CONFIG.Common.raspbian-arm
2#
3# Definitions for raspbian-arm target cross-builds
4# Override these settings in CONFIG_SITE.Common.raspbian-arm
5#-------------------------------------------------------
6
7# Include definitions common to all Linux ARM targets
8include $(CONFIG)/os/CONFIG.Common.linux-arm
9
10GNU_DIR = $(if $(filter %/arm-bcm2708,$(SDK_DIR)),$(SDK_DIR)/$(SDK_TARGET),$(SDK_DIR))
11GNU_TARGET = $(if $(filter arm-bcm2708%,$(SDK_TARGET)),$(SDK_TARGET),arm-linux-gnueabihf)
diff --git a/configure/os/CONFIG_SITE.Common.raspbian-arm b/configure/os/CONFIG_SITE.Common.raspbian-arm
0new file mode 10064412new file mode 100644
index 0000000..e7fddc3
--- /dev/null
+++ b/configure/os/CONFIG_SITE.Common.raspbian-arm
@@ -0,0 +1,69 @@
1# CONFIG_SITE.Common.raspbian-arm
2#
3# Site-specific information for raspbian-arm target cross-builds
4#---------------------------------------------------------------
5
6# Tested on:
7# Raspberry Pi 3B+ Raspbian 9
8# Raspberry Pi 2 Raspbian 7
9
10# Two different cross tool chains are supported,
11# either from https://github.com/raspberrypi/tools
12# (the "arm-bcm2708" tool chain)
13# or from https://sourceforge.net/projects/raspberry-pi-cross-compilers.
14# (the "cross-pi-gcc" tool chain).
15
16# Using the arm-bcm2708 tool chain.
17#
18# This tool chains offers 5 different pre-compiled targets. Which one
19# can be used depends on the glibc version installed on the host computer.
20#
21# Can be installed anywhere, e.g:
22SDK_DIR = /opt/raspberrypi/tools-master/arm-bcm2708
23#
24# Available SDK_TARGETs for arm-bcm2708 SDK:
25#
26# gcc 4.8.3 for 32 bit hosts with GLIBC 2.3 or higher
27SDK_TARGET = gcc-linaro-arm-linux-gnueabihf-raspbian
28#
29# gcc 4.7.1 for 64 bit hosts with GLIBC 2.14 or higher
30# SDK_TARGET = arm-linux-gnueabihf
31#
32# gcc 4.8.3 for 64 bit hosts with GLIBC 2.14 or higher
33# SDK_TARGET = gcc-linaro-arm-linux-gnueabihf-raspbian-x64
34#
35# gcc 4.7.1 for 32 bit hosts with GLIBC 2.4 or higher
36# SDK_TARGET = arm-bcm2708hardfp-linux-gnueabi
37# SDK_TARGET = arm-bcm2708-linux-gnueabi
38
39
40# Using the cross-pi-gcc tool chain.
41#
42# gcc 8.3.0 for 64 bit hosts with GLIBC 2.14 or higher.
43# Must be installed at the following location:
44# SDK_DIR = /opt/cross-pi-gcc-8.3.0-1
45
46
47# Using readline:
48#
49# Due to missing/messed up libs and missing headers in both toolchains,
50# readline needs copies of libtinfo.so.5.9 and libreadline.so.6.2 from
51# a Raspbian 7 rootfs /lib/arm-linux-gnueabihf/ to the toolchain, e.g.
52# $(SDK_DIR)/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/lib/arm-linux-gnueabihf/
53# or /opt/cross-pi-gcc-8.3.0-1/arm-linux-gnueabihf/lib/, depending on
54# the used toolchain, and manually created links libtinfo.so.5 and libreadline.so.
55#
56# For SDK_TARGET gcc-linaro-arm-linux-gnueabihf-raspbian, an existing incompatible
57# libtinfo.so.5 is in the way. Remove it.
58# (Built with glibc 2.16 like installed on Raspbian 9 but toolchain uses glibc 2.13.)
59#
60# The cross-pi-gcc toolchain is also missing libtinfo.so* as well. Copy the file and links
61# from /lib/arm-linux-gnueabihf/ to /opt/cross-pi-gcc-8.3.0-1/arm-linux-gnueabihf/lib/.
62#
63# Also copy the /usr/include/readline/ directory from some readline 6 installation
64# to $(SDK_DIR)/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/usr/include/
65# or /opt/cross-pi-gcc-8.3.0-1/arm-linux-gnueabihf/include/, depending on the
66# used toolchain.
67#
68# Once the above fixes are applied, uncomment the next line.
69# COMMANDLINE_LIBRARY = READLINE

Subscribers

People subscribed via source and target branches