forked from doniks/pycom-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sqnsup_sdcard.py
90 lines (74 loc) · 2.05 KB
/
sqnsup_sdcard.py
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
import sqnsupgrade
from machine import SD
import os
import time
import pycom
import binascii
import machine
###########
# Sequans modem firmware update per SDCARD
# 1. copy the sequans firmware you want to use onto an sd card:
# folder structure should look like this:
# /sd
# /sd/NB1-41019
# /sd/NB1-41019/updater.elf
# /sd/NB1-41019/NB1-41019.dup
# 2. adjust the CONFIG variables below
# 3. insert SD card into expansion board
# 4. run this script on the device (e.g., via Atom Pymakr)
# 5. wait
print("sqnsup_sdcard.py")
print("sqnsupgrade.info:")
sqnsupgrade.info(debug=True)
try:
sd = SD()
os.mount(sd, '/sd')
except:
# assume it is mounted already
pass
dir='/sd'
########### CONFIG
# choose whether you want recovery update method, or normal update method
use_recovery = False
# choose whether you want to use full image or diff image
use_full = True
# choose target version
ver = 'NB1-41019'
# ver = 'CATM1-41065'
# run upgrade in debug mode or not
dbg = True
###########
dv = dir + "/" + ver + "/"
full = dv + ver + ".dup"
diff = dv + "upgdiff_33080-to-41019.dup"
updater = dv + "updater.elf"
############ main
# list and let it raise an exception if it doesn't exist
if use_recovery:
print("updater", updater)
print("updater", updater, os.stat(updater)[6]/1024, "KB")
else:
print("full", full)
print("full", full, os.stat(full)[6]/1024, "KB")
print("sys", os.uname().sysname)
print("unique_id", binascii.hexlify(machine.unique_id()))
print("release", os.uname().release)
x = time.time()
if use_full:
if use_recovery:
print("full, recovery", full, updater)
sqnsupgrade.run(full, updater)
else:
print("full, normal", full)
sqnsupgrade.run(full)
else:
# diff
print("diff", diff, os.stat(diff)[6]/1024, "KB")
if use_recovery:
print("NOT SUPPORTED (I think)")
else:
print("diff, normal", diff)
sqnsupgrade.run(diff, debug=dbg)
print("upgrade finished after", time.time() - x , "seconds")
# full, normal: ~ 380 seconds
sqnsupgrade.info(debug=True)