diff mbox

[v2,3/3] imx-usb-loader: new package

Message ID 1412175826-9010-4-git-send-email-luca@lucaceresoli.net
State Changes Requested
Headers show

Commit Message

Luca Ceresoli Oct. 1, 2014, 3:03 p.m. UTC
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
---
 package/Config.in.host                   |  1 +
 package/imx-usb-loader/Config.in.host    | 14 ++++++++++++++
 package/imx-usb-loader/imx-usb-loader.mk | 22 ++++++++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 package/imx-usb-loader/Config.in.host
 create mode 100644 package/imx-usb-loader/imx-usb-loader.mk

Comments

Thomas Petazzoni Oct. 1, 2014, 4:16 p.m. UTC | #1
Dear Luca Ceresoli,

On Wed,  1 Oct 2014 17:03:46 +0200, Luca Ceresoli wrote:

> diff --git a/package/imx-usb-loader/Config.in.host b/package/imx-usb-loader/Config.in.host
> new file mode 100644
> index 0000000..2540ea9
> --- /dev/null
> +++ b/package/imx-usb-loader/Config.in.host
> @@ -0,0 +1,14 @@
> +config BR2_PACKAGE_HOST_IMX_USB_LOADER
> +	bool "host imx-usb-loader"
> +	depends on BR2_arm || BR2_armeb
> +	select BR2_PACKAGE_LIBUSB # libusb >= 1.0 is required

Huh, no! BR2_PACKAGE_LIBUSB is the *target* libusb. If you depend on
host-libusb, you don't need to add any select here.

> diff --git a/package/imx-usb-loader/imx-usb-loader.mk b/package/imx-usb-loader/imx-usb-loader.mk
> new file mode 100644
> index 0000000..48ef35c
> --- /dev/null
> +++ b/package/imx-usb-loader/imx-usb-loader.mk
> @@ -0,0 +1,22 @@
> +################################################################################
> +#
> +# imx-uxb-loader
> +#
> +################################################################################
> +
> +IMX_USB_LOADER_VERSION = f96aee286ea17c832b7ec922dd76842deb5ce299
> +IMX_USB_LOADER_SITE = $(call github,boundarydevices,imx_usb_loader,$(IMX_USB_LOADER_VERSION))
> +IMX_USB_LOADER_LICENSE = LGPLv2.1+, LGPL (getopt.*)

LGPL with no version specified?

> +IMX_USB_LOADER_LICENSE_FILES = COPYING
> +IMX_USB_LOADER_DEPENDENCIES = host-libusb
> +
> +define HOST_IMX_USB_LOADER_BUILD_CMDS
> +	$(HOST_MAKE_ENV) $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D)
> +endef
> +
> +define HOST_IMX_USB_LOADER_INSTALL_CMDS
> +    $(INSTALL) -D -m 0755 $(@D)/imx_usb $(HOST_DIR)/usr/bin
> +    $(INSTALL) -D -m 0755 $(@D)/imx_uart $(HOST_DIR)/usr/bin

Full path as the last argument.

Also: what about having this package enabled by default in the sabresd
defconfigs, if it makes sense to have this host tool enabled for those
configurations?

Best regards,

Thomas
Eric Nelson Oct. 1, 2014, 4:55 p.m. UTC | #2
Hi Thomas,

On 10/01/2014 09:16 AM, Thomas Petazzoni wrote:
> Dear Luca Ceresoli,
> 
> On Wed,  1 Oct 2014 17:03:46 +0200, Luca Ceresoli wrote:
> 
> <snip>
>
>> +IMX_USB_LOADER_LICENSE_FILES = COPYING
>> +IMX_USB_LOADER_DEPENDENCIES = host-libusb
>> +
>> +define HOST_IMX_USB_LOADER_BUILD_CMDS
>> +	$(HOST_MAKE_ENV) $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D)
>> +endef
>> +
>> +define HOST_IMX_USB_LOADER_INSTALL_CMDS
>> +    $(INSTALL) -D -m 0755 $(@D)/imx_usb $(HOST_DIR)/usr/bin
>> +    $(INSTALL) -D -m 0755 $(@D)/imx_uart $(HOST_DIR)/usr/bin
> 
> Full path as the last argument.
> 
> Also: what about having this package enabled by default in the sabresd
> defconfigs, if it makes sense to have this host tool enabled for those
> configurations?
> 

Or all i.MX devices. This is known to work with i.MX5x and i.MX6x
boards, and I think I saw some comments from Vybrid users.

