# Installing FreeBSD over serial console



## French Fries (Aug 13, 2017)

Dear all,

is there a simple way to install a standard FreeBSD installer using serial console only? 
Serial console installation is covered by the documentation. 
But I did not find any reference of an installation over serial console.

I am using small-factor servers (like PcEngines APU) to nice Supermicro servers with console redirection.
Today, I am preparing a migration, so I tested FreeBSD inside KVM, while learning, before I migrate in a few days.

If serial console is already a stock feature of the installer, please pardon my ignorance.

Kind regards,
French Fries


----------



## French Fries (Aug 13, 2017)

https://www.freebsd.org/cgi/man.cgi?query=loader.conf&sektion=5&manpath=freebsd-release-ports

```
comconsole_speed
            (``9600'' or the value of the BOOT_COMCONSOLE_SPEED vari-
             able when loader(8) was compiled).     Sets the speed    of the
             serial console.  If the previous boot loader stage    speci-
             fied that a serial    console    is in use then the default
             speed is determined from the current serial port speed
             setting.

       console   (``vidconsole'') ``comconsole'' selects serial console,
             ``vidconsole'' selects the    video console, ``nullconsole''
             selects a mute console (useful for    systems    with neither a
             video console nor a serial    port), and ``spinconsole''
             selects the video console which prevents any input    and
             hides all output replacing    it with    ``spinning'' character
             (useful for embedded products and such).
```

How to swith to comconsole automatically when you are not in front of keyboard, only a serial console?​


----------



## Phishfry (Aug 13, 2017)

You need to use #3 from the boot menu with the beastie logo. This drops you to a shell. You enter the commands here like this:
https://forums.freebsd.org/threads/59450/#post-341008

You can also mod your usb memstick installer and add /boot/loader.conf entries for comconsole. The installer will run in VT100 and others.
https://forums.freebsd.org/posts/340928/
You can modify you FreeBSD memstick installer without FreeBSD installed.
Simply boot up the memstick installer on any machine.
Instead of 'Install' pick 'LiveCD' and that will give you a chance to create /boot/loader.conf on the memstick installer and you add your comconsole settings. ee is easy editor and works good for text editing.
`ee /boot/loader.conf`

```
boot_multicons="YES"
boot_serial="YES"
comconsole_speed="115200"
console="comconsole,vidconsole"
```
Upon completing this you reboot your memstick installer and use it on the console box

After the FreeBSD installer runs it asks if you want to modify files for the new system.
This will drop you to a post-install shell that is the new install.
So you would then need to create /boot/loader.conf on the new system.
`ee /boot/loader.conf`
Add your comconsole settings

Many headless machines also need the vidconsole setting due to video cores on the cpu. Even without video output.


----------



## French Fries (Aug 13, 2017)

Thanks, I will do this immediately.

Later, I would like to mod the installer to be able to produce a full-fledged installer. 

Under Debian I used scripts to produce:
https://github.com/ffries/Debian-installer-with-serial-console

Can the same be done under FreeBSD?
i.e. rebuild a full-installer with serial-console in mind?


----------



## Phishfry (Aug 13, 2017)

Yes i modified my post..No rebuild just make 1 file with the comconsole settings after writing the memstick installer disk image..
/boot/loader.conf


----------



## French Fries (Aug 13, 2017)

Good to know, thanks.
I completed installation.
It is fairly easy and straightforward.


----------



## Rajesh (May 30, 2018)

Hi,  
I am facing similar issue in connecting to the serial console for FreeBSD installation.  I have set the following tunables from the loader prompt

```
set boot_multicons=YES
set boot_serial=YES
set comconsole_speed=115200 (I also made sure, the speed is same on the other side as well)
set console=comconsole
```
Then from a windows machine, using PUTTY opened a connection to the serial port with correct speed. But, I just get a blank screen.  After this screen is opened, I run "boot -h" from the FreeBSD loader prompt. But nothing is seen in putty console.

Is there anything I am missing? I even tried with 9600 on both sides, but no help.

Note: I have connected a serial cable (D9) to my box where I am installing FreeBSD, and through a serial to usb converter I am connecting the other end to my windows usb port


----------



## SirDice (May 30, 2018)

Rajesh said:


> I have connected a serial cable (D9) to my box where I am installing FreeBSD, and through a serial to usb converter I am connecting the other end to my windows usb port


Did you use a null-modem cable?

https://en.wikipedia.org/wiki/Null_modem


----------



## Rajesh (May 30, 2018)

SirDice said:


> Did you use a null-modem cable?
> 
> https://en.wikipedia.org/wiki/Null_modem



Hi SirDice, Yes I am using this cable only. I have one end connected directly to the FreeBSD box. Other end is connected to USB converter and then connected to windows machine through USB port.  Adding to this, I tried setting console=nullconsole also, but it doesn't help.


----------



## SirDice (May 30, 2018)

What type of null-modem cable? 3 wire, 5 wire or full? A 3 wire (RxD, TxD, GND) should be enough. Just make sure to turn off hardware handshaking in PuTTY. Also make sure to select the correct COM port for the USB->Serial converter in Windows, I have a few of those and they all get assigned a random COM port, so the first time it might be COM3, the next time you plug it in it's COM4, another time COM5, etc.


----------



## Rajesh (May 31, 2018)

Hi SirDice, I believe it's 3-wire only. After setting the above tunables in loader prompt, From putty serial settings, I set the following

1. Serial Line - COM1 (this name i got from device manager)
2. Speed - 115200
3. Databits - 8
4. Stop bits - 1
5. Parity - None
6. Flowcontrol - None

I verified the same settings in the windows device manager properties and also in the freebsd box. Also, I see the following in /etc/ttys

#Serial console
ttyu0   "/usr/libexec/getty 3wire"   vt100 onifconsole secure
ttyu1   "/usr/libexec/getty 3wire"   vt100  onifconsole secure
ttyu2   "/usr/libexec/getty 3wire"   vt100  onifconsole secure
ttyu3   "/usr/libexec/getty 3wire"   vt100  onifconsole secure
#Dumb console
dcons "/usr/libexec/getty std.9600"   vt100  off secure

Since, I am connecting to my windows PC, dumb console settings wont apply here I assume.  Is there any problem in the sequence I am following (First set tunables in loader prompt(in VGA console), then connect from putty)?


----------



## Phishfry (May 31, 2018)

SirDice said:


> Also make sure to select the correct COM port for the USB->Serial converter in Windows,


Also double check the setting for the port speed in Windows. It has to be set there in the device manager and in putty.
Truthfully this is probably not the problem though,  if there is a port speed problem you usually see gibberish on the screen.
Not a blank screen..


Rajesh said:


