-
Notifications
You must be signed in to change notification settings - Fork 8
/
Banana_Pi_M2Z_GPIO.sh
423 lines (319 loc) · 11.4 KB
/
Banana_Pi_M2Z_GPIO.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
#!/bin/sh
echo ' __ __ _ ___ ___ '
echo ' | \/ | __ _ __| | ___ | _ ) _ _ | _ \ ___ __ __ __ _ ___ '
echo ' | |\/| | / _` | / _` | / -_) | _ \ | || | | / / _ \ \ \ / / _` | (_-< '
echo ' |_| |_| \__,_| \__,_| \___| |___/ \_, | |_|_\ \___/ /_\_\ \__,_| /__/ '
echo ' |__/ '
echo ''
echo ' Welcome to GPIO Installation Wizard for Bananapi m2 zero'
echo ' rev 1.6.1.2 '
sleep 5s
echo ''
echo '-------------------------Add Repositories and Update-------------------------'
echo ''
sleep 2s
sudo apt-get -y update
sudo apt-get -y upgrade
sleep 2s
sudo apt-get install -y software-properties-common
sleep 2s
sudo add-apt-repository -y universe
sudo add-apt-repository -y multiverse
sudo add-apt-repository -y restricted
sleep 2s
sudo apt-get -y update
sudo apt-get -y upgrade
sleep 2s
echo ''
echo '------------------Installation of Packages and Dependencies------------------'
echo ''
sleep 2s
sudo apt-get install -y inxi \
git \
build-essential \
python3-pip \
python3-dev \
python3-smbus \
i2c-tools \
vsftpd \
python3-pil \
python3-setuptools \
libfreetype6-dev \
libjpeg8-dev \
libsdl1.2-dev \
libsdl-dev \
libportmidi-dev \
libsdl-ttf2.0-dev \
libsdl-mixer1.2-dev \
libsdl-image1.2-dev \
libjpeg-dev \
python3-dev \
python-dev \
lm-sensors \
unrar \
libgpiod2 \
python3-libgpiod \
gpiod \
python3-all \
python3-all-dev \
debhelper \
armbian-config
sleep 2s
echo ''
echo '--------------------Installation of Libraries for Python---------------------'
echo ''
sleep 2s
sudo pip3 install setuptools==58.3.0
sudo pip3 install wheel==0.37.0
sudo pip3 install pyserial==3.5
sudo pip3 install pyusb==1.2.1
sudo pip3 install pyftdi==0.54.0
sudo pip3 install Adafruit-PureIO==1.1.9
sudo pip3 install Adafruit-PlatformDetect==3.22.0
sudo pip3 install Adafruit-Blinka==7.1.1
#sudo python3 -m pip install --upgrade pip setuptools wheel
#sudo pip3 install adafruit-circuitpython-ssd1306
#sudo pip3 install Adafruit-SSD1306
sudo pip3 install smbus2==0.4.1
sudo pip3 install Deprecated==1.2.13
sudo pip3 install Pillow==9.4.0
sudo pip3 install RPi.GPIO==0.6.3
sudo pip3 install spidev==3.5
sudo pip3 install argcomplete==2.1.1
sudo pip3 install wrapt==1.14.0
#sudo pip3 install --upgrade ssd1306
sudo pip3 install pusherclient==0.3.0
sudo pip3 install psutil==5.8.0
sudo pip3 install oauthlib==3.1.1
sudo pip3 install requests-oauthlib==1.3.0
sudo pip3 install tweepy==4.2.0
sudo pip3 install sgmllib3k==1.0.0
sudo pip3 install feedparser==6.0.8
sudo pip3 install subprocess.run==0.0.8
sudo pip3 install vcgencmd==0.1.1
#sudo pip3 install Pillow==9.2.0
#sudo pip3 install cbor2==5.4.3
#sudo -H pip install --upgrade pip setuptools
sleep 2s
echo ''
echo '-----------------Extract and Download Necessary Files of git-----------------'
echo ''
sleep 2s
echo 'What is your directory (example:/home/******)'
read directory
cd /home/$directory
echo ''
git clone https://github.com/TuryRx/Bananapi-m2-zero-GPIO-files.git
git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
###git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi2.git
git clone https://github.com/bontango/BPI-WiringPi2.git
git clone https://github.com/LeMaker/RPi.GPIO_BP -b bananapi
git clone https://github.com/codelectron/ssd1306.git
###git clone https://github.com/BPI-SINOVOIP/RPi.GPIO.git //Old library
###git clone https://github.com/GrazerComputerClub/RPi.GPIO.git
sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/luma.examples.rar /home/$directory
sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/luma.oled.rar /home/$directory
##sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/Adafruit_Python_GPIO.rar /home/$directory
##sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/BPI-WiringPi2.rar /home/$directory
##sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/RPi.GPIO_BP.rar /home/$directory
##sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/ssd1306.rar /home/$directory
##sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/RPi.GPIO.rar /home/$directory
##sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/luma.examples.rar /home/$directory
##sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/luma.oled.rar /home/$directory
sudo rm -R /home/$directory/BPI-WiringPi2/gpio/readall.c
sudo cp /home/$directory/Banana-pi-m2-zero-GPIO/readall.c /home/$directory/BPI-WiringPi2/gpio/
sleep 2s
echo ''
echo '--------------------------Install Downloaded Files----------------------------'
echo ''
sleep 2s
cd Adafruit_Python_GPIO
sudo python3 setup.py install
cd ..
cd BPI-WiringPi2
sudo chmod 777 build
sudo ./build
cd ..
cd RPi.GPIO_BP
sudo python3 setup.py install
cd ..
cd ssd1306
sudo python3 setup.py install
cd ..
sudo rm -R /usr/local/lib/python3.8/dist-packages/luma*
#cd luma.oled
#sudo python3 setup.py install
#cd ..
#cd RPi.GPIO
#sudo python3 setup.py install
#cd ..
sudo pip3 install Adafruit-SSD1306==1.6.2
sudo pip3 install ssd1306==0.2.0
sudo pip3 install adafruit-circuitpython-busdevice==5.1.0
sudo pip3 install adafruit-circuitpython-framebuf==1.4.7
sudo pip3 install adafruit-circuitpython-ssd1306==2.12.2
sudo pip3 install cbor2==5.4.2
#sudo pip3 install luma.core==2.3.1
sudo pip3 install luma.oled==3.8.1
echo ''
echo 'Complete file installation'
sleep 2s
echo ''
echo '----------------------------Copy Files for use GPIO---------------------------'
echo ''
sleep 2s
cd /home/$directory
cd Bananapi-m2-zero-GPIO-files/bpi-servicee
cd etc
sudo cp -r * /etc
cd ..
cd usr
sudo cp -r * /usr
cd ..
cd var
sudo cp -r * /var
cd ..
echo 'Files Copied Successfully'
sleep 2s
echo ''
echo '----------------------------------Fix Problems--------------------------------'
echo ''
sleep 2s
sudo rm -R /usr/local/lib/python3.8/dist-packages/RPi*
sudo unrar x /home/$directory/Banana-pi-m2-zero-GPIO/RPi.GPIO.rar /home/$directory/
cd /home/$directory/RPi.GPIO
sudo python3 setup.py install
cd ..
cd /home/$directory/RPi.GPIO_BP
sudo python3 setup.py install
cd ..
mv /home/$directory/Banana-pi-m2-zero-GPIO/bananapi-m2-zero-eth0.dtbo /boot/overlay-user/
echo 'Operation Successfully Completed'
sleep 2s
echo ''
echo '------------------------------Add User to i2c Group---------------------------'
echo ''
sleep 2s
sudo adduser $directory i2c
echo 'user successfully added to i2c group'
sleep 2s
echo ''
echo '------------------------------Increase swap memory----------------------------'
echo ''
sleep 2s
cd /home/$directory/Banana-pi-m2-zero-GPIO/
sudo chmod 777 swap_memori.sh
sudo ./swap_memori.sh
sleep 2s
echo ''
echo '---------------Completing System Files and Enable ftp in Sistem---------------'
echo ''
sleep 2s
sed -i 's/BOARD=bpi-m3/BOARD=bpi-m2z/g' /var/lib/bananapi/board.sh
sed -i 's/BOARD_AUTO=bpi-m3/BOARD_AUTO=bpi-m2z/g' /var/lib/bananapi/board.sh
sed -i 's/#write_enable=YES/write_enable=YES/g' /etc/vsftpd.conf
sed -i 's/#local_umask=022/local_umask=022/g' /etc/vsftpd.conf
sed -i 's/#chroot_local_user=YES/chroot_local_user=YES/g' /etc/vsftpd.conf
echo 'allow_writeable_chroot=YES' | sudo tee -a /etc/vsftpd.conf
echo 'pasv_enable=Yes' | sudo tee -a /etc/vsftpd.conf
echo 'pasv_min_port=40000' | sudo tee -a /etc/vsftpd.conf
echo 'pasv_max_port=40100' | sudo tee -a /etc/vsftpd.conf
cd /home/$directory
sudo mkdir /home/$directory/gpio-examples
cd Bananapi-m2-zero-GPIO-files
sudo chmod 777 led_m2z.py
sudo mv led_m2z.py /home/$directory
sudo chmod 777 led_button_m2z.py
sudo mv led_button_m2z.py /home/$directory
sudo chmod 777 button_state_m2z.py
sudo mv button_state_m2z.py /home/$directory
sudo chmod 777 button_event_m2z.py
sudo mv button_event_m2z.py /home/$directory
sudo chmod 777 gpio_funcion_m2z.py
sudo mv gpio_funcion_m2z.py /home/$directory
sudo chmod 777 info_board_m2z.py
sudo mv info_board_m2z.py /home/$directory
sudo chmod 777 info_gpio_m2z.py
sudo mv info_gpio_m2z.py /home/$directory
sudo chmod 777 pwm_m2z.py
sudo mv pwm_m2z.py /home/$directory
sudo chmod 777 button_pull_up_m2z.py
sudo mv button_pull_up_m2z.py /home/$directory
sudo chmod 777 gpio_read_pin_m2z.py
sudo mv gpio_read_pin_m2z.py /home/$directory
sudo chmod 777 button_event_rising_m2z.py
sudo mv button_event_rising_m2z.py /home/$directory
sudo chmod 777 sys_stats.py
sudo mv sys_stats.py /home/$directory/luma.examples/examples/
sudo chmod 777 gpioread.sh
sudo mv gpioread.sh /usr/local/bin/gpioread
sudo chmod o+x /usr/local/bin/gpioread
sudo chmod 777 /usr/local/bin/gpioread
sudo touch /var/lib/bananapi/gpio
sudo chmod o+x /var/lib/bananapi/gpio
sudo chmod 777 /var/lib/bananapi/gpio
cd ..
sudo mkdir gpio_files
sudo mv led_m2z.py gpio_files/
sudo mv led_button_m2z.py gpio_files/
sudo mv button_state_m2z.py gpio_files/
sudo mv button_event_m2z.py gpio_files/
sudo mv gpio_funcion_m2z.py gpio_files/
sudo mv info_board_m2z.py gpio_files/
sudo mv info_gpio_m2z.py gpio_files/
sudo mv pwm_m2z.py gpio_files/
sudo mv button_pull_up_m2z.py gpio_files/
sudo mv gpio_read_pin_m2z.py gpio_files/
sudo mv button_event_rising_m2z.py gpio_files/
sudo mv Adafruit_Python_GPIO/ gpio_files/
sudo mv Bananapi-m2-zero-GPIO-files/ gpio_files/
sudo mv BPI-WiringPi2/ gpio_files/
sudo mv luma.examples/ gpio_files/
sudo mv luma.oled/ gpio_files/
sudo mv RPi.GPIO/ gpio_files/
sudo mv RPi.GPIO_BP/ gpio_files/
sudo mv ssd1306/ gpio_files/
sudo chmod 777 -R * gpio_files/luma.examples/examples/
ln -s /home/$directory/gpio_files/luma.examples/examples/sys_stats.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/led_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/led_button_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/button_state_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/button_event_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/gpio_funcion_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/info_board_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/info_gpio_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/pwm_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/button_pull_up_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/gpio_read_pin_m2z.py /home/$directory/gpio-examples/
ln -s /home/$directory/gpio_files/button_event_rising_m2z.py /home/$directory/gpio-examples/
sudo chmod 775 -R * ~/
cd /home/$directory/
sudo mkdir Ethernet
cd /home/$directory/Banana-pi-m2-zero-GPIO/
sudo chmod 777 -R "Activate Ethernet.sh"
sudo chmod 777 -R "Disable Ethernet.sh"
sudo mv "Activate Ethernet.sh" /home/$directory/Ethernet/
sudo mv "Disable Ethernet.sh" /home/$directory/Ethernet/
echo ''
echo 'Operation Successfully Completed'
sleep 2s
echo ''
echo 'I hope and this script will help you to make the installation of the gpio pins'
echo 'a bit easier on the bananapi m2 zero'
echo ''
echo 'I leave you the link of my repository in more detailed git for this'
echo 'and the link of my channel if you like this type of development'
echo 'I would appreciate it if you would like and subscribe to my channel'
echo 'And if you like my work and want to support me so that'
echo 'I keep uploading more content, I ll leave you my ko-fi'
echo ''
echo 'Youtube TuryRx'
echo 'https://www.youtube.com/channel/UC2qm0bsEO0u1wBgiINs8-5w'
echo ''
echo 'github link'
echo 'https://github.com/TuryRx/Bananapi-m2-zero-GPIO'
echo ''
echo 'Ko-fi'
echo 'https://ko-fi.com/turyrx'
sleep 2s
echo ''