unexport doesn't work on BBB GPIOs - beagleboneblack

When entering the /sys/class/gpio/ directory on a beagle bone running Linux beaglebone 4.9.82-ti-r102 #1 SMP PREEMPT Thu Feb 22 01:16:12 UTC 2018 armv7l, already several GPIOs get displayed, without me exporting them first. Trying to unexport them by using sudo echo gpio30 > unexport results in echo: write error: Invalid argument.
Why are all the GPIOs already exportet on BBB?
Why can't I unexport them?
What would be the best way to control those GPIO from a C++/C program? Should I really use ofstream? Or is there a different interfacing-lib already installed on my BBB?

Related

uwsgi upgrade to python3.7 to fix ImportError: No module named 'encodings'

Honestly, I have no idea what I am doing, so be gentle with me. I am trying to use uwsgi to run my django application on a aws ubuntu instance. I have a virtual environment with python3.7 running, but when I try to run uwsgi. I get this in the logs:
*** Starting uWSGI 2.0.14 (64bit) on [Sun Jan 5 14:51:32 2020] ***
compiled with version: 5.4.0 20160609 on 20 October 2016 05:56:34
os: Linux-4.4.0-109-generic #132-Ubuntu SMP Tue Jan 9 19:52:39 UTC 2018
nodename: ip-172-31-41-139
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /home/ubuntu/web/graff
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3804
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /home/ubuntu/web/graffuwsgi.sock fd 3
Python version: 3.5.2 (default, Oct 8 2019, 13:06:37) [GCC 5.4.0 20160609]
Set PythonHome to /home/ubuntu/.virtualenvs/graff
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Here is my uwsgi.conf
# file: /etc/init/graffuwsgi.conf
description "uWSGI server for graff"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/local/bin/uwsgi --home /home/ubuntu/web/graff/ --socket /home/ubuntu/web/graffuwsgi.sock --chmod-socket=666 --module=graff.wsgi --pythonpath /home/ubuntu/web -H /home/ubuntu/.virtualenvs/graff --logto /home/ubuntu/web/logs/graffuwsgi.log --chdir=/home/ubuntu/web/graff --chmod-socket=666
It seems like python3.5 just doesn't work anymore. I feel like I've had to replace python3.5 with 3.7 in several places lately to fix various bugs, and I have it in my head that if I can get uwsgi to run python3.7 instead of 3.5 then that will solve this error too. Anyway, any help is much appreciated.
Looks like your uwsgi is compiled with different python version, make sure you compile with python 3.5
PYTHON=python3.5 uwsgi --build-plugin "/usr/src/uwsgi/plugins/python python35"
mv python35_plugin.so /usr/lib/uwsgi/plugins/python35_plugin.so
chmod 644 /usr/lib/uwsgi/plugins/python35_plugin.so
you can follow this guide:
https://www.paulox.net/2017/04/04/how-to-use-uwsgi-with-python3-6-in-ubuntu/
The source of error is PythonHome (pyhome, venv, home) setting.
See at the official Python docs on Environment variables
Is your path /home/ubuntu/.virtualenvs/graff suited for Python requirements?
In short:
Use pythonpath (pp) and let the system to find modules.
You can set several repeated options in your uwsgi config to custom modules search, eg:
pythonpath = /opt/web2py/
pythonpath = /opt/anaconda/lib/python3.9/site-packages/
So, I had the same error. And it was fixed by editing uwsgi vassal config.
I thing the core of problem that virtual envs are created with symlinks or have some inner relative paths, so an isolated process inside uwsgi could not find modules.

Buildroot - RPI3 - Find the BCM43438 firmware to enable wireless

i'm a beginner.
i use a RPI3 and a buildroot build system and try to enable wireless.
I followed several links without success.
In particulary, i followed this link : https://delog.wordpress.com/2014/10/10/wireless-on-raspberry-pi-with-buildroot/
and verify my linux kernel wireless options are activated, but no results.
However, the options i used on the buildroot . config file seems to be good :
debian-host:/build/buildroot# egrep -i "wireless|wpa|80211" .config
# BR2_PACKAGE_WIRELESS_REGDB is not set
BR2_PACKAGE_WIRELESS_TOOLS=y
BR2_PACKAGE_WIRELESS_TOOLS_LIB=y
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_NL80211=y
BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y
BR2_PACKAGE_WPA_SUPPLICANT_WIFI_DISPLAY=y
# BR2_PACKAGE_WPA_SUPPLICANT_MESH_NETWORKING is not set
BR2_PACKAGE_WPA_SUPPLICANT_AUTOSCAN=y
BR2_PACKAGE_WPA_SUPPLICANT_EAP=y
BR2_PACKAGE_WPA_SUPPLICANT_HOTSPOT=y
BR2_PACKAGE_WPA_SUPPLICANT_DEBUG_SYSLOG=y
BR2_PACKAGE_WPA_SUPPLICANT_WPS=y
BR2_PACKAGE_WPA_SUPPLICANT_CLI=y
BR2_PACKAGE_WPA_SUPPLICANT_WPA_CLIENT_SO=y
BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y
# BR2_PACKAGE_WPA_SUPPLICANT_DBUS_OLD is not set
# BR2_PACKAGE_WPA_SUPPLICANT_DBUS_NEW is not set
BR2_PACKAGE_WPAN_TOOLS=y
I installed a minibian an another rpi3, i noticed a firmware was used and i installed it by a :
apt-get install firmware-brcm80211
If the firmware is not installed, I noticed that iwlist wlan0 scan have empty results. On my RPI3-buildroot-system, after booting, lsmod show no modules.
I need to load manually by modprobe or by /etc/modules. So i load the same modules used on minibian, so i did (i loaded bluetooth mods also)
uname -a
Linux pi3 4.9.13-rt12-v7 #1 SMP Mon Mar 20 14:04:21 CET 2017 armv7l GNU/Linux
pwd
/lib/modules/4.9.13-rt12-v7/kernel/drivers
find . -name "*brcm*.ko"
./net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko
./net/wireless/broadcom/brcm80211/brcmutil/brcmutil.ko
modprobe 8192cu
modprobe brcmfmac
modprobe brcmutil
modprobe hci_uart
modprobe bnep
and the lsmod show :
lsmod
Module Size Used by Not tainted
8192cu 581125 0
hci_uart 19956 0
btbcm 7992 1 hci_uart
bnep 12051 0
bluetooth 364941 3 hci_uart,btbcm,bnep
brcmfmac 222136 0
brcmutil 9156 1 brcmfmac
cfg80211 543530 1 brcmfmac
rfkill 20944 2 bluetooth,cfg80211
ipv6 405794 18 [permanent]
but
iwlist wlan0 scan
wlan0 Interface doesn't support scanning.
I don't arrive to have the same result as my minibian distro with my apt-get ..
What is the way to retrieve the buildroot process to have the same result that on my minibian ?
I've forget something ?
Thanks for helping me.
When using make menuconfig, enable rpi-wifi-firmware under Target packages > Hardware handling > Firmware to include the firmware files.
For WiFi on the Raspberry Pi, you need to enable the following packages in your defconfig file :
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_RPI_WIFI_FIRMWARE=y
If you want to reference any other things, I have an older buildroot external tree here for the Raspberry Pi.

Error while trying to enter sleep mode in Beagle Bone Black

While trying to enter sleep mode on beaglebone black am getting an error
When i issue the command echo -n "mem" > /sys/power/state am getting
-sh: echo: write error: No such device
The kernel version and os version is as below
root#beaglebone:~# uname -a
Linux beaglebone 3.8.13 #1 SMP Wed Sep 4 09:09:32 CEST 2013 armv7l GNU/Linux
root#beaglebone:~# lsb_release -a
Distributor ID: Angstrom
Description: Angstrom GNU/Linux v2012.12 (Core edition)
Release: v2012.12
Codename: Core edition
I was just trying to do the same thing and got the same error. Looks like the 3.8.13 kernel doesn't support suspend/sleep mode. In the link below they mention only 3.12 or higher supports that feature. (Note if you upgrade beyond 3.8.13 all the capemgr stuff works completely differently than on 3.8.13. I tried 3.18.1 and couldn't get any capes to work.)
Bug report for sleep mode

Disable transparent huge pages in TokuMX

When I try to start the mongod server by giving ./mongod --dbpath /nlu/ind/mongodata
I get an error saying
TokuMX will not run with transparent huge pages enabled.
Tue Aug 20 10:47:34 [initandlisten] Please disable them to continue.
Tue Aug 20 10:47:34 [initandlisten] (echo never > /sys/kernel/mm/transparent_hugepage/enabled)
Tue Aug 20 10:47:34 [initandlisten]
Tue Aug 20 10:47:34 [initandlisten] The assertion failure you are about to see is intentional
Please let me know how to sort this. Thanks in advance for your help.
I have 3 directories in /sys/kernel/mm/ and they are hugepages ksm redhat_transparent_hugepage
As the message states, you need to do the following:
sudo bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled'
You can cat /sys/kernel/mm/transparent_hugepage/enabled to see the current setting and to make sure that your echo worked.
The setting will be cleared when you reboot when setting it in this manner. TokuMX sets this in it's init script.
Please visit this question for a more thorough discussion: https://unix.stackexchange.com/questions/99154/disable-transparent-hugepages
You can add transparent_hugepage=never to the GRUB_CMDLINE_LINUX_DEFAULT option in /etc/default/grub and run sudo update-grub
To test that it took effectcat /sys/kernel/mm/transparent_hugepage/enabled should look like this: always madvise [never]

Nsclient: How can i display Windows HDD health on Nagios

i want to monitor hard-drive's health of my windows server, for this i have installed Smarttools(smartmontools-6.1-2.win32-setup.exe).
My question is, how can i display commands output on Nagios-Server via nrpe or somewhat else.
Some info: Nagios-Core-3.5, smartmontools-6.1-2,
Commands output on windows machine:
c:> smartctl.exe /dev/sda -l selftest
smartctl 6.1 2013-03-16 r3800 [i686-w64-mingw32-xp-sp2] (sf-6.1-2)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 17592 -
# 2 Extended offline Completed without error 00% 17393 -
# 3 Short offline Completed without error 00% 17392 -
c:> smartctl.exe /dev/sda -H
smartctl 6.1 2013-03-16 r3800 [i686-w64-mingw32-xp-sp2] (sf-6.1-2)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
C:>smartctl -d ata /dev/sda -i
smartctl 6.1 2013-03-16 r3800 [i686-w64-mingw32-xp-sp2] (sf-6.1-2)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Seagate Barracuda 7200.9
Device Model: ST3802110A
Serial Number: 5LR7M728
Firmware Version: 3.AAJ
User Capacity: 80,026,361,856 bytes [80.0 GB]
Sector Size: 512 bytes logical/physical
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA/ATAPI-7 (minor revision not indicated)
Local Time is: Fri Jun 07 19:02:13 2013 IST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Any help would greatly appreciated.
You have two issues.
You need to be able to get Nagios to run a check remotely on your Windows server, and
You need to be able to get the data into a Nagios-compatible format.
For the first, you can probably install an agent such as NC_Net or NSClient++. This can be queried using either check_nt or check_nrpe. I would recommend using NC_Net.
For the second, you will likely have to write your own script to run the command and output in Nagios plugin format (one line of text, and an exit status of 0/1/2/3 for OK/Warn/Crit/Unknown). This script can be remotely called via check_nrpe.
However, if your goal is simply to monitor disk space, you can do that using the standard check functions builtin to NC_Net or NSClient++
You may find pre-written scripts at monitoringexchange.org , such as this

Resources