# make xdev for armv6 issue



## BSDfanNo2 (Aug 15, 2016)

I ran this command in /usr/src:
`make XDEV=arm XDEV_ARCH=armv6 xdev-build`

There was no error. This is the tail of the log:


```
/libllvmx86info.a /usr/obj/armv6-freeb
sd/usr/src/usr.bin/clang/clang/../../../lib/clang/libllvmx86asmprinter/libllvmx86asmprinter.a
/usr/obj/armv6-freebsd/usr/src/usr.bin/clang/clang/../../../lib/clang/libll
vmmc/libllvmmc.a
/usr/obj/armv6-freebsd/usr/src/usr.bin/clang/clang/../../../lib/clang/libllvmx86utils/libllvmx86utils.a
/usr/obj/armv6-freebsd/usr/src/usr.bin/clang/cla
ng/../../../lib/clang/libllvmcore/libllvmcore.a
/usr/obj/armv6-freebsd/usr/src/usr.bin/clang/clang/../../../lib/clang/libllvmsupport/libllvmsupport.a
  -lz  -lncursesw  -
lpthread
--- clang.debug ---
objcopy --only-keep-debug clang.full clang.debug
--- clang ---
objcopy --strip-debug --add-gnu-debuglink=clang.debug  clang.full clang
```

Then I ran this other command:
`make XDEV=arm XDEV_ARCH=armv6 xdev-install`

I got these errors. Any idea?


```
--- xdev-install ---
`_xb-worldtmp' was not built (made 0, flags 2009, type b010001)!
`_xb-bootstrap-tools' was not built (made 0, flags 2009, type b010001)!
  `_xb-bootstrap-tools' has .ORDER dependency against _xb-worldtmp
(made 0, flags 2009, type b010001)
`_xb-build-tools' was not built (made 0, flags 2009, type b410001)!
  `_xb-build-tools' has .ORDER dependency against _xb-bootstrap-tools
(made 0, flags 2009, type b010001)
`_xb-cross-tools' was not built (made 0, flags 2009, type b010001)!
  `_xb-cross-tools' has .ORDER dependency against _xb-build-tools
(made 0, flags 2009, type b410001)
`_xi-mtree' was not built (made 0, flags 2009, type b010001)!
  `_xi-mtree' has .ORDER dependency against xdev-build (made 0, flags
3009, type 3010001)
`_xi-cross-tools' was not built (made 0, flags 2009, type b010001)!
  `_xi-cross-tools' has .ORDER dependency against _xi-mtree (made 0,
flags 2009, type b010001)
`_xi-includes' was not built (made 0, flags 2009, type b010001)!
  `_xi-includes' has .ORDER dependency against _xi-cross-tools (made
0, flags 2009, type b010001)
`_xi-libraries' was not built (made 0, flags 2009, type b010001)!
  `_xi-libraries' has .ORDER dependency against _xi-includes (made 0,
flags 2009, type b010001)
*** [xdev-install] Error code 1

make: stopped in /usr/src
1 error