> Is there any problem in the sequence I am following (First set tunables in loader prompt(in VGA console), then connect from putty


Nope those setting are straight out of the handbook.

Are you sure that the device you are connecting to uses COM1.
On some servers COM1 is used for iDRAC or other Lights-out BMC stuff.
Devices with an RJ45 comm port you see the same. RJ45-Console=COM1 and DB9=COM2


----------



## Phishfry (May 31, 2018)

Rajesh said:


> (First set tunables in loader prompt(in VGA console), then connect from putty)


Actually booting off VGA then setting the loader settings could be the problem. Have you tried hitting enter key repeatedly in putty?
Have you tried modifying a FreeBSD memstick installer with the /boot/loader.conf serial console settings already set?
That is the best way. It will run FreeBSD installer and ask you what mode. Pick vt100 and then you get a text mode install.

There is another Windows terminal program that I like too, TerraTerm.
https://osdn.net/projects/ttssh2/releases/


----------



## Phishfry (May 31, 2018)

One more question. Does this computer you are attempting to connect to via serial console use Serial-Redirect in the BIOS?
Serial Console will work without "Serial Redirect" settings in the BIOS but you will not see anything on screen until you get to the loader section of boot up sequence.


----------



## Rajesh (Jun 1, 2018)

Hi Phishfry, Thanks for multiple inputs.  To answer your questions one by one..



Phishfry said:


> Also double check the setting for the port speed in Windows. It has to be set there in the device manager and in putty



I made sure the setting in device manager and the settings in putty serial connection are same and they are compatible with the peer setting (freebsd box, which i am trying to get serial console)



Phishfry said:


> Are you sure that the device you are connecting to uses COM1.
> On some servers COM1 is used for iDRAC or other Lights-out BMC stuff.
> Devices with an RJ45 comm port you see the same. RJ45-Console=COM1 and DB9=COM2



Actually, by default device manager takes the serial console as COM6.  Since, it doesn't work, I manually changed to COM1 and tried. But still no luck.  Today I tried with COM1, COM2 and COM6 without VGA.  No luck. Still blank screen only.



Phishfry said:


> Actually booting off VGA then setting the loader settings could be the problem. Have you tried hitting enter key repeatedly in putty?
> Have you tried modifying a FreeBSD memstick installer with the /boot/loader.conf serial console settings already set?
> That is the best way. It will run FreeBSD installer and ask you what mode. Pick vt100 and then you get a text mode install.
> 
> ...



I tried without VGA after changing the /boot/loader.conf.  But still blank screen only seen.  I couldn't install the TerraTerm program.  Seems it's pretty old to run in windows 10.  I made sure the /boot/loader.conf settings are proper by connecting to VGA and read the /boot/loader.conf file from loader prompt. It's all intact.



Phishfry said:


> One more question. Does this computer you are attempting to connect to via serial console use Serial-Redirect in the BIOS?
> Serial Console will work without "Serial Redirect" settings in the BIOS but you will not see anything on screen until you get to the loader section of boot up sequence.



Yes, this machine has a serial-redirect in BIOS.  Those are enabled and here is the settings
Terminal Type - VT100
Bits per second - 115200
Data bits - 8
Parity - None
Stop Bits - 1
Flow control - None
Vt-UTF8 combo key sup - Enabled
Recorder Mode - Disabled
Resolution 100x31 - Disabled
Legacy OS redirection - 80x24
putty keypad - VT100
Redirection after BIOS - Always Enable

Note: I have two serial ports, with both of them having the same settings.  One wierd thing I see here is, If I change the Bits per second to 9600 in port 0, I see the VGA console output getting slower (output drawn line by line).

Also, I tried changing the serial cable and the USB connector. But no luck.


----------



## Phishfry (Jun 1, 2018)

One thing I noticed is you are only using part of the comconsole line:


Rajesh said:


> set console=comconsole


The handbook says to use : set console=comconsole,vidconsole
And I think its best. Especially going back and forth trying VGA and console.
The Vidconsole setting at worst case has no effect at all. Even in a serial only box with no video on the CPU.
On boxes where you are using VGA to set loader commands, it seems to me it is essential.
Use it until you get this worked out, it has no ill effects.


----------



## SirDice (Jun 1, 2018)

Rajesh said:


> Redirection after BIOS - Always Enable


I think you need to turn this off. It's probably keeping the serial port occupied so FreeBSD can't use it for its console.


----------



## Rajesh (Jun 1, 2018)

First, I tried setting both of them.  But seems "vidconsole" is invalid in my setup

OK show console
comconsole
OK set console=comconsole,vidconsole
console vidconsole is invalid!
Available consoles:
     efi
     comconsole
     nullconsole
OK

If I set "nullconsole" alone (or along with comconsole), even VGA console output goes away.


----------



## Rajesh (Jun 1, 2018)

SirDice said:


> I think you need to turn this off. It's probably keeping the serial port occupied so FreeBSD can't use it for its console.



Another option for this is "BootLoader".  If I set to that, I don't see any change. Still blank screen only.


----------



## SirDice (Jun 1, 2018)

Try turning off any and all serial console port settings in the BIOS. I have a suspicion they're keeping the port locked preventing FreeBSD from using it.


----------



## Rajesh (Jun 5, 2018)

Hi SirDice, Sorry for the delayed response.  In BIOS, I don't see much setting with respect to Serial port.  There is one section for serial port settings. It lists two serial ports. Both are enabled.  And for each enabled port, there is a subsection, which has the setting I listed in comment #15 above.

As I said in comment #15, If I change the Bits per second to 9600, I see the VGA console output getting slower (output drawn line by line). So, inline with your  comment #20, I doubted VGA port doing something with respect to serial port. But I have already experimented unplugging the VGA port cable (headless) and tried just to get the serial console. But no luck.

One another test I did is to turn off all ttyvX from /etc/ttys and just have the ttydX(Serial terminals) and Dumb console on.  But no luck. Wierdly, If i plug back the VGA cable, I see the beastie menu and boot logs in VGA output screen (which I believe shouldn't be the case).  So, I am really confused.

At this point, I have two questions.
1)  Why changing the Bits per second in serial port settings is slowing down the VGA output?
2)  How even after turning off the ttyvX in /etc/ttys, I see the beastie menu and boot logs in VGA output?

