From f4947e8b88059f55445c4606578d7e195de6baed Mon Sep 17 00:00:00 2001 From: Franck Jullien Date: Tue, 24 Dec 2013 10:07:14 +0100 Subject: [PATCH] target/image: allow for comments in IHEX files This is not in the Intel hex file format specification but some hex files may include comments (i.e. Altera USB-Blaster II firmware) starting with '#'. This patch makes image_ihex_buffer_complete_inner to skip comment lines. Change-Id: Id1f57d84d75da45e592f1c72b2b8c29193bc14e3 Signed-off-by: Franck Jullien Reviewed-on: http://openocd.zylin.com/1842 Tested-by: jenkins Reviewed-by: Andreas Fritiofson Reviewed-by: Spencer Oliver --- src/target/image.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/target/image.c b/src/target/image.c index f47ba2274b..8bcba34987 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -152,6 +152,9 @@ static int image_ihex_buffer_complete_inner(struct image *image, uint8_t cal_checksum = 0; size_t bytes_read = 0; + if (lpszLine[0] == '#') + continue; + if (sscanf(&lpszLine[bytes_read], ":%2" SCNx32 "%4" SCNx32 "%2" SCNx32, &count, &address, &record_type) != 3) return ERROR_IMAGE_FORMAT_ERROR; -- 2.30.2