Ubuntu UP Squared

Duane Goodman
Duane Goodman New Member Posts: 33
Hey

In the UP Wiki it says drivers are only available for the original UP on Ubuntu. Is there any idea when this will change? Hopefully by the time UP^2 ships it will be avaiable. :) That's also assuming the UP^2 ships as planned in August.

Comments

  • DCleri
    DCleri Administrator, AAEON Posts: 1,213 admin
    UP Squared drivers will be included in the next Ubuntu Kernel for UP that will be released later in August after 16.04.3 will be available from Canonical
  • Kurt
    Kurt New Member Posts: 146 ✭✭
    Maybe I missed this, but what is the status of drivers for UP2?

    The download section for this still says only for UP and driver should be available in August...
    It is now October, so wondering the status.

    Thanks
  • David Rolfe
    David Rolfe New Member Posts: 98
    Is it just me, or are we getting fewer driver, BIOS and Operating System updates than we have become accustomed to receiving from the UP team?

    There are still quite a number of questions which have been asked on here, and updates promised which have never actually appeared.

    Prior to this I was starting to become quite impressed with the prompt replies, and published solutions appearing as a result of questions asked on this Forum, but am not really sure what is going on at the moment... or am I seeing a problem which is not really there?

    Thanks!
  • theodoros p
    theodoros p New Member Posts: 24
    I’m using up squared and I developed with opencv simplecv .... and lot of dependencies of those ... currently I use the ubilinux 4 the newer version but I can’t compile opencv latest versions and I had problems with beignet compiling from source also ..so I had to use the standard deb packages for opencv that is the old versions of opencv and missing lot of features..Normaly I work on UBUNTU and everything works perfect but in the UP^2 with Ubuntu GPIOs doesn’t works as be read in upwiki ..Any idea when we ll have some kernel patch or release with full functionality in GPIOS with UBUNTU ??
  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin
    edited November 2017
    So tonight I installed Ubuntu 16.04 LTS and the UP kernel and am able to access the GPIOs as outlined in the wiki (I've also been fixing several Wiki links for the GPIO and examples).

    https://up-community.org/wiki/Pinout_UP2

    It's working on the UP Squared when accessed via command line and via the custom Linux pin numbers for the UP Squared (e.g. "433" == BCM4). "Working" as in the sense I can blink an LED (out) and read a button press (in).

    What I haven't gotten working yet is the Python RPi.GPIO Debian package that was built for Ubilinux. I can manually install it, it shows up under the system Python packages as "RPi.GPIO" just like it should. I can run a Python script that imports it without complaining. But, when trying to access the BCM pin or BOARD pin assignments, nothing happens.

    I didn't have much time to debug it - spent like 30m on it overall running the "blink LED" example.

    I'll try to find some time to debug the Python package and to sample some C code to see if that works as well. I'll write up a post about how to get it all working as well, and add it to the wiki (give me some time, family life takes precedence).

    But so far, it is looking like Ubuntu 16.04 LTS works well on the UP Squared with the UP Kernel.

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • theodoros p
    theodoros p New Member Posts: 24
    edited November 2017
    Does it works if we use the linux PIN numbers as are defined for the up board?i ask that cause I use the up board linux PIN numbers in up squared with ubilinux and I have wrote all my setup scripts to export the GPIOs and it works great.But if I want to turn to ubuntu I have to rewrite some scripts with up^2 linux PIN numbers if the up board numbering doesn’t work.Could you make a test and post the results?
    (In my code i use direct read write file operations in /sys/class/gpio/gpioXX with c++ but would be good to make the Rpi library work as well)
    Thanks
  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin
    edited November 2017
    pantheongr wrote:
    Does it works if we use the linux PIN numbers as are defined for the up board?i ask that cause I use the up board linux PIN numbers in up squared with ubilinux and I have wrote all my setup scripts to export the GPIOs and it works great.But if I want to turn to ubuntu I have to rewrite some scripts with up^2 linux PIN numbers if the up board numbering doesn’t work.Could you make a test and post the results?
    (In my code i use direct read write file operations in /sys/class/gpio/gpioXX with c++ but would be good to make the Rpi library work as well)
    Thanks

    Yes, it uses the same Linux PIN numbers on the UP2 on both Ubilinux and Ubuntu 16.04 LTS. As a matter of fact, the Wiki was written for Ubilinux - and I running the tests under Ubuntu.

    If you are directly accessing the sys class, then you are good to go:

    * install Ubuntu 16.04 LTS (I used Desktop).
    * follow the directions in the wiki to install the Ubuntu kernel 4.4 for UP board - https://up-community.org/wiki/Ubuntu#Ubuntu_16.04.1_LTS_.28Xenial_Xerus.29
    * set the kernel as default on boot (scroll down on that same page as above)

    Reboot and check that it lists the upboard kernel.

    Then that's it. Direct system class file i/o should work at that point.

    I haven't done SPI or I2C, but I can see SPI. I2C may require a device connected first before it sees something.

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • theodoros p
    theodoros p New Member Posts: 24
    edited November 2017
    HELP HELP HELP
    I Excecute everything as root
    I installed Ubuntu 16 following all instructions as written at upwiki I loaded up board-kernel I made it run as default I rewrote my scripts to export the GPIOs I needed ,the GPIOs in / sys/class/gpio are exported but they don’t obey to the commands on-off I give them in their corespondent value files!!
    Also I did upgrade using apt-get upgrade and nothing happened .
    Any idea or any help before I have to revert to ubilinux and install everything from the beginning.?
    Update::when I give a signal like on value=1 instantly it obeys but then return to 0 even if the contents of the value file are equal to 1!!!!
  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin
    Could you post some sample code and maybe what pins you are using?

    I'll give it a shot on my side.

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • theodoros p
    theodoros p New Member Posts: 24
    the following is my script for set up and initialize the pins it worked to the ubilinux and also similar script for gpios to beagle bone revc

    ##28/10/2017 THIS FILE IS FOR USING WITH UP BOARD SQUARED OR UP BOARD
    ##
    #input pins
    sudo echo 402 > /sys/class/gpio/export #P22
    sudo echo in > /sys/class/gpio/gpio402/direction
    echo 0 > /sys/class/gpio/gpio402/value
    sudo echo 419 > /sys/class/gpio/export #P24
    sudo echo in > /sys/class/gpio/gpio419/direction
    echo 0 > /sys/class/gpio/gpio419/value
    sudo echo 420 > /sys/class/gpio/export #P26
    sudo echo in > /sys/class/gpio/gpio420/direction
    echo 0 > /sys/class/gpio/gpio420/value
    sudo echo 465 > /sys/class/gpio/export #P28
    sudo echo in > /sys/class/gpio/gpio465/direction
    echo 0 > /sys/class/gpio/gpio465/value
    ##Output pins
    sudo echo 462 > /sys/class/gpio/export #P3
    sudo echo out > /sys/class/gpio/gpio462/direction
    sudo echo 1 > /sys/class/gpio/gpio462/value
    sudo echo 463 > /sys/class/gpio/export #P5
    sudo echo out > /sys/class/gpio/gpio463/direction
    sudo echo 1 > /sys/class/gpio/gpio463/value
    sudo echo 433 > /sys/class/gpio/export #P7
    sudo echo out > /sys/class/gpio/gpio433/direction
    sudo echo 1 > /sys/class/gpio/gpio433/value
    sudo echo 478 > /sys/class/gpio/export #P11
    sudo echo out > /sys/class/gpio/gpio478/direction
    sudo echo 1 > /sys/class/gpio/gpio478/value
    sudo echo 432 > /sys/class/gpio/export #P13
    sudo echo out > /sys/class/gpio/gpio432/direction
    sudo echo 1 > /sys/class/gpio/gpio432/value
    sudo echo 431 > /sys/class/gpio/export #P15
    sudo echo out > /sys/class/gpio/gpio431/direction
    sudo echo 1 > /sys/class/gpio/gpio431/value
    sudo echo 422 > /sys/class/gpio/export #P19
    sudo echo out > /sys/class/gpio/gpio422/direction
    sudo echo 1 > /sys/class/gpio/gpio422/value
    sudo echo 421 > /sys/class/gpio/export #P21
    sudo echo out > /sys/class/gpio/gpio421/direction
    sudo echo 1 > /sys/class/gpio/gpio421/value
    sudo echo 418 > /sys/class/gpio/export #P23
    sudo echo out > /sys/class/gpio/gpio418/direction
    sudo echo 1 > /sys/class/gpio/gpio418/value
    sudo echo 464 > /sys/class/gpio/export #P27
    sudo echo out > /sys/class/gpio/gpio464/direction
    sudo echo 1 > /sys/class/gpio/gpio464/value
    sudo echo 430 > /sys/class/gpio/export #P29
    sudo echo out > /sys/class/gpio/gpio430/direction
    sudo echo 1 > /sys/class/gpio/gpio430/value
    sudo echo 404 > /sys/class/gpio/export #P31
    sudo echo out > /sys/class/gpio/gpio404/direction
    sudo echo 1 > /sys/class/gpio/gpio404/value
    sudo echo 469 > /sys/class/gpio/export #P33
    sudo echo out > /sys/class/gpio/gpio469/direction
    sudo echo 1 > /sys/class/gpio/gpio469/value
    sudo echo 327 > /sys/class/gpio/export #P35
    sudo echo out > /sys/class/gpio/gpio327/direction
    sudo echo 1 > /sys/class/gpio/gpio327/value
    sudo echo 403 > /sys/class/gpio/export #P37
    sudo echo out > /sys/class/gpio/gpio403/direction
    sudo echo 1 > /sys/class/gpio/gpio403/value
    sudo echo 477 > /sys/class/gpio/export #P8
    sudo echo out > /sys/class/gpio/gpio477/direction
    sudo echo 1 > /sys/class/gpio/gpio477/value
    sudo echo 329 > /sys/class/gpio/export #P40 USED FOR VALVES SERVICE ALARM
    sudo echo out > /sys/class/gpio/gpio329/direction
    sudo echo 1 > /sys/class/gpio/gpio329/value
  • WereCatf
    WereCatf New Member Posts: 201
    pantheongr wrote:
    sudo echo 402 > /sys/class/gpio/export

    You can't use sudo like that. The "sudo echo 402" would execute as root, but the redirection to file, ie. ">/sys/class/gpio/export" would execute as your normal user. Use the following form instead:
    echo 402 | sudo tee /sys/class/gpio/export
    
  • theodoros p
    theodoros p New Member Posts: 24
    edited November 2017
    Did you try it and it doesn’t work?i Run the whole script as root and in ubilinux that I had installed some days ago was working that script and also at beaglebone black was working ,and when I excecute it in ubuntu instantly turn the signal to ON signal 1 but it falls again to OFF 0,also if I try to run the script without Sudo root permissions it gives me permissions error
    And when I excecute this script as root the GPIOs are all exported to /sys/class/gpio and the coresponding values are written in their gpio/goioXXX/value so the script works
    I m going to try your solution but I don’t think this is the issue
  • Kurt
    Kurt New Member Posts: 146 ✭✭
    Sorry, I may be wrong here, but wondering if maybe some of the UDEV rules stuff, might help?

    That is I remember in the thread: https://up-community.org/forum/general-discussion-up/1997-using-gpio-with-c-permission-problems#5217
    that it helped me to have udev rules setup such that the user (me) did not have to rely on using sudo... There was still the issue that once you issue the export, you had to delay a little to allow the udev system some time to change the permissions/owners of the file.
  • WereCatf
    WereCatf New Member Posts: 201
    pantheongr wrote:
    i Run the whole script as root

    If you're running it as root, then why do you even have calls to "sudo" in your script at all? You don't need sudo if you're root.
  • theodoros p
    theodoros p New Member Posts: 24
    That was maybe something unnecessary that I wrote it ones and I didn’t want then to rewrite the whole script being lazy,but it effects to nothing the whole script cause it’s tested already to UP SQUARED with ubilinux and BBB REVC
  • Kurt
    Kurt New Member Posts: 146 ✭✭
    edited November 2017
    Again maybe side note:

    I followed the instructions on this thread and updated my UP2 to Ubuntu and added the kernel... I also followed the instructions in the thread I mentioned to create the gpio group... (and spi)...

    I then tried to paraphrase your script (hand type in).
    kurt@kurt-UP-APL01:~$ uname -r
    4.4.0-2-upboard
    kurt@kurt-UP-APL01:~$ echo 402 > /sys/class/gpio/export
    kurt@kurt-UP-APL01:~$ cd /sys/class/gpio
    kurt@kurt-UP-APL01:/sys/class/gpio$ ls
    export  gpio402  gpiochip267  gpiochip310  gpiochip357  gpiochip434  unexport
    kurt@kurt-UP-APL01:/sys/class/gpio$ ls -l
    total 0
    -rwxrwx--- 1 root gpio 4096 Nov  2 08:41 export
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpio402 -> ../../devices/platform/INT3452:01/gpio/gpio402
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpiochip267 -> ../../devices/platform/INT3452:03/gpio/gpiochip267
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpiochip310 -> ../../devices/platform/INT3452:02/gpio/gpiochip310
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpiochip357 -> ../../devices/platform/INT3452:01/gpio/gpiochip357
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpiochip434 -> ../../devices/platform/INT3452:00/gpio/gpiochip434
    -rwxrwx--- 1 root gpio 4096 Nov  2 08:41 unexport
    kurt@kurt-UP-APL01:/sys/class/gpio$ echo in > gpio402/direction
    kurt@kurt-UP-APL01:/sys/class/gpio$ echo 0 > gpio402/value
    -bash: echo: write error: Operation not permitted
    
    And found you can not write a value to pin that is marked as input...

    Was able to Read it and also set it as output and then write to value...
    kurt@kurt-UP-APL01:/sys/class/gpio$ cat gpio402/value
    0
    kurt@kurt-UP-APL01:/sys/class/gpio$ echo out >gpio402/direction
    kurt@kurt-UP-APL01:/sys/class/gpio$ echo 1 > gpio402/value
    kurt@kurt-UP-APL01:/sys/class/gpio$ echo 0 > gpio402/value
    kurt@kurt-UP-APL01:/sys/class/gpio$
    

    Edit: forgot to mention, that the GPIO pins are now in the group gpio... so did this as normal user not su...
    kurt@kurt-UP-APL01:/sys/class/gpio$ ls -l
    total 0
    -rwxrwx--- 1 root gpio 4096 Nov  2 08:41 export
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpio402 -> ../../devices/platform/INT3452:01/gpio/gpio402
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpiochip267 -> ../../devices/platform/INT3452:03/gpio/gpiochip267
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpiochip310 -> ../../devices/platform/INT3452:02/gpio/gpiochip310
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpiochip357 -> ../../devices/platform/INT3452:01/gpio/gpiochip357
    lrwxrwxrwx 1 root gpio    0 Nov  2 08:41 gpiochip434 -> ../../devices/platform/INT3452:00/gpio/gpiochip434
    -rwxrwx--- 1 root gpio 4096 Nov  2 08:41 unexport
    
  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin
    I won't have time to test until tonight.

    But this isn't a board issue, it's the difference between operating systems.

    WereCatf is correct: in bash, you can't do sudo like that - at least not under Ubuntu. You'll have to use `tee` to send the output with proper permissions.

    Or, run the app as full root - in which sudo won't matter and should be removed (and actually running as sudo under root could cause issues, depending on the sudoers settings). That was hinted at in the wiki as well, when they state to `sudo -i` to start an interactive session under the root user.

    Also, Ubilinux does have different udev rules than Ubuntu.

    Ubilinux is set up to be more loose on security principals, to allow for an easier Maker/Developer experience. I am not surprised that the script may have worked under Ubilinux. But under Ubuntu, you'll have to follow more standard access rules.
    echo 402 | sudo tee /sys/class/gpio/export
    

    Is the process to follow under Ubuntu, Debian, etc.

    From my experience, so much of the GPIO needs root access - so I would remove "sudo" from all of your commands and run the entire app as root. I really don't like suggesting that for security reasons. If security is of concern, follow the link KurtE posted for WereCatf's UDEV edits but may need tweaking for Ubuntu. I'll have to test it first before adding to the wiki.

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • theodoros p
    theodoros p New Member Posts: 24
    edited November 2017
    And is it normal that when I excecute this script as root the GPIOs are exported to /sys/class/gpio location And each gpio/value is set as the script commands but whatever the signals turn on and off in an instant?Is it also normal that if I’ll manually write to one gpio/value 1 or 0 then the output have the same behavior?Also is it normal that in beaglebone black revc i had on it Ubuntu 12 and I was running the same script (with different linux numbering appropriate for the board) and it was working everything perfect??I still think is a kernel issue cause even if the script is wrong the manual way to write to the GPIOs should work.I hope you ll be able to test it and tell me if everything works perfect to you and also what commands you used to blink a LED
  • theodoros p
    theodoros p New Member Posts: 24
    edited November 2017
    Thanks for your reply ,the first 4 pins are intended for input and you are right we can’t write on them and even I do it the system just complain warning that I can’t write to device,the rest of the pins are intended for output and I make my tests to the outputs not to the input pins but even the input pins can’t read anything when I use the push buttons of my project machine!!yesterday I had ubilinux and everything were working, the same when I used ubuntu in beaglebone but today i just installed ubuntu and up-kernel on it and they just don’t work.In fact they give output instantly and revert to 0 ,and the inputs read absolutely nothing
  • theodoros p
    theodoros p New Member Posts: 24
    An other interesting thing I note using the ubilinux in UP2 is that I used the UP board Linux numbering for the GPIOs and not the UP2 Linux numbering and it worked!!
    As it worked like that I didn’t make a test using the UP 2 Linux numbering to watch it’s behavior and if was working.
  • Kurt
    Kurt New Member Posts: 146 ✭✭
    I have not personally checked out if it is working or not, other than I can type the commands.

    I also wonder if we jumped the GUN, or did I miss a message where they actually released a Kernel for Ubuntu on the UP2 that works with these pins?

    Last message I saw was: https://up-community.org/forum/public-otheros/2357-i-am-impressed-with-ubuntu-17-10#6872
    Where it sounded like they were hopefully going to upload a new kernel this week with this support.

    And the Download page does not show any differences: https://up-community.org/downloads/category/55-up-squared-os
    Still says only Ublilinux supports the 40 pin connector.

    And likewise the installing kernel instructions: https://up-community.org/wiki/Ubuntu#Ubuntu_16.04.1_LTS_.28Xenial_Xerus.29

    The top part is for UP board, the UP2 part says... only Ublinux...
  • theodoros p
    theodoros p New Member Posts: 24
    Yes those posts I see to,and I think I’ll have to reinstall ubilinux and setup all my programming tools libs etc and quit the ubuntu for the moment...
  • hwooi
    hwooi New Member Posts: 1

    Hi, I have installed ubilinux on my up squared board, but what if I want to changed the OS installation to ubuntu and install on my board again? is it possible? is there any method for it? thank you.

  • ccalde
    ccalde New Member Posts: 348 ✭✭✭

    Hi @hwooi ,

    Please follow the Ubuntu steps to get the Ubuntu 16 and kernel 4,.15 running on your UP2:

    https://wiki.up-community.org/Ubuntu