0

someone suggested me this would be the right place for asking this question and it seems so from other questions. I hope to get an answer here.
(by the way, the reason I'm trying to build ubuntu is to add some debug info in the ubuntu kernel to debug an ubuntu install failure on a virtual machine using qemu. The virtual machine is based on qemu's arm64 'virt' machine but has different address map and it has a simple peripheral device model that loads and uses a complex .so file based on multi2sim.)

I downloaded ubuntu source by git clone git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git.
and according to https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel and the included build process for arm, I did this:

LANG=C fakeroot debian/rules clean  
LANG=C fakeroot debian/rules binary-headers binary-generic binary-perarch  

I had exported ARCH=arm64 CROSS_COMPILE=aarch64-none-elf or
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- before the commands, or with the command but it ended with errors at the end. One of the error message was You are building kernel with non-retpoline compiler, please update your compiler and I saw I can fix it by changing configuration(https://askubuntu.com/questions/1145943/building-kernel-with-non-retpoline-compiler). So I tried

LANG=C fakeroot debian/rules editconfigs

But it asks me Do you want to edit config: amd64/config.flavour.generic? when I'm doing it for arm64 architecture. I tried giving ARCH and CROSS_COMPILE option but it always asks me if I want to change amd64 configuration. How can I give it the ARCH and CROSS_COMPILE option for this fakeroot debian/rules build method?

p.s. my toolchain info.

aarch64-linux-gnu-gcc (Linaro GCC 7.5-2019.12) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

or

aarch64-none-elf-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0

Based on the ARM cross-compilation instructions, you need to export the following:

export $(dpkg-architecture -aarm64)
export CROSS_COMPILE=aarch64-linux-gnu-

But it asks me Do you want to edit config: amd64/config.flavour.generic?

If you reply “no”, it will eventually ask you if you want to edit the arm64 configuration.

Once the configuration is ste up as you want it,

fakeroot debian/rules binary-headers binary-generic binary-perarch

will build the packages for you, targeting aarch64.

2
  • Thanks! when I give export $(dpkg-architecutre -aarm64) I get ` dpkg-architecture: warning: specified GNU system type aarch64-linux-gnu does not match CC system type x86_64-linux-gnu, try setting a correct CC environment variable`. I ignore this and do the build, then I get : check-config: FAIL (- != y): CONFIG_STACKPROTECTOR_PER_TASK policy<{'arm64': 'y'}>.
    – Chan Kim
    Jun 30 at 4:47
  • For those interested : I had to download the gcc for aarch64 from arm to remove that CONFIG_STACKPROTECTOR_PER_TASK related errors. now I can build ubuntu 20.04. please see unix.stackexchange.com/questions/656360/…
    – Chan Kim
    Jul 1 at 0:51
0

some people have already done the work of compiling for arm so I advise you to take the image in occurance an ubuntu server and then add a desktop environment, I did it and it's quite easy and it works very well, I put you a link where you will find the image and the steps to follow hoping that you have success.
https://ubuntu.com/download/raspberry-pi

https://ubuntu.com/tutorials/how-to-install-ubuntu-desktop-on-raspberry-pi-4#1-overview

by and good luck !

1
  • 1
    Hi lejurassien, thanks for the answer, but you know my purpose of building ubuntu is to debug ubuntu installation on my virtual machine(I updated my question). I've once installed ubuntu on raspberry pi. Welcome to stack exchange and enjoy!
    – Chan Kim
    Jun 29 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.