-
-
Notifications
You must be signed in to change notification settings - Fork 506
/
Copy pathdietpi-obtain_hw_model
executable file
·730 lines (533 loc) · 17.2 KB
/
dietpi-obtain_hw_model
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
#!/bin/bash
{
#////////////////////////////////////
# DietPi
#
#////////////////////////////////////
# Created by Daniel Knight / [email protected] / dietpi.com
#////////////////////////////////////
#
# Info:
# - Location: /boot/dietpi/func/dietpi-obtain_hw_model
# - Generates /boot/dietpi/.hw_model
# - Called from /boot/dietpi/preboot, called by /etc/systemd/system/dietpi-preboot.service
#
# G_HW_MODEL 93 Orange Pi 5 Pro
# G_HW_MODEL 92 NanoPi M6
# G_HW_MODEL 91 Orange Pi 5 Max
# G_HW_MODEL 90 Radxa ZERO 3
# G_HW_MODEL 89 Orange Pi 3 LTS
# G_HW_MODEL 88 Orange Pi Zero 2W
# G_HW_MODEL 87 Orange Pi 3B
# G_HW_MODEL 86 ASUS Tinker Board 2
# G_HW_MODEL 85 ROCK 5A
# G_HW_MODEL 84 Star64
# G_HW_MODEL 83 Orange Pi Zero 3
# G_HW_MODEL 82 Orange Pi 5 Plus
# G_HW_MODEL 81 StarFive VisionFive 2
# G_HW_MODEL 80 Orange Pi 5
# G_HW_MODEL 79 NanoPi 6 series
# G_HW_MODEL 78 ROCK 5B
# G_HW_MODEL 77 ROCK 3A
# G_HW_MODEL 76 NanoPi R5S/R5C
# G_HW_MODEL 75 Container
# G_HW_MODEL 74 Radxa Zero
# G_HW_MODEL 73 ROCK Pi S
# G_HW_MODEL 72 ROCK 4
# G_HW_MODEL 70 Sparky SBC
# G_HW_MODEL 68 NanoPi M4/T4/NEO4
# G_HW_MODEL 67 NanoPi K1 Plus
# G_HW_MODEL 66 NanoPi M1 Plus
# G_HW_MODEL 65 NanoPi NEO2
# G_HW_MODEL 64 NanoPi NEO Air
# G_HW_MODEL 63 NanoPi M1
# G_HW_MODEL 62 NanoPi M3/T3/Fire3
# G_HW_MODEL 61 NanoPi M2/T2
# G_HW_MODEL 60 NanoPi NEO
# G_HW_MODEL 59 ZeroPi
# G_HW_MODEL 58 NanoPi M4V2
# G_HW_MODEL 57 NanoPi NEO Plus2
# G_HW_MODEL 56 NanoPi NEO3
# G_HW_MODEL 55 NanoPi R2S
# G_HW_MODEL 54 NanoPi K2
# G_HW_MODEL 52 ASUS Tinker Board
# G_HW_MODEL 49 Quartz64
# G_HW_MODEL 48 NanoPi R1
# G_HW_MODEL 47 NanoPi R4S
# G_HW_MODEL 46 Pinebook Pro
# G_HW_MODEL 45 PINE H64
# G_HW_MODEL 44 Pinebook
# G_HW_MODEL 43 ROCK64
# G_HW_MODEL 42 ROCKPro64
# G_HW_MODEL 40 PINE A64
# G_HW_MODEL 29 Generic Amlogic S922X
# G_HW_MODEL 28 Generic Amlogic S905
# G_HW_MODEL 27 Generic Allwinner H6
# G_HW_MODEL 26 Generic Allwinner H5
# G_HW_MODEL 25 Generic Allwinner H3
# G_HW_MODEL 24 Generic Rockchip RK3399
# G_HW_MODEL 23 Generic Rockchip RK3328
# G_HW_MODEL 22 Generic Device
# G_HW_MODEL 21 x86_64 PC
# G_HW_MODEL 20 x86_64 VM
# G_HW_MODEL 16 Odroid C4/HC4
# G_HW_MODEL 15 Odroid N2
# G_HW_MODEL 13 Odroid U3
# G_HW_MODEL 12 Odroid C2
# G_HW_MODEL 11 Odroid XU3/XU4/MC1/HC1/HC2
# G_HW_MODEL 10 Odroid C1
# G_HW_MODEL 5 Raspberry Pi 5
# G_HW_MODEL 4 Raspberry Pi 4/400
# G_HW_MODEL 3 Raspberry Pi 3/3+/Zero 2
# G_HW_MODEL 2 Raspberry Pi 2
# G_HW_MODEL 1 Raspberry Pi 1/Zero (512 MiB)
# G_HW_MODEL 0 Raspberry Pi 1 (256 MiB)
# ----------------
# G_HW_ARCH 11 riscv64
# G_HW_ARCH 10 x86_64/amd64
# G_HW_ARCH 3 aarch64/arm64
# G_HW_ARCH 2 armv7l/armhf
# G_HW_ARCH 1 armv6l/armhf
# G_HW_ARCH 0 unsupported
#----------------
# G_HW_CPUID 0 Not set
# G_HW_CPUID 1 Allwinner H3
# G_HW_CPUID 2 Allwinner H5
# G_HW_CPUID 3 Rockchip RK3399
# G_HW_CPUID 4 Amlogic S922X
# G_HW_CPUID 5 Allwinner H6
# G_HW_CPUID 6 Rockchip RK3328
# G_HW_CPUID 7 Amlogic S905
# G_HW_CPUID 8 Allwinner A64
# G_HW_CPUID 9 Rockchip RK3566
# G_HW_CPUID 10 Rockchip RK3568
# G_HW_CPUID 11 Rockchip RK3588
# ----------------
# G_DISTRO 6 Bullseye
# G_DISTRO 7 Bookworm
# G_DISTRO 8 Trixie
#////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////
# Obtain Hardware Model index
#/////////////////////////////////////////////////////////////////////////////////////
FP_G_HW_MODEL_IDENTIFIER='/etc/.dietpi_hw_model_identifier'
# Read .hw_model if existent to preserve existing G_HW_UUID
G_HW_UUID=
[[ -f '/boot/dietpi/.hw_model' ]] && . /boot/dietpi/.hw_model
[[ $G_HW_UUID ]] || G_HW_UUID=$(</proc/sys/kernel/random/uuid)
G_HW_MODEL=22
G_HW_MODEL_NAME='Generic Device'
G_HW_ARCH=0
G_HW_ARCH_NAME=$(uname -m)
G_HW_CPUID=0
G_HW_CPU_CORES=$(nproc --all)
G_ROOTFS_DEV=$(findmnt -Ufnro SOURCE -M /)
G_DISTRO=0
G_DISTRO_NAME='Unknown'
# RPi extras
G_RASPBIAN=0
G_HW_ONBOARD_WIFI=0
G_HW_REVISION=
G_HW_PCB_REVISION='Unknown'
G_HW_MEMORY_SIZE=512
G_HW_MANUFACTURER='Unknown'
RPi_BoardInfo(){
G_HW_MODEL=1
G_HW_MODEL_NAME='RPi (Unknown)'
# Detect if this is Raspbian/Raspberry Pi OS (32-bit) or Debian/Raspberry Pi OS (64-bit)
grep -q '^ID=raspbian' /etc/os-release && G_RASPBIAN=1
# Obtain device info by revision code: https://github.com/raspberrypi/documentation/tree/master/hardware/raspberrypi/revision-codes
G_HW_REVISION=$(mawk '/^Revision/{print $3;exit}' /proc/cpuinfo)
# New style revision codes: 6th hex char >= 8
if [[ ${G_HW_REVISION: -6:1} == [8-9a-f] ]]; then
# PCB revision
G_HW_PCB_REVISION=${G_HW_REVISION: -1:1}
# RPi model
# shellcheck disable=SC2249
case ${G_HW_REVISION: -3:2} in
00) G_HW_MODEL_NAME='RPi A';;
01) G_HW_MODEL_NAME='RPi B';;
02) G_HW_MODEL_NAME='RPi A+';;
03) G_HW_MODEL_NAME='RPi B+';;
04) G_HW_MODEL_NAME='RPi 2 Model B' G_HW_MODEL=2;;
05) G_HW_MODEL_NAME='RPi B';;
06) G_HW_MODEL_NAME='RPi CM';;
08) G_HW_MODEL_NAME='RPi 3 Model B' G_HW_MODEL=3 G_HW_ONBOARD_WIFI=1;;
09) G_HW_MODEL_NAME='RPi Zero';;
0a) G_HW_MODEL_NAME='RPi CM 3' G_HW_MODEL=3;;
0c) G_HW_MODEL_NAME='RPi Zero W' G_HW_ONBOARD_WIFI=1;;
0d) G_HW_MODEL_NAME='RPi 3 Model B+' G_HW_MODEL=3 G_HW_ONBOARD_WIFI=1;;
0e) G_HW_MODEL_NAME='RPi 3 Model A+' G_HW_MODEL=3 G_HW_ONBOARD_WIFI=1;;
10) G_HW_MODEL_NAME='RPi CM 3+' G_HW_MODEL=3;;
11) G_HW_MODEL_NAME='RPi 4 Model B' G_HW_MODEL=4 G_HW_ONBOARD_WIFI=1;;
12) G_HW_MODEL_NAME='RPi Zero 2 W' G_HW_MODEL=3 G_HW_ONBOARD_WIFI=1;;
13) G_HW_MODEL_NAME='RPi 400' G_HW_MODEL=4 G_HW_ONBOARD_WIFI=1;;
14) G_HW_MODEL_NAME='RPi CM 4' G_HW_MODEL=4;;
15) G_HW_MODEL_NAME='RPi CM 4S' G_HW_MODEL=4;;
17) G_HW_MODEL_NAME='RPi 5 Model B' G_HW_MODEL=5 G_HW_ONBOARD_WIFI=1;;
esac
# Manufacturer
# shellcheck disable=SC2249
case ${G_HW_REVISION: -5:1} in
0) G_HW_MANUFACTURER='Sony UK';;
1) G_HW_MANUFACTURER='Egoman';;
2|4) G_HW_MANUFACTURER='Embest';;
3) G_HW_MANUFACTURER='Sony Japan';;
5) G_HW_MANUFACTURER='Stadium';;
esac
# Memory size
G_HW_MEMORY_SIZE=$(( 256*2**( 16#${G_HW_REVISION: -6:1} - 8 ) ))
(( $G_HW_MEMORY_SIZE == 256 )) && G_HW_MODEL=0
# Old style revision codes
elif [[ $G_HW_REVISION == *'Beta' ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi B'
G_HW_MEMORY_SIZE=256
elif [[ $G_HW_REVISION == *'000'[23] ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi B'
G_HW_PCB_REVISION='1.0'
G_HW_MEMORY_SIZE=256
G_HW_MANUFACTURER='Egoman'
elif [[ $G_HW_REVISION == *'0004' ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi B'
G_HW_PCB_REVISION='2.0'
G_HW_MEMORY_SIZE=256
G_HW_MANUFACTURER='Sony UK'
elif [[ $G_HW_REVISION == *'0005' ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi B'
G_HW_PCB_REVISION='2.0'
G_HW_MEMORY_SIZE=256
G_HW_MANUFACTURER='Qisda'
elif [[ $G_HW_REVISION == *'0006' ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi B'
G_HW_PCB_REVISION='2.0'
G_HW_MEMORY_SIZE=256
G_HW_MANUFACTURER='Egoman'
elif [[ $G_HW_REVISION == *'0007' ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi A'
G_HW_PCB_REVISION='2.0'
G_HW_MEMORY_SIZE=256
G_HW_MANUFACTURER='Egoman'
elif [[ $G_HW_REVISION == *'0008' ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi A'
G_HW_PCB_REVISION='2.0'
G_HW_MEMORY_SIZE=256
G_HW_MANUFACTURER='Sony UK'
elif [[ $G_HW_REVISION == *'0009' ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi A'
G_HW_PCB_REVISION='2.0'
G_HW_MEMORY_SIZE=256
G_HW_MANUFACTURER='Qisda'
elif [[ $G_HW_REVISION == *'000'[df] ]]; then
G_HW_MODEL_NAME='RPi B'
G_HW_PCB_REVISION='2.0'
G_HW_MANUFACTURER='Egoman'
elif [[ $G_HW_REVISION == *'000e' ]]; then
G_HW_MODEL_NAME='RPi B'
G_HW_PCB_REVISION='2.0'
G_HW_MANUFACTURER='Sony UK'
elif [[ $G_HW_REVISION == *'0010' ]]; then
G_HW_MODEL_NAME='RPi B+'
G_HW_PCB_REVISION='1.2'
G_HW_MANUFACTURER='Sony UK'
elif [[ $G_HW_REVISION == *'0011' ]]; then
G_HW_MODEL_NAME='RPi CM'
G_HW_PCB_REVISION='1.0'
G_HW_MANUFACTURER='Sony UK'
elif [[ $G_HW_REVISION == *'0012' ]]; then
G_HW_MODEL=0
G_HW_MODEL_NAME='RPi A+'
G_HW_PCB_REVISION='1.1'
G_HW_MEMORY_SIZE=256
G_HW_MANUFACTURER='Sony UK'
elif [[ $G_HW_REVISION == *'0013' ]]; then
G_HW_MODEL_NAME='RPi B+'
G_HW_PCB_REVISION='1.2'
G_HW_MANUFACTURER='Embest'
elif [[ $G_HW_REVISION == *'0014' ]]; then
G_HW_MODEL_NAME='RPi CM'
G_HW_PCB_REVISION='1.0'
G_HW_MANUFACTURER='Embest'
elif [[ $G_HW_REVISION == *'0015' ]]; then
G_HW_MODEL_NAME='RPi A+'
G_HW_PCB_REVISION='1.1'
# 256M and 512M versions exist: Below estimation can be wrong, since GPU memory can take >256M on a 512M model
if (( $(mawk '/^MemTotal:/{print $2;exit}' /proc/meminfo) < 262144 )); then
G_HW_MODEL=0
G_HW_MEMORY_SIZE=256
fi
G_HW_MANUFACTURER='Embest'
elif (( $G_HW_ARCH > 1 ))
then
# In case of ARMv7/8 architecture, if no model was detected, fall back to RPi 2.
G_HW_MODEL=2
fi
}
# NB: PLEASE ENSURE HW_MODEL INDEX ENTRIES MATCH : dietpi-installer, dietpi-obtain_hw_model, dietpi-survey_results
# NBB: DO NOT REORDER INDEX's. These are now fixed and will never change (due to survey results etc)
Obtain_HW_Info(){
# Get distro ID
local distro=$(</etc/debian_version)
if [[ $distro == '11.'* ]]
then
G_DISTRO=6
G_DISTRO_NAME='bullseye'
elif [[ $distro == '12.'* ]]
then
G_DISTRO=7
G_DISTRO_NAME='bookworm'
elif [[ $distro == '13.'* || $distro == 'trixie/sid' ]]
then
G_DISTRO=8
G_DISTRO_NAME='trixie'
fi
# Obtain CPU architecture
if [[ $G_HW_ARCH_NAME == 'armv6l' ]]
then
G_HW_ARCH=1
elif [[ $G_HW_ARCH_NAME == 'armv7l' ]]
then
G_HW_ARCH=2
elif [[ $G_HW_ARCH_NAME == 'aarch64' ]]
then
G_HW_ARCH=3
elif [[ $G_HW_ARCH_NAME == 'x86_64' ]]
then
G_HW_ARCH=10
elif [[ $G_HW_ARCH_NAME == 'riscv64' ]]
then
G_HW_ARCH=11
else
# Unsupported by DietPi, inform user by adding 'Unsupported'
G_HW_ARCH_NAME+=' (Unsupported)'
fi
# Systems that use /etc/.dietpi_hw_model_identifier for G_HW_MODEL
if [[ -f $FP_G_HW_MODEL_IDENTIFIER ]]; then
G_HW_MODEL=$(mawk 'NR==1' "$FP_G_HW_MODEL_IDENTIFIER")
if (( $G_HW_MODEL == 93 )); then
G_HW_MODEL_NAME='Orange Pi 5 Pro'
G_HW_CPUID=11
elif (( $G_HW_MODEL == 92 )); then
G_HW_MODEL_NAME='NanoPi M6'
G_HW_CPUID=11
elif (( $G_HW_MODEL == 91 )); then
G_HW_MODEL_NAME='Orange Pi 5 Max'
G_HW_CPUID=11
elif (( $G_HW_MODEL == 90 )); then
G_HW_MODEL_NAME='Radxa ZERO 3'
G_HW_CPUID=9
elif (( $G_HW_MODEL == 89 )); then
G_HW_MODEL_NAME='Orange Pi 3 LTS'
G_HW_CPUID=5
elif (( $G_HW_MODEL == 88 )); then
G_HW_MODEL_NAME='Orange Pi Zero 2W'
elif (( $G_HW_MODEL == 87 )); then
G_HW_MODEL_NAME='Orange Pi 3B'
G_HW_CPUID=9
elif (( $G_HW_MODEL == 86 )); then
G_HW_MODEL_NAME='ASUS Tinker Board 2'
G_HW_CPUID=3
elif (( $G_HW_MODEL == 85 )); then
G_HW_MODEL_NAME='ROCK 5A'
G_HW_CPUID=11
elif (( $G_HW_MODEL == 84 )); then
G_HW_MODEL_NAME='Star64'
elif (( $G_HW_MODEL == 83 )); then
G_HW_MODEL_NAME='Orange Pi Zero 3'
elif (( $G_HW_MODEL == 82 )); then
G_HW_MODEL_NAME='Orange Pi 5 Plus'
G_HW_CPUID=11
elif (( $G_HW_MODEL == 81 )); then
G_HW_MODEL_NAME='StarFive VisionFive 2'
elif (( $G_HW_MODEL == 80 )); then
G_HW_MODEL_NAME='Orange Pi 5'
G_HW_CPUID=11
elif (( $G_HW_MODEL == 79 )); then
G_HW_MODEL_NAME='NanoPi 6 series'
G_HW_CPUID=11
elif (( $G_HW_MODEL == 78 )); then
G_HW_MODEL_NAME='ROCK 5B'
G_HW_CPUID=11
elif (( $G_HW_MODEL == 77 )); then
G_HW_MODEL_NAME='ROCK 3A'
G_HW_CPUID=10
elif (( $G_HW_MODEL == 76 )); then
G_HW_MODEL_NAME='NanoPi R5S/R5C'
G_HW_CPUID=10
elif (( $G_HW_MODEL == 75 )); then
G_HW_MODEL_NAME='Container'
grep -q '^ID=raspbian' /etc/os-release && G_RASPBIAN=1
elif (( $G_HW_MODEL == 74 )); then
G_HW_MODEL_NAME='Radxa Zero'
elif (( $G_HW_MODEL == 73 )); then
G_HW_MODEL_NAME='ROCK Pi S'
elif (( $G_HW_MODEL == 72 )); then
G_HW_MODEL_NAME='ROCK 4'
G_HW_CPUID=3
elif (( $G_HW_MODEL == 70 )); then
G_HW_MODEL_NAME='Sparky SBC'
elif (( $G_HW_MODEL == 68 )); then
G_HW_MODEL_NAME='NanoPi M4/T4/NEO4'
G_HW_CPUID=3
elif (( $G_HW_MODEL == 67 )); then
G_HW_MODEL_NAME='NanoPi K1 Plus'
G_HW_CPUID=2
elif (( $G_HW_MODEL == 66 )); then
G_HW_MODEL_NAME='NanoPi M1 Plus'
G_HW_CPUID=1
elif (( $G_HW_MODEL == 65 )); then
G_HW_MODEL_NAME='NanoPi NEO2'
G_HW_CPUID=2
elif (( $G_HW_MODEL == 64 )); then
G_HW_MODEL_NAME='NanoPi NEO Air'
G_HW_CPUID=1
elif (( $G_HW_MODEL == 63 )); then
G_HW_MODEL_NAME='NanoPi M1'
G_HW_CPUID=1
elif (( $G_HW_MODEL == 62 )); then
G_HW_MODEL_NAME='NanoPi M3/T3/Fire3'
elif (( $G_HW_MODEL == 61 )); then
G_HW_MODEL_NAME='NanoPi M2/T2'
elif (( $G_HW_MODEL == 60 )); then
G_HW_MODEL_NAME='NanoPi NEO'
G_HW_CPUID=1
elif (( $G_HW_MODEL == 59 )); then
G_HW_MODEL_NAME='ZeroPi'
G_HW_CPUID=1
elif (( $G_HW_MODEL == 58 )); then
G_HW_MODEL_NAME='NanoPi M4V2'
G_HW_CPUID=3
elif (( $G_HW_MODEL == 57 )); then
G_HW_MODEL_NAME='NanoPi NEO Plus2'
G_HW_CPUID=2
elif (( $G_HW_MODEL == 56 )); then
G_HW_MODEL_NAME='NanoPi NEO3'
G_HW_CPUID=6
elif (( $G_HW_MODEL == 55 )); then
G_HW_MODEL_NAME='NanoPi R2S'
G_HW_CPUID=6
elif (( $G_HW_MODEL == 54 )); then
G_HW_MODEL_NAME='NanoPi K2'
G_HW_CPUID=7
elif (( $G_HW_MODEL == 52 )); then
G_HW_MODEL_NAME='ASUS Tinker Board'
elif (( $G_HW_MODEL == 49 )); then
G_HW_MODEL_NAME='Quartz64'
G_HW_CPUID=9
elif (( $G_HW_MODEL == 48 )); then
G_HW_MODEL_NAME='NanoPi R1'
G_HW_CPUID=1
elif (( $G_HW_MODEL == 47 )); then
G_HW_MODEL_NAME='NanoPi R4S'
G_HW_CPUID=3
elif (( $G_HW_MODEL == 46 )); then
G_HW_MODEL_NAME='Pinebook Pro'
G_HW_CPUID=3
elif (( $G_HW_MODEL == 45 )); then
G_HW_MODEL_NAME='PINE H64'
G_HW_CPUID=5
elif (( $G_HW_MODEL == 44 )); then
G_HW_MODEL_NAME='Pinebook'
G_HW_CPUID=8
elif (( $G_HW_MODEL == 43 )); then
G_HW_MODEL_NAME='ROCK64'
G_HW_CPUID=6
elif (( $G_HW_MODEL == 42 )); then
G_HW_MODEL_NAME='ROCKPro64'
G_HW_CPUID=3
elif (( $G_HW_MODEL == 40 )); then
G_HW_MODEL_NAME='PINE A64'
G_HW_CPUID=8
elif (( $G_HW_MODEL == 29 )); then
G_HW_MODEL_NAME='Generic Amlogic S922X'
G_HW_CPUID=4
elif (( $G_HW_MODEL == 28 )); then
G_HW_MODEL_NAME='Generic Amlogic S905'
G_HW_CPUID=7
elif (( $G_HW_MODEL == 27 )); then
G_HW_MODEL_NAME='Generic Allwinner H6'
G_HW_CPUID=5
elif (( $G_HW_MODEL == 26 )); then
G_HW_MODEL_NAME='Generic Allwinner H5'
G_HW_CPUID=2
elif (( $G_HW_MODEL == 25 )); then
G_HW_MODEL_NAME='Generic Allwinner H3'
G_HW_CPUID=1
elif (( $G_HW_MODEL == 24 )); then
G_HW_MODEL_NAME='Generic Rockchip RK3399'
G_HW_CPUID=3
elif (( $G_HW_MODEL == 23 )); then
G_HW_MODEL_NAME='Generic Rockchip RK3328'
G_HW_CPUID=6
elif (( $G_HW_MODEL == 21 )); then
G_HW_MODEL_NAME='Native PC'
elif (( $G_HW_MODEL == 20 )); then
G_HW_MODEL_NAME='Virtual Machine'
elif (( $G_HW_MODEL == 16 )); then
G_HW_MODEL_NAME='Odroid C4/HC4'
elif (( $G_HW_MODEL == 15 )); then
G_HW_MODEL_NAME='Odroid N2'
G_HW_CPUID=4
elif (( $G_HW_MODEL == 13 )); then
G_HW_MODEL_NAME='Odroid U3'
elif (( $G_HW_MODEL == 12 )); then
G_HW_MODEL_NAME='Odroid C2'
G_HW_CPUID=7
elif (( $G_HW_MODEL == 11 )); then
G_HW_MODEL_NAME='Odroid XU3/XU4/MC1/HC1/HC2'
elif (( $G_HW_MODEL == 10 )); then
G_HW_MODEL_NAME='Odroid C1'
# Unknown hardware ID, revert to "Generic Device"
elif [[ $G_HW_MODEL != 22 ]]; then
G_HW_MODEL=22
echo "$G_HW_MODEL" > "$FP_G_HW_MODEL_IDENTIFIER"
fi
# RPi? Detect via ondisk device tree file instead of /proc content, for chroot/systemd-nspawn support
elif for i in /boot/{,firmware/}bcm*-rpi-*\.dtb; do [[ -f $i ]] && break; done; then
# Detect exact RPi model
RPi_BoardInfo
# No hardware identifier and no RPi, revert to "Generic Device"
else
echo "$G_HW_MODEL" > "$FP_G_HW_MODEL_IDENTIFIER"
fi
# Add CPU arch to device name
G_HW_MODEL_NAME+=" ($G_HW_ARCH_NAME)"
# Save data
echo "G_HW_MODEL=$G_HW_MODEL
G_HW_MODEL_NAME='$G_HW_MODEL_NAME'
G_HW_ARCH=$G_HW_ARCH
G_HW_ARCH_NAME='$G_HW_ARCH_NAME'
G_HW_CPUID=$G_HW_CPUID
G_HW_CPU_CORES=$G_HW_CPU_CORES
G_DISTRO=$G_DISTRO
G_DISTRO_NAME='$G_DISTRO_NAME'
G_ROOTFS_DEV='$G_ROOTFS_DEV'
G_HW_UUID='$G_HW_UUID'" > /boot/dietpi/.hw_model
# - RPi extras
if (( $G_HW_MODEL < 10 ))
then
echo "G_RASPBIAN=$G_RASPBIAN
G_HW_ONBOARD_WIFI=$G_HW_ONBOARD_WIFI
G_HW_REVISION='$G_HW_REVISION'
G_HW_PCB_REVISION=$G_HW_PCB_REVISION
G_HW_MEMORY_SIZE=$G_HW_MEMORY_SIZE
G_HW_MANUFACTURER='$G_HW_MANUFACTURER'" >> /boot/dietpi/.hw_model
elif (( $G_HW_MODEL == 75 && $G_RASPBIAN == 1 ))
then
echo 'G_RASPBIAN=1' >> /boot/dietpi/.hw_model
fi
}
#-----------------------------------------------------------------------------------
# Main
Obtain_HW_Info
#-----------------------------------------------------------------------------------
exit 0
#-----------------------------------------------------------------------------------
}