That said, it's a bit of an arcane tool that's useful when doing
U-Boot development or unbricking a board.

Regards,


Eric
Luca Ceresoli Oct. 2, 2014, 8:47 a.m. UTC | #3
Dear Thomas,

Thomas Petazzoni wrote:
> Dear Luca Ceresoli,
>
> On Wed,  1 Oct 2014 17:03:46 +0200, Luca Ceresoli wrote:
>
>> diff --git a/package/imx-usb-loader/Config.in.host b/package/imx-usb-loader/Config.in.host
>> new file mode 100644
>> index 0000000..2540ea9
>> --- /dev/null
>> +++ b/package/imx-usb-loader/Config.in.host
>> @@ -0,0 +1,14 @@
>> +config BR2_PACKAGE_HOST_IMX_USB_LOADER
>> +	bool "host imx-usb-loader"
>> +	depends on BR2_arm || BR2_armeb
>> +	select BR2_PACKAGE_LIBUSB # libusb >= 1.0 is required
>
> Huh, no! BR2_PACKAGE_LIBUSB is the *target* libusb. If you depend on
> host-libusb, you don't need to add any select here.

Ops! Will fix!

>
>> diff --git a/package/imx-usb-loader/imx-usb-loader.mk b/package/imx-usb-loader/imx-usb-loader.mk
>> new file mode 100644
>> index 0000000..48ef35c
>> --- /dev/null
>> +++ b/package/imx-usb-loader/imx-usb-loader.mk
>> @@ -0,0 +1,22 @@
>> +################################################################################
>> +#
>> +# imx-uxb-loader
>> +#
>> +################################################################################
>> +
>> +IMX_USB_LOADER_VERSION = f96aee286ea17c832b7ec922dd76842deb5ce299
>> +IMX_USB_LOADER_SITE = $(call github,boundarydevices,imx_usb_loader,$(IMX_USB_LOADER_VERSION))
>> +IMX_USB_LOADER_LICENSE = LGPLv2.1+, LGPL (getopt.*)
>
> LGPL with no version specified?
>

Yes. The only indication in getopt.[hc] is:

   License: LGPL

and nothing else. This means LGPL (ant version), it is the list of
licenses documented on the BR manual.

BTW, the LGPL license is declared in BR for pppd and tslib as well.

>> +IMX_USB_LOADER_LICENSE_FILES = COPYING
>> +IMX_USB_LOADER_DEPENDENCIES = host-libusb
>> +
>> +define HOST_IMX_USB_LOADER_BUILD_CMDS
>> +	$(HOST_MAKE_ENV) $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D)
>> +endef
>> +
>> +define HOST_IMX_USB_LOADER_INSTALL_CMDS
>> +    $(INSTALL) -D -m 0755 $(@D)/imx_usb $(HOST_DIR)/usr/bin
>> +    $(INSTALL) -D -m 0755 $(@D)/imx_uart $(HOST_DIR)/usr/bin
>
> Full path as the last argument.

Will fix.

>
> Also: what about having this package enabled by default in the sabresd
> defconfigs, if it makes sense to have this host tool enabled for those
> configurations?

My plan is slightly more ambitious indeed. What I have in mind is to:
  1. enable imx-usb-loader for both SABRESD boards;
  2. prepare the configuration files that imx_usb_loader needs to boot
     the device;
  3. document how to boot using imx_usb_loader + the config files.

Step 1 is trivial.

For step 2 I'll have generate two files: imx_usb.conf (the top-level
config file for imx_usb) and mx6_usb_work.conf (different for the two
SoC variants). The former can be taken as is from the imx_usb_loader
sources, the latter must be edited as described in Vincent's tutorial
[1], at section "Prepare your payload and configuration".

I think the best way is to use a post-image script to create these
files in output/images, except they are not images. Does this sound
fine?

If step 2 is well done, the actions to boot the device would be as
simple as:

   ./output/host/usr/bin/imx_usb -c output/images

Then step 3 would be trivial as well.

[1] https://community.freescale.com/docs/DOC-101842
Vincent Stehlé Oct. 2, 2014, 9:13 a.m. UTC | #4
On 10/01/2014 05:03 PM, Luca Ceresoli wrote:
(snip)

Hi Luca,

Thank you for this imx_usb_loader "recipe".

I have just some small remarks for the configuration files (below), but
apart from that I could build the loader ok with 'make
host-imx-usb-loader', and boot through USB just fine. So thanks!

