commit | 4ec26bb16e3a8ef10b4c00a50605c70e2a5c228b | [log] [tgz] |
---|---|---|
author | Igor Kononenko <i.kononenko.e@gmail.com> | Thu Aug 29 13:54:56 2024 +0300 |
committer | Ninad Palsule <ninad@linux.ibm.com> | Mon Jan 27 21:51:52 2025 -0600 |
tree | dfbe43f1683ed0f1a1125bdd9937ef7033fea50f | |
parent | 366651d9ef0e03f97b1e1d2b6188f2b452044d1c [diff] |
obmc-console: fix segfault on missing config The `obmc-console-client` allow to not specify configuration file for active session. But at the same time it does not tolerate null pointer passed as config. This leads to a segmentation fault due to a missing configuration file. Fix this small inconvenience. Added testcase to make sure that obmc-console-client doesn't segfault when invoked without any arguments. Output without the fix: ''' + /home/dev/obmc-console/build/obmc-console-client + grep Connection refused Segmentation fault (core dumped) ''' Output with the fix: ''' + /home/ninad/dev/1110_ghe/obmc-console/build/obmc-console-client + grep Connection refused + cleanup + cd - + rm -rf /tmp/test_console_client_no_args_3245394.DZqk0S ''' Change-Id: Ia83da8bca30e2be94e00066f20f2cbe2ccba23b6 Tested-by: Ninad Palsule <ninad@linux.ibm.com> Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> Signed-off-by: Igor Kononenko <i.kononenko.e@gmail.com>
To build this project, run the following shell commands:
meson setup build meson compile -C build
To test:
dbus-run-session meson test -C build
Running the server requires a serial port (e.g. /dev/ttyS0):
touch obmc-console.conf ./obmc-console-server --config obmc-console.conf ttyS0
To connect to the server, simply run the client:
./obmc-console-client
To disconnect the client, use the standard ~.
combination.
This shows how the host UART connection is abstracted within the BMC as a Unix domain socket.
+---------------------------------------------------------------------------------------------+ | | | obmc-console-client unix domain socket obmc-console-server | | | | +----------------------+ +------------------------+ | | | client.2200.conf | +---------------------+ | server.ttyVUART0.conf | | +---+--+ +----------------------+ | | +------------------------+ +--------+-------+ Network | 2200 +--> +->+ @obmc-console.host0 +<-+ <--+ /dev/ttyVUART0 | UARTs +---+--+ | console-id = "host0" | | | | console-id = "host0" | +--------+-------+ | | | +---------------------+ | | | | +----------------------+ +------------------------+ | | | | | | | +---------------------------------------------------------------------------------------------+
This supports multiple independent consoles. The console-id
is a unique portion for the unix domain socket created by the obmc-console-server instance. The server needs to know this because it needs to know what to name the pipe; the client needs to know it as it needs to form the abstract socket name to which to connect.
In some hardware designs, multiple UARTS may be available behind a Mux. Please reference docs/mux-support.md in that case.
For developing obmc-console, we can use pseudo terminals (pty's) in Linux.
The socat command will output names of 2 pty's, one of which is the master and the other one is the slave. The master pty can be used to emulate a UART.
$ socat -d -d pty,raw,echo=0,link=pty1 pty,raw,echo=0,link=pty2 $ obmc-console-server --console-id dev $(realpath pty2) $ obmc-console-client -i dev # this message should appear for the client $ echo "hi" > pty1