-
Notifications
You must be signed in to change notification settings - Fork 5
/
hw_model.sh
executable file
·964 lines (722 loc) · 23.3 KB
/
hw_model.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
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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
#!/bin/bash
{
if [[ ! -f /var/log/nems/hw_model ]]; then
touch /var/log/nems/hw_model
fi
#////////////////////////////////////
#
# Originally Created by Daniel Knight
# daniel.knight@dietpi.com / dietpi.com
#
# Adapted for NEMS by Robbie Ferguson
#
#////////////////////////////////////
#
# Info:
# - Generates /DietPi/dietpi/.hw_model
# - Called from /DietPi/dietpi/boot
#
# In DietPi-Software:
# MAX_HW_MODEL=64 #This needs to match highest HW_MODEL value in dietpi-obtain_hw_model
# MAX_HW_ARCH=10 #This needs to match highest HW_ARCH value in dietpi-obtain_hw_model
#
# - Line1 -
# HW_MODEL 121 Khadas VIM3 Pro
# HW_MODEL 120 Khadas VIM3 Basic
# HW_MODEL 110 RoseapplePi
# HW_MODEL 101 ASUS Tinker Board S
# HW_MODEL 100 ASUS Tinker Board
# HW_MODEL 90 A20-OLinuXino-MICRO
# HW_MODEL 80 Cubieboard 3
# HW_MODEL 79 Sparky SBC
# HW_MODEL 70 NanoPi NEO Plus2 (1 GB)
# HW_MODEL 69 NanoPi NEO Plus2 (512 MB)
# HW_MODEL 68 NanoPi M4 (4 GB)
# HW_MODEL 67 NanoPi M4 (2 GB)
# HW_MODEL 66 NanoPi M1 Plus
# HW_MODEL 65 NanoPi NEO 2
# HW_MODEL 64 NanoPi NEO Air
# HW_MODEL 63 NanoPi M1/T1
# HW_MODEL 62 NanoPi M3/T3
# HW_MODEL 61 NanoPi M2/T2
# HW_MODEL 60 NanoPi Neo
# HW_MODEL 51 BananaPi Pro (Lemaker)
# HW_MODEL 50 BananaPi M2+ (sinovoip)
# HW_MODEL 49 RockPro64 4GB
# HW_MODEL 48 RockPro64 2GB
# HW_MODEL 47 Rock64 4GB
# HW_MODEL 46 Rock64 2GB
# HW_MODEL 45 Rock64 1GB
# HW_MODEL 44 Pine A64-LTS/Sopine
# HW_MODEL 42 Pine A64+ (2048mb)
# HW_MODEL 41 Pine A64+ (1024mb)
# HW_MODEL 40 Pine A64 (512mb)
# HW_MODEL 38 OrangePi PC 2
# HW_MODEL 37 OrangePi Prime
# HW_MODEL 36 OrangePi Win
# HW_MODEL 35 OrangePi Zero Plus 2 (H3/H5)
# HW_MODEL 34 OrangePi Plus
# HW_MODEL 33 OrangePi Lite
# HW_MODEL 32 OrangePi Zero (H2+)
# HW_MODEL 31 OrangePi One
# HW_MODEL 30 OrangePi PC
# HW_MODEL 29 x86_64 native (PC)
# HW_MODEL 22 Amazon Web Services
# HW_MODEL 21 Docker Container
# HW_MODEL 20 VM x64 (VMware VirtualBox)
# HW_MODEL 16 ODROID-N2 (4 GB)
# HW_MODEL 15 ODROID-N2 (2 GB)
# HW_MODEL 13 oDroid U3
# HW_MODEL 12 ODROID-C2
# HW_MODEL 11 oDroid XU3/XU4/HC1/HC2
# HW_MODEL 10 oDroid C0/C1/C1+
# HW_MODEL 8 Raspberry Pi 4 (4GB)
# HW_MODEL 7 Raspberry Pi 4 (2GB)
# HW_MODEL 6 Raspberry Pi 4 (1GB)
# HW_MODEL 5 Raspberry Pi 3 Model A+
# HW_MODEL 4 Raspberry Pi 3 Model B+
# HW_MODEL 3 Raspberry Pi 3
# HW_MODEL 2 Raspberry Pi 2
# HW_MODEL 1 Raspberry Pi 1/Zero (512mb)
# HW_MODEL 0 Raspberry Pi 1 (256mb)
# - Line2 -
# HW_MODEL_DESCRIPTION
# - Line3 -
# DISTRO 0 unknown
# DISTRO 1 Debian Wheezy (No longer supported, http://dietpi.com/phpbb/viewtopic.php?f=9&t=432#p1898)
# DISTRO 2 Ubuntu 14.04 (No longer supported, left in for user message during update)
# DISTRO 3 Jessie
# DISTRO 4 Stretch, pulled a muscle!
# - Line4 -
# RootFS device path (eg: /dev/mmc01)
# - Line5 -
# UUID
# - Line 6 -
# HW_ARCH 10 x86_64 (VM)
# HW_ARCH 3 armv8/arm64
# HW_ARCH 2 armv7
# HW_ARCH 1 armv6
# HW_ARCH 0 unknown
# - Line 7 -
# HW_ARCH_DESCRIPTION
# - Line 8 -
# IMAGE_ADDITIONAL_CREDITS (eg: ARMbian, Meveric)
# - Line 9 - Group CPU's
# HW_CPUID 0 Not set
# HW_CPUID 1 H3
# HW_CPUID 2 H5
# - Line 10 - Onboard WiFi/BT Index
# HW_ONBOARD_WIFI 0 Not set
# HW_ONBOARD_WIFI 1 RPi3/ZeroW (BCM43438)
# - Line 11 - (RPi only)
# HW_REVISION_CODE
# - Line 12 - (RPi only)
# HW_RELEASE_DATE
# - Line 13 - (RPi only)
# HW_PCB_REVISION_CODE
# - Line 14 - (RPi only)
# HW_MEMORY_SIZE
# - Line 15 - (RPi only)
# HW_MANUFACTURER_NAME
#////////////////////////////////////
#Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales.
LANG=en_GB.UTF-8
#Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705
cd "$HOME"
#/////////////////////////////////////////////////////////////////////////////////////
#Obtain Hardware Model index
#/////////////////////////////////////////////////////////////////////////////////////
HW_MODEL=0
HW_MODEL_DESCRIPTION='Unknown Device'
FP_HW_MODEL_INDENTIFIER='/etc/.nems_hw_model_identifier'
DISTRO=0
HW_UUID=0
HW_ARCH=0
HW_ARCH_DESCRIPTION='unknown'
IMAGE_ADDITIONAL_CREDITS=''
HW_CPUID=0
HW_ONBOARD_WIFI=0
ROOTFS_DEVICE_PATH=$(df | grep -m1 '/$' | awk '{print $1}')
# RPi Extras
HW_REVISION_CODE=0
HW_RELEASE_DATE='Unknown'
HW_PCB_REVISION_CODE='Unknown'
HW_MEMORY_SIZE=0
HW_MANUFACTURER_NAME='Unknown'
RPi_BoardInfo(){
#-----------------------------------------------------------------------------------
#Obtain device info by revision number
# *" because 10000002 then it indicates that your Raspberry Pi has been over-volted
HW_REVISION_CODE=$(cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}')
HW_MODEL_DESCRIPTION='Raspberry Pi '
if [[ "$HW_REVISION_CODE" = *"Beta" ]]; then
HW_RELEASE_DATE='Q1 2012'
HW_MODEL_DESCRIPTION+='Beta'
HW_PCB_REVISION_CODE='Unknown'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Unknown'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0002" ]]; then
HW_RELEASE_DATE='Q1 2012'
HW_MODEL_DESCRIPTION+='B'
HW_PCB_REVISION_CODE='1.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Unknown'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0003" ]]; then
HW_RELEASE_DATE='Q3 2012'
HW_MODEL_DESCRIPTION+='B (ECN0001)'
HW_PCB_REVISION_CODE='1.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Unknown'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0004" ]]; then
HW_RELEASE_DATE='Q3 2012'
HW_MODEL_DESCRIPTION+='B'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0005" ]]; then
HW_RELEASE_DATE='Q4 2012'
HW_MODEL_DESCRIPTION+='B'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Qisda'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0006" ]]; then
HW_RELEASE_DATE='Q4 2012'
HW_MODEL_DESCRIPTION+='B'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Egoman'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0007" ]]; then
HW_RELEASE_DATE='Q1 2013'
HW_MODEL_DESCRIPTION+='A'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Egoman'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0008" ]]; then
HW_RELEASE_DATE='Q1 2013'
HW_MODEL_DESCRIPTION+='A'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0009" ]]; then
HW_RELEASE_DATE='Q1 2013'
HW_MODEL_DESCRIPTION+='A'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Qisda'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"000d" ]]; then
HW_RELEASE_DATE='Q4 2012'
HW_MODEL_DESCRIPTION+='B'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Egoman'
HW_MODEL=1
elif [[ "$HW_REVISION_CODE" = *"000e" ]]; then
HW_RELEASE_DATE='Q4 2012'
HW_MODEL_DESCRIPTION+='B'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=1
elif [[ "$HW_REVISION_CODE" = *"000f" ]]; then
HW_RELEASE_DATE='Q4 2012'
HW_MODEL_DESCRIPTION+='B'
HW_PCB_REVISION_CODE='2.0'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Qisda'
HW_MODEL=1
elif [[ "$HW_REVISION_CODE" = *"0010" ]]; then
HW_RELEASE_DATE='Q3 2014'
HW_MODEL_DESCRIPTION+='B+'
HW_PCB_REVISION_CODE='1.0'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=1
elif [[ "$HW_REVISION_CODE" = *"0011" ]]; then
HW_RELEASE_DATE='Q2 2014'
HW_MODEL_DESCRIPTION+='CM'
HW_PCB_REVISION_CODE='1.0'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=1
elif [[ "$HW_REVISION_CODE" = *"0012" ]]; then
HW_RELEASE_DATE='Q4 2014'
HW_MODEL_DESCRIPTION+='A+'
HW_PCB_REVISION_CODE='1.0'
HW_MEMORY_SIZE=256
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=0
elif [[ "$HW_REVISION_CODE" = *"0013" ]]; then
HW_RELEASE_DATE='Q1 2015'
HW_MODEL_DESCRIPTION+='B+'
HW_PCB_REVISION_CODE='1.2'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Unknown'
HW_MODEL=1
elif [[ "$HW_REVISION_CODE" = *"a01041" ]]; then
HW_RELEASE_DATE='Q1 2015'
HW_MODEL_DESCRIPTION+='2 Model B'
HW_PCB_REVISION_CODE='1.1'
HW_MEMORY_SIZE=1024
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=2
elif [[ "$HW_REVISION_CODE" = *"a020a0" ]]; then
HW_RELEASE_DATE='Q1 2017'
HW_MODEL_DESCRIPTION+='CM 3'
HW_PCB_REVISION_CODE='1.0'
HW_MEMORY_SIZE=1024
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=3
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" = *"a21041" ]]; then
HW_RELEASE_DATE='Q1 2015'
HW_MODEL_DESCRIPTION+='2 Model B'
HW_PCB_REVISION_CODE='1.1'
HW_MEMORY_SIZE=1024
HW_MANUFACTURER_NAME='Embest, China'
HW_MODEL=2
elif [[ "$HW_REVISION_CODE" = *"a02082" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q1 2016'
HW_MODEL_DESCRIPTION+='3'
HW_PCB_REVISION_CODE='1.2'
HW_MEMORY_SIZE=1024
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=3
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" = *"a22082" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q1 2016'
HW_MODEL_DESCRIPTION+='3'
HW_PCB_REVISION_CODE='1.2'
HW_MEMORY_SIZE=1024
HW_MANUFACTURER_NAME='Embest, China'
HW_MODEL=3
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" = *"a32082" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q4 2016'
HW_MODEL_DESCRIPTION+='3'
HW_PCB_REVISION_CODE='1.2'
HW_MEMORY_SIZE=1024
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=3
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" = *"900092" ]]; then
HW_RELEASE_DATE='Q4 2015'
HW_MODEL_DESCRIPTION+='Zero'
HW_PCB_REVISION_CODE='1.2'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=1
elif [[ "$HW_REVISION_CODE" = *"900093" ]]; then
HW_RELEASE_DATE='Q2 2016'
HW_MODEL_DESCRIPTION+='Zero'
HW_PCB_REVISION_CODE='1.3'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=1
elif [[ "$HW_REVISION_CODE" = *"9000c1" ]]; then
HW_RELEASE_DATE='Q1 2017'
HW_MODEL_DESCRIPTION+='Zero W'
HW_PCB_REVISION_CODE='1.1'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=1
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" = *"a020d3" ]]; then
HW_RELEASE_DATE='Q1 2018'
HW_MODEL_DESCRIPTION+='3 B+'
HW_PCB_REVISION_CODE='n/a'
HW_MEMORY_SIZE=1024
HW_MANUFACTURER_NAME='Sony'
HW_MODEL=4
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" == *"9020e0" ]]; then
HW_RELEASE_DATE='Q3 2018'
HW_MODEL_DESCRIPTION+='3 A+'
HW_PCB_REVISION_CODE='1.0'
HW_MEMORY_SIZE=512
HW_MANUFACTURER_NAME='Sony UK'
HW_MODEL=5
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" == *"a03111" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q2 2019'
HW_MODEL_DESCRIPTION+='4'
HW_PCB_REVISION_CODE='1.1'
HW_MEMORY_SIZE=1024
HW_MANUFACTURER_NAME='Sony UK'
HW_MODEL=6
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" == *"b03111" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q2 2019'
HW_MODEL_DESCRIPTION+='4'
HW_PCB_REVISION_CODE='1.1'
HW_MEMORY_SIZE=2048
HW_MANUFACTURER_NAME='Sony UK'
HW_MODEL=7
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" == *"b03112" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q1 2020'
HW_MODEL_DESCRIPTION+='4'
HW_PCB_REVISION_CODE='1.2'
HW_MEMORY_SIZE=2048
HW_MANUFACTURER_NAME='Sony UK'
HW_MODEL=7
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" == *"c03111" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q2 2019'
HW_MODEL_DESCRIPTION+='4'
HW_PCB_REVISION_CODE='1.1'
HW_MEMORY_SIZE=4096
HW_MANUFACTURER_NAME='Sony UK'
HW_MODEL=8
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" == *"c03112" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q1 2020'
HW_MODEL_DESCRIPTION+='4'
HW_PCB_REVISION_CODE='1.2'
HW_MEMORY_SIZE=4096
HW_MANUFACTURER_NAME='Sony UK'
HW_MODEL=8
HW_ONBOARD_WIFI=1
elif [[ "$HW_REVISION_CODE" == *"d03114" ]]; then
# This is a Model B board
HW_RELEASE_DATE='Q2 2020'
HW_MODEL_DESCRIPTION+='4'
HW_PCB_REVISION_CODE='1.4'
HW_MEMORY_SIZE=8192
HW_MANUFACTURER_NAME='Sony UK'
HW_MODEL=9
HW_ONBOARD_WIFI=1
fi
}
Obtain_HW_Info(){
#Systems that use /etc/.dietpi_hw_model_identifier for HW_MODEL
if [ -f "$FP_HW_MODEL_INDENTIFIER" ]; then
HW_MODEL=$(sed -n 1p "$FP_HW_MODEL_INDENTIFIER")
#RoseapplePi
if (( $HW_MODEL == 110 )); then
HW_MODEL_DESCRIPTION='RoseapplePi'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
# Khadas VIM3 Basic / Pro
elif (( $HW_MODEL == 120 )); then
HW_MODEL_DESCRIPTION='Khadas VIM3 '
IMAGE_ADDITIONAL_CREDITS='balbes150'
MEMTOTAL=$(free | awk '/^Mem:/{print $2}')
if (( $MEMTOTAL > 3000000 )); then
HW_MODEL_DESCRIPTION+='Pro'
HW_MODEL=121
else
HW_MODEL_DESCRIPTION+='Basic'
fi
#ASUS Tinker Board
elif (( $HW_MODEL == 100 )); then
HW_MODEL_DESCRIPTION='ASUS Tinker Board'
# See if this happens to be an S model
# Do so by seeing if eMMC drive exists (since it is built in to the S)
# Work in progress. Won't work like this because Tinker Board treats SD card as mmcblk. Need to test on an S to figure out a means of distinguishing between them.
# for f in /dev/mmcblk*; do
# [ -e "$f" ] && HW_MODEL_DESCRIPTION='ASUS Tinker Board S' && HW_MODEL=101
# break
# done
#A20-OLinuXino-MICRO
elif (( $HW_MODEL == 90 )); then
HW_MODEL_DESCRIPTION='A20-OLinuXino-MICRO'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
#Cubieboard 3
elif (( $HW_MODEL == 80 )); then
HW_MODEL_DESCRIPTION='Cubieboard 3'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
#Sparky SBC
elif (( $HW_MODEL == 79 )); then
HW_MODEL_DESCRIPTION='Sparky SBC'
# NanoPi NEO Plus2
elif (( $HW_MODEL == 69 )); then
MEMTOTAL=$(free | awk '/^Mem:/{print $2}')
if (( $MEMTOTAL > 1000000 )); then
HW_MODEL_DESCRIPTION='NanoPi NEO Plus2 (1 GB)'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_MODEL=69
else
HW_MODEL_DESCRIPTION='NanoPi NEO Plus2 (512 MB)'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_MODEL=70
fi
#NanoPi M4
elif (( $HW_MODEL == 67 )); then
MEMTOTAL=$(free | awk '/^Mem:/{print $2}')
if (( $MEMTOTAL > 3900000 )); then
HW_MODEL_DESCRIPTION='NanoPi M4 (4 GB)'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
HW_MODEL=68
else
HW_MODEL_DESCRIPTION='NanoPi M4 (2 GB)'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
HW_MODEL=67
fi
#NanoPi M1 Plus
elif (( $HW_MODEL == 66 )); then
HW_MODEL_DESCRIPTION='NanoPi M1 Plus'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#NanoPi NEO 2
elif (( $HW_MODEL == 65 )); then
HW_MODEL_DESCRIPTION='NanoPi NEO 2'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=2
#NanoPi NEO Air
elif (( $HW_MODEL == 64 )); then
HW_MODEL_DESCRIPTION='NanoPi NEO Air'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#NanoPi M1
elif (( $HW_MODEL == 63 )); then
HW_MODEL_DESCRIPTION='NanoPi M1/T1'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#NanoPi M3
elif (( $HW_MODEL == 62 )); then
HW_MODEL_DESCRIPTION='NanoPi M3/T3'
#NanoPi M2
elif (( $HW_MODEL == 61 )); then
HW_MODEL_DESCRIPTION='NanoPi M2/T2'
#NanoPi Neo
elif (( $HW_MODEL == 60 )); then
HW_MODEL_DESCRIPTION='NanoPi Neo'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#BananaPi M2+
elif (( $HW_MODEL == 50 )); then
HW_MODEL_DESCRIPTION='BananaPi M2+'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#BananaPi Pro
elif (( $HW_MODEL == 51 )); then
HW_MODEL_DESCRIPTION='BananaPi Pro'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
#Pine A64-LTS
elif (( $HW_MODEL == 44 )); then
HW_MODEL_DESCRIPTION='Pine A64-LTS/Sopine'
IMAGE_ADDITIONAL_CREDITS='Longsleep, Ayufan'
#Rock64
elif (( $HW_MODEL >= 45 && $HW_MODEL <= 47 )); then
IMAGE_ADDITIONAL_CREDITS='Longsleep, Ayufan'
MEMTOTAL=$(free | awk '/^Mem:/{print $2}')
if (( $MEMTOTAL > 4000000 )); then
HW_MODEL_DESCRIPTION='Rock64 4GB'
HW_MODEL=47
elif (( $MEMTOTAL > 2000000 )); then
HW_MODEL_DESCRIPTION='Rock64 2GB'
HW_MODEL=46
else
HW_MODEL_DESCRIPTION='Rock64 1GB'
HW_MODEL=45
fi
#RockPro64
elif (( $HW_MODEL >= 48 && $HW_MODEL <= 49 )); then
IMAGE_ADDITIONAL_CREDITS='Longsleep, Ayufan'
MEMTOTAL=$(free | awk '/^Mem:/{print $2}')
if (( $MEMTOTAL > 3900000 )); then
HW_MODEL_DESCRIPTION='RockPro64 4GB'
HW_MODEL=49
else
HW_MODEL_DESCRIPTION='RockPro64 2GB'
HW_MODEL=48
fi
#PineA64
elif (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then
IMAGE_ADDITIONAL_CREDITS='Longsleep, Rhkean'
MEMTOTAL=$(free | awk '/^Mem:/{print $2}')
if (( $MEMTOTAL > 2000000 )); then
HW_MODEL_DESCRIPTION='Pine A64+ 2GB'
HW_MODEL=42
elif (( $MEMTOTAL > 1000000 )); then
HW_MODEL_DESCRIPTION='Pine A64+ 1GB'
HW_MODEL=41
else
HW_MODEL_DESCRIPTION='Pine A64 512MB'
HW_MODEL=40
fi
#OrangePi PC 2
elif (( $HW_MODEL == 38 )); then
HW_MODEL_DESCRIPTION='OPi PC2'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=2
#OrangePi Prime
elif (( $HW_MODEL == 37 )); then
HW_MODEL_DESCRIPTION='OPi Prime'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=2
#OrangePi Win
elif (( $HW_MODEL == 36 )); then
HW_MODEL_DESCRIPTION='OPi Win'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
#OrangePi Zero Plus 2 (h3/h5)
elif (( $HW_MODEL == 35 )); then
HW_MODEL_DESCRIPTION='OPi Zero 2 Plus'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#OrangePi Plus
elif (( $HW_MODEL == 34 )); then
HW_MODEL_DESCRIPTION='OrangePi Plus'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#OrangePi Lite
elif (( $HW_MODEL == 33 )); then
HW_MODEL_DESCRIPTION='OrangePi Lite'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#Orange Pi Zero
elif (( $HW_MODEL == 32 )); then
HW_MODEL_DESCRIPTION='Orange Pi Zero'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
#HW_CPUID=1 #H2+
#OrangePi One
elif (( $HW_MODEL == 31 )); then
HW_MODEL_DESCRIPTION='OrangePi One'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#OrangePi Pc
elif (( $HW_MODEL == 30 )); then
HW_MODEL_DESCRIPTION='OrangePi PC'
IMAGE_ADDITIONAL_CREDITS='ARMbian'
HW_CPUID=1
#x86_64 native PC
elif (( $HW_MODEL == 29 )); then
HW_MODEL_DESCRIPTION='Native PC'
#Amazon Web Services
elif (( $HW_MODEL == 22 )); then
HW_MODEL_DESCRIPTION='Amazon Web Services'
#Docker Container
elif (( $HW_MODEL == 21 )); then
HW_MODEL_DESCRIPTION='Docker'
#VM
elif (( $HW_MODEL == 20 )); then
HW_MODEL_DESCRIPTION='Virtual Machine'
#oDroid U3
elif (( $HW_MODEL == 13 )); then
HW_MODEL_DESCRIPTION='ODROID U3'
#IMAGE_ADDITIONAL_CREDITS='Meveric'
elif (( $HW_MODEL == 12 )); then
HW_MODEL_DESCRIPTION='ODROID-C2'
IMAGE_ADDITIONAL_CREDITS='Meveric'
#oDroid XU3/4 via /etc/.dietpi_hw_model
elif (( $HW_MODEL == 11 )); then
HW_MODEL_DESCRIPTION='ODROID XU3/XU4/HC1/HC2'
IMAGE_ADDITIONAL_CREDITS='Meveric'
# ODROID-C0/C1/C1+
elif (( $HW_MODEL == 10 )); then
HW_MODEL_DESCRIPTION='ODROID C0/C1/C1+'
#ODROID-N2
elif (( $HW_MODEL == 15 )); then
MEMTOTAL=$(free | awk '/^Mem:/{print $2}')
if (( $MEMTOTAL > 3800000 )); then
HW_MODEL_DESCRIPTION='ODROID-N2 (4 GB)'
HW_MODEL=16
else
HW_MODEL_DESCRIPTION='ODROID-N2 (2 GB)'
IMAGE_ADDITIONAL_CREDITS='Meveric'
fi
# Logic Supply CL100
elif (( $HW_MODEL >= 98010 && $HW_MODEL <= 98019 )); then
MEMTOTAL=$(free | awk '/^Mem:/{print $2}')
if (( $MEMTOTAL > 7000000 )); then
HW_MODEL_DESCRIPTION='Logic Supply CL100 (8GB RAM)'
HW_MODEL=98010
elif (( $MEMTOTAL > 3000000 )); then
HW_MODEL_DESCRIPTION='Logic Supply CL100 (4GB RAM)'
HW_MODEL=98011
else
HW_MODEL_DESCRIPTION='Logic Supply CL100 (2GB RAM)'
HW_MODEL=98012
fi
fi
#RPi
elif (( $(cat /etc/os-release | grep -ci -m1 '^ID=raspbian') )); then
#Grab hardware description from rpi_boardinfo
RPi_BoardInfo
#odroid-C2
elif (( $(cat /proc/cpuinfo | grep -ci -m1 'ODROID-C2') )); then
HW_MODEL_DESCRIPTION='ODROID-C2'
HW_MODEL=12
IMAGE_ADDITIONAL_CREDITS='Meveric'
#oDroid XU3/4
elif (( $(cat /proc/cpuinfo | grep -ci -m1 'ODROID-XU3') )); then
HW_MODEL_DESCRIPTION='ODROID XU3/4'
HW_MODEL=11
IMAGE_ADDITIONAL_CREDITS='Meveric'
#oDroid C1
elif (( $(cat /proc/cpuinfo | grep -ci -m1 'ODROIDC') )); then
HW_MODEL_DESCRIPTION='ODROID C0 / C1 / C1+'
HW_MODEL=10
fi
#Get Distro Index (assumes jessie)
if (( $( cat /etc/*release | grep -ci -m1 'jessie') )); then
DISTRO=3
elif (( $( cat /etc/*release | grep -ci -m1 'stretch') )); then
DISTRO=4
fi
#Generate UUID if it doesnt not exist
if [ ! -f /DietPi/dietpi/.hw_model ]; then
HW_UUID=$(cat /proc/sys/kernel/random/uuid)
else
HW_UUID=$(sed -n 5p /DietPi/dietpi/.hw_model)
fi
#Obtain hardware cpu architecture
HW_ARCH_DESCRIPTION=$(uname -m)
if [ "$HW_ARCH_DESCRIPTION" = "armv6l" ]; then
HW_ARCH=1
elif [ "$HW_ARCH_DESCRIPTION" = "armv7l" ]; then
HW_ARCH=2
elif [ "$HW_ARCH_DESCRIPTION" = "aarch64" ]; then
HW_ARCH=3
elif [ "$HW_ARCH_DESCRIPTION" = "x86_64" ]; then
HW_ARCH=10
# - Unknown arch for DietPi, inform user by adding 'unknown'.
else
HW_ARCH_DESCRIPTION+=' (Unknown)'
fi
# - Add HW arch to HW desc
# HW_MODEL_DESCRIPTION+=" ($HW_ARCH_DESCRIPTION)"
#Save data
cat << _EOF_ > /var/log/nems/hw_model
$HW_MODEL
$HW_MODEL_DESCRIPTION
$DISTRO
$ROOTFS_DEVICE_PATH
$HW_UUID
$HW_ARCH
$HW_ARCH_DESCRIPTION
$IMAGE_ADDITIONAL_CREDITS
$HW_CPUID
$HW_ONBOARD_WIFI
$HW_REVISION_CODE
$HW_RELEASE_DATE
$HW_PCB_REVISION_CODE
$HW_MEMORY_SIZE
$HW_MANUFACTURER_NAME
_EOF_
}
#-----------------------------------------------------------------------------------
#Main
Obtain_HW_Info
#-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}