BeagleBone Black: P8_5 is stuck at HIGH - beagleboneblack

I can control P8_3, P8_4, but P8_5 stays stuck at 3V3.
I've booted the BB with this configuration to disable HDMI:
# cat /proc/cmdline
optargs=quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
Then I enabled GPIO 34+38+39 (P8_{5,3,4}):
# echo 34 > /sys/class/gpio/export
# echo 38 > /sys/class/gpio/export
# echo 39 > /sys/class/gpio/export
And set them as outputs:
# echo out > /sys/class/gpio/gpio34/direction
# echo out > /sys/class/gpio/gpio38/direction
# echo out > /sys/class/gpio/gpio39/direction
Then I'm setting them to alternate between HIGH/LOW at 1Hz using a script which writes as so:
# value is 0/1, pin is 34/38/39
# echo $value > /sys/class/gpio/gpio$pin/value
I measure P8_{3,4} alternating between 0V and 3V3, but P8_5 is stuck at 3V3.
I've tried compiling the devicetree overlay for gpio-P8.5 from here and adding it, but with the same result.
I'm aware that these pins are used by HDMI, but I thought I'd disabled HDMI with that kernel command-line, and I ideally need to use those specific pins due to the board I'm connecting the BBB to.
A colleague using my SD image also had the same issue on a BB green (which I believe doesn't have HDMI).

It seems the device tree files provided with the BBB were trying to configure GPIO#2 instead of GPIO#34 (gpio0_2 instead of gpio1_2).
I generated a new device-tree overlay for P8_5 (gpio1_2 / gpio34) with this and it all works now.

Related

How can I access a memory mapped device, synthesized on fpga, with a Lauterbach script?

on a ZCU106 board with MPSoC Zynq Ultrascale+, I have developed a simple test application that performs reads and writes to a memory-mapped device register. The device in question is a GPIO peripheral, synthesized to fpga and accessed in memory with address (0xA0010000) configured via Vivado tool. The application does not use MMU. If I try to launch and run my application from the Vitis debugger, everything works correctly, with no problems. However, I need to launch the application from Lauterbach's Trace32. By doing the launch with a practice script (Lauterbach's scripting language), the application loads correctly, but upon reading or writing to the memory address where the synthesized device is mapped to fpga, a "debug port fail" type problem is returned. I therefore analyzed the tcl script automatically generated by Vitis to see if there are any hardware configurations that are made in tcl, but which I do not predict with the practice script (Lauterbach). My suspicion is that there are special instructions to enable the mapping of memory addresses that a processor can access. I attach the tcl script generated by Vitis, perhaps the "offending" instruction is the 'loadhw -hw'? Thanks in advance to anyone who can help me.
# In Vitis IDE create a Single Application Debug launch configuration,
# change the debug type to 'Attach to running target' and provide this
# tcl script in 'Execute Script' option.
# Path of this script: /home/daniele/vitis_workspace/interr_measurement_test_system/_ide/scripts/debugger_interr_measurement_test-default.tcl
#
#
# Usage with xsct:
# To debug using xsct, launch xsct and run below command
# source /home/daniele/vitis_workspace/interr_measurement_test_system/_ide/scripts/debugger_interr_measurement_test-default.tcl
#
connect -url tcp:127.0.0.1:3121
source /tools/Xilinx/Vitis/2021.2/scripts/vitis/util/zynqmp_utils.tcl
targets -set -nocase -filter {name =~"APU*"}
rst -system
after 3000
targets -set -filter {jtag_cable_name =~ "Xilinx HW-FTDI-TEST FT232H 49619" && level==0 && jtag_device_ctx=="jsn-HW-FTDI-TEST FT232H-49619-14730093-0"}
fpga -file /home/daniele/vitis_workspace/interr_measurement_test/_ide/bitstream/zcu106_int_meas_plat_wrapper.bit
targets -set -nocase -filter {name =~"APU*"}
loadhw -hw /home/daniele/vitis_workspace/zcu106_int_meas_plat_wrapper/export/zcu106_int_meas_pp
lat_wrapper/hw/zcu106_int_meas_plat_wrapper.xsa -mem-ranges [list {0x80000000 0xbfffffff} {0x400000000 0x5ffffffff} {0x1000000000 0x7fffffffff}] -regs
configparams force-mem-access 1
targets -set -nocase -filter {name =~"APU*"}
set mode [expr [mrd -value 0xFF5E0200] & 0xf]
targets -set -nocase -filter {name =~ "*A53*#0"}
rst -processor
dow /home/daniele/vitis_workspace/zcu106_int_meas_plat_wrapper/export/zcu106_int_meas_plat_wrapper/sw/zcu106_int_meas_plat_wrapper/boot/fsbl.elf
set bp_30_4_fsbl_bp [bpadd -addr &XFsbl_Exit]
con -block -timeout 60
bpremove $bp_30_4_fsbl_bp
targets -set -nocase -filter {name =~ "*A53*#0"}
rst -processor
dow /home/daniele/vitis_workspace/interr_measurement_test/Debug/interr_measurement_test.elf
configparams force-mem-access 0
bpadd -addr &main

Changing default focused screen on awesome wm

I have a bit of a hacky setup on my laptop where I use optimus-manager to configure my screen layout at X startup based on whether an external monitor is connected or not. If it is, I only want to use the external monitor and not the laptop monitor, but because of a limitation of NVIDIA drivers, I need to leave my laptop monitor on, and just lower the backlight brightness. See my /etc/optimus-manager/xsetup-hybrid.sh for how this works (eDP-1 is my laptop screen, and HDMI-1-0 is my external monitor):
#!/bin/sh
# Everything you write here will be executed by the display manager when setting up the login screen in "hybrid" mode.
xrandr --output eDP-1 --mode 1920x1080 --pos 3000x0 --output HDMI-1-0 --primary --mode 2560x1080 --pos 0x0
if [ "$?" -ne "0" ]; then
echo "Not connected to display, don't dim internal monitor"
exit 0
fi
echo 0 | tee /sys/class/backlight/intel_backlight/brightness
Notice that eDP-1 (laptop monitor) is positioned at 3000x0. I've done this to keep the screens far enough apart so that my mouse can't accidentally stray from my external monitor's screen into my laptop monitor's screen.
This works pretty well, but for some reason every time I log into awesome (or anytime I change the screen layout with xrandr for that matter), awesome focuses the laptop monitor screen by default, even though xrandr is specifying the external monitor screen as --primary.
How can I change this behaviour so that my external monitor screen is focused by default if that monitor is connected, falling back to my laptop screen if it isn't?
You could warp the mouse cursor to the primary screen in your config:
mouse.screen = screen.primary
The above can also be tested in an already running awesome session via awesome-client: awesome-client 'mouse.screen = screen.primary'.
If you want to decide the pointer coordinates more precisely (the above uses the upper left corner of the screen), there is mouse.coords({ x = 42, y = 21 }).
It's likely apps are being displayed where the mouse currently resides. You could use xdotool to ensure mouse is on desired display to begin with.
#!/bin/sh
## executed by display manager during login
if [ "$?" -eq "0" ] ; then
xrandr --output eDP-1 --mode 1920x1080 --pos 3000x0 --output HDMI-1-0 --primary --mode 2560x1080 --pos 0x0
echo 0 | tee /sys/class/backlight/intel_backlight/brightness
## sudo apt install xdotool
## x, y coordinates: half of 2560x1080, so middle of main screen
xdotool mousemove 1280 540
else
## external display not plugged in
xrandr --output eDP-1 --mode 1920x1080 --primary --pos 0x0
fi

postscript printing with netcat

How can I use the netcat program for bidirectional communication with a networked postscript printer? Postscript programs frequently send information to the STDOUT and that is difficult to capture over the network. I need bidirectional communication with the printer 9100 port. My answer is below. Does anybody know of a better way?
The netcat program can be used for bidirectional communication with a postscript printer.
I have been using some simple programs to send print jobs directly to a network postscript printer and haven't gotten any return info from the printer until now. I like to communicate directly with the printer instead of sending jobs to a spooler.
There is a little information a few places about printing with netcat just very sparse so I am making this report.
My printer is a Xerox 6500n connected to a router by ethernet cable. I can send postscript programs or pdf files directly to the printer in a variety of ways. Sometimes I want to get answers from the printer and so have a test program to use the printer to convert the input using 'pathforall' and send back the answer. The netcat does this nicely:
nc -n 192.168.1.111 9100 < pathforall.ps
I then get the desired response. This has been checked and is similar to ghostscript output only slightly off for some reason:
$ nc -v -w 5 -n 192.168.1.111 9100 < pathforall.ps
192.168.1.111 9100 (hp-pdl-datastr) open
28.6998 12.2999 moveto
28.6998 9.29996 28.3998 8.09995 25.2998 6.59998 curveto
24.3998 6.09998 21.2999 4.79999 19.0999 4.79999 curveto
15.3999 4.79999 12.4999 7.89996 12.4999 12.5999 curveto
12.4999 12.7999 lineto
12.4999 16.1999 13.5999 21.7999 28.6998 26.7999 curveto
closepath
$ gs pathforall.ps
GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Loading Times-Roman font from /usr/share/ghostscript/fonts/Times-Roman.pfa... 4824712 3114962 3833824 2546359 1 done.
28.6184 12.2615 moveto
28.6184 9.27632 28.3224 8.07977 25.2262 6.57484 curveto
24.3257 6.08141 21.2418 4.78618 19.0461 4.78618 curveto
15.3577 4.78618 12.4589 7.8824 12.4589 12.5576 curveto
12.4589 12.7673 lineto
12.4589 16.1472 13.5567 21.7352 28.6184 26.7188 curveto
28.6184 12.2615 lineto
closepath
The netcat allows me to communicate with my printer similar to ghostscript except I don't have the executive mode working yet. Also, be sure to include a 'flush' command in the postscript to get the entire answer sent back.
This can be used for many purposes to get information from the printer.
EDIT: Here is a simple test to see if the printer STDOUT is getting back to the computer:
%!
(Hello World\n) print flush
EDIT3: Postscript executive mode works using telnet for the Xerox 6500n as suggested by luser droog. See comments below.
Here is a bash /dev/tcp alternative for printing without netcat.
This sends to a network PostScript printer using bash if built with --enable-net-redirections. This works with my Void bash and with my Xerox Phaser 6500n and switches between PJL and PostScript. Testing results with other printers would be helpful.
#!/bin/bash
#
# ++++ driverless postscript printing ++++
# bash needs --enable-net-redirections build option
#
# for postscript programs with postscript printer only
#
# bash escape is \033 or \e or \E or \x1B
exec 5<>/dev/tcp/192.168.1.111/9100 || exit 1 # change ip as needed
{
echo -e "\E%-12345X#PJL" # PJL entrance
echo #PJL ECHO "$(date)"
echo #PJL ECHO "setting up printer ..."
echo #PJL COMMENT Change Printer Settings
echo #PJL SET COPIES = 1 # modify environment settings
echo #PJL SET MANUALFEED = off
echo #PJL ECHO "Starting PostScript Program ..."
echo #PJL ENTER LANGUAGE = POSTSCRIPT
echo "%!" # optional
cat "$1" || echo -E "(Hello World\n) print flush" # if input.ps missing
echo -e "\004" # ctrl-D for end of file
echo -e "\e%-12345X#PJL" # back to PJL
echo #PJL ECHO "Finished PostScript Program."
echo #PJL RESET # unset modified environment settings
echo #PJL ECHO BYE.
echo -e "\033%-12345X" # PJL universal exit
} >&5 # send to printer
while read -t 122 -r LINE # timeout after 122 seconds of silence
do
echo "$LINE"
if [[ "$LINE" =~ #PJL\ ECHO\ BYE. ]]; then break; fi
done <&5
echo "Finished reading printer"
exec 5>&- # close
exec 5<&- # close both
exit 0
Here is the result in my terminal. Be sure to send a file like "print.sh input.ps" or this will happen:
$ ./print.sh
cat: '': No such file or directory
#PJL ECHO Mon 20 Apr 2020 07:10:03 AM PDT
#PJL ECHO setting up printer ...
#PJL ECHO Starting PostScript Program ...
Hello World
#PJL ECHO Finished PostScript Program.
#PJL ECHO BYE.
Finished reading printer
UPDATE: I have added this here: github

how to remove zero packets (empty streams) records in wireshark

I am very new to wireshark. in my day to day job i need to remove the packet bytes zero records from captured PCAP file. please help me in this process. attached image is for reference
wireshark packets zero.png
Since you have 47 TCP Streams and 28 that you want to remove, it might be a bit faster to filter for all the TCP streams that you do want to keep since there are only 19 of those.
For the 19 streams you want:
Right-click on the first TCP conversation and choose "Prepare a Filter -> Selected -> A<-->B".
For the next 17 TCP conversations, right-click on each one and choose "Prepare a Filter -> ... And Selected -> A<-->B".
Finally, for the last TCP stream, right-click on the TCP conversation and choose "Apply as Filter -> ... And Selected -> A<-->B".
You may wish to export the resulting filtered packets to a new file via "File -> Export Specified Packets... -> All packets:Displayed" so you won't have to keep filtering for those streams anymore.
If you have a large number of streams to filter, then you are better off scripting something. Here's a script you can use that seems to work well in my testing on my Linux machine. If you're using Windows, you will need to write an equivalent batch file, or you may be able to use it as is if you have Cygwin installed.
#!/bin/sh
# Check usage
if [ ${#} -lt 2 ] ; then
echo "Usage: $0 <infile> <outfile>"
exit 0
fi
infile=${1}
outfile=${2}
# TODO: Could also pass the filter on the command-line too.
filter="ip.dst eq 192.168.10.44 and tcp.len > 0"
stream_filter=
for stream in $(tshark -r ${infile} -Y "${filter}" -T fields -e tcp.stream | sort -u | tr -d '\r')
do
if [[ -z ${stream_filter} ]] ; then
stream_filter="tcp.stream eq ${stream}"
else
stream_filter+=" or tcp.stream eq ${stream}"
fi
done
tshark -r ${infile} -Y "${stream_filter}" -w ${outfile}
echo "Wrote ${outfile}"

Is the sysfs pwm interface using hardware pwm?

I followed this answer to enable PWM on my Beaglebone Black, but I wasn't sure if that method is using the PRU to do hardware PWM or if it's toggling the pin in software? I see other references to /sys/class/pwm/ehrpwm (e.g. here) which I'm more confident is hardware PWM, but I'm not sure how to enable that interface.
To summarize how I'm enabling PWM:
echo am33xx_pwm > /sys/devices/bone_capemgr.9/slots
echo cape-universal > /sys/devices/bone_capemgr.9/slots
config-pin P8.13 pwm
echo 6 > /sys/class/pwm/export
echo 1 > /sys/class/pwm/pwm6/run
echo 50000 > /sys/class/pwm/pwm6/period_ns
echo 50000 > /sys/class/pwm/pwm6/duty_ns
Thanks!
Yup, that's using the hardware PWM modules - the am33xx_pwm overlay enables all the different PWM subsystems (eHRPWM, eCAP), then the PWM kernel driver configures the corresponding PWM module for the pin being configured.

Resources