Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux, Ubuntu, Raspbian (Raspberry Pi OS) installer #38

Closed
cparrapa opened this issue Jun 28, 2020 · 30 comments
Closed

Linux, Ubuntu, Raspbian (Raspberry Pi OS) installer #38

cparrapa opened this issue Jun 28, 2020 · 30 comments

Comments

@cparrapa
Copy link
Member

Separated from #9 as suggested by @mxochicale

@cparrapa cparrapa changed the title Linux and possible Raspberry Pi installer Linux, Ubuntu, Raspbian (Raspberry Pi OS) installer Jun 28, 2020
@cparrapa
Copy link
Member Author

Hola @mxochicale

Nuestro amigo @agomezgar ya hizo un gran progreso aquí https://github.com/agomezgar/masayloBlockly/tree/05e43fb3a85b9adc2c1ab78e9b46a361a9bdb510/linux

Lo puedes ensayar?

@mxochicale
Copy link

Wow, Gracias @cparrapa y @agomezgar :) Lo checo el pr'oximo fin de semana :)

@gitaroktato
Copy link
Contributor

Hi @mxochicale, is someone looking at this? Is there any progress? Are there any manual steps available for experimenting?

@mxochicale
Copy link

mxochicale commented Sep 7, 2020

Hi @gitaroktato

, is someone looking at this?

I am interested in this issue but only making little progress on my weekends.

Is there any progress? Are there any manual steps available for experimenting?

Antonio Gómez has made some progress here and waiting for some instructions stated here. Perhaps, if you don't want to wait, you can start having it a go :)

@gitaroktato
Copy link
Contributor

gitaroktato commented Sep 7, 2020

@mxochicale after bumping serialport dependency version to 8.0.4 the build was successful, but when running the application with npm install I get a blank screen. Any guidance on how I can fix this?

P.S.: If this works, I can submit a pull request.

@gitaroktato
Copy link
Contributor

It's not ready yet, but it's something. 👍

Screenshot from 2020-09-07 21-52-22

@mxochicale
Copy link

Great progress @gitaroktato

It would be nice that you add explicit instructions on how you are building it in Ubuntu plus the version and architecture of your GNU/Linux distro. Perhaps, this might be one example for the readme file. I would be more than happy to help to review it and test it on my machines.

@agomezgar
Copy link
Member

agomezgar commented Sep 7, 2020 via email

@gitaroktato
Copy link
Contributor

gitaroktato commented Sep 8, 2020

I'll just keep updating the issue, so someone can also take this further if I'm unable to.
You can track the progress by comparing master to my personal branch:
master...gitaroktato:linux_build

Runtime environment

  • Ubuntu 18.0.4.5 LTS
  • Linux kernel 4.15.0-112-generic
  • Node 10.22.0
  • npm 6.14.6

Steps taken so far

  • Make sure you're having Python 2.7 installed (I use miniconda to create a separate environment for building)
  • Make sure you have Node version > 10.0 (You can use a project called n for this purpose)
  • Change serialport version to 8.0.4 in package.json
  • Change build arguments for compiler and publier commands to --linux --x64, but I haven't used those.
  • Fix path locations in electronApp.js according to the changes above

Building the project
First, build & compile everything

npm install

Next, run the electron app

npm start

Debugging the app
Run the app in debug mode

npm run debug

Attach to the running process with VSCode

Also, you can bring up the developer console by hitting F8.

Update - 2020-09-08

The serial monitor functionality was not working. I suspect that somehow index.js was not loaded properly. When I build another blockly based project, the serial monitor window opens normally. The same is also true for the "Check the code" functionality.

This solved the issue: https://stackoverflow.com/a/55908510/8321787

Another problem was, that I had to add app.allowRendererProcessReuse = false to load a native serial library from the renderer.

Update - 2020-09-09

The serial library API changed, so tried to downgrade to an older version to see if it still compiles. This did not work, so I ended up changing the breaking methods from callback to Promise.
I had to import Arduino and Python binaries for Linux from the another blockly based project and refer to those in every exec() command in index.js

Everything seems to work now if I run the project with npm start. I have to wait for my Otto builder kit to arrive to test this for real 😉

image

Current issues

My branch is more like a POC. I totally suspect, that the changes are breaking Windows build, so I need to refactor my version and make the whole build multi-platform. Make it work, make it pretty.

