Cannot Figure Out PWM Overlay for BeagleBone Green Wireless - linux-kernel

I am new to BeagleBone Green Wireless (BBGW). I just read Derek Molloy's Exploring BeagleBone. Very good read, however, BBGW has Linux 4.4.9-ti-r25 and everything is quite different. Linux 4.4.9 no longer has the device tree source. Just has the device tree overlays (.dto). I am trying to experiment with the PWM's. I loaded am33xx_pwm-00A0.dtbo and BB-PWM1-00A0.dtbo overlays found in /lib/firmware. I presume these are default overlays for PWM1 but not sure.
export SLOTS=/sys/devices/platform/bone_capemgr/slots
export PINS=/sys/kernel/debug/pinctrl/44e10800.pinmux/pins
sudo sh -c "echo am33xx_pwm > $SLOTS"
sudo sh -c "echo BB-PWM1 > $SLOTS"
They appear to be loaded correctly,
root#beaglebone:/lib/firmware# cat $SLOTS
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
5: P-O-L- 0 Override Board Name,00A0,Override Manuf,am33xx_pwm
7: P-O-L- 1 Override Board Name,00A0,Override Manuf,BB-PWM1
However, I cannot find where to access PWM1's properties. Malloy says that they are in, /sys/devices/ocp.3/pwm_test_p9_22.15. I could not find that directory and the closest I could find was /sys/devices/platform/ocp/. There are several devices but nothing about PWM1. Where can I find the location of PWM1's properties? I want to change them using the echo command using this example,
sudo su
echo 5000 > duty
echo 10000 > period
echo 1 > run
If someone knows of a good document that would be helpful as well.

I know you said you are close to solving it but I got it to work..
Kernel: 4.4.30-ti-r64
Distro: Debian 8.6 Jessie
Now to load the PWM overlay...
My distro is from RCN and comes with the overlays pre-populated in my /lib/firmware/ folder. If you have the overlays there continue to step 4, if not step 2.
apt-get update
sudo apt install bb-cape-overlays
Load the overlay into the cape manager:
echo BB-PWM1 > /sys/devices/platform/bone_capemgr/slots
Ensure the overlay is loaded correctly by doing two things:
First make sure it is in the capemanager:
cat /sys/devices/platform/bone_capemgr/slots
output:
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-PWM1
The second is to make sure the pin is correctly muxed to do this:
cd /sys/kernel/debug/pinctrl/44e10800.pinmux
more pins | grep 848
the output should be similar to this :
pin 18 (44e10848.0) 00000006 pinctrl-single
You can look into the overlay to get a deeper understanding of what is going on but it is a little outside the scope of this question.
if you don't see the 00000006 output. Dont proceed. Reboot the BB and try again. This happened to me and a reboot solved the problem
So, the BB is now ready for PWM.
cd /sys/class/pwm
cd pwmchip0
echo 0 > export
cd pwm0
echo 1000000000 > period
echo 800000000 > duty_cycle
echo 1 > enable
Ta-da. it should work. Sorry for the lengthy response. I wanted to be thorough.
I followed the tutorial: http://www.teachmemicro.com/beaglebone-black-pwm-ubuntu-device-tree/
Edit:
This is for setting the PWM for P9_14

Related

Limit on number of wireless "sta" stations in openwrt

I have openwrt implementation on a TPLink WR902AC (pocket router)
I have a /etc/network/wireless configuration file with 10 sta configurations for connecting to AP all of which are active (option disabled '0')
This is to ensure that openwrt connects to any one of the APs configured.
Only the first 4 configured are attempted to be connected and the rest are simply ignored.
(if first 4 configured are not available the 5th one is being ignored)
I tried to identify the bottleneck.
Only first 4 wpa_supplicant instances are called as evident from these files in /tmp/run
./tmp/run/wpa_supplicant/wifi3
./tmp/run/wpa_supplicant/wifi1
./tmp/run/wpa_supplicant/wifi2
./tmp/run/wpa_supplicant/wifi0
When I disable the first one, the fifth one gets connected on reconnect with "wifi"
I tried to check the source code. I lost the track after ubus being called from wifi script.
This I believe is similar question to https://forum.openwrt.org/t/limit-on-the-number-of-wifi-ssids/63141
iw list on openwrt show me the limit.
valid interface combinations:
* #{ IBSS } <= 1, #{ managed, AP, mesh point, P2P-client, P2P-GO } <= 4,
total <= 4, #channels <= 1, STA/AP BI must match
I tried to use wpa_supplicant directly instead of depending on scripts.
wpa_supplicant -c /root/wifi0.conf -i wifi0 -s -B
wpa_supplicant -c /root/wifi1.conf -i wifi1 -s -B
wpa_supplicant -c /root/wifi2.conf -i wifi2 -s -B
wpa_supplicant -c /root/wifi3.conf -i wifi3 -s -B
wpa_supplicant -c /root/wifi4.conf -i wifi4 -s -B
wpa_supplicant -c /root/wifi5.conf -i wifi5 -s -B
This failed with "interface wifi4" not available error.
Could someone point me to the source where this hard limit is set?
Is there any way around this?
Thanks in advance.
Update:-
mt7601u based usb WiFi dongle was added to wr902ac and configured (as radio2)
This time only one is connected. If I have AP configured, sta doesn't even get connected.
so number of slots is limited. (ap counts as one slot and each sta is one slot)
The built-in 2.4 GHZ has 4 slots & 5 GHz has 8 slots.
The mt7601u based wifi has only 1 slot.
Probably there exists a usb dongle that has 8 slots. Could someone point me to the theory behind all this?

How to make cpuset.cpu_exclusive function of cpuset work correctly

I'm trying to use the kernel's cpuset to isolate my process. To obtain this, I follow the instructions(2.1 Basic Usage) from kernel doc cpusets, however, it didn't work in my environment.
I have tried in both my centos7 server and my ubuntu16.04 work pc, but neither did work.
centos kernel version:
[root#node ~]# uname -r
3.10.0-327.el7.x86_64
ubuntu kernel version:
4.15.0-46-generic
What I have tried is as follows.
root#Latitude:/sys/fs/cgroup/cpuset# pwd
/sys/fs/cgroup/cpuset
root#Latitude:/sys/fs/cgroup/cpuset# cat cpuset.cpus
0-3
root#Latitude:/sys/fs/cgroup/cpuset# cat cpuset.mems
0
root#Latitude:/sys/fs/cgroup/cpuset# cat cpuset.cpu_exclusive
1
root#Latitude:/sys/fs/cgroup/cpuset# cat cpuset.mem_exclusive
1
root#Latitude:/sys/fs/cgroup/cpuset# find . -name cpuset.cpu_excl
usive | xargs cat
0
0
0
0
0
1
root#Latitude:/sys/fs/cgroup/cpuset# mkdir my_cpuset
root#Latitude:/sys/fs/cgroup/cpuset# echo 1 > my_cpuset/cpuset.cpus
root#Latitude:/sys/fs/cgroup/cpuset# echo 0 > my_cpuset/cpuset.mems
root#Latitude:/sys/fs/cgroup/cpuset# echo 1 > my_cpuset/cpuset.cpu_exclusive
bash: echo: write error: Invalid argument
root#Latitude:/sys/fs/cgroup/cpuset#
It just printed the error bash: echo: write error: Invalid argument.
Google it, however, I can't get the correct answers.
As I pasted above, before my operation, I confirmed that the cpuset root path have enabled the cpu_exclusive function and all the cpus are not been excluded by other sub-cpuset.
By using ps -o pid,psr,comm -p $PID, I can confirm that the cpus can be assigned to some process if I don't care cpu_exclusive. But I have also proved that if cpu_exclusive is not set, the same cpus can also be assigned to another processes.
I don't know if it is because some pre-setting are missed.
What I expected is "using cpuset to obtain exclusive use of cpus". Can anyboy give any clues?
Thanks very much.
i believe it is a mis-understanding of cpu_exclusive flag, as i did. Here is the doc https://www.kernel.org/doc/Documentation/cgroup-v1/cpusets.txt, quoting:
If a cpuset is cpu or mem exclusive, no other cpuset, other than
a direct ancestor or descendant, may share any of the same CPUs or
Memory Nodes.
so one possible reason you have bash: echo: write error: Invalid argument, is that you have some other cgroup cpuset enabled, and it conflicts with your operations of echo 1 > my_cpuset/cpuset.cpu_exclusive
please run find . -name cpuset.cpus | xargs cat to list all your cgroup's target cpus.
assume you have 12 cpus, if you want to set cpu_exclusive of my_cpuset, you need to carefully modify all the other cgroups to use cpus, eg. 0-7, then set cpus of my_cpuset to be 8-11. After all these cpus configurations , you can set cpu_exclusive to be 1.
But still, other process can still use cpu 8-11. Only the tasks that belongs to the other cgroups will not use cpu 8-11
for me, i had some docker container running, which prevents me from setting my cpuset cpu_exclusive
with kernel doc, i do not think it is possible to use cpus exclusively by cgroup itself. One approach (i know this approach is running on production) is that we isolate cpus, and manage the cpu affinity/cpuset by ourselves

Raspberry Pi 3 - sound and microphone doesn't work

I have installed Raspbian Jessie with Pixel (version April 2017) on my Raspberry Pi 3. I have plugged a Platronics C320-M headphone + microphone set.
And obviously it doesn't work.
I have followed this instructions: https://raspberrypi.stackexchange.com/questions/40831/how-do-i-configure-my-sound-for-jasper-on-raspbian-jessie/40832
to make my USB set a main device.
So no I have:
pi#raspberrypi:~ $ cat /proc/asound/modules
0 snd_usb_audio
1 snd_bcm2835
pi#raspberrypi:~ $ cat /etc/modprobe.d/alsa-base.conf
# This sets the index value of the cards but doesn't reorder.
options snd_usb_audio index=0
options snd_bcm2835 index=1
# Does the reordering.
options snd slots=snd_usb_audio,snd_bcm2835
pi#raspberrypi:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: C320M [Plantronics C320-M], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
But when I try to play test sound:
speaker-test -c2 -twav
I can see test running but can't hear anything.
Really have no idea what to check/set more...
I will be grateful for any hints.
Regards
Pawel
try to follow below steps to enable audio recording and playback from a usb-sound adapter for rpi-3. I had documented these while performing audio recording from usb sound adapter. Hope this help you.
Steps:
1.1) Create/edit file .asoundrc
$vim .asoundrc
If file is not present create it;
$ touch .asoundrc
$vim .asoundrc
pcm.!default {
type asym
playback.pcm "hw:1,0"
capture.pcm "hw:1,0"
}
ctl.!default {
type hw
card 1
}
1.2)Edit below line in file alsa.conf;
$sudo vim /usr/share/alsa/alsa.conf
defaults.ctl.card 0
defaults.pcm.card 0
to
$sudo vim /usr/share/alsa/alsa.conf
defaults.ctl.card 1
defaults.pcm.card 1
1.3) Change audio levels/setting using alsamixer utility
$alsamixer
1.4) Command to record audio
$arecord -D plughw:1 -f S16_LE -r 48000 -d 5 ./testSound.wav
1.5) Command to play recorded audio
$aplay --device=plughw:1,0 ./testSound.wav

How to suppress the general information for top command

I wish to suppress the general information for the top command
using a top parameter.
By general information I mean the below stuff :
top - 09:35:05 up 3:26, 2 users, load average: 0.29, 0.22, 0.21
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.3%us, 0.7%sy, 0.0%ni, 96.3%id, 0.8%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 3840932k total, 2687880k used, 1153052k free, 88380k buffers
Swap: 3998716k total, 0k used, 3998716k free, 987076k cached
What I do not wish to do is :
top -u user | grep process_name
or
top -bp $(pgrep process_name) | do_something
How can I achieve this?
Note: I am on Ubuntu 12.04 and top version is 3.2.8.
Came across this question today. I have a potential solution - create a top configuration file from inside top's interactive mode when the summary area is disabled. Since this file is also read at startup of top in batch mode, it will cause the summary area to be disabled in batch mode too.
Follow these steps to set it up..
Launch top in interactive mode.
Once inside interactive mode, disable the summary area by successively pressing 'l', 'm' and 't'.
Press 'W' (upper case) to write your top configuration file (normally, ~/.toprc)
Exit interactive mode.
Now when you run top in batch mode the summary area will not appear (!)
Taking it one step further...
If you only want this for certain situations and still want the summary area most of the time, you could use an alternate top configuration file. However, AFAIK, the way to get top to use an alternate config file is a bit funky. There are a couple of ways to do this. The approach I use is as follows:
Create a soft-link to the top executable. This does not have to be done as root, as long as you have write access to the link's location...
ln -s /usr/bin/top /home/myusername/bin/omgwtf
Launch top by typing the name of the link ('omgwtf') rather than 'top'. You will be in normal top interactive mode, but when you save the configuration file it will write to ~/.omgwtfrc, leaving ~/.toprc alone.
Disable the summary area and write the configuration file same as before (press 'l', 'm', 't' and 'W')
In the future, when you're ready to run top without summary info in batch mode, you'll have to invoke top via the link name you created. For example,
% omgwtf -usyslog -bn1
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
576 syslog 20 0 264496 8144 1352 S 0.0 0.1 0:03.66 rsyslogd
%
If you're running top in batch mode (-b -n1), just delete the header lines with sed:
top -b -n1 | sed 1,7d
That will remove the first 7 header lines that top outputs and returns only the processes.
It's known as the "Summary Area" and i don't think there is a way at top initialization to disable those.
But while top is running, you can disable those by pressing l, t, m.
From man top:
Summary-Area-defaults
'l' - Load Avg/Uptime On (thus program name)
't' - Task/Cpu states On (1+1 lines, see '1')
'm' - Mem/Swap usage On (2 lines worth)
'1' - Single Cpu On (thus 1 line if smp)
This will dump the output and it can be redirected to any file if needed.
top -n1 |grep -Ev "Tasks:|Cpu(s):|Swap:|Mem:"
To monitoring a particular process, following command is working for me -
top -sbn1 -p $(pidof <process_name>) | grep $(pidof <process_name>)
And to get the all process information you can use the following -
top -sbn1|sed -n '/PID/,/^$/p'
egrep may be good enough in this case, but I would add that perl -lane could do this kind of thing with lightning speed:
top -b -n 1 | perl -lane '/PID/ and $x=1; $x and print' | head -n10
This way you may forget the precise arguments for grep, sed, awk, etc. for good because perl is typically much faster than those tools.
On a mac you cannot use -b which is used in many of the other answers.
In that case the command would be top -n1 -l1 | sed 1,10d
Grabbing only the first process line (and its header), only logging once, instead of interactive, then suppress the general information for top command which are the first 10 lines.

Changing monitor brightness programatically in Ubuntu 11.10

I'm using Dell inspiron 1564 laptop with Ubuntu 11.10. Here I can change my monior brightness simply via fn+F4/5. But I need a low brightness even lower than the min limit of fn+F4. How can I do it programatically or which shell command to use for that?
I'm not sure that it's possible to go lower than what the laptop controls get you, but you can programatically change brightness by echoing a value to /sys/class/backlight/<something>/brightness. On my netbook the 'something' is acpi_video0.
$ cat /sys/class/backlight/acpi_video0/brightness
10
$ sudo sh -c 'echo 0 > /sys/class/backlight/acpi_video0/brightness'
$ cat /sys/class/backlight/acpi_video0/brightness
0
Edit: There's also xbacklight, which uses XRandr.
According to this site, you should be able to alter the brightness by modifying the /proc/acpi/video/VGA/LCD/brightness file.
The valid brightness levels appear to be:
levels: 12 25 37 50 62 75 87 100
So modifying that file accordingly should do what you need.
you can change it by following command sudo setpci -s 00:02.0 f4.b=00, here you can enter value from 00 to ff in hexadecimal, [00 = bright and ff = dull]
for more details go through the following link : http://daksh21ubuntu.blogspot.in/2011/12/how-to-increasedecrease-brightness-on.html

Resources