With the recent launch of several low cost Cortex A53 development boards, 64-bit ARM hardware is now pretty common and inexpensive, but if you want to run 64-bit ARM code on your x86 Linux computer, Riku Voipio, a software engineer working for Linaro, wrote some instructions to run Ubuntu 16.04 Aarch64 Cloud image in QEMU. Ubuntu cloud images are “the official Ubuntu images and are pre-installed disk images that have been customized by Ubuntu engineering to run on public clouds that provide Ubuntu Certified Images, Openstack, LXD, and more. ” So the instructions are also useful if you want to easily try such packages on 64-bit ARM platform.
I’ve tried those instructions myself on my Ubuntu 14.04 machine with and AMD FX8350 processor, and they worked pretty well, and the only things I had to find out by myself was to install a recent version of qemu.
First, we’ll need to install qemu & cloud-utils, and download QEMU EFI firmware as well as the Ubuntu 16.04 Xenial server Cloud image:
1
2
3
|
sudo
apt
install
-
y
qemu
qemu
-
utils
cloud
-
utils
wget
https
:
/
/
releases
.linaro
.org
/
components
/
kernel
/
uefi
-
linaro
/
15.12
/
release
/
qemu64
/
QEMU_EFI
.fd
wget
https
:
/
/
cloud
-
images
.ubuntu
.com
/
xenial
/
current
/
xenial
-
server
-
cloudimg
-
arm64
-
uefi1
.img
|
The instructions require qemu-system-aarch64 version 2.5, and my system only comes with qemu 2.0.0
1
2
|
qemu
-
system
-
x86_64
--
version
QEMU
emulator
version
2.0.0
(
Debian
2.0.0
+
dfsg
-
2ubuntu1.22
)
,
Copyright
(
c
)
2003
-
2008
Fabrice
Bellard
|
So I had to find a qemu ppa to install a more recent version:
1
2
3
|
sudo
sudo
apt
-
add
-
repository
ppa
:
gns3
/
qemu
sudo
apt
update
sudo
apt
install
qemu
-
system
-
aarch64
|
I now have version 2.5:
1
2
|
qemu
-
system
-
aarch64
--
version
QEMU
emulator
version
2.5.0
(
Debian
1
:
2.5
+
dfsg
-
5ubuntu1
)
,
Copyright
(
c
)
2003
-
2008
Fabrice
Bellard
|
Since the Cloud images don’t come with default username and password, they need to configured with cloud-utils. To do so, I created cloud-utils as follows:
1
2
3
4
5
6
7
8
9
|
#cloud-config
users
:
-
name
:
<
your_username
>
ssh
-
authorized
-
keys
:
-
ssh
-
rsa
AAAAB3NzaC1y
.
.
.
.
sudo
:
[
'ALL=(ALL) NOPASSWD:ALL'
]
groups
:
sudo
shell
:
/
bin
/
bash
|
You simply need to change the file with your username, and RSA key, which should be in ~/.ssh/id_rsa.pub. If you don’t have that file you may want to read my post showing how to create the SSH key and login without password. Cloud config can take many arguments, including packages to install during the first boot, and you can learn all about it on Cloud-init documentation.
Now you can initialize the cloud image, and run it:
1
2
3
4
5
6
7
8
|
cloud
-
localds
cloud
.img
cloud
.txt
qemu
-
system
-
aarch64
-
smp
2
-
m
1024
-
M
virt
-
bios
QEMU_EFI
.fd
-
nographic
\
-
device
virtio
-
blk
-
device
,
drive
=
image
\
-
drive
if
=
none
,
id
=
image
,
file
=
xenial
-
server
-
cloudimg
-
arm64
-
uefi1
.img
\
-
device
virtio
-
blk
-
device
,
drive
=
cloud
\
-
drive
if
=
none
,
id
=
cloud
,
file
=
cloud
.img
\
-
netdev
user
,
id
=
user0
-
device
virtio
-
net
-
device
,
netdev
=
user0
-
redir
tcp
:
2222
::
22
\
-
cpu
cortex
-
a57
|
The boot until the login prompt tool about 3 minutes on my machine. Here’s the boot log:
You won’t be able to login there however, so instead you can access the emulated server via ssh:
1
|
ssh
-
p
2222
<
your_username
>
@
localhost
|
No password will be asked since we’re using an ssh key.
A few commands confirm we are indeed running Ubuntu 16.04 with Linux 4.4 on a dual core Cortex A57 processor:
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
|
jaufranc
@
ubuntu
:
~
$
cat
/
etc
/
lsb
-
release
DISTRIB_ID
=
Ubuntu
DISTRIB_RELEASE
=
16.04
DISTRIB_CODENAME
=
xenial
DISTRIB_DESCRIPTION
=
"Ubuntu 16.04 LTS"
jaufranc
@
ubuntu
:
~
$
uname
-
a
Linux
ubuntu
4.4.0
-
22
-
generic
#39-Ubuntu SMP Thu May 5 16:54:53 UTC 2016 aarch64 aarch64 aarch64 GNU/Linux
jaufranc
@
ubuntu
:
~
$
cat
/
proc
/
cpuinfo
processor
:
0
BogoMIPS
:
125.00
Features
:
fp
asimd
evtstrm
aes
pmull
sha1
sha2
crc32
CPU
implementer
:
0x41
CPU
architecture
:
8
CPU
variant
:
0x1
CPU
part
:
0xd07
CPU
revision
:
0
processor
:
1
BogoMIPS
:
125.00
Features
:
fp
asimd
evtstrm
aes
pmull
sha1
sha2
crc32
CPU
implementer
:
0x41
CPU
architecture
:
8
CPU
variant
:
0x1
CPU
part
:
0xd07
CPU
revision
:
0
|
I’ve also run linpack benchmark:
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
|
wget
http
:
/
/
www
.netlib
.org
/
benchmark
/
linpackc
.new
mv
linpackc
.new
linpack
.c
sudo
apt
install
gcc
gcc
-
O3
-
o
linpack
linpack
.c
-
lm
.
/
linpack
Enter
array
size
(
q
to
quit
)
[
200
]
:
Memory
required
:
315K.
LINPACK
benchmark
,
Double
precision
.
Machine
precision
:
15
digits
.
Array
size
200
X
200.
Average
rolled
and
unrolled
performance
:
Reps
Time
(
s
)
DGEFA
DGESL
OVERHEAD
KFLOPS
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
16
0.68
91.81
%
2.84
%
5.35
%
34198.250
32
1.37
91.78
%
2.86
%
5.37
%
33984.987
64
2.73
91.77
%
2.81
%
5.42
%
34036.419
128
5.43
91.79
%
2.81
%
5.40
%
34204.638
256
10.93
91.76
%
2.83
%
5.41
%
34018.723
gcc
-
O3
-
o
linpack
linpack
.c
-
lm
-
mcpu
=
cortex
-
a57
.
/
linpack
Enter
array
size
(
q
to
quit
)
[
200
]
:
Memory
required
:
315K.
LINPACK
benchmark
,
Double
precision
.
Machine
precision
:
15
digits
.
Array
size
200
X
200.
Average
rolled
and
unrolled
performance
:
Reps
Time
(
s
)
DGEFA
DGESL
OVERHEAD
KFLOPS
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
16
0.62
90.56
%
2.81
%
6.63
%
37711.131
32
1.26
90.83
%
2.73
%
6.44
%
37205.669
64
2.50
90.97
%
2.69
%
6.34
%
37495.956
128
5.02
90.89
%
2.78
%
6.33
%
37401.005
256
10.02
90.81
%
2.75
%
6.44
%
37487.820
|
Emulation from x86 to ARM is affecting the results quite a bit here. For reference, a Raspberry Pi 2 achieves about 113300 KFLOPS for the same benchmark. You’ll also noticed specifically compiling for Cortex-A57 CPU improves the performance by about 10%, even in qemu.
https://www.cnx-software.com/2016/05/10/how-to-run-ubuntu-16-04-aarch64-64-bit-arm-cloud-images-on-your-intelamd-linux-computer/