Go Down

Topic: [solved] yun mega: reset the mega in reset-mcu (code needed) (Read 2719 times) previous topic - next topic

Jantje

Jul 17, 2014, 04:40 pm Last Edit: Jul 18, 2014, 05:55 pm by Jantje Reason: 1
Hi
I hacked my yun to replace the leonardo by a Arduino mega. I use upload via ttyACM0 and that works all great.
However when I run the reboot command in openwrt it doesn't work because the mod to reset the leonardo does not work to reset the mega (I tried to connect the reset line to the mega but that didn't work)
So basically the leonardo is reset (who is not using ttyATH0) but not the mega (that is using ttyATH0) so the boot process of openwrt does get interrupted.
I was wondering whether there is a easy command to reset the mega using ttyACM0 that I can put in reset-mcu.
A search didn't reveal anything trivial.

Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

sonnyyu

Possible solution;-

Daisy chain reset

Code: [Select]
void setup() {
  // put your setup code here, to run once:
  int pin=12;
  pinMode(pin, INPUT);
  digitalWrite(pin, LOW);
  pinMode(pin, OUTPUT);
  delay(100);
  pinMode(pin, INPUT);
}



via a 1K resistor, a Yun Digital Pin (for example pin12) to the Mega Reset Pin, connect both board ground to ground.

Jantje

sonnyyu
Thanks for the response. However I'm looking for code to run on openwrt that will reset a mega that is connected to ttyACM0.
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

sonnyyu

Code: [Select]
root@Arduino:/usr/bin# cat /usr/bin/reset-mcu
#!/bin/sh

echo 18 > /sys/class/gpio/export
echo "high" > /sys/class/gpio/gpio18/direction
echo 1 > /sys/class/gpio/gpio18/value
echo 0 > /sys/class/gpio/gpio18/value
echo 18 > /sys/class/gpio/unexport


call "/usr/bin/reset-mcu" at openwrt ->reset ATmega32u4 -> ATmega32u4's set() run once-> reset Arduino Mega

Daisy chain reset

arbor

This might do it for you:

Code: [Select]
echo "@00 on 12/r" > /dev/ttyACM0

federicofissore

arbor, can you explain this? It looks like magic to me

arbor

Quote

Code: [Select]
echo "@00 on 12/r" > /dev/ttyACM0

Oops.  That's not what I meant to put in there.  That was from something else.

I meant just try to open the USB serial port and see if that resets it.
Code: [Select]
cat /dev/ttyACM0

I'm not sure if usbreset is part of usbutils pkg, but maybe just resetting the USB port.



Jantje

@sonnyyu
Ach now I get it. I'd prefer a Linux command though. As The hardware is finished and the mods I did make it more difficult to upload to the leonardo.

@arbor
I have some battery issues (another 500 euro down the drain  =( ) so I'll test as soon as I have the  hardware running again.

Best reagards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Jantje

placed some other batteries so I could do some testing.
Code: [Select]
cat /dev/ttyACM0
works but I have to press ctrl+C because the stream isn't closing.
But this set me to think and I came up with this solution:
Code: [Select]
head -c 0 /dev/ttyACM0
This works like an charm and probably works on any linux.

Why it works?
Head opens a file and prints the first lines. so
Code: [Select]
head  /dev/ttyACM0
may work if the arduino is printing to Serial. However mine is not and the delay may become to big.

Code: [Select]
head -c 0 /dev/ttyACM0
The -c 0 (zero no capital O) says to print 0 characters. So this will open the file and close it.

Thanks for the lead :-)
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Go Up