I can't make a releasable package with npm run compiler because the directory structure is different. Have to introduce some kind-of configuration for these:
image

@gitaroktato
Copy link
Contributor

@agomezgar @mxochicale - could you please check out this branch and see if it works with the steps above?
All you need to do to run the application is an npm install followed by an npm start.

I can work on fixing the compiler and deb64 goals in the meantime.

@mxochicale
Copy link

mxochicale commented Sep 13, 2020

Great progress @gitaroktato

I have tried your linux_build branch in https://github.com/gitaroktato/blockly in my machine with Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic. I got the following error that might be related to some permissions. Any ideas on how to sort it out?

Screenshot from 2020-09-13 07-50-56

README

Additionally, perhaps you would like to create a README file in ~/compilation/dependencies/ where you can start adding the above instructions. I think such instructions are very important to allow other users to test your work. For example, you can add in that README file something like this:

## usage 
git clone https://github.com/gitaroktato/blockly
cd ~/blockly
git checkout linux_build 

## dependencies and requirements 
* You can use my README on how to setup a conda env
https://github.com/mxochicale/BlocklyDuino/tree/49afe53fbc62f06a5c342e334a13c6b46581246a/setup_arduino_web_server

* checking usb port 
ll /dev/serial/by-id/
624 lrwxrwxrwx 1 root root 13 Sep 13 07:37 usb-1a86_USB_Serial-if00-port0 -> ../../ttyUSB0

* Be more explicit in the installation of 
Node 10.22.0 # here some nice instructions https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04 
npm 6.14.6 # here some nice instructions  https://github.com/nvm-sh/nvm

Also the first time I run npm install I need to run `sudo chown -R $USER:$(id -gn $USER) /home/$USER/.config`

@mxochicale
Copy link

Thanks @agomezgar for such great effort and share your work

Slightly similar as above, and with the dependencies suggested by gitaroktato, I have tried your linux build in my machine with Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic by cloning https://github.com/agomezgar/blockly and I got the following error that might be related to some permissions. Any ideas on how to sort it out?

Screenshot from 2020-09-13 08-04-31

You might also like to create a README file as suggested above.

@agomezgar
Copy link
Member