Another thread (https://forums.freebsd.org/threads/serial-console-problem.15740/), suggests to disable acpi and test.  But when I disabled acpi, I am running into panic with message "running without a device atpic requires a local APIC".  So, I am compiling the src again with "device atpic" set in GENERIC, so that I can try running with ACPI disabled.  I will post the results of it. 

Meanwhile, Is there anything else I can try to get the serial console working? Or any other way to capture the boot logs from VGA output (No IPMI is there)?


----------



## Phishfry (Jun 5, 2018)

Rajesh said:


> 2) How even after turning off the ttyvX in /etc/ttys, I see the beastie menu and boot logs in VGA output?


You might want to do some reading on boot0. Depending on its settings it looks for video and keyboard.

Halfway down the page gives some good insight.
https://harrykar.blogspot.com/2010/06/freebsd-booting-and-shutting-down.html

I don't think I have ever disabled ACPI for a serial console.


----------



## Rajesh (Jun 6, 2018)

Hi Phishfry,  I believe you said about the option (-h, -D, -Dh or -P) in /boot/config. If so, I have already tried that. But still facing the issue.  If you mean something else, please correct me.

Today, I tried serial console for a Linux server with the same set of cables I used with Freebsd. I don't see the serial console working there as well.  So, wondering cable has any issues.  I tried 2 ways of cabling.

1. Null Modem cable from freebsd server connected to serial->usb converted and connected to windows through usb --> This used to be working with linux servers.  Not sure what is different now.
2. Directly connected a serial to usb converter to freebsd server through a gender changer and the usb side to the windows. 

I will do some more testing to make sure about the cabling part.  Anyway, Thanks for the inputs.


----------



## Rajesh (Jun 8, 2018)

Sorry about the trouble here. Null modem cable I used is the problem here. Seems the connection went like direct line rather than cross-over..  Today I manually did a cross-over connection and I could see the boot menu in serial console (Even without any loader tunables set).

But I am facing another issue now. In the serial console, I see the logs only upto the following.  After that I don't see anything in the serial console, but VGA output show the boot logs. Any idea why? I tried reducing the speed to 9600 and also set the previously said loader tunables. But I see the logs only upto the following.

/boot/kernel/kernel text=0x14972f8 data=0x1384c0+0x4c15e8 syms=[0x8+0x15e8b0+0x8+0x178422]
Booting...
Start @ 0xffffffff80302000 ...


----------



## Rajesh (Jun 11, 2018)

Following a similar issue reported below,

https://docs.freebsd.org/cgi/getmsg.../freebsd-questions/20090830.freebsd-questions

I tried setting hw.uart.console="io:0x3F8" (or) hw.uart.console="io:0x2F8" (set the flags of corresponding uart to 0x10) from loader.conf, but it didn't help in my case.  For sure, I am missing some simple thing. But not sure what it is.

Note: For Testing, I manually connected Pin 5 to Pin 5, Pin 2 to Pin 3 and Pin 3 to Pin 2 directly.  No other pins are connected (DTR, DSR and DCD) are not touched.  I assume this is good for "None" Flow control case, as I am seeing the output on serial console upto FreeBSD loader. Only Kernel message are not seen.  Please correct me if I am doing wrong.


----------



## Rajesh (Jun 13, 2018)

I tried with multiple baud rate (9600, 19200, 38400, 57600 and 115200). But no luck. Here are the changes I have for each speed,

1. Set the speed to X (Eg: 115200) in BIOS for the COM0 serial port.  (Other Constant values: Data bits - 8, Stop bits - 1, Parity - 1, Flow Control - None)
Mounted bootable usb and made the following changes
2.  boot.config

```
-SX -Dh
Eg: -S115200 -Dh
```
3.  boot/loader.conf

```
boot_multicons="YES"
boot_serial="YES"
comconsole_speed="X" (Eg: 115200)
comconsole_port=0x3F8
console=comconsole
hw.uart.console="io:0x3F8"
```
4.  boot/device.hints

```
hint.uart.0.at="isa"
hint.uart.0.baud="X" (Eg: 115200)
hint.uart.0.flags=0x10
hint.uart.0.port=0x3F8
hint.uart.1.at="isa"
hint.uart.1.baud="X" (Eg: 115200)
hint.uart.1.port=0x2F8
```
5. etc/ttys

