Building Chromium OS for Raspberry Pi (ARMv6)

I had previously written the instructions to build an older version of Chromium (via Berkelium) for ARM using Beagleboard/Overo rootfs in order to use it with Xibo digital signage.

Recently I’ve been contacted by hexxeh, who maintains Chromium OS vanilla builds for x86 and MacOS computer, as he intends to provide Chromium OS for the Raspberry Pi, and you should be able to get a SD card image once everything is working from the site above.

Today, I’ll post the steps followed to build Chromium OS LKGR (“the latest revision to pass only unit tests”) optimized for  ARMv6 processor with soft-float support, which is the type of processor (Broadcom BCM2835) used in the Raspberry Pi. Please note that although it can build, it still does not run properly and a few more changes are needed.

First, you’ll need a fast machine to build Chromium OS in a reasonable amount of time. A PC based on a Intel Core i7 950 CPU @ 3.06 GHz (Quad core) with 4 GB RAM, 6 GB swap and running Debian Squeeze 64-bit. A 64-bit OS is necessary to be able to build the debug version of Chromium OS.

The steps provided below are only to build the Chromium OS binaries file, the kernel and rootfs would also have to be generated and packaged to get a full image. The steps to build the Chromium browser are similar, simply remove chromeos=1 in the instructions below.