I could solve (or so I think) the serial monitor problem, @gitaroktato . New versions of serialmonitor don't admit functions anymore. I.e., this old code:
sp.list(function(err,ports) { var nb_com = localStorage.getItem("nb_com"), menu_opt = portserie.getElementsByTagName('option') if(ports.length > nb_com){ ports.forEach(function(port){ if (port.vendorId){ var opt = document.createElement('option') opt.value = port.comName opt.text = port.comName portserie.appendChild(opt) localStorage.setItem("com",port.comName) } }) localStorage.setItem("nb_com",ports.length) localStorage.setItem("com",portserie.options[1].value) } if(ports.length < nb_com){ while(menu_opt[1]) { portserie.removeChild(menu_opt[1]) } localStorage.setItem("com","com") localStorage.setItem("nb_com",ports.length) }
Must be changed for something like:
sp.list().then(ports => { var nb_com = localStorage.getItem("nb_com"), menu_opt = portserie.getElementsByTagName('option') if(ports.length > nb_com){ ports.forEach(function(port){ if (port.vendorId){ var opt = document.createElement('option') opt.value = port.path opt.text = port.path portserie.appendChild(opt) localStorage.setItem("com",port.path) } }) localStorage.setItem("nb_com",ports.length) localStorage.setItem("com",portserie.options[1].value) } if(ports.length < nb_com){ while(menu_opt[1]) { portserie.removeChild(menu_opt[1]) } localStorage.setItem("com","com") localStorage.setItem("nb_com",ports.length) } });
You are right in other comment that you do, which is the different folder system related to Linux version. I solved it by creating a humble script that detects if it's the first time the application is being executed and then creating an auxiliary data folder into the home user directory, so we can avoid any permission problems.
Summary: many changes are needed. I have a first working Linux version here, in my own github. You can download an AppImage (portable version) here
SPAM I learned these things, in first place, analyzing @cparrapa work here and @fontainejp with blocklino. and secondly, creating my own graphical programming environment, MasayloBlockly, which allows you to program many types of robots as well as doing general programming jobs with Arduino.

@agomezgar
Copy link
Member

Thanks @agomezgar for such great effort and share your work

Slightly similar as above, and with the dependencies suggested by gitaroktato, I have tried your linux build in my machine with Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic by cloning https://github.com/agomezgar/blockly and I got the following error that might be related to some permissions. Any ideas on how to sort it out?

Screenshot from 2020-09-13 08-04-31

You might also like to create a README file as suggested above.

It seems to me that the app can't communicate with your Arduino. What model are you using? It's a nano 168? Because these model is not adapted yet. I'm working on this issue.

@agomezgar
Copy link
Member

agomezgar commented Sep 13, 2020

First question, really, should be: have you programmed an Arduino the usual way before you have tested this app?. Because, as I think you know, some Linux OS give some permission problems related to the DIALOUT group. If so, try opening your shell and typing:
sudo usermod -a -G dialout youruser
where youruser is the user name you are running the program with.

@mxochicale
Copy link

mxochicale commented Sep 13, 2020

First question, really, should be: have you programmed an Arduino the usual way before you have tested this app?. Because, as I think you know, some Linux OS give some permission problems related to the DIALOUT group. If so, try opening your shell and typing:
sudo usermod -a -G dialout youruser
where youruser is the user name you are running the program with.

Many thanks @agomezgar

Good news OttoDIY/blockly is now working on my Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic. I just need to chose Arduino Nano instead of "Arduino Nano (old bootloader)"
Screenshot from 2020-09-13 08-30-10

Thanks for the hint on testing nano with arduino app. I did test nano with arduino app with Board: Arduino Nano; Processor: ATMega328P; Port:/dev/ttyUSB0. For the record, see the terminal output for the ttyUSB0 port

ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Sep 13 08:21 /dev/ttyUSB0

PS. I guess next step is to create a branch for linux_build in OttoDIY/blockly (to avoid conflict with others OS) where you can add a README with some instructions for the dependencies, usage, and installations steps. Happy to help with reviews and tests of such PR.

@agomezgar
Copy link
Member

First question, really, should be: have you programmed an Arduino the usual way before you have tested this app?. Because, as I think you know, some Linux OS give some permission problems related to the DIALOUT group. If so, try opening your shell and typing:
sudo usermod -a -G dialout youruser
where youruser is the user name you are running the program with.

Many thanks @agomezgar

Good news OttoDIY/blockly is now working on my Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic. I just need to chose Arduino Nano instead of "Arduino Nano (old bootloader)"
Screenshot from 2020-09-13 08-30-10

Thanks for the hint on testing nano with arduino app. I did test nano with arduino app with Board: Arduino Nano; Processor: ATMega328P; Port:/dev/ttyUSB0. For the record, see the terminal output for the ttyUSB0 port

ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Sep 13 08:21 /dev/ttyUSB0

PS. I guess next step is to create a branch for linux_build in OttoDIY/blockly (to avoid conflict with others OS) where you can add a README with some instructions for the dependencies, usage, and installations steps. Happy to help with reviews and tests of such PR.

Those are great news!. You know? You're the first one who test the program apart from me. I am really happy that it works for you. Your suggestions, on the other hand, are welcome, and I am working on it.

@mxochicale
Copy link

mxochicale commented Sep 13, 2020

First question, really, should be: have you programmed an Arduino the usual way before you have tested this app?.

PS. I guess next step is to create a branch for linux_build in OttoDIY/blockly (to avoid conflict with others OS) where you can add a README with some instructions for the dependencies, usage, and installations steps. Happy to help with reviews and tests of such PR.

Those are great news!. You know? You're the first one who test the program apart from me. I am really happy that it works for you. Your suggestions, on the other hand, are welcome, and I am working on it.

Very happy to help. My suggestion is that you create a new branch called linux_build in your https://github.com/agomezgar/blockly and add detailed instructions for the linux_build and then you can create a new PR and ask for reviews to us. I am saying that because your #52 in the master branch might create conflicts to the build in windows.

PS just forked your work and created linux_build branch and added few instructions to get you an idea of such details. It would be also good that you add GNU/Linux distribution and kernel as your work might be used/tested in other distributions of GNU/Linux and kernel versions.

@gitaroktato
Copy link
Contributor

gitaroktato commented Sep 13, 2020

@agomezgar many thanks for all the help, basically everything I did was based on your work in masayloBlocklyLinux

I went ahead and added all the features to support Linux and Windows builds in the same repo. For this, I've separated the compilation folder's content in compilation/linux, compilation/win32 subfolders and added helper functions in the electronApp.js
These helper functions change paths for HTML files and executables based on OS and development/production mode.

I've added separate build commands for Linux and Windows binaries in package.json

What should work by now:
npm run debug and npm start runs the application in development mode, all without renaming paths manually. This should be both OK in Windows and Linux

npm run compiler-linux creates a Linux binary
npm run compiler-win creates a Windows binary

Please check my changes and just let me know how I can help:
Repo URL: https://github.com/gitaroktato/blockly/blob/linux_build
Diff: master...gitaroktato:linux_build

@agomezgar
Copy link
Member

It's what i'd planned to do in the next future... I'll check the code, @gitaroktato . Thanks a lot

@mxochicale
Copy link

Such a great job @agomezgar and @gitaroktato :)

In terms of workflow, perhaps you might like to mention that users have this branch https://github.com/OttoDIY/blockly/tree/versionlinux where other people can send PRs to contribute to the documentation and test in other GNU/Linux distributions.

@cparrapa
Copy link
Member Author

cparrapa commented Sep 21, 2020

awesome @agomezgar and @gitaroktato thanks a lot!
@mxochicale mention where? so i think all the steps to install should be in the readme of this branch

@mxochicale
Copy link

Hi @cparrapa

Re:

@mxochicale mention where? so i think all the steps to install should be in the readme of this branch

You might like to add few lines in the README of the master branch to mention that the branch of versionlinux is ready for other people to test their robot using, at least, Ubuntu 18.04 or 20.04 : )

