Virtualized X86 support (#807) - 4/28/2023

* x86 configs

* Update for new update system

* Build support

* Handle nowifi on status page
This commit is contained in:
Tim Wilkinson 2023-04-28 11:01:58 -07:00 committed by GitHub
parent 794d6caa89
commit 3863207c5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 273 additions and 244 deletions

View File

@ -48,6 +48,10 @@ jobs:
name: Build
command: make MAINTARGET=ipq40xx SUBTARGET=mikrotik
no_output_timeout: 2h
- run:
name: Build
command: make MAINTARGET=x86 SUBTARGET=64
no_output_timeout: 2h
- run:
name: Compress build files
command: tar -cjf ~/${CIRCLE_BRANCH}_${ARTIFACTS_FILE} -C ${MY_WORKING_DIRECTORY}/${ARTIFACTS_DIR} .

View File

@ -149,7 +149,7 @@ compile: stamp-clean-compiled .stamp-compiled
$(UMASK); \
$(MAKE) -C $(OPENWRT_DIR) $(MAKE_ARGS)
for FILE in `find $(TOP_DIR)/firmware/targets/$(MAINTARGET)/$(SUBTARGET) -path "*packages" -prune -o \( -type f -a \
! \( -name "*factory.bin" -o -name "*sysupgrade.bin" -o -name "*initramfs*" -o -name sha256sums -o -name "*.buildinfo" -o -name "*.json" \) \
! \( -name "*factory.bin" -o -name "*sysupgrade.bin" -o -name "*x86*" -o -name "*initramfs*" -o -name sha256sums -o -name "*.buildinfo" -o -name "*.json" \) \
-print \)`; do rm $$FILE; \
done;
$(TOP_DIR)/scripts/tests-postbuild.sh

6
configs/x86-64.config Executable file
View File

@ -0,0 +1,6 @@
CONFIG_TARGET_x86=y
CONFIG_TARGET_x86_64=y
CONFIG_TARGET_ALL_PROFILES=y
CONFIG_TARGET_ROOTFS_INITRAMFS=n
CONFIG_TARGET_ROOTFS_TARGZ=n
CONFIG_TARGET_ROOTFS_SQUASHFS=n

View File

@ -541,5 +541,8 @@
"name" : "Ubiquiti PowerBridge M5",
"maxpower" : "22",
"pwroffset" : "5"
},
"QEMU Standard PC (i440FX + PIIX, 1996)" : {
"name" : "QEMU PC"
}
}

View File

@ -240,6 +240,14 @@ function hardware.has_usb()
return false
end
function hardware.has_wifi()
if nixio.fs.stat("/sys/kernel/debug/ieee80211") then
return true
else
return false
end
end
function hardware.get_rfbandwidths(wifiintf)
return { 5, 10, 20 }
end

View File