make: stopped in /usr/src
```


```
# svn info /usr/src
Path: .
Working Copy Root Path: /usr/src
URL: https://svn.freebsd.org/base/stable/11
Relative URL: ^/stable/11
Repository Root: https://svn.freebsd.org/base Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 304074
Node Kind: directory
Schedule: normal
Last Changed Author: kib
Last Changed Rev: 304074
Last Changed Date: 2016-08-14 08:59:34 +0100 (Sun, 14 Aug 2016)
```


----------



## ThothK (Nov 5, 2016)

Hi BSFanNo2,

Did you find a solution for this?

I have been having a similar issue.
In my case when I use
XDEV=arm XDEV_ARCH=armv6 xdev
or
`make XDEV=arm XDEV_ARCH=armv6 WITH_GCC=1 WITH_GCC_BOOTSTRAP=1 WITHOUT_CLANG=1 WITHOUT_CLANG_BOOTSTRAP=1 WITHOUT_CLANG_IS_CC=1 xdev xdev-links`

the process terminates with:

```
===> lib/libc++ (obj,all,install)
/usr/obj/armv6-freebsd/usr/src/lib/libc++ created for /usr/src/lib/libc++
echo libc++.so.1.full: //usr/armv6-freebsd/usr/lib/libcxxrt.a >> .depend
c++ -isystem //usr/armv6-freebsd/usr/include -L//usr/armv6-freebsd/usr/lib  --sysroot=//usr/armv6-freebsd/ -B//usr/armv6-freebsd/usr/libexec  -B//usr/armv6-freebsd/usr/bin -B//usr/armv6-freebsd/usr/lib -mlong-calls -O -pipe -isystem /usr/src/lib/libc++/../../contrib/libc++/include -isystem /usr/src/lib/libc++/../../contrib/libcxxrt -nostdinc++ -nostdlib -DLIBCXXRT -MD -MF.depend.algorithm.o -MTalgorithm.o -Qunused-arguments  -std=c++11 -Wno-c++11-extensions  -c /usr/src/lib/libc++/../../contrib/libc++/src/algorithm.cpp -o algorithm.o
In file included from /usr/src/lib/libc++/../../contrib/libc++/src/algorithm.cpp:10:
In file included from /usr/src/lib/libc++/../../contrib/libc++/include/algorithm:624:
In file included from /usr/src/lib/libc++/../../contrib/libc++/include/initializer_list:47:
[1m/usr/src/lib/libc++/../../contrib/libc++/include/cstddef:43:15: [0m[0;1;31mfatal error: [0m[1m
      'stddef.h' file not found[0m
#include_next <stddef.h>
```

I have read the -isystem is the problem. However, did not see the option in the Makefile.

Do you have any thoughts or suggestions?


=thoth=


----------



## BSDfanNo2 (Nov 17, 2016)

Hi Toth,

I only saw your message today.

No, I did not find how to build the cross chain the way I described in my first post, and I did not pursue it further. I managed however to build an image for the BeagleBone on a amd64 PC using the tools that I believe are used by the FreeBSD project to build the BB image they ship, and as a side effect I got a cross compiling chain.


----------



## cpm@ (Nov 18, 2016)

From time to time, it's worth reading the freebsd-arm mailing list.

https://lists.freebsd.org/pipermail/freebsd-arm/2016-June/014080.html


----------



## Phishfry (Nov 18, 2016)

My advice is to checkout crochet. Is is so easy to crossbuild with its scripts.

For adding a RTC to RPi2 and BPi it was very useful. 
Edit source and rerun crochet. Test image.


----------



## ThothK (Nov 20, 2016)

BSDfanNo2 said:


> No, I did not find how to build the cross chain the way I described in my first post, and I did not pursue it further. I managed however to build an image for the BeagleBone on a amd64 PC using the tools that I believe are used by the FreeBSD project to build the BB image they ship, and as a side effect I got a cross compiling chain.



Hi BSDFan,

I have had no success with this.
What did you do to build the BBB image? Afterwards, where were the cross compile tools?


=thoth=


----------



## Phishfry (Nov 21, 2016)

Here are crochet instructions. They are easier than crossbuilding.

```
pkg install git u-boot-beaglebone
git clone https://github.com/freebsd/crochet /crochet
cd /crochet
./crochet.sh -b BeagleBone
>WAIT UNTIL DONE -- MAYBE MANY HOURS ON FIRST RUN<
cd /crochet/work
dd if=FreeBSD-armv6-12-BEAGLEBONE.img of=/dev/da0 bs=10240 conv=sync
```
*Your Image Name May Be Different*


----------



## Phishfry (Nov 21, 2016)

If you insist on hand building look at this post. I failed at writing the image file as I am new at this.
The files did fully compile though so all the environment settings are right. Output was my problem.
I am sure in a few months I will laugh at the crutch of crochet. Right now it is valuable.
It produces incredible logs and build scripts in the /Work directory, so even for hand building it will serve as a template for you.


----------



## Phishfry (Nov 21, 2016)

Here is the output I did to test. Notice it only took 25 minutes. This is because I already have armv6 built for rpi2 and bpi. On a release version it is much quicker(4-6 minutes on Sandy Bridge j 4). The debug features and witness cause longer build times on -CURRENT

```
Fetching u-boot-beaglebone-2016.05.txz: 100%  198 KiB 202.9kB/s    00:01  
Checking integrity... done (0 conflicting)
[1/1] Installing u-boot-beaglebone-2016.05...
[1/1] Extracting u-boot-beaglebone-2016.05: 100%
root@Testing:/crochet # ./crochet.sh -b BeagleBone
Starting at Sun Nov 20 20:04:39 EST 2016
Board: BeagleBone
Source version is: unknown
Building FreeBSD version: 12.0
Image name is:
    /crochet/work/FreeBSD-armv6-12-BEAGLEBONE.img
Building FreeBSD version: 12.0
Object files are at: /crochet/work/obj/arm.armv6/usr/src
Found suitable FreeBSD source tree in:
    /usr/src
Found U-Boot port in:
    /usr/local/share/u-boot/u-boot-beaglebone
Using FreeBSD armv6 world from previous build
Building FreeBSD armv6-BEAGLEBONE kernel at Sun Nov 20 20:04:39 EST 2016
    (Logging to /crochet/work/_.buildkernel.armv6-BEAGLEBONE.log)
Building FreeBSD armv6-BEAGLEBONE ubldr at Sun Nov 20 20:18:35 EST 2016
    (Logging to /crochet/work/ubldr-armv6-BEAGLEBONE/_.ubldr.armv6-BEAGLEBONE.build.log)
Creating a 1000MB raw disk image in:
    /crochet/work/FreeBSD-armv6-12-BEAGLEBONE.img
Partitioning the raw disk image with MBR at Sun Nov 20 20:19:06 EST 2016
gpart create -s MBR md0
md0 created
Creating a 2m FAT partition at Sun Nov 20 20:19:06 EST 2016 with start block 63 and label BOOT
active set on md0s1
Default to FAT12 for partition size 2m
Creating an auto-sized UFS partition at Sun Nov 20 20:19:06 EST 2016
md0s2 created
/dev/md0s2a: 950.9MB (1947520 sectors) block size 32768, fragment size 4096
   using 4 cylinder groups of 237.75MB, 7608 blks, 30464 inodes.
super-block backups (for fsck_ffs -b #) at:
 192, 487104, 974016, 1460928
tunefs: soft updates set
Using inode 4 in cg 0 for 4194304 byte journal
tunefs: soft updates journaling set
tunefs: NFSv4 ACLs set
Mounting all file systems:
Mounting FAT partition 1 at /crochet/work/_.mount.boot
Mounting UFS partition 1 at /crochet/work/_.mount.freebsd
Installing U-Boot from: /usr/local/share/u-boot/u-boot-beaglebone
Installing ubldr in /crochet/work/_.mount.boot
Installing FreeBSD world at Sun Nov 20 20:19:13 EST 2016
    Destination: /crochet/work/_.mount.freebsd
Overlaying board-specific files from /crochet/board/BeagleBone/overlay
8 blocks
Installing FreeBSD kernel at Sun Nov 20 20:27:44 EST 2016
    Destination: /crochet/work/_.mount.freebsd
Installing all ubldr files in boot
1322 blocks
Unmounting /crochet/work/_.mount.boot
Unmounting /crochet/work/_.mount.freebsd
Releasing md0
DONE.
Completed disk image is in: /crochet/work/FreeBSD-armv6-12-BEAGLEBONE.img

Copy to a suitable memory card using a command such as:
dd if=/crochet/work/FreeBSD-armv6-12-BEAGLEBONE.img of=/dev/da0 bs=1m
(Replace /dev/da0 with the appropriate path for your card reader.)

Finished at Sun Nov 20 20:29:11 EST 2016
```


----------



## BSDfanNo2 (Nov 21, 2016)

ThothK said:


> Hi BSDFan,
> 
> I have had no success with this.
> What did you do to build the BBB image? Afterwards, where were the cross compile tools?
> ...



Hi Thoth,

I think it is worthwhile to check crochet, as Phishfry suggested. It is on my list of things to do.

With respect to how I (successfully) built the BB image: it was very easy, I used what I believe are the tools used to build the BB official images. These are the commands I used:


```
cd /usr/src/release
time sh release.sh -c ~/devel/myBEAGLEBONE.conf | & tee log.txt
dd if=/scratch/usr/obj/usr/src/release/FreeBSD-11.0-PRERELEASE-arm-armv6-BEAGLEBONE.img of=/dev/da2 bs=1M conv=sync
```

It took several hours. How long it takes it depends on how fast your computer is (number of cores,  frequency, etc), and to a lesser degree on how fast is your connection to the internet and how fast is the FreeBSD SVN mirror you are connected to. I built it before the official 11 Release version came out, so the file name of the BB image in the command above would be different today.

The file ~/devel/myBEAGLEBONE.conf  is based on stable/11/release/arm/BEAGLEBONE.conf. I only made one change, which was to add this line at the beginning of the file, keeping the rest:

`# my changes
SRCBRANCH="base/stable/11"`

The reason for the above is that the default is (or was when I did my build) `SRCBRANCH="base/head@rHEAD"`
set in /usr/src/release/release.sh , and that did not suit me.

With respect to where the cross compiling tool chain goes: I started looking at other things and have not yet had time to figure everything out, however there is a gcc cross compiler at /scratch/usr/local/bin/. I am not sure yet if that is the compiler used to build the whole BB image or just part of it, in other words I don’t know what the clang and gcc compilers are used for. Maybe someone else will be able to help with that.

You will need 15 GBytes of disk space for the build.


----------



## ThothK (Nov 28, 2016)

Hi Hi Hi,

I spent a couple of days going through and trying the suggestions with mixed results.

The Crochet FreeBSD instructions Phishfry specified earlier in this thread worked like a charm. This was the first time Crochet worked for me since I was trying it with FreeBSD 9.x.
Thank you.

The native build method BSDFan listed earlier in this thread worked. The only surprise was that all of the source was downloaded. I do not know enough about the build system to suppress that and will likely deal with that once I do.
I ended up using a 25GB drive for the virtual machine.

The only reason I say mixed results is that I did not see the actual cross compile tools after the processes. Rather, I did not recognize them as such if I did see them. I am still learning about FreeBSD.

The upside is that after reviewing the Native Build log, I checked for ARM packages. It turns out that there are several tools available. My guess is that the ARM compiler tools do not actually have to be compiled and can be installed as a package.
I will dig into what I found and update this thread if it appears so.



=Thoth=


----------



## ThothK (Nov 28, 2016)

Hi Phishfry,



Phishfry said:


> If you insist on hand building look at this post. I failed at writing the image file as I am new at this.
> ...



I did look at this. I am very glad that you are working with the TK1. That is what I hope to base the K1 build on. 

Right now though, I just want to be able to compile NVidia's U-Boot by itself. My thought is to break the process into smaller pieces starting with being able to compile U-Boot. I hope that from this, I will learn some lower-level details regarding compiling and possibly porting on FreeBSD.
I know it seems a little goofy, but I would have to be able to do something with the stuff the company I work for is building. If I am to convince them to use FreeBSD for part of it.


=Thoth=


----------



## Phishfry (Nov 28, 2016)

U-Boot is still something I am learning about.

Why not consider compiling u-boot on another armv6 board. It will save you the hassle of cross compiling.
I just debugged a RPi3 iicbus problem module by compiling on platform. The error message led to an easy header fix. Crochet showed no error.

The /src release tools were a really good suggestion, I am not sure if they crossbuild but that is how official images are produced.


----------



## ThothK (Nov 28, 2016)

Hi Phishfry,

I hope to be able to turn one of the BBBs and one of the Olimex A20s into micro-build platforms. My thought is that in order to do so, I need to understand the process much better than I do now.
U-Boot seems really good for this.



=Thoth=


----------