```
ttyu0   "/usr/libexec/getty 3wire"   vt100   onifconsole secure
Otherways,
ttyu0   "/usr/libexec/getty 3wire.X"   vt100   onifconsole secure (Eg: 3wire.115200)
ttyu0   "/usr/libexec/getty std.X"   vt100   onifconsole secure (Eg: std.115200)
```

From Windows, I have the serial settings as below and connected.

```
Speed - X (Eg: 115200)
Data bits - 8
Stop bits - 1
Parity - 1
Flow Control - None
```

One other reason I could see is,
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193745#c22

Could this reason be the case here? Or is there anything wrong in the above settings or its order?


----------



## Phishfry (Jun 14, 2018)

Rajesh said:


> Set the speed to X (Eg: 115200) in BIOS for the COM0 serial port.


Now this is the first you mentioned COM0.

Me and jef were just talking about COM0 on our Lanner Boxes.
So like I said to him, COM0 in BIOS console redirect = The RJ45 Serial Port.
On these boards there is no db9 serial. So I added one to the motherboard header for COMb.
Then in BIOS I have to enable Serial Redirect for COM1 for Serial redirect to the second serial port.
Now the operating system see's these as COM1 and COM2
To get COM2 serial console working I had to add a setting
(Search dmesg for the port number of your serial port (0x2f8 for COM2 on my motherboard)):
`comconsole_port=0x2f8`
To the /boot/loader.conf settings for comconsole on serial port 2.
.
Also you need to edit /etc/ttys to configure the second serial port for a console.
`ttyu1   "/usr/libexec/getty std.115200" vt100   onifconsole secure`
.
So maybe your board had an option for RJ45 console and it was left off, but BIOS still thinks it is there.
So in the bios console redirect screen try and change COM0 to COM1. On many boards you can have serial redirect over both.
COM0 and COM1

That's all i got. Are you absolutly sure there is no serial console jack. A RJ45 connector that looks exactly like a LAN jack.
It is easy to confuse them.


----------



## Rajesh (Jun 15, 2018)

Hi Phishfry, Sorry about the delayed response.

*Hardware:*   2 DB-9 serial ports, 4 USB 3.0 ports, 2 SFP network ports on-board.  Apart from this, there is a PCI VGA card with traditional VGA port. No RJ45 kind of port.

*BIOS:*  Serial port redirection settings list two serial ports COM0 and COM1. Both are enabled and each have their own settings for baudrate, flow control etc.,

In comment #26, I have given the setting I had for getting the serial console using COM0 (I have disabled COM1 in BIOS). Likewise and inline with what you have said in comment #27, I made similar changes (in /boot/loader.conf and /etc/ttys) to get serial console using COM1(disabling COM0 in BIOS). But I still couldn't get the boot logs in serial console.



Phishfry said:


> Now the operating system see's these as COM1 and COM2



Since, I am hitting issues during Installation part itself, I couldn't see how the serial ports are seen by the OS.

*Other tests and observations:*

