# How to compile FreeBSD with COM2 as the boot console serial port



## watcher00090 (Jan 23, 2022)

Hi,

I’m trying to compile the FreeBSD kernel to use COM2 instead of COM1 as the boot console serial port.

I’ve got a VirtualBox VM running FreeBSD 13.0-RELEASE and have checked out the FreeBSD source to commit ef1e43df92c6 . 

I want my FreeBSD kernel to use serial port COM2 (instead of COM1) for the console when it boots up. I also want it to use baud rate 115200.

I have a /etc/make.conf which is the following: 
```
BOOT_COMCONSOLE_PORT="0x2F8"
BOOT_COMCONSOLE_SPEED=115200
```

I have added the line
```
device ttyu1 port IO_COM2 flags 0x30 irq 3
```
to the end of my kernel configuration file.

But when I run the commands "sudo make clean && sudo make buildkernel KERNCONF=MAINCONFIG" from the root directory, config fails with a syntax error on the line that I added to my kernel configuration file. Do you guys have any ideas how I could fix this? 

When I run `ls dev | grep ttyu1` in the VM there are entries for `ttyu1`, `ttyu1.init`, and `ttyu1.lock`, not sure if this is relevant here.

Thank you,
James Pedersen


----------



## Andriy (Jan 24, 2022)

watcher00090 said:


> device ttyu1 port IO_COM2 flags 0x30 irq 3


Just curious, did you come up with this syntax yourself or is there some document that describes it?


----------



## Andriy (Jan 24, 2022)

As to your question, read loader(8) and search for comconsole_port.


----------



## watcher00090 (Feb 9, 2022)

Andriy said:


> Just curious, did you come up with this syntax yourself or is there some document that describes it?


This syntax is my own invention. I have no idea it it’s right or not. At the moment I don’t know where to find info about the right syntax.


----------



## watcher00090 (Feb 9, 2022)

Andriy said:


> As to your question, read loader(8) and search for comconsole_port.


Thanks Andriy, this is helpful


----------



## watcher00090 (Feb 9, 2022)

I ended up solving this issue by doing the following:

1. Creating /boot.config with line:

```
-Dh -S115200
```
2. Creating /boot/loader.conf:

```
boot_multicons=“YES”
boot_serial=“YES”
console=“comconsole,vidconsole”
comconsole_port=“0x2F8”
comconsole_speed=“115200”
```
3. Editing /etc/ttys to be as follows:

console none unknown off secure

```
ttyv0 “/usr/libexec/getty Pc” xterm onifexists secure
ttyv1 “/usr/libexec/getty Pc” xterm onifexists secure
ttyv2 “/usr/libexec/getty Pc” xterm onifexists secure
ttyv3 “/usr/libexec/getty Pc” xterm onifexists secure
ttyv4 “/usr/libexec/getty Pc” xterm off secure
ttyv5 “/usr/libexec/getty Pc” xterm off secure
ttyv6 “/usr/libexec/getty Pc” xterm off secure
ttyv7 “/usr/libexec/getty Pc” xterm off secure
ttyv8 “/usr/local/bin/xdm -nodaemon” xterm off secure
ttyu0 “/usr/libexec/getty 3wire” vt100 onifexists secure
ttyu1 “/usr/libexec/getty std.115200” vt100 onifexists secure
ttyu2 “/usr/libexec/getty 3wire” vt100 off secure
ttyu3 “/usr/libexec/getty 3wire” vt100 off secure
dcons “/usr/libexec/getty std.115200” vt100 onifexists secure
xc0 “/usr/lib/getty Pc” xterm off secure
rcons “/usr/libexec/getty std.115200” vt100 onifexists secure
```
This solved the issue.

Basically I wanted to boot my pfSense box using a FreeBSD USB drive so that I could fsck.ufs the pfSense filesystem. But the hardware running pfSense uses COM2 for the serial port running at a baud rate of 115200, hence my desire to make these modifications.


----------



## Lex- (Jul 26, 2022)

watcher00090 said:


> Hi,
> 
> I’m trying to compile the FreeBSD kernel to use COM2 instead of COM1 as the boot console serial port.
> 
> ...


Hello James,
FreeBSD can't be installed to my computer due to an old bug: 



			Kernel panic at early boot time
		




			Kernel panic at early boot time
		


I don't know why it's still not solved, I want to use the exact same FreeBSD version ef1e43df92c6, can you let me know please how you setup the virtual machine to compile it ? 

I want to apply this patch but I don't know how: 



			Fixing FreeBSD kernel panic with UHK keyboard
		


Hope you can help.
Thank you.


----------

