Making Omega2 talks with SAMD21 (Arduino Zero)



  • @Suman-kumar-Jha
    Please enable / uncomment the fifth (5th) line in the '/etc/opkg/distfeeds.conf' file.
    Please run these commands:
    opkg update
    opkg install python-light
    opkg install yunbridge

    uci set yunbridge.config.disabled='0'
    uci commit yunbridge

    reboot

    # Omega2+  FW v0.3.2 b226
    
    root@Omega-5BE1:/# cat /etc/opkg/distfeeds.conf
    #src/gz openwrt_core http://downloads.openwrt.org/releases/18.06-SNAPSHOT/targets/ramips/mt76x8/packages
    #src/gz openwrt_base http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/base
    #src/gz openwrt_luci http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/luci
    #src/gz openwrt_onion http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/onion
    src/gz openwrt_packages http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/packages
    #src/gz openwrt_routing http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/routing
    #src/gz openwrt_telephony http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/telephony
    src/gz omega2_core http://repo.onioniot.com/omega2/packages/core
    src/gz omega2_base http://repo.onioniot.com/omega2/packages/base
    src/gz omega2_packages http://repo.onioniot.com/omega2/packages/packages
    src/gz omega2_routing http://repo.onioniot.com/omega2/packages/routing
    src/gz omega2_onion http://repo.onioniot.com/omega2/packages/onion
    
    root@Omega-5BE1:/# opkg update
    
    root@Omega-5BE1:/# opkg install python-light
    Installing python-light (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-light_2.7.15-4_mipsel_24kc.ipk
    Installing python-base (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-base_2.7.15-4_mipsel_24kc.ipk
    Installing libffi (3.2.1-3) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/libffi_3.2.1-3_mipsel_24kc.ipk
    Configuring python-base.
    Configuring libffi.
    Configuring python-light.
    
    root@Omega-5BE1:/# opkg install yunbridge
    Installing yunbridge (160-f2042052115e71ad2c91f77e78d21db8275fcdd6) to root...
    Downloading http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/packages/yunbridge_160-f2042052115e71ad2c91f77e78d21db8275fcdd6_mipsel_24kc.ipk
    Installing python-ctypes (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-ctypes_2.7.15-4_mipsel_24kc.ipk
    Installing python-pydoc (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-pydoc_2.7.15-4_mipsel_24kc.ipk
    Installing python-multiprocessing (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-multiprocessing_2.7.15-4_mipsel_24kc.ipk
    Installing python-logging (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-logging_2.7.15-4_mipsel_24kc.ipk
    Installing python-codecs (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-codecs_2.7.15-4_mipsel_24kc.ipk
    Installing libsqlite3 (3260000-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/libsqlite3_3260000-4_mipsel_24kc.ipk
    Installing python-sqlite3 (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-sqlite3_2.7.15-4_mipsel_24kc.ipk
    Installing libgdbm (1.11-1) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/libgdbm_1.11-1_mipsel_24kc.ipk
    Installing python-gdbm (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-gdbm_2.7.15-4_mipsel_24kc.ipk
    Installing python-email (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-email_2.7.15-4_mipsel_24kc.ipk
    Installing python-distutils (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-distutils_2.7.15-4_mipsel_24kc.ipk
    Installing python-openssl (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-openssl_2.7.15-4_mipsel_24kc.ipk
    Installing python-xml (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-xml_2.7.15-4_mipsel_24kc.ipk
    Installing python-compiler (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-compiler_2.7.15-4_mipsel_24kc.ipk
    Installing libxml2 (2.9.9-1) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/libxml2_2.9.9-1_mipsel_24kc.ipk
    Installing libdb47 (4.7.25.4.NC-5) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/libdb47_4.7.25.4.NC-5_mipsel_24kc.ipk
    Installing python-db (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-db_2.7.15-4_mipsel_24kc.ipk
    Installing python-decimal (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-decimal_2.7.15-4_mipsel_24kc.ipk
    Installing python-unittest (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-unittest_2.7.15-4_mipsel_24kc.ipk
    Installing python-ncurses (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python-ncurses_2.7.15-4_mipsel_24kc.ipk
    Installing python (2.7.15-4) to root...
    Downloading http://repo.onioniot.com/omega2/packages/packages/python_2.7.15-4_mipsel_24kc.ipk
    Configuring python-codecs.
    Configuring libxml2.
    Configuring libdb47.
    Configuring python-db.
    Configuring python-decimal.
    Configuring python-distutils.
    Configuring python-pydoc.
    Configuring python-ctypes.
    Configuring python-multiprocessing.
    Configuring python-logging.
    Configuring libsqlite3.
    Configuring python-sqlite3.
    Configuring libgdbm.
    Configuring python-gdbm.
    Configuring python-email.
    Configuring python-openssl.
    Configuring python-xml.
    Configuring python-compiler.
    Configuring python-unittest.
    Configuring python-ncurses.
    Configuring python.
    Configuring yunbridge.
    
    root@Omega-5BE1:/# uci set yunbridge.config.disabled='0'
    root@Omega-5BE1:/# uci commit yunbridge
    
    root@Omega-5BE1:/# uci show yunbridge
    yunbridge.config=bridge
    yunbridge.config.socket_timeout='5'
    yunbridge.config.secure_rest_api='false'
    yunbridge.config.disabled='0'
    
    root@Omega-5BE1:/# reboot
    
    

    Good luck!



  • Thanks, something better now.
    In the processes of doing, i found my omega2 not responding properly.
    so i followed this "https://docs.onion.io/omega2-docs/manual-firmware-installation.html"
    and flashed omega2 with b227 firmware.

    After doing all the steps successfully, and booting back i installed python and yunbridge as you described all good done.

    After that i found new small problem. My laptop and omega2 is on same wifi network, but "omega-CF2D.local" not working which was previously working.

    0_1563789653022_ea788899-dd00-4827-aad7-e5064070687b-image.png

    and also on arduino i can't see the omega2 IP under IDE port option. Which was coming earlier.

    what can be the problem, i am not able to test yunbridge.



  • @Suman-kumar-Jha If I understand well now you have a new (a pre) project - you want to try your original project using an "Arduino UNO" (ie. an Arduino Dock R2) instead of a Zero and an Omega2 instead of an Omega2+.

    something better now

    What did you do previously? Did you change some settings? What was good and what was wrong?


    You thought a manual firmware upgrade to b227 helps but you have new problems.

    i am not able to test yunbridge

    You should make a clean system (Factory Restore) with a long OMEGA_RESET button press or with these command:
    firstboot -y
    reboot
    and repeat the Initial Setup process again.

    If your system will be OK (hostname, Omega-CF2D.local, IP address, Arduino IDE settings, etc.) then install python and yunbridge.
    (Formerly I supposed that python-light is enough but I was wrong.)

    Before you enable yunbridge with uci set yunbridge.config.disabled='0' you should look through each related file.
    I thought it's an obvious step because the Linkit Smart 7688 is slightly different from Omega2+ and the Linkit Smart 7688 Duo (or the Arduino Yún) differs from the Arduino Dock R2 & Omega2+ combo.
    Please let us know what settings should be modify according to you.



  • Sorry my mistake, let me clear.
    My project is on omega2+ and SAMD21 only, but as my local distributor was not having stock Omega2+ so i purchased Omega2 only. I guess apart from memory size there no other difference between Omega2 and Omega2+. Right ?

    Till now i tried your suggestion on Omega2 itself.

    And regarding arduino, as you said you don't have Arduino Zero. So i messaged you that if you can help me to bring yunbridge working on arduino uno then i will try to find some solution by myself for Arduino zero.

    Is my problem statement clear now?

    I have one question. I had sent you before my omega2 console photo. why its seems a lot different from the tutorial which i followed. There is no features, "settings" option is not there. Am i running right firmware and hardware ? Please let me know.

    You should make a clean system (Factory Restore) with a long OMEGA_RESET button press or with these command:
    firstboot -y
    reboot
    and repeat the Initial Setup process again.
    Thanks, but I had tried this before putting message to you

    Before you enable yunbridge with uci set yunbridge.config.disabled='0' you should look through each related file. Which files plz can you explain

    I thought it's an obvious step because the Linkit Smart 7688 is slightly different from Omega2+ and the Linkit Smart 7688 Duo (or the Arduino yun) differs from the Arduino Dock R2 & Omega2+ combo.

    Can you explain what is the difference, in hardware perspective i found same (Omega2+ and Linkit Smart 7688).



  • Hi György Farkas
    Please response



  • Hi
    Are you there, I am waiting for the response.
    Kindly response anyone



  • @Suman-kumar-Jha I've lost the thread.

    You installed the 'yunbridge' package and wrote:
    Thanks, something better now.

    I questioned:
    What did you do previously? Did you change some settings? What was good and what was wrong?

    No answer.

    You upgraded to b227 manually and wrote:
    After that i found new small problem.

    I wrote
    You should make a clean system (Factory Restore) ... and repeat the Initial Setup process again.
    ...
    If your system will be OK...

    You wrote:
    Thanks, but I had tried this before putting message to you

    Does it mean that your test arrangement (the whole HW, each SW and Omega2's firmware,) worked well before you installed and enabled 'yunbridge' again?



  • *After doing all the steps successfully, and booting back i installed python and yunbridge as you described all good done.

    After that i found new small problem. My laptop and omega2 is on same wifi network, but "omega-CF2D.local" not working which was previously working.*

    Above was my statement. For me YUN bridge never worked till now. And about above problem, i figured out what was the reason. Actually after i flashed firmware i forgot to reinstall omega arduino dock package.

    Then i re-installed omega dock on arduino ide. Now omega-CF2D.local is working in browser and also arduino ide is detecting Omega2.

    Coming to the topic, YUN bridge. You said (Formerly I supposed that python-light is enough but I was wrong.) What does mean, python light will not work? Should i install full python?

    Also while trying YUN Bridge Console read, i felt omega dock is not communicating with Omega2.
    on putty ssh
    I am getting always
    root@Omega-CF2D:~# telnet localhost 6571
    telnet: can't connect to remote host (127.0.0.1): Connection refused

    On which UART, Omega2 is interfaced with dock ?
    Also on Omega2 side what is default baudrate for YUN bridge?

    I had used this firmware

    *#include <Bridge.h>
    #include <Console.h>

    SerialBridgeClass myBridge(Serial);

    String name;

    void setup() {
    // Initialize Console and wait for port to open:
    pinMode(13, OUTPUT);
    digitalWrite(13, HIGH);
    myBridge.begin();
    ConsoleClass(myBridge);
    Console.begin();
    // Wait for Console port to connect
    while (!Console);
    digitalWrite(13, LOW);
    Console.println("Hi, what's your name?");
    }

    void loop() {
    if (Console.available() > 0) {
    char c = Console.read(); // read the next char received
    // look for the newline character, this is the last character in the string
    if (c == '\n') {
    //print text with the name received
    Console.print("Hi ");
    Console.print(name);
    Console.println("! Nice to meet you!");
    Console.println();
    // Ask again for name and clear the old name
    Console.println("Hi, what's your name?");
    name = ""; // clear the name string
    } else { // if the buffer is empty Cosole.read() returns -1
    name += c; // append the read char from Console to the name string
    }
    } else {
    delay(100);
    }
    }*

    please response soon?



  • Hi György Farkas
    Will Omega2 will support Arduino YUN official firmware ?



  • Hi György Farkas
    Please response



  • @Suman-kumar-Jha I don't have an Arduino Yún. Sadly I don't know its official firmware. So I don't know that Omega2 is or isn't able to support the official firmware of Arduino Yún.



  • Thanks for the response, can you tell me if i bring same hardware specification like omega2 then is it possible to port other openwrt firmware ?

    Flashing bootloader and firmware everything. I came across Dragino YUN shield. I had checked hardware. Everything is matching. I like omega2 modular design. So i want to stick with this.

    Let me show you my project plan.
    0_1564415143690_DAD_PLAN.PNG



  • Hi György Farkas
    please reply, guide me i need your help. If other board firmware i can't flash on omega2, then please tell me what configuration i need to do on linux side.

    Also as before you said, i had done complete reset of omega2 then on fresh i had installed python full + YUN bridge and connected arduino UNO serial (RX TX). I had tested UART simple communication its working. Omega2 is communicating with arduino dock2 via UART (/dev/ttyS0 -- Arduinno(Serial)). But YUN bridge its not working.

    I had read on arduino forum that, when arduino invoke "run-bridge" command through serial, then on linux side python bridge.py should be called which will setup bridge.

    I had checked using WinSCP, files exist.
    0_1564731797797_9652ba34-7efe-45c7-8579-b71fd5637972-image.png

    also i had checked some yunbridge files
    1_1564731552662_sbin-yunbridge.PNG 0_1564731552660_initd-Yunbridge.PNG

    I am waiting for your reply



  • @Suman-kumar-Jha said in Making Omega2 talks with SAMD21 (Arduino Zero):

    Also as before you said, i had done complete reset of omega2 then on fresh i had installed python full + YUN bridge and connected arduino UNO serial (RX TX).

    Please let me know what is your hardware test environment now.
    Are you try to test the Arduino Bridge software and the yunbridge package with

    1. Omega2 on Arduino Dock 2 and a Windows (10?) laptop with Arduino IDE and PuTTY
    2. Omega2 and a separate Arduino UNO and a Windows laptop with ...
      In this case: which serial port are you using? How did you connect them exactly?

    I had tested UART simple communication its working.

    What does it mean exactly?

    Omega2 is communicating with arduino dock2 via UART (/dev/ttyS0 -- Arduinno(Serial)).

    Are you sure?

    But YUN bridge its not working.

    Yes.



  • Yes i am testing Arduino bridge software (Console Read) with yunbridge linux package

    and i using Omega2 with Arduino Dock 2 and software (Arduino IDE and Putty) running on windows 10 home

    I have seen documentation for Arduino dock 2, hardware serial is connected with omega Uart1 (/dev/ttyS1) . So i planned to understand first what dock is sending message to omega during YUN bridge Init.

    Testing procedure

    1. UART communication test at High baudrate.
    • checked sent data from dock using FTDI RX connected to TX pin of dock

    • checked received data on linux by using screen /dev/ttyS1 250000

    One more strange thing i found, at High baud-rate (250000, which is the default baudrate of YUN bridge) omega 2 not able receive data. Dock is sending properly. Why?
    Please check below snapshot. Where left side is COM93 FTDI UART listener and right is Omega2 SSH0_1564827361299_UartFailatHighBaud.PNG

    1. UART communication test at LOW baudrate (57600)
      Please check below image, you can see its working good at 57600 baudrate.

    0_1564827552355_UartGoodAtLOWBaud-57600.PNG

    1. Then i had set yun bridge baudrate at 57600 by calling
    • uci set yunbridge.config.baudrate='57600'
      uci commit yunbridge
      reboot
    • After that i had done Simple Yun Bridge test at 57600 baud.
      In this test arduino dock geting stuck on bridge begin itself Dock is sending bridge start command continuously at regular interval and omega2 is not responding. As if its not listening. Even i saw some garbage on screen. I feel garbage was produce by dock itself
      Please check image below

    0_1564828185751_Bridge_test.PNG

    What should i do, please response soon
    Thanks



  • @Suman-kumar-Jha
    Arduino Dock 2 is not the best test bed for you due to lack of the Serial Monitor on Arduino IDE.

    On Arduino Dock 2 the serial connection between the on board Omega2(+) and the on board ATmega328P is hard- wired
    (Omega2's UART1/ttyS1 : TX1, RX1, GND to MCU's Rx (D0), Tx (D1), GND respectively via a TXS0108E bidirectional level shifter).

    On the serial line the "run-bridge XX100 XX100 ... " (XX100 max 50 times) is not some garbage it's some command - sent by an MCU (Arduino) to an MPU (now it's an Omega2).

    uci set yunbridge.config.baudrate='57600' does not change the baudrate of the serial port of the '/sbin/yunbridge' script.


    BTW what are the outputs of these commands on your test environment (ie. on Omega2):
    stty -F /dev/ttyS0 -a
    stty -F /dev/ttyS1 -a



  • Thanks György Farkas for explaining.

    Arduino Dock 2 is not the best test bed for you due to lack of the Serial Monitor on Arduino IDE.
    Did you mean arduino IDE, where arduino IDE has serial monitor. But actually atmega328p comes with only one hardware serial.
    For the above i can use another arduino board multiple hardware serial. So i can assign one of the hardware serial (Serial1) to the Omega UART. What you suggest?

    On the serial line the "run-bridge XX100 XX100 ... " (XX100 max 50 times) is not some garbage it's some command

    • But on putty screen you can see, there are some unknown symbols also apart from above command. Are these unknows symbols (¢qÿ) are part of commands ?
    • By seeing the putty screen and the commands, can i say arduino dock is sending right message for YUN bridge initialization ?

    uci set yunbridge.config.baudrate='57600' does not change the baudrate of the serial port of the '/sbin/yunbridge' script
    How to set YUN bridge serial port baudrate ? Please explain

    BTW what are the outputs of these commands on your test environment (ie. on Omega2):

    0_1564860840623_a7dd6039-6eb4-425d-9125-b156eb492fc5-image.png

    Which package do i need to install ?



  • I got it stty package name from another omega community
    0_1564862016318_b3e068d7-8995-4aaa-952a-e4755ab30274-image.png

    I had installed stty package, and here is the result

    0_1564862083578_76629337-cca4-400d-802c-de5a1d567184-image.png

    Please guide me what next i should do ?



  • @Suman-kumar-Jha OK :-) Now - after more than 30 posts - we know if you want to test Arduino Bridge between an Arduino and an Omega2(+) then you must install these packages:
    python, coreutils-stty and yunbridge.


    The next step:

    I think first of all you should modify the '/sbin/yunbridge' shell script.

    #!/bin/sh
    stty -F /dev/ttyS0 2500000 clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS0
    exec > /dev/ttyS0
    exec 2> /dev/ttyS0
    askfirst bin/ash --login

    There are at least two problems here:

    • On Omega2 the Serial Console uses ttyS0 (UART0) - so it's not free.
      On Omega2 ttyS0 (UART0) is occupied by the Serial Console - so it's not free.
      One of the possibilities: use ttyS1 (UART1) instead.

    • 2500000 Baud (2,500,000 Baud ie. 2.5 MBaud) is too high for Omega2
      and stty - without some hack - can set only regular Baud rates (eg. ..., 115200, 230400, ...).
      I think 115200 is a good choice for the first test.

    So this could be the modified script:

    #!/bin/sh
    stty -F /dev/ttyS1 115200 clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS1
    exec > /dev/ttyS1
    exec 2> /dev/ttyS1
    askfirst bin/ash --login

    or if you want to set the communication speed in the yunbridge config file
    with uci set yunbridge.config.baudrate='<BAUDRATE>' then it could be

    #!/bin/sh
    BAUDRATE=`uci get yunbridge.config.baudrate`
    stty -F /dev/ttyS1 ${BAUDRATE} clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS1
    exec > /dev/ttyS1
    exec 2> /dev/ttyS1
    askfirst bin/ash --login


    Here you are some quick and dirty tests wit the modified '/sbin/yunbridge' script
    test bed [Arduino UNO -- level shifters -- Omega2+ on Expansion Dock, FW b299] :

     *** The first "test" ***
    
    # Without Arduino UNO
    # Omega2+ on Expansion Dock, FW b299
    # FTD232 on Omega2's UART1 lines -- Ubuntu 18.04.2 LTS, picocom
    
    Please press Enter to activate this console.
    
    # Enter pressed manually
    
    BusyBox v1.28.3 () built-in shell (ash)
    
    /bin/ash: can't access tty; job control turned off
       ____       _             ____
      / __ \___  (_)__  ___    / __ \__ _  ___ ___ ____ _
     / /_/ / _ \/ / _ \/ _ \  / /_/ /  ' \/ -_) _ `/ _ `/
     \____/_//_/_/\___/_//_/  \____/_/_/_/\__/\_, /\_,_/
     W H A T  W I L L  Y O U  I N V E N T ?  /___/
     -----------------------------------------------------
       Ω-ware: 0.3.2 b229
     -----------------------------------------------------
    root@Omega-5BE1:/#
    
    # So the shell started "well"
    # although the *'can't access tty; job control turned off~'* is not a too good message 
     
    
    # *** The second "test" ***
    
    # With Arduino - the *'Console Pixel'* example sketch is running on it
    # I watched only Omega2's TX1 line 
    
    Please press Enter to activate this console.
    ��^C  # this was Omega's reply: 0xEF 0xBF 0xBD 0xEF 0xBF 0xBD 5E 43 0A 0A 0A  . . . . . . ^ C LF LF LF
    
    
     
    BusyBox v1.28.3 () built-in shell (ash)
    
    bin/ash: can't access tty; job control turned off
       ____       _             ____
      / __ \___  (_)__  ___    / __ \__ _  ___ ___ ____ _
     / /_/ / _ \/ / _ \/ _ \  / /_/ /  ' \/ -_) _ `/ _ `/
     \____/_//_/_/\___/_//_/  \____/_/_/_/\__/\_, /\_,_/
     W H A T  W I L L  Y O U  I N V E N T ?  /___/
     -----------------------------------------------------
       Ω-ware: 0.3.2 b229
     -----------------------------------------------------
    root@Omega-5BE1:/# 
    root@Omega-5BE1:/# �V�  # Omega's reply: 0xEF 0xBF 0xBD 56 0xEF 0xBF 0xBD 0A 0A 0A  . . . V . . . LF LF LF
    
    
    
    

    It seems the two devices can communicate with each other via the Arduino Bridge
    but something is not perfect yet because the LED is not blinking.
    See also the Console Pixel example sketch.

    You could repeat these tests also on your Arduino Dock 2.



  • @György-Farkas said in Making Omega2 talks with SAMD21 (Arduino Zero):

    dirty tests wit the modified '/sbin/yunbridge' script

    Thanks, i had done everything as you said. Now can you please send yunbridge script. So i can also perform bridge test on my test bed


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.