Can an Uno program and Uno?

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I am still quite new and learning the AVR world. If this question is silly or not obvious please excuse me: I am still a beginner.

 

 

Is the following possible?

 

 

Imagine two Arduino Uno's that talk to each other  via the on-board Serial pins (ATMega328P-PU chips).  They "talk" via RX/TX pins at 9600 baud. They have a common ground wire also.  So all is well so far: they send and receive character strings no problem.  Lets call them "A" and "B".

 

 

I can easily re-program "A" with out any change to my set up by popping out the 328P-PU chip, updating it and popping it back in "A"

 

Is there anyway for "A" to reprogram "B" directly?   I already have a "boot burner" set up where one Uno can be used to burn a boot loader to another Uno that does not have it.  Why I am asking is can one Uno directly re-program a connected Uno?  So if "A" has version 1.3 it in ROM, it can force "B" to have 1.3 as well and re-boot it.

 

 

"B" might be buried deep in the bowels of some mechanical project, where it is a PITA to get to: so any software corrections / revisions are a pain in the butt to implement.

 

Thank you for any and all help / insight.

 

Sam

 

 

 

I am a new AVR programmer. I am learning alone out of books, the Internet, etc. Please excuse me if I ask simple questions. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes.   Uno-A can run the ArduinoISP sketch.

 

You can program Uno-B by connecting the ArduinoISP wires from Uno-A.

 

This can "Burn Bootloader" on Uno-B

Or "Upload sketch with external programmer" on Uno-B

 

Note that every time you "Upload sketch with external programmer" it will destroy any pre-burned bootloader on Uno-B.

 

Quite honestly.   A Uno comes out of the factory ready to go.    The bootloader works beautifully.

 

AvrFreaks are obsessed with shooting their own feet.    e.g. by using an external programmer.

You can recover by "Burn Bootloader" but it is easier to avoid painful toes in the first place.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David:

 

So if  "A" is running one kind of hello world / blink program, I can transfer it to "B" and then they both are running it?

 

Do I understand what you wrote correctly?

 

Thank you!

I am a new AVR programmer. I am learning alone out of books, the Internet, etc. Please excuse me if I ask simple questions. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 

More specifically:  In the Arduino world, my Windows desk top used 4 wires (Vcc, GND, Rx and Tx) in a USB cable to tell my Uno it is getting a program update and to update it.   I am asking how can i set up "A" to use those same 4 wires to do the same task?

I am a new AVR programmer. I am learning alone out of books, the Internet, etc. Please excuse me if I ask simple questions. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVR_Beginner wrote:

David:

 

So if  "A" is running one kind of hello world / blink program, I can transfer it to "B" and then they both are running it?

 

Do I understand what you wrote correctly?

 

Thank you!


No. "A" will be running firmware specifically to act as a programmer.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVR_Beginner wrote:

 

 

More specifically:  In the Arduino world, my Windows desk top used 4 wires (Vcc, GND, Rx and Tx) in a USB cable to tell my Uno it is getting a program update and to update it.   I am asking how can i set up "A" to use those same 4 wires to do the same task?


You can't. Your PC is a USB host. An Uno has no provisions to be a USBhost.

You seem to be in deeper waters than you can currently swim in. Take a step back and tell us what you actually want to accomplish.

If this is simply about having two Unos running the same sketch then why not simply program both Unos with the same sketch from your PC?
EDIT: Spelign misteaks.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Thu. Oct 12, 2017 - 08:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl

 

