Skip to content

Build Chromium for Chromium OS and Deploy to real device. (deprecated)

Dongseong Hwang edited this page Apr 23, 2015 · 4 revisions

DEPRECATED

Overview

  • my opinion: It's so burdensome. After this course, you might like Tizen more...
  • Major reasons:
  • you can not launch your custom chrome in command line. What you can do is to replace chrome files and reboot.
  • There is not nice tool to build chromium in chroot.
  • You need to hack linux filesystem to replace your custom chrome on device, because every mount is read-only.
  • target listener: chromium dev to want to test their changes on real device.
  • why this wiki is needed?: Build Chromium for Chromium OS covers only generic x86/amd64/arm, not real device. and there is no document about it.
  • Although Ryan Cui improve ChromeSDK and --sdk-path option, there is not official document.
  • I explain for peppy (Acer C720/C720P) but it can be applied for all devices.
  • I made it on Ubuntu 14.04. I guess above 12.04 is fine.

Build image and flash to the device

# make your image
export BOARD=peppy
./setup_board --board=${BOARD}
./set_shared_user_password.sh
./build_packages --board=peppy --nowithdebug
./build_image --board=${BOARD} --noenable_rootfs_verification dev

# optional: check if the image is good
./get_latest_image.sh --board=${BOARD}
./mount_gpt_image.sh --board=${BOARD} -f $(./get_latest_image.sh --board=${BOARD})
./mount_gpt_image.sh --board=${BOARD} -u

# optional: make qemu image to run it on your pc.
./image_to_vm.sh --board=${BOARD}
./cros_start_vm --image_path /home/dshwang/chromiumos/src/build/images/peppy/R37-5875.0.2014_05_21_1624-a1/chromiumos_qemu_image.bin

# make booting usb
cros flash usb:// $(./get_latest_image.sh --board=${BOARD})/chromiumos_image.bin

run image on kvm

  • See Running a Chromium OS image under KVM
  • In summary
  • Enabling native virtualization in BIOS
  • sudo apt-get install qemu-kvm libvirt-bin virt-manager virtinst python-libvirt
  • ./bin/cros_start_vm --image_path ../build/images/peppy/latest/chromiumos_qemu_image.bin
  • trouble shooting
  • I encountered following error: "Could not initialize SDL(No available video device) - exiting"
  • The solution is to add "Defaults env_keep+="DISPLAY XAUTHORITY" after executing 'sudo visudo'.
  • Both env variables should be passed to sudo. I don't know why.

after repo sync

  • you don't need to setup_board again, although it's really small part.
~/trunk/src/scripts/update_chroot
export BOARD=peppy
./build_packages --board=peppy --nowithdebug
...

Build Chromium and deploy

I guess there is better way but it is the best among what I found.

Build

Why it's hard to build

  • chrome os build system does not build chromium actually. It just downloads pre-built chromium from gs server during ./build_package.

  • this file include your chrome. ~/chromiumos/chroot/build/peppy/packages/chromeos-base/chromeos-chrome-37.0.2006.4_rc-r1.tbz2

  • If wanna know more, see Portage Build FAQ

  • If you want to build your own change, you need to touch cros_workon.

  • I gave up understanding this, because it requires to know how Gentoo distribution is packaged.

Find GYP_DEFINES, which you need

correct way

  • parse ebuild files in ~/chromiumos/src/third_party/chromiumos-overlay/chromeos-base/chromeos-chrome manually.

easy way

