Help Compiling armv6 Ports from x64

Sean Bruno sbruno at ignoranthack.me
Fri Dec 26 21:11:16 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 12/25/14 07:17, Jeremy Brown wrote:
> Sean,
> 
> It seems the binmiscctl command was the last part of the puzzle,
> now everything's working. But I have one last issue I'm trying to
> solve:
> 
> Now I'm trying to use the x64 cross compiler instead of emulating
> through the arm one. I've copied my toolchain over and I've set up
> variables for CC, et al to refer to the x64 versions in
> /root/.profile, but I can't get make to pick up on them. Is there
> something else I need to do?
> 
> -Jeremy

I think these things are actually controlled by /etc/make.conf in the
jail/chroot that you are using.

e.g. poudriere sets up some CC= and friends that does some of this for
me, but you'll have to replicate by hand:

% cat /usr/local/poudriere/jails/11-armv6/etc/make.conf
CC=/nxb-bin/usr/bin/cc
CPP=/nxb-bin/usr/bin/cpp
CXX=/nxb-bin/usr/bin/c++
AS=/nxb-bin/usr/bin/as
NM=/nxb-bin/usr/bin/nm
LD=/nxb-bin/usr/bin/ld
OBJCOPY=/nxb-bin/usr/bin/objcopy
SIZE=/nxb-bin/usr/bin/size
STRIPBIN=/nxb-bin/usr/bin/strip
SED=/nxb-bin/usr/bin/sed
READELF=/nxb-bin/usr/bin/readelf
RANLIB=/nxb-bin/usr/bin/ranlib
YACC=/nxb-bin/usr/bin/yacc
NM=/nxb-bin/usr/bin/nm
MAKE=/nxb-bin/usr/bin/make
STRINGS=/nxb-bin/usr/bin/strings
AWK=/nxb-bin/usr/bin/awk
FLEX=/nxb-bin/usr/bin/flex