@ -102,8 +102,8 @@ local ieee80211 = "/sys/class/ieee80211/"
local lanintf = aredn.hardware.get_board_network_ifname("lan")
local node = aredn_info.get_nvram("node")
local tactical = aredn_info.get_nvram("tactical")
local mac2 = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("wifi")), 0)
local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(lanintf:match("^(%S+)")), 0) -- *not* based of dtdlink
local mac2 = aredn_info.get_nvram("mac2")
local dtdmac = aredn_info.get_nvram("dtdmac")
local deleteme = {}
local cfg = {
@ -739,6 +739,7 @@ c:commit("dhcp")
local config = ""
local ifacenum = 0
local ifacecount = 0
if nixio.fs.stat(ieee80211) then
for devname in nixio.fs.dir(ieee80211)
do
ifacecount = ifacecount + 1
@ -853,6 +854,7 @@ do
ifacenum = ifacenum + 1
end
end
write_all("/etc/config/wireless", config)
if not auto then

View File

@ -55,10 +55,12 @@ local dtdmac = aredn_info.get_nvram("dtdmac")
local hardware_mac
if wifi_mac == "" or mac2 == "" then
local wlan = get_ifname("wifi")
if wlan then
local phy
for i = 1,5
do
local f = io.popen("iwinfo " .. get_ifname("wifi") .. " info")
local f = io.popen("iwinfo " .. wlan .. " info")
if f then
for line in f:lines()
do
@ -82,11 +84,19 @@ if wifi_mac == "" or mac2 == "" then
break
end
end
end
if not hardware_mac then
if not aredn.hardware.has_wifi() then
-- Non wifi device, create a random mac address instead
hardware_mac = capture([[hexdump -n5 -e'/5 "02" 5/1 ":%02X"' /dev/random]]):match("^(%S+)")
-- Disable wifi
os.execute("sed -i -e 's/wifi_enable = 1/wifi_enable = 0/' /etc/config.mesh/_setup")
else
io.stderr:write("ERROR: hardware mac not found\n")
os.exit(-1)
end
end
end
if wifi_mac == "" then
aredn_info.set_nvram("wifimac", hardware_mac)

View File

@ -186,7 +186,7 @@ if os.getenv("REQUEST_METHOD") == "POST" then
if not fp then
if meta and meta.file then
firmfile = meta.file
if firmfile:match("sysupgrade%.bin$") then
if firmfile:match("sysupgrade%.bin$") or firmfile:match("ext4%-combined%.img%.gz$") then
-- Uploading a system upgrade - clear out memory early
os.execute("/usr/local/bin/upgrade_prepare.sh stop > /dev/null 2>&1")
end
@ -226,6 +226,13 @@ serverpaths[#serverpaths + 1] = uciserverpath
local hardwaretype = aredn.hardware.get_type()
local targettype = conn:call("system", "board", {}).release.target
local local_firmware = "local_firmware.bin"
local firmware_type = "bin"
if targettype:match("x86") then
local_firmware = "local_firmware.img.gz"
firmware_type = "gz"
end
-- handle TPLink and Mikrotik exception conditions
local mfg = aredn.hardware.get_manufacturer()
local mfgprefix = ""
@ -237,52 +244,6 @@ elseif mfg:match("[Tt][Pp]-[Ll]ink") then
mfgprefix = "cpe"
end
local hardwaretypev
if hardwaretype == "nanostation-m" then
hardwaretypev = "nano-m" -- Nano XM
elseif hardwaretype == "nanostation-m-xw" then
hardwaretypev = "nano-m-xw" -- Nano XW
elseif hardwaretype == "rb-952ui-5ac2nd" then
hardwaretypev = "rb-nor-flash-16M-ac" -- hAP AC Lite
elseif hardwaretype:match("rb-911g-[25]hpnd") or hardwaretype:match("rb-912uag-[25]hpnd") then
hardwaretypev = "nand-large" -- Basebox 2/5 and QRT 2/5
elseif hardwaretype:match("rb-l[dfhg]+-[25]nd") or hardwaretype:match("rb-lhg-[25]hpnd") then
hardwaretypev = "rb-nor-flash-16M" -- LHGs & LDFs
elseif mfgprefix == "cpe" then
local hwmodel = aredn.hardware.get_board_id()
if hwmodel:match("CPE210 v1%.[01]") then
hardwaretypev = "210-220-v1" -- v1.0/v1.1
elseif hwmodel:match("CPE210 v2%.0") then
hardwaretypev = "210-v2" -- v2.0
elseif hwmodel:match("CPE210 v3%.0") then
hardwaretypev = "210-v3" -- v3.0
elseif hwmodel:match("CPE220 v2%.0") then
hardwaretypev = "220-v2" -- v3.0
elseif hwmodel:match("CPE220 v3%.0") then
hardwaretypev = "220-v3" -- v3.0
elseif hwmodel:match("CPE510 v2%.0") then
hardwaretypev = "510-v2" -- v2.0
elseif hwmodel:match("CPE510 v3%.0") then
hardwaretypev = "510-v3" -- v3.0
elseif hwmodel:match("CPE510") then
hardwaretypev = "510-520-v1" -- CPE510 V1.0/v1.1
elseif hwmodel:match("CPE605") then
hardwaretypev = "605-v1" -- CPE605 V1.0
elseif hwmodel:match("CPE610 v2%.0") then
hardwaretypev = "610-v2" -- CPE610 V2.0
elseif hwmodel:match("CPE610") then
hardwaretypev = "610-v1" -- CPE610 V1.0
elseif hwmodel:match("WBS510 v2%.0") then
mfgprefix="wbs"
hardwaretypev = "510-v2" -- WBS510 v2.0
elseif hwmodel:match("WBS210 v1%.[012]") then
mfgprefix="wbs"
hardwaretypev = "210-v1" -- WBS210 v1.0/v1.1
end
else
hardwaretypev = hardwaretype
end
-- refresh fw
if parms.button_refresh_fw then
nixio.fs.remove("/tmp/web/firmware.list")
@ -393,10 +354,14 @@ if f then
end
-- sideload fw
if parms.button_apply_fw and nixio.fs.stat("/tmp/web/local_firmware.bin") then
if parms.button_apply_fw and nixio.fs.stat("/tmp/web/" .. local_firmware) then
nixio.fs.mkdir("/tmp/web/upload")
os.execute("mv -f /tmp/web/local_firmware.bin /tmp/web/upload/file")
os.execute("mv -f /tmp/web/" .. local_firmware .. " /tmp/web/upload/file")
if firmware_type == "gz" then
firmfile = "arednmesh-sideload-ext4-combined.img.gz"
else
firmfile = "arednmesh-sideload-sysupgrade.bin"
end
parms.button_ul_fw = "Upload"
os.execute("/usr/local/bin/upgrade_prepare.sh stop > /dev/null 2>&1")
end
@ -404,7 +369,7 @@ end
-- upload fw
if parms.button_ul_fw and nixio.fs.stat("/tmp/web/upload/file") then
os.execute("mv -f /tmp/web/upload/file " .. tmpdir .. "/firmware")
if firmfile:match("sysupgrade%.bin$") then -- full firmware
if firmware_type == "bin" and firmfile:match("sysupgrade%.bin$") then -- full firmware
fw_install = true
-- drop the page cache to take pressure off tmps when checking the firmware
write_all("/proc/sys/vm/drop_caches", "3")
@ -419,6 +384,8 @@ if parms.button_ul_fw and nixio.fs.stat("/tmp/web/upload/file") then
fwout("Failed to restart all services, please reboot this node.")
end
end
elseif firmware_type == "gz" and firmfile:match("ext4%-combined%.img%.gz$") then -- full x86 firmware
fw_install = true
else
fwout("Firmware CANNOT be updated")
fwout("the uploaded file is not recognized")
@ -448,7 +415,7 @@ if parms.button_dl_fw and parms.dl_fw ~= "default" then
local fwimage
for _, image in ipairs(fwinfo.images)
do
if image.type == "sysupgrade" or image.type == "nand-sysupgrade" then
if (firmware.type == "bin" and (image.type == "sysupgrade" or image.type == "nand-sysupgrade")) or (firmware_type == "gz" and image.type == "combined") then
fwimage = {
url = fw_versions[parms.dl_fw].target .. "/" .. image.name,
sha = image.sha256
@ -468,7 +435,7 @@ if parms.button_dl_fw and parms.dl_fw ~= "default" then
end
end
else
err = "sysupgrade is not available"
err = "upgrade is not available"
end
else
err = "the downloaded file cannot be found"
@ -844,7 +811,7 @@ end
html.print("<tr>")
html.print("<td>Upload Firmware</td>")
html.print("<td><input style='width:100%' type=file name=firmfile title='choose the firmware file to install from your hard drive' accept='.bin'></td>")
html.print("<td><input style='width:100%' type=file name=firmfile title='choose the firmware file to install from your hard drive' accept='." .. firmware_type .. "'></td>")
html.print("<td align=center><input type=submit name=button_ul_fw value=Upload title='install the firmware'></td>")
html.print("</tr>")
@ -864,8 +831,8 @@ html.print("</tr>")
html.print("<tr>")
html.print("<td>Load Local Firmware</td>")
html.print("<td style='font-family:monospace'>")
html.print("<input type=submit name=button_apply_fw value='Apply Local Firmware' title='apply firmware previously uploaded to this node and named as shown' " .. (nixio.fs.stat("/tmp/web/local_firmware.bin") and "" or "disabled") .. ">")
html.print(" /tmp/web/local_firmware.bin</td>")
html.print("<input type=submit name=button_apply_fw value='Apply Local Firmware' title='apply firmware previously uploaded to this node and named as shown' " .. (nixio.fs.stat("/tmp/web/" .. local_firmware) and "" or "disabled") .. ">")
html.print(" /tmp/web/" .. local_firmware .. "</td>")
html.print("</tr>")
html.print("</table></td></tr>")

View File

@ -175,6 +175,7 @@ wan_gw = ""
passwd1 = ""
passwd2 = ""
local haswifi = aredn.hardware.has_wifi()
local wifiintf = aredn.hardware.get_iface_name("wifi")
local phy = iwinfo.nl80211.phyname(wifiintf)
local phycount = tonumber(capture("ls -1d /sys/class/ieee80211/* | wc -l"):chomp())
@ -226,8 +227,8 @@ end
if parms.button_default then
local node = aredn_info.get_nvram("node")
local mac2 = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("wifi")), 0)
local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("lan")), 0)
local mac2 = aredn_info.get_nvram("mac2")
local dtdmac = aredn_info.get_nvram("dtdmac")
for line in io.lines("/etc/config.mesh/_setup.default")
do
if not (line:match("^%s*#") or line:match("^%s*$")) then
@ -246,8 +247,8 @@ else
end
if parms.button_reset or not has_parms then
local node = aredn_info.get_nvram("node")
local mac2 = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("wifi")), 0)
local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("lan")), 0)
local mac2 = aredn_info.get_nvram("mac2")
local dtdmac = aredn_info.get_nvram("dtdmac")
for line in io.lines("/etc/config.mesh/_setup")
do
if not (line:match("^%s*#") or line:match("^%s*$")) then
@ -535,7 +536,6 @@ if parms.button_save then
if not valid then
err("invalid Mesh RF channel")
end
end
local wifi_country_validated = false
local countries = { "00","HX","AD","AE","AL","AM","AN","AR","AT","AU","AW","AZ","BA","BB","BD","BE","BG","BH","BL","BN","BO","BR","BY","BZ","CA","CH","CL","CN","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GE","GB","GD","GR","GL","GT","GU","HN","HK","HR","HT","HU","ID","IE","IL","IN","IS","IR","IT","JM","JP","JO","KE","KH","KP","KR","KW","KZ","LB","LI","LK","LT","LU","LV","MC","MA","MO","MK","MT","MY","MX","NL","NO","NP","NZ","OM","PA","PE","PG","PH","PK","PL","PT","PR","QA","RO","RS","RU","RW","SA","SE","SG","SI","SK","SV","SY","TW","TH","TT","TN","TR","UA","US","UY","UZ","VE","VN","YE","ZA","ZW" }
@ -550,6 +550,7 @@ if parms.button_save then
wifi_country = "00"
err("Invalid country")
end
end
if lan_proto == "static" then
if not validate_netmask(lan_mask) then
@ -1035,7 +1036,7 @@ html.print([[
]])
-- reset wifi channel/bandwidth to default
if nixio.fs.stat("/etc/config/unconfigured") or parms.button_reset then
if haswifi and (nixio.fs.stat("/etc/config/unconfigured") or parms.button_reset) then
local defaultwifi = aredn.hardware.get_default_channel(wifiintf)
wifi_channel = defaultwifi.channel
wifi_chanbw = tostring(defaultwifi.bandwidth)
@ -1043,16 +1044,22 @@ end
-- mesh rf settings
html.print("<table width=100% style='border-collapse: collapse;'>")
if haswifi then
html.print("<tr><th colspan=2>Mesh RF (" .. (M3model and "3GHz" or M9model and "900MHz" or wifi_channel < 36 and "2GHz" or "5GHz") .. ")</th></tr>")
else
html.print("<tr><th colspan=2>Mesh</th></tr>")
end
hidden[#hidden + 1] = "<input type=hidden name=wifi_proto value='static'>"
-- add enable/disable
if haswifi then
html.print("<tr><td>Enable</td><td><input type=checkbox name=wifi_enable value=1")
if wifi_enable == "1" then
html.print(" checked")
end
html.print("></td></tr>")
end
html.print("<tr><td><nobr>IP Address</nobr></td><td><input type=text size=15 name=wifi_ip value='" .. wifi_ip .. "'></td></tr><tr><td>Netmask</td><td><input type=text size=15 name=wifi_mask value='" .. wifi_mask .. "'></td></tr>")
if wifi_enable == "1" then

View File

@ -153,11 +153,12 @@ if config == "" or nixio.fs.stat("/etc/config.mesh", "type") ~= "dir" then
config = "not set"
end
local haswifi = aredn.hardware.has_wifi()
local wifi_iface = aredn.hardware.get_iface_name("wifi")
local wifi_nr = wifi_iface:match("wlan(%d+)")
local wifi_disabled = true
local radio = "radio0"
if wifi_nr then
if haswifi and wifi_nr then
wifi_disabled = false
radio = "radio" .. wifi_nr
end
@ -260,7 +261,7 @@ if config == "not set" then
config_mode = "ram"
for line in io.lines("/proc/mounts")
do
if line:match("overlay") then
if line:match("overlay") or line:match("ext4") then
config_mode = "setup"
break
end
@ -305,13 +306,19 @@ local col2 = {}
-- left column - network interface info
local ip = cursor:get("network", "wifi", "ipaddr")
local cidr = netmask_to_cidr(cursor:get("network", "wifi", "netmask"))
local mask = cursor:get("network", "wifi", "netmask")
local cidr
if not ip or not mask then
col1[#col1 + 1] = "<th align=right><nobr>primary address:</nobr></th><td>none<br>"
else
cidr = netmask_to_cidr(mask)
if wifi_disabled then
col1[#col1 + 1] = "<th align=right><nobr>primary address:</nobr></th><td>" .. ip .. " <small>/ " .. cidr .. "</small><br>"
else
wifi_gw = get_default_gw("wifi")
col1[#col1 + 1] = "<th align=right><nobr>mesh RF address:</nobr><br><nobr>mesh gateway:</nobr><br><nobr>gateway node:</nobr><br>SSID:<br>channel:<br><nobr>channel width:</nobr></th><td>" .. ip .. " <small>/ " .. cidr .. "</small><br>" .. wifi_gw .. "<br>" .. mesh_ip_to_hostnames(wifi_gw) .. "<br>" .. wifi_ssid .. "<br>" .. wifi_channel .. "<br>" .. wifi_chanbw .. " MHz</td>"
end
end
ip = cursor:get("network", "lan", "ipaddr")
mask = cursor:get("network", "lan", "netmask")

14
patches/751-x86.patch Executable file
View File

@ -0,0 +1,14 @@
--- a/target/linux/x86/base-files/etc/board.d/02_network
+++ b/target/linux/x86/base-files/etc/board.d/02_network
@@ -45,6 +45,11 @@
macaddr="$(cat /sys/class/net/eth0/address)" 2>/dev/null
[ -n "$macaddr" ] && ucidef_set_interface_macaddr "wan" "$macaddr"
;;
+*)
+ ucidef_set_interfaces_lan_wan "eth0" "eth0.1"
+ ucidef_set_interface "dtdlink" device "eth0.2" protocol "static"
+ ;;
+
esac
board_config_flush

View File

@ -36,5 +36,6 @@
749-fix-tiny.patch
749-ubiquiti-extra-support.patch
750-ibss-2g-fix.patch
751-x86.patch
800-upgrade-compatibility.patch
801-mikrotik-lhg-variants.patch