Crap... there goes that idea!  :-(

I am a new AVR programmer. I am learning alone out of books, the Internet, etc. Please excuse me if I ask simple questions. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What was the ultimate idea?

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 

JohanEkdahl

 

 

I am working on a project, really an idea right now: no prototype yet.  One Uno will be some what easy to reach, the other one deep in the bowels of a machine I have an idea for.  Just an idea right now.

I am a new AVR programmer. I am learning alone out of books, the Internet, etc. Please excuse me if I ask simple questions. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In principle, there is nothing stopping you from having "A" be both an ISP programmer (programming "B") AND running HelloWorld. You'll have to take the ArduinoISP sketch sources and adapt it to add the HelloWorld part to it. Not trivial by any means - but not impossible.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just plug Uno-A into one USB socket and Uno-B into a second USB socket.

You can program the same sketch into Uno-A and Uno-B.

 

Once the sketches are Uploaded into the Unos,  you can unplug from USB  and power with batteries or external power supply.

 

In practice,  life is simpler with USB.   Buy a USB hub for your Laptop if you don't have enough USB sockets.    Most Arduino projects take very little current.   But a big 7" TFT screen or motor drivers are power hungry.   

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guess (in principal) I don't full understand why it cant work.

 

The USB cable I have that programs the Uno from my desktop has only 4 wires:  Vcc, GND and Tx/Rx    So in principal I can;t see why it would not work.  I am sure there is a good reason why those 4 wires won't do it: It probably will become clear when i learn more (I am hoping).

I am a new AVR programmer. I am learning alone out of books, the Internet, etc. Please excuse me if I ask simple questions. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The USB cable has 4 wires: 5V, GND, D+, D-

 

The D+, D- wires can perform many different things.  e.g. anything from a video camera to a Serial link.

 

Those D+, D- wires not only communicate the RX, TX data but also things like DTR, RTS, ...

A regular RS232 cable has multiple wires.

 

When you start a "Bootloader Upload" the PC sends a DTR signal to the Uno.   This provides a Reset pulse.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David: Thanks.

 

 

So I looked at the ISP Programmer code Johan suggested: as expected I can not (at this time) modify it because I don't have the skill yet.  Still, if I only had a simple frame work that I can inset my blink  / hello world into I would be happy.  I am going to try and hack the ISP Programmer program when I have the knowledge.

 

All I am looking to do is have "A" force it's program into "B", when that is done "A" will run it's blink / hello world block an so will "B"

I am a new AVR programmer. I am learning alone out of books, the Internet, etc. Please excuse me if I ask simple questions. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is a critical USB "issue" that the OP appears not to know about. That is that USB devices come in several "flavors" One is "host" - this kind communicates with other USB devices. Another is "client" - it is controlled by hosts. Another flavor is "OnTheGo - OTG" which is a special kind of client that can work as a reduced functionality host. Another is "hub" which can serve as an intermediary between hosts and clients. 

 

The problem comes from the fact that USB is not just a "send a message" system. There is a very complex "stack" that manages each devices operation. Host stacks are very much more complex than client stacks and will typically NOT fit into things a whole lot smaller than, lets say, a RaspberryPi. Yes, I do recall that there is one AVR that can function as a host (maybe an OTG host?) but it is not your ordinary run-of-the-mill AVR. 

 

The short conclusion is that just because it has an D+, D-, common, and power does NOT mean that it can function as a host, or even an OTG device. It also has to have the stack. 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You still haven't explained why you can't just reach the 'deep down in the machine' UNO via the normal USB cable.  Just get a long cable.  Where's the problem?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you bypassed the USB on 'Uno B' and made a serial connection you could use a bootloader to talk to it 'STK500' over a regular serial (RS232/RS485) link.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thought about this problem: I am getting the impression it would probably not be practical (at my stage of understanding) to try to implement this.  Discretion is osme times the better part of valor :-)

 

So I will drop the idea for now: bigger fish to fry out there.

 

Thank you everyone for the help though. I learned a bit more and that is certainly worth the trouble!

I am a new AVR programmer. I am learning alone out of books, the Internet, etc. Please excuse me if I ask simple questions. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't really get what's the big problem. You want to have both UNOs running the same program. As long as it is acceptable that none of them is running the program at a specific point, you can just:

 

  - Upload the ArduinoISP to Uno-A

  - Use Uno-A to program Uno-B with the desired sketch

  - Now that Uno-B is programmed and there's no point in Uno-A to keep running ArduinoISP... reprogram it, upload the desired sketch to Uno-A

 

 

Now both are running the same program.

 

Is there something I'm missing?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The major point is that Uno-A and Uno-B are both functional. i.e. they can both upload the sketch with their bootloaders.
.
Yes, you can destroy the bootloader on Uno-B if you want. But you will need to use Uno-A to do the programming.
Then upload the sketch to Uno-A with its intact bootloader.
.
The real mystery is: WHY?
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys, he won't tell.

 

It's either a brilliant idea worth millions, or he thinks it is too embarrassingly stupid to mention. ;-)

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to say that you CAN do what you ask here. Any AVR can pass a program to any other and as long as that second one has a bootloader then it can program what it receives into itself.

 

Using Arduinos just makes this a bit more complex because in the Arduino infrastructure each board is already using its bootloading capability for the usual programming anyway. So if you are to re-use the existing stuff then when A talks to be B to send it the program it has to "look like" a PC running avrdude and sending data via the "-c arduino" protocol.

 

But ultimately anything is possible.

 

Like others here I don't see how a (long!) UART cable from A to B is "better" for programming it than a USB cable stretching from the PC alongside A to B instead? Why does A need to act as a "proxy" (which is what it really is) here?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Any AVR can pass a program to any other and as long as that second one has a bootloader then it can program what it receives into itself.

And not only that, I suppose. Many AVRs should be capable enough to be ISP programmers on their own. Towards the host is exposes itself as a bootloader, and towards the AVR actually to be programmed it does ISP. Takes some work, but I can't see why it should not be do-able.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
Towards the host is exposes itself as a bootloader, and towards the AVR actually to be programmed it does ISP.
Which is pretty much what the "Arduino ISP" sketch does ;-)

 

EDIT: But in this case now your A to B "long cable" is not just a USB cable or a UART TX/RX cable but it is all the wires (SCK, MOSI, MISO) involved in connecting an ISP programmer to an AVR

Last Edited: Fri. Oct 13, 2017 - 01:39 PM