summaryrefslogtreecommitdiff
path: root/docs/howto/CrossBuildForArm.md
blob: e307596d098454bb7cdc352c1ed924806c88ad5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Cross building for ARM

## Prepare Ubuntu RootFS

Install required packages

```
sudo apt-get install qemu qemu-user-static binfmt-support debootstrap
```

Use `build_rootfs.sh` script to prepare Root File System. You should have `sudo`

```
sudo ./tools/cross/build_rootfs.sh arm
```
- supports `arm`(default) and `arm64` architecutre for now
- supports `xenial`(default) and `trusty` release

To see the options,
```
./tools/cross/build_rootfs.sh -h
```

RootFS will be prepared at `tools/cross/rootfs/arm` folder.

## Prepare RootFS at alternative folder

Use `ROOTFS_DIR` to a full path to prepare at alternative path.

```
ROOTFS_DIR=/home/user/rootfs/arm-xenial sudo ./tools/cross/build_rootfs.sh arm
```

## Using proxy

If you need to use proxy server while building the rootfs, use `--setproxy` option.

```
# for example,
sudo ./tools/cross/build_rootfs.sh arm --setproxy="1.2.3.4:8080"
# or
sudo ./tools/cross/build_rootfs.sh arm --setproxy="proxy.server.com:8888"
```

This will put `apt` proxy settings in `rootfs/etc/apt/apt.conf.d/90proxy` file
for `http`, `https` and `ftp` protocol.

## Install ARM Cross Toolchain

We recommend you have g++ >= 6 installed on your system because NN generated tests require it.

On Ubuntu 16.04 or older, follow the next steps:

```
cd ~/your/path
wget https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabihf/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
tar xvf gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
echo 'PATH=~/your/path/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin:$PATH' >> ~/.bashrc
```

On Ubuntu 18.04 LTS, you can install using `apt-get`.
Choose g++ version whatever you prefer: 6, 7 or 8.

```
sudo apt-get install g++-{6,7,8}-arm-linux-gnueabihf
```

Make sure you get `libstdc++.so` updated on your target with your new toolchain's corresponding one.

For example, if you installed gcc-linaro-7.2.1-2017.11 above, do

```
wget https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabihf/runtime-gcc-linaro-7.2.1-2017.11-arm-linux-gnueabihf.tar.xz
tar xvf runtime-gcc-linaro-7.2.1-2017.11-arm-linux-gnueabihf.tar.xz
```

Then, copy `libstdc++.so.6.0.24` into `/usr/lib/arm-linux-gnueabihf`, and update symbolic links on your device.

## Build and install ARM Compute Library

```
CROSS_BUILD=1 TARGET_ARCH=armv7l make acl
```
Mostly you only need once of ACL build. This will build and install to `Product/(target_arch-os)/out/bin` folder.
- this is required for ARM on Ubuntu

## Build nnfw

Give `TARGET_ARCH` variable to set the target architecture

```
CROSS_BUILD=1 TARGET_ARCH=armv7l make all install
```
- supports `armv7l` and `aarch64` for now

If you used `ROOTFS_DIR` to prepare in alternative folder, you should also give this to makefile.

```
ROOTFS_DIR=ROOTFS_ARM=/path/to/your/rootfs/arm \
CROSS_BUILD=1 TARGET_ARCH=armv7l make all install
```

## Run test

```
 ./tests/scripts/test_driver.sh --artifactpath=.
```