1. When trying to get the serial console via COM0, I see lot of other logs(may be BIOS logs) before the freebsd loader prompt.  Not sure if any other service is using COM0 port for its output (like SirDice mentioned in comment #20).  I don't see those logs in VGA output.  Any idea what logs it could be?
2. When trying to get the serial console via COM1, I DO NOT see those other logs (what I see with COM0).
3. If I change the Baud rate of any of the serial ports in BIOS, I could see the VGA output getting impacted.  Not sure how this could happen?
4. Whatever I see in serial console (BIOS, Beastie menu and loader prompt), I see them even without any setting I mentioned in comment #26. 
5. For testing, I experimented with Linux and its Serial port setting.  There also, I could see the grub loader menu in serial console, but boot logs are not seen in serial console.  But login prompt appears in serial console, once the boot is complete.  Wierd. 

So, I am confused whether the problem is with FreeBSD (or) BIOS (or) the board configuration. Based on the observations mentioned, if you people have any comments, please share


----------



## Phishfry (Jun 15, 2018)

How about we take another tact. What exact hardware are you using. Either motherboard or server name and model.

Disabling COM1 in the BIOS seems counter-intuitive.
You need the hardware serial on for the software serial console to have somewhere to land.
Software serial console is just a module added into the bios.


----------



## Rajesh (Jun 19, 2018)

Hi Phishfry,  I am using a new development board which is AMD EPYC processor based, with 128GB of memory and 500GB HDD.  Apart from this, as mentioned earlier, this boards has 2 DB-9 serial ports, 4 USB 3.0 ports, 2 SFP network ports on-board and a PCI attached VGA card with traditional VGA port. Please let me know if you need any specific details.



Phishfry said:


> Disabling COM1 in the BIOS seems counter-intuitive.
> You need the hardware serial on for the software serial console to have somewhere to land.
> Software serial console is just a module added into the bios.



For testing, I disabled one serial port while I was trying to get the serial console on another.  But, even with both ports enabled in BIOS, I see the same behavior as mentioned in comment #28


----------



## Rajesh (Jun 27, 2018)

Any other clue here? or any other inputs needed?


----------



## Phishfry (Jun 27, 2018)

I have been working serial consoles heavy the last month. So everything I wrote seems accurate.
Only 2 things stand out. What is COM0 if you have no RJ45 serial console.
Some boards use COM0 for the Serial over LAN. Never messed with it.

#2 issue VGA card installed. Pull it and see if you get anything without it.
There are certain things that go on during boot from comconsole, vidconsole, like checking for video and keyboard.
Also FreeBSD might detect video card where there is only video on the CPU cores. With no video jacks.
So no video card is really a must for debugging this. Setup SSH to work on it until you figure it out.
You would think a 'develoment box' would have DB9 COM1 serial console.

What is the connection platform you are using to try and connect? FreeBSD and cu ?


----------



## Phishfry (Jun 27, 2018)

The way you said you had slow video come up makes me wonder if it could be a ground problem.
Maybe a flakey connection forced it to a lower speed. Have you tried both null modem and straight through cables?
Most computer serial consoles use null modem cable, but you never know.


----------



## Rajesh (Jun 28, 2018)

Hi Phishfry,

Thanks for your inputs.

Please find the pic of my board's I/O. You can see the ports what I have mentioned earlier. Apart from this, there is a VGA card by the side, which is connected to the monitor. I have tried without having a VGA card also. But no luck.








Phishfry said:


> You would think a 'develoment box' would have DB9 COM1 serial console.



Any reason, why a development box can't have a DB9 COM1 serial port?



Phishfry said:


> What is the connection platform you are using to try and connect? FreeBSD and cu ?



Are you asking about the connector I am using? If so, I have tried the following

1) A Straight through cable (one end connected to FreeBSD, other end to USB to serial convertor and the USB side is connected to my windows box).  This way, I am not getting anything on the putty serial console from windows.

2) I made a 3-wire cross over directly (connected pin2 of usb serial converter to pin 3 of FreeBSD DB9, vice versa and connected ground pin5 of usb serial converter to pin5 of FreeBSD DB9).  This way, I am getting the serial console output till loader prompt, but not anything after that.

Let me know if you are looking for something else.



Phishfry said:


> The way you said you had slow video come up makes me wonder if it could be a ground problem.
> Maybe a flakey connection forced it to a lower speed. Have you tried both null modem and straight through cables?
> Most computer serial consoles use null modem cable, but you never know.



I couldn't get what you mean by ground problem here?  As I said above, I have tried with both null modem and straight through cable. But both cases are not fruitful.

I understand, we have discussed and tried whatever is possible.  But, just curious to get it working and see the boot logs in serial console.


----------



## Rajesh (Jul 11, 2018)

Here are few more updates.

Seems, the uart for the serial port in my board is synopsys designware. And the driver (uart_snps) for that is not enabled by default (GENERIC kernel). So, I had a custom kernel compiled with "device uart_snps" set.  But I faced some compilation issues saying "ofw_bus_if.h".  So, I managed to compile the kernel masking all "ofw" reference in uart_dev_snps.c

With that kernel, after booting, I see the following

```
#kldstat -v | grep uart

simplebus/uart_snps

puc/uart

pci/uart

pccard/uart

isa/uart

acpi/uart
```

With this kernel, I made the config settings for serial console as mentioned in comment #26. But still, no luck.  

Question is,  any known issues (or) anything missing with "uart_snps" to have that compilation issue? In general, any idea how to compile and use the uart_snps driver for serial console?

Note: Initially, we faced serial console issue with Linux as well, but after enabling CONFIG_SERIAL_8250_DW (to enable synopsys designware driver), things are working in Linux.


----------