(..)
> diff --git a/package/imx-usb-loader/imx-usb-loader.mk b/package/imx-usb-loader/imx-usb-loader.mk
> new file mode 100644
> index 0000000..48ef35c
> --- /dev/null
> +++ b/package/imx-usb-loader/imx-usb-loader.mk
> @@ -0,0 +1,22 @@
> +################################################################################
> +#
> +# imx-uxb-loader
> +#
> +################################################################################
> +
> +IMX_USB_LOADER_VERSION = f96aee286ea17c832b7ec922dd76842deb5ce299
> +IMX_USB_LOADER_SITE = $(call github,boundarydevices,imx_usb_loader,$(IMX_USB_LOADER_VERSION))
> +IMX_USB_LOADER_LICENSE = LGPLv2.1+, LGPL (getopt.*)
> +IMX_USB_LOADER_LICENSE_FILES = COPYING
> +IMX_USB_LOADER_DEPENDENCIES = host-libusb
> +
> +define HOST_IMX_USB_LOADER_BUILD_CMDS
> +	$(HOST_MAKE_ENV) $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D)
> +endef
> +
> +define HOST_IMX_USB_LOADER_INSTALL_CMDS
> +    $(INSTALL) -D -m 0755 $(@D)/imx_usb $(HOST_DIR)/usr/bin
> +    $(INSTALL) -D -m 0755 $(@D)/imx_uart $(HOST_DIR)/usr/bin

Wouldn't you want to install the supplied configurations files, too?
Like in:

  $(INSTALL) -D -m 0644 $(@D)/imx_usb.conf $(HOST_DIR)/etc/imx_usb.conf
  $(INSTALL) -D -m 0644 $(@D)/mx6_usb_work.conf
$(HOST_DIR)/etc/mx6_usb_work.conf

I feel they could be used as examples or, at least, starting points.

Maybe you want to patch a bit imx_usb, to change the default
configuration files path? It defaults to '/etc/imx-loader.d/' but I
think we could have something better in the buildroot case, like
"$(HOST_DIR)/etc".

> +endef
> +
> +$(eval $(host-generic-package))

Best regards,

V.
Luca Ceresoli Oct. 2, 2014, 9:17 a.m. UTC | #5
Hi,

Luca Ceresoli wrote:
> Dear Thomas,
>
> Thomas Petazzoni wrote:
>> Dear Luca Ceresoli,
>>
>> On Wed,  1 Oct 2014 17:03:46 +0200, Luca Ceresoli wrote:
...
>>> --- /dev/null
>>> +++ b/package/imx-usb-loader/imx-usb-loader.mk
>>> @@ -0,0 +1,22 @@
>>> +################################################################################
>>>
>>> +#
>>> +# imx-uxb-loader
>>> +#
>>> +################################################################################
>>>
>>> +
>>> +IMX_USB_LOADER_VERSION = f96aee286ea17c832b7ec922dd76842deb5ce299
>>> +IMX_USB_LOADER_SITE = $(call
>>> github,boundarydevices,imx_usb_loader,$(IMX_USB_LOADER_VERSION))
>>> +IMX_USB_LOADER_LICENSE = LGPLv2.1+, LGPL (getopt.*)
>>
>> LGPL with no version specified?
>>
>
> Yes. The only indication in getopt.[hc] is:
>
>    License: LGPL
>
> and nothing else. This means LGPL (ant version), it is the list of
> licenses documented on the BR manual.
>
> BTW, the LGPL license is declared in BR for pppd and tslib as well.

Looking at it a bit closer, getopt.* is not used to build on Linux,
only for Windows.

So I guess I could drop the LGPL part:

   IMX_USB_LOADER_LICENSE = LGPLv2.1+
Thomas Petazzoni Oct. 2, 2014, 9:52 a.m. UTC | #6
Dear Luca Ceresoli,

On Thu, 02 Oct 2014 10:47:44 +0200, Luca Ceresoli wrote:

> Yes. The only indication in getopt.[hc] is:
> 
>    License: LGPL
> 
> and nothing else. This means LGPL (ant version), it is the list of
> licenses documented on the BR manual.
> 
> BTW, the LGPL license is declared in BR for pppd and tslib as well.

Ok.

> > Also: what about having this package enabled by default in the sabresd
> > defconfigs, if it makes sense to have this host tool enabled for those
> > configurations?
> 
> My plan is slightly more ambitious indeed. What I have in mind is to:
>   1. enable imx-usb-loader for both SABRESD boards;
>   2. prepare the configuration files that imx_usb_loader needs to boot
>      the device;
>   3. document how to boot using imx_usb_loader + the config files.