# run at 22/May/2014, you need to get it by yourself
chromium> cros chrome-sdk --board=amd64-generic --nogoma
(sdk amd64-generic R37-5863.0.0-b13527) dshwang@dshwang-X230: ~/workspace/chromium $ env | grep GYP
GYP_DEFINES=use_ozone=0 remoting=1 use_brlapi=1 linux_use_gold_flags=1 chromeos=1 target_arch=x64 use_vtable_verify=0 use_xi2_mt=2 use_cups=0 use_evdev_gestures=0 release_extra_cflags=-g system_libdir=lib64 use_gnome_keyring=0 sysroot=/home/dshwang/workspace/chromium/blink/.cros_cache/chrome-sdk/tarballs/amd64-generic+5863.0.0+sysroot_chromeos-base_chromeos-chrome.tar.xz linux_link_libbrlapi=1 enable_smooth_scrolling=1 use_cras=1 linux_sandbox_path=/opt/google/chrome/chrome-sandbox linux_use_bundled_binutils=0 swig_defines=-DOS_CHROMEOS clang=0 linux_use_bundled_gold=0 icu_use_data_file_flag=1 remove_webcore_debug_symbols=1 strip_tests=1 internal_pdf=0 pkg-config=pkg-config-amd64-generic
GYP_GENERATOR_FLAGS=output_dir=out_amd64-generic
GYP_GENERATORS=ninja
  • change following variables
  • sysroot=/build/peppy
  • pkg-config=pkg-config-peppy
  • so you can get GYP_DEFINES for peppy. See next section.

Build chromium in chroot

$ cd <your src>
$ export GYP_DEFINES="use_ozone=0 remoting=1 use_brlapi=1 linux_use_gold_flags=1 chromeos=1 target_arch=x64 use_vtable_verify=0 use_xi2_mt=2 use_cups=0 use_evdev_gestures=0 system_libdir=lib64 use_gnome_keyring=0 linux_link_libbrlapi=1 enable_smooth_scrolling=1 use_cras=1 linux_sandbox_path=/opt/google/chrome/chrome-sandbox linux_use_bundled_binutils=0 swig_defines=-DOS_CHROMEOS clang=0 linux_use_bundled_gold=0 icu_use_data_file_flag=1 remove_webcore_debug_symbols=1 strip_tests=1 internal_pdf=0 sysroot=/build/peppy pkg-config=pkg-config-peppy"
$ export GYP_GENERATOR_FLAGS=output_dir=out_peppy
$ export GYP_GENERATORS=ninja
$ ./build/gyp_chromium
$ ninja -C out_peppy/Release -j10 chrome chrome_sandbox

Why it's hard to deploy

  • Deploying Chrome to the device doesn't work for some reason.
  • Although my chroot can ssh to device, deploy_chrome script doesn't recognize my device. WTF
  • You need to replace /opt/google/chrome with your built binary. BUT
  • / is mounted as Read-only
  • you can not launch any X11 based executable on shell.

Deploy

usb boot (fast way)

  • reuse your usb that you flash the image.
  • ROOT-A partition is chromeos's /
  • copy your custom chrome to ROOT-A
sudo mv /media/dshwang/ROOT-A/opt/google/chrome /media/dshwang/ROOT-A/opt/google/chrome_bak
sudo cp -r <your chrome> /media/dshwang/ROOT-A/opt/google/
sudo chmod 4755 /media/dshwang/ROOT-A/opt/google/chrome/chrome-sandbox
  • boot usb chromeos via ctrl+u

replace chrome in device (permanent way)

  • Make the same layout to /opt/google/chrome using your out_peppy/Release by yourself. There is not script only for this.

  • you can see the layout in ~/chromiumos/chroot/build/peppy/opt/google/chrome/

  • Copy the dir to usb

  • go to shell in your device

# remount your root for rw
chronos@localhost $ sudo mount -o remount,rw /dev/root /

# mount your usb
chronos@localhost $ sudo mount -t ext4 /dev/sdb1 /media/removable/

# backup your chrome and kill chrome
chronos@localhost $ sudo mv /opt/google/chrome /opt/google/chrome_bak
chronos@localhost $ sudo killall -9 chrome

# copy & reboot
chronos@localhost $ sudo cp -r /media/removable/chrome /opt/google/
chronos@localhost $ sudo chmod 4755 /opt/google/chrome/chrome-sandbox
chronos@localhost $ sudo reboot

Plz

Send dongseong.hwang(at)intel.com mail if you know better way.

Clone this wiki locally