## Phishfry (Jul 11, 2018)

I would have never guessed that.
You are a trooper. I am looking around to see what I can find.
"ofw_bus_if.h".
So you realize OFW is Open Firmware which tells me this is predominantly used in Arm devices.
It now makes me wonder about some of the newfangled 'serial' consoles.
My gigabyte server board has a mini USB jack for OTG Port. These don't work like good old serial comms.
They need a driver. Thank goodness they included a RS232 on my board too.

SERIAL_8250 is interesting. I guess this different than your standard 16550.


----------



## Phishfry (Jul 11, 2018)

OK I see this and something dawned on me.
https://www.freebsd.org/doc/en/articles/serial-uart/index.html

FreeBSD uses hint for UARTS and maybe 8250 uses different port addresses.
COM1 and COM2 are coded in /boot/device.hints

So if you think your COM driver is working good then look at the port address it provides.
Here is the relevant snippet of what FreeBSD expects:

```
hint.uart.0.at="isa"
hint.uart.0.port="0x3F8"
hint.uart.0.flags="0x10"
hint.uart.0.irq="4"
hint.uart.1.at="isa"
hint.uart.1.port="0x2F8"
hint.uart.1.irq="3"
```
I have been messing around with serial comms alot recently.
If you want UARTs on COM3 and COM4 to show up you must add them here manually.
But you can also adjust/change COM1 and COM2 here.


----------



## Phishfry (Jul 11, 2018)

Looking at that driver I doubt if you can just strip out OFW.
ofw_bus_get_node(dev);
Generally my experience is that Arm drivers are not backward compatible.
For instance OneWire drivers will not work on X86 GPIO because of the same issue. OFW and Device Tree.
The driver was written for Arm boards..

This is just a theory on my part. The best thing to do in the case of an obscure driver is ask the author.
Jared is still active and his details are in the source header.
First question for him is "will it work on X86" and if so what mods are needed to make it compile..
Explain your situation clearly and maybe even send him a link to this thread.


----------



## Rajesh (Jul 13, 2018)

Phishfry said:


> So you realize OFW is Open Firmware which tells me this is predominantly used in Arm devices.



Yes, I could realize the term as open-firmware. But I have no idea, what that is.  Do you have any read references for it?  And I am working on amd64 architecture only, not ARM based.

Regarding the device hints, I have already played around using them (as mentioned in comment #26). But no luck. But, I need to see whether the port address is changed in my case. I will check about that as well.

Also, better I send a note to Jared as you mentioned explaining the problem and seeking clarification. I will keep the thread posted.  Thanks Phishfry for your answers here.


----------



## Phishfry (Jul 21, 2018)

I see on Warners page an interesting way. Use Linux to get the UART address and pipe that back to FreeBSD, either through beastie prompt or /boot/device.hints No driver needed. Needs a register shift directive.
https://bsdimp.blogspot.com/2018/07/how-to-get-memory-mapped-serial-console.html
Rajesh Is this Warner helping you or somebody else with a similar problem?


----------



## Rajesh (Jul 23, 2018)

Hi Phishfry, 

Sorry about the delayed response.

Interesting, I had the same suggestion from another person last week. I was little lazy to say it here.  But, it was not Warner, but another guy. With that tunable, I could see the serial console working.  Thanks for pointing this Phishfry and Thanks for all your inputs.


----------



## Phishfry (Jul 23, 2018)

Thank You for confirming it works.
Just for my sake does the port address appear to be the same address and RS  the one on Warners page?
I am wondering if this is the same hardware or different. We may see more of this in the future.


----------



## Rajesh (Jul 24, 2018)

Yes Phishfry, It's exactly the same port address and the register shift. Looks like same hardware only. That's what is interesting. Do you have any idea about Warner's hardware (or) how he has landed in a similar situation?


----------



## Phishfry (Jul 24, 2018)

No but I just so happening to be looking at his blog and saw the recent addition and thought of you.
Warner and Gonzo are two of the most knowledgeable guys on FreeBSD and I lilke reading technical blogs.
You would think with such an odd serial port address the manufacturer would note that factoid somewhere!


----------



## Rajesh (Jul 24, 2018)

Fine Phishfry. That's a good catch.
What I understand is port address 0x2F8/0x3F8 are used in legacy way and the address in that blog post are used in non-legacy way. I will update if I get more clarity here.


----------

