Skip to content

Commit c5b2786

Browse files
Minor fix on alternative root V3 procedure (flash) (#118)
* Minor fix on alternative root V3 procedure (flash)
1 parent ada6035 commit c5b2786

4 files changed

Lines changed: 215 additions & 195 deletions

File tree

_includes/ymodem_lantiq.html

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
<div class="modal" data-jtd-modal="flash-modal" data-jtd-modal-backdrop="static" id="flash-modal">
2+
<div class="modal-content">
3+
<div class="modal-header">
4+
<span class="close">&times;</span>
5+
<h2>Flash firmware</h2>
6+
</div>
7+
<form id="flash-form" class="p-4" novalidate>
8+
<div class="form-floating mb-3">
9+
<input type="file" class="form-control" placeholder="Flash MTD" name="flash-mtd" id="flash-mtd" required>
10+
<label for="flash-mtd">Flash MTD</label>
11+
</div>
12+
<div class="mb-3 form-check">
13+
<input type="checkbox" class="form-check-input" id="baud-rate-oc" name="baud-rate-oc">
14+
<label class="form-check-label" for="baud-rate-oc">230400 baud rate, do not enable unless told to do so</label>
15+
</div>
16+
<div class="form-check">
17+
<input class="form-check-input" type="radio" name="image" id="image0" value="image0">
18+
<label class="form-check-label" for="image0">
19+
Image 0
20+
</label>
21+
</div>
22+
<div class="form-check">
23+
<input class="form-check-input" type="radio" name="image" id="image1" value="image1">
24+
<label class="form-check-label" for="image1">
25+
Image 1
26+
</label>
27+
</div>
28+
<div class="mb-3">
29+
<input type="submit" class="btn btn-primary" value="Flash!">
30+
</div>
31+
<progress id="flash-progress" value="0" max="100"></progress>
32+
<p id="flash-text-step"></p>
33+
</form>
34+
</div>
35+
</div>
36+
37+
<script type="text/javascript" src="/assets/js/xymini.js"></script>
38+
{% if include.dontLoadRootScript != true %}
39+
<script type="text/javascript" src="/assets/js/rootLantiq.js"></script>
40+
<script type="text/javascript" src="/assets/js/serialUtil.js"></script>
41+
{% endif %}
42+
<script>
43+
if ('serial' in navigator) {
44+
document.getElementById('flash-start-button').disabled = false;
45+
} else {
46+
document.getElementById('flash-browser-error').style.display = 'block';
47+
}
48+
const acontroller = new AbortController();
49+
const cs = acontroller.signal;
50+
let flashModal = document.getElementById("flash-modal");
51+
let flashForm = document.getElementById("flash-form");
52+
let flashProgress = document.getElementById("flash-progress");
53+
let flashTextStep = document.getElementById("flash-text-step");
54+
flashModal.addEventListener('modal-jtd-close', async function(event) {
55+
acontroller.abort();
56+
});
57+
flashModal.addEventListener('modal-jtd-open', async function(event) {
58+
flash({signal: cs});
59+
});
60+
function initTextStep() {
61+
flashTextStep.textContent = "";
62+
flashTextStep.classList.remove('text-success-400');
63+
flashTextStep.classList.remove('text-error-400');
64+
}
65+
function pause(message) {
66+
flashTextStep.textContent = message;
67+
}
68+
function loading(message) {
69+
flashTextStep.textContent = message;
70+
}
71+
function showError(message) {
72+
flashTextStep.textContent = message;
73+
flashTextStep.classList.add('text-error-400');
74+
flashTextStep.classList.remove('text-success-400');
75+
}
76+
function showSuccess(message) {
77+
flashTextStep.textContent = message;
78+
flashTextStep.classList.add('text-success-400');
79+
flashTextStep.classList.remove('text-error-400');
80+
}
81+
async function flash({ signal } = {}) {
82+
initTextStep();
83+
let port;
84+
try {
85+
port = await navigator.serial.requestPort();
86+
} catch (err) {
87+
showError(`Error: ${err.message}`);
88+
console.log(`Error: ${err.message}\n`);
89+
return;
90+
}
91+
if (!port) {
92+
showError('Error: port not open');
93+
console.log('Error: port not open\n');
94+
return;
95+
}
96+
flashForm.addEventListener('submit', async function(event) {
97+
if (!flashForm.checkValidity()) {
98+
event.preventDefault();
99+
[...flashForm.elements].map(function(e){return e.parentNode}).forEach(function(e){e.classList.toogle('was-validated', true)});
100+
} else {
101+
event.preventDefault();
102+
[...flashForm.elements].map(function(e){return e.parentNode}).forEach(function(e){e.classList.toogle('was-validated', false)});
103+
var fomrdata = new FormData(flashForm);
104+
var file = fomrdata.get('flash-mtd');
105+
var image = fomrdata.get('image');
106+
var data = new Uint8Array(await file.arrayBuffer());
107+
console.log(data);
108+
109+
/* Unlock U-Boot if needed and stop booting */
110+
let result = await lantiqRootUboot(port, "{{include.modelName}}",
111+
(msg) => {
112+
loading(msg);
113+
console.log(msg);
114+
},
115+
(err) => {
116+
showError(err);
117+
console.log(err);
118+
}
119+
);
120+
121+
if (!result) {
122+
return;
123+
}
124+
125+
let baudrate = 115200;
126+
if(fomrdata.has('baud-rate-oc')) {
127+
let newBaudrate = 230400;
128+
loading(`Changing baudrate to: ${newBaudrate}`);
129+
130+
result = await changeBaudrate(port, newBaudrate, baudrate,
131+
(err) => {
132+
showError(err);
133+
console.log(err);
134+
}
135+
);
136+
137+
if (result) {
138+
baudrate = newBaudrate;
139+
} else {
140+
return;
141+
}
142+
}
143+
144+
loading("Start sending image to the SFP...");
145+
result = await sendImageMtd(port, data, baudrate,
146+
(err) => {
147+
showError(err);
148+
console.log(err);
149+
},
150+
(byteTransfered) => {
151+
const perc = (byteTransfered/data.length) * 100;
152+
const percTrunc = Math.trunc(perc*100)/100; /* Two decimal trunc */
153+
flashProgress.value = perc;
154+
loading(`Image transfer: ${percTrunc}% complete`)
155+
}
156+
);
157+
158+
if (!result) {
159+
return;
160+
}
161+
162+
result = await waitEndImageLoad(port, baudrate,
163+
(err) => {
164+
showError(err);
165+
console.log(err);
166+
}
167+
);
168+
169+
if (!result) {
170+
return;
171+
}
172+
173+
if(fomrdata.has('baud-rate-oc')) {
174+
let newBaudrate = 115200;
175+
loading(`Restore baudrate to: ${newBaudrate}`);
176+
177+
result = await changeBaudrate(port, newBaudrate, baudrate,
178+
(err) => {
179+
showError(err);
180+
console.log(err);
181+
}
182+
);
183+
184+
if (result) {
185+
baudrate = newBaudrate;
186+
} else {
187+
return;
188+
}
189+
}
190+
191+
loading("Transfer complete, image flash in progress. DO NOT REMOVE the SFP!");
192+
result = await flashImageMtd(port, image, baudrate,
193+
(err) => {
194+
showError(err);
195+
console.log(err);
196+
}
197+
);
198+
199+
if (result) {
200+
showSuccess("Flash completed, now you can remove the SFP");
201+
}
202+
}
203+
});
204+
};
205+
</script>

_ont/ont-huawei-ma5671a-root-web.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Connect the TTL adapter to the computer, once done press the following button. A
3535
{% include alert.html content="Your browser does not support JavaScript!" alert="Note" icon="svg-warning" color="red" %}
3636
</noscript>
3737

38+
{% include alert.html content="If this procedure does not work, you can use this [alternative procedure](/ont-huawei-ma5671a-ymodem)" alert="Info" icon="svg-info" color="blue" %}
3839

3940
# Connect to the stick via SSH
4041

_ont/ont-huawei-ma5671a-root.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ search_exclude: true
1515

1616
Can be accessed via the link [Web root procedure](/ont-huawei-ma5671a-root-web)
1717

18+
{% include alert.html content="If this procedure does not work, you can use this [alternative procedure](/ont-huawei-ma5671a-ymodem). Do not use the V2 and V1 versions under any circumstances." alert="Info" icon="svg-warning" color="red" %}
19+
1820
# Root Procedure for Huawei MA5671A (V2 - Python)
1921

2022
{% include alert.html content="This version remains for documentation purposes only. Please use the latest procedure: [Web root procedure](/ont-huawei-ma5671a-root-web)" alert="Important" icon="svg-warning" color="red" %}

0 commit comments

Comments
 (0)