diff --git a/jtag/README b/jtag/README index 094a5f45..6a20b4bf 100644 --- a/jtag/README +++ b/jtag/README @@ -44,6 +44,7 @@ JTAG adapters/cables (see 'help cable' command for more info): JTAG-aware parts (chips): - Altera EP1C20F400 - Altera EPM7128AETC100 +- Analog Devices Sharc-21065L - Atmel ATmega128 (partial support) - Broadcom BCM1250 - Broadcom BCM3310 (partial support) @@ -75,6 +76,7 @@ Flash chips: - Intel 28FxxxK3 (28F640K3, 28F128K3, 28F256K3) - Intel 28FxxxK18 (28F640K18, 28F128K18, 28F256K18) - AMD Am29LV64xD (Am29LV640D, Am29LV641D, Am29LV642D) +- AMD Am29xx040B (Am29F040B, Am29LV040B) Required software diff --git a/jtag/README_21065L b/jtag/README_21065L new file mode 100644 index 00000000..ec41f8bd --- /dev/null +++ b/jtag/README_21065L @@ -0,0 +1,39 @@ +$Id: README_21065L, v 1.0 20/09/2006 + +See README in JTAG source folder + +Download and install "include" package from + +Use include version 0.3.2 + +Installation instructions for "include" package +------------------------- + +1. Download and unpack include sources. +2. Run ./configure script. +3. Run `make`. +4. Run `make install`. + +Build & installation instructions for JTAG tools +--------------------------------- +1. Download and install required software (see previous section). +2. Download and unpack jtag sources. + + Use jtag version 0.5.1 +3. Apply patch to the jtag source directory. + patch -p1 < "patch filename" +4. Run ./configure script. Use optional --with-include parameter if required. + See `./configure --help` for more info. +5. Run `make`. +6. Run `make install`. + +For running JTAG tools Type 'jtag' from command prompt. + +In jtag prompt type command "setdevice sharc21065L", now the mode changes to SHARC 21065L specific. Note that this mode works only with SHARC 21065L processor. If you want to try another device, please restart the JTAG tool. + +jtag>setdevice sharc21065L +outputs +Device is set to SHARC 21065L + +Please refer README in JTAG source folder for more information regarding JTAG tools + diff --git a/jtag/THANKS b/jtag/THANKS index 44048b50..cf3093d7 100644 --- a/jtag/THANKS +++ b/jtag/THANKS @@ -32,3 +32,11 @@ Alan Wallace Zhang Wei Matan Ziv-Av Alessandro Zummo + +For Sharc - 21065L Support +Girish G Pai +Lesly A. M +Tony K Nadackal +Shaju Abraham + + diff --git a/jtag/data/Makefile.am b/jtag/data/Makefile.am index f465e4df..676ae9c0 100644 --- a/jtag/data/Makefile.am +++ b/jtag/data/Makefile.am @@ -52,6 +52,9 @@ nobase_dist_pkgdata_DATA = \ analog/PARTS \ analog/bf533/STEPPINGS \ analog/bf533/bf533 \ + analog/PARTS \ + analog/sharc21065l/STEPPINGS \ + analog/sharc21065l/sharc21065l brecis/PARTS \ brecis/msp2006/STEPPINGS \ brecis/msp2006/msp2006 \ diff --git a/jtag/data/analog/PARTS b/jtag/data/analog/PARTS index 3a60d194..8821c734 100644 --- a/jtag/data/analog/PARTS +++ b/jtag/data/analog/PARTS @@ -20,4 +20,5 @@ # # bits 27-12 of the Device Identification Register +0010011110100111 sharc21065l SHARC 0010011110100101 bf533 BF533 diff --git a/jtag/data/analog/sharc21065l/STEPPINGS b/jtag/data/analog/sharc21065l/STEPPINGS new file mode 100644 index 00000000..1ca4d48d --- /dev/null +++ b/jtag/data/analog/sharc21065l/STEPPINGS @@ -0,0 +1,32 @@ +# +# $Id: STEPPINGS v 1.0 20/09/2006 $ +# +# Copyright (C) 2006 Kila Medical Systems. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# Written by Lesly A.M , 2006 +# +# Documentation: +# [1] Analog Devices Inc.,"ADSP-21065L SHARC Technical Reference", September 1998 +# +# +# bits 31-28 of the Device Identification Register +0000 sharc21065l 0 +0001 sharc21065l 1 +0010 sharc21065l 2 +0011 sharc21065l 3 + diff --git a/jtag/data/analog/sharc21065l/sharc21065l b/jtag/data/analog/sharc21065l/sharc21065l new file mode 100644 index 00000000..e5093508 --- /dev/null +++ b/jtag/data/analog/sharc21065l/sharc21065l @@ -0,0 +1,515 @@ +# +# $Id: sharc21065l,v 1.0 20/09/2006 $ +# +# JTAG declarations for ADSP SHARC 21065L +# Copyright (C) 2006 Kila Medical Systems. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# Written by Lesly A.M , 2006 +# +# Documentation: +# [1] Analog Devices Inc.,"ADSP-21065L SHARC Technical Reference", September 1998 +# [2] Analog Devices Inc.,"BSDL Description for ADSP-21065L: MBGA Package", BSDL rev 1.1 +# http://www.analog.com/UploadedFiles/BSDL_Files/435954194035486111591903bsdl_21065l_bga.txt +# +# + + +signal ADDR0 +signal ADDR1 +signal ADDR2 +signal ADDR3 +signal ADDR4 +signal ADDR5 +signal ADDR6 +signal ADDR7 +signal ADDR8 +signal ADDR9 +signal ADDR10 +signal ADDR11 +signal ADDR12 +signal ADDR13 +signal ADDR14 +signal ADDR15 +signal ADDR16 +signal ADDR17 +signal ADDR18 +signal ADDR19 +signal ADDR20 +signal ADDR21 +signal ADDR22 +signal ADDR23 +signal DATA0 +signal DATA1 +signal DATA2 +signal DATA3 +signal DATA4 +signal DATA5 +signal DATA6 +signal DATA7 +signal DATA8 +signal DATA9 +signal DATA10 +signal DATA11 +signal DATA12 +signal DATA13 +signal DATA14 +signal DATA15 +signal DATA16 +signal DATA17 +signal DATA18 +signal DATA19 +signal DATA20 +signal DATA21 +signal DATA22 +signal DATA23 +signal DATA24 +signal DATA25 +signal DATA26 +signal DATA27 +signal DATA28 +signal DATA29 +signal DATA30 +signal DATA31 +signal MS0 +signal MS1 +signal MS2 +signal MS3 +signal RD_B +signal WR_B +signal SW_B +signal ACK +signal TS_B +signal IRQ0_B +signal IRQ1_B +signal IRQ2_B +signal FLAG0 +signal FLAG1 +signal FLAG2 +signal FLAG3 +signal FLAG4 +signal FLAG5 +signal FLAG6 +signal FLAG7 +signal FLAG8 +signal FLAG9 +signal FLAG10 +signal FLAG11 +signal HBR_B +signal HBG_B +signal CS_B +signal REDY +signal DMAR1_B +signal DMAR2_B +signal DMAG1_B +signal DMAG2_B +signal BR1 +signal BR2 +signal ID0 +signal ID1 +signal CPA_B +signal DT0A +signal DT0B +signal DR0A +signal DR0B +signal TCLK0 +signal RCLK0 +signal TFS0 +signal RFS0 +signal DT1A +signal DT1B +signal DR1A +signal DR1B +signal TCLK1 +signal RCLK1 +signal TFS1 +signal RFS1 +signal BSEL +signal BMS_B +signal CLKIN +signal RESET_B +signal TCK +signal TMS +signal TDI +signal TDO +signal TRST +signal EMU +signal BMSTR +signal SDWE_B +signal SDA10 +signal CAS_B +signal RAS_B +signal DQM +signal SDCKE +signal SDCLK0 +signal SDCLK1 +signal PWM_EVENT0 +signal PWM_EVENT1 +signal VDD0 +signal VDD1 +signal VDD2 +signal VDD3 +signal VDD4 +signal VDD5 +signal VDD6 +signal VDD7 +signal VDD8 +signal VDD9 +signal VDD10 +signal VDD11 +signal VDD12 +signal VDD13 +signal VDD14 +signal VDD15 +signal VDD16 +signal VDD17 +signal VDD18 +signal VDD19 +signal VDD20 +signal VDD21 +signal GND0 +signal GND1 +signal GND2 +signal GND3 +signal GND4 +signal GND5 +signal GND6 +signal GND7 +signal GND8 +signal GND9 +signal GND10 +signal GND11 +signal GND12 +signal GND13 +signal GND14 +signal GND15 +signal GND16 +signal GND17 +signal GND18 +signal GND19 +signal GND20 +signal GND21 +signal GND22 +signal GND23 +signal GND24 +signal GND25 +signal GND26 +signal GND27 +signal GND28 +signal GND29 +signal GND30 +signal GND31 +signal GND32 +signal GND33 + +register BSR 285 +register BR 1 +register DIR 32 + +instruction length 5 + +instruction BYPASS 11111 BR +instruction EXTEST 00000 BSR +instruction SAMPLE/PRELOAD 10000 BSR + +bit 284 O 1 EMU 278 0 Z +bit 283 I 1 ID0 +bit 282 I 1 ID1 +bit 281 O 1 * +bit 280 O 1 * +bit 279 O 1 * +bit 278 C 0 * +bit 277 C 0 * +bit 276 I 1 FLAG4 +bit 275 O 1 FLAG4 277 0 Z +bit 274 I 1 FLAG5 +bit 273 O 1 FLAG5 270 0 Z +bit 272 I 1 FLAG6 +bit 271 O 1 FLAG6 269 0 Z +bit 270 C 0 * +bit 269 C 0 * +bit 268 C 0 * +bit 267 I 1 FLAG7 +bit 266 O 1 FLAG7 268 0 Z +bit 265 I 1 DATA31 +bit 264 O 1 DATA31 243 0 Z +bit 263 I 1 DATA30 +bit 262 O 1 DATA30 243 0 Z +bit 261 I 1 DATA29 +bit 260 O 1 DATA29 243 0 Z +bit 259 I 1 DATA28 +bit 258 O 1 DATA28 243 0 Z +bit 257 I 1 DATA27 +bit 256 O 1 DATA27 243 0 Z +bit 255 I 1 DATA26 +bit 254 O 1 DATA26 243 0 Z +bit 253 I 1 DATA25 +bit 252 O 1 DATA25 243 0 Z +bit 251 I 1 DATA24 +bit 250 O 1 DATA24 243 0 Z +bit 249 I 1 DATA23 +bit 248 O 1 DATA23 243 0 Z +bit 247 I 1 DATA22 +bit 246 O 1 DATA22 243 0 Z +bit 245 I 1 DATA21 +bit 244 O 1 DATA21 243 0 Z +bit 243 C 0 * +bit 242 O 1 * +bit 241 O 1 * +bit 240 O 1 * +bit 239 I 1 DATA20 +bit 238 O 1 DATA20 243 0 Z +bit 237 I 1 DATA19 +bit 236 O 1 DATA19 243 0 Z +bit 235 I 1 DATA18 +bit 234 O 1 DATA18 243 0 Z +bit 233 I 1 DATA17 +bit 232 O 1 DATA17 243 0 Z +bit 231 I 1 DATA16 +bit 230 O 1 DATA16 243 0 Z +bit 229 I 1 DATA15 +bit 228 O 1 DATA15 243 0 Z +bit 227 I 1 DATA14 +bit 226 O 1 DATA14 243 0 Z +bit 225 O 1 * +bit 224 O 1 * +bit 223 O 1 * +bit 222 O 1 * +bit 221 O 1 * +bit 220 O 1 * +bit 219 I 1 DATA13 +bit 218 O 1 DATA13 209 0 Z +bit 217 I 1 DATA12 +bit 216 O 1 DATA12 209 0 Z +bit 215 I 1 DATA11 +bit 214 O 1 DATA11 209 0 Z +bit 213 I 1 DATA10 +bit 212 O 1 DATA10 209 0 Z +bit 211 I 1 DATA9 +bit 210 O 1 DATA9 209 0 Z +bit 209 C 0 * +bit 208 I 1 DATA8 +bit 207 O 1 DATA8 209 0 Z +bit 206 I 1 DATA7 +bit 205 O 1 DATA7 209 0 Z +bit 204 I 1 DATA6 +bit 203 O 1 DATA6 209 0 Z +bit 202 I 1 DATA5 +bit 201 O 1 DATA5 209 0 Z +bit 200 I 1 DATA4 +bit 199 O 1 DATA4 209 0 Z +bit 198 I 1 DATA3 +bit 197 O 1 DATA3 209 0 Z +bit 196 I 1 DATA2 +bit 195 O 1 DATA2 209 0 Z +bit 194 I 1 DATA1 +bit 193 O 1 DATA1 209 0 Z +bit 192 I 1 DATA0 +bit 191 O 1 DATA0 209 0 Z +bit 190 C 0 * +bit 189 I 1 FLAG8 +bit 188 O 1 FLAG8 190 0 Z +bit 187 I 1 FLAG9 +bit 186 O 1 FLAG9 183 0 Z +bit 185 I 1 FLAG10 +bit 184 O 1 FLAG10 182 0 Z +bit 183 C 0 * +bit 182 C 0 * +bit 181 C 0 * +bit 180 I 1 FLAG11 +bit 179 O 1 FLAG11 181 0 Z +bit 178 I 1 MS3 +bit 177 O 1 MS3 153 0 Z +bit 176 I 1 MS2 +bit 175 O 1 MS2 153 0 Z +bit 174 I 1 MS1 +bit 173 O 1 MS1 153 0 Z +bit 172 I 1 MS0 +bit 171 O 1 MS0 153 0 Z +bit 170 I 1 ACK +bit 169 O 1 ACK 167 0 Z +bit 168 O 1 * +bit 167 C 0 * +bit 166 I 1 CPA_B +bit 165 O 1 CPA_B 165 1 Z +bit 164 I 1 SW_B +bit 163 O 1 SW_B 153 0 Z +bit 162 O 1 REDY 161 0 Z +bit 161 C 0 * +bit 160 I 1 RD_B +bit 159 O 1 RD_B 153 0 Z +bit 158 I 1 WR_B +bit 157 O 1 WR_B 153 0 Z +bit 156 O 1 * +bit 155 I 1 TS_B +bit 154 I 1 CS_B +bit 153 C 0 * +bit 152 O 1 BMSTR +bit 151 I 1 HBG_B +bit 150 O 1 HBG_B 147 0 Z +bit 149 O 1 DMAG2_B 153 0 Z +bit 148 O 1 DMAG1_B 153 0 Z +bit 147 C 0 * +bit 146 O 1 SDA10 131 0 Z +bit 145 I 1 SDCKE +bit 144 O 1 SDCKE 131 0 Z +bit 143 O 1 DQM 131 0 Z +bit 142 I 1 SDWE_B +bit 141 O 1 SDWE_B 131 0 Z +bit 140 I 1 CAS_B +bit 139 O 1 CAS_B 131 0 Z +bit 138 I 1 RAS_B +bit 137 O 1 RAS_B 131 0 Z +bit 136 I 1 HBR_B +bit 135 I 1 DMAR2_B +bit 134 I 1 DMAR1_B +bit 133 I 1 SDCLK0 +bit 132 O 1 SDCLK0 131 0 Z +bit 131 C 0 * +bit 130 I 1 SDCLK1 +bit 129 O 1 SDCLK1 128 0 Z +bit 128 C 0 * +bit 127 I 1 CLKIN +bit 126 I 1 BR2 +bit 125 O 1 BR2 120 0 Z +bit 124 I 1 BR1 +bit 123 O 1 BR1 119 0 Z +bit 122 I 1 PWM_EVENT0 +bit 121 O 1 PWM_EVENT0 118 0 Z +bit 120 C 0 * +bit 119 C 0 * +bit 118 C 0 * +bit 117 C 0 * +bit 116 I 1 PWM_EVENT1 +bit 115 O 1 PWM_EVENT1 117 0 Z +bit 114 O 1 DT1B 112 0 Z +bit 113 O 1 DT1A 111 0 Z +bit 112 C 0 * +bit 111 C 0 * +bit 110 C 0 * +bit 109 I 1 TCLK1 +bit 108 O 1 TCLK1 110 0 Z +bit 107 I 1 TFS1 +bit 106 O 1 TFS1 101 0 Z +bit 105 I 1 DR1B +bit 104 I 1 DR1A +bit 103 I 1 RCLK1 +bit 102 O 1 RCLK1 100 0 Z +bit 101 C 0 * +bit 100 C 0 * +bit 99 C 0 * +bit 98 I 1 RFS1 +bit 97 O 1 RFS1 99 0 Z +bit 96 O 1 DT0B 94 0 Z +bit 95 O 1 DT0A 93 0 Z +bit 94 C 0 * +bit 93 C 0 * +bit 92 C 0 * +bit 91 I 1 TCLK0 +bit 90 O 1 TCLK0 92 0 Z +bit 89 I 1 TFS0 +bit 88 O 1 TFS0 83 0 Z +bit 87 I 1 DR0B +bit 86 I 1 DR0A +bit 85 I 1 RCLK0 +bit 84 O 1 RCLK0 82 0 Z +bit 83 C 0 * +bit 82 C 0 * +bit 81 C 0 * +bit 80 I 1 RFS0 +bit 79 O 1 RFS0 81 0 Z +bit 78 O 1 * +bit 77 O 1 * +bit 76 O 1 * +bit 75 I 1 IRQ2_B +bit 74 I 1 IRQ1_B +bit 73 I 1 IRQ0_B +bit 72 O 1 * +bit 71 O 1 * +bit 70 O 1 * +bit 69 O 1 * +bit 68 O 1 * +bit 67 O 1 * +bit 66 I 1 FLAG3 +bit 65 O 1 FLAG3 64 0 Z +bit 64 C 0 * +bit 63 C 0 * +bit 62 I 1 FLAG2 +bit 61 O 1 FLAG2 63 0 Z +bit 60 I 1 FLAG1 +bit 59 O 1 FLAG1 56 0 Z +bit 58 I 1 FLAG0 +bit 57 O 1 FLAG0 55 0 Z +bit 56 C 0 * +bit 55 C 0 * +bit 54 I 1 ADDR0 +bit 53 O 1 ADDR0 36 0 Z +bit 52 I 1 ADDR1 +bit 51 O 1 ADDR1 36 0 Z +bit 50 I 1 ADDR2 +bit 49 O 1 ADDR2 36 0 Z +bit 48 I 1 ADDR3 +bit 47 O 1 ADDR3 36 0 Z +bit 46 I 1 ADDR4 +bit 45 O 1 ADDR4 36 0 Z +bit 44 I 1 ADDR5 +bit 43 O 1 ADDR5 36 0 Z +bit 42 I 1 ADDR6 +bit 41 O 1 ADDR6 36 0 Z +bit 40 I 1 ADDR7 +bit 39 O 1 ADDR7 36 0 Z +bit 38 I 1 ADDR8 +bit 37 O 1 ADDR8 36 0 Z +bit 36 C 0 * +bit 35 I 1 ADDR9 +bit 34 O 1 ADDR9 36 0 Z +bit 33 I 1 ADDR10 +bit 32 O 1 ADDR10 36 0 Z +bit 31 I 1 ADDR11 +bit 30 O 1 ADDR11 36 0 Z +bit 29 I 1 ADDR12 +bit 28 O 1 ADDR12 36 0 Z +bit 27 I 1 ADDR13 +bit 26 O 1 ADDR13 36 0 Z +bit 25 I 1 ADDR14 +bit 24 O 1 ADDR14 36 0 Z +bit 23 I 1 ADDR15 +bit 22 O 1 ADDR15 36 0 Z +bit 21 I 1 ADDR16 +bit 20 O 1 ADDR16 36 0 Z +bit 19 I 1 ADDR17 +bit 18 O 1 ADDR17 36 0 Z +bit 17 I 1 ADDR18 +bit 16 O 1 ADDR18 36 0 Z +bit 15 I 1 ADDR19 +bit 14 O 1 ADDR19 36 0 Z +bit 13 I 1 ADDR20 +bit 12 O 1 ADDR20 36 0 Z +bit 11 I 1 ADDR21 +bit 10 O 1 ADDR21 36 0 Z +bit 9 I 1 ADDR22 +bit 8 O 1 ADDR22 36 0 Z +bit 7 I 1 ADDR23 +bit 6 O 1 ADDR23 36 0 Z +bit 5 I 1 RESET_B +bit 4 C 0 * +bit 3 O 1 * +bit 2 I 1 BMS_B +bit 1 O 1 BMS_B 4 0 Z +bit 0 I 1 BSEL + +initbus SHARC_21065L diff --git a/jtag/include/setdevice.h b/jtag/include/setdevice.h new file mode 100644 index 00000000..79ce8866 --- /dev/null +++ b/jtag/include/setdevice.h @@ -0,0 +1,10 @@ +#define AUTO_DETECT 0 +#define SHARC_21065L 0x327A70CB //should be the dummy device id + +typedef struct +{ + unsigned long deviceID; + unsigned long flash; + unsigned short algorithm; + unsigned short unlock_bypass; +}forced_detection_t; diff --git a/jtag/libbrux/Makefile.am b/jtag/libbrux/Makefile.am index 9c1d4bda..c5ffda0a 100644 --- a/jtag/libbrux/Makefile.am +++ b/jtag/libbrux/Makefile.am @@ -27,7 +27,8 @@ SUBDIRS = po noinst_HEADERS = \ sysdep.h \ - gettext.h + gettext.h \ + setdevice.h EXTRA_DIST = \ Makefile.rules @@ -43,6 +44,7 @@ libbrux_a_SOURCES = \ flash/jedec.c \ flash/detectflash.c \ flash/amd.c \ - flash/intel.c + flash/intel.c \ + flash/amd_flash.c ACLOCAL_AMFLAGS = -I m4 diff --git a/jtag/libbrux/flash/amd_flash.c b/jtag/libbrux/flash/amd_flash.c new file mode 100644 index 00000000..5a26a277 --- /dev/null +++ b/jtag/libbrux/flash/amd_flash.c @@ -0,0 +1,347 @@ +/* + * $Id: amd_flash.c,v 1.0 20/09/2006 12:38:01 $ + * + * AMD 8 bit flash driver for AM29F040B & AM29LV040B + * Copyright (C) 2006 Kila Medical Systems. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Ajith Kumar P.C + * + * Documentation: + * [1] Spansion, Am29F040B Data Sheet + * [2] Spansion, Am29LV040B Data Sheet +*/ + +#include "sysdep.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "setdevice.h" +//write specific +#define AMD_SECTOR_PROTECTED + +//Read Specific +#define AMD_READ_IN_ERASE_SUSPENDED_SECTOR +#define AMD_READ_IN_NON_ERASE_SUSPENDED_SECTOR +#define AMD_NORMAL_READ +#define AMD_UNKNOWN_READ + +//Mode +#define AMD_ERASE_SUSPEND_MODE +#define AMD_READING_MODE +#define AMD_EMBEDDED_ERASE_ALGORITHM +#define AMD_EMBEDDED_PROGRAM_ALGORITHM +#define AMD_UNDEFINED_MODE + +#define FLASH_ERASE_ERROR -5 +#define ERASE_FLASH_SUCCESS 1 + +#define AMD_29xx040B 1 + +#define AMD_BYPASS_UNLOCK_ALGORITHM 1 +#define AMD_STANDARD_WRITE_ALGORITHM 0 +#define AMD_BYPASS_UNLOCK_MODE 1 +#define AMD_STANDARD_MODE 0 + + +forced_detection_t var_forced_detection; + +int amd_detect(bus_t *bus, cfi_array_t **cfi_array ); +static int amd_29xx040_autodetect( cfi_array_t *cfi_array ); +static int amd_29xx040_status( bus_t *bus, uint32_t adr, unsigned short data ); +static void amd_29xx040_print_info( cfi_array_t *cfi_array ); +static void amd_29xx040_read_array( cfi_array_t *cfi_array ); +static int amd_29xx040_erase_block( cfi_array_t *cfi_array, uint32_t adr ); +static int amd_29xx040_program( cfi_array_t *cfi_array, uint32_t adr, uint32_t data ); +static int amd_29xx040_unlock_block( cfi_array_t *cfi_array, uint32_t adr ); + +int amd_detect(bus_t *bus, cfi_array_t **cfi_array ) +{ + int mid; + int did; + bus_area_t area; + cfi_query_structure_t *cfi ; + + bus_write( bus, 0x0, 0xf0 ); + bus_write( bus, 0x555, 0xaa ); + bus_write( bus, 0x2AA, 0x55 ); + bus_write( bus, 0x555, 0x90 ); + mid = bus_read( bus, 0x0); + did = bus_read( bus, 0x1); + bus_write( bus, 0x0, 0xf0 ); + + printf( "%s: mid %x, did %x\n", __FUNCTION__, mid, did ); + if (mid != 0x01) + return -1; + + switch(did) + { + case 0xA4: + var_forced_detection.flash = AMD_29xx040B; + break; + case 0x4F: + var_forced_detection.flash = AMD_29xx040B; + var_forced_detection.algorithm = AMD_BYPASS_UNLOCK_ALGORITHM; + break; + default: + break; + } + + *cfi_array = calloc( 1, sizeof (cfi_array_t) ); + if (!*cfi_array) + return -2; /* out of memory */ + + (*cfi_array)->bus = bus; + (*cfi_array)->address = 0; + if (bus_area( bus, 0, &area ) != 0) + return -8; /* bus width detection failed */ + unsigned int bw = area.width; + int ba,i; + if (bw != 8 && bw != 16 && bw != 32) + return -3; /* invalid bus width */ + (*cfi_array)->bus_width = ba = bw / 8; + (*cfi_array)->cfi_chips = calloc( ba, sizeof (cfi_chip_t *) ); + if (!(*cfi_array)->cfi_chips) + return -2; + for ( i=0; icfi_chips[i] = calloc( 1, sizeof (cfi_chip_t) ); + if (!(*cfi_array)->cfi_chips[i]) + return -2; /* out of memory */ + (*cfi_array)->cfi_chips[i]->width = 1; //ba; + cfi = &(*cfi_array)->cfi_chips[i]->cfi; + + cfi->identification_string.pri_id_code = CFI_VENDOR_NULL; + cfi->identification_string.pri_vendor_tbl = NULL; + cfi->identification_string.alt_id_code = 0; + cfi->identification_string.alt_vendor_tbl = NULL; + + cfi->device_geometry.device_size = 512*1024; + cfi->device_geometry.device_interface = 0; // x 8 + cfi->device_geometry.max_bytes_write = 32; //not used + cfi->device_geometry.number_of_erase_regions = 1; + cfi->device_geometry.erase_block_regions = + malloc( cfi->device_geometry.number_of_erase_regions * sizeof (cfi_erase_block_region_t) ); + if (!cfi->device_geometry.erase_block_regions) + return -2; /* out of memory */ + + cfi->device_geometry.erase_block_regions[i].erase_block_size = 64 * 1024; + cfi->device_geometry.erase_block_regions[i].number_of_erase_blocks = 8; + //Add other details for info + } + return 0; +} + + +static int amd_29xx040_autodetect( cfi_array_t *cfi_array ) +{ + return(var_forced_detection.flash == AMD_29xx040B); //Non-CFI Am29xx040B flash +} + +static int amd_29xx040_status( bus_t *bus, uint32_t adr, unsigned short data ) +{ + short timeout; + unsigned short dq7bit,dq7mask,dq5mask; + unsigned short data1; + + dq7mask = (1 << 7); + dq5mask = (1 << 5); + dq7bit = data & dq7mask; + + for (timeout = 0; timeout < 1000; timeout++) //typical sector erase time = 0.7 sec + { + data1 = (unsigned short)(bus_read( bus, adr ) & 0xFF); + if((data1 & dq7mask) == dq7bit) + return 1; //Success + + if((data1 & dq5mask) == dq5mask) + { + data1 = (unsigned short)(bus_read( bus, adr ) & 0xFF); + if((data1 & dq7mask) == dq7bit) + { + return 1; //Success + } + else + { + return 0; //Failure - Needs a reset command to return back to read array data + } + } + usleep (50); + } + + return 0; //hardware failure +} + + + +static void amd_29xx040_print_info( cfi_array_t *cfi_array ) +{ + int mid, did, prot; + bus_t *bus = cfi_array->bus; + + + bus_write( bus, 0x0, 0xf0 ); + bus_write( bus, 0x555, 0xaa ); + bus_write( bus, 0x2AA, 0x55 ); + bus_write( bus, 0x555, 0x90 ); + mid = bus_read( bus, 0x0); + did = bus_read( bus, 0x1); + prot = bus_read( bus, 0x2); + bus_write( bus, 0x0, 0xf0 ); + + printf( "%s: mid %x, did %x\n", __FUNCTION__, mid, did ); +// amd_29xx040_read_array( cfi_array ); /* AMD reset */ + + switch (mid) + { + case 0x01: + printf( _("Chip: AMD Flash\n\tPartNumber: ") ); + break; + default: + printf( _("Unknown manufacturer (ID 0x%04x)"), mid ); + break; + } + printf( _("\n\tChip: ") ); + switch (did) { + case 0xA4: + printf( _("Am29C040B\t-\t") ); + printf( _("5V Flash\n") ); + break; + case 0x4F: + printf( _("Am29LV040B\t-\t") ); + printf( _("3V Flash\n") ); + break; + default: + printf ( _("Unknown (ID 0x%04x)"), did ); + break; + } + printf( _("\n\tProtected: %04x\n"), prot ); +} + +static void amd_29xx040_read_array( cfi_array_t *cfi_array ) +{ + /* Read Array */ + if(var_forced_detection.unlock_bypass == AMD_BYPASS_UNLOCK_MODE) + { + bus_write( bus, 0x555, 0x90 ); + bus_write( bus, 0x2AA, 0x00 ); + usleep(100); + var_forced_detection.unlock_bypass = AMD_STANDARD_MODE; + } + bus_write( cfi_array->bus, 0x0, 0x0F0 ); /* AMD reset */ +} + + + +static int amd_29xx040_erase_block( cfi_array_t *cfi_array, uint32_t adr ) +{ + bus_t *bus = cfi_array->bus; + + printf("flash_erase_block 0x%08X\n", adr); + + /* printf("protected: %d\n", amdisprotected(ps, adr)); */ + + if(var_forced_detection.unlock_bypass == AMD_BYPASS_UNLOCK_MODE) + { + bus_write( bus, 0x555, 0x90 ); + bus_write( bus, 0x2AA, 0x00 ); + usleep(100); + var_forced_detection.unlock_bypass = AMD_STANDARD_MODE; + } + + bus_write( bus, 0x0, 0xf0 ); + bus_write( bus, 0x555, 0xaa ); + bus_write( bus, 0x2AA, 0x55 ); + bus_write( bus, 0x555, 0x80 ); + bus_write( bus, 0x555, 0xaa ); + bus_write( bus, 0x2AA, 0x55 ); +// bus_write( bus, 0x555, 0x10 ); //Chip Erase + bus_write( bus, adr, 0x30 ); //Sector erase + + + if (amd_29xx040_status( bus, adr, 0xff )) { + printf( "flash_erase_block 0x%08X DONE\n", adr ); + amd_29xx040_read_array( cfi_array ); /* AMD reset */ + return ERASE_FLASH_SUCCESS; + } + printf( "flash_erase_block 0x%08X FAILED\n", adr ); + /* Read Array */ + amd_29xx040_read_array( cfi_array ); /* AMD reset */ + + return FLASH_ERASE_ERROR; +} + +static int amd_29xx040_program( cfi_array_t *cfi_array, uint32_t adr, uint32_t data ) +{ + int status; + bus_t *bus = cfi_array->bus; + + if (0) + printf("\nflash_program 0x%08X = 0x%08X\n", adr, data); + if(var_forced_detection.algorithm == AMD_BYPASS_UNLOCK_ALGORITHM) + { + if(var_forced_detection.unlock_bypass != AMD_BYPASS_UNLOCK_MODE) + { + bus_write( bus, 0x555, 0xaa ); + bus_write( bus, 0x2AA, 0x55 ); + bus_write( bus, 0x555, 0x20 ); + usleep(1000); + var_forced_detection.unlock_bypass = AMD_BYPASS_UNLOCK_MODE; + } + } + else + { + bus_write( bus, 0x555, 0xaa ); + bus_write( bus, 0x2AA, 0x55 ); + } + + bus_write( bus, 0x555, 0xA0 ); + bus_write( bus, adr, data ); + status = amd_29xx040_status( bus, adr, data ); + /* amd_29xx040_read_array(cfi_array); */ + + return !status; +} + +static int amd_29xx040_unlock_block( cfi_array_t *cfi_array, uint32_t adr ) +{ + printf( "flash_unlock_block 0x%08X IGNORE\n", adr ); + return 0; +} + + +flash_driver_t amd_29xx040_flash_driver = { + 1, /* buswidth */ + N_("AMD Standard Command Set"), + N_("supported: AMD 29LV040B, 29C040B, 1x8 Bit"), + amd_29xx040_autodetect, + amd_29xx040_print_info, + amd_29xx040_erase_block, + amd_29xx040_unlock_block, + amd_29xx040_program, + amd_29xx040_read_array, +}; diff --git a/jtag/libbrux/flash/detectflash.c b/jtag/libbrux/flash/detectflash.c index 35b98dd7..e8276315 100644 --- a/jtag/libbrux/flash/detectflash.c +++ b/jtag/libbrux/flash/detectflash.c @@ -44,6 +44,8 @@ cfi_array_t *cfi_array = NULL; int jedec_detect( bus_t *bus, uint32_t adr, cfi_array_t **cfi_array ); +extern int amd_detect(bus_t *bus, cfi_array_t **cfi_array ); //Ajith + void detectflash( bus_t *bus, uint32_t adr ) { @@ -64,11 +66,15 @@ detectflash( bus_t *bus, uint32_t adr ) cfi_array_free( cfi_array ); cfi_array = NULL; if (jedec_detect( bus, adr, &cfi_array ) != 0) { - cfi_array->bus_width = 1; cfi_array_free( cfi_array ); - cfi_array = NULL; - printf( _("Flash not found!\n") ); - return; + if(amd_detect(bus, &cfi_array ) != 0) + { + cfi_array_free( cfi_array ); + cfi_array->bus_width = 1; + cfi_array = NULL; + printf( _("Flash not found!\n") ); + return; + } } } @@ -157,7 +163,7 @@ detectflash( bus_t *bus, uint32_t adr ) /* see 4.3.4 in [1] */ printf( _("Device geometry definition:\n") ); - printf( _("\tDevice Size: %d B (%d KiB, %d MiB)\n"), + printf( _("\tDevice Size: %d B (%d KiB, %d MiB)\n"), cfi->device_geometry.device_size, cfi->device_geometry.device_size / 1024, cfi->device_geometry.device_size / (1024 * 1024) ); diff --git a/jtag/libbrux/setdevice.h b/jtag/libbrux/setdevice.h new file mode 100644 index 00000000..79ce8866 --- /dev/null +++ b/jtag/libbrux/setdevice.h @@ -0,0 +1,10 @@ +#define AUTO_DETECT 0 +#define SHARC_21065L 0x327A70CB //should be the dummy device id + +typedef struct +{ + unsigned long deviceID; + unsigned long flash; + unsigned short algorithm; + unsigned short unlock_bypass; +}forced_detection_t; diff --git a/jtag/src/bus/Makefile.am b/jtag/src/bus/Makefile.am index d8ae0d56..0e317b3e 100644 --- a/jtag/src/bus/Makefile.am +++ b/jtag/src/bus/Makefile.am @@ -48,5 +48,6 @@ libbus_a_SOURCES = \ h7202.c \ slsup3.c \ tx4925.c \ - jopcyc.c + jopcyc.c \ + sharc21065l.c diff --git a/jtag/src/bus/buses.c b/jtag/src/bus/buses.c index 1b1247f7..6cdbb082 100644 --- a/jtag/src/bus/buses.c +++ b/jtag/src/bus/buses.c @@ -52,6 +52,7 @@ const bus_driver_t *bus_drivers[] = { &slsup3_bus, &tx4925_bus, &jopcyc_bus, + &sharc_21065L_bus, NULL /* last must be NULL */ }; diff --git a/jtag/src/bus/buses.h b/jtag/src/bus/buses.h index c8095346..03447677 100644 --- a/jtag/src/bus/buses.h +++ b/jtag/src/bus/buses.h @@ -47,5 +47,6 @@ extern const bus_driver_t h7202_bus; extern const bus_driver_t slsup3_bus; extern const bus_driver_t tx4925_bus; extern const bus_driver_t jopcyc_bus; +extern const bus_driver_t sharc_21065L_bus; #endif /* BUSES_H */ diff --git a/jtag/src/bus/sharc21065l.c b/jtag/src/bus/sharc21065l.c new file mode 100644 index 00000000..ca388166 --- /dev/null +++ b/jtag/src/bus/sharc21065l.c @@ -0,0 +1,346 @@ +/* + * $Id: sharc21065l.c,v 1.0 20/09/2006 12:38:01 $ + * + * Analog Device's SHARC 21065L compatible bus driver via BSR + * Copyright (C) 2006 Kila Medical Systems. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Ajith Kumar P.C + * + * Documentation: + * [1] Analog Devices Inc.,"ADSP-21065L SHARC Technical Reference", September 1998 + * [2] Analog Devices Inc.,"ADSP-21065L SHARC User's Manual", September 1998 + * + */ + +#include "sysdep.h" + +#include +#include +#include + +#include "part.h" +#include "bus.h" +#include "bssignal.h" +#include "jtag.h" +#include "buses.h" + +//no SDRAM access + +typedef struct +{ + chain_t *chain; + part_t *part; + uint32_t last_adr; + signal_t *ma[19]; //19 - 512K flash address are used + signal_t *md[8]; //8 bit data bus connected to Flash are used + signal_t *bms; //boot memory select + signal_t *nwe; + signal_t *noe; +} bus_params_t; + + +#define CHAIN ((bus_params_t *) bus->params)->chain +#define PART ((bus_params_t *) bus->params)->part +#define LAST_ADR ((bus_params_t *) bus->params)->last_adr +#define MA ((bus_params_t *) bus->params)->ma +#define MD ((bus_params_t *) bus->params)->md +#define BMS ((bus_params_t *) bus->params)->bms +#define nWE ((bus_params_t *) bus->params)->nwe +#define nOE ((bus_params_t *) bus->params)->noe + + + + +static void setup_address( bus_t *bus, uint32_t a ) +{ + int i; + part_t *p = PART; + + for (i = 0; i < 19; i++) + part_set_signal( p, MA[i], 1, (a >> i) & 1 ); +} + +static int sharc_21065L_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); + + +static void set_data_in( bus_t *bus, uint32_t adr ) +{ + int i; + part_t *p = PART; + bus_area_t area; + + sharc_21065L_bus_area( bus, adr, &area ); + + for (i = 0; i < area.width; i++) + part_set_signal( p, MD[i], 0, 0 ); +} + + +static void setup_data( bus_t *bus, uint32_t adr, uint32_t d ) +{ + int i; + part_t *p = PART; + bus_area_t area; + + sharc_21065L_bus_area( bus, adr, &area ); + + for (i = 0; i < area.width; i++) + part_set_signal( p, MD[i], 1, (d >> i) & 1 ); +} + + +static void sharc_21065L_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Analog Device's SHARC 21065L compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +static void sharc_21065L_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + + +static void sharc_21065L_bus_read_start( bus_t *bus, uint32_t adr ) +{ + chain_t *chain = CHAIN; + part_t *p = PART; + + LAST_ADR = adr; + if (adr >= 0x080000) + return; + + + part_set_signal( p, BMS, 1, 0 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 0 ); + + setup_address( bus, adr ); + set_data_in( bus, adr ); + + chain_shift_data_registers( chain, 0 ); +} + + +static uint32_t sharc_21065L_bus_read_next( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + uint32_t d; + //uint32_t old_last_adr = LAST_ADR; + + LAST_ADR = adr; + + if (adr < UINT32_C(0x080000)) { + int i; + bus_area_t area; + + sharc_21065L_bus_area( bus, adr, &area ); + + + setup_address( bus, adr ); + chain_shift_data_registers( chain, 1 ); + + d = 0; + for (i = 0; i < area.width; i++) + d |= (uint32_t) (part_get_signal( p, MD[i] ) << i); + + return d; + } + return 0; +} + + +static uint32_t sharc_21065L_bus_read_end( bus_t *bus ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + if (LAST_ADR < UINT32_C(0x080000)) { + int i; + uint32_t d = 0; + bus_area_t area; + + sharc_21065L_bus_area( bus, LAST_ADR, &area ); + + + part_set_signal( p, BMS, 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + + chain_shift_data_registers( chain, 1 ); + + for (i = 0; i < area.width; i++) + d |= (uint32_t) (part_get_signal( p, MD[i] ) << i); + + return d; + } + + return 0; +} + +static uint32_t sharc_21065L_bus_read( bus_t *bus, uint32_t adr ) +{ + sharc_21065L_bus_read_start( bus, adr ); + return sharc_21065L_bus_read_end( bus ); +} + + + +static void sharc_21065L_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + if (adr >= 0x080000) + return; + + + part_set_signal( p, BMS, 1, 0 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + + setup_address( bus, adr ); + setup_data( bus, adr, data ); + + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, nWE, 1, 0 ); + chain_shift_data_registers( chain, 0 ); + part_set_signal( p, nWE, 1, 1 ); + chain_shift_data_registers( chain, 0 ); +} + + +static int sharc_21065L_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + /* BMS (512 KB) */ + if (adr < UINT32_C(0x080000)) { + area->description = N_("Boot Memory Select"); + area->start = UINT32_C(0x000000); + area->length = UINT64_C(0x080000); + area->width = 8; + + return 0; + } + + area->description = NULL; + area->start = UINT32_C(0xffffffff); + area->length = UINT64_C(0x080000); + area->width = 0; + return 0; +} + + +static void sharc_21065L_bus_free( bus_t *bus ) +{ + free( bus->params ); + free( bus ); +} + +static bus_t *sharc_21065L_bus_new( void ); + +const bus_driver_t sharc_21065L_bus = { + "SHARC_21065L", + N_("SHARC_21065L compatible bus driver via BSR"), + sharc_21065L_bus_new, + sharc_21065L_bus_free, + sharc_21065L_bus_printinfo, + sharc_21065L_bus_prepare, + sharc_21065L_bus_area, + sharc_21065L_bus_read_start, + sharc_21065L_bus_read_next, + sharc_21065L_bus_read_end, + sharc_21065L_bus_read, + sharc_21065L_bus_write +}; + + +static bus_t *sharc_21065L_bus_new( void ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = malloc( sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &sharc_21065L_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 19; i++) { + sprintf( buff, "ADDR%d", i ); + MA[i] = part_find_signal( PART, buff ); + if (!MA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 8; i++) { + sprintf( buff, "DATA%d", i ); + MD[i] = part_find_signal( PART, buff ); + if (!MD[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + BMS = part_find_signal( PART, "BMS_B" ); + if (!BMS) { + printf( _("signal '%s' not found\n"), "BMS_B" ); + failed = 1; + } + nWE = part_find_signal( PART, "WR_B" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "WR_B" ); + failed = 1; + } + nOE = part_find_signal( PART, "RD_B" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "RD_B" ); + failed = 1; + } + + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} diff --git a/jtag/src/cmd/Makefile.am b/jtag/src/cmd/Makefile.am index cc9996d7..5150d5e9 100644 --- a/jtag/src/cmd/Makefile.am +++ b/jtag/src/cmd/Makefile.am @@ -56,6 +56,7 @@ libcmd_a_SOURCES = \ script.c \ include.c \ cmd.c \ + setdevice.c \ svf.c INCLUDES = -DJTAG_DATA_DIR=\"$(pkgdatadir)\" diff --git a/jtag/src/cmd/cmd.c b/jtag/src/cmd/cmd.c index 83b6a907..83105a5a 100644 --- a/jtag/src/cmd/cmd.c +++ b/jtag/src/cmd/cmd.c @@ -65,6 +65,7 @@ extern cmd_t cmd_script; extern cmd_t cmd_include; extern cmd_t cmd_svf; extern cmd_t cmd_debug; +extern cmd_t cmd_setdevice; const cmd_t *cmds[] = { &cmd_quit, @@ -101,6 +102,7 @@ const cmd_t *cmds[] = { &cmd_include, &cmd_svf, &cmd_debug, + &cmd_setdevice, NULL /* last must be NULL */ }; diff --git a/jtag/src/cmd/setdevice.c b/jtag/src/cmd/setdevice.c new file mode 100644 index 00000000..ab63de1f --- /dev/null +++ b/jtag/src/cmd/setdevice.c @@ -0,0 +1,104 @@ +/* + * $Id: setdevice.c,v 1.0 20/09/2006 12:38:01 $ + * + * Copyright (C) 2006 Kila Medical Systems. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Ajith Kumar P.C + * +*/ + + +#include "sysdep.h" +#include +#include +#include "jtag.h" +#include "cmd.h" +#include "bus.h" +#include "setdevice.h" + +extern chain_t *chain; +extern forced_detection_t var_forced_detection; + +static int cmd_setdevice_run( char *params[] ) +{ + if(cmd_params(params) != 2) + return -1; + if (strcmp( params[1], "sharc21065L" ) == 0) + { +#if 0 + buses_free(); + parts_free( chain->parts ); + chain->parts = NULL; +#endif + var_forced_detection.deviceID = SHARC_21065L; + printf( _("Device is set to SHARC 21065L\n") ); + } +#if 0 + else + { + buses_free(); + parts_free( chain->parts ); + chain->parts = NULL; + var_forced_detection.deviceID = AUTO_DETECT; + printf( _("Automatic Device selection\n") ); + } +#endif + +#if 1 + else + { + + if(var_forced_detection.deviceID == SHARC_21065L) + { + printf( _("Support is only for SHARC 21065L\n") ); + printf( _("If you want to try another device:\n") ); + printf( _("\tPlease restart the JTAG tool\n\n") ); + } + else + { + var_forced_detection.deviceID = AUTO_DETECT; + //printf( _("Supports devices which posses device ID\n") ); + printf( _("If you want to try SHARC 21065L, type command:\n") ); + printf( _("\tsetdevice sharc21065L \n\n") ); + } + } +#endif + return 1; +} + +static void cmd_setdevice_help( void ) +{ + printf( _("Provision for supporting devices which do not have device ID\n" + "Usage: %s sharc21065L\n" + "\t For setting to SHARC Processor\n" +#if 0 + "Or %s auto\n" + "\t For auto selection of the device\n" + "Default is Auto Selection\n" +#endif + ),"setdevice" ); +} + +cmd_t cmd_setdevice = { + "setdevice", + N_("Provision for supporting devices which do not have device ID\n"), + cmd_setdevice_help, + cmd_setdevice_run +}; + + diff --git a/jtag/src/detect.c b/jtag/src/detect.c index e57506e1..8bd66dd1 100644 --- a/jtag/src/detect.c +++ b/jtag/src/detect.c @@ -19,6 +19,7 @@ * 02111-1307, USA. * * Written by Marcel Telka , 2002. + * Modified by Ajith Kumar P.C , 20/09/2006. * */ @@ -39,6 +40,9 @@ #include "jtag.h" +#include "setdevice.h" +extern forced_detection_t var_forced_detection; + struct id_record { char name[20]; char fullname[100]; @@ -261,6 +265,29 @@ detect_parts( chain_t *chain, char *db_path ) } printf( _("Device Id: %s (0x%016lX)\n"), register_get_string( did ), bits_to_uint64(did) ); + + if (var_forced_detection.deviceID != AUTO_DETECT) + { + const char *tmp_id_data; + did = id; + + switch(var_forced_detection.deviceID) + { + case SHARC_21065L: + printf("\n\n\tAttention !!!!: This mode supports only SHARC 21065L\n\n"); + break; + default: + break; + } + tmp_id_data = register_get_string( did ); + for( i=0; i<32; i++) + { + did->data[i] = ((var_forced_detection.deviceID >> i) & 1) ? 1 : 0; + } + tmp_id_data = register_get_string( did ); + printf(" Dummy device ID : %s\n ",tmp_id_data); + } + part = part_alloc( did ); if (part == NULL) { printf( _("Out of memory\n") ); diff --git a/jtag/src/flash.c b/jtag/src/flash.c index 61b40ad8..b7761406 100644 --- a/jtag/src/flash.c +++ b/jtag/src/flash.c @@ -19,6 +19,7 @@ * 02111-1307, USA. * * Written by Marcel Telka , 2002. + * Modified by Ajith Kumar P.C , 20/09/2006 * * Documentation: * [1] Advanced Micro Devices, "Common Flash Memory Interface Specification Release 2.0", @@ -52,6 +53,7 @@ extern flash_driver_t amd_8_flash_driver; extern flash_driver_t intel_32_flash_driver; extern flash_driver_t intel_16_flash_driver; extern flash_driver_t intel_8_flash_driver; +extern flash_driver_t amd_29xx040_flash_driver; //20/09/2006 flash_driver_t *flash_drivers[] = { &amd_32_flash_driver, @@ -60,11 +62,14 @@ flash_driver_t *flash_drivers[] = { &intel_32_flash_driver, &intel_16_flash_driver, &intel_8_flash_driver, + &amd_29xx040_flash_driver, //20/09/2006 NULL }; flash_driver_t *flash_driver = NULL; +extern int amd_detect(bus_t *bus, cfi_array_t **cfi_array ); //Ajit + static void set_flash_driver( cfi_array_t *cfi_array ) { @@ -95,10 +100,15 @@ flashcheck( bus_t *bus, cfi_array_t **cfi_array ) printf( _("Note: Supported configuration is 2 x 16 bit or 1 x 8/16 bit only\n") ); *cfi_array = NULL; + if (cfi_detect( bus, 0, cfi_array )) { cfi_array_free( *cfi_array ); - printf( _("Flash not found!\n") ); - return; + if(amd_detect(bus, cfi_array ) != 0) + { + cfi_array_free( *cfi_array ); + printf( _("Flash not found!\n") ); + return; + } } set_flash_driver( *cfi_array ); diff --git a/jtag/src/jtag.c b/jtag/src/jtag.c index 82c16b1b..e93a55e8 100644 --- a/jtag/src/jtag.c +++ b/jtag/src/jtag.c @@ -19,6 +19,7 @@ * 02111-1307, USA. * * Written by Marcel Telka , 2002, 2003. + * Modified by Ajith Kumar P.C , 20/09/2006. * */ @@ -371,6 +372,23 @@ main( int argc, const char **argv ) go = jtag_parse_rc(); if (go) { + /* ajk: always run "setdevice auto" command */ + char **s; + s = malloc(25*sizeof(char)); + if (!s) + { + free( s ); + printf( _("Out of memory\n") ); + } + else + { + s[0] = "setdevice"; + s[1] = "auto"; + s[2] = NULL; + cmd_run(s); + free(s); + } + /* Load history */ jtag_load_history();