diff mbox

[U-Boot] arm: mx5: Fix NAND image generation

Message ID 1459846446-5893-1-git-send-email-marex@denx.de
State Accepted
Commit 0297bd1106bc59f46ba4401bb50a0cdc9afc9faa
Delegated to: Stefano Babic
Headers show

Commit Message

Marek Vasut April 5, 2016, 8:54 a.m. UTC
The echo -ne "\xNN" does not work in certain bourne-compatible shells, like
dash. The recommended way of hex->char conversion is using printf(1), but
there is a pitfall here. The GNU printf does support "\xNN" format, but
according to the opengroup documentation, this is not part of POSIX. The
POSIX printf only defines "\NNN" where N is octal. Thus, for the sake of
compatibility, we use that.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
---
 arch/arm/imx-common/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marek Vasut April 19, 2016, 11:49 a.m. UTC | #1
On 04/05/2016 10:54 AM, Marek Vasut wrote:
> The echo -ne "\xNN" does not work in certain bourne-compatible shells, like
> dash. The recommended way of hex->char conversion is using printf(1), but
> there is a pitfall here. The GNU printf does support "\xNN" format, but
> according to the opengroup documentation, this is not part of POSIX. The
> POSIX printf only defines "\NNN" where N is octal. Thus, for the sake of
> compatibility, we use that.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>  arch/arm/imx-common/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/imx-common/Makefile b/arch/arm/imx-common/Makefile
> index 30e66ba..c208628 100644
> --- a/arch/arm/imx-common/Makefile
> +++ b/arch/arm/imx-common/Makefile
> @@ -86,7 +86,7 @@ u-boot-with-nand-spl.imx: spl/u-boot-nand-spl.imx u-boot.uim FORCE
>  	$(call if_changed,pad_cat)
>  
>  quiet_cmd_u-boot-nand-spl_imx = GEN     $@
> -cmd_u-boot-nand-spl_imx = (echo -ne '\x00\x00\x00\x00\x46\x43\x42\x20\x01' && \
> +cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \
>  	dd bs=1015 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
>  
>  spl/u-boot-nand-spl.imx: SPL FORCE
> 

Can this be applied? This fixes real bug.
Stefano Babic April 19, 2016, 1:55 p.m. UTC | #2
On 05/04/2016 10:54, Marek Vasut wrote:
> The echo -ne "\xNN" does not work in certain bourne-compatible shells, like
> dash. The recommended way of hex->char conversion is using printf(1), but
> there is a pitfall here. The GNU printf does support "\xNN" format, but
> according to the opengroup documentation, this is not part of POSIX. The
> POSIX printf only defines "\NNN" where N is octal. Thus, for the sake of
> compatibility, we use that.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>  arch/arm/imx-common/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/imx-common/Makefile b/arch/arm/imx-common/Makefile
> index 30e66ba..c208628 100644
> --- a/arch/arm/imx-common/Makefile
> +++ b/arch/arm/imx-common/Makefile
> @@ -86,7 +86,7 @@ u-boot-with-nand-spl.imx: spl/u-boot-nand-spl.imx u-boot.uim FORCE
>  	$(call if_changed,pad_cat)
>  
>  quiet_cmd_u-boot-nand-spl_imx = GEN     $@
> -cmd_u-boot-nand-spl_imx = (echo -ne '\x00\x00\x00\x00\x46\x43\x42\x20\x01' && \
> +cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \
>  	dd bs=1015 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
>  
>  spl/u-boot-nand-spl.imx: SPL FORCE
> 

Applied to master, thanks !

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/arch/arm/imx-common/Makefile b/arch/arm/imx-common/Makefile
index 30e66ba..c208628 100644
--- a/arch/arm/imx-common/Makefile
+++ b/arch/arm/imx-common/Makefile
@@ -86,7 +86,7 @@  u-boot-with-nand-spl.imx: spl/u-boot-nand-spl.imx u-boot.uim FORCE
 	$(call if_changed,pad_cat)
 
 quiet_cmd_u-boot-nand-spl_imx = GEN     $@
-cmd_u-boot-nand-spl_imx = (echo -ne '\x00\x00\x00\x00\x46\x43\x42\x20\x01' && \
+cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \
 	dd bs=1015 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
 
 spl/u-boot-nand-spl.imx: SPL FORCE