This repository contains tools and utilities used for manufacturing solution. The Chromium OS reference factory software provides a sample factory install and test flow for manufacturing Chrome devices. It is available as part of the public Chromium OS repository on chromium.org. This code is meant as a starting point, to modify and adapt to different projects.
The Chromium OS Factory Software Platform has three major components:
build_image test
).build_image base
).build_image base; mod_image_for_recovery
and can be downloaded directly from ChromeOS Buildbots or CPFE).emerge-$BOARD factory
or make BOARD=$BOARD toolkit
inside factory repository).The basic steps are:
Under chroot, after setting up board, you have two ways to get factory toolkit.
Using emerge. Simply run emerge-$BOARD factory
and find it in /build/$BOARD/usr/local/factory/bundle/toolkit/install_factory_toolkit.run
Build manually. In factory repo, run make BOARD=$BOARD toolkit
and find it in build/install_factory_toolkit.run
.
If you encounter build problems, try to update chroot and rebuild necessary dependencies by running build_packages
and then try again.
The toolkit can be installed into a Chromium OS test image, by either running that locally on a DUT, or apply to a test image directly as blow:
./install_factory_toolkit.run PATH_TO/chromiumos_test_image.bin
Under chroot, after setting up board, you can get the test image by running following commands in trunk/src/scripts
:
build_packages build_image test
After image is built, you can flash it into an USB stick (assume your USB appears as sdX
):
# outside chroot cros flash usb:// chromiumos_test_image.bin # outside chroot sudo dd bs=4M if=/path/to/image/chromiumos_test_image.bin of=/dev/sdX \ iflag=fullblock oflag=dsync
Under chroot, after setting up board, you can get the factory shim by running following commands in trunk/src/scripts
:
build_packages build_image factory_install
There are few options that you may want to change. Run setup/edit_lsb_factory.sh
to get more information.
After image is built, you can flash it into an USB stick (assume your USB appears as sdX
):
# outside chroot cros flash usb:// chromiumos_install_shim.bin # outside chroot sudo dd bs=4M if=/path/to/image/factory_install_shim.bin of=/dev/sdX \ iflag=fullblock oflag=dsync
On boot, the factory shim displays a download status and downloads the image from the server. On completion, the shim reboots. If you are using legacy firmware (not Chrome OS firmware), you might need to remove the SD card to allow booting the newly-installed image.
After the image starts downloading and the status message turns green, you can remove the SD card—it is not needed after that point.
To pre-image the machines rather than image them over the network, you can generate the disk image from a factory test image and a release image.
A generic factory package can be built from a release image and a factory image:
./make_factory_package.sh --diskimg=ssd_image.bin \ --test=/path/to/chromiumos_test_image.bin \ --factory_toolkit=/path/to/install_factory_toolkit.run \ --release=/path/to/chromiumos_image.bin \ --hwid=/path/to/hwid_bundle.sh
You can image directly to a device, or to a .bin file. Available options are:
--diskimg=XX
specifies the destination device or file--sectors=XX
specifies the number of sectors in the bin file--preserve
prevents wiping of the unused space for faster imagingFor development and local testing, it is possible to boot the factory test image from a USB memory stick rather than using a network installation. The following steps sare optional:
test0000
if required.sudo chromeos-firmwareupdate --mode=todev
chromeos-install
command.By default, a factory installation places the factory test image in the first slot of Chrome OS image partitions (#2 and #3), and the release image in the second slot (#4 and #5).
You can build a generic factory package from a release image and a factory image as follows:
# (cros-chroot) ~/trunk/src/scripts/make_factory_package.sh \ --test=/path/to/chromiumos_test_image.bin \ --factory_toolkit=path/to/install_factory_toolkit.run \ --release=/path/to/chromiumos_image.bin \ --hwid=/path/to/hwid_bundle.sh
The factory test image runs the series of pytests located at src/platform/factory/py/test/pytests/
(installed in /usr/local/factory/py/test/pytests/
on the DUT). The sequence of pytest cases are determined by test_lists
files under /usr/local/factory/py/test/test_lists/
. Status is logged to /var/log/factory.log
and more details can be found under /var/factory/*
.
After modifying the source code, you can run the following commands to push files to the DUT. The host machine and DUT must be on the same subnet.
Enter chroot.
Update factory source code on DUT:
./bin/goofy_remote DUT_IP_ADDRESS
For more information on adding test cases, build the Chromium OS Factory SDK documentation:
Enter chroot.
Build the SDK documentation
make doc
Open the following file in a browser window:
build/doc/index.html
The layout of /usr/local/factory
, as installed on devices' stateful partitions, is as follows. Most of these files are installed from this repository, and follow this repository's directory structure.
bin/
: Symbolic links to executable scripts and Python modules.
build/
: Folder to contain build output artifacts.
doc/
: Document templates and resources.
go/
: Programs written in Go language.
init/
: Initialization of factory environment for Chrome OS.
misc/
: Miscellaneous resources used outside of Goofy
proto/
: Proto-buf schema definition.
setup/
: Scripts and programs for partner to setup the environment.
sh/
: Shell scripts.
py_pkg/
: Symbolic link to enable importing Python packages
py/
: Python source code in the cros.factory module and sub-modules. See py/README.md
for more information.
board/
: Board-specific files (optional and only provided by board overlays, not this repository.) in board overlay:
board_setup_factory.sh
: A script to add board-specific arguments when starting the Goofy (the factory test harness).Within the build root (/build/$BOARD
), /usr/local/factory/bundle
is a “pseudo-directory” for the factory bundle: it is masked with INSTALL_MASK
so it is not actually installed onto devices, but any files in this directory will be included in factory bundles built by Buildbot. For example, the shopfloor and mini-Omaha servers are placed into this directory.
Within board overlays, the chromeos-base/factory-board
or chromeos-base/chromeos-factory-board
package may overlay files into this directory structure.
For instance, a board overlay may install:
A board-specific test into /usr/local/factory/py/test/pytests
.
/usr/local/factory/bundle/README
to include a README in the factory bundle.
Any arbitrary board-specific file (e.g., a proprietary tool licensed only for use on a particular board) into /usr/local/factory/board
.
/usr/local/factory/board/board_setup_{factory,x}.sh
to customize Goofy or X arguments.