From 566c79e209524b2aa2a5d1ea4cfc5690267b3cd6 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Fri, 29 Nov 2002 08:28:34 +0000 Subject: [PATCH] 2002-11-29 Marcel Telka * src/flash.c (flashmsbin, flashmem): Fixed crash if flash memory is not detected. * src/readmem.c (detectflash): Ditto. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@285 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 5 +++++ jtag/NEWS | 1 + jtag/src/flash.c | 9 +++++++++ jtag/src/readmem.c | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 63bdd5a8..5e4d07c8 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,8 @@ +2002-11-29 Marcel Telka + + * src/flash.c (flashmsbin, flashmem): Fixed crash if flash memory is not detected. + * src/readmem.c (detectflash): Ditto. + 2002-11-27 Marcel Telka * data/xilinx/xcr3128xl-cs144/xcr3128xl-cs144: Added pins and BSR bits. diff --git a/jtag/NEWS b/jtag/NEWS index 6ba52997..ff2f3d6c 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -1,6 +1,7 @@ Changes since 0.1: * Completed JTAG declarations for Xilinx XCR3128XL-CS144. + * Fixed crash if flash memory is not detected. jtag-0.1 (2002-11-25): diff --git a/jtag/src/flash.c b/jtag/src/flash.c index 02be40bf..25772c6d 100644 --- a/jtag/src/flash.c +++ b/jtag/src/flash.c @@ -77,6 +77,10 @@ flashmsbin( parts *ps, FILE *f ) parts_shift_instructions( ps ); cfi = detect_cfi( ps ); + if (!cfi) { + printf( "Flash not found!\n" ); + return; + } /* test sync bytes */ { @@ -213,6 +217,11 @@ flashmem( parts *ps, FILE *f, uint32_t addr ) parts_shift_instructions( ps ); cfi = detect_cfi( ps ); + if (!cfi) { + printf( "Flash not found!\n" ); + return; + } + erased = malloc( cfi->device_geometry.erase_block_regions[0].number_of_erase_blocks * sizeof *erased ); if (!erased) { printf( "Out of memory!\n" ); diff --git a/jtag/src/readmem.c b/jtag/src/readmem.c index 1d466401..e06f9a18 100644 --- a/jtag/src/readmem.c +++ b/jtag/src/readmem.c @@ -74,6 +74,10 @@ detectflash( parts *ps ) parts_shift_instructions( ps ); cfi = detect_cfi( ps ); + if (!cfi) { + printf( "Flash not found!\n" ); + return; + } /* detect CFI capable devices */ /* TODO: Low chip only */