Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,139 @@
From ead759007999573bf37d1ea01bf19ae76af79e01 Mon Sep 17 00:00:00 2001
From: roly <Rolyli.Li@luxshare-ict.com>
Date: Wed, 20 Nov 2024 15:16:53 +0800
Subject: [PATCH] Support SOL non-volatile bitrate and volatile bitrate
---
console-dbus.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++----
meson.build | 2 +-
2 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/console-dbus.c b/console-dbus.c
index dd53908..e0c0011 100644
--- a/console-dbus.c
+++ b/console-dbus.c
@@ -19,6 +19,7 @@
#include <err.h>
#include <string.h>
#include <sys/socket.h>
+#include <stdlib.h>
#include "console-server.h"
@@ -53,7 +54,7 @@ static void tty_change_baudrate(struct console *console)
}
}
-static int set_baud_handler(sd_bus *bus, const char *path,
+static int set_non_volatile_baud_handler(sd_bus *bus, const char *path,
const char *interface, const char *property,
sd_bus_message *msg, void *userdata,
sd_bus_error *err __attribute__((unused)))
@@ -61,6 +62,8 @@ static int set_baud_handler(sd_bus *bus, const char *path,
struct console *console = userdata;
uint64_t baudrate;
speed_t speed;
+ char buf[64] = {0};
+ int encodedBitRate = 0;
int r;
if (!console) {
@@ -84,6 +87,63 @@ static int set_baud_handler(sd_bus *bus, const char *path,
sd_bus_emit_properties_changed(bus, path, interface, property, NULL);
+ switch(baudrate)
+ {
+ case 9600:
+ encodedBitRate = 0x06;
+ break;
+ case 19200:
+ encodedBitRate = 0x07;
+ break;
+ case 38400:
+ encodedBitRate = 0x08;
+ break;
+ case 57600:
+ encodedBitRate = 0x09;
+ break;
+ case 115200:
+ encodedBitRate = 0xa;
+ break;
+ default:
+ encodedBitRate = 0xa;
+ break;
+ }
+ snprintf(buf, sizeof(buf), "fw_setenv hostserialcfg %d", encodedBitRate);
+ system(buf);
+ system("/usr/bin/sol-configure.sh setup");
+ return 1;
+}
+
+static int set_volatile_baud_handler(sd_bus *bus, const char *path,
+ const char *interface, const char *property,
+ sd_bus_message *msg, void *userdata,
+ sd_bus_error *err __attribute__((unused)))
+{
+ struct console *console = userdata;
+ uint64_t baudrate;
+ speed_t speed;
+ int r;
+
+ if (!console) {
+ return -ENOENT;
+ }
+
+ r = sd_bus_message_read(msg, "t", &baudrate);
+ if (r < 0 || baudrate > UINT32_MAX) {
+ return -EINVAL;
+ }
+
+ speed = parse_int_to_baud((uint32_t)baudrate);
+ if (!speed) {
+ warnx("Invalid baud rate: '%" PRIu64 "'", baudrate);
+ return -EINVAL;
+ }
+
+ assert(console->tty.type == TTY_DEVICE_UART);
+ console->tty.uart.baud = speed;
+ tty_change_baudrate(console);
+
+ sd_bus_emit_properties_changed(bus, path, interface, property, NULL);
return 1;
}
@@ -142,10 +202,14 @@ static int method_connect(sd_bus_message *msg, void *userdata,
static const sd_bus_vtable console_uart_vtable[] = {
SD_BUS_VTABLE_START(0),
- SD_BUS_WRITABLE_PROPERTY("Baud", "t", get_baud_handler,
- set_baud_handler, 0,
- SD_BUS_VTABLE_UNPRIVILEGED |
- SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+ SD_BUS_WRITABLE_PROPERTY("NonVbitrate", "t", get_baud_handler,
+ set_non_volatile_baud_handler, 0,
+ SD_BUS_VTABLE_UNPRIVILEGED |
+ SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+ SD_BUS_WRITABLE_PROPERTY("Vbitrate", "t", get_baud_handler,
+ set_volatile_baud_handler, 0,
+ SD_BUS_VTABLE_UNPRIVILEGED |
+ SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_VTABLE_END,
};
diff --git a/meson.build b/meson.build
index 8a570a1..c4e8cf0 100644
--- a/meson.build
+++ b/meson.build
@@ -10,7 +10,7 @@ project('obmc-console', 'c',
meson_version: '>=0.63.0',
)
-add_project_arguments('-D_GNU_SOURCE', language: 'c')
+add_project_arguments('-D_GNU_SOURCE', '-Wno-unused-result', language: 'c')
systemdsystemunitdir = dependency('systemd').get_variable('systemdsystemunitdir')
install_data('conf/obmc-console@.service.in',
--
2.25.1
@@ -0,0 +1,54 @@
From a35a3427d49a618550d6c0b252270bbe51f858cd Mon Sep 17 00:00:00 2001
From: Jonathan Doman <jonathan.doman@intel.com>
Date: Fri, 5 May 2023 17:51:42 -0700
Subject: [PATCH] Use sol-configure.sh to configure UART routing
Change-Id: I7f4945a56565b30a4baa1e241905a055a9a0ada7
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Upstream-Status: Pending
---
socket-handler.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/socket-handler.c b/socket-handler.c
index 5f9d383..9c2a587 100644
--- a/socket-handler.c
+++ b/socket-handler.c
@@ -299,6 +299,16 @@ err_close:
return POLLER_REMOVE;
}
+static void init_routing()
+{
+ static bool init_done = false;
+ if (!init_done) {
+ if (system("/usr/bin/sol-configure.sh setup_routing") == 0) {
+ init_done = true;
+ }
+ }
+}
+
static enum poller_ret socket_poll(struct handler *handler, int events,
void __attribute__((unused)) * data)
{
@@ -316,6 +326,8 @@ static enum poller_ret socket_poll(struct handler *handler, int events,
return POLLER_OK;
}
+ init_routing();
+
client = malloc(sizeof(*client));
memset(client, 0, sizeof(*client));
@@ -395,6 +407,8 @@ int dbus_create_socket_consumer(struct console *console)
n = sh->n_clients++;
+ init_routing();
+
/*
* We're managing an array of pointers to aggregates, so don't warn about
* sizeof() on a pointer type.
--
2.25.1
@@ -0,0 +1,26 @@
From 7e181d361f54473c5a9f914f456933feb1e64126 Mon Sep 17 00:00:00 2001
From: roly <Rolyli.Li@luxshare-ict.com>
Date: Mon, 2 Dec 2024 15:02:51 +0800
Subject: [PATCH] Sol support 921600 bitrate
---
console-dbus.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/console-dbus.c b/console-dbus.c
index e0c0011..f409a16 100644
--- a/console-dbus.c
+++ b/console-dbus.c
@@ -104,6 +104,9 @@ static int set_non_volatile_baud_handler(sd_bus *bus, const char *path,
case 115200:
encodedBitRate = 0xa;
break;
+ case 921600:
+ encodedBitRate = 0xb;
+ break;
default:
encodedBitRate = 0xa;
break;
--
2.25.1
@@ -0,0 +1,3 @@
[Service]
ExecStartPre=/usr/bin/sol-configure.sh setup
ExecStopPost=/usr/bin/sol-configure.sh teardown
@@ -0,0 +1,5 @@
# This will get overwritten by sol-configure.sh
baud = 921600
local-tty = ttyS3
local-tty-baud = 921600
console-id = default
@@ -0,0 +1,76 @@
#!/bin/sh
# Copyright 2017-2020 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
ROUTER=$(echo /sys/bus/platform/drivers/aspeed-uart-routing/*.uart-routing)
[ -L "$ROUTER" ] || exit 2
route() {
echo -n "$1" > "$ROUTER/$2"
echo -n "$2" > "$ROUTER/$1"
}
setup_routing() {
echo "Enabling UART routing"
route uart1 uart3
route uart4 io1
}
setup() {
hostserialcfg=$(fw_printenv hostserialcfg 2> /dev/null)
hostserialcfg=${hostserialcfg##*=}
if [ "$hostserialcfg" = 6 ]
then
baud=9600
elif [ "$hostserialcfg" = 7 ]
then
baud=19200
elif [ "$hostserialcfg" = 8 ]
then
baud=38400
elif [ "$hostserialcfg" = 9 ]
then
baud=57600
elif [ "$hostserialcfg" = 11 ]
then
baud=921600
else
baud=115200
fi
echo "Configuring host UART for $baud baud"
CONSOLE_CONF=/etc/obmc-console/server.ttyS2.conf
cat > $CONSOLE_CONF <<-EOF
# Autogenerated by $0
baud = $baud
local-tty = ttyS3
local-tty-baud = $baud
console-id = default
EOF
}
teardown() {
echo "Disabling UART routing"
route uart1 io1
route uart3 io3
route uart4 io4
}
$1
@@ -0,0 +1,27 @@
# Enable downstream autobump - this can be removed after upstream sync
# The URI is required for the autobump script but keep it commented
# to not override the upstream value
# SRC_URI = "git://github.com/openbmc/obmc-console;branch=master;protocol=https"
SRCREV = "dfda5afb4ff7c76c4df3ebebbf496fdbda0fbbae"
FILESEXTRAPATHS:append := ":${THISDIR}/${PN}"
OBMC_CONSOLE_HOST_TTY = "ttyS2"
SRC_URI += "file://sol-configure.sh \
file://pre-post-routing.conf \
file://server.ttyS2.conf \
file://0001-Use-sol-configure.sh-to-configure-UART-routing.patch \
file://0001-Support-SOL-non-volatile-bitrate-and-volatile-bitrat.patch \
file://0002-Sol-support-921600-bitrate.patch \
"
do_install:append() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/sol-configure.sh ${D}${bindir}
local drop_in=${D}${sysconfdir}/systemd/system/${PN}@${OBMC_CONSOLE_HOST_TTY}
local service_drop_in=${drop_in}.service.d
# Install service drop-in override to add UART routing and baud configuration
install -d $service_drop_in
install -m 0644 ${WORKDIR}/pre-post-routing.conf $service_drop_in
}