OPNsense Forum

English Forums => 24.7, 24.10 Legacy Series => Topic started by: Lantern5 on August 06, 2024, 03:39:42 AM

Title: No serial port - Console Access using USB?
Post by: Lantern5 on August 06, 2024, 03:39:42 AM
Hi all,
Just started using Opnsense, bare metal install on a Lenovo M900 tiny PC. The unit I bought does not have a serial port, and the slot is taken up by the second NIC anyways. The system is in a tight spot and I want some kind of out of band access.

Is it possible to get console access using a USB - Serial convertor? I was thinking of getting two of these with a female-female adaptor in between. Both ends of the cable will be USB, one on the opnsense host and the other on my laptop. Will this work? Or do I need to look at other options?

https://www.amazon.com/gp/product/B0759HSLP1/ref=ox_sc_act_title_1?smid=A1IR1GJH6XB88L&th=1
Title: Re: No serial port - Console Access using USB?
Post by: hansdampf on August 06, 2024, 06:13:33 AM
I had problems with FTDI-Adapters, Adapters with PL2303-Chip (RS232) worked directly without problems...
https://www.prolific.com.tw/US/ShowProduct.aspx?pcid=41&showlevel=0017-0037-0041

Otherwise try an adapter for RS232. (I mostly needed to install a driver, which doesnt exist for Freebsd)
https://ftdichip.com/product-category/products/cables/

But i dont know if they are supported now with Freebsd 13/14.
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on August 06, 2024, 09:07:37 AM
ok I found another one with a PL2303 chip, but will it work off a USB port on the opnsense box?

This is what I have in mind, will it work?

Opnsense box --> USB  -->DB9Serial<-->DB9Serial-->USB -->Laptop
Title: Re: No serial port - Console Access using USB?
Post by: doktornotor on August 06, 2024, 09:13:13 AM
PL2303 works just fine when you enable the USB serial console setting.
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on August 06, 2024, 11:09:00 AM
Quote from: doktornotor on August 06, 2024, 09:13:13 AM
PL2303 works just fine when you enable the USB serial console setting.

As in USB on the Opnsense box? And do I need a serial convertor or can it be straight USB to USB?
Title: Re: No serial port - Console Access using USB?
Post by: Greg_E on August 06, 2024, 03:09:15 PM
You will probably need a null-modem coupler between the two serial connections, especially since they will likely both have the same connector on the end.
Title: Re: No serial port - Console Access using USB?
Post by: Patrick M. Hausen on August 06, 2024, 03:18:25 PM
Apparently USB-Nullmodems exist:

https://hackaday.com/2020/08/25/the-usb-null-modem-cable-is-now-a-thing/
https://ftdichip.com/products/usb-nmc-2-5m/
https://de.aliexpress.com/item/1005001407066778.html

Cool  8)

HTH,
Patrick
Title: Re: No serial port - Console Access using USB?
Post by: doktornotor on August 06, 2024, 07:43:17 PM
Quote from: Patrick M. Hausen on August 06, 2024, 03:18:25 PM
Apparently USB-Nullmodems exist:

https://hackaday.com/2020/08/25/the-usb-null-modem-cable-is-now-a-thing/
https://ftdichip.com/products/usb-nmc-2-5m/
https://de.aliexpress.com/item/1005001407066778.html

Well, this has worked for me a couple of times:

https://a.co/d/6rdWQW9
Title: Re: No serial port - Console Access using USB?
Post by: Greg_E on August 06, 2024, 10:46:51 PM
Quote from: doktornotor on August 06, 2024, 07:43:17 PM
Quote from: Patrick M. Hausen on August 06, 2024, 03:18:25 PM
Apparently USB-Nullmodems exist:

https://hackaday.com/2020/08/25/the-usb-null-modem-cable-is-now-a-thing/
https://ftdichip.com/products/usb-nmc-2-5m/
https://de.aliexpress.com/item/1005001407066778.html

Well, this has worked for me a couple of times:

