Communication between MCU and linux

Hi,

I know from the documentation about Serial1 which is reserved for Bridge (MCU -- linux), also I found pins 0 and 1 are for Serial1.

But I think that sketch uploading is done by another way, is it possible? Why the bridge is using Serial1 if both sides can communicate with another way? Or what I missed?

Story behind this: In my project I started with RS485 library ModbusMaster then my next step was Bridge communication and I found I can't use Serial1 (pins 0, 1) for RS485 because Serial1 is for Bridge. But when I was blocking Serial1 by Modbus I was able to upload the sketch thru the linux (because I have some issue and I can't upload via USB) without problems.

So I'm going to move RS485 probably to SoftwareSerial. I can also resign Serial (debug) output and put RS485 to it but there is no pins bonded with Serial like as 0,1 with Serial1.

There are a couple ways to load a sketch, neither of which use Serial1:

  • Through the USB connector (Serial) which is not connected to any shield pins
  • Through the Linux system, either directly from the Arduino IDE by selecting a network port, or by using the load sketch button on the Yun's web configuration utility, or by running avrdude on the Linux side directly. In this case, the Linux side is programming the sketch into the '32U4 processor using an SPI interface connected directly to the 6 pin ICSP connector.

To get an RS485 port running at the same time as Bridge communications, you will need to use one of he various software serial libraries. Just keep in mind that the Yun shares the same limitation is the Leonardo:

Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

Pins 14, 15, and 16 are on the six pin ICSP connector - if you use them, then you will likely interfere with the ability to load a sketch through the Linux side.

As an alternative, you could use a USB to RS485 adapter, but that would have to go through the Linux side: the micro USB connector going to "Serial" on the '32U4 processor can only act as a device, not a host, and will not support connecting another device to it. The full size USB A connector is connected to the Linux side, and acts as a host. That is the port you will need if you want to connect a USB device to the Yun.