summaryrefslogtreecommitdiff
path: root/docs/howto/CrossBuildForAarch64.md
blob: f3dc55236054826725d037e7c33f11cca1d15ed9 (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
# Cross building for AARCH64

In nnfw, we use both `ARM64` and `AARCH64` on build files such as Makefile, CMakeLists.txt and so on.
- `ARM64`: only for Android
- `AARCH64`: all except for Android

However we use only one term `ARM64` in RootFS. Use `ARM64` if you need a RootFS for `AARCH64`.

## 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 arm64
```
- 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/arm64` folder.

### Prepare RootFS at alternative folder

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

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

### Using proxy

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

```
# for example,
sudo ./tools/cross/build_rootfs.sh arm64 --setproxy="1.2.3.4:8080"
# or
sudo ./tools/cross/build_rootfs.sh arm64 --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.

## Cross build for AARCH64

Install cross compilers
```
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
```

Build and install ARM Compute Library
```
CROSS_BUILD=1 TARGET_ARCH=aarch64 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 `AARCH64` on Ubuntu

Give `TARGET_ARCH` variable to set the target architecture
```
CROSS_BUILD=1 TARGET_ARCH=aarch64 make
CROSS_BUILD=1 TARGET_ARCH=aarch64 make install
```
- supports `armv7l` and `aarch64` for now

If you used `ROOTFS_DIR` to prepare in alternative folder,
you should also give this to makefile.
```
CROSS_BUILD=1 ROOTFS_DIR=/home/user/rootfs/arm64-xenial TARGET_ARCH=aarch64 make
CROSS_BUILD=1 ROOTFS_DIR=/home/user/rootfs/arm64-xenial TARGET_ARCH=aarch64 make install
```