https://a.co/d/6rdWQW9

That's what I was thinking of, but I normally build my own (having parts on hand).

I like that first link that Patrick gave us, that's pretty cool and might be useful down the road for those odd times when needed. I'll have to look into it a bit more.
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on August 28, 2024, 12:56:05 PM
Thanks everyone, I bought the USB to serial cable and am able to get console access to the Opnsense box. However, there's no console output until the OS fully boots up.

The link below seems to indicate that serial can be active during boot. I'm using a VGA image, will switching to the serial image help to get console access during boot?

https://serverfault.com/questions/918972/serial-over-usb-during-boot
Title: Re: No serial port - Console Access using USB?
Post by: doktornotor on August 28, 2024, 12:59:00 PM
System - Settings - Administration - Console: Primary console
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on August 28, 2024, 09:26:52 PM
Quote from: doktornotor on August 28, 2024, 12:59:00 PM
System - Settings - Administration - Console: Primary console

Already set to Serial Console and "Use USB-based serial ports" is ticked. Do I need to change any other settings?
Title: Re: No serial port - Console Access using USB?
Post by: Patrick M. Hausen on August 28, 2024, 09:29:50 PM
Well, using a USB based serial console needs OS support, so no wonder you get output only once it is booted. Your system's BIOS as well as the boot loader do not support USB serial devices as console, so there is no way to access these phases of the boot process.

You would need a builtin serial port and BIOS support to see anything before the OS is up and running.
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on August 28, 2024, 09:37:18 PM
Quote from: Patrick M. Hausen on August 28, 2024, 09:29:50 PM
Well, using a USB based serial console needs OS support, so no wonder you get output only once it is booted. Your system's BIOS as well as the boot loader do not support USB serial devices as console, so there is no way to access these phases of the boot process.

You would need a builtin serial port and BIOS support to see anything before the OS is up and running.

Pardon my ignorance, but USB boot and install from USB storage is possible; and I guess that means USB is enabled at power up? And I believe Serial being bi-directional it doesnt matter which end (USB or RS-232) is plugged into the opnsense box?
Title: Re: No serial port - Console Access using USB?
Post by: Patrick M. Hausen on August 28, 2024, 10:09:05 PM
Console is different. Seriously. I know of no BIOS that would support a USB serial console.
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on August 28, 2024, 11:16:50 PM
I meant USB working at the OS level before it fully boots up. The Opnsense image for serial install provides output over serial while reading off a USB storage device? That would mean both serial and USB are recognised by the installer?

Would the serial image be able to provide console output to serial during boot up after I complete the full installation? Or is it limited to the install process only?
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on August 29, 2024, 12:44:58 AM
Quote from: Lantern5 on August 28, 2024, 11:16:50 PM
I meant USB working at the OS level before it fully boots up. The Opnsense image for serial install provides output over serial while reading off a USB storage device? That would mean both serial and USB are recognised by the installer?

Would the serial image be able to provide console output to serial during boot up after I complete the full installation? Or is it limited to the install process only?

If this will not work, I'll have to install a physical serial port. Bit the problem is that the spare port on the rear panel is taken up by the second NIC and I'll have to rig an extension cable and install the serial port outside the case.

I have attached a photo of the com port header can someone tell me what type of connector it is?

Title: Re: No serial port - Console Access using USB?
Post by: Patrick M. Hausen on August 29, 2024, 08:03:30 AM
Quote from: Lantern5 on August 28, 2024, 11:16:50 PM
Would the serial image be able to provide console output to serial during boot up after I complete the full installation?
Over a regular serial port, definitely. Don't know about USB serial, I don't use that myself.

As for the connector: nothing in the mainboard manual?
Title: Re: No serial port - Console Access using USB?
Post by: franco on August 29, 2024, 08:10:01 AM
Late to the party but just to be clear: an USB serial port is a serial port presented via US-Bus. It's a device you typically plug into an USB port. Anything that isn't an USB port is not an USB serial. The exception to this rule is that some manufacturers (like Deciso) use a serial port that is only externally presenting USB, but not internally wired as a plain serial port (like shown in the picture).


