Open main menu

Changes

X728-script

1,579 bytes added, 2 April
-->
Now we think you have successfully flashed the OS Image into Micro SD and and power on the device, and you have also completed the operations such as creating new user required in some OS. You need to perform the following operations in <code>Terminal</code>.
 
 
'''[Update]:'''
 
1. Use '''gpiod''' instead of obsolete interface
 
2. The script now supports the Raspberry Pi OS '''BOOKWORM''' version. You just need to '''uninstall''' the original script and '''reinstall''' it. Please refer to the following:
 
OPen ternimal window, then run the following command:
<pre>
mv x728-script x728-script-old
git clone https://github.com/geekworm-com/x728-script
cd x728-script
chmod +x *.sh
./uninstall.sh
</pre>
Then just follow the installation process below.
 
3. The current installation script also supports Raspberry Pi 5 hardware.
==OS that has been tested==
#68 - the address of the RTC chip
</PRE>
 
===Install gpiod package===
sudo apt install -y gpiod
===Clone the script===
'''PS''': For some OS such as 'Raspberry Pi OS Lite', the '''git''' tool is not installed by default, if you get an error like '''error: -bash: git: command not found''', please run the following command to install the git tool.
sudo apt install -y git
 
===Configuring Different GPIO Chip for Raspberry Pi 5 hardware===
If you are not using Raspberry 5 hardware, skip this step,or run the following command to set differnt chip and pwm number.
sed -i 's/xPWR.sh 0 5 12/xPWR.sh 4 5 12/g' x728-pwr.service
sed -i 's/xSoft.sh 0 26/xSoft.sh 4 26/g' install-sss.sh
sed -i 's/xSoft.sh 0 16/xSoft.sh 4 16/g' install-sss-v1.sh
===Create the x728-pwr service===
x728-pwr service will be responsible for power management and hardware safe shutdown.
<pre>
sudo cp -f ./x728-pwrxPWR.sh /usr/local/bin/
sudo cp -f x728-pwr.service /lib/systemd/system
sudo systemctl daemon-reload
===Prepair software shutdown script===
Please check the version of X728 shield and select the appropriate file, <code>x728-v2.x-softsd.sh</code> fiel * for <code>x728 v2.5/v2.3/v2.2/v2.1 shield</code>v2. then run the following command:0 sudo cp -f ./x728install-v2.x-softsd.sh /usr/local/bin/x728-softsdsss.sh'''OR''' (Run the following command * for <code>x728 v1.2/v1.3 shield</code>) sudo cp -f ./x728install-sss-v1.x-softsd.sh /usr/local/bin/x728-softsd.shCreate a alias <code>x728off</code> command to execute the software shutdown<pre>echo "alias x728off='sudo /usr/local/bin/x728-softsd.sh'" >> ~/.bashrcsource ~/.bashrc</pre>
Then you can run <code>x728off</code> to execute software shutdown as follows
x728off
===Uninstall===
Run the following command to uninstall all:
./uninstall.sh
===Test safe shutdown===
'''Software safe shutdown command''':
===Sample Files===
The example programs are only suitable for advanced players, and you can construct your own usage scenarios according to the example programs.
 
'''[PS]'''
 
The old example code uses the RPi.GPIO library, which is currently not supported in kernel 6.6.x, so you may encounter an error when running the following code
sudo python3 sample/x728-v2.x-plsd.py
 
Note that you need to provide a different gpiochip number on Pi 0,1,2,3,4 ('''0''') and Pi 5 ('''4''').
 
We recommend that you change your example program to use the libgpiod library, and libgpiod is officially recommended, and we also provide ONLY ONE example using the libgpiod library ('''x728-v2.x-plsd-gpiod.py'''), which you can run as follows:
 
sudo python3 sample/x728-v2.x-plsd-libgpiod.py
 
For other example programs that use the RPi.GPIO library, it is recommended that you change to the libgpiod version if it runs incorrectly.
 
In fact, you can change those sample program to shell
Each example program demonstrates a different function:
===Set and Read the RTC time===
Refer to [[How to enable RTC]]
 
==How to Use GPIO16 to control battery charging==
1. This feature is only newly added from '''Version 2.5'''
<pre style="color:blue">
# Sample shell command
 GPIO=16 # Read the /sys/kernel/debug/gpio file to get the actual GPIO pinGPIO=$(cat /sys/kernel/debug/gpio | grep "GPIO$GPIO" | awk -F'gpio-' '{print $2}' | awk -F' ' '{print $1}')echo "16$GPIO" > /sys/class/gpio$GPIO/exportecho "out" > /sys/class/gpio/gpio16gpio$GPIO/direction
# Enable charging
echo "1" > /sys/class/gpio/gpio16gpio$GPIO/value
# Disable charging
echo "0" > /sys/class/gpio/gpio16gpio$GPIO/value
</pre>