Build Chromium for Chromium OS and Deploy to real device - ds-hwang/wiki GitHub Wiki
- Very burdensome.
- Major reasons:
- It's very hard to launch your custom chrome in command line.
- Target listener: chromium developers who want to test their changes on real devices.
- 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.
- This was written for peppy (Acer C720/C720P), but it can be applied for all devices.
- I made it on Ubuntu 15.04. I guess it could work fine on 12.04
Build image and flash to the device
- Follow Chromium OS Developer Guide until installing Chromium OS on your Device. It works well for peppy and strago also.
- Don't read Quick Start Guide. It makes you confused.
- You probably run following commands in chroot.
Get the source code
host $ mkdir ${HOME}/chromiumos && cd ${HOME}/chromiumos
host $ repo init -u https://chromium.googlesource.com/chromiumos/manifest.git --repo-url https://chromium.googlesource.com/external/repo.git [-g minilayout]
host $ repo sync
Optional: Add the "-g minilayout" option to do a minilayout checkout.
Get the chromium sources
mkdir ~/chromium && cd ~/chromium
fetch --nohooks chromium
Install Build tools for ubuntu:
./src/build/install-build-deps.sh
Background
-
explain how to build image using local chromium source tree. However, it's not very different to use pre-built chromium from gs server. See inline comments
-
If you don't set up local chromium 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, 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.
Enter chroot
- Chromium ebuild defines
CHROME_ORIGIN
for chromium dev. - See
~/chromiumos/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, and chroot mount the directory as
~/chrome_root
host $ cd ${HOME}/chromiumos
host $ cros_sdk --enter --chrome_root=${HOME}/chromium
chroot $ export BOARD=amd64-generic # or peppy or peppy_freon or strago
- For more overlays, refer to
./src/overlays
- Personally, I'm interested in
amd64-generic
,peppy
,peppy_freon
,strago
- You can change build configuration by
USE
- e.g.
host $ USE=chrome_media cros_sdk --enter --chrome_root=${HOME}/chromium
Setup board
- setup board per each target board.
chroot $ ./setup_board --board=${BOARD}
# optional. default passwd is test0000
chroot $ set_shared_user_password.sh
Build
- Now that you are inside the chroot. Create chromium os image from
build_packages
step. CHROME_ORIGIN=LOCAL_SOURCE inform chromium os build system to build chromium using your chromium checkout.
# without this env, build system uses prebuilt chromium binary.
chroot $ export CHROME_ORIGIN=LOCAL_SOURCE
chroot $ export USE="component_build chrome_media vulkan clang"
chroot $ cros_workon --board=$BOARD start chromeos-chrome
# If you supply --nowithdebug, then NDEBUG will be defined and the debugging constructs will be removed.
chroot $ ./build_packages --board=${BOARD} [--withtest --nowithdebug]
# use test instead of dev to deploy via ssh
chroot $ ./build_image --board=${BOARD} --noenable_rootfs_verification test [--disk_layout=2gb-rootfs-updatable]
... // more
-
--disk_layout=2gb-rootfs-updatable
makes 2gb root partition. -
You need additional 16GB
-
out_amd64-generic ~13G:
~/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src/out_amd64-generic
-
debug symbols ~2G:
~/chromiumos/chroot/build/amd64-generic/usr/lib/debug/opt/google/chrome
-
Image is baked in
~/dshwang/chromiumos/src/build/images
-
need to remove old images sometime
Option l: check if the image is good
# query latest image. absolute path is /mnt/host/source/src/build/images/..
chroot $ get_latest_image.sh --board=${BOARD}
# mount and unmount the image
chroot $ mount_gpt_image.sh --board=${BOARD} -f $(./get_latest_image.sh --board=${BOARD})
chroot $ mount_gpt_image.sh --board=${BOARD} -u
Option 2: make a qemu image to run it on your PC.
./image_to_vm.sh --board=${BOARD} [--test_image]
See below section how to launch the image on qemu
Make a bootable usb drive
chroot $ cros flash usb:// ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin
Install image to device
- Boot via usb
- Press
CTRL
+ALT
+F2
to enter shell - Login as user
chronos
if you didn't set a password when building the default istest0000
- Change [Your Drive Path] to your HDD/SSD. This is probably
/dev/sda
NOTE: Running the following command will format your entire disk, make sure to backup any data that you would like to keep.
$ /usr/sbin/chromeos-install --dst [Your Drive Path]
Make the usb from the device
- we can make the bootable chromeos usb from the device.
- Possible scenario; install CPFE image, switch kernel and make usb stick to share with coworkers.
chromeos-install --skip_src_removable --skip_dst_removable --dst /dev/sdb
After repo sync
- You don't need to run setup_board every time.
chroot $ ~/trunk/src/scripts/update_chroot
export BOARD=amd64-generic
chroot $ setup_board --board=${BOARD}
...
- Trouble shooting: after
gclient sync
your chromium, I recommend to bake an image again. Otherwise, you might waste your several hours like me :(
Trouble shooting.
sshfs fails
- Issue
chronos@localhost /opt/google/chrome $ sshfs [email protected]:/home/dshwang/chromium/src/out_amd64-generic/Release /opt/google/chrome/out/
fuse: failed to exec fusermount: No such file or directory
- Solve copy
fusermount
to/usr/bin/fusermount
and
chmod +rx /usr/bin/fusermount
chmod u+s /usr/bin/fusermount
- you may need to add
chronos
in some groups in/etc/group
outdated toolchain
- e.g.
python "../../../../../../../home/dshwang/chrome_root/src/build/toolchain/gcc_link_wrapper.py" --output="host/genmacro" -- x86_64-pc-linux-gnu-g++ -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -lpthread -Wl,--as-needed -fuse-ld=gold -B../../../../../../../home/dshwang/chrome_root/src/third_party/binutils/Linux_x64/Release/bin -m64 -Wl,-O1 -Wl,--gc-sections -Wl,--gdb-index -nostdlib++ -Wl,-rpath-link=host -Wl,--disable-new-dtags -o "host/genmacro" -Wl,--start-group @"host/genmacro.rsp" -Wl,--end-group -ldl -lpthread -lrt
x86_64-pc-linux-gnu-g++.real: error: unrecognized command line option '-nostdlib++'
[15/25661] LINK host/genstring
FAILED: host/genstring
- solution
./update_chroot
Failure to compile an image
- Sometimes
emerge
corrupts package files. I hopeemerge
would re-try to download corrupted files butemerge
is not that smart. If some files are corrupted, you encounter as follows
~/trunk/src/scripts $ ./build_image --board=${BOARD} --noenable_rootfs_verification test
...
Packages failed:
media-fonts/ja-ipafonts-003.03-r1
=== Start output for job ja-ipafonts-003.03-r1 (0m0.2s) ===
ja-ipafonts-003.03-r1: >>> Emerging binary (1 of 1) media-fonts/ja-ipafonts-003.03-r1::chromiumos for /mnt/host/source/src/build/images/daisy_spring/R48-7581.0.2015_11_02_1956-a1/rootfs/
ja-ipafonts-003.03-r1: !!! Fetching Binary failed for 'media-fonts/ja-ipafonts-003.03-r1'
ja-ipafonts-003.03-r1: >>> Failed to emerge media-fonts/ja-ipafonts-003.03-r1 for /mnt/host/source/src/build/images/daisy_spring/R48-7581.0.2015_11_02_1956-a1/rootfs/, Log file:
ja-ipafonts-003.03-r1: >>> '/build/daisy_spring/tmp/portage/logs/media-fonts:ja-ipafonts-003.03-r1:20151102-175732.log'
- You need to build the package again by yourself. In above example, you should run
~/trunk/src/scripts $ emerge-daisy_spring media-fonts/ja-ipafonts
!!! CONFIG_PROTECT is empty for '/build/daisy_spring/'
...
>>> No outdated packages were found on your system.
- And then build image again
~/trunk/src/scripts $ ./build_image --board=${BOARD} --noenable_rootfs_verification test
- If it doesn't work, the best way to fix is to setup board again and build again.
chroot $ ./setup_board --board=${BOARD} --force
fail to build image at last minuite
Starting fast-emerge.
Building package virtual/target-os-test on /build/amd64-generic
Calculating deps...
emerge: there are no ebuilds to satisfy "dev-libs/protobuf-python" for /mnt/host/source/src/build/images/amd64-generic/R61-9691.0.2017_06_27_1338-a1/rootfs/usr/local/.
(dependency required by "virtual/target-chromium-os-test-1-r47::chromiumos" [binary])
(dependency required by "virtual/target-os-test-1-r2::chromiumos" [binary])
(dependency required by "virtual/target-os-test" [argument])
INFO : Unmounting image from /mnt/host/source/src/build/images/amd64-generic/R61-9691.0.2017_06_27_1338-a1/stateful and /mnt/host/source/src/build/images/amd64-generic/R61-9691.0.2017_06_27_1338-a1/rootfs
- solution: build all dependancies
emergy-${BOARD} virtual/target-chromium-os-test
emergy-${BOARD} virtual/target-os-test
emergy-${BOARD} dev-python/protobuf-python
Chromeos-mrc workaround
- You need to have access permission of https://chrome-internal.googlesource.com/#
- generate password in https://chrome-internal.googlesource.com/#
- build with gitcookies
EGIT_OPTIONS="-c http.cookiefile=~/.gitcookies" emerge-$(BOARD) sys-boot/chromeos-mrc
android-container build fails.
- symptoms
$ emerge-samus chromeos-base/android-container
...
cmd=['/mnt/host/source/.cache/common/gsutil_4.19.tar.gz/gsutil/gsutil', '-o', 'Boto:num_retries=10', '-o', 'Boto:proxy=proxy-ir.intel.com', '-o', 'Boto:proxy_port=911', 'cp', '-v', '--', 'gs://chromeos-arc-images/builds/git_mnc-dr-arc-dev-linux-cheets_x86-user/3918031/cheets_x86-target_files-3918031.zip', '/var/cache/chromeos-cache/distfiles/target/cheets_x86-target_files-3918031.zip.tmp'], extra env={'BOTO_CONFIG': '/mnt/host/source/src/private-overlays/overlay-samus-private/googlestorage_account.boto'}
!!! Couldn't download 'cheets_x86-target_files-3918031.zip'. Aborting.
* Fetch failed for 'chromeos-base/android-container-3918031-r1', Log file:
* '/build/samus/tmp/portage/logs/chromeos-base:android-container-3918031-r1:20170417-185221.log'
...
- solution
cd chromiumos/src/private-overlays
cp overlay-cyan-cheets-private/googlestorage_account.boto overlay-samus-private/
emerge-samus chromeos-base/android-container
emerge-samus chromeos-bsp-samus-private
Mount error (device "/proc/7318/fd/3" busy)
- You might got
plain floppy: device "/proc/7318/fd/3" busy (Resource temporarily unavailable):
Cannot initialize 'S:'
Bad target s:/ldlinux.sys
syslinux: failed to create ldlinux.sys
ERROR : Wed Mar 16 04:11:50 EET 2016
ERROR : PGID PPID PID ELAPSED TIME %CPU COMMAND
ERROR : 9 6 9 06:31:41 00:00:00 0.0 -bash
ERROR : 8151 9 8151 09:38 00:00:00 0.0 \_ /bin/bash ./build_image --board=glados --noenable_rootfs_verification test
ERROR : 8151 8151 4684 00:14 00:00:00 0.7 \_ /bin/bash /mnt/host/source/src/scripts/bin/cros_make_image_bootable /mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1 chromiumos_test_image.bin --force_developer_mode
ERROR : 8151 4684 7114 00:00 00:00:00 0.0 \_ /bin/bash /mnt/host/source/src/scripts/update_bootloaders.sh --arch=amd64 --to=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/chromiumos_test_image.bin --from=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/rootfs_dir/boot --vmlinuz=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/rootfs_dir/boot/vmlinuz --to_offset=127926272 --to_size=16777216 --kernel_partition='/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/vmlinuz.image' --install_syslinux
ERROR : 8151 7114 7326 00:00 00:00:00 0.0 \_ /bin/bash /mnt/host/source/src/scripts/update_bootloaders.sh --arch=amd64 --to=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/chromiumos_test_image.bin --from=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/rootfs_dir/boot --vmlinuz=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/rootfs_dir/boot/vmlinuz --to_offset=127926272 --to_size=16777216 --kernel_partition='/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/vmlinuz.image' --install_syslinux
ERROR : 8151 7326 7327 00:00 00:00:00 0.0 \_ ps f -o pgid,ppid,pid,etime,cputime,%cpu,command
ERROR : Arguments of 7114: '--arch=amd64' '--to=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/chromiumos_test_image.bin' '--from=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/rootfs_dir/boot' '--vmlinuz=/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/rootfs_dir/boot/vmlinuz' '--to_offset=127926272' '--to_size=16777216' '--kernel_partition='/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/vmlinuz.image'' '--install_syslinux'
ERROR : Backtrace: (most recent call is last)
ERROR : update_bootloaders.sh:195:main(), called: die_err_trap
ERROR :
ERROR : Command failed:
ERROR : Command 'sudo syslinux -d /syslinux "${ESP_DEV}"' exited with nonzero code: 1
umount: /tmp/esp.mrqXy6: not mounted
WARNING : Initial unmount failed. Possibly crosbug.com/23443. Retrying
umount: /tmp/esp.mrqXy6: not mounted
INFO : Unmounting image from /mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/stateful_dir and /mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/rootfs_dir
Cleaning up /usr/local symlinks for /mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/stateful_dir/dev_image
ERROR : Wed Mar 16 04:11:56 EET 2016
ERROR : PGID PPID PID ELAPSED TIME %CPU COMMAND
ERROR : 9 6 9 06:31:47 00:00:00 0.0 -bash
ERROR : 8151 9 8151 09:44 00:00:00 0.0 \_ /bin/bash ./build_image --board=glados --noenable_rootfs_verification test
ERROR : 8151 8151 4684 00:20 00:00:00 0.5 \_ /bin/bash /mnt/host/source/src/scripts/bin/cros_make_image_bootable /mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1 chromiumos_test_image.bin --force_developer_mode
ERROR : 8151 4684 7669 00:00 00:00:00 0.0 \_ /bin/bash /mnt/host/source/src/scripts/bin/cros_make_image_bootable /mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1 chromiumos_test_image.bin --force_developer_mode
ERROR : 8151 7669 7670 00:00 00:00:00 0.0 \_ ps f -o pgid,ppid,pid,etime,cputime,%cpu,command
ERROR : Arguments of 4684: '/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1' 'chromiumos_test_image.bin' '--force_developer_mode'
ERROR : Backtrace: (most recent call is last)
ERROR : cros_make_image_bootable:427:main(), called: make_image_bootable '/mnt/host/source/src/build/images/glados/R51-8068.0.2016_03_16_0402-a1/chromiumos_test_image.bin'
ERROR : cros_make_image_bootable:1:make_image_bootable(), called: die 'cros_make_image_bootable failed.'
ERROR :
ERROR : Error was:
ERROR : cros_make_image_bootable failed.
- It often happen if you mount your local chromium. I don't know why.
- solution
scripts> git diff
diff --git a/update_bootloaders.sh b/update_bootloaders.sh
index c81dce7..0d850ea 100755
--- a/update_bootloaders.sh
+++ b/update_bootloaders.sh
@@ -140,6 +140,7 @@ else
fi
ESP_FS_DIR=$(mktemp -d /tmp/esp.XXXXXX)
+ESP_LOOP_COPY=$(mktemp /tmp/esp-loop-copy.XXXXXX)
cleanup() {
set +e
if ! safe_umount "${ESP_FS_DIR}"; then
@@ -154,6 +155,7 @@ cleanup() {
sudo losetup -d "${ESP_DEV}"
fi
rm -rf "${ESP_FS_DIR}"
+ rm -f "${ESP_LOOP_COPY}"
}
trap cleanup EXIT
sudo mount "${ESP_DEV}" "${ESP_FS_DIR}"
@@ -192,7 +194,12 @@ if [ "${FLAGS_arch}" = "x86" ](/ds-hwang/wiki/wiki/|-"${FLAGS_arch}"-=-"amd64"-); then
# we cut over from rootfs booting (extlinux).
if [ ${FLAGS_install_syslinux} -eq ${FLAGS_TRUE} ](/ds-hwang/wiki/wiki/-${FLAGS_install_syslinux}--eq-${FLAGS_TRUE}-); then
safe_umount "${ESP_FS_DIR}"
- sudo syslinux -d /syslinux "${ESP_DEV}"
+ # We cannot syslinux ESP_DEV directly because of a race condition with udev,
+ # see http://crbug.com/508713
+ sudo dd if="${ESP_DEV}" of="${ESP_LOOP_COPY}" status=none
+ sudo syslinux -d /syslinux "${ESP_LOOP_COPY}"
+ sudo flock --wait 10 -x "${ESP_DEV}" \
+ dd if="${ESP_LOOP_COPY}" of="${ESP_DEV}" status=none
# mount again for cleanup to free resource gracefully
sudo mount -o ro "${ESP_DEV}" "${ESP_FS_DIR}"
fi
kernel build failure
- problem
make: Target '_all' not remade because of errors.
* ERROR: sys-kernel/chromeos-kernel-4_14-4.14.78-r572::chromiumos failed (compile phase):
* emake failed
* Could not find a Makefile in the kernel source directory.
* Please ensure that points to a complete set of Linux sources
* Unable to calculate Linux Kernel version for build, attempting to use running version
- solution: removing
/build/$BOARD/var/cache/portage/sys-kernel
and rebuild
Enabling debugging features
When we create a image, we pass the --noenable_rootfs_verification flag in order to disable the rootfs verification, but it enables automatically once we change chrome file or reboot CrOS.
In this case, you should enable debugging feature in the welcome menu of CrOS when first booting it.
Incremental build and Deploy
I guess there is a better way but it is the best way among what I found.
Incremental build
package build
- If you want to build a single package, instead of running
build_packages
you can manually run emerge. For instance the chromium package can be built with:
$ export CHROME_ORIGIN=LOCAL_SOURCE
$ export USE="component_build chrome_media vulkan clang"
$ emerge-peppy chromeos-base/chromeos-chrome
- However, above command rollback your local source to release branch :( I mean that it run
git checkout <commit for release branch>
on your chromium/src - 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 build via ninja
- It's the fastest way for development. build & deploy combo saves your time.
chroot $ cd ~/chrome_root/src/
chroot $ 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
- you can build it outside chroot after gyp_chromium once, which means you probably can use icecc. (I failed to use icecc :( )
- don't forget
--nogoma
- Currently (7/Apr/15), it works only for amd64-generic. Unfortunately, eve doesn't work :(
- However, deploy amd64-generic chrome to eve devices sometimes (with high probability) works lol
> cros chrome-sdk --board=amd64-generic --nogoma --clang --gn-extra-args='proprietary_codecs=true ffmpeg_branding="Chrome" use_v4l2_codec=false google_api_key="xxx" google_default_client_id="xxx.apps.googleusercontent.com" google_default_client_secret="xxx"' --gn-gen --chroot=/home/dshwang/chromiumos/chroot ./autoninja.sh
cros chrome-sdk
can execute only executable name without any options. It's why./autoninja.sh
exists.
# autoninja.sh
autoninja -C out_amd64-generic/Release/ chrome chrome_sandbox nacl_helper
Making changes to packages whose source code is checked into Chromium OS git repositories
- I want to build kernel with https://chromium-review.googlesource.com/#/c/266900
- reference How to quickly test kernel modification
> cd src/third_party/kernel/v3.14/
# apply the patch
git fetch https://chromium.googlesource.com/chromiumos/third_party/kernel refs/changes/30/335830/1 && git cherry-pick FETCH_HEAD
chroot $ cros_workon start --board=amd64-generic sys-kernel/chromeos-kernel-4_4
chroot $ FEATURES="noclean" cros_workon_make --board=${BOARD} --install chromeos-kernel-4_4
# or chroot $ emerge-amd64-generic sys-kernel/chromeos-kernel-3_14
# or build_package
- If build fails due to radeon something.
* Detected file collision(s):
*
* /build/amd64-generic/lib/firmware/radeon/RS780_pfp.bin
* /build/amd64-generic/lib/firmware/radeon/RV710_me.bin
* /build/amd64-generic/lib/firmware/radeon/RS780_me.bin
- Solution: build linux-firmware first
- Apply following change in chromiumos/src/third_party/chromiumos-overlay/sys-kernel/linux-firmware/linux-firmware-9999.ebuild
diff --git a/sys-kernel/linux-firmware/linux-firmware-9999.ebuild b/sys-kernel/linux-firmware/linux-firmware-9999.ebuild
index 6e28055..c6dab9d 100644
--- a/sys-kernel/linux-firmware/linux-firmware-9999.ebuild
+++ b/sys-kernel/linux-firmware/linux-firmware-9999.ebuild
@@ -158,7 +158,6 @@ src_install() {
use_fw nvidia-xusb && doins_subdir nvidia/tegra*/xusb.bin
use_fw rockchip-dptx && doins_subdir rockchip/dptx.bin
- use video_cards_radeon && doins_subdir radeon/*
use video_cards_amdgpu && doins_subdir amdgpu/{carrizo,stoney}*
// Build firmware
chroot $ cros_workon start --board=amd64-generic sys-kernel/linux-firmware
chroot $ cros_workon_make --board=${BOARD} --install sys-kernel/linux-firmware
- update the kernel in the device, using the sdk script
chroot $ ~/trunk/src/scripts/update_kernel.sh --remote 10.10.15.214
- clean up
chroot $ cros_workon stop --board=amd64-generic sys-kernel/chromeos-kernel-3_14
deploy single package
tests
$ emerge-amd64-generic autotest
$ test_that 10.237.68.57 graphics_Gbm
Deploy
Booting and getting to a command prompt
- Plug the USB stick into the machine and reboot.
- First, you need to enable developer mode on your chrome book: How to enable developer mode on Acer C720
- 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 ] [ <= ]
Deploy (generic)
# in host. e.g. deploy to amd64-generic
> cd ~/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src
> ~/chromiumos/chromite/bin/deploy_chrome --board=amd64-generic --build-dir=out_amd64-generic/Release --to=10.10.15.136
# deploy to qemu
> ~/chromiumos/chromite/bin/deploy_chrome --board=amd64-generic --build-dir=out_amd64-generic/Release --to=dshwang-INTEL -p 9222
- It works only for amd64-generic :(
SSH
> ssh [email protected]
or > ssh [email protected]
Password: test0000
Deploy (hack)
Copying chrome executable file into chromebook.
- Remount and prepare in device
localhost $ ssh [email protected]
# Remount your root for rw
root # mount -o remount,rw /
# Backup
root # cd /opt/google/chrome/
root # mv chrome chrome_bak
- Copy via scp
localhost $ cd ~/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src
# Before scp, you might want to strip to reduce size 2G -> 0.2G
localhost $ strip out_peppy_freon/Release/chrome
localhost $ scp out_peppy_freon/Release/chrome [email protected]:/opt/google/chrome/chrome
Partner Image
- Partner images: https://www.google.com/chromeos/partner/fe/#release
- remove_rootfs_verification
/usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions 2
Run
Run image on KVM
-
Enabling native virtualization in BIOS
-
sudo apt-get install qemu-kvm libvirt-bin virt-manager virtinst python-libvirt
-
Run qemu
> cd ~/chromiumos/src/scripts
> ./bin/cros_start_vm --image_path ../build/images/amd64-generic/latest/chromiumos_qemu_image.bin
# ssh
> ssh root@dshwang-INTEL -p 9222 -o StrictHostKeyChecking=no
# scp
> scp -P 9222 ./vgem_fb_test root@dshwang-INTEL:/opt/google/chrome/
-
NOTE: host ip is 10.0.2.2
-
mount host folder on qemu
# sshfs -o idmap=user [email protected]:/home/dshwang/chromium /opt/google/chrome/remote/
- 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.
LOG
- Logs are stored in
# /var/log/chrome/chrome # what you want
# /var/log/messages
# /var/log/ui/ui.LATEST
# /home/chronos/user/log/chrome
root # tail -f /home/chronos/user/log/chrome /var/log/chrome/chrome /var/log/ui/ui.LATEST
- chrome_os_logging
- How to log
LOG(WARNING) << error_message;
VLOG(1) << "Got display added event for ";
NOTIMPLEMENTED();
- Look at fd of browser
ls `ps -ef | grep "chrome\/chrome " | awk '{print $2}' | sed "s/^/\/proc\//g" | sed "s/$/\/fd/g"` -la
Run chrome
- Restart chrome
# Restart the UI via:
root # restart ui
# However, killing chrome is faster because the watchdog restarts chrome automatically.
root # killall -9 chrome
-
refer to chrome os debugging for more information
-
Command line
# Change the following file (read the comments in the file for more details)
root # mount -o remount,rw /
root # vi /etc/chrome_dev.conf
# killall is not sufficient
root # restart ui
root # vi /etc/chrome_dev.conf
GOOGLE_API_KEY=your_api_key
GOOGLE_DEFAULT_CLIENT_ID=your_client_id
GOOGLE_DEFAULT_CLIENT_SECRET=your_client_secret
- remove rootfs verification
- After failing to start ui repeatedly, sometimes rootfs is locked.
root # /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification
Run app_shell without deploy
- mount your host machine
# after login via ssh
root # mount -o remount,rw /
root # mkdir -p /opt/google/chrome/remote/
root # sshfs [email protected]:/home/dshwang/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src/out_amd64-generic /opt/google/chrome/remote/
- run app_shell
root # /opt/google/chrome/remote/Release/
root # ./app_shell --ozone-platform=gbm --load-apps=/opt/google/chrome/remote/samples/hello-world/ --ozone-use-surfaceless --no-sandbox
Run your chrome without deploy
- start only session
root # stop ui
root # touch /var/run/disable_chrome_restart
root # start ui
- login as chronos
root # su chronos
- run installed
chrome
. NoteXDG_RUNTIME_DIR=/run/chrome
env is needed
chronos $ XDG_RUNTIME_DIR=/run/chrome /opt/google/chrome/chrome --enable-fixed-position-compositing --enable-impl-side-painting --max-tiles-for-interest-area=512 --ui-enable-per-tile-painting --ui-prioritize-in-gpu-process --use-gl=egl --gpu-sandbox-failures-fatal=yes --enable-logging --log-level=1 --use-cras --enable-wayland-server --user-data-dir=/home/chronos --max-unused-resource-memory-usage-percentage=5 --system-developer-mode --login-profile=user --aura-legacy-power-button --enable-prefixed-encrypted-media --enterprise-enrollment-initial-modulus=14 --enterprise-enrollment-modulus-limit=18 --vmodule=screen_locker=2,webui_screen_locker=2,lock_state_controller=2,webui_login_view=2,power_button_observer=2,*ui/display/chromeos*=1,*ash/display*=1,*ui/ozone*=1,*zygote*=1,*plugin*=2,*chromeos/login/*=1 --login-manager
- mount via sshfs as above, but make sure via chronos
chronos $ sshfs [email protected]:/home/dshwang/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src/out_amd64-generic/ /opt/google/chrome/remote/
- run chrome
chronos $ ./chrome --ozone-platform=gbm --ozone-use-surfaceless --user-data-dir=/home/chronos --login-manager --no-sandbox
- clean-up
chronos $ fusermount -u /opt/google/chrome/remote/
root # rm /var/run/disable_chrome_restart
Run your chrome built for Ubuntu without deploy
- now you reach highlight of this doc.
- believe or not, you can run your chrome built for Ubuntu on ChromeOS in the same way to above section.
- build chromium with
GYP_DEFINES='use_ozone=1 chromeos=1 ozone_platform_gbm=1'
- mount the
out
directory of the host on the ChromeOS device.
chronos $ sshfs [email protected]:/home/dshwang/chromium/src/out_ozone_cros /opt/google/chrome/out/
- run chrome
chronos $ ./chrome --ozone-platform=gbm --ozone-use-surfaceless --user-data-dir=/home/chronos --login-manager --no-sandbox
Without --no-sandbox
- create
chrome-sandbox
on you host
> ninja -C out/Release chrome_sandbox
> cd out/Release
cp chrome_sandbox chrome-sandbox
sudo chown root:root chrome-sandbox
sudo chmod 4755 chrome-sandbox
- now you can run
chrome
andapp_shell
without--no-sandbox
chronos $ ./chrome --ozone-platform=gbm --ozone-use-surfaceless --user-data-dir=/home/chronos --login-manager
chronos $ ./app_shell --ozone-platform=gbm --load-apps=/opt/google/chrome/remote/samples/hello-world/ --ozone-use-surfaceless
Without ui session
- you can run
chrome
in guest mode withoutstart ui
chronos $ ./chrome --ozone-platform=gbm --ozone-use-surfaceless --user-data-dir=/home/chronos/ --bwsi --login-user='$guest' --login-profile=user
--incognito
makeschrome
accept url.
./chrome --ozone-platform=gbm --ozone-use-surfaceless --user-data-dir=/home/chronos/ --bwsi --login-user='$guest' --login-profile=user --incognito --enable-native-gpu-memory-buffers --disable-persistent-gpu-memory-buffer --proxy-auto-detect http://media.24ways.org/2009/15/space.html
- It's particularly useful when your chrome-os image complains "Oops, something went wrong with signing in".
Ubuntu 15.10 trouble shooting
After upgrading Ubuntu 15.10, your host has brand-new libstdc++.so. Your host chrome linking with it is in trouble on your device. You encounter this ld error. Don't panic. You don't have to downgrade your Ubuntu.
chronos $ ./chrome blahblah
./chrome: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./chrome)
./chrome: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /opt/google/chrome/out/Release/lib/libnative_theme.so)
...
- Copy following libraries in the folder which is mounted by your device
libdbus-1.so.3 -> libdbus-1.so.3.14.3
libdbus-1.so.3.14.3
libstdc++.so.6 -> libstdc++.so.6.0.21
libstdc++.so.6.0.21
libsystemd.so.0 -> libsystemd.so.0.10.2
libsystemd.so.0.10.2
- Run
chrome
withLD_LIBRARY_PATH
pointing out the folder.
LD_LIBRARY_PATH=/opt/google/chrome/out/ ./chrome --ozone-platform=gbm --user-data-dir=/home/chronos/ --bwsi --login-user='$guest' --login-profile=user --incognito --proxy-auto-detect http://media.24ways.org/2009/15/space.html
Tips etc.
Debug symbol
export KEEP_CHROME_DEBUG_SYMBOLS=1
(chroot) ./build_image --adjust_part='ROOT-A:+1G' --noenable_rootfs_verification test
Dcheck
export USE="chrome_media dcheck_always_on"
- CL
- need more space for bloated chrome file
./build_image --adjust_part='ROOT-A:+1G' --noenable_rootfs_verification test
Bypass ui session
- don't launch ui session at booting
$ cd /etc/init
$ mv ui.conf ui-respawn.conf ~
- launch ui session without chrome
$ touch /var/run/disable_chrome_restart
lars build
- lars (SKL) uses proprietary Intel gpu video decoder, so need additional license term.
./build_packages --board=${BOARD} --accept_licenses=Google-TOS --nowithdebug
Freq. commands
- amd64-generic
export BOARD=amd64-generic; ./build_packages --board=${BOARD} --nowithdebug
; ./build_image --board=${BOARD} --noenable_rootfs_verification test;
export BOARD=amd64-generic; USE="component_build chrome_media vulkan clang" CHROME_ORIGIN=LOCAL_SOURCE emerge-${BOARD} chromeos-chrome
export BOARD=amd64-generic; rm -rf /var/cache/chromeos-chrome/chrome-src/src/out_${BOARD}; ./build_packages --board=${BOARD} --accept_licenses=Google-TOS --nowithdebug; ./build_image --board=${BOARD} --noenable_rootfs_verification test; rm -rf /var/cache/chromeos-chrome/chrome-src/src/out_${BOARD}; USE="component_build chrome_media vulkan clang" CHROME_ORIGIN=LOCAL_SOURCE emerge-${BOARD} chromeos-chrome
export BOARD=amd64-generic; ./setup_board --board=${BOARD}; ./build_packages --board=${BOARD} --accept_licenses=Google-TOS --nowithdebug; ./build_image --board=${BOARD} --noenable_rootfs_verification test; USE="component_build chrome_media vulkan clang" CHROME_ORIGIN=LOCAL_SOURCE emerge-${BOARD} chromeos-chrome
sshfs [email protected]:/home/dshwang/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src/out_amd64-generic/Release/ /opt/google/chrome/out/
./chrome --ui-prioritize-in-gpu-process --use-gl=egl --user-data-dir=/home/chronos/ --bwsi --login-user='$guest' --login-profile=user --incognito --proxy-auto-detect --use-cras --enable-hardware-overlays --enable-drm-atomic http://dshwang-xeon.jf.intel.com/browsertests/public/media/fullscreen.html
- everyday script to mount and run chrome
cd /opt/google/chrome/
mount -o remount,rw /
mkdir out
mkdir bin
chown chronos:chronos out
touch /var/run/disable_chrome_restart
restart ui
su chronos
sshfs [email protected]:/home/dshwang/chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src/out_eve/Release/ /opt/google/chrome/out/
XDG_RUNTIME_DIR=/run/chrome ./chrome --enable-webvr --ui-prioritize-in-gpu-process --use-gl=egl --user-data-dir=/home/chronos/ --bwsi --login-user='$guest' --login-profile=user --incognito --proxy-auto-detect --use-cras --enable-wayland-server --enable-hardware-overlays="single-fullscreen,single-on-top" --enable-drm-atomic http://dshwang-xeon.jf.intel.com/browsertests/public/webvr
when disk is not enough
- delete
chromiumos/chroot/build/${BOARD}
chromiumos/chroot/var/cache/chromeos-chrome/chrome-src/src/out_${BOARD}
chromiumos/src/build/images/${BOARD}
Faster build hack
- If you want to know useless hacks, see Build-Chromium-for-Chromium-OS-and-Deploy-to-real-device.-(deprecated)#build-chromium-and-deploy
Test
Power measurement
- create
power.sh
script
power_supply_info | grep "energy rate" >> $1
tail -1 $1
- run the script
TERM=xterm watch -n 1 ./power.sh 1.txt
- another way
TERM=xterm watch -n1 -d 'power_supply_info 2>&1 | grep "energy rate" | tee -a 1.txt'
- there is new tool which shows SoC, LCD, dram respectively dump_intel_rapl_consumption
alias dump_power='while true ; do a=`power_supply_info | grep rate`; echo -n "$a " ; dump_intel_rapl_consumption | tail -1 ; done'
GPU debug
intel_gpu_top
- mesa debug message:
export INTEL_DEBUG=perf
- drm debug message: forget :(
- drm error log:
cat /sys/class/drm/card0/error
- display info:
TERM=xterm watch -n1 -d cat /sys/kernel/debug/dri/0/i915_display_info
Version
Contact
Send me at dongseong.hwang(at)intel.com if you know a better way.
Reference
- Chromium OS Developer Guide
- Build Simple Chromium
- ChromeOS Debugging tips
- Kernel Crash Logs in Chromium OS
- ChromeOS by Triplett
- https://www.chromium.org/chromium-os/poking-around-your-chrome-os-device
- Directory Structure
- Debugging tips
- Running a Chromium OS image under KVM
- ChromeOS contribution
repo upload --cbr . --no-verify
- Internal