* [Buildroot] [PATCH 1/2] package/rwmem: add python module.
@ 2026-04-08 10:04 Vincent Cruz
2026-04-08 10:04 ` [Buildroot] [PATCH 2/2] support/testing: add rwmem tests Vincent Cruz
0 siblings, 1 reply; 2+ messages in thread
From: Vincent Cruz @ 2026-04-08 10:04 UTC (permalink / raw)
To: buildroot; +Cc: Thomas Petazzoni, Vincent Cruz
Signed-off-by: Vincent Cruz <mooz@blockos.org>
---
package/rwmem/Config.in | 4 ++++
package/rwmem/rwmem-python/Config.in | 8 ++++++++
package/rwmem/rwmem-python/rwmem-python.hash | 3 +++
package/rwmem/rwmem-python/rwmem-python.mk | 21 ++++++++++++++++++++
package/rwmem/rwmem.mk | 2 ++
5 files changed, 38 insertions(+)
create mode 100644 package/rwmem/rwmem-python/Config.in
create mode 100644 package/rwmem/rwmem-python/rwmem-python.hash
create mode 100644 package/rwmem/rwmem-python/rwmem-python.mk
diff --git a/package/rwmem/Config.in b/package/rwmem/Config.in
index 690b034070..f20c00016e 100644
--- a/package/rwmem/Config.in
+++ b/package/rwmem/Config.in
@@ -10,6 +10,10 @@ config BR2_PACKAGE_RWMEM
https://github.com/tomba/rwmem
+if BR2_PACKAGE_RWMEM
+source "package/rwmem/rwmem-python/Config.in"
+endif
+
comment "rwmem needs a toolchain w/ C++, wchar, gcc >= 10"
depends on !BR2_INSTALL_LIBSTDCPP || !BR2_USE_WCHAR || \
!BR2_TOOLCHAIN_GCC_AT_LEAST_10
diff --git a/package/rwmem/rwmem-python/Config.in b/package/rwmem/rwmem-python/Config.in
new file mode 100644
index 0000000000..3289102b0e
--- /dev/null
+++ b/package/rwmem/rwmem-python/Config.in
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_RWMEM_PYTHON
+ bool "python tools"
+ depends on BR2_PACKAGE_RWMEM
+ depends on BR2_PACKAGE_PYTHON3
+ help
+ Python bindings for rwmem
+
+ https://github.com/tomba/rwmem
diff --git a/package/rwmem/rwmem-python/rwmem-python.hash b/package/rwmem/rwmem-python/rwmem-python.hash
new file mode 100644
index 0000000000..8b73f662ea
--- /dev/null
+++ b/package/rwmem/rwmem-python/rwmem-python.hash
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256 d10639f563100c819202337c4d4df57db11c2fcd59a19b0c68e34b8eb9aa1d01 rwmem-2.0.tar.gz
+sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 LICENSE
diff --git a/package/rwmem/rwmem-python/rwmem-python.mk b/package/rwmem/rwmem-python/rwmem-python.mk
new file mode 100644
index 0000000000..4a6de35d6a
--- /dev/null
+++ b/package/rwmem/rwmem-python/rwmem-python.mk
@@ -0,0 +1,21 @@
+################################################################################
+#
+# pyrwmem
+#
+################################################################################
+
+RWMEM_PYTHON_VERSION = $(RWMEM_VERSION)
+RWMEM_PYTHON_SOURCE = $(RWMEM_SOURCE)
+RWMEM_PYTHON_SITE = $(RWMEM_SITE)
+RWMEM_PYTHON_DL_SUBDIR = rwmem
+
+RWMEM_PYTHON_LICENSE = $(RWMEM_LICENSE)
+RWMEM_PYTHON_LICENSE_FILES = $(RWMEM_LICENSE_FILES)
+
+RWMEM_PYTHON_DEPENDENCIES = rwmem
+
+RWMEM_PYTHON_INSTALL_STAGING = YES
+
+RWMEM_PYTHON_SETUP_TYPE = setuptools
+
+$(eval $(python-package))
diff --git a/package/rwmem/rwmem.mk b/package/rwmem/rwmem.mk
index 1259b5503f..db05ecab86 100644
--- a/package/rwmem/rwmem.mk
+++ b/package/rwmem/rwmem.mk
@@ -11,3 +11,5 @@ RWMEM_LICENSE_FILES = LICENSE
RWMEM_DEPENDENCIES = host-pkgconf fmt inih
$(eval $(meson-package))
+
+include package/rwmem/rwmem-python/rwmem-python.mk
--
2.51.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Buildroot] [PATCH 2/2] support/testing: add rwmem tests
2026-04-08 10:04 [Buildroot] [PATCH 1/2] package/rwmem: add python module Vincent Cruz
@ 2026-04-08 10:04 ` Vincent Cruz
0 siblings, 0 replies; 2+ messages in thread
From: Vincent Cruz @ 2026-04-08 10:04 UTC (permalink / raw)
To: buildroot; +Cc: Thomas Petazzoni, Vincent Cruz
Add a basic runtime test for rwmem package.
This test verifies that `rwmem` package can read register values from
an I2C device and a memory mapped file.
Signed-off-by: Vincent Cruz <mooz@blockos.org>
---
support/testing/tests/package/test_rwmem.py | 72 +++++++++++++++++++
.../package/test_rwmem/linux-rwmem.fragment | 3 +
.../test_rwmem/rootfs-overlay/root/tests.py | 22 ++++++
3 files changed, 97 insertions(+)
create mode 100644 support/testing/tests/package/test_rwmem.py
create mode 100644 support/testing/tests/package/test_rwmem/linux-rwmem.fragment
create mode 100644 support/testing/tests/package/test_rwmem/rootfs-overlay/root/tests.py
diff --git a/support/testing/tests/package/test_rwmem.py b/support/testing/tests/package/test_rwmem.py
new file mode 100644
index 0000000000..15d9fbc8d0
--- /dev/null
+++ b/support/testing/tests/package/test_rwmem.py
@@ -0,0 +1,72 @@
+import os
+
+import infra.basetest
+
+
+class TestRwmem(infra.basetest.BRTest):
+ kernel_fragment = infra.filepath("tests/package/test_rwmem/linux-rwmem.fragment")
+ rootfs_overlay = infra.filepath("tests/package/test_rwmem/rootfs-overlay")
+
+ config = \
+ f"""
+ BR2_arm=y
+ BR2_cortex_a9=y
+ BR2_ARM_ENABLE_NEON=y
+ BR2_ARM_ENABLE_VFP=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+ BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV7_EABIHF_GLIBC_STABLE=y
+ BR2_LINUX_KERNEL=y
+ BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
+ BR2_LINUX_KERNEL_DTS_SUPPORT=y
+ BR2_LINUX_KERNEL_INTREE_DTS_NAME="arm/vexpress-v2p-ca9"
+ BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+ BR2_TARGET_ROOTFS_CPIO=y
+ BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kernel_fragment}"
+ BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_RWMEM=y
+ BR2_PACKAGE_RWMEM_PYTHON=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+
+ def test_run(self):
+ img = os.path.join(self.builddir, "images", "rootfs.cpio")
+ kern = os.path.join(self.builddir, "images", "zImage")
+ dtb = os.path.join(self.builddir, "images", "vexpress-v2p-ca9.dtb")
+ self.emulator.boot(arch="armv7",
+ kernel=kern,
+ kernel_cmdline=["console=ttyAMA0"],
+ options=["-M", "vexpress-a9",
+ "-dtb", dtb,
+ "-device", "virtio-rng-device",
+ "-device", "tmp105,address=0x49,id=sensor",
+ "-initrd", img])
+ self.emulator.login()
+
+ self.assertRunOk("i2cset -y 0 0x49 0x02 0x5a 0x80 i")
+
+ out, ret = self.emulator.run("rwmem -S 8 -s 16be --i2c=0:0x49 0x02")
+ self.assertEqual(ret, 0)
+ self.assertIn("0x02 (+0x0) = 0x5a80", out)
+
+ out, ret = self.emulator.run("rwmem -S 8 -s 8 --mmap /etc/os-release 0x6-0xe")
+ self.assertEqual(ret, 0)
+ self.assertEqual(out, [
+ "0x06 (+0x0) = 0x75",
+ "0x07 (+0x1) = 0x69",
+ "0x08 (+0x2) = 0x6c",
+ "0x09 (+0x3) = 0x64",
+ "0x0a (+0x4) = 0x72",
+ "0x0b (+0x5) = 0x6f",
+ "0x0c (+0x6) = 0x6f",
+ "0x0d (+0x7) = 0x74"
+ ])
+
+ self.assertRunOk("i2cset -y 0 0x49 0x02 0x7c 0xa0 i")
+ out, ret = self.emulator.run("python3 /root/tests.py")
+ self.assertEqual(ret, 0)
+ self.assertEqual(out, [
+ "0x7ca0",
+ "0x75696c64726f6f74"
+ ])
diff --git a/support/testing/tests/package/test_rwmem/linux-rwmem.fragment b/support/testing/tests/package/test_rwmem/linux-rwmem.fragment
new file mode 100644
index 0000000000..15d1e73bc8
--- /dev/null
+++ b/support/testing/tests/package/test_rwmem/linux-rwmem.fragment
@@ -0,0 +1,3 @@
+CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_SENSORS_LM75=y
\ No newline at end of file
diff --git a/support/testing/tests/package/test_rwmem/rootfs-overlay/root/tests.py b/support/testing/tests/package/test_rwmem/rootfs-overlay/root/tests.py
new file mode 100644
index 0000000000..f3e094b913
--- /dev/null
+++ b/support/testing/tests/package/test_rwmem/rootfs-overlay/root/tests.py
@@ -0,0 +1,22 @@
+#! /usr/bin/env python3
+# This is the python version of the rwmem cli tests.
+import sys
+
+import rwmem as rw
+
+# rwmem -S 8 -s 16be --i2c=0:0x49 0x02
+map = rw.I2CTarget(i2c_adapter_nr=0, i2c_dev_addr=0x49,
+ offset=0x0, length=16,
+ addr_endianness=rw.Endianness.Big, addr_size=1,
+ data_endianness=rw.Endianness.Big, data_size=2,
+ mode=rw.MapMode.ReadWrite)
+
+out = map.read(0x02)
+print(hex(out))
+
+# rwmem -S 8 -s 8 --mmap /etc/os-release 0x6-0xe
+map = rw.MMapTarget('/etc/os-release', 0, 32, rw.Endianness.Big, 1, rw.MapMode.Read)
+out = map.read(0x6, 8)
+print(hex(out))
+
+sys.exit(0)
--
2.51.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-08 10:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 10:04 [Buildroot] [PATCH 1/2] package/rwmem: add python module Vincent Cruz
2026-04-08 10:04 ` [Buildroot] [PATCH 2/2] support/testing: add rwmem tests Vincent Cruz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox