Serial port unavaliable arduino - linux

Trying to upload a code to arduino, but whether in the Arduino IDE or Arduino Create, both return this erro while uploading. Running on Linux Tara(mint 19 cinnamon).
./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:avr:mega:cpu=atmega2560 -build-cache /tmp -build-path /tmp/716441957/build -verbose -libraries /tmp/716441957/custom -libraries /tmp/716441957/pinned /tmp/716441957/sketch_oct8a
Sketch uses 8280 bytes (3%) of program storage space. Maximum is 253952 bytes.
Global variables use 443 bytes (5%) of dynamic memory, leaving 7749 bytes for local variables. Maximum is 8192 bytes.
Programming with: Serial
Flashing with command:/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/bin/avrdude -C/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/etc/avrdude.conf -q -q -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino-create-agent734074237/sketch_oct8a.hex:i
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device
ioctl("TIOCMGET"): Inappropriate ioctl for device

1#
First, check the port in your IDE. In Arduino tools->port
If the port is hidden or you can not move the cursor over this then run this commands in your terminal.If everything ok then skips this and follow the second part.
sudo apt-get install librxtx-java -y
sudo usermod -aG dialout $USER
sudo apt-get install gnome-system-tools
2#
After this again check the first method. If it is not working then run this commands
ls -l /dev/ttyACM*
sudo usermod -a -G dialout <username>

You probably have another program running which is already using this port.
You should close most other programs like putty or another serial monitor app.
Otherwise, try to reconnect the Arduino to the PC.

I know that these ideas below come from using a Teensy, but they may help you.
Sometimes there are the ACM* ports listed in the Arduino IDE. Try looking at the ser ports. I know when I am running my Teensy, sometimes I have them switched and need to select the correct one.
Also, from my experience with the Teensy, you might need to add a udev rule to allow permissions to access the port from non-root user. Here is the link that shows the udev file.

There is no direct way to solve this issue. In addition to it, you are not using an IDE. I will list the things you need to check, I am sure this will solve your problem.
I am not good at Linux environment so I will refer to applications names as window, you go the corresponding application in Linux.
Go to linux device manager and see for your arduino board. It should have proper naming like "arduino uno at port 3", then use the correct port in your command. If this name does not come properly then it means Driver is not available in your machine. So, go to step2.
Find the driver online and install it in your system, I am not sure about the support of linux with arduino, once it is done please repeat step1.
So, I conclude in short that you do not have the proper driver (which is strongly believe) or pointing the wrong port. I am not an expert with the udev rules, but it is definitely an issue you can experience with these kinds of micro-controllers.

Related

How Port Linux onto MAIXDUINO board with Kendryte K210 core?

I am trying to port Linux OS onto the maixduino board as RISC-V resources say that Linux can be ported onto the Kendryte K210 core. I am using the binary file from https://dl.sipeed.com/MAIX/MaixLinux/Firmware and using kflash in the terminal of my Ubuntu machine to try flash it onto the board using the command
kflash -p /dev/ttyUSB0 -b 115200 -B maixduino Maix-linux-5.6-rc1.bin
Afterwhich I get ‘FileNotFoundError’ not defined line:
[INFO] COM Port Selected Manually: /dev/ttyUSB0
[INFO] Default baudrate is 115200 , later it may be changed to the value you set.
global name ‘FileNotFoundError’ is not defined
Does anyone know what i am doing wrong?
$ sudo pip3 install kflash
you must add yourself to dialout group as follows or you have to use sudo every time
$ sudo usermod -a -G dialout $(whoami)
You can try Kflash GUI:
use the below Kflash gui tool as mentioned below where you can manually change board settings and serial settings
https://github.com/sipeed/kflash_gui
Make sure that hardware connections are proper and try with low baud rate, check the USB device name usually represented by ttyUSB*

Serial Ports Linux vs Windows

