SOLVED - LOOK UNDER "EDIT 3" SUBTITLE.
Board with LPC4337(left) and board with ATSAM3X8E(right), JTAG interconnected, using FT2232H chip soldered on the board of the left as an interface.
The first one (LPC4337) can be programmed. The second one (ATSAM3X8E) can be programmed too as long as traces between the programming chip (FT2232H) and the LPC4337 MCU are cut. If no traces are cut (both LPC4337 and ATSAM3X8E connected to the JTAG) then I can't access the ATSAM3X8E chip. I'm using OpenOCD. This is OpenOCD output when both chips are connected to the JTAG:
...
Info: JTAG tap: lpc4337.m4 tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part:0xba00, ver: 0x4)
Info: JTAG tap: lpc4337.m0 tap/device found: 0x0ba01477 (mfg: 0x23b (ARM Ltd.), part:0xba01, ver: 0x0)
Info: JTAG tap: sam3.m3 tap/device found: 0xfffffff (mfg: 0x7ff (), part:0xffff, ver: 0xf)
Error: sam3.m3: IR capture error; saw 0x0f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: Invalid ACK (4) in DAP response
Error: Invalid ACK (4) in DAP response
Error: Invalid ACK (4) in ... (many more)
Error: Invalid ACK (0) in DAP response
Error: Could not initialize the debug port
Some notes: If I change OpenOCD config to ignore the "IR capture error", the connection fails anyways, the first problem is the sam3.m3 TAP ID being detected as 0xfffffff etc.
Same output with LPC4337 JTAG traces cut (only ATSAM3X8E connected):
...
Info: JTAG tap: sam3.m3 tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part:0xba00, ver: 0x4)
Info: sam3.m3: hardware has 6 breakpoints, 4 watchpoints
Some notes: This is a successful connection.
An interesting thing is that both LPC4337 and ATSAM3X8E share the same JTAG TAP ID. Isn't this value chosen by the manufacturer? Is having different chips with the same JTAG ID a strange coincidence? May this be the problem preventing me from connecting both of them to the JTAG? I've seen repeated JTAG IDs being handled by OpenOCD before, but always with different instances of the same chip, not from different chip families like in this case. Is there a way to change chips JTAG ID? What other problems could be causing this behaviour? I'm interested to hear any kind suggestions, even if they turn not to be the solution they might help.
Some other notes: I've tried with two different ATSAM3X8E boards so I know the chips aren't faulty. Both boards were Arduino Due and worked when LPC4337 JTAG traces were cut. I'm running OpenOCD version 0.10.0 ("Freddie Chopin" compiled version) on Windows. I haven't got an oscilloscope. I would like to work with both MCUs without adding more modifications or cutting traces. I would also like to understand the fault that's preventing me to program these chips in case I design something in the future using them.
Lastly, I would like to thank the community for their time, I hope this post helps some other people in the future!
EDIT:
These are the JTAG interface schematics of both boards that were connected together. The flat cable is connecting Pin1 of "P3" connector on LPC4337 board schematic with Pin1 of "JTAG" connector of ATSAM3X8E board schematic, etc. (All 10 pins connected accordingly, tested with continuity with a multi-meter). This is LPC4337 board schematic.
This is ATSAM3X8E board schematic.
EDIT 2:
Thanks to the answers I found out I was using a star JTAG topology but a daisy chain JTAG topology would be the standard approach. I will change my wiring and post my results. Thanks for the help. This will be my wiring topology (but with two devices):
EDIT 3:
JTAG was changed from a star topology to a daisy chain topology. LPC4337 TDO is routed to the connector and eventually to ATSAM3X8E TDI. ATSAM3X8E TDO connects via the connector to the FT2232H interface. When no device is connected and only the LPC4337 is being programmed, a little male connector (pictured below) can be plugged (instead of the cable) and bridges LPC4337 TDO directly to the FT2232H interface. OpenOCD connection succeeds and outputs the following:
...
Info: JTAG tap: lpc4337.m4 tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part:0xba00, ver: 0x4)
Info: JTAG tap: lpc4337.m0 tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part:0xba00, ver: 0x4)
Info: JTAG tap: sam3.m3 tap/device found: 0x4ba01477 (mfg: 0x23b (ARM Ltd.), part:0xba00, ver: 0x4)
Info: lpc4337.m4: hardware has 6 breakpoints, 4 watchpoints
Info: lpc4337.m0: hardware has 6 breakpoints, 4 watchpoints
Info: sam3.m3: hardware has 6 breakpoints, 4 watchpoints
(the 0x4ba01477 TAP ID turned to be the ATSAM3X8E, I wonder if OpenOCD could be arranged in a different order [atsam, lpc m0, lpc m4] and work in a star topology or not)
Thank you all for your help!