فهرست منبع

memtool: Add recipe

memtool is a program that allows to access memory mapped registers.
This is useful to inspect and modify registers from the command line.
memtool can also operate on plain files, and access PHY registers.

Signed-off-by: Ricardo Simoes <ricardo.simoes@pt.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Ricardo Simoes 10 ماه پیش
والد
کامیت
1974c7a6d3

+ 27 - 0
meta-oe/recipes-devtools/memtool/memtool/run-ptest

@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# SPDX-FileCopyrightText: 2024 Bosch Sicherheitssysteme GmbH
+#
+# SPDX-License-Identifier: MIT
+
+fail_count=0
+all_count=0
+
+for test_suite in tests/test_*
+do
+    if "./$test_suite"
+    then
+        echo "PASS: $test_suite"
+    else
+        echo "FAIL: $test_suite"
+        fail_count=$((fail_count + 1))
+    fi
+    all_count=$((all_count + 1))
+done
+
+if [ $fail_count -eq 0 ]
+then
+    echo "PASS: All $all_count tests passed"
+else
+    echo "FAIL: $fail_count of $all_count tests failed"
+fi

+ 69 - 0
meta-oe/recipes-devtools/memtool/memtool/test_read_write_plainfiles.sh

@@ -0,0 +1,69 @@
+#!/bin/bash
+
+# SPDX-FileCopyrightText: 2024 Bosch Sicherheitssysteme GmbH
+#
+# SPDX-License-Identifier: MIT
+
+# This script verifies the behavior of memtool against plain files.
+
+readonly PLAIN_FILE=$(mktemp)
+FAIL_COUNT=0
+
+setup() {
+	echo "Hello World!" >"$PLAIN_FILE"
+}
+
+teardown() {
+	rm "$PLAIN_FILE"
+}
+
+verify() {
+	ACTUAL=$1
+	EXPECTED=$2
+	TEST_NAME=$3
+
+	if [ "$ACTUAL" = "$EXPECTED" ]; then
+		echo "pass: $TEST_NAME"
+	else
+		echo "FAIL: $TEST_NAME"
+		echo "  Expected: $EXPECTED"
+		echo "  Actual: $ACTUAL"
+		FAIL_COUNT=$((FAIL_COUNT + 1))
+	fi
+}
+
+# Test Case: Verifies that the expected string of bytes is read from a plain file starting from
+# the offset 6 and reading 6 bytes.
+test_memtool_read() {
+	EXPECTED="00000006: 57 6f 72 6c 64 21                                  World!"
+	ACTUAL=$(memtool md -s "$PLAIN_FILE" -b 0x6+6)
+	verify "$ACTUAL" "$EXPECTED" "memtool read from plain file"
+}
+
+# Test Case 2: Verifies that the expected string of bytes is written to a plain file starting from
+# and then read the result.
+test_memtool_write() {
+	# Usage of 'od' ensures correct endianess.
+	readonly replace_str_bytes=$(echo "Yocto!" | od -t d4 -A n)
+
+	# shellcheck disable=SC2086 # We want to pass the bytes as separate arguments.
+	memtool mw -d "$PLAIN_FILE" 0x6+6 $replace_str_bytes
+
+	EXPECTED="00000006: 59 6f 63 74 6f 21                                  Yocto!"
+	ACTUAL=$(memtool md -s "$PLAIN_FILE" -b 0x6+6)
+	verify "$ACTUAL" "$EXPECTED" "memtool write to plain file"
+}
+
+for test_case in $(declare -F | grep test_memtool_ | cut -f 3 -d ' '); do
+	setup
+	$test_case
+	teardown
+done
+
+if [ $FAIL_COUNT -eq 0 ]; then
+	echo "Test Passed: memtool plain file read/write functionality is correct."
+	exit 0
+else
+	echo "Test FAILED: memtool plain file read/write functionality is incorrect. Check the logs."
+	exit 1
+fi

+ 31 - 0
meta-oe/recipes-devtools/memtool/memtool_2018.03.0.bb

@@ -0,0 +1,31 @@
+# SPDX-FileCopyrightText: 2024 Bosch Sicherheitssysteme GmbH
+#
+# SPDX-License-Identifier: MIT
+
+SUMMARY = "A tool to manipulate and read memory mapped registers"
+DESCRIPTION = "memtool is a program that allows to access memory mapped registers. This is useful \
+to inspect and modify registers from the command line. memtool can also operate on plain files, \
+and access PHY registers."
+HOMEPAGE = "https://github.com/pengutronix/memtool"
+BUGTRACKER = "https://github.com/pengutronix/memtool/issues"
+SECTION = "devtool"
+
+LICENSE = "GPL-2.0-only"
+LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
+
+SRC_URI = " \
+    http://www.pengutronix.de/software/memtool/downloads/memtool-${PV}.tar.xz \
+    file://run-ptest \
+    file://test_read_write_plainfiles.sh \
+"
+
+SRC_URI[sha256sum] = "87cb7175266ff3a00a9c1f541c4c6c93693ffbe8dcc0d97a60d13c45ff860900"
+
+inherit autotools ptest
+
+do_install_ptest () {
+    install -d ${D}${PTEST_PATH}/tests
+    install -m 0755 ${UNPACKDIR}/test_* ${D}${PTEST_PATH}/tests
+}
+
+RDEPENDS:${PN}-ptest += "bash coreutils"