Configure the serial port for debugging

Enable the serial port from the build_image command line.
Currenly, you have to edit build_kernel_image.sh to enable
the serial port for kernel debugging. Now:

./build_image --board=${BOARD} --enable_serial=ttyS0

Will enable sending printks to the specified serial port.

BUG=chromium-os:38026
TEST=built images with and without serial enabled

Change-Id: I9ef4f2a20f0d451e132371339c4eba1faf4c94de
Reviewed-on: https://gerrit.chromium.org/gerrit/41638
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Paul Taysom <taysom@chromium.org>
Tested-by: Paul Taysom <taysom@chromium.org>
This commit is contained in:
Paul Taysom 2013-01-18 07:39:25 -08:00 committed by ChromeBot
parent 3239b1aacd
commit 5e39bb6cd1
4 changed files with 27 additions and 3 deletions

View File

@ -145,6 +145,9 @@ DEFINE_boolean enable_squashfs ${FLAGS_FALSE} \
DEFINE_string squash_sort_file "" \
"Specify the priority of files when squashing the rootfs."
DEFINE_string enable_serial "" \
"Enable serial port for printks. Example values: ttyS0"
# Parse the boot.desc and any overrides
eval set -- "${BOOT_DESC} ${FLAG_OVERRIDES}"
FLAGS "${@}" || exit 1
@ -240,6 +243,7 @@ make_image_bootable() {
--verity_error_behavior=${FLAGS_verity_error_behavior} \
--verity_salt=${FLAGS_verity_salt} \
--keys_dir="${FLAGS_keys_dir}" \
--enable_serial="${FLAGS_enable_serial}" \
${enable_rootfs_verification_flag} \
${enable_bootcache_flag} \
${use_dev_keys}

View File

@ -31,6 +31,8 @@ DEFINE_boolean standard_backdoor ${FLAGS_TRUE} \
"Install standard backdoor credentials for testing"
DEFINE_string usb_disk /dev/sdb3 \
"Path syslinux should use to do a usb boot. Default: /dev/sdb3"
DEFINE_string enable_serial "" \
"Enable serial port for printks. Example values: ttyS0"
FLAGS_HELP="USAGE: build_image [flags] [list of images to build].
This script is used to build a Chromium OS image. Chromium OS comes in many

View File

@ -49,6 +49,8 @@ DEFINE_boolean enable_rootfs_verification ${FLAGS_TRUE} \
"Enable kernel-based root fs integrity checking. (Default: true)"
DEFINE_boolean enable_bootcache ${FLAGS_FALSE} \
"Enable boot cache to accelerate booting. (Default: false)"
DEFINE_string enable_serial "" \
"Enable serial port for printks. Example values: ttyS0"
# Parse flags
FLAGS "$@" || exit 1
@ -180,10 +182,25 @@ WORK="${WORK} ${FLAGS_working_dir}/boot.config"
info "Emitted cross-platform boot params to ${FLAGS_working_dir}/boot.config"
# Add common boot options first.
cat <<EOF | cat - "${FLAGS_working_dir}/boot.config" \
> "${FLAGS_working_dir}/config.txt"
loglevel=7
config="${FLAGS_working_dir}/config.txt"
if [[ -n ${FLAGS_enable_serial} ]]; then
console=${FLAGS_enable_serial}
if [[ ${console} != *,* ]]; then
console+=",115200n8"
fi
cat <<EOF > "${config}"
console=${console}
earlyprintk=${console}
console=tty1
EOF
else
cat <<EOF > "${config}"
console=
EOF
fi
cat <<EOF - "${FLAGS_working_dir}/boot.config" >> "${config}"
loglevel=7
init=/sbin/init
cros_secure
EOF

View File

@ -139,6 +139,7 @@ create_boot_desc() {
--boot_args="${FLAGS_boot_args}"
--nocleanup_dirs
--verity_algorithm=sha1
--enable_serial="${FLAGS_enable_serial}"
${enable_rootfs_verification_flag}
${enable_bootcache_flag}
EOF