Showing posts with label 7. Good to knows. Show all posts
Showing posts with label 7. Good to knows. Show all posts

Sunday, August 24, 2014

Reset or reboot not working

I had an issue that when typing reboot, or pressing the reset button, the Yun (open wrt) would not correctly reboot (e.g. the white LED did no go on anymore). The only way the reboot worked correctly was by power cycling the device. Also a watchdog based reboot didnt work.

Cause: my running sketch was sending stuff to the Console. This will interrupt the boot. The "old" Uboot version will be interrupted by any char. A bridge operation will cause the same problem (I think even a get as this is implemented as transfer)

Solution:
 - newer uboot version (with openwrt-yun 1.3) is more strict and will only interrupt on the characters "ard". The upgrade is unfortunatley a manual step that will void warranty. See http://arduino.cc/en/Tutorial/YunUBootReflash  (you can do only the uboot stuff)

extra info: takes about 4sec to enter uboot (so probably a good idea to let a sketch do nothing the 4 first seconds)

Wednesday, July 23, 2014

Arduino Yun Wifi stuff (reset, access point mode, ...)

The Yun has 3 reset buttons: one of those is a Wifi reset button (WLAN Rst)

Depending on how long you press the button the following will happen (I think):


  • Pressing the WLAN Rst button for <5 sec does not do any reset at all, correct (it just lets a LED blink)
  • Pressing the Wifi Rst button for >=5 but <30 sec will run the wifi-reset-and-reboot script. This script will return the Yun in access point (AP) mode and will reboot the Yun. The Yun should then present its network SSID.
  • Pressing for >= 30 sec will restore some factory settings

If you just want to reset the Wifi, you can do this with the wifi script (should be in /sbin):

    root@Arduino:/tmp# wifi down && sleep 5 && wifi
    Successfully initialized wpa_supplicant

You probably can also do:

    ifconfig wlan0 down; ifconfig wlan0 up

Note that rc.local contains by default the entry wifi-live-or-reset. After the Yun boots, it will check for the configured Wifi network. If it is not found within 60sec, the Yun will go into access point mode.

Sunday, May 25, 2014

Moving the linux filesystem OpenWrt to the SD card

Standard the OS is on the flash of the Yun. It is possible to move (most) to the SD card.

Advantages are:
- much more space, allowing to install many more packages
- the flash can be written only a limited amount of times. If you move the OS to the SD card, this is no longer an issue. The SD card also has a limited amount of writes, but typically more than the flash, and it is much easier to replace the SD card than the flash.

Before starting, create at least one ext4 partition on the SD card (see e.g. http://myyafa.blogspot.be/2014/05/create-and-format-partitions-on-yun-sd.html)

On the Yun do (pivot root option):
opkg update
opkg install block-mount
cd /
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/sda1 -xf -
umount /tmp/cproot
edit the file /etc/config/fstab and add:


config mount
        option target        /
        option device        /dev/sda1
        option fstype        ext4
        option options       rw,sync
        option enabled       1
        option enabled_fsck  0
That's it. Reboot and the OS should now reside on the SD. If you still want to access the old filesystem on the flash (this is still used at boot for example) you can do
cd /
mkdir original-boot
and add
config mount
        option target   /original-boot
        option device   /dev/mtdblock3
        option fstype   jffs2
        option options  rw,sync
        option enabled  1
        option enabled_fsck     0
to the /etc/config/fstab file (see also http://forum.arduino.cc/index.php?topic=289215.0) (the one on the SD card)

Monday, December 30, 2013

Starting a script after the CPU Linino boot

Just add the script to the /etc/rc.local file

The stdout and stderr get redirected to a log file in /tmp (ramdisk)

My rc.local on the Arduino Yun now looks as follows:


touch /tmp/begin
wifi-live-or-reset
boot-complete-notify
sleep 5s
cd /mnt/sda1/arduino/Yafa
./main.py 1> /tmp/Yafa.log 2>&1 &
touch /tmp/end
exit 0

Monday, December 23, 2013

Good to knows - 4

Using the watchdog to reset the mcu if something goes wrong:

See
#include 

void setup ()
{
  Serial.begin (115200);
  Serial.println ("Restarted.");
  wdt_enable (WDTO_1S);  // reset after one second, if no "pat the dog" received
 }  // end of setup

void loop ()
{
  Serial.println ("Entered loop ...");
  wdt_reset ();  // give me another second to do stuff (pat the dog)
  while (true) ;   // oops, went into a loop
}  // end of loop

This code comes from http://forum.arduino.cc/index.php?topic=128717.msg968831#msg968831

Obviously this can be used to trigger a restart when you detect an error (if error --> while(1){})


Thursday, November 28, 2013

Good to knows - 2

Finding out how much free memory:

int freeRam () 
{
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}

Sunday, November 24, 2013

Good to knows - 1

http://forum.arduino.cc/index.php?topic=200732.msg1480813#msg1480813

Do not CTRL-C a python script that uses the bridge. Stuff may hang. Use kill-bridge instead.

To reset the 32u4 from linino, you can use command reset-mcu