SOLUTION MBR hack for serial console

remodeler remodeler at alentogroup.org
Fri Sep 18 18:39:17 UTC 2009


This is a solution to the problem I had. I think others might struggle with it
too. John Baldwin kindly helped on this list.

The FreeBSD handbook article on setting up serial consoles says "Only sio0
through sio3 (COM1 through COM4) can be used; multiport serial cards will not
work". I have a recent motherboard that does not have an on-board serial port,
only only has PCI / PCI-e expansion slots. PCI dynamically assigns addresses
to devices, and I cannot assign a COM1-COM4 address (0x3F8, 0x2F8, 0x3E8 or
0x2E8) to my single-port PCI serial card because a different PCI-PCI bridge
has a bit set claiming the legacy addresses.

I cannot modify the use of the legacy com address for the serial console in
the boot0 code, due to its single-sector size and complexity. It uses PC BIOS
calls to access a serial console, and I do not have access to the proprietary
motherboard BIOS to change the mapping below boot0. For this reason, creating
/boot.config with a flag enabling the serial console (-P, etc.) causes a
lockup on boot before boot0 outputs the "F1: FreeBSD" menu.

I can catch the serial console during initialization of the loader, though,
and can drop to single-user mode or the loader prompt remotely. I specified my
non-legacy serial console address in /etc/make.conf and rebuilt the kernel:

BOOT_COMCONSOLE_PORT=   0xE800

I set the port and speed in the boot2 Makefile (/usr/src/sys/boot/i386 - it's
an AMD64 machine but amd64 still uses the i386 boot blocks):

BOOT_COMCONSOLE_PORT?= 0xe800
BOOT_COMCONSOLE_SPEED?= 115200

Rebuilt the boot blocks and wrote the new boot blocks out:

# cd /sys/boot
# make clean
# make
# make install
# bsdlabel -B /dev/boot_disk

I added the console flag to the serial device in /boot/device.hints (could be
sio driver instead of uart, this is on 9.0-HEAD):

hint.uart.0.port="0xE800"
hint.uart.0.flags="0x10"
hint.uart.0.irq="20"

And last I set these environmental variables in /boot/loader.conf:

console="comconsole"
comconsole_speed="115200"

My goal was a headless remote server w/o high-end server gear, so I didn't set
"boot_multicons". I didn't see any effect to setting "boot_serial" in the
loader configuration file. I have a fully functioning serial console ;)

                                  __     __         
   ________  ____ ___  ____  ____/ /__  / /__  _____
  / ___/ _ \/ __ `__ \/ __ \/ __  / _ \/ / _ \/ ___/
 / /  /  __/ / / / / / /_/ / /_/ /  __/ /  __/ /    
/_/   \___/_/ /_/ /_/\____/\__,_/\___/_/\___/_/     
 
The information contained in this message is confidential and is intended
for the addressee only. Any unauthorized use, dissemination of the
information, or copying of this message is prohibited.



More information about the freebsd-hackers mailing list