Build error for svn 177

Hi Dominic,

How’s it going? Haven’t visited the forums in a while.

I’m planning on getting a Intel Mac this weekend, that way I don’t

have to pester you about endianess questions anymore :wink:

I’m trying to build your latest svn but i’m getting this error for xscale.c:

xscale.c: In function 'xscale_deassert_reset':
xscale.c:1631: error: subscripted value is neither array nor pointer
...[same error repeated 4 times]

Seems like the compiler is having fits with the &buffer in the le_to_h_u32() macro.
If I tweak the file so that I don’t get the error, this next one pops up:
* *image.c: In function image_elf_read_headers image.c:332: error: subscripted value is neither array nor pointer image.c:332: error: subscripted value is neither array nor pointer image.c:355: error: subscripted value is neither array nor pointer image.c:355: error: subscripted value is neither array nor pointer image.c:355: error: subscripted value is neither array nor pointer image.c:355: error: subscripted value is neither array nor pointer image.c:361: error: subscripted value is neither array nor pointer image.c:361: error: subscripted value is neither array nor pointer image.c:361: error: subscripted value is neither array nor pointer image.c:361: error: subscripted value is neither array nor pointer image.c:363: error: subscripted value is neither array nor pointer image.c:363: error: subscripted value is neither array nor pointer image.c:363: error: subscripted value is neither array nor pointer image.c:363: error: subscripted value is neither array nor pointer image.c:364: error: subscripted value is neither array nor pointer image.c:364: error: subscripted value is neither array nor pointer image.c:364: error: subscripted value is neither array nor pointer image.c:364: error: subscripted value is neither array nor pointer image.c:366: error: subscripted value is neither array nor pointer image.c:366: error: subscripted value is neither array nor pointer image.c:366: error: subscripted value is neither array nor pointer image.c:366: error: subscripted value is neither array nor pointer image.c:372: error: subscripted value is neither array nor pointer image.c:372: error: subscripted value is neither array nor pointer image.c:372: error: subscripted value is neither array nor pointer image.c:372: error: subscripted value is neither array nor pointer image.c: In function 'image_elf_read_section': image.c:389: error: subscripted value is neither array nor pointer image.c:389: error: subscripted value is neither array nor pointer image.c:389: error: subscripted value is neither array nor pointer image.c:389: error: subscripted value is neither array nor pointer image.c:392: error: subscripted value is neither array nor pointer image.c:392: error: subscripted value is neither array nor pointer image.c:392: error: subscripted value is neither array nor pointer image.c:392: error: subscripted value is neither array nor pointer image.c:392: error: subscripted value is neither array nor pointer image.c:392: error: subscripted value is neither array nor pointer image.c:392: error: subscripted value is neither array nor pointer image.c:392: error: subscripted value is neither array nor pointer image.c:393: error: subscripted value is neither array nor pointer image.c:393: error: subscripted value is neither array nor pointer image.c:393: error: subscripted value is neither array nor pointer image.c:393: error: subscripted value is neither array nor pointer image.c:396: error: subscripted value is neither array nor pointer image.c:396: error: subscripted value is neither array nor pointer image.c:396: error: subscripted value is neither array nor pointer image.c:396: error: subscripted value is neither array nor pointer image.c:415: error: subscripted value is neither array nor pointer image.c:415: error: subscripted value is neither array nor pointer image.c:415: error: subscripted value is neither array nor pointer image.c:415: error: subscripted value is neither array nor pointer image.c:418: error: subscripted value is neither array nor pointer image.c:418: error: subscripted value is neither array nor pointer image.c:418: error: subscripted value is neither array nor pointer image.c:418: error: subscripted value is neither array nor pointer image.c:418: error: subscripted value is neither array nor pointer image.c:418: error: subscripted value is neither array nor pointer image.c:418: error: subscripted value is neither array nor pointer image.c:418: error: subscripted value is neither array nor pointer make[3]: *** [image.o] Error 1* *
for this one, it seems to similar to that as the xscale.c one.
I’m using gcc-4.0.1 under MacOS X 10.4.10.
luis…

I haven’t been using openocd lately, but I gave it a try on my macppc, the problem is just that the macro isn’t protecting its arguments … here’s a patch that will make it compile correctly (dunno about running correctly :smiley: ) just add parentheses on those two lines:

Index: src/helper/types.h
===================================================================
--- src/helper/types.h	(revision 177)
+++ src/helper/types.h	(working copy)
@@ -40,8 +40,8 @@
 
 #ifdef WORDS_BIGENDIAN /* big endian host */
 
-#define le_to_h_u32(x) (u32)(x[0] | x[1] << 8 | x[2] << 16 | x[3] << 24)
-#define le_to_h_u16(x) (u16)(x[0] | x[1] << 8)
+#define le_to_h_u32(x) (u32)((x)[0] | (x)[1] << 8 | (x)[2] << 16 | (x)[3] << 24)
+#define le_to_h_u16(x) (u16)((x)[0] | (x)[1] << 8)
 #define be_to_h_u32(x) (*(u32*)(x))
 #define be_to_h_u16(x) (*(u16*)(x))

wiml,