Sounds like a good plan.

> 
> Step 1 is trivial.
> 
> For step 2 I'll have generate two files: imx_usb.conf (the top-level
> config file for imx_usb) and mx6_usb_work.conf (different for the two
> SoC variants). The former can be taken as is from the imx_usb_loader
> sources, the latter must be edited as described in Vincent's tutorial
> [1], at section "Prepare your payload and configuration".
> 
> I think the best way is to use a post-image script to create these
> files in output/images, except they are not images. Does this sound
> fine?

Yes, it sounds fine. From my point of view output/images is not
necessarily strictly limited to binary images. It can also contain
other files that are useful to run/flash the system on the target.

Though do you really need to generate those files? They look like
pretty much static configuration files, that could be put in
board/freescale/<foo>/, no?

> If step 2 is well done, the actions to boot the device would be as
> simple as:
> 
>    ./output/host/usr/bin/imx_usb -c output/images

Cool!

Thomas
Luca Ceresoli Oct. 2, 2014, 11:10 a.m. UTC | #7
Dear Thomas,

Thomas Petazzoni wrote:
> Dear Luca Ceresoli,
>
> On Thu, 02 Oct 2014 10:47:44 +0200, Luca Ceresoli wrote:
>
...
>>> Also: what about having this package enabled by default in the sabresd
>>> defconfigs, if it makes sense to have this host tool enabled for those
>>> configurations?
>>
>> My plan is slightly more ambitious indeed. What I have in mind is to:
>>    1. enable imx-usb-loader for both SABRESD boards;
>>    2. prepare the configuration files that imx_usb_loader needs to boot
>>       the device;
>>    3. document how to boot using imx_usb_loader + the config files.
>
> Sounds like a good plan.
>
>>
>> Step 1 is trivial.
>>
>> For step 2 I'll have generate two files: imx_usb.conf (the top-level
>> config file for imx_usb) and mx6_usb_work.conf (different for the two
>> SoC variants). The former can be taken as is from the imx_usb_loader
>> sources, the latter must be edited as described in Vincent's tutorial
>> [1], at section "Prepare your payload and configuration".
>>
>> I think the best way is to use a post-image script to create these
>> files in output/images, except they are not images. Does this sound
>> fine?
>
> Yes, it sounds fine. From my point of view output/images is not
> necessarily strictly limited to binary images. It can also contain
> other files that are useful to run/flash the system on the target.
>
> Though do you really need to generate those files? They look like
> pretty much static configuration files, that could be put in
> board/freescale/<foo>/, no?

Probably.

I didn't want to create a lot of almost-equal files: the only
difference between the two boards is the .dtb to use. Hence I thought
of a script producing the config file from a template file.

But since there would be only 2 files for now it may be fine as well to
just have the two files.

I'll choose as soon as I start coding.
Luca Ceresoli Oct. 2, 2014, 11:43 a.m. UTC | #8
Dear Vincent,

Vincent Stehlé wrote:
> On 10/01/2014 05:03 PM, Luca Ceresoli wrote:
> (snip)
>
> Hi Luca,
>
> Thank you for this imx_usb_loader "recipe".
>
> I have just some small remarks for the configuration files (below), but
> apart from that I could build the loader ok with 'make
> host-imx-usb-loader', and boot through USB just fine. So thanks!

Thanks for keeping my patches tested!

