icecast2 and mpg123 not closing connection - icecast

I'm running mpg123 1.20.1 in a loop, connected to a local icecast2 2.4.0stream created by Mopidy (Spotify).
mpg123 finish normally after each song; looks like icecast2 end-of-track is interpreted as end-of-stream, so, I have a loop that restart mpg123 at the end of each track.
The issue is that after a few hundred tracks, there are as many open connections! and icecast2 stop advertising the stream.
There are no mpg123 running processes.
How can I clean the open connections? Is this Icecast2 or mpg123 issue?
Raspbian Jessie, Linux xxxx 4.1.15-v7+ #830 SMP Tue Dec 15 17:02:45 GMT 2015 armv7l GNU/Linux

Related

I am installing rocM to use tensorflow in the ec2 g4ad environment, but an error ''ROCk module is NOT loaded, possibly no GPU devices'' occurs

I was setting up to run tensorflow in g4ad environment (amd gpu).
i followed this
https://github.com/Grench6/RX580-rocM-tensorflow-ubuntu20.4-guide
usname -a
=> Linux ip-172-31-37-18 5.4.0-1060-aws #63~18.04.1-Ubuntu SMP Mon Nov 15 14:31:31 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
after enter rocminfo this error occured
ROCk module is NOT loaded, possibly no GPU devices
Unable to open /dev/kfd read-write: No such file or directory
ubuntu is member of video group
hsa api call failure at: /src/rocminfo/rocminfo.cc:1142
Call returned HSA_STATUS_ERROR_OUT_OF_RESOURCES: The runtime failed to allocate the necessary resources. This error may also occur when the core runtime library needs to spawn threads or create internal OS-specific events.

Gdb can't connect to OpenOCD on stm32

Trying to debug my sample blink_led code on STM32L476 Nucleo-64 board but gdb can't connect to OpenOCD (connection drops almost instantly with error). I've read plenty of posts here and there but none of them helped. Tried adding commands to OpenOCD using -c but no change of behavior.
My code compiles both in Release and Debug config in Eclipse. I can flash the bin file using drag and drop (while the board has built-in STLink add-on) and looks the code runs perfectly on the board (LED blinks).
Cross compiling on Centos7 using the following versions:
Toolchain (gdb): gcc-arm-none-eabi-8-2018-q4-major
OpenOCD: 0.10.0-11-20190118-1134
As using eclipse didn't work I tried the command line,
(I'm not an experienced developer in this environment so I could not find any config file closer to my stm32l476 board than the stm32l4discovery.cfg, please let me know if there might be some issues using it)
./bin/openocd -f scripts/board/stm32l4discovery.cfg -c "init"
It starts,
GNU MCU Eclipse 64-bit Open On-Chip Debugger 0.10.0+dev-00462-gdd1d90111 (2019-01-18-11:37)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 500 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 500 kHz
Info : STLINK V2J28M17 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.244386
Info : stm32l4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Then starting GDB:
./arm-none-eabi-gdb ~/eclipse-workspace/test-blink-led/Debug/test-blink-led.elf
then running the following command in gdb:
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
Remote connection closed
As it shows gdb connection drops instantly and OpenOCD prompts the following errors:
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080022e6 msp: 0x20017ff8
Info : device id = 0x10076415
Warn : STM32 flash size failed, probe inaccurate - assuming 1024k flash
Info : flash size = 1024kbytes
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
Error: jtag status contains invalid mode value - communication failure
Polling target stm32l4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
So from those geeks who do it on a similar platform on a daily basis, can anyone help and tell me where am I doing wrong. Does missing any compile-time flag might result in this problem?
I'm scratching my head for a couple of days now so please let me have your hints.
One of the reasons may be that your STLINK firmware seems pretty old (STLINK V2J28M17 as your log shows). I suggest downloading the STSW-LINK007 application to upgrade the firmware. The software is a multiplatform Java application. It works flawlessly in Debian GNU/Linux.
Currently, I use another gdb server texane/stlink for my debugging task with GDB without any problem on some Nucleo and also custom boards. I use target extended-remote command to join the port of the server. Maybe you can try to connect with this command also under OpenOCD.
Try
telnet localhost 4444
it worked for me, while 3333 didn't

Reading peripheral register of Cortex M0 MCU using JLink and GDB

I'm trying to read the MCUs ADC register using GDB but I can't seem to find how it's done.
Using x\10x 0x40012708 in gdb just returns zeroes, as do any memory mapped peripheral register I try to read.
It this possible to do? If so, how is it done?
Thanks!
I would suggest to validate that your setup is functional first.
For example, you could try to read the CPUID register which is present on all Cortex-M0 processors - see section 4.3 of the Cortex™-M0 DevicesGeneric User Guide.
It is located at address 0xE000ED00, and it shall contain value 0x410CC200.
If you can read it, this would be a good sign.
You probably should try using J-Link commander first, then with GDB-Server and GDB. I ran the procedure hereafter on an Olimex board using an LPC1114/301 Cortex-M0. I was using J-Link software V5.10n, and arm-none-eabi-gdb version 7.10.1.20151217-cvs, which is part of Linaro gcc 5.2 for ARM Cortex-M processors package.
Start JLink.exe using the following options:
jlink.exe -if SWD -speed 4000 -AutoConnect 1 -device Cortex-M0
You should see something similar to:
SEGGER J-Link Commander V5.10n (Compiled Feb 19 2016 18:39:46)
DLL version V5.10n, compiled Feb 19 2016 18:39:11<br/>
Connecting to J-Link via USB...O.K.
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware version: V8.00
S/N: [My J-Link EDU Serial Number]
License(s): FlashBP, GDB
OEM: SEGGER-EDU
Emulator has Trace capability
VTref = 3.313V
Device "CORTEX-M0" selected.
Found SWD-DP with ID 0x0BB11477
Found Cortex-M0 r0p0, Little endian.
FPUnit: 4 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl 0 # E00FF000
ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB008 SCS
ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 000BB00A DWT
ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 000BB00B FPB
Cortex-M0 identified.
J-Link>
You can now read the CPUID register using the J-Link commander mem32 command, and verify the CPUID register does contain the expected value:
J-Link>mem32 0xE000ED00,1
You should get:
E000ED00 = 410CC200
If this is the case, I would say that your J-Link/Cortex-M0 setup is likely functional. We can now verify GDB Server and GDB are working fine too.
Launch JLinkGDBServerCL.exe with the following options: JLinkGDBServerCL.exe -if SWD -speed 4000 -device Cortex-M0
SEGGER J-Link GDB Server V5.10n Command Line Version
JLinkARM.dll V5.10n (DLL compiled Feb 19 2016 18:39:11)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: Cortex-M0
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware: V8.00
S/N: [My J-Link EDU Serial Number]
OEM: SEGGER-EDU
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.31 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...
Keep the GDB server running, and start GDB in an other Windows console session:
arm-none-eabi-gdb
GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20151217-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
We can now connect to GDB server, and attempt to display the content of the CPUID register again:
(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0xfffffffe in ?? ()
(gdb) monitor halt
(gdb) monitor reset
Resetting target
(gdb) x/1xw 0xE000ED00
0xe000ed00: 0x410cc200
(gdb)
If you are getting 0x410cc200 again, your J-Link/Cortex-m0/GDB Server/GDB setup should be functional, and you should now try again to read your ADC register using this command:
x/1xw 0x40012708
If you were able to read the CPUID register, but not the ADC register, and if the address for the ADC register is correct, I would not have an explanation for this behavior right now - knowing the exact brand/model for the MCU you are using could of course help further.
Please note that from now on, you should specify the exact model for your MCU as the argument to the -device J-Link Commander/GDB Server options instead of Cortex-M0. You can get the list by entering command ? on the J-Link Commander command-prompt.

Ubuntu, libftdi priviliges, seg fault when non-root user run program

I am trying to write simple program, that uses libftdi, and I have come across a strange problem.
When running the program as non-root it looks like this:
./BoxDriver
Naruszenie ochrony pamięci (zrzut pamięci)
And in Dmesg the last line I see is:
[ 3320.467864] BoxDriver[4205]: segfault at 0 ip 00007f05c2821f7a sp 00007ffd9c6c9c00 error 4 in libftdi.so.1.20.0[7f05c2820000+7000]
I am using Ubuntu:
Linux AdamsPC 3.19.0-30-generic #34-Ubuntu SMP Fri Oct 2 22:08:41 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
And FTDI device:
Bus 001 Device 011: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
The program runs fine, when it is running as a root:
sudo ./BoxDriver
OK, started
I have also tried to debug the source code (in eclipse ang gcc, no seg fault occurred), and the problem is with:
ftdi_usb_open(ftc, 0x0403, 0x6010)
It always returns -8, that stands for : "get product description failed"
I have searched for any answer, most are about adding user to dialout group, or adding rule to udev, but none of answers I have founded worked.
Any suggestions are highly appreciated. Thanks
There is a few different ways to fix this but generally it sounds like your user account does not have permission to interface with the USB device. You could add the user to the appropriate group I believe for ubuntu that is dialout so.
sudo usermod -a -G dialout user
Alternatively if multiple accounts need to use it but they all should have permissions you could change the filesystem it's mounted to to have full permissions.
sudo chmod 777 /media/drive_name

Querying the Power Status of a Linux Machine Programmatically

On a Windows(R) machine the following function can be used for querying the system power status of the machine:
BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS lpSystemPowerStatus);
Is there something similar for a Linux machine?
On most linux systems a daemon named acpid runs all the time monitoring for ACPI events and normally logs info to /var/log/acpid or /var/log/messages. There is a manpage for it at http://linux.die.net/man/8/acpid. acpid stores current ACPI info in /proc/acpi although that's being relocated to /sys somewhere and /sys/power/state holds the current power state seen by catting it (cat /sys/power/state). More info about ACPI is at http://acpi.sourceforge.net/documentation/sleep.html. JCM mentioned a command line tool for ACPI status monitoring named AcpiTool available at http://sourceforge.net/projects/acpitool/. I built that on CentOS and it works fine. Just follow the instructions in its INSTALL file to install it -- it requires a C++ compiler, which is commonly on linux or if not install one using yum or apt.
dmidecode can do many kinds of queries for low level issues including system power supply and controls, see http://linux.die.net/man/8/dmidecode
In collaboration with freedesktop.org RedHat developed and provides DeviceKit-power pre RH7 which is called UPower starting with RH7. It consists of a daemon and command line tool. A manpage for it is at http://www.pkill.info/linux/man/1-upower/. The --dump option of the command line tool provides some useful info but rarely up to date. Maybe restarting the daemon would cause an update. Here is an example of the output from a CentOS 6 host:
ca:17: devkit-power --dump
Device: /org/freedesktop/DeviceKit/Power/devices/line_power_ACAD
native-path: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/ACAD
power supply: yes
updated: Tue Dec 23 20:28:27 2014 (866 seconds ago)
has history: no
has statistics: no
line-power
online: yes
Daemon:
daemon-version: 014
can-suspend: no
can-hibernate yes
on-battery: no
on-low-battery: no
lid-is-closed: no
lid-is-present: no
Most major PC vendors such as Dell and HP provide their own apps for power management and monitoring and I've found it is best to use them because they know how to query custom probes designed into the HW and print full diagnostics for their support team.
On My Ubuntu system I found this Information in /sys/class/power_suply/ADP1/online .
For example I used it in a script in an If statement with the following code:
if (( CPUBenutzung > 11 )) || ! (( $(cat /sys/class/power_suply/ADP1/online) )); then Stopmining ; fi
for me this worked fine and stopped the mining process allways when there was no power connected or I did use for some other reason all 12 threads of my notebook.