[PATCH 01/32] cmd: fdt: Import is_printable_string() from DTC to fix u32 misprint

Simon Glass sjg at chromium.org
Wed Mar 1 16:01:56 CET 2023

On Mon, 27 Feb 2023 at 12:55, Marek Vasut
<marek.vasut+renesas at mailbox.org> wrote:
> Import is_printable_string() implementation from DTC 1.7.0 as of
> DTC commit 039a994 ("Bump version to v1.7.0") . This fixes a print
> of u32 property which so far used to be printed as string by U-Boot
> fdt print command.
> We might see the case where the parsed property value, in this case
> it is a 32-bit integer, identified as a printable string or a null byte
> (concatenated strings) because of its last character happens to be:
>   0x00 (null character), 0xB (vertical tab character) or
>   0x10 (line feed character)
> In this situation, if the string is identified as printable string,
> it will be displayed as character instead of hex value
> When the isprint() condition is true, there are two possibilities:
>   1) The character is ASCII character (except the first 32)
>   2) The character is extended ASCII character
> For example,
> NG property in device tree:
>     clock-frequency = <16640000>;
> by default, would be displayed as
>     clock-frequency = "", "ýè";
> and with this patch applied, would be displayed as
>     clock-frequency = <0x00fde800>;
> Full investigation was done by Nam and Hai, patch reworked by Marek
> to use common code from DTC.
> Signed-off-by: Hai Pham <hai.pham.ud at renesas.com>
> Signed-off-by: Nam Nguyen <nam.nguyen.yh at renesas.com>
> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> ---
> Cc: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Tom Rini <trini at konsulko.com>
> ---
>  cmd/fdt.c | 36 ++++++++++++++----------------------
>  1 file changed, 14 insertions(+), 22 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

More information about the U-Boot mailing list