Showing posts with label chromeos. Show all posts
Showing posts with label chromeos. Show all posts

Thursday, May 22, 2014

Build Chromium for Chromium OS and Deploy to real device.

Origin: https://github.com/ds-hwang/wiki/wiki/Build-Chromium-for-Chromium-OS-and-Deploy-to-real-device

I want to test my media change on Acer C720P. Life is more bitter than I expected.

  • 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 reboot everytime.
    • Emerge, chromium os and Gentoo build tool, is so slow to build & package.
  • 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.
  • I explain for peppy (Acer C720/C720P) but it can be applied for all devices.
  • I made it on Ubuntu 14.04. I guess it could work fine on 12.04

Build image and flash to the device

# make your image
$ cros_sdk 
Now you're in the chroot environment.

chroot$ export BOARD=peppy
./setup_board --board=${BOARD}
./set_shared_user_password.sh
./build_packages --board=${BOARD} --nowithdebug
./build_image --board=${BOARD} --noenable_rootfs_verification test

# 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_test_image.bin
  • for more overlays, refer to ./src/overlays
    • personally I'm interested in amd64-genericamd64-generic_freonpeppy,peppy_freon

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 run 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 a better way but it is the best way among what I found.

Build

Background

  • 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, because it requires to know how Gentoo distribution is packaged.
    • However, chromium provides convenient hack for you to not need to make your own branch.

Build

Standard way

  • Chromium ebuild defines CHROME_ORIGIN for chromium dev.
    • See ~/src/third_party/chromiumos-overlay/chromeos-base/chromeos-chrome/chromeos-chrome-9999.ebuild
    • Enter chroot with --chrome_root option to inform the location of your chromium checkout.
$ cd $HOME/cros
$ cros_sdk --enter --chrome_root=$HOME/chromium
  • Now that you are inside the chroot. Create chromium os image frombuild_packages step. CHROME_ORIGIN=LOCAL_SOURCE inform chromium os build system to build chromium using your chromium checkout.
$ export CHROME_ORIGIN=LOCAL_SOURCE
$ export BOARD=peppy  # or amd64-generic_freon or peppy_freon
$ ./build_packages --board=${BOARD} --nowithdebug
$ ./build_image --board=${BOARD} --noenable_rootfs_verification test
// use test instead of dev to deploy via ssh
... // more
  • Install & reboot chromebook to test
  • You need additional 16GB
    • out_peppy ~13G: ~/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src/out_peppy
    • debug symbols ~2G:~/chromiumos/chroot/build/peppy/usr/lib/debug/opt/google/chrome

package build

  • If you want to build a single package, instead of running buid_packages you can manually run emerge. For instance the chromium package can be built with:
$ export CHROME_ORIGIN=LOCAL_SOURCE
$ emerge-peppy chromeos-base/chromeos-chrome
  • However, above command rollback your local source to release branch :( Don't do that.
  • It takes 15 min when you change one line in chromium source code. :(

Build only chromium

  • If you don't add/remove any file, you can
# inside chroot
~/trunk/src/scripts $ cd ~/chrome_root/src/
~/chrome_root/src $ ninja -C c/Release chrome

Build Simple chromium

  • you have an image now. time to follow Build Simple Chromium if you build amd64-generic or amd64-generic_freon
    • you can build it outside chroot after gyp_chromium once, which means you can use icecc.
    • don't forget --nogoma
    • Currently (7/Apr/15), it works only for amd64-generic. Unfortunately, amd64-generic_freon doesn't work :(
> cros chrome-sdk --board=amd64-generic --nogoma

Booting and getting to a command prompt

  • Plug the USB stick into the machine and reboot.
  • At the dev-mode warning screen, press Ctrl-U to boot from the USB.
  • Switch to terminal, Ctrl-Alt-F2 [ Ctrl ] [ Alt ] [ => ]
    • the [ => ] key is the right-arrow key just above the number 3 on your keyboard.
  • Login as chronos, password test0000.
  • Get back to the browser. Just press: [ Ctrl ] [ Alt ] [ <= ]

SSH

> ssh chronos@10.10.15.136
or > ssh root@10.10.15.136
Password: test0000

LOG

  • log is stored in
# /var/log/chrome/chrome # what you want
# /home/chronos/user/log/chrome # some browser process log. why?
$ tail -f /home/chronos/user/log/chrome /var/log/chrome/chrome

Deploy (generic)

# in host. e.g. deploy to peppy_freon
> cd ~/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src
> ~/chromiumos/chromite/bin/deploy_chrome --board=peppy --build-dir=out_peppy_freon/Release --to=10.10.15.136
  • It works only for amd64-generic :(

Deploy (hack)

  • remount and prepare in device
> ssh root@10.10.15.136

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

# backup
localhost $ cd /opt/google/chrome/
localhost $ mv chrome chrome_bak

  • copy via scp
> cd ~/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src

# before scp, you might want to strip to reduce size 2G -> 0.2G
> strip out_peppy_freon/Release/chrome

> scp out_peppy_freon/Release/chrome root@192.168.43.175:/opt/google/chrome/chrome
  • restart chrome
# Restart the UI via:
localhost $ restart ui

# however killing chrome is faster. watchdog restarts chrome automatically
localhost $ killall -9 chrome
  • command line
# change following file (read the comments in the file for more details)
localhost $ vi /etc/chrome_dev.conf

# killall is not sufficient
localhost $ restart ui
  • Trouble shooting: after gclient sync your chromium, I recommend to bake image again. otherwise, you might waste your several hours like me :(

Faster build hack

Plz

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

Reference