Ahhh…thats all that it took to get it built! :smiley:

I didn’t know about that macro nitty-gitty stuff, but now i do!

Thanks for the fix!

luis…

(I’ve uploaded a more complete patch to berlios’ patch tracker: [patch 2080)](https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2080&group_id=4148)

Hi,

thanks for finding and fixing this bug. I’ve applied the patch to my local tree and I’m going to push it into SVN with my next set of changes.

Best regards,

Dominic

Luis,

I would like to compile OpenOCD for Mac OS X (Intel 10.4.10) and do so for the FTDI drivers. What are the steps that you performed to get the OpenOCD code to compile? My steps are shown below and I’m stuck at a compiler error where the ftd2xx.h file references macros like DWORD but the source doesn’t know what that is.

Thanks,

Darrik

1) Get latest from svn://svn.berlios.de/openocd/trunk

2) autoconf
	* Get errors:
configure.in:159: error: possibly undefined macro: AM_CONFIG_HEADER
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.in:160: error: possibly undefined macro: AM_INIT_AUTOMAKE
configure.in:162: error: possibly undefined macro: AM_CONDITIONAL

	* Do aclocal first and THEN autoconf

3) aclocal

4) autoconf

5) ./configure --enable-ft2232-ftd2xx --prefix=/usr/bin
	* Got error:
	configure: error: cannot find install-sh or install.sh

	* Do automake -a and try again
6) automake -a

7) ./configure --enable-ft2232-ftd2xx --prefix=/usr/bin
	* Got error:
config.status: error: cannot find input file: config.h.in

	* Try using autoheader and try again???

8) autoheader

9) ./configure --enable-ft2232-ftd2xx --prefix=/usr/bin

10) make
	* Got lots of errors, probably all related to this:
ft2232.c:45:20: error: ftd2xx.h: No such file or directory

	* Probably need to also use --with-ftd2xx=/path/to/d2xx/
	* Copy D2XX to ~/Code

11) ./configure --prefix=/usr/bin --enable-ft2232-ftd2xx --with-ftd2xx=/path/to/D2XX/bin
	* Now it doesn't know what DWORD is in ftd2xx.h!

Darrik,

These were the step that I do to build openocd

  1. Install the ftdi library in /usr/local/lib (I personal put it in /usr/lib), and

copy both ftd2xx.h AND WinTypes.h in /usr/local/include

  1. bootstrap

  2. ./configure --prefix=/usr/local --enable-ft2232_ftd2xx --with-ftd2xx=/usr/local/include/

  3. make

The make should fail in that it could not find the ftd2xx library.

  1. I then went in by hand and modified the ~/src/Makefile:

@line 102 add

FTD2XXLDADD = /usr/local/lib/libftd2xx.0.1.0.dylib

then from the top level of the source, just ‘make’.

As for the prefix, I have MacPorts installed, and those files live under the /opt directory, so I also put the binary and include files under the /opt/local tree.

cheers!

luis…

Luis and Dominic,

I have a basic list of steps to compile OpenOCD for use with the FTDI chipset on Mac OS X. Hopefully this is useful to someone.

Darrik


The Official Mac OS X Build Steps



  • FTDI D2XX Dynamic Library *

  1. Get latest FTDI Mac OS X D2XX dynamic library from:

http://www.ftdichip.com/Drivers/D2XX.htm

  1. Copy D2XX/Samples/ftd2xx.h and D2XX/Samples/WinTypes.h to /usr/local/include

  2. This step may or may not be needed, but here it is anyway. Modify the D2XX/bin/ftd2xx.cfg file’s VID (VID_0403) and PID (PID_6001) as needed for the FTDI JTAG device as needed. If you have the device connected, you can use USB Prober (part of Apple’s developer software installation) to find the VID and PID. For example, the Amontec JTAGkey needs the following:

[VID_0403&PID_CFF8]

  1. Copy the D2XX/bin dynamic library and D2XX/bin/ftd2xx.cfg file to /usr/local/lib (in this example the dynamic library is libftd2xx.0.1.0.dylib)

  2. Create a symbolic link to the dynamic library:

ln -sf libftd2xx.0.1.0.dylib libftd2xx.dylib


  • OpenOCD *

  1. Get latest OpenOCD source from svn:

//svn.berlios.de/openocd/trunk

  1. Using Terminal.app, change the the root of the OpenOCD source code

  2. aclocal

  3. autoconf

  4. autoheader

  5. automake -a

  6. ./configure --prefix=/usr --enable-ft2232-ftd2xx --with-ftd2xx=/usr/local/include

  7. In ./src/Makefile, change FTD2XXLDADD (about line 102) to point to the FTDI dynamic library:

FTD2XXLDADD = /usr/local/lib/libftd2xx.dylib

  1. From the root of the OpenOCD source, now make the project:

make

  1. Install the binary:

sudo make install

I did a fresh install of the D2XX dynamic library and OpenOCD on a different machine and I found that the D2XX ftd2xx.cfg file is not necessary for the Amontec JTAGkey. The correct PID info wasn’t need in my Eclipse debug environment which uses Jim Lynch’s Atmel tutorial files to obtain the JTAG device.

Darrik