Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions boards/kgpe-d16.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ CONFIG_DROPBEAR=y

CONFIG_LINUX_USB=y
CONFIG_LINUX_E1000E=y
CONFIG_LINUX_PTY=y

CONFIG_BOOTSCRIPT=/bin/generic-init
export CONFIG_BOOTSCRIPT=/bin/generic-init
#export CONFIG_BOOTSCRIPT_NETWORK=/bin/network-init-recovery

CONFIG_BOOT_REQ_HASH=n
CONFIG_BOOT_REQ_ROLLBACK=n
CONFIG_BOOT_KERNEL_ADD="nohz=on console=ttyS1,115200n8 "
CONFIG_BOOT_KERNEL_REMOVE=""
CONFIG_BOOT_DEV="/dev/sda1"
CONFIG_USB_BOOT_DEV="/dev/sdb1"
CONFIG_BOOT_RECOVERY_SERIAL="/dev/ttyS0"
CONFIG_BOOT_LOCAL=y
export CONFIG_BOOT_REQ_HASH=n
export CONFIG_BOOT_REQ_ROLLBACK=n
export CONFIG_BOOT_KERNEL_ADD="nohz=on console=ttyS1,115200n8 "
export CONFIG_BOOT_KERNEL_REMOVE=""
export CONFIG_BOOT_DEV="/dev/sda1"
export CONFIG_USB_BOOT_DEV="/dev/sdb1"
export CONFIG_BOOT_RECOVERY_SERIAL="/dev/ttyS0"
#export CONFIG_BOOT_STATIC_IP=192.168.1.2
2 changes: 2 additions & 0 deletions boards/qemu-linuxboot.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ CONFIG_LINUX_ATA=y
CONFIG_LINUX_AHCI=y

export CONFIG_BOOTSCRIPT=/bin/generic-init
export CONFIG_BOOTSCRIPT_NETWORK=/bin/network-init-recovery

export CONFIG_BOOT_REQ_HASH=n
export CONFIG_BOOT_REQ_ROLLBACK=n
export CONFIG_BOOT_DEV="/dev/sda1"
export CONFIG_USB_BOOT_DEV="/dev/sdb1"
export CONFIG_BOOT_STATIC_IP=10.0.2.15

# You can ssh into the qemu instance by running
# ssh -p 5555 root@localhost
Expand Down
1 change: 1 addition & 0 deletions boards/x230.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CONFIG_COREBOOT_CONFIG=config/coreboot-x230.config
CONFIG_LINUX_CONFIG=config/linux-x230.config

CONFIG_CRYPTSETUP=y
CONFIG_FLASHROM=y

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really should modify the x230-flash script to use flashtool. It is so much simpler than flashrom and takes up a fraction of the space.

CONFIG_FLASHTOOLS=y
CONFIG_GPG=y
CONFIG_KEXEC=y
Expand Down
6 changes: 3 additions & 3 deletions config/busybox.config
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ CONFIG_FEATURE_XARGS_SUPPORT_ARGS_FILE=y
# CONFIG_BOOTCHARTD is not set
# CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set
# CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set
CONFIG_HALT=y
CONFIG_POWEROFF=y
CONFIG_REBOOT=y
# CONFIG_HALT is not set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these removed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These interfere with the sysrq-based scripts in bin on x230. I think those work always (as long as the kernel has it enabled).

# CONFIG_POWEROFF is not set
# CONFIG_REBOOT is not set
# CONFIG_FEATURE_CALL_TELINIT is not set
CONFIG_TELINIT_PATH=""
# CONFIG_INIT is not set
Expand Down
7 changes: 3 additions & 4 deletions initrd/bin/kexec-boot
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,15 @@ do
firstval=`echo $line | cut -d\ -f2`
restval=`echo $line | cut -d\ -f3-`
if [ "$key" = "kernel" ]; then
fix_file_path
if [ "$kexectype" = "xen" ]; then
# always overload xen and with custom arguments
kexeccmd="$kexeccmd -l $bootdir$firstval"
# always use xen with custom arguments
kexeccmd="$kexeccmd -l $filepath"
kexeccmd="$kexeccmd --command-line \"no-real-mode reboot=no vga=current\""
elif [ "$kexectype" = "multiboot" ]; then
fix_file_path
kexeccmd="$kexeccmd -l $filepath"
kexeccmd="$kexeccmd --command-line \"$restval\""
else
fix_file_path
kexeccmd="$kexeccmd -l $filepath"
fi
fi
Expand Down
29 changes: 29 additions & 0 deletions initrd/bin/network-init-recovery
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/ash

# bring up the ethernet; maybe should do DHCP?
ifconfig lo 127.0.0.1

if [ -f /lib/modules/e1000.ko ]; then
insmod /lib/modules/e1000.ko
fi

if [ -f /lib/modules/e1000e.ko ]; then
insmod /lib/modules/e1000e.ko
fi

