* [Buildroot] [PATCH] package/linux-tools: add USB tools (testusb and ffs-test)
@ 2023-03-24 9:33 Luca Ceresoli via buildroot
2023-03-24 10:09 ` Herve Codina via buildroot
2023-03-24 10:27 ` yann.morin
0 siblings, 2 replies; 5+ messages in thread
From: Luca Ceresoli via buildroot @ 2023-03-24 9:33 UTC (permalink / raw)
To: buildroot
Cc: Hervé Codina, Luca Ceresoli, Yann E . MORIN,
Thomas Petazzoni
Extend the linux-tools package to also build the userspace USB tools, which
currently include testusb and ffs-test.
These tools are in the kernel tree since a long time, but a Makefile was
added only in 5.9 to allow building in the same way as other tools provided
with the kernel. Here we use the Makefile and thus version >= 5.9 is
required. Support for older kernels may be added later if needed.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
DEVELOPERS | 1 +
package/linux-tools/Config.in | 26 ++++++++++++
package/linux-tools/linux-tool-usbtools.mk.in | 42 +++++++++++++++++++
3 files changed, 69 insertions(+)
create mode 100644 package/linux-tools/linux-tool-usbtools.mk.in
diff --git a/DEVELOPERS b/DEVELOPERS
index b6d288c54fa9..67c6004ddf2e 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1874,6 +1874,7 @@ F: configs/zynqmp_zcu106_defconfig
F: package/agentpp/
F: package/exim/
F: package/libpjsip/
+F: package/linux-tools/linux-tool-usbtools.mk.in
F: package/qpid-proton/
F: package/rtl8188eu/
F: package/snmppp/
diff --git a/package/linux-tools/Config.in b/package/linux-tools/Config.in
index 8a0b6d5802cc..451b0eeff5bb 100644
--- a/package/linux-tools/Config.in
+++ b/package/linux-tools/Config.in
@@ -135,6 +135,32 @@ comment "selftests needs BR2_PACKAGE_BUSYBOX_SHOW_OTHERS and a toolchain w/ dyna
depends on !BR2_PACKAGE_BUSYBOX_SHOW_OTHERS || \
BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_14
+config BR2_PACKAGE_LINUX_TOOLS_USBTOOLS
+ bool "USB test programs"
+ select BR2_PACKAGE_LINUX_TOOLS
+ help
+ Build and install the USB test tools.
+
+ These tools exist since Linux 2.6.35, but Buildroot can build
+ them only with kernel versions 5.9 and later.
+
+if BR2_PACKAGE_LINUX_TOOLS_USBTOOLS
+
+config BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_TESTUSB
+ bool "testusb"
+ help
+ testusb issues ioctls to perform the tests implemented by the
+ kernel driver. It can generate a variety of transfer
+ patterns.
+
+ See http://www.linux-usb.org/usbtest/
+
+config BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_FFSTEST
+ bool "ffs-test"
+ help
+ User mode filesystem api for usb composite function
+endif
+
config BR2_PACKAGE_LINUX_TOOLS_TMON
bool "tmon"
depends on BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/linux-tools/linux-tool-usbtools.mk.in b/package/linux-tools/linux-tool-usbtools.mk.in
new file mode 100644
index 000000000000..28b3aff25cc2
--- /dev/null
+++ b/package/linux-tools/linux-tool-usbtools.mk.in
@@ -0,0 +1,42 @@
+################################################################################
+#
+# usbtools
+#
+################################################################################
+
+LINUX_TOOLS += usbtools
+
+USBTOOLS_MAKE_OPTS = $(LINUX_MAKE_FLAGS) LDFLAGS="$(TARGET_LDFLAGS)"
+
+define USBTOOLS_BUILD_CMDS
+ $(Q)if ! grep install $(LINUX_DIR)/tools/usb/Makefile >/dev/null 2>&1 ; then \
+ echo "Your kernel version is too old to build the USB tools." ; \
+ echo "At least kernel 5.9 must be used." ; \
+ exit 1 ; \
+ fi
+
+ $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/usb \
+ $(USBTOOLS_MAKE_OPTS) \
+ all
+endef
+
+ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_TESTUSB),)
+define USBTOOLS_INSTALL_REMOVE_TESTUSB
+ $(RM) -rf $(TARGET_DIR)/usr/bin/testusb
+endef
+endif
+
+ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_FFSTEST),)
+define USBTOOLS_INSTALL_REMOVE_FFSTEST
+ $(RM) -rf $(TARGET_DIR)/usr/bin/ffs-test
+endef
+endif
+
+define USBTOOLS_INSTALL_TARGET_CMDS
+ $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/usb \
+ $(USBTOOLS_MAKE_OPTS) \
+ DESTDIR=$(TARGET_DIR) \
+ install
+ $(USBTOOLS_INSTALL_REMOVE_TESTUSB)
+ $(USBTOOLS_INSTALL_REMOVE_FFSTEST)
+endef
--
2.34.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] package/linux-tools: add USB tools (testusb and ffs-test)
2023-03-24 9:33 [Buildroot] [PATCH] package/linux-tools: add USB tools (testusb and ffs-test) Luca Ceresoli via buildroot
@ 2023-03-24 10:09 ` Herve Codina via buildroot
2023-03-24 10:13 ` Thomas Petazzoni via buildroot
2023-03-24 10:27 ` yann.morin
1 sibling, 1 reply; 5+ messages in thread
From: Herve Codina via buildroot @ 2023-03-24 10:09 UTC (permalink / raw)
To: Luca Ceresoli; +Cc: Yann E . MORIN, Thomas Petazzoni, buildroot
Hi Luca,
On Fri, 24 Mar 2023 10:33:07 +0100
Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> Extend the linux-tools package to also build the userspace USB tools, which
> currently include testusb and ffs-test.
>
> These tools are in the kernel tree since a long time, but a Makefile was
> added only in 5.9 to allow building in the same way as other tools provided
> with the kernel. Here we use the Makefile and thus version >= 5.9 is
> required. Support for older kernels may be added later if needed.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
[...]
> +
> +ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_TESTUSB),)
> +define USBTOOLS_INSTALL_REMOVE_TESTUSB
> + $(RM) -rf $(TARGET_DIR)/usr/bin/testusb
Why -r ?
> +endef
> +endif
> +
> +ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_FFSTEST),)
> +define USBTOOLS_INSTALL_REMOVE_FFSTEST
> + $(RM) -rf $(TARGET_DIR)/usr/bin/ffs-test
Same here
> +endef
> +endif
> +
Otherwise, looks good for me.
Thanks for this patch,
Hervé
--
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] package/linux-tools: add USB tools (testusb and ffs-test)
2023-03-24 10:09 ` Herve Codina via buildroot
@ 2023-03-24 10:13 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-03-24 10:13 UTC (permalink / raw)
To: Herve Codina via buildroot; +Cc: Luca Ceresoli, Herve Codina, Yann E . MORIN
On Fri, 24 Mar 2023 11:09:46 +0100
Herve Codina via buildroot <buildroot@buildroot.org> wrote:
> > +ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_TESTUSB),)
> > +define USBTOOLS_INSTALL_REMOVE_TESTUSB
> > + $(RM) -rf $(TARGET_DIR)/usr/bin/testusb
>
> Why -r ?
And the -f is already inside $(RM):
'RM'
Command to remove a file; default 'rm -f'.
(from the make documentation)
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] package/linux-tools: add USB tools (testusb and ffs-test)
2023-03-24 9:33 [Buildroot] [PATCH] package/linux-tools: add USB tools (testusb and ffs-test) Luca Ceresoli via buildroot
2023-03-24 10:09 ` Herve Codina via buildroot
@ 2023-03-24 10:27 ` yann.morin
2023-03-27 13:57 ` Luca Ceresoli via buildroot
1 sibling, 1 reply; 5+ messages in thread
From: yann.morin @ 2023-03-24 10:27 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Hervé Codina, Yann E . MORIN, Thomas Petazzoni, buildroot
Luca, All,
On 2023-03-24 10:33 +0100, Luca Ceresoli via buildroot spake thusly:
> Extend the linux-tools package to also build the userspace USB tools, which
> currently include testusb and ffs-test.
>
> These tools are in the kernel tree since a long time, but a Makefile was
> added only in 5.9 to allow building in the same way as other tools provided
> with the kernel. Here we use the Makefile and thus version >= 5.9 is
> required. Support for older kernels may be added later if needed.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
[--SNIP--]
> diff --git a/package/linux-tools/linux-tool-usbtools.mk.in b/package/linux-tools/linux-tool-usbtools.mk.in
> new file mode 100644
> index 000000000000..28b3aff25cc2
> --- /dev/null
> +++ b/package/linux-tools/linux-tool-usbtools.mk.in
> @@ -0,0 +1,42 @@
> +################################################################################
> +#
> +# usbtools
> +#
> +################################################################################
> +
> +LINUX_TOOLS += usbtools
> +
> +USBTOOLS_MAKE_OPTS = $(LINUX_MAKE_FLAGS) LDFLAGS="$(TARGET_LDFLAGS)"
> +
> +define USBTOOLS_BUILD_CMDS
> + $(Q)if ! grep install $(LINUX_DIR)/tools/usb/Makefile >/dev/null 2>&1 ; then \
> + echo "Your kernel version is too old to build the USB tools." ; \
> + echo "At least kernel 5.9 must be used." ; \
> + exit 1 ; \
> + fi
> +
> + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/usb \
> + $(USBTOOLS_MAKE_OPTS) \
> + all
> +endef
> +
> +ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_TESTUSB),)
> +define USBTOOLS_INSTALL_REMOVE_TESTUSB
> + $(RM) -rf $(TARGET_DIR)/usr/bin/testusb
> +endef
> +endif
> +
> +ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_FFSTEST),)
> +define USBTOOLS_INSTALL_REMOVE_FFSTEST
> + $(RM) -rf $(TARGET_DIR)/usr/bin/ffs-test
> +endef
> +endif
> +
> +define USBTOOLS_INSTALL_TARGET_CMDS
> + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/usb \
> + $(USBTOOLS_MAKE_OPTS) \
> + DESTDIR=$(TARGET_DIR) \
> + install
> + $(USBTOOLS_INSTALL_REMOVE_TESTUSB)
> + $(USBTOOLS_INSTALL_REMOVE_FFSTEST)
> +endef
Rather than installing everything (two files) and removing the one that
is not needed, h=why not just install the one(s) that is(are) needed?
LINUX_TOOLS_USBTOOLS_LIST = \
$(if $(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_TESTUSB),$(LINUX_DIR)/tools/usb/testusb) \
$(if $(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_FFSTEST),$(LINUX_DIR)/tools/usb/ffs-test)
define USBTOOLS_INSTALL_TARGET_CMDS
$(foreach f,$(LINUX_TOOLS_USBTOOLS_LIST),$(INSTALL) -D -m 0755 $(t) $(TARGET_DIR)/usr/bin/$(notdir $(t)))
endef
Regards,
Yann E. MORIN.
> --
> 2.34.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
____________
.-----------------.--------------------: _ :------------------.
| Yann E. MORIN | Real-Time Embedded | __/ ) | /"\ ASCII RIBBON |
| | Software Designer | _/ - /' | \ / CAMPAIGN |
| +33 638.411.245 '--------------------: (_ `--, | X AGAINST |
| yann.morin (at) orange.com |_=" ,--' | / \ HTML MAIL |
'--------------------------------------:______/_____:------------------'
_________________________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] package/linux-tools: add USB tools (testusb and ffs-test)
2023-03-24 10:27 ` yann.morin
@ 2023-03-27 13:57 ` Luca Ceresoli via buildroot
0 siblings, 0 replies; 5+ messages in thread
From: Luca Ceresoli via buildroot @ 2023-03-27 13:57 UTC (permalink / raw)
To: yann.morin; +Cc: Hervé Codina, Yann E . MORIN, Thomas Petazzoni, buildroot
Hi Yann, Hervé, Thomas,
On Fri, 24 Mar 2023 11:27:02 +0100
<yann.morin@orange.com> wrote:
> Luca, All,
>
> On 2023-03-24 10:33 +0100, Luca Ceresoli via buildroot spake thusly:
> > Extend the linux-tools package to also build the userspace USB tools, which
> > currently include testusb and ffs-test.
> >
> > These tools are in the kernel tree since a long time, but a Makefile was
> > added only in 5.9 to allow building in the same way as other tools provided
> > with the kernel. Here we use the Makefile and thus version >= 5.9 is
> > required. Support for older kernels may be added later if needed.
> >
> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> > ---
> [--SNIP--]
> > diff --git a/package/linux-tools/linux-tool-usbtools.mk.in b/package/linux-tools/linux-tool-usbtools.mk.in
> > new file mode 100644
> > index 000000000000..28b3aff25cc2
> > --- /dev/null
> > +++ b/package/linux-tools/linux-tool-usbtools.mk.in
> > @@ -0,0 +1,42 @@
> > +################################################################################
> > +#
> > +# usbtools
> > +#
> > +################################################################################
> > +
> > +LINUX_TOOLS += usbtools
> > +
> > +USBTOOLS_MAKE_OPTS = $(LINUX_MAKE_FLAGS) LDFLAGS="$(TARGET_LDFLAGS)"
> > +
> > +define USBTOOLS_BUILD_CMDS
> > + $(Q)if ! grep install $(LINUX_DIR)/tools/usb/Makefile >/dev/null 2>&1 ; then \
> > + echo "Your kernel version is too old to build the USB tools." ; \
> > + echo "At least kernel 5.9 must be used." ; \
> > + exit 1 ; \
> > + fi
> > +
> > + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/usb \
> > + $(USBTOOLS_MAKE_OPTS) \
> > + all
> > +endef
> > +
> > +ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_TESTUSB),)
> > +define USBTOOLS_INSTALL_REMOVE_TESTUSB
> > + $(RM) -rf $(TARGET_DIR)/usr/bin/testusb
> > +endef
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_FFSTEST),)
> > +define USBTOOLS_INSTALL_REMOVE_FFSTEST
> > + $(RM) -rf $(TARGET_DIR)/usr/bin/ffs-test
> > +endef
> > +endif
> > +
> > +define USBTOOLS_INSTALL_TARGET_CMDS
> > + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/usb \
> > + $(USBTOOLS_MAKE_OPTS) \
> > + DESTDIR=$(TARGET_DIR) \
> > + install
> > + $(USBTOOLS_INSTALL_REMOVE_TESTUSB)
> > + $(USBTOOLS_INSTALL_REMOVE_FFSTEST)
> > +endef
>
> Rather than installing everything (two files) and removing the one that
> is not needed, h=why not just install the one(s) that is(are) needed?
>
> LINUX_TOOLS_USBTOOLS_LIST = \
> $(if $(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_TESTUSB),$(LINUX_DIR)/tools/usb/testusb) \
> $(if $(BR2_PACKAGE_LINUX_TOOLS_USBTOOLS_FFSTEST),$(LINUX_DIR)/tools/usb/ffs-test)
>
> define USBTOOLS_INSTALL_TARGET_CMDS
> $(foreach f,$(LINUX_TOOLS_USBTOOLS_LIST),$(INSTALL) -D -m 0755 $(t) $(TARGET_DIR)/usr/bin/$(notdir $(t)))
> endef
Thanks for your review! I generally prefer using the upstream
installation procedure when one exists, instead of (re)writing it. But
I must agree the removal logic is ugly.
Prompted by your comments, I noticed the upstream Makefile builds and
installs the tools listed in the ALL_TARGETS variable, so in v2 I'm
just setting it, and the upstream logic works just fine with it.
As a side effect, 'RM' is not used anymore, getting rid of all those
unneeded flags reported by Hervé and Thomas! :-)
v2 incoming.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-27 13:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-24 9:33 [Buildroot] [PATCH] package/linux-tools: add USB tools (testusb and ffs-test) Luca Ceresoli via buildroot
2023-03-24 10:09 ` Herve Codina via buildroot
2023-03-24 10:13 ` Thomas Petazzoni via buildroot
2023-03-24 10:27 ` yann.morin
2023-03-27 13:57 ` Luca Ceresoli via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox