2013-09-27 08:59:21

by Ramkumar Ramachandra

[permalink] [raw]
Subject: [QUERY] Building and testing Aarch64

Hi,

I'm interested in cross-compiling for ARM v8, and fixing some early
papercuts to begin with; my host machine is a normal x86_64 box.
Although I managed to use Linaro's toolchain [1] to build an Aarch64
kernel, and found a suitable rootfs [2] to use it with, I am not able
to find an ARM64 machine emulator. qemu-system-arm seems to emulate
only a 32-bit ARM machine, and is hence unsuitable for the task. How
is everyone else working on the /arch/arm64 tree?

Thanks.

[1]: https://aur.archlinux.org/packages/gcc-aarch64-linaro/
[2]: http://people.debian.org/~wookey/bootstrap/rootfs/


2013-09-27 14:33:41

by Catalin Marinas

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Hi,

On 27 September 2013 09:58, Ramkumar Ramachandra <[email protected]> wrote:
> I'm interested in cross-compiling for ARM v8, and fixing some early
> papercuts to begin with; my host machine is a normal x86_64 box.
> Although I managed to use Linaro's toolchain [1] to build an Aarch64
> kernel, and found a suitable rootfs [2] to use it with, I am not able
> to find an ARM64 machine emulator. qemu-system-arm seems to emulate
> only a 32-bit ARM machine, and is hence unsuitable for the task. How
> is everyone else working on the /arch/arm64 tree?

Linaro has a page with links for running Linux on ARMv8

http://www.linaro.org/engineering/engineering-projects/armv8

ARM provides an emulator, ARMv8 Foundation Model (free as in free beer
but you need to register to be able to download, just like the
architecture documentation):

http://www.arm.com/products/tools/models/fast-models/foundation-model.php

I think the direct download link is at the bottom of the page:

https://silver.arm.com/browse/FM00A

--
Catalin

2013-09-27 14:44:05

by Ramkumar Ramachandra

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Hi Catalin,

Catalin Marinas wrote:
> ARM provides an emulator, ARMv8 Foundation Model (free as in free beer
> but you need to register to be able to download, just like the
> architecture documentation):
>
> http://www.arm.com/products/tools/models/fast-models/foundation-model.php

I downloaded the foundation model and ran:

$ ./Foundation_v8 --image linux-system-foundation.axf --block-device
debian-arm-rootfs

as described in the Debian page [1]. However, I didn't understand how
to boot it up with the kernel I just built with my toolchain
(arch/arm64/boot/Image.gz). What is this linux-system-foundation.axf?
Also, what is libarmctmodel.so?

Thanks.

[1]: https://wiki.debian.org/Arm64Port#Pre-built_Rootfs

2013-09-27 15:02:19

by Catalin Marinas

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

On Fri, Sep 27, 2013 at 03:43:21PM +0100, Ramkumar Ramachandra wrote:
> Catalin Marinas wrote:
> > ARM provides an emulator, ARMv8 Foundation Model (free as in free beer
> > but you need to register to be able to download, just like the
> > architecture documentation):
> >
> > http://www.arm.com/products/tools/models/fast-models/foundation-model.php
>
> I downloaded the foundation model and ran:
>
> $ ./Foundation_v8 --image linux-system-foundation.axf --block-device
> debian-arm-rootfs
>
> as described in the Debian page [1]. However, I didn't understand how
> to boot it up with the kernel I just built with my toolchain
> (arch/arm64/boot/Image.gz). What is this linux-system-foundation.axf?

The .axf file is something traditionally called ARM eXecutable Format,
which these days it's just an ELF format that the model can load
directly. The above code contains the pre-Linux boot initialisation, the
kernel Image (uncompressed, doesn't have a decompressor) and possibly a
filesystem, unless you use the --block-device model option. To get the
boot wrapper, just clone this:

git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/boot-wrapper-aarch64.git

The README and Makefile should be enough to get you started.

> Also, what is libarmctmodel.so?

I think that's the library that contains the actual software model.

--
Catalin

2013-09-28 07:57:50

by Ramkumar Ramachandra

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Catalin Marinas wrote:
> git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/boot-wrapper-aarch64.git

Thanks, I made some progress. Now I'm stuck trying to specify the
rootfs. I boot with the following arguments (full fork of your
repository here [1]):

console=ttyAMA0 mem=2048M devtmpfs.mount=1 earlyprintk rw
init=/bin/sh root=/dev/vda

I copied it from the command-line parameters that
linux-system-foundation.axf uses [2]. And then boot with the raring
image specified as the --block-device in Foundation_v8 like:

$ ./Foundation_v8 --image linux-system.axf --block-device raring-arm64-rootfs

I built my linux-system.axf from my kernel tree using your Makefile.
Unfortunately, instead of the sh prompt, I get:

VFS: Cannot open root device "vda" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available
partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

I'm not exactly sure what went wrong: I made sure to compile my kernel
with virtio support. My confusion can be summarized as: when I specify
a file as a --block-device to the Foundation_v8 emulator, under which
device node is it available to the kernel? How do I specify a proper
root device? I tried reading through foundation-v8.dts, but couldn't
understand much.

Also, I didn't understand the part of your Makefile that deals with
the filesystem: what is filesystem.cpio.gz, and where is it going to
be used?

Thanks.

[1]: https://github.com/artagnon/boot-wrapper-aarch64
[2]: http://people.debian.org/~wookey/bootstrap/rootfs/

2013-09-28 08:21:30

by Andreas Schwab

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Ramkumar Ramachandra <[email protected]> writes:

> I'm not exactly sure what went wrong: I made sure to compile my kernel
> with virtio support.

Make sure you have CONFIG_VIRTIO_MMIO enabled.

> Also, I didn't understand the part of your Makefile that deals with
> the filesystem: what is filesystem.cpio.gz, and where is it going to
> be used?

It is the optional initrd.

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2013-09-28 08:36:43

by Ramkumar Ramachandra

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Andreas Schwab wrote:
>> I'm not exactly sure what went wrong: I made sure to compile my kernel
>> with virtio support.
>
> Make sure you have CONFIG_VIRTIO_MMIO enabled.

Now, I get the following build error:

LD init/built-in.o
drivers/built-in.o: In function `vgacon_init':
:(.text+0xbc4): undefined reference to `screen_info'
:(.text+0xbc8): undefined reference to `screen_info'
drivers/built-in.o: In function `vgacon_startup':
:(.text+0xc1c): undefined reference to `screen_info'
:(.text+0xc28): undefined reference to `screen_info'
:(.text+0xc74): undefined reference to `screen_info'
drivers/built-in.o::(.text+0xf9c): more undefined references to
`screen_info' follow
make: *** [vmlinux] Error 1

Is there a bug in the Kconfig dependency tree? Sounds like VIRTIO_MMIO
requires some vga (?) drivers to be compiled in as well.

2013-09-28 09:10:27

by Andreas Schwab

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Ramkumar Ramachandra <[email protected]> writes:

> Is there a bug in the Kconfig dependency tree? Sounds like VIRTIO_MMIO
> requires some vga (?) drivers to be compiled in as well.

I don't have any VGA option enabled. You should use a serial console
with CONFIG_SERIAL_AMBA_PL011_CONSOLE.

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2013-09-28 09:40:27

by Ramkumar Ramachandra

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Andreas Schwab wrote:
> Ramkumar Ramachandra <[email protected]> writes:
>> Is there a bug in the Kconfig dependency tree? Sounds like VIRTIO_MMIO
>> requires some vga (?) drivers to be compiled in as well.

I hit this bug when I do `make menuconfig` directly (which
configuration does it start out with?). When I `make defconfig`
(picking up arch/arm64/configs/defconfig), and then enable VIRTIO_MMIO
in the menuconfig, it builds fine.

> I don't have any VGA option enabled. You should use a serial console
> with CONFIG_SERIAL_AMBA_PL011_CONSOLE.

arch/arm64/configs/defconfig:676 already builds this feature in.

Unfortunately, even with VIRTIO_MMIO built in, I get the same error:

VFS: Cannot open root device "vda" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available
partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Any hints on how to proceed from here? What is your kernel
configuration (are you using arch/arm64/configs/defconfig)? Is
root=/dev/vda part of your kernel arguments?

How is this supposed to work? When I pass the rootfs-file as the
--block-device, it's supposed to see the file as the block device
/dev/vda (what determines this?), mount it, and finally get devtmpfs
to populate the /dev, right? The transcript from the working
linux-system.axf (with raring-rootfs) looks like:

[ 4.977788] vda: unknown partition table
[ 4.997392] mtdoops: mtd device (mtddev=name/number) must be supplied
[ 5.001787] smc91x: not found (-19).
[ 5.011141] mousedev: PS/2 mouse device common for all mice
[ 5.020830] device-mapper: ioctl: 4.23.1-ioctl (2012-12-18)
initialised: [email protected]
[ 5.027396] TCP: cubic registered
[ 5.027456] Initializing XFRM netlink socket
[ 5.027885] NET: Registered protocol family 17
[ 5.028207] NET: Registered protocol family 15
[ 5.047665] EXT3-fs (vda): error: couldn't mount because of
unsupported optional features (240)
[ 5.050214] EXT2-fs (vda): error: couldn't mount because of
unsupported optional features (244)
[ 5.095085] EXT4-fs (vda): recovery complete
[ 5.096307] EXT4-fs (vda): mounted filesystem with ordered data
mode. Opts: (null)
[ 5.096723] VFS: Mounted root (ext4 filesystem) on device 254:0.
[ 5.098965] devtmpfs: mounted

What am I missing?

2013-09-28 10:39:20

by Andreas Schwab

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Ramkumar Ramachandra <[email protected]> writes:

> Unfortunately, even with VIRTIO_MMIO built in, I get the same error:

You need all the other relevant virtio options built-in, too, like
VIRTIO_BLK.

> The transcript from the working linux-system.axf (with raring-rootfs)
> looks like:

>From there you can extract the config from /proc/config.gz.

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2013-09-28 10:50:59

by Ramkumar Ramachandra

[permalink] [raw]
Subject: Re: [QUERY] Building and testing Aarch64

Andreas Schwab wrote:
> You need all the other relevant virtio options built-in, too, like
> VIRTIO_BLK.

Thanks! VIRTIO_BLK was the missing feature. I'll submit patches shortly.