Nano Pi R2S Status LEDS Configuration - linux

I have a Nano Pi R2S on Ubuntu 20.04 and I am trying to configure the WAN and LAN led of the unit. Please excuse my low skill set. According to the guide (https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R2S#Config_status_LEDs) I need to put the following into a auto run script.
echo netdev > /sys/class/leds/wan_led/trigger
echo eth0 > /sys/class/leds/wan_led/device_name
echo 1 > /sys/class/leds/wan_led/link
echo netdev > /sys/class/leds/lan_led/trigger
echo eth1 > /sys/class/leds/lan_led/device_name
echo 1 > /sys/class/leds/lan_led/link
Here is my ledstatus.sh
#!/bin/bash
echo netdev > /sys/class/leds/wan_led/trigger
echo eth0 > /sys/class/leds/wan_led/device_name
echo 1 > /sys/class/leds/wan_led/link
echo netdev > /sys/class/leds/lan_led/trigger
echo eth1 > /sys/class/leds/lan_led/device_name
echo 1 > /sys/class/leds/lan_led/link
This is my errors.
./statusled.sh: line 3: echo: write error: Invalid argument
./statusled.sh: line 4: /sys/class/leds/wan_led/device_name: Permission denied
./statusled.sh: line 5: /sys/class/leds/wan_led/link: Permission denied
./statusled.sh: line 7: echo: write error: Invalid argument
./statusled.sh: line 8: /sys/class/leds/lan_led/device_name: Permission denied
./statusled.sh: line 9: /sys/class/leds/lan_led/link: Permission denied

Same issue but fixed, invalid argument here is not invalid for echo, but for the file /sys/class/leds/wan_led/trigger.
The trigger needs a specific value, you can run cat /sys/class/leds/wan_led/trigger to see all valid value, as for the output of cat: the [value] is selected, and the others are options,you must echo one of them, or you got "invalid "

Related

How do you disable cores on an RPi running Ubuntu 18.04?

Everything done below has been as the root user.
I tried the solution stated here and got this:
$ echo 0 > /sys/devices/system/cpu/online
bash: /sys/devices/system/cpu/online: Permission denied
I then changed the permissions on /sys/devices/system/cpu/online and got this:
$ sudo chmod 777 /sys/devices/system/cpu/online
$ echo 0 > /sys/devices/system/cpu/online
bash: echo: write error: Input/output error
This raspberrypi forum does not help since there is no /boot/cmdline.txt file.
The file /sys/devices/system/cpu/online contains the text: 0-3 and the file /sys/devices/system/cpu/offline contains nothing, so I assume that:
0 in sys/devices/system/cpu/online means only core 0 is online, 0-1 means cores 0 and 1 are online, etc. I've also tried the above commands with 0-1 instead of 0 and got the same results.

How do i fix bash error - /dev/tty No such device or address

As the question specifics ,i am getting this error while executing my bash script
In exact terms i get following error
bash: line 26: /dev/tty: No such device or address
bash: line 29: /dev/tty: No such device or address
Here are the concerned Line 26 and 29 in script respectively which causes the issue
read -e -p "Paste the links : " links </dev/tty
read -e -p "Enter your input : " sub </dev/tty
If someone wonders, i cannot simply remove writing to </dev/tty from line 26 and 29 , it causes different issues .. So basically i need fix or get alternative for writing to /dev/tty
I am executing my script by running -
curl raw_link | bash
Preferably i want a solution which only requires me to my edit my existing script .i don't want to run the script after saving it locally or execute it using any other way apart from curl raw_link | bash
ls -l /dev/tty returns the following
crw-rw-rw- 1 root root 5, 0 Aug 8 09:28 /dev/tty
ls -l </dev/tty returns the following
/bin/bash: /dev/tty: No such device or address
Also i would like to mention that this issue doesn't seem to be happening on every machine , i intend to use this script on Google Colab where i definitely do get this issue
To fix the bash error, you can try this workaround :
tty=$(readlink /proc/$$/fd/2)
read ... < $tty
$tty contains the actual tty device name.

write error: Invalid argument using linux remoteproc on BeagleBone Black

I have been trying to further understand the Sitara Am335x PRUs and I tried to follow the TI labs on how to get started with Programmable real-time units on the BeagleBone Black and but I encountred this problem that I couldn't overcome;
sudo -i
cp /home/debian/pru_blinky.out /lib/firmware/pru_blinky
cd /sys/class/remoteproc/remoteproc1
echo 'pru_blinky' > firmware
but when I type echo 'start' > state I get the following error
this is the return of man echo
NAME
echo - display a line of text
SYNOPSIS
echo [SHORT-OPTION]... [STRING]...
echo LONG-OPTION
DESCRIPTION
Echo the STRING(s) to standard output.
-n do not output the trailing newline
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
--help display this help and exit
--version
output version information and exit
-bash: echo: write error: Invalid argument
I tried to to specify the directory and file with command: echo 'pru_blinky/pru_blinky.out' > firmware but still problem not solved
can anyone explain to me what am i doing wrong here

error in executing loadui test in Linux: "loadUI-cmd.sh: ...syntax error near unexpected token `in"

This is my shell command line in linux:
.../loadUI-cmd.sh -J-Djava.awt.headless=true -p /.../loadui_basicPTproject.xml -r /.../PT_reports -F PDF
and this is output (error):
: command not found/SmartBear/LoadUI-2.6.8/loadUI-cmd.sh: line 10:
: command not found/SmartBear/LoadUI-2.6.8/loadUI-cmd.sh: line 12:
: command not found/SmartBear/LoadUI-2.6.8/loadUI-cmd.sh: line 14:
'home/bbiixli/tools/SmartBear/LoadUI-2.6.8/loadUI-cmd.sh: line 15: syntax error near unexpected token `in
'home/bbiixli/tools/SmartBear/LoadUI-2.6.8/loadUI-cmd.sh: line 15: `case "`uname`" in
Note: loadUI-cmd.sh script is "come with the product". The script content is below (the top 2 lines added by me for avoid running the script with unix format error.
### the below line was added for linux env 052114
:set fileformat=unix
###!/bin/sh
### ====================================================================== ###
## ##
## loadUI Agent Bootstrap Script ##
## ##
### ====================================================================== ###
### $Id$ ###
DIRNAME=`dirname $0`
# OS specific support (must be 'true' or 'false').
cygwin=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;
esac
# Setup LOADUI_HOME
if [ "x$LOADUI_HOME" = "x" ]
then
# get the full path (without any relative bits)
LOADUI_HOME=`cd $DIRNAME/; pwd`
fi
export LOADUI_HOME
LOADUI_CLASSPATH="$LOADUI_HOME:$LOADUI_HOME/lib/*"
# For Cygwin, switch paths to Windows format before running java
if $cygwin
then
LOADUI_HOME=`cygpath --path -w "$LOADUI_HOME"`
LOADUI_CLASSPATH=`cygpath --path -w "$LOADUI_CLASSPATH"`
fi
JAVA="jre/bin/java"
if [ ! -f "$JAVA" ]; then
JAVA="java"
fi
JAVA_OPTS="-Xms128m -Xmx768m -XX:MaxPermSize=128m"
$JAVA $JAVA_OPTS -cp "$LOADUI_CLASSPATH" com.javafx.main.Main --cmd=true --nofx=true -nofx - Dlog4j.configuration=log4j_headless.xml "$#"
Anyone can Help me on this problem?
Thanks,
Larry
It seems your file has DOS style line ending characters. Fix that using the dos2unix command if your system has it. If you don't have it, you can do like this:
tr -d '\r' < script.sh > fixed.sh
mv fixed.sh script.sh
chmod +x script.sh
After this, change the first line to:
#!/bin/sh
Then it should work.

Cannot change hostname on raspberry pi

Error writting /ect/hostname: no such file or directory
I am currently getting that error when I follow How to change raspberry pi hostname
When I type sudo nano /etc/hosts I get a blank file, and when I type sudo nano /etc/hostname I also get a blank file. I have tried to save the new hostname in /ect/hostname but I get the error above. I am not a linux user normally so I don't know what else to do.
According to raspi-config you need to do these 3 steps
Replace /etc/hostname with you new hostname
Edit /etc/hosts to replace 127.0.1.1 $CURRENT_HOSTNAME 127.0.1.1 $NEW_HOSTNAME
MUST reboot to see effect
This can be done quickly via below:
sudo raspi-config nonint do_hostname ${NEW_HOSTNAME}
sudo reboot # Must reboot to see change
This is since raspi-config is a bash script and has a noninteractive mode you can use. Of which as of now, this is what we are trying to trigger below:
do_hostname() {
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "\
Please note: RFCs mandate that a hostname's labels \
may contain only the ASCII letters 'a' through 'z' (case-insensitive),
the digits '0' through '9', and the hyphen.
Hostname labels cannot begin or end with a hyphen.
No other symbols, punctuation characters, or blank spaces are permitted.\
" 20 70 1
fi
CURRENT_HOSTNAME=`cat /etc/hostname | tr -d " \t\n\r"`
if [ "$INTERACTIVE" = True ]; then
NEW_HOSTNAME=$(whiptail --inputbox "Please enter a hostname" 20 60 "$CURRENT_HOSTNAME" 3>&1 1>&2 2>&3)
else
NEW_HOSTNAME=$1
true
fi
if [ $? -eq 0 ]; then
echo $NEW_HOSTNAME > /etc/hostname
sed -i "s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\t$NEW_HOSTNAME/g" /etc/hosts
ASK_TO_REBOOT=1
fi
}

Resources