> 
> On Wed, Dec 24, 2014 at 8:56 PM, Sean Bruno
> <sbruno at ignoranthack.me> wrote:
> 
> On 12/24/14 17:29, Jeremy Brown wrote:
>>>> Sean,
>>>> 
>>>> Does poudriere work with previously-established roots or does
>>>> it have to generate its own? I'm using crochet 
>>>> <https://github.com/kientzle/crochet-freebsd> to create my
>>>> image, so I can do whatever I want to the filesystem it
>>>> creates and have it apply to the image.
>>>> 
> 
> Poudirere's main purpose is to create a package repo for remote 
> installation.
> 
> So, I'm guessing that you don't want that.
> 
> What you "want" is the magical binmiscctl command on your host
> system and then copy /usr/local/qemu-user-arm into your jail.
> 
> Modify the binmiscctl(8) command I pointed you at below to point
> to /usr/local/bin/qemu-user-arm.
> 
> Then you should be able to "chroot" into your existing chroot and
> it will act like an arm box.  It will be slow, but currently
> there's no reliable way that I am aware of to get what you and
> other need done.
> 
> 
> sean
> 
>>>> Also, will poudriere actually install a package and modify 
>>>> necessary files to let the system know a port is installed,
>>>> or does it only create the package and leave it to me to
>>>> install?
>>>> 
>>>> -Jeremy
> 
> 
> 
> 
>>>> 
>>>> On Wed, Dec 24, 2014 at 8:16 PM, Sean Bruno 
>>>> <sbruno at ignoranthack.me> wrote:
>>>> 
>>>> On 12/24/14 16:34, Jeremy Brown wrote:
>>>>>>> I have a VM running FreeBSD 10.1 x64 that I'm trying to
>>>>>>> use to create an image that will run on a Raspberry Pi.
>>>>>>> I've managed to get the base system working, but I
>>>>>>> can't figure out how to compile ports for the image. I
>>>>>>> know my cross-compilation toolchain is working, as I
>>>>>>> can build the kernel and world without issue.
>>>>>>> 
>>>>>>> For sake of example, say my arm root is at /tmp/rootfs,
>>>>>>> my toolchain is at /usr/armv6-freebsd/usr/bin and some
>>>>>>> other assorted cross-compilation items are at 
>>>>>>> /usr/obj/armv6-freebsd.
>>>>>>> 
>>>>>>> Some of the commands I have tried to build a port are:
>>>>>>> 
>>>>>>> PATH=/path/to/toolchain:${PATH} make TARGET=arm 
>>>>>>> TARGET_ARCH=armv6 install (this typically fails during 
>>>>>>> compilation)
>>>>>>> 
>>>>>>> PATH=/path/to/toolchain:${PATH} make TARGET=arm 
>>>>>>> TARGET_ARCH=armv6 configure install (this typically
>>>>>>> fails during configuration, the error I get is
>>>>>>> something along the lines of "cannot read C-compiled
>>>>>>> file"; in addition the configure script never notices
>>>>>>> that I am trying to cross-compile)
>>>>>>> 
>>>>>>> PATH=/path/to/toolchain:${PATH} make 
>>>>>>> CONFIGURE_ARGS="--host=armv6-freebsd" configure
>>>>>>> install (this typically fails during compilation for
>>>>>>> varying reasons, but at least it'll recognize that I'm
>>>>>>> cross-compiling; including TARGET and TARGET_ARCH makes
>>>>>>> no difference)
>>>>>>> 
>>>>>>> make TARGET=arm TARGET_ARCH=armv6 DESTDIR=/tmp/rootfs 
>>>>>>> install (this was what I originally tried, when the
>>>>>>> chroot kicked in it would try to run the ARM version of
>>>>>>> /bin/sh; as the VM is x64 this would always give an
>>>>>>> exec format error before failing)
>>>>>>> 
>>>>>>> make TARGET=arm TARGET_ARCH=armv6 DESTDIR=/tmp/rootfs 
>>>>>>> CHROOTED=no install (this would seem to work, but
>>>>>>> would install the port to the VM instead of the
>>>>>>> filesystem for the image, and in addition would be
>>>>>>> compiled x64 instead of armv6)
>>>>>>> 
>>>>>>> There are others, but these are the ones I can remember
>>>>>>> the best right now. I understand there won't be any
>>>>>>> precompiled ports, and I don't want to have to build my
>>>>>>> desired ports on the Pi itself (despite the fact that
>>>>>>> doing so would be agonizingly slow, the space required
>>>>>>> to store the ports tree and compile what I need would
>>>>>>> explode the size of the image from ~400MB to
>>>>>>>> 2GB).
>>>>>>> 
>>>>>>> I've tried many different websites (see here 
>>>>>>> <http://www.cruwe.de/?p=78>, here <
>>>> 
> http://allskyee.blogspot.com/2014/02/freebsd-10-ports-cross-compile-amd64-to.html
>>>>>>>
>>>>>>>
>>>>>>>
>>>>
>>>>
>
> 
, here
>>>>>>> <
>>>> 
> http://ray-freebsd.blogspot.kr/2011/09/cross-compiling-ports-for-freebsd.html
>>>>>>>
>>>>>>>
>>>>>>>
>>>>
>>>>
>
> 
, here <http://blog.ignoranthack.me/?p=221>, here
>>>>>>> <
>>>> 
> http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037469.html
>>>>>>>
>>>>
>
> 
),
>>>>>>> 
>>>>>>> 
>>>> but none of their methods have resulted in a successful 
>>>> compilation.
>>>>>>> 
>>>>>>> Do you know of a method to compile armv6 ports on an
>>>>>>> x64 machine, or can you direct me to someone who
>>>>>>> might?
>>>>>>> 
>>>>>>> -Jeremy
>>>> 
>>>> At this point, poudriere can build packages by default.
>>>> 
>>>> If you want armv6 packages for RPi or BBB, get poudriere 3.1
>>>> on your system with qemu-bsd-user.
>>>> 
>>>> Setup this arcane binmiscctl(8) command: /usr/sbin/binmiscctl
>>>> add armv6 --interpreter "/usr/local/bin/qemu-arm" \ --magic
>>>> 
>>>> 
> "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00"
>>>>
>>>>
>
> 
\
>>>> --mask
>>>> 
>>>> 
> "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
>>>>
>>>>
>
> 
\
>>>> --size 20 --set-enabled
>>>> 
>>>> 
>>>> That is the command that will redirect execution of armv6
>>>> binaries to qemu-bsd-user.
>>>> 
>>>> Build an armv6 jail with:
>>>> 
>>>> poudriere jail -c -j armv6 -m svn -v head -a arm.armv6 -x
>>>> 
>>>> And build your ports with poudriere via: poudriere bulk -j
>>>> amrv6 <listofports>
>>>> 
>>>> You can fetch packages from the freebsd cluster arm builder
>>>> if you wish as well:
>>>> 
>>>> http://chips.ysv.freebsd.org/packages/11armv6-11armv6/
>>>> 
>>>> Sean
>>>> 
>>>> 
>>>> 
>>>>> 
>>>> 
> 
>> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQF8BAEBCgBmBQJUnc7vXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MDAwMDAwMDAwMDAwMDAwAAoJEBIB78oecn5k5cYH/2NxHEtE8sgVzoWZ84nHL26B
2U7IRHypCrPuSxtkcBb8hnQJk1F2ybeC/i56BwuT1Gjois/0Yu3EeybBw2zHxU5q
hvyyvGJXptUTnXD/JQHEcV/hqbD6j5ng5iXds+LB8htmbfoROtH1Bxs+ZXhmwqsH
aJ7cL4Ufmx0/VtbPevFU9Lzxes1r3JpbeOrX54DfLgLmEEe8sbj+eSNW/St49so9
jk5wXxPy6VbSz/YC4gMl0S6Ev1VQtBeyEg+2kRmaUf/1JlxYh+dG8j5FaihZnjo9
SBloROfgjIRzWRtEgCKZVsOjlREg8kvIik0s3jOUgwjwvRJW3Pc4UnyFyBmoEMc=
=8zMx
-----END PGP SIGNATURE-----


More information about the freebsd-embedded mailing list