Here are the steps to build Chromium OS:

  • Install emdebian toolchain (including xapt and dpkg-cross)
  • Install some tools and libraries on the host machine:

    sudo apt-get install build-essential git-core subversion cmake doxygen gyp libudev-dev g++-multilib libssl-dev

  • Install required armel libraries with xapt:

    /usr/share/pdebuild-cross/xapt -a armel libnss3-dev libgconf2-dev libgnome-keyring-dev libgtk2.0-dev libgnome-keyring-dev libgtk2.0-dev libxtst-dev libpam-dev libxss-dev libdbus-glib-1-dev libnss3-dev libgconf2-dev libgnome-keyring-dev libxss-dev libdbus-glib-1-dev libnspr4-dev libglib2.0-dev libjpeg-dev libasound2-dev libbz2-dev libudev-dev libssl-dev libgcrypt11-dev --force-yes

  • Create a working directory (e.g. lkgr):
  • Install the depot_tools used to checkout the code, and add them to your path (Source):

    svn co http://src.chromium.org/svn/trunk/tools/depot_tools
    export PATH="$PATH":pwd/depot_tools

  • Add the following 2 files to .gclient file (Source):


    { "name"        : "cros_deps",
    "url"         : "http://src.chromium.org/svn/trunk/src/tools/cros.DEPS",
    },

    If you don’t you may encounter the following error:

    Exception: src/third_party/cros/cros_api.gyp not found (cwd: /usr/local/space/depot/chrome) while loading dependencies of src/chrome/chrome.gyp while loading dependencies of src/chrome/browser/sync/tools/sync_tools.gyp while loading dependencies of src/build/all.gyp while trying to load src/build/all.gyp
    Error: Command /usr/bin/python src/build/gyp_chromium returned non-zero exit status 1 in /usr/local/space/depot/chrome

  • Retrieve Chromium / Chromium OS source code (Source):

    gclient config https://src.chromium.org/svn/trunk/src https://chromium-status.appspot.com/lkgr
    gclient sync --deps="unix,chromeos" --force

    The last step will take a while.

  • Create a file (e.g. arm.env) with the environment variables required to build chromium


    export CROSSTOOL=arm-linux-gnueabi
    export CXX=$CROSSTOOL-g++
    export CC=$CROSSTOOL-gcc
    export AR=$CROSSTOOL-ar
    export AS=$CROSSTOOL-as
    export RANLIB=$CROSSTOOL-ranlib

    export CFLAGS=”-I/usr/arm-linux-gnueabi/include/gtk-2.0 -I/usr/arm-linux-gnueabi/include/glib-2.0 -march=armv6 -mfpu=vfp -mfloat-abi=softfp”

    export CCFLAGS=$CFLAGS

    export CXXFLAGS=”-I/usr/arm-linux-gnueabi/include/gtk-2.0 -I/usr/arm-linux-gnueabi/include/glib-2.0/ -I/usr/arm-linux-gnueabi/lib/glib-2.0/include/ -I/usr/arm-linux-gnueabi/include/pango-1.0 -I/usr/arm-linux-gnueabi/include/cairo/ -I/usr/arm-linux-gnueabi/include/librsvg-2 -O3 -march=armv6 -mfpu=vfp -mfloat-abi=softfp”

    export GYP_DEFINES=”target_arch=arm disable_nacl=1 linux_use_tcmalloc=0 armv6=1 arm_thumb=0 use_libjpeg_turbo=0 chromeos=1″

  • You may also need to create or edit ~/.gyp/include.gypi with the following:


    {
    'variables': {
    'chromeos': 1,
    'target_arch': 'arm',
    'disable_nacl': 1,  # NaCL does not build for ARM.
    'linux_use_tcmalloc': 0, # tcmalloc does not build for ARM.
    'armv7': 0, # Optional, for targeting ARMv7.
    'armv6': 1, # Optional, for targeting ARMv7.
    'arm_thumb': 0, # Optional, for targeting thumb.  Combine with armv7 to target thumb2.
    'arm_neon': 0, # Optional, to disable NEON. 1 is the default, and most people want to keep it that way.
    'arm_fpu': 'vfp', # Optional, to select which version of vfp to use if NEON is off. Default is vfpv3.
    'verbose': 1
    }
    }

  • Once this is done,  source the environment variables:

    source arm.env

    You may also want to “export V=1” in order to see the arm-linux-gnueabi-xxx command lines used. This will greatly help in case the build fails.
  • Some v8 makefiles will add “-m32” flags to target builds, this is not supported by the compiler and breaks the build. This flag is also not necessary for ARM since up to now only 32-bit is supported. Simply edit src/v8/tools/gyp/v8_base.target.mk and v8/tools/gyp/v8_snapshot.target.mk and comments out cflags and lflags lines with -m32.Failure to do so will result in the following error:

    cc1plus: error: unrecognized command line option “-m32”
    make: *** [out/Debug/obj.target/v8_base/v8/src/accessors.o] Error 1

  • ffmpeg is optimized for ARMv7 Cortex a8 with neon by default and obviously fails to build for armv6, here are the steps to fix this issue:
    • Configure ffmpeg for armv6 + soft float vfp:


      cd src/third_party/ffmpeg
      ./configure --disable-everything --enable-fft --enable-rdft --disable-network --disable-bzlib --disable-zlib --disable-swscale --disable-amd3dnow --disable-amd3dnowext --enable-shared --optflags=-O2 --enable-decoder='theora,vorbis,vp8' --enable-decoder='pcm_u8,pcm_s16le,pcm_f32le' --enable-demuxer='ogg,matroska,wav' --enable-parser=vp8 --enable-cross-compile --cross-prefix=arm-linux-gnueabi- --target-os=linux --arch=arm --enable-armv6 --enable-armv6t2 --enable-armvfp --disable-neon --extra-cflags='-march=armv6'  --extra-cflags='-mfpu=vfp' --extra-cflags='-mfloat-abi=softfp' --enable-pic --enable-decoder='aac,h264,mp3' --enable-demuxer='mp3,mov' --enable-parser=mpegaudio --enable-bsf=h264_mp4toannexb --enable-decoder=mpeg4 --enable-demuxer=avi --enable-bsf=mpeg4video_es --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-demuxer=flac --enable-decoder=flac --enable-decoder=pcm_mulaw
      cp config.h  chromium/config/ChromiumOS/linux/arm/

    • Edit ffmpeg.gyp to replace “armv7-a” with “armv6”, “vfp16-d3” with “vfp” and remove mtune=cortex-a8 and mthumb options.
  • During the link stage, the system will look for libEGL.so and libGLESv2.so which are not available in debian armel package manager. You’ll need to copy those files from Raspberry Pi Debian 6 image in /opt/vc/lib directory to /usr/arm-liux-gueabi/lib directory in your build machine.If those files are missing, the following error will be displayed:

    out/Release/../../third_party/gold/gold64: error: cannot find -lEGL
    out/Release/../../third_party/gold/gold64: error: cannot find -lGLESv2

  • The linker will also fail to find arm_memset16 and arm_memset32 functions. To work around this, change line 1127 in src/skia/skia.gyp:
  • You may also want to modify deps/v8/SConstruct as explained at How to install Node.js on your Raspberry Pi, to avoid illegal instruction or segfault when accessing pages with JavaScript. You may also consider adding support for the FPU using “-march=armv6 -mfpu=vfp -mfloat-abi=softfp” instead of just “-march=armv6”, although I’m not sure JavaScript would benefit much from it.
  • Now, we are ready to build Chromium OS

After a bit over one hour  (maybe 2), you should be able to get the resulting binaries in out/Release directory. Bear in mind that there are still issues (segfaults) and it needs to be debugged to work properly.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
4 Comments
oldest
newest
Jancis
Jancis
12 years ago

so you have compiled chromium os for raspberry? fancy to share?

Benfll
Benfll
11 years ago

So can we have the compiled version of it once these scripts have run. Why can’t you just run these instructions yourself and give us the end result?

Khadas VIM4 SBC