>
> (..)
>> diff --git a/package/imx-usb-loader/imx-usb-loader.mk b/package/imx-usb-loader/imx-usb-loader.mk
>> new file mode 100644
>> index 0000000..48ef35c
>> --- /dev/null
>> +++ b/package/imx-usb-loader/imx-usb-loader.mk
>> @@ -0,0 +1,22 @@
>> +################################################################################
>> +#
>> +# imx-uxb-loader
>> +#
>> +################################################################################
>> +
>> +IMX_USB_LOADER_VERSION = f96aee286ea17c832b7ec922dd76842deb5ce299
>> +IMX_USB_LOADER_SITE = $(call github,boundarydevices,imx_usb_loader,$(IMX_USB_LOADER_VERSION))
>> +IMX_USB_LOADER_LICENSE = LGPLv2.1+, LGPL (getopt.*)
>> +IMX_USB_LOADER_LICENSE_FILES = COPYING
>> +IMX_USB_LOADER_DEPENDENCIES = host-libusb
>> +
>> +define HOST_IMX_USB_LOADER_BUILD_CMDS
>> +	$(HOST_MAKE_ENV) $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D)
>> +endef
>> +
>> +define HOST_IMX_USB_LOADER_INSTALL_CMDS
>> +    $(INSTALL) -D -m 0755 $(@D)/imx_usb $(HOST_DIR)/usr/bin
>> +    $(INSTALL) -D -m 0755 $(@D)/imx_uart $(HOST_DIR)/usr/bin
>
> Wouldn't you want to install the supplied configurations files, too?
> Like in:
>
>    $(INSTALL) -D -m 0644 $(@D)/imx_usb.conf $(HOST_DIR)/etc/imx_usb.conf
>    $(INSTALL) -D -m 0644 $(@D)/mx6_usb_work.conf
> $(HOST_DIR)/etc/mx6_usb_work.conf
>
> I feel they could be used as examples or, at least, starting points.
>
> Maybe you want to patch a bit imx_usb, to change the default
> configuration files path? It defaults to '/etc/imx-loader.d/' but I
> think we could have something better in the buildroot case, like
> "$(HOST_DIR)/etc".

This means I would need to patch the imx_usb.c source code, and do it in
a way that is not relocatable.

Actually I have another plan [1]: creating a ready-to-use config file
and document how to use it, without touching how imx_usb works now.
Unless I'm missing something from your e-mail, I find my way cleaner
and more complete.

Users who want to use this tool in a different way can still find the
original files in output/build/imx-usb-loader-*/ of course.

[1] http://lists.busybox.net/pipermail/buildroot/2014-October/107492.html
diff mbox

Patch

diff --git a/package/Config.in.host b/package/Config.in.host
index 2c88c0b..dce209f 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -8,6 +8,7 @@  menu "Host utilities"
 	source "package/genext2fs/Config.in.host"
 	source "package/genimage/Config.in.host"
 	source "package/genpart/Config.in.host"
+	source "package/imx-usb-loader/Config.in.host"
 	source "package/lpc3250loader/Config.in.host"
 	source "package/mtd/Config.in.host"
 	source "package/mtools/Config.in.host"
diff --git a/package/imx-usb-loader/Config.in.host b/package/imx-usb-loader/Config.in.host
new file mode 100644
index 0000000..2540ea9
--- /dev/null
+++ b/package/imx-usb-loader/Config.in.host
@@ -0,0 +1,14 @@ 
+config BR2_PACKAGE_HOST_IMX_USB_LOADER
+	bool "host imx-usb-loader"
+	depends on BR2_arm || BR2_armeb
+	select BR2_PACKAGE_LIBUSB # libusb >= 1.0 is required
+	help
+	  This utility allows to download and execute code on Freescale
+	  i.MX5/i.MX6 and Vybrid SoCs through the Serial Download Protocol
+	  (SDP). Depending on the board, there is usually some kind of recovery
+	  button to bring the SoC into serial download boot mode, check
+	  documentation of your hardware.
+
+	  The utility support USB and UART as serial link.
+
+	  https://github.com/boundarydevices/imx_usb_loader
diff --git a/package/imx-usb-loader/imx-usb-loader.mk b/package/imx-usb-loader/imx-usb-loader.mk
new file mode 100644
index 0000000..48ef35c
--- /dev/null
+++ b/package/imx-usb-loader/imx-usb-loader.mk
@@ -0,0 +1,22 @@ 
+################################################################################
+#
+# imx-uxb-loader
+#
+################################################################################
+
+IMX_USB_LOADER_VERSION = f96aee286ea17c832b7ec922dd76842deb5ce299
+IMX_USB_LOADER_SITE = $(call github,boundarydevices,imx_usb_loader,$(IMX_USB_LOADER_VERSION))
+IMX_USB_LOADER_LICENSE = LGPLv2.1+, LGPL (getopt.*)
+IMX_USB_LOADER_LICENSE_FILES = COPYING
+IMX_USB_LOADER_DEPENDENCIES = host-libusb
+
+define HOST_IMX_USB_LOADER_BUILD_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D)
+endef
+
+define HOST_IMX_USB_LOADER_INSTALL_CMDS
+    $(INSTALL) -D -m 0755 $(@D)/imx_usb $(HOST_DIR)/usr/bin
+    $(INSTALL) -D -m 0755 $(@D)/imx_uart $(HOST_DIR)/usr/bin
+endef
+
+$(eval $(host-generic-package))