Wiki source code of Armbian OS instruction

Version 114.1 by Xiaoye on 2024/10/31 14:19

Show last authors
1 **Table of Contents:**
2
3 {{toc/}}
4
5
6
7
8 = 1.  Overview =
9
10
11 This is a general instruction for the use of Armbian base OS of Dragino devices. Current models include:
12
13 * HP0A
14 * HP0C
15 * LPS8v2
16 * MS20
17
18 (% style="display:none" %)
19
20
21 = 2.  Development Guide =
22
23
24 For advanced users to develop Driver/ Linux etc.
25
26
27 == 2.1  How to recompile LoRaWAN Concentrator Driver ( dragino-fwd package). ==
28
29
30 === (% style="color:blue" %)**Step 1. Clone dragino-fwd package**(%%) ===
31
32
33 **Requirements:**
34
35 **~ (% style="background-color:yellow; color:green" %)sudo apt install -y libsqlite3-dev(%%)**
36
37 **~ (% style="background-color:yellow; color:green" %)sudo apt install -y libftdi1-dev(%%)**
38
39
40 **Run command clone dragino-fwd package: (% style="background-color:yellow; color:green" %)git clone https:~/~/github.com/dragino/dragino_fwd_src.git(%%)**
41
42
43 [[image:image-20220527151010-1.png]]
44
45
46 === (% style="color:blue" %)**Step 2. Compile dragino_fwd**(%%) ===
47
48
49 **After cloning is complete, Run the command starts compiling:**
50
51 (% style="background-color:yellow; color:green" %)**Compile HP0C/HP0A fwd:  ./hp0z-make-deb.sh c**
52
53
54 The following example compilers HP0C fwd.
55
56 [[image:image-20220527153913-3.png]]
57
58
59
60 When the compilation is complete a** (% style="color:blue" %)draginofwd-*.deb(%%) **package is generated.
61
62 [[image:image-20220527154311-4.png||height="385" width="773"]]
63
64
65 === (% style="color:blue" %)**Step 3. Install the dragino_fwd**(%%) ===
66
67
68 **Run command:**
69
70 (% style="background-color:yellow; color:green" %)**dpkg -i draginofwd-*.deb **
71
72
73 [[image:image-20220527154811-5.png]]
74
75
76 === (% style="color:blue" %)**Step 4. Test**(%%) ===
77
78
79 **Check the dragino_fwd log:**
80
81 (% style="background-color:yellow; color:green" %)**journalctl -u draginofwd -f**
82
83
84 [[image:image-20220527165221-7.png||height="182" width="931"]]
85
86
87 **Start/stop dragino_fwd via systemctl:**
88
89 (% style="background-color:yellow; color:green" %)**systemctl start draginofwd**
90
91 (% style="background-color:yellow; color:green" %)**systemctl stop draginofwd**
92
93
94 == 2.2  How to clone Complete OS on the EMMC to SD card ==
95
96
97 **2.2.1 Prepare a USB flash drive/SD card and plug it into the USB port of the gateway.**
98
99
100
101
102 **2.2.2 Mounting a USB Flash Drive/SD Card in the Linux CLI**
103
104
105
106
107 **2.2.3 Using the dd command, copy Emmc as an img file**
108
109
110 dd if=/etc/sidmem of=/dev/mmcblk2p2 bs=1M count=1
111
112
113
114 **2.2.4 Export the img file and follow the steps in 2.3 for burning**
115
116
117 == 2.3  How to flash a new image(OS) to the gateway(LPS8V2) ==
118
119
120 Since the gateway has a large system, you need to use the sd card to reflash the system for the gateway
121
122
123 //2.3.1: Making an SD card with the new image//
124
125 //2.3.2: Instal the SD card to the gateway//
126
127 //2.3.3: Flash the image to the gateway's built memory from the SD card//
128
129 //2.3.4: Finished the process of flash and power cycle the gateway//
130
131
132 ==== (% style="background-color:yellow" %)**//Preparations~://**(%%) ====
133
134 1. Prepare an SD card
135 1. Prepare a card reader device
136 1. Download the OS image from the release.image~: **[[draginolps8v2-release-v1.7>>http://repo.dragino.com/release/hp0c-image/]]**
137 1. A Flash software tool ( Such as v1.7.9 from [[balenaEtcher>>url:https://www.balena.io/etcher/]] )
138 1. SD Card [[format>>url:http://repo.dragino.com/release/tool/PanasonicSDFormatter.zip]] tool
139
140 === **2.3.1 Making an SD Card with the new image** ===
141
142
143 ==== Step 1.  Formatting the SD Card ====
144
145 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20All%20Gateway%20models/HP0D/WebHome/image-20220609111027-9.png?rev=1.1||alt="image-20220609111027-9.png" height="318" width="292"]]
146
147
148 ==== Step 2. Select the OS image ====
149
150 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20All%20Gateway%20models/HP0D/WebHome/image-20220609104907-8.png?rev=1.1||alt="image-20220609104907-8.png" height="435" width="689"]]
151
152
153 ==== Step 3. Select the target ====
154
155 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20All%20Gateway%20models/HP0D/WebHome/image-20220609104637-2.png?rev=1.1||alt="image-20220609104637-2.png" height="436" width="690"]]
156
157 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20All%20Gateway%20models/HP0D/WebHome/image-20220609104701-3.png?rev=1.1||alt="image-20220609104701-3.png" height="436" width="690"]]
158
159
160 ==== Step 4. Flash start ====
161
162 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20All%20Gateway%20models/HP0D/WebHome/image-20220609104727-4.png?rev=1.1||alt="image-20220609104727-4.png" height="435" width="689"]]
163
164 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20All%20Gateway%20models/HP0D/WebHome/image-20220609104741-5.png?rev=1.1||alt="image-20220609104741-5.png" height="434" width="687"]]
165
166
167
168 === **2.3.2 Instal the SD card to the gateway** ===
169
170 1. Open the device's enclosure, and put the SD card into the SD card slot
171
172 [[image:image-20230712201032-1.png]]
173
174
175 2. Power the gateway with 5V2A, and access the gateway's Ethernet port to your PC
176
177 [[image:image-20230712201458-3.png||height="649" width="832"]]
178
179
180 Note: The PWR LED on red
181
182 The  LAN LED blink
183
184 The SYS LED on red
185
186
187
188 === **3.2.3 Flash the image to the gateway's built memory from the SD card** ===
189
190
191 Access the gateway Linux CLI to flash the image to the gateway's built memory
192
193
194 * **Use the IP address to access the gateway CLI**
195
196 Users can access the gateway CLI via the SSH protocol. Make sure your PC and the gateway are connected to the same network, then use a SSH tool (such as [[putty>>url:http://www.chiark.greenend.org.uk/~~sgtatham/putty/download.html]] in Windows) to access it.
197
198
199 IP address:  IP address of gateway or **Fallback IP**(172.31.255.254)
200
201 Port:  22
202
203 User Name:      (% style="color:blue" %)**root**
204
205 Password:         (% style="color:blue" %)**dragino**(%%) (default)
206
207 //After logging in, you will be in the gateway CLI and can enter commands as shown below.//
208
209
210 [[image:image-20230508155357-1.png||height="225" width="634"]]
211
212
213 **Run command:**
214
215 draginolps8v2-release-chirpsrtack-v1.7-240725 image :
216
217 (% style="background-color:#ffff00; color:#008000" %)** flash_emmc /usr/local/image/dragino-LPS8V2-ChirpStack-240725-1.img **
218
219 draginolps8v2-release-ttnstack-v1.7-240712 image :
220
221 (% style="background-color:#ffff00; color:#008000" %)** flash_emmc /usr/local/image/dragino-LPS8V2-TTN-231124.img**
222
223 [[image:image-20241008091850-2.png]]
224
225 (% style="color:red" %)**Note: Note: After the flash is completed, please power off the device (run the command halt) and disconnect the power supply, and then unplug the SD card.**
226
227
228 == 2.4 How to extend the gateway size of memory with SD card ==
229
230
231 Users can use the SD card slot to expand the gateway memory size by following the steps below
232
233
234 === 2.4.1 View SD card information ===
235
236 (% class="box infomessage" %)
237 (((
238 fdisk -l
239 )))
240
241 [[image:image-20230831150518-3.png]]
242
243
244 === 2.4.2 Displays the current file system disk usage statistics on Linux systems ===
245
246
247 (% class="box infomessage" %)
248 (((
249 df -h
250 )))
251
252 [[image:image-20230831150341-2.png]]
253
254
255 === 2.4.3 Mount SD card ===
256
257
258 (% class="box infomessage" %)
259 (((
260 mkdir /mnt/sd
261
262 mount /dev/mmcblk0p1 /mnt/sd
263 )))
264
265 After the mount is successful to check the file system disk usage on the Linux system again:
266
267 [[image:image-20230831151432-4.png]]
268
269
270 If the mount fails, you can format the file system and try the mount again
271
272 (% class="box infomessage" %)
273 (((
274 mkfs.ext4 /dev/mmcblk0p1
275 )))
276
277 == 2.5 Default Built Version ==
278
279
280 [[image:image-20220902155621-1.png]]
281
282
283 == 2.6 How to upgrade the nodejs version to the latest. ==
284
285
286 By default, the nodejs uses the pre-install version v12 which is due to Debian the ultra-stable via ultra-old.
287
288 [[image:image-20221112145029-2.png]]
289
290 **If you want to upgrade the nodejs to the latest, please follow to use these commands on the gateway CIL.**
291
292
293 #install n, which is an Interactively Manage Your Node.js Versions
294
295 [[image:image-20221112154230-3.png||height="89" width="689"]]
296
297 (% class="box infomessage" %)
298 (((
299 **npm install -g n**
300 )))
301
302
303 #Install the latest LTS Node.js release (downloading if necessary)
304
305 [[image:image-20221112154418-4.png||height="184" width="893"]]
306
307 (% class="box infomessage" %)
308 (((
309 **n lts**
310 )))
311
312
313 #Remove all downloaded versions except the installed version
314
315 [[image:image-20221112154456-5.png||height="139" width="899"]]
316
317 (% class="box infomessage" %)
318 (((
319 **n prune**
320 )))
321
322
323 (% class="box infomessage" %)
324 (((
325 **apt remove nodejs -y && apt autoremove -y && reboot**
326 )))
327
328
329 Check the current version
330
331 [[image:image-20221112154724-6.png]]
332
333 (% class="box infomessage" %)
334 (((
335 **node -v**
336 )))
337
338
339 == 2.7 How to install Grafana and influxdb ==
340
341
342 === **Grafana:** ===
343
344
345 (% class="box infomessage" %)
346 (((
347 curl https:~/~/packages.grafana.com/gpg.key | gpg ~-~-dearmor | sudo tee /usr/share/keyrings/grafana-archive-keyrings.gpg >/dev/null
348 echo "deb [signed-by=/usr/share/keyrings/grafana-archive-keyrings.gpg] https:~/~/packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
349 apt update && apt install grafana
350 )))
351
352
353 Check the running status:
354
355
356 (% class="box infomessage" %)
357 (((
358 systemctl status grafana-server
359 )))
360
361
362 configuration path:
363
364
365 (% class="box infomessage" %)
366 (((
367 /etc/grafana/grafana.ini
368 )))
369
370
371 === **Influxdb:** ===
372
373
374 (% class="box infomessage" %)
375 (((
376 curl https:~/~/repos.influxdata.com/influxdata-archive_compat.key | gpg ~-~-dearmor | sudo tee /usr/share/keyrings/influxdb-archive-keyring.gpg >/dev/null
377 echo "deb [signed-by=/usr/share/keyrings/influxdb-archive-keyring.gpg] https:~/~/repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
378 apt update && apt install influxdb
379 )))
380
381
382 Check the running status:
383
384
385 (% class="box infomessage" %)
386 (((
387 systemctl status influxdb
388 )))
389
390
391 configuration path:
392
393
394 (% class="box infomessage" %)
395 (((
396 /etc/influxdb/influxdb.conf
397 )))
398
399
400 = 3.  Package Management =
401
402 == 3.1 Default Package Maintain System ==
403
404 === 3.1.1  How Package-Auto-Update works? ===
405
406
407 By default, LPS8v2 / MS20 series products have an auto-update feature for main packages. The device will connect to Dragino's auto-update server and check for updates. 
408
409
410 (% style="color:blue" %)**When devices will check for updates**?
411
412 * Devices will check for updates for every boot.
413 * Devices will check for updates on every day midnight.
414
415 (% style="color:blue" %)**What packages will be checked for updates**?
416
417 dragino-httpd ~-~- Main Web UI http configuration
418
419 dragino-sid  ~-~- SN write and read tool
420
421 dragino-ui  ~-~- Gateway Web UI package
422
423 draginofwd   ~-~- UDP packet forwarder, LoRa Base Station
424
425 draginoups   ~-~- Miscellaneous between different versions
426
427
428
429 (% style="color:blue" %)**Location and changelog for packages**:
430
431 * Location: http:~/~/repo.dragino.com/release/tool/
432 * Changelog: [[http:~~/~~/repo.dragino.com/release/tool/Readme_HP0.txt>>http://repo.dragino.com/release/tool/Readme_HP0.txt]]
433
434 (% style="color:blue" %)**How to view auto-updated log**
435
436 You can view the log on the page of (% style="color:#037691" %)**System ~-~-> Package Management.**
437
438
439 [[image:1661305025451-220.png]]
440
441
442
443 (% style="color:blue" %)**Can I disable package-auto-update?**
444
445 You can check the checkbox and click the(% style="color:red" %)** ‘SAVE’ **(%%)button to enable or disable the auto-update.
446
447
448 [[image:1661305258501-636.png]]
449
450
451 === 3.1.2 How to manually update core packages? ===
452
453
454 You can click the (% style="color:red" %)**‘Manual Update’**(%%) to update the dragino's packages.
455
456
457 [[image:1661305328295-218.png]]
458
459
460 === 3.1.3 How to manually update other packages? ===
461
462
463 For the other packages, you have to access the device's CLI to do it via the apt command.
464
465
466 == 3.2 Set up a 3^^rd^^ party package maintain server ==
467
468 === 3.2.1 Overview ===
469
470
471 Customers can use their own package maintenance system instead of using the default one from Dragino. They need to set up a package maintenance system for Debian. Lots of instructions are available in Internet, below is a reference instruction.
472
473
474 === 3.2.2 Install Apache2 HTTP server ===
475
476
477 (% style="background-color:yellow; color:green" %)**apt install apache2**
478
479
480 === 3.2.3 Creating Package Directories ===
481
482
483 **~ (% style="background-color:yellow; color:green" %)cd /var/www/html/(%%)**
484
485 **~ (% style="background-color:yellow; color:green" %)mkdir debian/release/dists/stable/main/binary-armhf/ -p(%%)**
486
487 **~ (% style="background-color:yellow; color:green" %)mkdir debian/release/pool/main/d/dragino/ -p(%%)**
488
489
490 **Tree Structure:**
491
492 (% style="color:red" %)**Note: If you are not familiar with updating servers, most directory names are not recommended to be changed.**
493
494
495 └── debian
496
497 └── release
498
499 ├── dists
500
501 │   └── stable
502
503 │       └── main
504
505 │           └── binary-armhf
506
507 └── pool
508
509 └── main
510
511 └── d
512
513 └── dragino   ~-~-> (% style="background-color:yellow; color:green" %)**This is the directory to store the packages. User can change it to other name.**
514
515
516 === 3.2.4 Get deb packages ===
517
518
519 The deb packages for auto-update can be placed in** (% style="color:blue" %)/var/www/html/debian/release/pool/main/d/dragino/(%%)**
520
521 Below is an example package(testing-0808.deb) for test purpose:
522
523
524 **~ (% style="background-color:yellow; color:green" %)wget http:~/~/repo.dragino.com/release/tool/unimportant/testing-0808.deb(%%)**
525
526 **~ (% style="background-color:yellow; color:green" %)cp ./testing-0808.deb /var/www/html/debian/release/pool/main/d/dragino/(%%)**
527
528
529 === 3.2.5 Generate Package Index file ===
530
531
532 (% style="background-color:yellow; color:green" %)**cd /var/www/html/debian/release/**
533
534 (% style="background-color:yellow; color:green" %)**dpkg-scanpackages pool/ > dists/stable/main/binary-armhf/Packages**
535
536 (% style="background-color:yellow; color:green" %)**cat dists/stable/main/binary-armhf/Packages | gzip -9 > dists/stable/main/binary-armhf/Packages.gz**
537
538
539 (% style="color:red" %)**Note: Every time a package has been update, above comments need to be executed in the server to get the up-to-date package list.**
540
541
542 === 3.2.6 Generate Release file ===
543
544
545 ==== (% style="color:blue" %)**Create the generated script:**(%%) ====
546
547
548 (% style="background-color:yellow; color:green" %)**cd /var/www/html/debian/release/dists/stable**
549
550
551 (% style="background-color:yellow; color:green" %)**wget [[http:~~/~~/repo.dragino.com/release/tool/unimportant/generate-release.sh>>url:http://repo.dragino.com/release/tool/unimportant/generate-release.sh]]**
552
553 (% style="background-color:yellow; color:green" %)**chmod + x ./generate-release.sh**
554
555 (% style="background-color:yellow; color:green" %)**./generate-release.sh > Release**
556
557
558 === 3.2.7 Sign the Release file with gpg and generating Inrelease file ===
559
560
561 ==== (% style="color:blue" %)**Make sure auto-update server has gnupg**(%%) ====
562
563
564 (% style="background-color:yellow; color:green" %)**apt install gnupg**
565
566
567
568 ==== (% style="color:blue" %)**generate gpg key**(%%) ====
569
570
571 (% style="background-color:yellow; color:green" %)**gpg -gen-key**
572
573
574 (% style="color:red" %)**Note: Fill in the content as required and remember the name and email address.**
575
576
577
578 ==== (% style="color:blue" %)**Check the gen-key**(%%) ====
579
580
581 (% style="background-color:yellow; color:green" %)**gen -list-key**
582
583
584
585 ==== (% style="color:blue" %)**Generate the release.gpg**(%%) ====
586
587
588 (% style="background-color:yellow; color:green" %)**cd /var/www/html/debian/release/dists/stable**
589
590 (% style="background-color:yellow; color:green" %)**gpg ~-~-armor ~-~-detach-sign -o Release.gpg Release**
591
592
593 (% style="background-color:yellow; color:green" %)**gpg ~-~-clearsign -o InRelease Release**
594
595
596
597 ==== (% style="color:blue" %)**Generate the public key**(%%) ====
598
599
600 (% style="background-color:yellow; color:green" %)**gpg ~-~-armor ~-~-output <name>.asc ~-~-export <email address>**
601
602
603 **example: gpg ~-~-armor ~-~-output xiao.asc ~-~-export **[[xiaoye@dragino.cc>>mailto:xiaoye@dragino.cc]]
604
605
606
607 === 3.2.8 Add url as apt source in LPS8v2 / MS20 ===
608
609
610
611 ==== (% style="color:blue" %)**Add the public key**(%%) ====
612
613
614 (% style="background-color:yellow; color:green" %)**cp xiao.asc /etc/apt/trusted.gpg.d/**
615
616
617 (% style="color:red" %)**Note: First need to transfer the public key from auto-update server to device.**
618
619
620
621 ==== (% style="color:blue" %)**Add the apt source list**(%%) ====
622
623
624 Add the apt source list url and name this as test_server.list
625
626 (% style="background-color:yellow; color:green" %)**echo "deb http:~/~/<IP_address or hostname>/debian/release stable main" | tee /etc/apt/sources.list.d/test_server.list**
627
628
629
630 ==== (% style="color:blue" %)**Validate the apt repository**(%%) ====
631
632
633 Get and install the testing package (download testing-0808.deb and test)
634
635 (% style="background-color:yellow; color:green" %)**apt update && apt install testing**
636
637
638 Example output:
639
640 [[image:1661306420449-569.png]]
641
642
643 === 3.2.9 Configure the gateway's auto-upgrade rules ===
644
645
646 ==== (% style="color:blue" %)**Remove dragino apt source**(%%) ====
647
648
649 (% style="background-color:yellow; color:green" %)**/etc/apt/sources.list**
650
651
652 [[image:1661306460134-112.png]]
653
654
655
656 ==== (% style="color:blue" %)**Set up automatic updates**(%%) ====
657
658
659 (% style="background-color:yellow; color:green" %)**Path : /usr/lib/dragino/dragino-apt-updates**
660
661
662 The device performs automatic updates from this script,
663
664 But it will now only look for dragino as a keyword, so you need to replace the keyword dragino with your own keyword.
665
666
667 [[image:1661306487761-768.png]]
668
669
670