racecannon:
The cable works fine programming the mega, as long as I don't use the YUN shield.
I think this is how you will have to use it when uploading sketches - remove the Yun Shield.
Disclaimer: I do not have any experience with the Yun Shield or the Arduino Mega, let alone using them together. My comments are based on analyzing the Yun Shield User Manual and the Arduino Mega Schematic.
Looking at the schematic, you can see the USB interface on the right side of the sheet: IC4. The serial I/O from this chip (M8RXD and M8TXD) pass through a couple resistors (RN4A and RN4B) and connect to the PE0 and PE1 signals. These are the same signals are are connected to the shield digital pins 0 and 1.
The Yun Shield also uses pins 0 and 1 for Bridge communications. Page 7 of the Yun Shield user manual states that it's important to make sure these serial pins are not used by any other hardware. Page 14 shows how to connect to a Mega, and indicates that it is necessary to add a jumper to hold the USB interface in reset. This allows the pins to be used by the Yun Shield.
You indicated that you have added that jumper, and that the Yun can talk to the Mega in this state. But now you want to upload sketches to the Mega, and that requires use of the USB interface.
Obviously, with the USB interface held in reset, you will not be able to connect to the Mega using the USB interface. It simply won't be detected by your computer, and there will be no serial port created for it.
So, it would seem that the solution is to remove the jumper that is holding the USB interface in reset. This will allow the USB interface to be detected by the computer, and the IDE will attempt to download a sketch. However, just as the USB interface can interfere with the Yun Shield's communications with the Mega, the Yun Shield can interfere with the USB interface's communications with the Mega.
It seems to me that to be able to upload a sketch to the Mega using the USB port (or to use the Serial object to communicate over the USB port) it will be necessary to remove the Yun Shield to free up the communications lines.
As an alternative to always removing and reinstalling the Yun Shield, it may be possible to:
- Hold the Yun Shield's reset button in the whole time that the IDE is trying to access the Mega and upload a sketch.
- Control GPIO24 on the Linux side to disable the serial communications level shifter on the Yun Shield (U11 on page 3 of the Yun Shield schematic.)
- Upload the sketch over the network instead of USB (if the Yun Shield supports this feature when connected to a Mega.)