Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bmcd package #116

Merged
merged 5 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tp2bmc/Config.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
menu "tpi2 app packages"
source "$BR2_EXTERNAL_TP2BMC_PATH/package/bmc/Config.in"
source "$BR2_EXTERNAL_TP2BMC_PATH/package/bmcd/Config.in"
source "$BR2_EXTERNAL_TP2BMC_PATH/package/tpi/Config.in"
source "$BR2_EXTERNAL_TP2BMC_PATH/package/tpi_rs/Config.in"
endmenu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

start() {
if [ "$1" = "start" ]; then
mkdir -p /mnt/sdcard

if [ -b /dev/mmcblk0p1 ]; then
Expand All @@ -9,12 +9,6 @@ start() {
mount /dev/mmcblk0 /mnt/sdcard
fi

echo " _____ _ _ ____ ___ _ _ ____ "
echo "|_ _| | | | _ \|_ _| \ | |/ ___|"
echo " | | | | | | |_) || || \| | | _ "
echo " | | | |_| | _ < | || |\ | |_| |"
echo " |_| \___/|_| \_\___|_| \_|\____|"

echo 3 4 1 7 > /proc/sys/kernel/printk

sleep 1
Expand All @@ -23,8 +17,4 @@ start() {
bmc &

/etc/test_ping.sh &
}

if [ "$1" = "start" ]; then
start
fi
9 changes: 9 additions & 0 deletions tp2bmc/board/tp2bmc/overlay/etc/init.d/S99hello
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ "$1" = "start" ]; then
echo " _____ _ _ ____ ___ _ _ ____ "
echo "|_ _| | | | _ \|_ _| \ | |/ ___|"
echo " | | | | | | |_) || || \| | | _ "
echo " | | | |_| | _ < | || |\ | |_| |"
echo " |_| \___/|_| \_\___|_| \_|\____|"
fi
2 changes: 2 additions & 0 deletions tp2bmc/configs/tp2bmc_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ BR2_PACKAGE_NSS_MDNS=y
BR2_PACKAGE_NTPSEC=y
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_PICOCOM=y
BR2_PACKAGE_START_STOP_DAEMON=y
BR2_PACKAGE_SWUPDATE_CONFIG="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/swupdate.config"
BR2_PACKAGE_SWUPDATE_INSTALL_WEBSITE=n
BR2_PACKAGE_SWUPDATE_WEBSERVER=n
Expand All @@ -113,5 +114,6 @@ BR2_PACKAGE_UTIL_LINUX_UUIDD=y

# Custom packages
BR2_PACKAGE_BMC=y
BR2_PACKAGE_BMCD=y
BR2_PACKAGE_TPI=y
BR2_PACKAGE_TPI_RS=y
6 changes: 6 additions & 0 deletions tp2bmc/package/bmcd/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config BR2_PACKAGE_BMCD
bool "bmcd"
depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
select BR2_PACKAGE_HOST_RUSTC
help
System management daemon for the Baseboard Management Controller (BMC)
50 changes: 50 additions & 0 deletions tp2bmc/package/bmcd/S94bmcd
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh
ruslashev marked this conversation as resolved.
Show resolved Hide resolved

DAEMON="bmcd"
BIN="/usr/bin/$DAEMON"
PIDFILE="/var/run/$DAEMON.pid"

start() {
printf 'Starting %s...\n' "$DAEMON"

start-stop-daemon --start --quiet --background --make-pidfile --pidfile "$PIDFILE" --no-close \
--exec "$BIN"

# Note: there are a lot of init.d scripts in buildroot packages that use -b/--background flag
# for programs that don't daemonize themselves. Contrary to the vast majority of them, it's
# pointless to check exit code ($?) here because in that case start-stop-daemon(8) "cannot
# check the exit status if the process fails to execute for any reason". Because of that, we
# rely on `bmcd` itself to notify where, and if, it failed.
}

stop() {
printf 'Stopping %s: ' "$DAEMON"

start-stop-daemon --stop --quiet --pidfile "$PIDFILE"

status=$?
if [ "$status" -eq 0 ]; then
rm -f "$PIDFILE"
echo "OK"
else
echo "FAIL"
fi

return "$status"
}

restart() {
stop
sleep 1
start
}

case "$1" in
start|stop|restart)
"$1";;
reload)
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
50 changes: 50 additions & 0 deletions tp2bmc/package/bmcd/bmcd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
###########################################################
#
# bmcd
#
###########################################################

BMCD_VERSION = bb3636350509b09fcb4b4637b8fd669719206d5a
BMCD_SITE = $(call github,turing-machines,bmcd,$(BMCD_VERSION))
BMCD_LICENSE = Apache-2.0
BMCD_LICENSE_FILES = LICENSE
BMCD_CARGO_ENV := PKG_CONFIG_ALLOW_CROSS=1
BMCD_CARGO_ENV += CC_armv7_unknown_linux_gnueabi="arm-linux-gcc"

define BMCD_BUILD_CMDS
cd $(BMCD_SRCDIR) && \
$(TARGET_MAKE_ENV) \
$(PKG_CARGO_ENV) \
$(BMCD_CARGO_ENV) \
cargo build \
--offline \
$(if $(BR2_ENABLE_DEBUG),,--release) \
--manifest-path Cargo.toml \
--locked \
$(BMCD_CARGO_BUILD_OPTS)
endef

# A copy of default build commands but with --path amended, since we have a virtual manifest.
# For the same reasons as in tpi_rs.mk, TARGET_CONFIGURE_OPTS are removed.
define BMCD_INSTALL_TARGET_CMDS
cd $(BMCD_SRCDIR) && \
$(TARGET_MAKE_ENV) \
$(PKG_CARGO_ENV) \
$(BMCD_CARGO_ENV) \
cargo install \
--offline \
--root $(TARGET_DIR)/usr/ \
--bins \
--path bmcd \
--force \
--locked \
-Z target-applies-to-host \
$(BMCD_CARGO_INSTALL_OPTS)
endef

define BMCD_INSTALL_INIT_SYSV
$(INSTALL) -D -m 755 $(BR2_EXTERNAL_TP2BMC_PATH)/package/bmcd/S94bmcd \
$(TARGET_DIR)/etc/init.d/S94bmcd
endef

$(eval $(cargo-package))
6 changes: 3 additions & 3 deletions tp2bmc/package/tpi_rs/tpi_rs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
###########################################################

TPI_RS_VERSION = 1.3.0
TPI_RS_SITE = $(call github,turing-machines,tpi_rs,$(TPI_RS_VERSION))
TPI_RS_VERSION = bb3636350509b09fcb4b4637b8fd669719206d5a
TPI_RS_SITE = $(call github,turing-machines,bmcd,$(TPI_RS_VERSION))
TPI_RS_LICENSE = Apache-2.0
TPI_RS_LICENSE_FILES = LICENSE
TPI_RS_INSTALL_STAGING = YES
Expand All @@ -32,7 +32,7 @@ endef

define TPI_RS_INSTALL_STAGING_CMDS
$(INSTALL) -D -m 0644 $(@D)/target/$(RUSTC_TARGET_NAME)/$(if $(BR2_ENABLE_DEBUG),debug,release)/libtpi_rs.a $(STAGING_DIR)/lib
$(INSTALL) -D -m 0644 $(@D)/tpi_rs.h $(STAGING_DIR)/usr/include
$(INSTALL) -D -m 0644 $(@D)/tpi_rs/tpi_rs.h $(STAGING_DIR)/usr/include
endef

$(eval $(cargo-package))