Cheers,
Franco
Title: Re: No serial port - Console Access using USB?
Post by: Patrick M. Hausen on August 29, 2024, 08:17:38 AM
This thread is specifically about adding a USB to serial converter to the OPNsense host to use as the console device. See first post. Open question is if it's possible to interact with the boot loader and watch kernel messages that way before configd (?) starts the getty process for login.

Do you happen to know, Franco?
Title: Re: No serial port - Console Access using USB?
Post by: franco on August 29, 2024, 08:22:57 AM
I was mostly commenting on the picture shown...

If we talk USB to serial with USB being plugged into OPNsense and the serial end somewhere else ti view the OPNsense thing:

I don't exactly know.

Checking src.git/stand/usb however, it looks like the (later) boot code could be capable of attaching USB devices similar to ZFS being bootable from there. So in theory it should be possible to see the boot menu at least and all the kernel messages during boot given that the serial console is the primary console.


Cheers,
Franco
Title: Re: No serial port - Console Access using USB?
Post by: doktornotor on August 29, 2024, 08:29:32 AM
Quote from: Lantern5 on August 29, 2024, 12:44:58 AM
I have attached a photo of the com port header can someone tell me what type of connector it is?

Well, looks like 14 pin.  ;D Would need something similar to this, or DIY... https://www.amazon.com/PNGKNYOCN-Serial-Motherboard-Header-Cable%EF%BC%881-8m/dp/B0BGQ96LX5
Title: Re: No serial port - Console Access using USB?
Post by: franco on August 29, 2024, 08:34:53 AM
True story: a user was once asking in IRC why his serial console was wonky. When he finally showed me a picture you could see the bare minimum of actual loose wires dangling from the mainboard into a serial connector matching end "attached" to it. After buying a proper shielded cable the problem was obviously gone he later reported.


Cheers,
Frnaco
Title: Re: No serial port - Console Access using USB?
Post by: doktornotor on August 29, 2024, 08:49:04 AM
The picture - perhaps something like ARM JTAG-14 (https://developer.arm.com/documentation/dui0499/d/ARM-DSTREAM-Target-Interface-Connections/ARM-JTAG-14). Motherboard manual for pinout description would be useful.
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on August 29, 2024, 11:43:49 PM
Quote from: franco on August 29, 2024, 08:22:57 AM
I was mostly commenting on the picture shown...

If we talk USB to serial with USB being plugged into OPNsense and the serial end somewhere else ti view the OPNsense

Two USB-Serial cables connected to each other, so USB at either end, and it works well. Console becomes available
after the login message appears on screen. Would it be possible to get console before the login screen appears so I can view the boot up messages for troubleshooting.
Title: Re: No serial port - Console Access using USB?
Post by: franco on August 30, 2024, 06:50:19 AM
Yeah but you still have a serial converter in there twice ;)

And:

Quote from: franco on August 29, 2024, 08:22:57 AM
So in theory it should be possible to see the boot menu at least and all the kernel messages during boot given that the serial console is the primary console.


Cheers,
Franco
Title: Re: No serial port - Console Access using USB?
Post by: Greg_E on August 30, 2024, 03:17:48 PM
Does EFI support USB serial devices inside it's firmware? That might be the only way I could see a USB serial device working before the OS loads all of the appropriate "stuff" to talk on the interface.
Title: Re: No serial port - Console Access using USB?
Post by: Lantern5 on September 08, 2024, 08:19:01 AM
*Update in case someone else has a similar requirement.*

It turns out that the Lenovo M900 Tiny PC I am using is capable of Intel AMT, which provides remote manageability at the BIOS level. After enabling the feature in BIOS, I am able to manage the device using opensource software called Mesh Commander.

The caveat is that Intel AMT works only with Intel 'LM' series NICs which is usually the onobard NIC on these little corporate PCs.

Thanks for your responses everyone.