From 17739b7ef510917471409d71fb45d8eaf6a1e1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Thu, 9 Dec 2021 07:14:20 +0100 Subject: Support 'r' format for printing raw bytes with fdtget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FT is sometimes used for storing raw data. That is quite common for U-Boot FIT images. Extracting such data is not trivial currently. Using type 's' (string) will replace every 0x00 (NUL) with 0x20 (space). Using type 'x' will print bytes but in xxd incompatible format. This commit adds support for 'r' (raw) format. Example usage: fdtget -t r firmware.itb /images/foo data > image.raw Support for encoding isn't added as there isn't any clean way of passing binary data as command line argument. Signed-off-by: Rafał Miłecki Message-Id: <20211209061420.29466-1-zajec5@gmail.com> Signed-off-by: David Gibson --- util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 40274fb..14d3868 100644 --- a/util.c +++ b/util.c @@ -353,11 +353,11 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size) } /* we should now have a type */ - if ((*fmt == '\0') || !strchr("iuxs", *fmt)) + if ((*fmt == '\0') || !strchr("iuxsr", *fmt)) return -1; /* convert qualifier (bhL) to byte size */ - if (*fmt != 's') + if (*fmt != 's' && *fmt != 'r') *size = qualifier == 'b' ? 1 : qualifier == 'h' ? 2 : qualifier == 'l' ? 4 : -1; -- cgit v1.1