diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/recipes-core/ images/fc-image.bb b/recipes-core/images/fc-image.bb similarity index 84% rename from recipes-core/ images/fc-image.bb rename to recipes-core/images/fc-image.bb index a1cc72b..31d45d0 100644 --- a/recipes-core/ images/fc-image.bb +++ b/recipes-core/images/fc-image.bb @@ -1,6 +1,6 @@ SUMMARY = "Flight computer image" -IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL} packagegroup-core-ssh-openssh kernel-modules i2c-tools libgpiod libgpiod-dev libgpiod-tools srp-startup" +IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL} packagegroup-core-ssh-openssh kernel-modules i2c-tools libgpiod libgpiod-dev libgpiod-tools htop srp srp-recover srp-user" IMAGE_LINGUAS = " " diff --git a/recipes-core/srp-recover/files/srp_recover.sh b/recipes-core/srp-recover/files/srp_recover.sh new file mode 100644 index 0000000..badae48 --- /dev/null +++ b/recipes-core/srp-recover/files/srp_recover.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +out_put_file="/srp/token/token.hex" +out_put_file_ver="/srp/token/token.hex.sha1" + +if [ ! -d "/srp/update" ]; then + cd /srp + mkdir update + echo "[SRP-PLATFORM]: [INFO] SRP sw dir added" +fi + +if [ ! -d "/srp/update/backup" ]; then + cd /srp/update + mkdir backup + echo "[SRP-PLATFORM]: [INFO] Backup dir added" +fi + +if [ ! -d "/srp/update/new" ]; then + cd /srp/update + mkdir new + echo "[SRP-PLATFORM]: [INFO] New dir added" +fi + +if [ ! -d "/srp/update/current" ]; then + cd /srp/update + mkdir current + echo "[SRP-PLATFORM]: [INFO] Current dir added" +fi + +if [ ! -e "/srp/token/token.hex" ] +then + if [ ! -d "/srp/token" ]; then + cd /srp + mkdir token + fi + var1="$(cat /sys/class/net/*/address | tr -d '\n')" + sec='sec_token2' + eng='eng_token2' + upload='upload_token2' + sec=$var1$sec + sec="$(echo $sec | sha256sum)" + eng=$var1$eng + eng="$(echo $eng | sha256sum)" + upload=$var1$upload + upload="$(echo $upload | sha256sum)" + echo ${sec::-3} > $out_put_file + echo ${eng::-3} >> $out_put_file + echo ${upload::-3} >> $out_put_file + ver_hash="$(sha1sum $out_put_file)" + echo $ver_hash > $out_put_file_ver + chmod -w $out_put_file + chmod -w $out_put_file_ver + reboot +fi \ No newline at end of file diff --git a/recipes-core/srp-recover/srp-recover.bb b/recipes-core/srp-recover/srp-recover.bb new file mode 100644 index 0000000..f3a1ad9 --- /dev/null +++ b/recipes-core/srp-recover/srp-recover.bb @@ -0,0 +1,22 @@ +DESCRIPTION = "SRP Initscripts" +LICENSE = "CLOSED" + +SRC_URI += "\ + file://srp_recover.sh \ +" + +INITSCRIPT_NAME = "srp_recover.sh" +INITSCRIPT_PARAMS = "start 99 5 ." + +inherit update-rc.d + +S = "${UNPACKDIR}" + +do_install () { + install -d ${D}${sysconfdir}/init.d/ + install -c -m 755 ${UNPACKDIR}/${INITSCRIPT_NAME} ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME} +} + +DEPENDS = "bash" + +RDEPENDS:${PN} = "bash" \ No newline at end of file diff --git a/recipes-core/srp-startup/files/srp_start.service b/recipes-core/srp-startup/files/srp_start.service deleted file mode 100644 index 96d90bd..0000000 --- a/recipes-core/srp-startup/files/srp_start.service +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=SRP platform start -StartLimitIntervalSec=30 -StartLimitBurst=2 -After=multi-user.target -AllowIsolate=yes - -[Service] -Type=simple -ExecStart=/bin/srp_start.sh -StandardOutput=journal+console -StandardError=journal+console -SyslogIdentifier=srp_start -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target diff --git a/recipes-core/srp-startup/files/srp_start.sh b/recipes-core/srp-startup/files/srp_start.sh deleted file mode 100644 index e83d6aa..0000000 --- a/recipes-core/srp-startup/files/srp_start.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -if [ ! -d "/etc/simba" ]; then - cd /etc - mkdir simba - echo "SRP sw dir added" -fi - -if [ ! -d "/etc/simba/backup" ]; then - cd /etc/simba - mkdir backup - echo "Backup dir added" -fi - -if [ ! -d "/etc/simba/new" ]; then - cd /etc/simba - mkdir new - echo "New dir added" -fi - -if [ ! -d "/etc/simba/current" ]; then - cd /etc/simba - mkdir current - echo "Current dir added" -fi - -if [ "$(ls -A /etc/simba/new | grep .tar)" ]; then - echo "SRP update detected:" - ls -A /etc/simba/new - - if [ ! -d "/opt/cpu_simba/update.sh" ]; then - echo "Update script not detected !!!" - for file in /etc/simba/new/*.tar; do - echo "Opening: $file" - cp $file /etc/simba/current - tar -xvf $file -C / - rm $file - done - else - sh /opt/cpu_simba/update.sh - fi -else - echo "SRP update not detected" -fi - -sh /opt/cpu_simba/start_up.sh \ No newline at end of file diff --git a/recipes-core/srp-startup/srp-startup.bb b/recipes-core/srp-startup/srp-startup.bb deleted file mode 100644 index a651714..0000000 --- a/recipes-core/srp-startup/srp-startup.bb +++ /dev/null @@ -1,36 +0,0 @@ -SUMMARY = "SRP platform init" -LICENSE = "CLOSED" - -SRC_URI += "\ - file://srp_start.sh \ - file://start_up.sh \ - file://network_interface.sh \ - file://srp_start.service \ -" - -inherit systemd - -SYSTEMD_SERVICE:${PN} = "\ - srp_start.service \ -" - -do_install:append() { - - install -d ${D}${systemd_system_unitdir} - install -d ${D}/bin - install -d ${D}/opt/cpu_simba - - install -m 0777 ${WORKDIR}/srp_start.sh ${D}/bin - - install -m 0777 ${WORKDIR}/network_interface.sh ${D}/opt/cpu_simba - install -m 0777 ${WORKDIR}/start_up.sh ${D}/opt/cpu_simba - - install -m 0644 ${WORKDIR}/srp_start.service ${D}${systemd_system_unitdir} -} - -FILES:${PN} += "\ - /bin/srp_start.sh \ - ${systemd_system_unitdir}/srp_start.service \ - /opt/cpu_simba/start_up.sh \ - /opt/cpu_simba/network_interface.sh \ -" diff --git a/recipes-core/srp-user/srp-user.bb b/recipes-core/srp-user/srp-user.bb new file mode 100644 index 0000000..01da9d6 --- /dev/null +++ b/recipes-core/srp-user/srp-user.bb @@ -0,0 +1,72 @@ +SUMMARY = "Example recipe for using inherit useradd" +DESCRIPTION = "This recipe serves as an example for using features from useradd.bbclass" +SECTION = "examples" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +SRC_URI = "file://file1 \ + file://file2 \ + file://file3 \ + file://file4" + +S = "${UNPACKDIR}" + +inherit useradd + +PACKAGES =+ "${PN}-user3" + +# You must set USERADD_PACKAGES when you inherit useradd. This +# lists which output packages will include the user/group +# creation code. +USERADD_PACKAGES = "${PN} ${PN}-user3" + +# You must also set USERADD_PARAM and/or GROUPADD_PARAM when +# you inherit useradd. + +# USERADD_PARAM specifies command line options to pass to the +# useradd command. Multiple users can be created by separating +# the commands with a semicolon. Here we'll create two users, +# user1 and user2: + +GROUPADD_PARAM:${PN} = "-g 1000 srp ; -g 1001 logs ; -g 1002 persistence ; -g 1003 com ; -g 890 group2;--system gpio;--system i2c;--system tty;--system bin" + +# Likewise, we'll manage group3 in the useradd-example-user3 package: +GROUPADD_PARAM:${PN}-user3 = "-g 900 group3" + +USERADD_PARAM:${PN} = "-u 1000 -d /home/srpapp -r -s /bin/bash --groups srp,gpio,i2c,tty,bin,logs,persistence,com srpapp" + +# user3 will be managed in the useradd-example-user3 package: +# As an example, we use the -p option to set password ('user3') for user3 +USERADD_PARAM:${PN}-user3 = "-u 1202 -d /home/user3 -r -s /bin/bash -p '\$6\$XAWr.8nc\$bUE4pYYaVb8n6BbnBitU0zeJMtfhTpFpiOBLL9zRl4e4YQo88UU4r/1kjRzmTimCy.BvDh4xoFwVqcO.pihLa1' user3" + + +GROUPADD_PARAM:${PN}-user3 = "-g 900 group3" + +do_install () { + install -d -m 755 ${D}${datadir}/srpapp + install -d -m 755 ${D}${datadir}/user3 + install -p -m 644 ${UNPACKDIR}/file1 ${D}${datadir}/srpapp/ + + install -p -m 644 ${UNPACKDIR}/file3 ${D}${datadir}/user3/ + install -p -m 644 ${UNPACKDIR}/file4 ${D}${datadir}/user3/ + install -d ${D}/persistence + install -d ${D}/logs + chmod 0666 ${D}/persistence + chmod 0666 ${D}/logs +} + +do_rootfs() { + chgrp -R persistence ${D}/persistence + chgrp -R logs ${D}/logs + chgrp -R com ${D}/run +} + +FILES:${PN} = "${datadir}/srpapp/* \ + /logs \ + /persistence \ +" +FILES:${PN}-user3 = "${datadir}/user3/*" + +# Prevents do_package failures with: +# debugsources.list: No such file or directory: +# INHIBIT_PACKAGE_DEBUG_SPLIT = "1" diff --git a/recipes-core/srp-user/srp-user/file1 b/recipes-core/srp-user/srp-user/file1 new file mode 100644 index 0000000..e69de29 diff --git a/recipes-core/srp-user/srp-user/file2 b/recipes-core/srp-user/srp-user/file2 new file mode 100644 index 0000000..e69de29 diff --git a/recipes-core/srp-user/srp-user/file3 b/recipes-core/srp-user/srp-user/file3 new file mode 100644 index 0000000..e69de29 diff --git a/recipes-core/srp-user/srp-user/file4 b/recipes-core/srp-user/srp-user/file4 new file mode 100644 index 0000000..e69de29 diff --git a/recipes-core/srp-startup/files/network_interface.sh b/recipes-core/srp/files/network_interface.sh similarity index 75% rename from recipes-core/srp-startup/files/network_interface.sh rename to recipes-core/srp/files/network_interface.sh index f0861c8..d52ccc5 100644 --- a/recipes-core/srp-startup/files/network_interface.sh +++ b/recipes-core/srp/files/network_interface.sh @@ -1,14 +1,13 @@ - -#!/bin/sh + #!/bin/bash ################################################################################ # # Copyright (c) 2024 Bartosz Snieg. -# +# ################################################################################ -# +# echo "Setting interface: eth0 for ec " -echo "ip: 192.168.10.101" +echo "ip: 192.168.10.52" echo "net mask 255.255.255.0 " -ifconfig eth0 192.168.10.101 netmask 255.255.255.0 +ifconfig eth0 192.168.10.52 netmask 255.255.255.0 echo "Interface set [DONE]" \ No newline at end of file diff --git a/recipes-core/srp/files/srp_start.sh b/recipes-core/srp/files/srp_start.sh new file mode 100644 index 0000000..ad94968 --- /dev/null +++ b/recipes-core/srp/files/srp_start.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +out_put_file="/srp/token/token.hex" +out_put_file_ver="/srp/token/token.hex.sha1" + +if [ ! -d "/srp/update" ]; then + cd /srp + mkdir update + echo "[SRP-PLATFORM]: [INFO] SRP sw dir added" +fi + +if [ ! -d "/srp/update/backup" ]; then + cd /srp/update + mkdir backup + echo "[SRP-PLATFORM]: [INFO] Backup dir added" +fi + +if [ ! -d "/srp/update/new" ]; then + cd /srp/update + mkdir new + echo "[SRP-PLATFORM]: [INFO] New dir added" +fi + +if [ ! -d "/srp/update/current" ]; then + cd /srp/update + mkdir current + echo "[SRP-PLATFORM]: [INFO] Current dir added" +fi + +if sha1sum -c $out_put_file_ver; +then +sh /srp/opt/cpu_srp/start_up.sh +else +echo "[SRP-PLATFORM]: [ERROR] Security file breach detected" +echo "[SRP-PLATFORM]: [INFO] Deletion of invalid token" +rm $out_put_file +rm $out_put_file_ver +echo "[SRP-PLATFORM]: [INFO] Reboot the system" +fi \ No newline at end of file diff --git a/recipes-core/srp-startup/files/start_up.sh b/recipes-core/srp/files/start_up.sh similarity index 55% rename from recipes-core/srp-startup/files/start_up.sh rename to recipes-core/srp/files/start_up.sh index 50eb94f..759ddcf 100644 --- a/recipes-core/srp-startup/files/start_up.sh +++ b/recipes-core/srp/files/start_up.sh @@ -1,14 +1,12 @@ - -#!/bin/sh + #!/bin/bash ################################################################################ # # Copyright (c) 2024 Bartosz Snieg. # ################################################################################ # -echo "Simab SRP start up script" +echo "SRP start up script" -sh /opt/cpu_simba/network_interface.sh -sh /opt/cpu_simba/component_start_up.sh +sh /srp/opt/cpu_srp/network_interface.sh -echo "Simab SRP start up script [DONE]" +echo "SRP start up script [DONE]" diff --git a/recipes-core/srp/files/test.txt b/recipes-core/srp/files/test.txt new file mode 100644 index 0000000..da7ae7a --- /dev/null +++ b/recipes-core/srp/files/test.txt @@ -0,0 +1,3 @@ + +f0fe281ebf48da4c8cb23d1cdf5a908c04824b8065fff81f8494730abe4e62b8 +3171dc64bae40fd17caab150af3012e4d6f3a560900c56d2c84af211d98870d9 diff --git a/recipes-core/srp/files/token.hex b/recipes-core/srp/files/token.hex new file mode 100644 index 0000000..bece978 --- /dev/null +++ b/recipes-core/srp/files/token.hex @@ -0,0 +1,2 @@ +f0fe281ebf48da4c8cb23d1cdf5a908c04824b8065fff81f8494730abe4e62b8 +3171dc64bae40fd17caab150af3012e4d6f3a560900c56d2c84af211d98870d9 diff --git a/recipes-core/srp/files/token.hex.sha1 b/recipes-core/srp/files/token.hex.sha1 new file mode 100644 index 0000000..1fe0798 --- /dev/null +++ b/recipes-core/srp/files/token.hex.sha1 @@ -0,0 +1 @@ +697c683dab6a72bb16e01ca51b085d34e9a23dff token.hex diff --git a/recipes-core/srp/files/token.hex.verified b/recipes-core/srp/files/token.hex.verified new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/recipes-core/srp/files/token.hex.verified @@ -0,0 +1 @@ + diff --git a/recipes-core/srp/srp.bb b/recipes-core/srp/srp.bb new file mode 100644 index 0000000..0932095 --- /dev/null +++ b/recipes-core/srp/srp.bb @@ -0,0 +1,45 @@ +DESCRIPTION = "SRP Initscripts" +LICENSE = "CLOSED" + +SRC_URI += "\ + file://srp_start.sh \ + file://start_up.sh \ + file://network_interface.sh \ +" + +INITSCRIPT_NAME = "srp_start.sh" +INITSCRIPT_PARAMS = "start 1 S ." + +inherit update-rc.d + +S = "${UNPACKDIR}" + +do_install () { + + install -d ${D}/srp + install -d ${D}/srp/opt + install -d ${D}/srp/opt/cpu_srp + # install -d ${D}/persistance + # install -d ${D}/logs + chmod 0755 ${D}/srp + # chmod 0666 ${D}/persistance + # touch ${D}/persistance/.keep + # chmod 0666 ${D}/logs + # touch ${D}/logs/.keep + install -d ${D}${sysconfdir}/init.d/ + install -c -m 755 ${UNPACKDIR}/${INITSCRIPT_NAME} ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME} + + install -m 0755 ${UNPACKDIR}/network_interface.sh ${D}/srp/opt/cpu_srp + install -m 0755 ${UNPACKDIR}/start_up.sh ${D}/srp/opt/cpu_srp +} + +DEPENDS = "bash" + +RDEPENDS:${PN} = "bash" + +FILES:${PN} += "\ + /srp/opt/cpu_srp/start_up.sh \ + /srp/opt/cpu_srp/network_interface.sh \ + # /persistance/.keep \ + # /logs/.keep \ +" \ No newline at end of file diff --git a/recipes-kernel/linux/linux-yocto/0003-enable-uart4-bbb.patch b/recipes-kernel/linux/linux-yocto/0003-enable-uart4-bbb.patch new file mode 100644 index 0000000..ed236c7 --- /dev/null +++ b/recipes-kernel/linux/linux-yocto/0003-enable-uart4-bbb.patch @@ -0,0 +1,47 @@ +From 02b262d830263772f9035361138a99ffba19ec8b Mon Sep 17 00:00:00 2001 +From: Kondracki Krzysztof +Date: Sat, 18 Apr 2026 00:00:00 +0000 +Subject: [PATCH] ARM: dts: am335x-bone-common: enable UART4 on P9.11/P9.13 + +BeagleBone Black: mux GPMC_WAIT0 / GPMC_WPN to uart4_rxd / uart4_txd (MODE6) +and enable uart4. +--- + arch/arm/boot/dts/am335x-bone-common.dtsi | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi +index bc4b703322ee..822a2339ea63 100644 +--- a/arch/arm/boot/dts/am335x-bone-common.dtsi ++++ b/arch/arm/boot/dts/am335x-bone-common.dtsi +@@ -117,6 +117,14 @@ AM33XX_PADCONF(AM335X_PIN_UART0_TXD, PIN_OUTPUT_PULLDOWN, MUX_MODE0) + >; + }; + ++ /* UART4 on BBB P9.11 (RX) / P9.13 (TX), MODE6 */ ++ bb_uart4_pins: pinmux_bb_uart4_pins { ++ pinctrl-single,pins = < ++ AM33XX_PADCONF(AM335X_PIN_GPMC_WAIT0, PIN_INPUT, MUX_MODE6) /* P9.11 uart4_rxd */ ++ AM33XX_PADCONF(AM335X_PIN_GPMC_WPN, PIN_OUTPUT_PULLDOWN, MUX_MODE6) /* P9.13 uart4_txd */ ++ >; ++ }; ++ + clkout2_pin: pinmux_clkout2_pin { + pinctrl-single,pins = < + AM33XX_PADCONF(AM335X_PIN_XDMA_EVENT_INTR1, PIN_OUTPUT_PULLDOWN, MUX_MODE3) /* xdma_event_intr1.clkout2 */ +@@ -212,6 +220,13 @@ &uart0 { + status = "okay"; + }; + ++&uart4 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&bb_uart4_pins>; ++ ++ status = "okay"; ++}; ++ + &usb0 { + dr_mode = "peripheral"; + interrupts-extended = <&intc 18 &tps 0>; +-- +2.43.0 + diff --git a/recipes-kernel/linux/linux-yocto/config.cfg b/recipes-kernel/linux/linux-yocto/config.cfg index 35a699a..4f33635 100644 --- a/recipes-kernel/linux/linux-yocto/config.cfg +++ b/recipes-kernel/linux/linux-yocto/config.cfg @@ -57,3 +57,11 @@ CONFIG_CAN_C_CAN_PLATFORM=y CONFIG_CAN_DEBUG_DEVICES=y # end of CAN Device Drivers +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +# Enough 8250 ports for UART0..UART4 (and friends) on AM335x +CONFIG_SERIAL_8250_NR_UARTS=8 +CONFIG_SERIAL_8250_RUNTIME_UARTS=8 +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y diff --git a/recipes-kernel/linux/linux-yocto_%.bbappend b/recipes-kernel/linux/linux-yocto_%.bbappend index 5419b92..91ee832 100644 --- a/recipes-kernel/linux/linux-yocto_%.bbappend +++ b/recipes-kernel/linux/linux-yocto_%.bbappend @@ -2,5 +2,5 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" SRC_URI += "file://config.cfg \ file://0001-bus-config.patch file://0002-pin-config.patch \ - " + file://0003-enable-uart4-bbb.patch"