@mxochicale
Copy link

Hi @cparrapa @agomezgar and @gitaroktato

I have noticed that the version of OttoBlockly for versionlinux is v1.0.0. You might like to update it to its latest version 1.3.0. Perhaps, for future versions, such as 1.4.0, you might like to include in the changelog that OttoBlockly works for both windows and Ubuntu.

Thanks
Miguel

@mxochicale mxochicale reopened this Nov 15, 2020
@cparrapa
Copy link
Member Author

Hi @mxochicale

I am really lost of how it work the linux version so not sure how to do a proper readme.
Did it work for you what are the steps to install it?

No idea why is in a different version than Windows maybe is as @agomezgar established? or technically is the same 1.3.0. Blockly
We are working in 1.4.0. but there is is a lot to handle how could we for examaple reflect the changes on the linux version?

Thanks!

@mxochicale
Copy link

Re: 1.3.0. Blockly mentioned above, I realised that your version 1.3.0 is showing 1.0.0:

"version": "1.0.0",

Perhaps, a minor changes has to be made to fix the appropriate version.

mxochicale added a commit to mxochicale/blockly that referenced this issue Dec 13, 2020
@cparrapa
Copy link
Member Author

Hi @mxochicale

You are right so we make them match versions
Thanks

gitaroktato added a commit to gitaroktato/blockly that referenced this issue Dec 16, 2020
Added USB connectivity setting necessary for some of the Linux distribution mentioned in OttoDIY#38 (comment)
@mxochicale
Copy link

Hi @cparrapa

It great to see the new version blockly with lots of nice new features https://github.com/OttoDIY/blockly/releases/tag/v1.4.0. Which makes me wonder: does blockly version 1.4.0 has been tested on its linuxversion counterpart?. If yes or not, I guess, you might like to close this issue and perhaps users can open new issues such as

  • Otto_blockly_v1.4.0 in Ubuntu18.04
  • Otto_blockly_v1.4.0 in Ubuntu20.04
  • Otto_blockly_v1.4.0 in Raspberry PI OS, etc

Thanks
Miguel

@cparrapa
Copy link
Member Author

Hi @mxochicale

Glad you like them, unfortunately i do not have a computer with Linux to test it, i tried to install an ubuntu to an old laptop but it turn out to be even slower after flashing.

I was hoping you can test and somehow translate the changes to the Linux branch, it should be quite smooth.

Do you think is possible, I have some Raspberry PI also but no idea where to start?

I will close this issue then since it has been solved in this branch https://github.com/OttoDIY/blockly/tree/versionlinux

Thanks

@mxochicale
Copy link

Hi guys

just saw the amazing work of @agomezgar for the OttoBlockly Linux Version 1.4.2. (x64)

@agomezgar perhaps you would like to create a PR and update the current documentation of your work with the new version. It is always good to have a good documentation to allow the community to replicate your work. Happy to test your last version and review your PR if that is helpful.

Thanks
Miguel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants