Temporary docs/notes (and small change to systemctl service)

This commit is contained in:
Miel Truyen 2022-01-09 16:09:08 +01:00
parent 18dba9b9f2
commit 1a16f37275
6 changed files with 455 additions and 4 deletions

View File

@ -0,0 +1,100 @@
# NoxBox ArchArm
- add note that users are alarm/alarm and root/root
- Configure wpa_supplicant: create config (interface specific), start temporarily, use wpa_cli to configure wifi, enable systemd service (for specific interface, which requires specific config file created earlier)
- enable and start dhcpcd (systemd service)
- Enable bluetooth stuffs. see one of the latest comments [here](https://gist.github.com/shenghaoyang/92e6dd65b9f0cc736a419f3e640663c2)
Particularly where it says:
`So put dtparam=krnbt=on in your /boot/config.txt and hci0 should come up after boot,`
Scratch this, Wat uiteindelijk in de config.txt moet staan, want anders geen sound via broadcom:
```
# See /boot/overlays/README for all available options
dtparam=audio=on
dtoverlay=vc4-kms-v3d
dtparam=krnbt=on
initramfs initramfs-linux.img followkernel
```
- install bluez and bluez-utils. start and enable bluetooth service.
- Follow this again? https://gist.github.com/yejun/2c1a070a839b3a7b146ede8a998b5495
- Interesting note: installing just pulseaudio-bluetooth this time (before it was pulseaudio as a whole?) only took 94.20MiB this time. before it was something between .5 and 1 gigabyte
-> yes the pulse user is needed or pulseaudio will complain on it not being there (when run as a system service?)
-> I did everything except for alsa stuff (just the /boot/config.txt stuff did the trick i think to resolve issues i had earlier )
-> What i also did from this (https://didier.io/post/raspberrypi-stream-sound-over-bluetooth) is:
- In /etc/bluetooth/main.conf file, add Class = 0x00041C.
All the rest i tried did not seem to have effect and was reverted
- Go through the loops and hoops to pair a bluetooth device using bluetoothctl and make sure to add it to trusted devices (power on, scan or set discover on and pair/connect, trust)
Side note: messing with wrong clock (which was confusing in journalctl), this link seems interesting for various other things: https://gist.github.com/theramiyer/cb2b406128e54faa12c37e1a01f7ae15 but nothing about the clock
Configure time: rapsberry pi does not have a proper hardware clock, so we need to sync time using the interwebs (ntpd)
pacman -S ntp
systemctl enable ntpd
systemctl start ntpd
And set the right timezone
```ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime```
Last state:
Audio sort of works and so does auto-connect (forgot to trust the device earlier) it is however popping and lagging a lot.
We're probably not using APT-X (as that seems to be done by replacing pulseaudio-bluetooth with pulseaudio-modules-bt AUR)
See the error handling section of: https://wiki.archlinux.org/title/Bluetooth_headset#Switch_between_HSP/HFP_and_A2DP_setting
neither can we switch to a2dp_sink so we're probably running as headset (speex codec shit?)
Continuation:
- Annoyed by pulseaudio not being controllabe due to system-wide service, i skimmed the arch wiki page on pulseaudio:
```
Then enable pulseaudio.service at the system level.
# systemctl enable --now pulseaudio
You will also need to disable the user-level pulseaudio service across the whole system:
# systemctl --global mask pulseaudio.socket
```
this however does not seem to be the issue of our crackling/popping sound...
And no solution for our pactl issues, appears that installing sudo helps so we are able to do this instead:
sudo -u pulse pactl
to run pactl and thus for example
sudo -u pulse pactl list
- Installing aptX support required building 'pulseaudio-modules-bt' from AUR. Which implies installing base-devel packages to be able to do so, and some extra dependencies
Once installed it automatically works, but unfortunately does not fix the sound glitches we have (popping/crackling)
- This fixed most of the crackling/popping. sound still feels a bit off and laggy. (from the arch wiki on pulseaudio, adapted for out system-wide usage of pulse)
Glitches, skips or crackling
The newer implementation of the PulseAudio sound server uses timer-based audio scheduling instead of the traditional, interrupt-driven approach.
Timer-based scheduling may expose issues in some ALSA drivers. On the other hand, other drivers might be glitchy without it on, so check to see what works on your system.
To turn timer-based scheduling off add tsched=0 in /etc/pulse/system.pa:
```
#/etc/pulse/system.pa
load-module module-udev-detect tsched=0
```
Relevant sources:
- most of this stuff matches
https://gist.github.com/yejun/2c1a070a839b3a7b146ede8a998b5495
- Enabling bluetooth on arch arm
https://gist.github.com/shenghaoyang/92e6dd65b9f0cc736a419f3e640663c2
- generic, archwiki
https://wiki.archlinux.org/title/Bluetooth_headset
- This seems to be shit (or just totally outdated)
https://didier.io/post/raspberrypi-stream-sound-over-bluetooth
Previous side tracked on:
<!-- IGNORE THIS
=> not fully working yet, trying some of this: https://didier.io/post/raspberrypi-stream-sound-over-bluetooth
mainly added Socket in audio.confg based on 'In /etc/bluetooth/input.conf file, add Enable=Source,Sink,Media,Socket.'
and In /etc/bluetooth/main.conf file, add Class = 0x00041C.
+ reboot
Still not workin! Bluetooth service zegt
Oct 29 22:46:39 noxbox-miel bluetoothd[342]: Authentication attempt without agent
Oct 29 22:46:39 noxbox-miel bluetoothd[342]: src/profile.c:ext_auth() Headset unit rejected 3C:01:EF:70:21:BC: org.bluez.Error.Rejected
wanner ik met de phone connect (is dit een auto reconnect issue, of beuh?)
IGNORE UNTIL HERE -->
Que? 14.812470] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM4345/6

View File

@ -0,0 +1,18 @@
Start looking into speaker design: https://www.diyaudioandvideo.com/Tutorial/DesignBuildSpeakerBox/
- The 2 speakers we have are car speakers and might not be great aren't great at low-ranges (a car typically has some seperate woofers around? Frequency range we have now is 45 - 22,000Hz which is reasonable)
- The IQaudio board we postponed because it was out of stock everywhere might still get interesting if we add a seperate woofer (which we could have facing backwards with the 2 smallers speakers on the front left/right)
In this case we'd be feeding into a crossover first, seperating low/high frequency to the 2 different amps. The one for low-frequency could be merged into mono again after amplification
(doubling the max power for our sub while also allowing us to tune its amplification seperately. The loss to mono is very acceptable for our use case especially if its only for the subwoofer)
organization wise, it could be looking a bit like a a retro speaker.
- IQaudio DAC is back in stock. (TODO: Can't find much about driving 4ohm speakers with these, whereas the sparkfun one explicitely specifies it can and should)
- If it does go with 4ohm speakers we can find subwoofers on the same site that supplies the iqaudio: https://www.reichelt.de/nl/nl/subwoofer-inbouw-30-cm-1800-w-jvc-cw-dr120-p306980.html?&trstct=pos_1&nbc=1
...it is however rather large (30cm, wheras we are currently using 10cm speakers.
Might not be bad if the IQAudio is only tuned for 8ohms speakers, as it is gonna be hard to find woofers that are not car-size (e.g. 30cm/12inch) and we won't get much to choose from
(additionally 8ohm might be easier on the AMPS power rating?)
Look for build-in speakers if we want to find woofers under 12inch, e.g: https://www.bax-shop.be/nl/interne-speaker-componenten/8-inch-luidsprekers?filters%5Border%5D=score&filters%5Bprice%5D%5Bmin%5D=0&filters%5Bprice%5D%5Bmax%5D=100&filters%5Bq%5D=&filters%5B20676%5D%5B%5D=83266&filters%5B20676%5D%5B%5D=83262&grid=list
which for example gets us this one: https://www.bax-shop.be/nl/8-inch-luidsprekers/visaton-w-200-s-8-inch-woofer-115w-8-ohm

View File

@ -0,0 +1,61 @@
# This describes how to use GPIO pins````
#
#
Follow wiring guide from sparkfun
Dont install python
install nodejs and npm instead
then install
npm i -g onoff
Enable i2c
https://github.com/fivdi/i2c-bus/blob/master/doc/raspberry-pi-i2c.md
New boot config, when also enabling pull-up for GPIO17 and 27:
````
# See /boot/overlays/README for all available options
dtparam=i2c_arm=on
dtparam=audio=on
gpio=17=pu
gpio=27=pu
dtoverlay=vc4-kms-v3d
dtparam=krnbt=on
initramfs initramfs-linux.img followkernel
````
Using it in as NodeJS project to control amp volume using up/down buttons:
````
const i2c = require('i2c-bus');
const Gpio = require('onoff').Gpio;
const MAX9744_ADDR = 0x4B;
let curVolume = 20;
async function setVolume(v){
const bus = await i2c.openPromisified(1);
const wbuf = Buffer.from([v]);
bus.i2cWrite(MAX9744_ADDR,wbuf.length,wbuf);
bus.close()
}
setVolume(30);
const upButton = new Gpio(17, 'in', 'both', {activeLow: true});
const downButton = new Gpio(27, 'in', 'both', {activeLow: true});
upButton.watch((err,value) => {
if(value && curVolume < 63){
console.log('UP');
setVolume(++curVolume);
}
});
downButton.watch((err,value) => {
if(value && curVolume > 0){
console.log('DOWN');
setVolume(--curVolume);
}
});
console.log("Watching");
````

View File

@ -0,0 +1,19 @@
# This describes the story of trying to get the Pi to shutdown and reboot using a single power-button
## Findings:
- gpio-shutdown interferes with I2C pin, we need to either move gpio-shutdown or i2c to different pins
- GLOBAL_EN does not seem to be useful to send a halt signal, shorting it to ground is equivalent to disconnecting the power (somehow) and thus will allow it to boot up, and hard-reset but thats it
# Things modded:
- Installed the rpi-eeprom package documentation from Rpi themselves [here](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-bootloader-configuration)
```To view the current EEPROM configuration:
rpi-eeprom-config
To edit it and apply the updates to latest EEPROM release:
sudo -E rpi-eeprom-config --edit```
## References
- [gpio-shutdown overlay and low power state](https://github.com/seamusdemora/PiFormulae/blob/master/LoPwrOneButtonStartStop.md)
- [Stackexchange discussion refering to link above and GLOBAL_EN](https://raspberrypi.stackexchange.com/questions/117013/raspberry-pi-4-b-gpio-boot-and-shutdown-buttons)

View File

@ -0,0 +1,257 @@
# This describes trying to set up and install samba to allow sync from webstorm and remote debugging
- install `samba` package, see [ArchWiki](https://wiki.archlinux.org/title/Samba#Server)
##` /etc/samba/smb.conf`
```
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba,
# read the Samba-HOWTO-Collection. This may be obtained from:
# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the
# Samba-Guide which is generated daily and can be downloaded from:
# http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# Any line which starts with a ; (semi-colon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors.
#
#======================= Global Settings =====================================
[global]
# Restrict protocols for better security
server min protocol = SMB2_02
# Specify permissions
create mask = 0664
directory mask = 2755
force create mode = 0644
force directory mode = 2755
# Prefer encription
smb encrypt = auto
# Disable printing sharing
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
show add printer wizard = no
# Allow shares to be open to public without having to auth
security = user
map to guest = Bad Password
browseable = yes
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
workgroup = WORKGROUP
# server string is the equivalent of the NT Description field
server string = NoxBox Miel Samba
# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller".
#
# Most people will want "standalone server" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
server role = standalone server
# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
; hosts allow = 192.168.1. 192.168.2. 127.
# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
guest account = nobody
# this tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/%m.log
# Put a capping on the size of the log files (in Kb).
max log size = 50
# Specifies the Kerberos or Active Directory realm the host is part of
; realm = MY_REALM
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
passdb backend = tdbsam
# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting.
# Note: Consider carefully the location in the configuration file of
# this line. The included file is read at that point.
; include = /usr/local/samba/lib/smb.conf.%m
# Configure Samba to use multiple interfaces
# If you have multiple network interfaces then you must list them
# here. See the man page for details.
; interfaces = 192.168.12.2/24 192.168.13.2/24
# Where to store roving profiles (only for Win95 and WinNT)
# %L substitutes for this servers netbios name, %U is username
# You must uncomment the [Profiles] share below
; logon path = \\%L\Profiles\%U
# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
; wins support = yes
# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; wins server = w.x.y.z
# WINS Proxy - Tells Samba to answer name resolution queries on
# behalf of a non WINS capable client, for this to work there must be
# at least one WINS Server on the network. The default is NO.
; wins proxy = yes
# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups. The default is NO.
dns proxy = no
# These scripts are used on a domain controller or stand-alone
# machine to add or delete corresponding unix accounts
; add user script = /usr/sbin/useradd %u
; add group script = /usr/sbin/groupadd %g
; add machine script = /usr/sbin/adduser -n -g machines -c Machine -d /dev/null -s /bin/false %u
; delete user script = /usr/sbin/userdel %u
; delete user from group script = /usr/sbin/deluser %u %g
; delete group script = /usr/sbin/groupdel %g
#============================ Share Definitions ==============================
[homes]
comment = Home Directories
browseable = no
writable = yes
# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
; comment = Network Logon Service
; path = /usr/local/samba/lib/netlogon
; guest ok = yes
; writable = no
; share modes = no
# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
;[Profiles]
; path = /usr/local/samba/profiles
; browseable = no
; guest ok = yes
# NOTE: If you have a BSD-style print system there is no need to
# specifically define each individual printer
[printers]
comment = All Printers
path = /usr/spool/samba
browseable = no
# Set public = yes to allow user 'guest account' to print
guest ok = no
writable = no
printable = yes
# This one is useful for people to share files
;[tmp]
; comment = Temporary file space
; path = /tmp
; read only = no
; public = yes
# A publicly accessible directory, but read only, except for people in
# the "staff" group
;[public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = no
; printable = no
; write list = @staff
# Other examples.
#
# A private printer, usable only by fred. Spool data will be placed in fred's
# home directory. Note that fred must have write access to the spool directory,
# wherever it is.
;[fredsprn]
; comment = Fred's Printer
; valid users = fred
; path = /homes/fred
; printer = freds_printer
; public = no
; writable = no
; printable = yes
# A private directory, usable only by fred. Note that fred requires write
# access to the directory.
;[fredsdir]
; comment = Fred's Service
; path = /usr/somewhere/private
; valid users = fred
; public = no
; writable = yes
; printable = no
# a service which has a different directory for each machine that connects
# this allows you to tailor configurations to incoming machines. You could
# also use the %U option to tailor it by user name.
# The %m gets replaced with the machine name that is connecting.
;[pchome]
; comment = PC Directories
; path = /usr/pc/%m
; public = no
; writable = yes
# A publicly accessible directory, read/write to all users. Note that all files
# created in the directory by users will be owned by the default user, so
# any user with access can delete any other user's files. Obviously this
# directory must be writable by the default user. Another user could of course
# be specified, in which case all files would be owned by that user instead.
;[public]
; path = /usr/somewhere/else/public
; public = yes
; only guest = yes
; writable = yes
; printable = no
# The following two entries demonstrate how to share a directory so that two
# users can place files there that will be owned by the specific users. In this
# setup, the directory should be writable by both users and should have the
# sticky bit set on it to prevent abuse. Obviously this could be extended to
# as many users as required.
;[myshare]
; comment = Mary's and Fred's stuff
; path = /usr/somewhere/shared
; valid users = mary fred
; public = no
; writable = yes
; printable = no
; create mask = 0765
[data]
comment = Data
path = /data
public = no
writeable = yes
printable = no
```

View File

@ -7,10 +7,6 @@ WorkingDirectory=/data/services/i2c-amp-control
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=i2c-amp-control
#Environment=NODE_ENV=production PORT=1337
[Install]