if [ -e /sys/class/net/eth0 ]; then
# Setup static IP
if [ ! -z "$CONFIG_BOOT_STATIC_IP" ]; then
ifconfig eth0 $CONFIG_BOOT_STATIC_IP
fi
# TODO: setup DHCP if available
ifconfig eth0 > /dev/ttyprintk

# Setup the ssh server, allow root logins and log to stderr
if [ ! -d /etc/dropbear ]; then
mkdir /etc/dropbear
fi
dropbear -B -R 2>/dev/ttyprintk

ifconfig eth0 | head -1 > /dev/tty0
fi
4 changes: 4 additions & 0 deletions initrd/etc/functions
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ recovery() {
exec /bin/ash
}

pause_recovery() {
read -p 'Hit enter to proceed to recovery shell:'
recovery $*
}

pcrs() {
head -7 /sys/class/tpm/tpm0/pcrs
Expand Down
61 changes: 34 additions & 27 deletions initrd/init
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@ if [ ! -r /dev/ptmx ]; then
ln -s /dev/pts/ptmx /dev/ptmx
fi

# bring up the ethernet; maybe should do DHCP?
ifconfig lo 127.0.0.1

if [ -f /lib/modules/e1000.ko ]; then
insmod /lib/modules/e1000.ko
ifconfig eth0 10.0.2.15 # qemu
ifconfig eth0 > /dev/ttyprintk

# Setup the ssh server, allow root logins and log to stderr
if [ ! -d /etc/dropbear ]; then
mkdir /etc/dropbear
fi
dropbear -B -R 2>/dev/ttyprintk
ifconfig eth0 | head -1 > /dev/tty0
fi

# Recovery shells will erase anything from here
mkdir -p /tmp/secret

Expand All @@ -67,11 +51,12 @@ if [ ! -z "$CONFIG_USB_BOOT_DEV" ]; then
echo >> /etc/fstab "$CONFIG_USB_BOOT_DEV /media auto defaults,ro 0 0"
fi

if [ ! -x "$CONFIG_BOOTSCRIPT" ]; then
recovery 'Boot script missing? Entering recovery shell'
# just in case...
tpm extend -ix 4 -ic recovery
exec /bin/ash
# Setup recovery serial shell
if [ ! -z "$CONFIG_BOOT_RECOVERY_SERIAL" ]; then
stty -F "$CONFIG_BOOT_RECOVERY_SERIAL" 115200
pause_recovery 'Console recovery shell' \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this require user intervension on every boot with CONFIG_BOOT_RECOVERY_SERIAL set?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope - you can boot normally via generic-init through the internal serial connected to the BMC. This is just here to enable recovery shell access on the external serial port on the back of the motherboard (in cases when the BMC is not active or down). This allows you to flash openbmc when physically local to the machine. You can also do this remotely if you configure network-init-recovery as the network bootscript (same drop to recovery shell on ssh into the machine)

< "$CONFIG_BOOT_RECOVERY_SERIAL" \
> "$CONFIG_BOOT_RECOVERY_SERIAL" 2>&1 &
fi

# If the user has been holding down r, enter a recovery shell
Expand All @@ -87,15 +72,37 @@ if [ "$boot_option" = "r" ]; then
# Start an interactive shell
recovery 'User requested recovery shell'
# just in case...
tpm extend -ix 4 -ic recovery
if [ "$CONFIG_TPM" = y ]; then
tpm extend -ix 4 -ic recovery
fi
exec /bin/ash
exit
fi

echo '***** Normal boot:' $CONFIG_BOOTSCRIPT
exec "$CONFIG_BOOTSCRIPT"
if [ ! -x "$CONFIG_BOOTSCRIPT" -a ! -x "$CONFIG_BOOTSCRIPT_NETWORK" ]; then
recovery 'Boot script missing? Entering recovery shell'
else
if [ -x "$CONFIG_BOOTSCRIPT_NETWORK" ]; then
echo '***** Network Boot:' $CONFIG_BOOTSCRIPT_NETWORK
$CONFIG_BOOTSCRIPT_NETWORK
echo '***** Network Boot Completed:' $CONFIG_BOOTSCRIPT_NETWORK
# not blocking
fi

if [ -x "$CONFIG_BOOTSCRIPT" ]; then
echo '***** Normal boot:' $CONFIG_BOOTSCRIPT
exec "$CONFIG_BOOTSCRIPT"

# We should never reach here, but just in case...
recovery 'Boot script failure? Entering recovery shell'
else
# wait for boot via network to occur
pause_recovery 'Override network boot. Entering recovery shell'
fi
fi

# We should never reach here, but just in case...
recovery 'Boot script failure? Entering recovery shell'
# belts and suspenders, just in case...
tpm extend -ix 4 -ic recovery
if [ "$CONFIG_TPM" = y ]; then
tpm extend -ix 4 -ic recovery
fi
exec /bin/ash