I am having issues with my pyserial program on Ubuntu 16.
I am trying to send a break command to a hardware device using pyserial. I wrote a python script that:
Sets the port/baud/parity/bytesize/...
Opens the port
Sends a break command
Reads the return message from the device.
I run the script on my Ubuntu 16.04 machine and I get zero response, it just hangs or eventually timeouts. I copy the same script to my Windows machine, change the port (from /dev/ttyUSB0 to COM#) and my script works perfectly, gets a response from the device immediately.
When I run the script on Ubunutu I have to give permissions to the port (sudo chmod 666 /dev/ttyUSB), or I get permission denied errors when opening the port. Not sure if this matters.
Does anyone have any insight on what might be going on? I know Windows and Linux handle serial/com ports differently but I am a newbie to both Linux and serial so not sure if I am missing something.
I am using this USB to Serial cable (http://www.ugreen.com.cn/product-681-en.html) and I had to install some drivers. I connected the serial read/write pins and tested to make sure data is going through (which it is) so I know that works.
import serial
ser = serial.Serial()
ser.port = '/dev/ttyUSB0' # or COM12 on windows
ser.baudrate = 9600
ser.parity = serial.PARITY_NONE
ser.bytesize = serial.EIGHTBITS
ser.stopbits = serial.STOPBITS_ONE
ser.open()
ser.send_break(duration=0.9)
print(ser.read(10))
First off, you need to have proper permissions for accessing serial ports. It can be done by including your user into the group dialout:
sudo usermod -aG dialout <user>
You need to restart the system to complete it.
To avoid of some information to remain in buffers, you may need to clear read and write buffers before serial port operations:
pyserial 3.0:
ser.reset_input_buffer()
ser.reset_output_buffer()
pyserial 2.7 or earlier:
ser.flushInput()
ser.flushOutput()
Don't forget to close a port after all operations being done. Hope this helps.
First forget about your app and focus on the port troubleshooting, use putty in serial mode for sending a few terminal chars using this port. Use a jumper for conecting DB9 pin 3 to pin 2(rx and tx) an validate that you receive an echo of each character you type.

Trouble locating my serial ports using bash on Windows 10

I want to be able to read from serial ports on my computer and write to a file. Inside /dev (using Bash shell on Windows 10) I can't seem to locate my USB serial ports (I have tty, tty0, tty1, and that's it for tty).
Is it located somewhere else, or even accessible through the bash shell? I just want to be able to know how to access it at this point.
In device manager, COM4 shows up under ports when I plug in my USB. I also ran the command wmic path Win32_SerialPort in the Windows command prompt and it said "No Instance(s) Available." So I'm very confused as to how I can view my Serial Ports and why they aren't showing up in certain instances.
Any clarification on how serial ports work, especially with USB, would be greatly appreciated, as I am pretty new with this stuff.
Soon, Windows will officially support serial on the Windows Subsystem for Linux (WSL). The COM_n_ ports will be available at /dev/ttyS_n_
Mapping:
COM1 >> /dev/ttyS0
COM2 >> /dev/ttyS1
...
COM192 >> /dev/ttyS191
A good functional description can be found here:
https://blogs.msdn.microsoft.com/wsl/2017/04/14/serial-support-on-the-windows-subsystem-for-linux/
NOTE: At time of writing this feature is only available on the insider builds.
I have the same problem. Apparently you still can`t use serial ports in Bash on Ubuntu on Windows (BoUoW).
You can do basic read and write operations using socat. I used Cygwin to create a socat server that sees my serial ports. I had problems with DTR and RTS pins though.
With socat you can create virtual serial ports or forward a serial port over TCP. (And much more.)
In Cygwin serial ports are listed under /dev/ as ttyS*.
For example COM3 is /dev/ttyS2 and COM4 is /dev/ttyS3.
Start the server in Cygwin with
socat -d -d -d TCP4-LISTEN:2022,reuseaddr,fork /dev/ttyS3
Start the client on BoUoW with
socat PTY,link=/tmp/vmodem0 TCP:localhost:2022
This will create a virtual serial port in BoUoW at /tmp/vmodem0 that is connected to COM4 on your machine.

How do I deploy code to hardware nodes that are all on seperate networks?

This is an interesting problem I've been thinking about recently and have not come up with or found a solution that I find acceptable.
I'm playing with Raspberry Pi's and have 6 currently that I want to use throughout a few of my personal properties for surveillance purposes.
Making them work and sending video streams to my server is all easy, well and good - but how in the world do I deploy code updates to these "nodes" that are not on the same network, some are behind wi-fi networks that I don't have port forwarding access to also, so it's not like I can just post forward and SSH into them and run some .sh magic to update things.
The best I've come up with is using autossh to keep a constant, connection open to one of my servers through reverse ssh, and then ssh in to them through my parent server in parallel and running a .sh script on them when I want to update.. But this seems overly excessive and I'm sure there's some solution or platform out there that exists to solve this - how else do companies like Redbox or Nest for example update firmware on their systems remotely?
I'm actually doing something similar. I have Pi's deployed around the city that I live in. In order to not have to worry about port-forwarding and people changing their router configurations, I started using a service called Pagekite http://pagekite.net/
I'm not affiliated with them, but I can't say enough good things about the service and price. My Pi's are hooked up to screens that need to display certain things at certain times, and I'm able to VNC in very easily no matter where the Pi is to see what's currently playing. I can obviously just ssh in as well.
The following steps from my pi setup guide deal with installing pagekite and getting it to start on boot:
echo deb http://pagekite.net/pk/deb/ pagekite main | sudo tee -a /etc/apt/sources.list
sudo apt-key adv --recv-keys --keyserver keys.gnupg.net AED248B1C7B2CAC3
sudo apt-get update
sudo apt-get install pagekite
sudo leafpad /etc/pagekite.d/10_account.rc
Replace NAME.pagekite.me with the name of the kite
Replace YOURSECRET with whatever the secret is from the pagekite admin console
Remove the line “abort_not_configured” and the comment above it
sudo cp /etc/pagekite.d/80_sshd.rc.sample /etc/pagekite.d/80_sshd.rc
sudo invoke-rc.d pagekite restart
sudo reboot
This assumes you've made an account and setup a "kite"
I think you basically need a reliable reverse tunnel such as Pagekite, especially if you plan on expanding your network, as it will turn into a nightmare at a certain size. I believe I'm just going to keep a list of ssh usernames, ssh passwords, and pagekite addresses, then write a script that loops through them and rsync's my local directory with the new code to the remote directory on the pi.

Unable to lock chain (Insufficient port permissions)

I am new to Linux , and I am trying to install AlteraQuartus 2 WEb Edition and NIOS2 EDS to play with Nios2 Processor.
However , after installing Quartus and when I am trying to execute jtagconfig.
I do not see something like below , even after running /altera/nios2eds/nios2_command_shell.sh
1.)[Nios2 EDS] $
2.) Unable to lock chain (Insufficient port permissions)
Please Help,
To check if this is indeed a port permission problem, start the trouble-shooting by running jtagd (the deamon between the Altera tool and the driver) as root. At first, you must make sure that jtagd is not running, since if it is already running as a user, trying to start it as root will have no effect.
$ sudo killall -9 jtagd # Kill jtagd, ...
$ sudo killall -9 jtagd # ...and verify jtagd is indeed not running.
jtagd: no process found # Good, verified.
$ sudo jtagconfig # Will also start jtagd as root
1) CV SoCKit [2-1]
02D020DD 5CSEBA6(.|ES)/5CSEMA6/..
4BA00477 SOCVHPS
If the above is successful, this is indeed a port permission problem. To fix it permanently, try with udev rules, as suggested by #eepp.
(On a side note, jtagd will be started by jtagconfig if not already running, as the same user that started jtagd. Hence #eepps command will work as well, but jtagd should be killed first.)
For further trouble-shooting, running jtagd with some debug command-line options can give useful information:
$ jtagd --foreground --debug
JTAG daemon started
Using config file /etc/jtagd/jtagd.conf
Remote JTAG permitted when password set
Cant bind to TCP port 1309 - exiting
(The above error message is typical if jtagd is already running.)
(Above is taken från http://www.fpga-dev.com/altera-usb-blaster-with-ubuntu/. See that page for more details.)
"Insufficient permissions" or "permission denied" or whatever relating to not having permissions on *nix usually means you must run the command as user root (or as another user who has the permissions, but root has all of them).
So run jtagconfig as root:
$ sudo jtagconfig
Alternatively, as root, put this in a new file /etc/udev/rules.d/51-altera-usb-blaster.rules:
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6002", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6003", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6010", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6810", MODE="0666"
and then, run:
$ sudo udevadm control --reload
This should change the permission of your USB-Blaster Download Cable device so that any user may access it (if this is what you want), so you should be able to issue jtagconfig without sudo. Those five idProducts are all the known USB-Blaster Download Cable USB product IDs (for the Altera vendor ID, 0x09fb).
I wrote a fairly complete Arch Linux wiki page about Altera softwares on Linux if you want more details.
It may be obvious but make sure you're not going through a USB hub. That was my problem for Altera DE2-115 with Quartus Prime Lite 20.1.1 on Ubuntu 20.04.
The above answers fixed my permissions issue (Specifically adding ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", MODE="0666" to the new file /etc/udev/rules.d/51-altera-usb-blaster.rules).
But I was still getting.
1) USB-Blaster [1-2.1]
unable to lock chain - Chain in use - check
Going straight to my PC solved it.

Resources