新增:FPGA 升级后热恢复射频链路

This commit is contained in:
2026-08-28 13:26:45 +08:00
parent 47b782e976
commit 33d8f4f428
7 changed files with 257 additions and 93 deletions
+132 -69
View File
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title id="webtitle"></title>
<script src="js/theme.js"></script>
<link href="css/styles.css" rel="stylesheet" media="screen">
<script src="js/auth.js"></script>
<script src="js/jquery.js"></script>
@@ -16,6 +17,13 @@ var lastTime = new Date().getTime();
var currentTime = new Date().getTime();
var timeOut = 20 * 60 * 1000; // 20 min
var upgrade_imx_flg = 0;
/* Keep the settings page authenticated while a long FPGA upload/flash is active. */
var fpga_upgrade_in_progress = 0;
function finishFpgaUpgrade(){
fpga_upgrade_in_progress = 0;
upgrade_imx_flg = 0; // resume normal status refresh
lastTime = new Date().getTime();
}
var remot_local_ctrl = 0; // 0 remote 1 local
var g_old_adpc_status = 0;
var g_old_adpc = 0;
@@ -37,7 +45,7 @@ $(function(){
function testTime(){
currentTime = new Date().getTime();
if(currentTime - lastTime > timeOut){
if(!fpga_upgrade_in_progress && currentTime - lastTime > timeOut){
window.location.href="login.cgi?logout=1"
}
@@ -145,6 +153,17 @@ $(document).ready(function(){
update_dpd_state();
});
/* REG-3 (2026-08-05) — ONE canonical control-lock list. The grey/green mismatch the owner
reported came from hand-typed parallel lists (the load-lock had 9 IDs; the IMX-upgrade
lock was missing #upgrade_fpga_id/#key_set_id/#ntp_set_id; the FPGA flash locked only
its own button). Every full-page lock/unlock now goes through lockAllControls();
NEVER re-type the ID list anywhere. Text (Loading.../Local Mode/Set) stays owned by
each call site — this helper owns only the disabled state. */
var ALL_CONTROL_IDS = '#para_set_id, #net_set_id, #sys_rtc_id, #sysreset_bt_id, #upgrade_imx_id, #upgrade_fpga_id, #key_set_id, #ntp_set_id, #timezone_set_id';
function lockAllControls(lock) {
$(ALL_CONTROL_IDS).attr("disabled", !!lock);
}
function SetFormDefaults(){
if(upgrade_imx_flg == 1) return;
@@ -154,7 +173,7 @@ function SetFormDefaults(){
var queryData = "sys_cfg=&sysnet=&imxsystime=&web_title=&system_a1_key=&ntp_server=&imx_timezone=&";
} else {
// Remote mode: show LOADING indicator
$('#para_set_id, #net_set_id, #sys_rtc_id, #sysreset_bt_id, #upgrade_imx_id, #upgrade_fpga_id, #key_set_id, #ntp_set_id, #timezone_set_id')
$(ALL_CONTROL_IDS)
.attr("disabled", true)
.val("Loading...");
var queryData = "sys_cfg=&sysnet=&imxsystime=&web_title=&system_a1_key=&ntp_server=&imx_timezone=&";
@@ -279,12 +298,12 @@ function SetFormDefaults(){
var currentCtlValue = Number(cf0.ctl.value);
if(currentCtlValue == 1) {
// Local mode: keep buttons disabled
$('#para_set_id, #net_set_id, #sys_rtc_id, #sysreset_bt_id, #upgrade_imx_id, #upgrade_fpga_id, #key_set_id, #ntp_set_id, #timezone_set_id')
$(ALL_CONTROL_IDS)
.attr("disabled", true)
.val("Local Mode");
} else {
// Remote mode: enable buttons
$('#para_set_id, #net_set_id, #sys_rtc_id, #sysreset_bt_id, #upgrade_imx_id, #upgrade_fpga_id, #key_set_id, #ntp_set_id, #timezone_set_id')
$(ALL_CONTROL_IDS)
.attr("disabled", false)
.val("Set");
$('#upgrade_imx_id').val("Upgrade");
@@ -461,7 +480,7 @@ function set_syspara() {
postData += "#"+cf.orx_manu_gain.value;
if(cf.ab_mode.value == "1" && Number(cf.adp.value) > 0) {
alert("The ADPC can't be set to Hold or Update or UpdateLIN/UpdateNLIN mode when 'FSSI Refresh' switch 'On' !!! Please change 'FSSI Refresh' to 'Off'.");
alert("The ADPC cannot be set to Hold or Update or UpdateLIN/UpdateNLIN mode when 'FSSI Refresh' switch is 'On'. Please change 'FSSI Refresh' to 'Off'.");
return;
} else {
var bak_adpc = Number(g_old_adpc);
@@ -510,6 +529,7 @@ function setsysnet() {
if(cmd_confirm()){
$.post("atsc_status_cfg.cgi?",postData,function(data, status){
if(status!="success"){ upgrade_imx_flg = 0; lockAllControls(false); return; } // P-5: release on failure
if(status=="success"){
SetFormDefaults();
} else{
@@ -522,6 +542,20 @@ function setsysnet() {
}
function sysresetff() {
/* P-5 (2026-08-06). Two gaps closed here, both proven against the 1.0:
(a) LOCAL-LOCKOUT: the 1.0 refuses a restart in Local mode and re-syncs the
form (its sys_set.html:926); smod posted regardless. A restart is
destructive, so it must honour the same lockout as every other write.
(b) CONTROL LOCK: the restart path locked nothing, so every Set/Upgrade
button stayed live (and green) while the unit rebooted — the owner's
hardware finding. REG-3 already built ONE lockAllControls(); the restart
simply never called it. Same single-lock-list class as the upgrades. */
if(remot_local_ctrl == 1){
cmd_confirm();
SetFormDefaults();
return;
}
var postData = "sysreset=";
var cf = document.getElementById("form_reset");
var prog_val = 1;
@@ -534,13 +568,14 @@ function sysresetff() {
if(cmd_confirm()){
upgrade_imx_flg = 1;
lockAllControls(true);
$.post("atsc_status_cfg.cgi?",postData,function(data, status){
if(status=="success"){
var t = setInterval(function() {
$('#rst_tb').hide();
$('#rst_progid').show();
$('#rst_note').text("System is now reseting. Please don't power off during the reseting. Wait for a minute and the page will automatically refreshed.");
$('#rst_note').text("The unit is now restarting. Please do not power off during the restart. Wait for a minute and the page will automatically refresh.");
var rst_prog_num = document.getElementById("rst_progid");
rst_prog_num.value = prog_val;
@@ -599,18 +634,15 @@ function uploadfile(){
}
var result=document.getElementById('result');
$('#upgrade_imx_id').attr("disabled",true);
// REG-3: ALL controls lock during an upgrade — including the FPGA/key/NTP buttons the
// old hand-typed list missed (the grey/green mismatch).
lockAllControls(true);
$('#formupgrade').attr("disabled",true);
$('#net_set_id').attr("disabled",true);
$('#para_set_id').attr("disabled",true);
$('#sys_rtc_id').attr("disabled",true);
$('#sysreset_bt_id').attr("disabled",true);
$('#timezone_set_id').attr("disabled",true);
var file = document.getElementById('Upgrade').files[0];
if (!file) {
alert('Please select a file');
$('#upgrade_imx_id').attr("disabled",false); // undo the disables above
lockAllControls(false); // undo the disables above (all of them)
$('#formupgrade').attr("disabled",false);
return
}
@@ -651,7 +683,7 @@ function uploadfile(){
$('#formupgrade').hide();
$('#prog_id').show();
$("#progress").hide();
$('#retnote').text("Code package has been uploaded successfully. System is now upgrading and reboot. Please don't power off the system during the upgrade. Wait for a minute and the page will automatically refreshed.");
$('#retnote').text("Code package uploaded successfully. System is now upgrading and rebooting. Please do not power off during the upgrade. Wait for a minute and the page will automatically refresh.");
SetFormDefaults();
var prog_num = document.getElementById("prog_id");
prog_num.value = widthddd;
@@ -689,7 +721,8 @@ function uploadFpgaFile(){
}
var result = document.getElementById('fpga_result');
document.getElementById('upgrade_fpga_id').disabled = true;
// REG-3: a flash locks the whole page's controls, not only its own button
lockAllControls(true);
// The .mcs is ~23 MB and takes ~10 min to land on the board's flash. The board runs a
// small forking httpd; if testTime() keeps firing update_dpd_state/get_ntp_server_state/
@@ -699,6 +732,8 @@ function uploadFpgaFile(){
// the imx6 package; the FPGA path was missing it, which is why large .mcs uploads never
// finished from the browser while a scripted POST (no background polling) did.
upgrade_imx_flg = 1;
fpga_upgrade_in_progress = 1;
lastTime = new Date().getTime();
var params = new FormData();
params.append('file', file);
@@ -706,12 +741,12 @@ function uploadFpgaFile(){
var xhr = new XMLHttpRequest();
xhr.onerror = function(){
alert('FPGA upload request failed');
document.getElementById('upgrade_fpga_id').disabled = false;
upgrade_imx_flg = 0; // let the dashboard resume
lockAllControls(false);
finishFpgaUpgrade();
};
xhr.onabort = xhr.ontimeout = function(){
document.getElementById('upgrade_fpga_id').disabled = false;
upgrade_imx_flg = 0;
lockAllControls(false);
finishFpgaUpgrade();
};
xhr.upload.onprogress = function(e){
var percent = Math.round(e.loaded / e.total * 100);
@@ -721,7 +756,17 @@ function uploadFpgaFile(){
// upload done -> the board now erases+writes the flash; track its progress
result.innerHTML = "Upload complete. Flashing FPGA... DO NOT power off.";
document.getElementById('fpga_progress').value = 0;
}
};
xhr.onload = function(){
if(xhr.status >= 200 && xhr.status < 300){
/* The CGI has accepted this request and reset the server-side status.
* Start polling now so a previous DONE result cannot be consumed. */
startFpgaFlashPoll();
}else{
alert('FPGA upload request failed');
lockAllControls(false);
finishFpgaUpgrade();
}
};
xhr.open('POST', 'fpga_upload.cgi', true);
@@ -747,26 +792,35 @@ function startFpgaFlashPoll(){
if(phase==='PENDING'){ result.innerHTML = "Preparing (stopping DPD)..."; bar.value = 0; }
else if(phase==='ERASE'){ result.innerHTML = "Erasing flash (~30s)..."; bar.value = 0; }
else if(phase==='WRITE'){ sawProgress = true; result.innerHTML = "Writing FPGA image ... " + pct + "%"; bar.value = pct; }
else if(phase==='DONE'){
else if(phase==='RELINK' || phase==='DONE'){
bar.value = 100;
result.innerHTML = "FPGA flash complete (100%). System is rebooting.";
note.innerText = "Done. FPGA reloaded + RF re-established automatically (no power cycle needed).";
clearInterval(poll); if(btn) btn.disabled = false;
result.innerHTML = "FPGA flash complete (100%). Re-establishing RF...";
note.innerText = "FPGA reloaded. Waiting for RF/JESD relink...";
}
else if(phase==='READY'){
var redirectLeft = 5;
bar.value = 100;
note.innerText = "RF re-established. Redirecting to login page...";
clearInterval(poll); lockAllControls(false); finishFpgaUpgrade();
result.innerHTML = "FPGA and RF are ready. Opening login page in " + redirectLeft + " s...";
var redirectTimer = setInterval(function(){
redirectLeft--;
if(redirectLeft <= 0){ clearInterval(redirectTimer); window.location.href = 'login.html'; }
else result.innerHTML = "FPGA and RF are ready. Opening login page in " + redirectLeft + " s...";
}, 1000);
}
else if(phase==='ERROR'){
result.innerHTML = "<span style='color:#d00;font-weight:bold'>FPGA flash FAILED (code " + ret + "). Aborted — check the device log. The board falls back to golden on cold boot.</span>";
clearInterval(poll); if(btn) btn.disabled = false;
clearInterval(poll); lockAllControls(false); finishFpgaUpgrade();
}
},
error:function(){
// the board reboots on success and drops the connection; if we had
// already seen write progress, treat a sustained drop as done-then-reboot
// FPGA reload may temporarily interrupt CGI access. Do not redirect
// until the backend explicitly publishes READY.
errAfterProgress++;
if(sawProgress && errAfterProgress >= 4){
bar.value = 100;
result.innerHTML = "FPGA flashed; board is rebooting (connection lost). Cold-restart it when it returns.";
note.innerText = "Done. FPGA reloaded + RF re-established automatically (no power cycle needed).";
clearInterval(poll); if(btn) btn.disabled = false;
result.innerHTML = "FPGA flashed. Waiting for RF/JESD relink...";
note.innerText = "Connection temporarily unavailable; retrying status check.";
}
}
});
@@ -1249,12 +1303,13 @@ function set_timezone() {
<div class="app-layout">
<aside class="app-sidebar">
<ul class="items">
<li><a href="overview.html" title="Overview">Overview</a></li>
<li><a href="status_info.html" title="Status">Status</a></li>
<li class="active"><a href="sys_set.html" title="Settings">Settings</a></li>
<li><a href="sys_rf.html" title="RF Control">RF Control</a></li>
<li><a href="sys_psip.html" title="TSID&PSIP">TSID&PSIP</a></li>
<li><a href="sys_ts.html" title="TSoIP">TSoIP</a></li>
<li><a href="sys_spectrum.html" title="Spectrum">Spectrum</a></li>
<li><a href="sys_spectrum.html" title="RF Performance">RF Performance</a></li>
<li><a href="log_output.html" title="Log">Log</a></li>
</ul>
<div class="sidebar-footer">
@@ -1274,8 +1329,15 @@ function set_timezone() {
</button>
<h1><a href="https://anywavecom.net/" class="logo-bg" title="Anywave Broadcast Inc."></a></h1>
<h2 id="webtitle_header"><span></span></h2>
<h3>
<div class="dropdown">
<h3 class="has-toggle">
<div class="utility-cluster">
<button class="theme-toggle" onclick="toggleTheme()" aria-label="Switch color theme" title="Switch color theme">
<span class="tt-sun" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg></span>
<span class="tt-moon" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg></span>
<span class="tt-label"><span class="tt-to-light">Light Mode</span><span class="tt-to-dark">Dark Mode</span></span>
</button>
<span class="utility-divider" aria-hidden="true"></span>
<div class="dropdown">
<button class="dropbtn-modern">Admin &#9662;</button>
<div class="dropdown-content">
<a href="#" onclick="openAccountModal(); return false;">
@@ -1295,7 +1357,8 @@ function set_timezone() {
</a>
</div>
</div>
</h3>
</div>
</h3>
</header>
<!-- Fixed Dashboard Summary - Top of page, under header -->
@@ -1321,16 +1384,6 @@ function set_timezone() {
<span class="summary-unit">dB</span>
</div>
</div>
<div class="summary-card">
<div class="summary-label-row">
<span class="status-dot status-ok" id="dot_uimd" aria-hidden="true"></span>
<span class="summary-label">UIMD</span>
</div>
<div class="summary-value-wrapper">
<span class="summary-value value-ok" id="sum_uimd">--</span>
<span class="summary-unit">dBc</span>
</div>
</div>
<div class="summary-card">
<div class="summary-label-row">
<span class="status-dot status-ok" id="dot_limd" aria-hidden="true"></span>
@@ -1341,6 +1394,16 @@ function set_timezone() {
<span class="summary-unit">dBc</span>
</div>
</div>
<div class="summary-card">
<div class="summary-label-row">
<span class="status-dot status-ok" id="dot_uimd" aria-hidden="true"></span>
<span class="summary-label">UIMD</span>
</div>
<div class="summary-value-wrapper">
<span class="summary-value value-ok" id="sum_uimd">--</span>
<span class="summary-unit">dBc</span>
</div>
</div>
<div class="summary-card">
<div class="summary-label-row">
<span class="status-dot status-off" id="dot_rf" aria-hidden="true"></span>
@@ -1596,7 +1659,7 @@ function set_timezone() {
</div>
<br>
<h2>RTC Configuration</h2>
<h2>Time &amp; Clock Configuration</h2>
<div class="box">
<form id="form_rtc">
<table>
@@ -1660,11 +1723,11 @@ function set_timezone() {
</tr>
</table>
</form>
</div>
<br>
<h2>NTP Server Configuration</h2>
<div class="box">
<!-- R4 (2026-08-11): RTC and NTP merged into ONE "Time & Clock Configuration"
section, matching the 1.0 (sys_set.html:1556-1642), which holds form_rtc and
form_ntp in a single .box separated by this hairline rule. Both forms, both
Set buttons and every field id are unchanged - only the section wrapper is. -->
<hr style="border:none; border-top:1px solid var(--border-subtle); margin:10px 0;">
<form id="form_ntp">
<table>
<tr>
@@ -1696,16 +1759,16 @@ function set_timezone() {
</div>
<br>
<h2>SYSTEM KEY</h2>
<h2>System Key</h2>
<div class="box">
<form id="form_key">
<table>
<tr>
<td>PSIP KEY</td>
<td>PSIP Key</td>
<td style="width:500px"><fieldset>
<input style="width:100px" maxlength="8" size="9" name="psip_key" id="psip_key" value="" oninput="validateHex(this)">
</fieldset></td>
<td>EAS KEY</td>
<td>EAS Key</td>
<td style="width:500px"><fieldset>
<input style="width:100px" maxlength="8" size="9" name="eas_key" id="eas_key" value="" oninput="validateHex(this)">
</fieldset></td>
@@ -1718,51 +1781,51 @@ function set_timezone() {
</div>
<br>
<h2>System Reset Configuration</h2>
<h2>Remote Restart</h2>
<div class="box">
<form id="form_reset">
<table id="rst_tb">
<tr>
<td>System Reset</td>
<td>Remote Restart</td>
<td>
<select name="sysreset" id="sysreset">
<option value="0">No
<option value="1">Yes
</select>
</td>
<td><input type="button" class="btn-modern" disabled id="sysreset_bt_id" alt="Set" value="Set" onclick="return sysresetff();"> </td>
<td><input type="button" class="btn-modern" disabled id="sysreset_bt_id" alt="Restart" value="Restart" onclick="return sysresetff();"> </td>
</tr>
</table>
</form>
</div>
<div><span id="rst_note" style="color:#0B77B7; font-size:14px" ></span></div>
<div><span id="rst_note" style="color:var(--info-text); font-size:14px" ></span></div>
<br><br>
<div>
<progress id="rst_progid" style="width:100%; margin-left:1px; display:none; color:#0bb710;" value="0" max="100"></progress>
<span id='rst_progsval' style="color:#0B77B7; font-size:18px;"></span>
<progress id="rst_progid" class="aw-progress" style="width:100%; margin-left:1px; display:none" value="0" max="100"></progress>
<span id='rst_progsval' style="color:var(--info-text); font-size:18px;"></span>
</div>
<br>
<h2>Remote Update</h2>
<h2>MCU Update (.tar.gz)</h2>
<div class="box">
<form id="formupgrade" target="myIframe" name="formupgrade" method="post" action="upload.cgi" enctype="multipart/form-data">
<div id="divupgrade" style="padding: 20px;">
<span id="LUpgrade" ></span>
<input name="Upgrade" type="file" id="Upgrade"/>
<input type="button" class="btn-modern" alt="UPGRADE" value="Upgrade" disabled id="upgrade_imx_id" onclick='uploadfile("imx")'>
<input name="Upgrade" type="file" id="Upgrade" accept=".tar.gz,.tgz"/>
<input type="button" class="btn-modern" alt="MCU UPGRADE" value="Upgrade MCU" disabled id="upgrade_imx_id" onclick='uploadfile("imx")'>
</div>
</form>
<iframe name="myIframe" id="myIframe" style="display: none;"></iframe>
</div>
<div><span id="retnote" style="color:#0B77B7; font-size:14px" ></span></div>
<div><span id="retnote" style="color:var(--info-text); font-size:14px" ></span></div>
<br><br>
<div>
<progress id="prog_id" style="width:100%; margin-left:1px; display:none; color:#0bb710;" value="0" max="100"></progress>
<progress id="prog_id" class="aw-progress" style="width:100%; margin-left:1px; display:none" value="0" max="100"></progress>
<br><br>
<span id='result' style="color: #0B77B7 ;font-size:18px"></span>
<progress id='progress' style="width:100%; margin-left:1px; color:#0B77B7; font-size:18px" value="0" max="100"></progress>
<span id='result' style="color:var(--info-text);font-size:18px"></span>
<progress id='progress' class="aw-progress" style="width:100%; margin-left:1px" value="0" max="100"></progress>
</div>
<br>
@@ -1777,11 +1840,11 @@ function set_timezone() {
</form>
<iframe name="myIframeFpga" id="myIframeFpga" style="display: none;"></iframe>
</div>
<div><span id="fpga_retnote" style="color:#0B77B7; font-size:14px"></span></div>
<div><span id="fpga_retnote" style="color:var(--info-text); font-size:14px"></span></div>
<br>
<div>
<span id='fpga_result' style="color: #0B77B7 ;font-size:18px"></span>
<progress id='fpga_progress' style="width:100%; margin-left:1px; color:#0B77B7; font-size:18px" value="0" max="100"></progress>
<span id='fpga_result' style="color:var(--info-text);font-size:18px"></span>
<progress id='fpga_progress' class="aw-progress" style="width:100%; margin-left:1px" value="0" max="100"></progress>
</div>
</main>