Building debian image on GCC8 systems

Hi,

I’m currently trying to build debian with the help with your wiki article using the sources (https://wiki.radxa.com/Rockpi4/dev/Debian).

It seems that the guide doesn’t work on current distributions, that use a GCC 8 based compiler (in my case GCC 8.2.0-7ubuntu1 on Ubuntu 18.10).

For the kernel, I get following warnings, that are turned into errors:

arch/arm64/kernel/vdso.c: In function ‘vdso_init’:
arch/arm64/kernel/vdso.c:119:6: warning: ‘memcmp’ reading 4 bytes from a region of size 1 [-Wstringop-overflow=]
error, forbidden warning:vdso.c:119
  if (memcmp(&vdso_start, "\177ELF", 4)) {
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:277: arch/arm64/kernel/vdso.o] Error 1
make[1]: *** Waiting for unfinished jobs....
  EXTRACT_CERTS   
  CC      arch/arm64/mm/flush.o
  CC      arch/arm64/mm/ioremap.o
make: *** [Makefile:1031: arch/arm64/kernel] Error 2
make: *** Waiting for unfinished jobs....

fs/exec.c: In function ‘get_task_comm’:
fs/exec.c:1084:32: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess]
error, forbidden warning:exec.c:1084
  strncpy(buf, tsk->comm, sizeof(tsk->comm));
                            ^
make[1]: *** [scripts/Makefile.build:277: fs/exec.o] Error 1
make[1]: *** Waiting for unfinished jobs....

The guide also later seems to to mention following command:

sudo dpkg -i ubuntu-build-service/packages/*

This command seems odd, since no such folder is present when pulling the rockchip-bsp git repository. Maybe there are steps missing leading to this command?

Hi,

what’s your aarch64-linux-gnu-gcc -v shows?

For the sudo dpkg -i ubuntu-build-service/packages/*, please cd to rootfs first, the wiki is corrected. Thanks for reporting.

Hi,

Like I already said, the GCC is version 8.2.0-1ubuntu1. This includes aarch64-linux-gnu-gcc.

Thank you for correcting the documentation.

Currently testing to compile everything on a fresh Debian 9. It seems that you also need to install the “mtools” package to be able to build the kernel. It might be wise to also include it in the documentation.

1 Like

True. mtools is needed for boot.img generation. The wiki is updated.

Tried to build on Fedora, got compile error in kernel build…

  1. Some package names are different; so far I have installed gcc-aarch64-linux-gnu ncurses ncurses-devel openssl-devel. I could not find device-tree-compiler build-essential. Did sudo dnf groupinstall -y "Development Tools" "Development Libraries" and sudo dnf install -y dtc.
  2. Compile error: after ./build/mk-kernel.sh rockpi4b

arch/arm64/kernel/vdso.c: In function ‘vdso_init’:
arch/arm64/kernel/vdso.c:119:6: warning: ‘memcmp’ reading 4 bytes from a region of size 1 [-Wstringop-overflow=]
error, forbidden warning:vdso.c:119
if (memcmp(&vdso_start, “\177ELF”, 4)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:277: arch/arm64/kernel/vdso.o] Error 1

  1. also

fs/exec.c: In function ‘get_task_comm’:
fs/exec.c:1084:32: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess]
error, forbidden warning:exec.c:1084
strncpy(buf, tsk->comm, sizeof(tsk->comm));
^
make[1]: *** [scripts/Makefile.build:277: fs/exec.o] Error 1

Please advise.

@martin

Of course the package names are different between different distribution families. The distributions decide how a package will be named after all.

The errors you posted are the same as the original post. The current kernel sources provided are not compatible as of right now with GCC8. Until the kernel sources are patched, you need to use a gcc version that is compatible. I personaly used a VM with Debian 9 to compile (GCC 6). Ubuntu 16.04 LTS and 18.04 LTS should also work, since they ship with GCC 5 and 7 respectively.

OK, thanks, yes that worked. I was able to downgrade gcc-aarch64-linux-gnu to version 7 as found in the previous release of Fedora.

You might want to update the documentation to describe this, and also list the Fedora packages that I mentioned earlier, as not everyone uses Debian/Ubuntu.

Also

  • binfmt-support seems to be built into Fedora, so it does not need to be installed,
  • the following lines do not work at all on Fedora as Fedora does not have dpkg or apt-get

sudo dpkg -i ubuntu-build-service/packages/* # ignore the broken dependencies, we will fix it next step
sudo apt-get install -f

  • RELEASE=stretch TARGET=desktop ARCH=$ARCH ./mk-base-debian.sh gives an error that lb is not found.

Should I do the rest of the build process on the Rock Pi? It seems that the rootfs script only works on Debian.

Hi, Martin

I don’t think it’s a good idea to build a debian based system on Fedora. I did some quick search and it seems the essential tool live build, which is used to bootstrap a debian image is not available on Fedora.

I suggest you to use docker or Virtual Machine to init a ubuntu 16.04 build environment. We plan to update a dockerfile on the rockhip-bsp repo for easier build environment maintaining.

Hi,
For building inside Docker containers there is also a dependency on ‘bc’ , ‘python2.7’ and ‘dosfstools’ that would be useful to add to the wiki.

Hi, Art

Thanks for pointing it out. I will add it to the wiki. At the same time, welcome to contribute to the wiki. The wiki is open to edit(except some protected pages) and we believe together with the community can maintain it well.

It looks like the modules are statically build-in the kernel.