OpenWrt / ImmortalWrt USB 网卡避坑指南

一、USB 网卡芯片选择(买前必看)

推荐优先级

  1. Realtek RTL8153 / RTL8152B(千兆最稳)
    • 代表产品:TP-Link UE300、UE306
    • 驱动:kmod-usb-net-rtl8152
    • 优点:内核原生支持、兼容性极强、ARM 软路由几乎零故障
    • 缺点:无明显缺点,OpenWrt 首选
  2. ASIX AX88179 / AX88179B(性能强)
    • 驱动方式:cdc_ether + cdc_ncm 或专用驱动
    • 优点:速度快、延迟低
    • 缺点:依赖多、内核版本敏感、部分软路由 USB 供电不稳会掉线
  3. 尽量避免
    • 杂牌 RTL8156B 2.5G 网卡(OpenWrt 驱动问题多)
    • 无品牌、无固件信息的 AX88179 山寨网卡
    • 需要频繁模式切换的无线网卡类设备

二、通用必备驱动包(所有 USB 网卡都要装)

bash

运行

opkg update
opkg install kmod-usb-core kmod-usb-net kmod-usb2 kmod-usb3

三、CDC-NCM 网卡(AX88179 等)专用驱动

bash

运行

opkg install \
  kmod-usb-net-cdc-ether \
  kmod-usb-net-cdc-ncm \
  kmod-mii

注意:只装 cdc_ncm 不装 cdc_ether 一定无法识别。


四、插上不识别?排查步骤

  1. 查看 USB 设备是否被识别bash运行lsusb 无输出 → 供电不足 / USB 口坏 / 延长线问题
  2. 查看系统日志bash运行dmesg | grep usb dmesg | grep eth
  3. 查看是否出现新网卡bash运行ip addr 出现 eth2、eth3 等新设备 → 驱动正常

五、Web 界面网卡显示灰色?

灰色 = 驱动正常,但未分配网络用途

解决方法:

  • 加入 br-lan 作为 LAN 口扩展
  • 或新建接口作为 WAN 口(DHCP/PPPoE)分配后图标立即变蓝。

六、USB 网卡经常掉线?

原因:USB 自动省电挂起

解决:

bash

运行

echo 2 > /sys/module/usbcore/parameters/autosuspend

七、速度跑不满、CPU 占用高?

  1. 必须插 USB 3.0 蓝色接口
  2. 避免使用劣质延长线、多口 Hub
  3. ARM 软路由性能有限,不要同时跑:
    • Docker
    • SQM / QoS
    • 多拨 / 流量叠加
    • USB 硬盘读写 + USB 网卡

八、防火墙与网络安全规则

  1. USB 网卡必须归属 lan 或 wan 区域,不可裸奔
  2. 做多 WAN 叠加要避免二层环路
  3. 不建议频繁热插拔 USB 网卡

九、OpenWrt 内核模块铁律

  1. 内核模块版本必须与固件内核完全一致
  2. 小版本不匹配 → 装不上 / 格式错误 / 无法加载
  3. 最稳方案:自己编译固件时直接内置驱动

十、最优使用总结

  1. 优先买 RTL8153 芯片网卡
  2. 自己编译固件,驱动直接内置
  3. USB 插 3.0 口,不用 Hub
  4. 识别后加入网桥或设置 WAN
  5. 关闭 USB 自动挂起,稳定不掉线
发表在 计算机技术 | 留下评论

ImmortalWrt 24.10 安装 UU 路由器插件 完整教程(官方适配版)

说明:本教程严格对齐网易UU官方教程思路,专门适配 ImmortalWrt 24.10(nftables / Firewall4)系统,解决官方教程在该系统下缺依赖、不兼容的问题,直接照做即可成功,无需额外修改。

一、适用环境

  • 系统版本:ImmortalWrt 24.10(支持 x86_64 / ARM / RK3568 等主流架构)
  • 防火墙:系统默认 nftables (Firewall4)(核心适配点)
  • 用途:用于 PS5、Xbox、Switch、Steam Deck 等主机游戏加速
  • 注意:官方教程仅适配 iptables 老固件,ImmortalWrt 24.10 必须补充兼容层,否则安装后无法正常使用。

二、准备工作

2.1 设备与系统要求

  • 已刷入 ImmortalWrt 24.10 系统的路由器,确保路由器可正常访问互联网。
  • 操作电脑与路由器处于同一局域网(便于SSH连接和网页后台操作)。

2.2 必备工具

  • SSH工具:Putty、Termius、Xshell 任意一款(用于登录路由器命令行)。
  • 手机App:安装「UU主机加速」(非电脑版UU加速器,用于绑定路由器和控制加速)。

三、详细安装步骤

步骤1:登录路由器SSH(基础操作)

  1. 打开已安装的SSH工具(如Putty),输入路由器IP地址(默认通常为 192.168.1.1)。
  2. 登录账号:root(默认用户名,无需修改)。
  3. 登录密码:路由器Web管理后台的密码(自行设置,若未修改则为默认密码)。
  4. 输入完成后,点击连接,成功登录后将显示命令行界面。

步骤2:安装必备依赖(24.10系统必做,解决兼容问题)

在SSH命令行中,依次执行以下两条命令(复制粘贴即可,避免手动输入出错):

第一条命令:更新软件源

bash
opkg update

第二条命令:安装兼容层及依赖包(核心适配nftables防火墙)

bash
opkg install \
kmod-tun \
iptables-nft \
iptables-legacy \
ip6tables-nft \
ip6tables-legacy \
kmod-ipt-nat \
kmod-ipt-extra \
ca-bundle \
libustream-openssl

作用:让UU插件能在nftables防火墙下正常调用iptables规则,同时创建加速所需的tun网卡,避免出现“iptables找不到”“插件启动失败”等问题。

步骤3:执行官方安装脚本(与官方教程一致)

依赖安装完成后,继续在SSH命令行中,依次执行以下4条命令(严格按照顺序,复制粘贴即可):

  1. 进入临时目录(用于存放安装脚本):
            cd /tmp
  2. 下载官方最新安装脚本:wget -O install.sh “https://router.uu.163.com/api/script/install?type=openwrt”
  3. 赋予脚本执行权限:
            chmod +x install.sh
  4. 执行安装脚本(自动识别路由器架构,无需手动修改):
            /bin/sh install.sh openwrt $(uname -m)

安装成功提示:当命令行中出现 UU plugin install success! 字样,说明插件安装成功。

步骤4:设置开机自启并启动UU服务

插件安装完成后,需手动设置开机自启(避免路由器重启后插件失效),继续在SSH命令行中执行以下3条命令:

  1. 设置开机自启:
            /etc/init.d/uuplugin enable
  2. 启动UU插件服务:
           /etc/init.d/uuplugin start
  3. 查看插件运行状态(验证是否正常启动):
            /etc/init.d/uuplugin status

正常状态:命令行输出中会显示 running 字样,说明插件已成功启动;若显示 stopped,则重新执行“启动服务”命令。

步骤5:网页后台防火墙设置(官方要求+24.10优化)

插件启动后,需配置防火墙规则(避免加速流量被拦截),操作如下:

  1. 打开电脑浏览器,输入路由器IP地址(默认 192.168.1.1),登录Web管理后台(账号root,密码与SSH登录一致)。
  2. 点击左侧导航栏:网络 → 防火墙
  3. 找到“区域”设置,将「lan」区域的「转发」选项改为 接受
  4. 找到“SYN-flood 防御”选项,取消勾选(避免干扰UU加速连接,导致加速不稳定)。
  5. 点击页面底部的 保存并应用,等待设置生效(约1-2秒)。

步骤6:手机App绑定路由器(官方标准流程)

防火墙设置完成后,通过手机App绑定路由器,即可控制加速,操作如下:

  1. 将手机连接到当前安装了UU插件的路由器WiFi(确保手机与路由器在同一局域网)。
  2. 打开手机上的「UU主机加速」App(若未登录,先登录网易账号)。
  3. 点击App右下角「我的」,找到「路由器插件」选项,点击进入。
  4. App会自动扫描当前局域网内的路由器,找到对应路由器后,点击「绑定」。
  5. 绑定成功后,返回App首页,添加需要加速的主机(PS5/Xbox/Switch等),选择对应游戏,点击「启动加速」即可。

四、旁路由/单臂路由额外设置(仅旁路由用户必做)

若你的ImmortalWrt路由器是作为旁路由使用(非主路由),需额外执行以下命令(否则加速后主机可能断网):

bash
ROUTER_IP=”192.168.X.X”  # 请将此处改为你的旁路由IP地址(如192.168.1.2)

iptables -t nat -A POSTROUTING -d 127.0.0.0/8 -o br-lan -j ACCEPT
iptables -t nat -A POSTROUTING -d 10.0.0.0/8 -o br-lan -j ACCEPT
iptables -t nat -A POSTROUTING -d 172.16.0.0/12 -o br-lan -j ACCEPT
iptables -t nat -A POSTROUTING -d 192.168.0.0/16 -o br-lan -j ACCEPT
iptables -t nat -A POSTROUTING -o br-lan -j SNAT –to $ROUTER_IP

补充说明:旁路由用户还需确保:主路由关闭UPnP、IGMP Snooping功能;所有需要加速的主机,网关必须设置为旁路由的IP地址。

五、常用维护命令(备用,解决常见问题)

5.1 重启UU插件(加速异常时使用)

bash
/etc/init.d/uuplugin restart

5.2 查看UU插件日志(排查启动/加速失败问题)

bash
logread -e uuplugin

5.3 完全卸载UU插件(重装时使用)

bash
/etc/init.d/uuplugin stop
/etc/init.d/uuplugin disable
opkg remove uuplugin
rm -rf /usr/share/uuplugin /etc/uuplugin.conf

六、常见问题说明

  • 问题1:安装时提示“iptables: not found”? → 未执行步骤2安装依赖,重新执行步骤2的两条命令即可。
  • 问题2:App搜不到路由器? → 手机未连接路由器WiFi,或主机/手机网关未指向路由器IP,重启路由器和手机后重试。
  • 问题3:插件启动成功,但加速失败? → 防火墙设置未生效,重新执行步骤5;旁路由用户需确认已执行步骤4的额外命令。
  • 问题4:路由器重启后,UU插件失效? → 未设置开机自启,重新执行步骤4的“设置开机自启”命令。

七、补充说明

本教程在官方教程基础上,仅补充了ImmortalWrt 24.10系统所需的兼容层和必要设置,未修改官方安装流程,确保插件稳定性和兼容性。若执行过程中遇到其他问题,可查看步骤5.2的日志,根据日志提示排查问题。

发表在 计算机技术 | 一条评论

Setup the OpenWRT build environment, and compile a test image on macOS

# Install Xcode from the AppStore
# Install Xcode build tools
xcode-select --install

# Install the Hombrew package manager
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

# Install required packages
brew install apr apr-util arping asciidoc autoconf automake bash bdw-gc berkeley-db binutils \
	binwalk boost brotli bzip2 c-ares cmake coreutils curl dash diffutils docbook e2fsprogs \
	fastjar findutils flex freetype gawk gcc gdbm gettext git git-extras gmp gnu-getopt \
	gnu-sed gnu-tar gnutls gpatch gputils grep guile icu4c intltool isl jemalloc libev libevent \
	libffi libgcrypt libgpg-error libidn2 libmetalink libmpc libnet libpng libssh2 libtasn1 \
	libtool libunistring libxml2 libxslt libyaml lz4 m4 make mercurial mpdecimal mpfr mtr \
	ncurses nettle nghttp2 numpy openblas openldap [email protected] openssl@3 p11-kit p7zip patchutils \
	pcre pcre2 perl pkg-config python quilt readline rtmpdump ruby source-highlight sqlite \
	ssdeep subversion tcl-tk unbound unzip utf8proc wget xz zlib zstd

# Link gnu-make to be used as default
cd /usr/local/bin
ln -s /usr/local/opt/make/libexec/gnubin/make make

# Link coreutils stat to be used as default
ln -s gstat stat

# Edit /etc/shells
sudo nano /etc/shells

# Add the following line at the end
/usr/local/bin/bash

# Change the default shell to bash, and exit
chsh -s /usr/local/bin/bash
exit

# open Disk Utility
# press Command-N to create a new virtual disk
# Image Format: sparse disk image
# save as: ~/vhd/test
# Name: test
# Size: 50 GB
# Format: APFS (Case-sensitive)
# Encryption: none
# Partitions: Single partition - GUID Partition Map
# Save
# open a new terminal

# Clone OpenWRT: official or httpstorm fork
# git clone https://github.com/openwrt/openwrt.git
git clone https://github.com/httpstorm/openwrt.git
cd openwrt

# When using the httpstorm fork, checkout branch gvalkov
git checkout gvalkov

# Update and install feeds
./scripts/feeds update -a
./scripts/feeds install -a

# Make default config and them menuconfig
make defconfig
make menuconfig

# Configure the target system, e.g.
# Target System (Marvell EBU Armada)
# Subtarget (Marvell Armada 37x/38x/XP)
# Target Profile (Linksys WRT3200ACM)
# Save
# Exit

# Compile the target image
make -j 16
发表在 计算机技术 | 一条评论

OpenWrt 构建工具链文档翻译(macOS 系统要求)‌

注意:‌ 此方法‌非官方支持‌,推荐使用原生 GNU/Linux 环境进行构建。

测试环境:‌

macOS 10.15.7 (Darwin v19.6.0), Xcode 12.1 build 12A7403, 以及 homebrew 提供的软件包
macOS 11.6 (Darwin v20.6.0) Xcode 13.0 build 13A233, arm64 内核, 以及 homebrew 提供的软件包

系统信息查看命令:‌

查看 macOS 版本号等:sw_vers
查看 Darwin 版本号等:sysctl kern.osrelease

macOS 与 Darwin Unix:‌
您可以选择跳过本节,直接前往下一节 ‌A. 获取构建工具链‌。

macOS 和 Darwin Unix 简要信息:‌

macOS‌ 包含 APSL(Apple 公共源许可证)和 BSD(伯克利软件发行版)以及其他许可的开源组件[1,2,3]
Darwin‌ 基于 XNU 混合内核,并包含 Darwin Unix 作为内部子系统以支持基于命令行的工具(来自各种 Unix 和 Linux 发行版)。Darwin 支持 POSIX API,因为它基于 BSD Unix 并且大量使用 FreeBSD 用户态工具等。大多数驱动程序和 GUI 层的大部分组件都是专有(非开源)许可。构建工具需要与 “darwin” 兼容。

内核扩展变化:‌

在 macOS v10.15.x (Catalina) 及更早版本中,内核模块、硬件驱动程序等通常以内核扩展(kext)的形式在内核空间/层加载,并使用 LKM 和 KPI(内核编程接口)以及 d-KPI(已弃用的 KPI)。
但从 macOS v11 (Big Sur) 及更新版本开始,较新的系统扩展(sext/sysext)和(较旧的)不带 d-KPI 的 kext 在用户空间/层中使用。此外,macOS v11 及更高版本中较新的驱动程序扩展(dext)也在用户空间/布局中运行,并取代了早期的 I/O 套件。因此,硬件/软件开发商/制造商仍应提供 sext/dext 和不带 d-KPI 的 kext。
早期的 macOS/Darwin 使用 HFS 分区,现在使用 APFS。

衍生项目:‌

一个衍生项目 OpenDarwin 于 2004 年 7 月 16 日发布了最后一个稳定版本 v7.2.1,随后于 2006 年 7 月 25 日关闭。一些自由软件社区、ISC 等与 Apple 合作开发了 OpenDarwin,其中一些想法被用于构建 GNU-Darwin[1,2]。另一个衍生项目 PureDarwin 于 2015 年发布了基于 Darwin 9 并带有 X11 GUI 的预览版,随后于 2019 年发布了仅支持命令行的、基于 Darwin 17 的 17.4 Beta 版。

驱动程序链接:‌

无线:,
网卡:, ,
Zyxel 调制解调器:
读卡器:
在 macOS 下支持 Ext2 和 Ext3(Linux 文件系统):,

A. 获取构建工具链:‌
获取更适合 Apple 硬件、macOS 和 Darwin Unix 的构建工具链。

● 安装 Xcode 或 CLT:‌

从此处获取 Xcode。注意:安装程序文件下载量超过/接近 5 GB,并且需要 17+ GB 的空间。Xcode 11.5:16,958,217,326 字节(磁盘上 10.5 GB)。
查看已安装的 Xcode 版本号,运行命令:xcodebuild -version。如果输出不显示版本号,则 Xcode 未安装。

CLT 替代方案:‌
如果您不想获取 Xcode,其中一个替代方案是:

从此处获取命令行工具(CLT),或从 macOS 的 App Store 加载它,或使用以下命令,或通过包管理器软件获取 apple-gcc 包。CLT 也称为命令行开发人员工具。注意:安装程序下载量低于/接近 300 MB,可能需要大约 2 GB 的空间。
在终端实用程序/应用程序中,运行此命令以加载 CLT:xcode-select –install
查看已安装的 CLT 版本号,运行命令:pkgutil –pkg-info=com.apple.pkg.CLTools_Executables。如果输出不显示版本号或显示消息”…No receipt…”,则 CLT 未安装,或其与 Xcode 捆绑在一起。要查看预安装的软件包,您可以运行:pkgutil –pkgs

● 查看工具链版本号、目录等信息,运行命令:‌
gcc -v && llvm-gcc -v && clang -v

● 您也可以运行 xcrun clang 命令,并查看其输出:‌
UserMacBook:~ username$ xcrun clang clang: error: no input files
如果输出‌不是‌此消息 clang: error: no input files,则要么安装有错误,要么可执行文件未正确设置在 PATH 环境变量中。

● 构建工具链用途:‌
来自 Apple 的构建工具链(Xcode 或 CLT)在(第一阶段)用于创建适用于 OpenWrt 构建目的的软件组件,然后(在第二阶段)这些软件组件用于创建最终的 OpenWrt 组件,以便创建与跨平台广泛兼容的 OpenWrt 固件等。

B. 查看隐藏文件/文件夹:‌
● 我们需要非常准确地查看完整文件名、文件扩展名、所有文件和目录(包括隐藏的),以减少错误。‌

● 使用 Finder 启动终端:‌

Finder 与 Windows 资源管理器文件浏览器应用程序/工具非常相似。在 macOS 中 > 单击桌面屏幕上的任何空白区域 > 然后在顶部的  菜单中,单击 Window > 单击 Bring All to Front > 在 Finder 的左侧窗格(左侧列)中,转到 Favorites 下并单击 Applications > 然后向下滚动并进入 Utilities 子文件夹 > 然后单击 Terminal 或 Terminal.app 启动它。macOS 终端与 Windows 命令提示符非常相似,是一个命令行界面(CLI)工具。
立即启动 Finder 的热键:[Alt/Option⌥] + [Command⌘] + [Space-bar],然后关闭搜索选项卡。
立即启动终端的热键:无。(注意:如果您勾选了选项:重启后加载之前运行的应用程序,则重启后终端将保持运行状态并自动启动)。

● 在终端内运行以下命令:‌
defaults write com.apple.Finder AppleShowAllFiles true
以上命令仅使文件在文件浏览器软件中可见,实际上并不更改任何文件属性。

● 然后您必须重启 Mac 计算机‌ 或运行(以下任意一个)命令:
/usr/bin/sudo /usr/bin/killall Finder /System/Library/CoreServices/Finder.app
或者,只运行这个:/usr/bin/sudo /usr/bin/killall Finder
或者,只运行这个:sudo killall Finder
然后 Finder 将自动启动,并且所有隐藏的文件和文件夹将默认开始在 macOS Finder 中显示给用户。

● 在 macOS Finder 或 macOS 中的任何其他文件浏览窗口中,用户也可以同时按下以下三个按钮一次以显示所有隐藏的文件/文件夹:‌
[Command⌘] + [Shift⇧] + [.>]
如果用户再次按下上述三个按钮,文件浏览窗口将隐藏隐藏的文件/文件夹。

● 默认情况下,在 macOS 中,Finder 会隐藏大部分文件扩展名。但我们需要查看所有文件的扩展名以查看完整文件名,以便我们能够确定且不犯错误。要查看所有文件的扩展名,请执行以下步骤:‌
在 macOS 中 > 启动 “Finder” 应用程序 > 转到主菜单 > Finder > Preferences > Advanced > 选择 Show All Filename Extensions 选项。

C. 安装包管理器:‌
在 macOS 中安装任意一个(第三方)包管理器软件:
(1) Homebrew, 或 (2) MacPorts, 或 (3) pkgsrc。

注意/警告:‌ 通常大多数时候,使用来自主要/原始作者/开发者的(源码或二进制)软件包比下一级(即:下游)软件包分发者(例如:操作系统/发行版开发者、计算机制造商等)分发的软件包要好得多。并且通常大多数时候,操作系统/发行版开发者或计算机制造商分发的软件包比第三方包管理器维护者分发的软件包要好。但通常操作系统/发行版开发者或计算机制造商不会更新其预包含的软件包,或使用较旧版本,或不包含用户获取其他/相关软件包(来自操作系统/发行版开发者或计算机制造商)的选项。因此,在这种情况下,次优选择是:通过安全连接从原始作者的网站为您的操作系统/发行版获取(源码/二进制)软件包。(软件包的源码需要编译以构建软件包的二进制/可执行文件)。如果原始作者仅分享源码,则意味着作者希望您编译源码。因此,您的下一个最佳选择是:在您对源码进行补丁以使其与您的操作系统/发行版兼容并可编译后,编译从原始作者/开发者处获取的源码。编译过程构建软件包的二进制文件等。如果之前的步骤对您来说不可能(因为”打补丁”需要软件开发、操作系统/发行版平台和硬件平台相关知识等),那么在这种情况下,使用第三方包管理器可能是必要的。一些(第三方)包管理器默认下载软件包的源码(和依赖项/先决条件)并在您的操作系统/发行版中自动编译以创建/构建二进制文件。通常,软件包的维护者会对原始源码进行补丁,以使其适合在目标操作系统/发行版中编译/运行。一些(第三方)包管理器下载的是已经为您的操作系统/发行版打好补丁并预构建的二进制文件。当二进制文件在您自己的操作系统/发行版中正确编译和构建时,这比快速直接下载(预构建的)二进制文件更值得信赖且更好。”信任”比”快”/”慢”更重要、更安全、更可靠。macOS 有一个名为 App Store 的原生包管理器,它有各种或太多由 macOS 开发者 Apple 设置的不公平限制和壁垒,不允许各种类型的开源应用程序等,这就是为什么有时我们需要使用第三方包管理器。您绝不能从任何非原始作者网站或帖子下载、编译和使用源码或二进制文件。要么通过安全/加密连接从原始作者的网站下载源码/二进制文件,‌或者‌,您必须使用基于 OpenPGP/GPG/PGP 的身份验证来确保下载的源码/二进制文件确实是由实际原始作者发布的。包管理器工具内部包含选项,以便为任何下载使用(某种形式的)身份验证和验证。

  1. Homebrew:‌
    它是适用于 macOS 等的开源且免费的(第三方)包管理器。Homebrew 是在 MacPorts 包管理器(以前称为 DarwinPorts)之后 7 年构建的。

● 注意 / 警告 / 警告:‌ homebrew 是开源包管理器,但此工具使用 Google Analytics 收集使用遥测数据。如果您使用 homebrew:请使用选择退出选项/命令,
brew analytics off
或通过设置
export HOMEBREW_NO_ANALYTICS=1

  1. MacPorts:‌
    它是适用于 macOS 等的开源且免费的(第三方)包管理器,并且它不会窃取您的使用/私人数据。MacPorts 指南。它可以获取源码或二进制文件或两者(对于大多数软件包)。下载源码后,它可以在您的操作系统/发行版中自动编译以创建/构建值得信赖的二进制文件。MacPorts 是在 homebrew 之前 7 年创建的。wp.

● 下载/获取 MacPorts 安装程序 dmg/pkg 文件,安装它。更多信息在此。‌

● 在安装 MacPorts 之前,您的 ~/.bash_profile 文件(在您的主目录内)可能看起来接近这样:‌

text
Copy Code

.bash_profile for BASH

PROMPT_COMMAND=update_terminal_cwd

PS1=’\h:\W \u\$ ‘
PS2=’> ‘
PS4=’+ ‘
PATH=”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin”
export PATH

● MacPorts 安装程序网页将指示您将 macports 包管理器可执行文件的位置添加到 PATH 变量的末尾,如下所示:‌
PATH=”$PATH:/opt/macports/bin:/opt/macports/sbin”

在您手动将上述行添加到 ~/.bash_profile 文件后,它将如下所示:

text
Copy Code

.bash_profile for BASH

PROMPT_COMMAND=update_terminal_cwd

PS1=’\h:\W \u\$ ‘
PS2=’> ‘
PS4=’+ ‘
PATH=”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin”
PATH=”$PATH:/opt/macports/bin:/opt/macports/sbin”
export PATH

您可以使用此命令编辑 ~/.bash_profile 文件:sudo nano ~/.bash_profile

● 当 MacPorts 安装后,安装程序会将存储 macports port 软件包可执行文件的位置添加到 ~/.bash_profile 文件内的 PATH 中。通过这种方式,在您登录后,您的 macOS 用户帐户可以找到并使用已安装的 macports port 软件包文件。但我们必须稍微更改它。‌

以下是您通常在 ~/.bash_profile 文件中看到的内容(在安装 macports 后):

text
Copy Code

.bash_profile for BASH

PROMPT_COMMAND=update_terminal_cwd

PS1=’\h:\W \u\$ ‘
PS2=’> ‘
PS4=’+ ‘
PATH=”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin”
PATH=”$PATH:/opt/macports/bin:/opt/macports/sbin”

Your previous /Users//.bash_profile file was backed up as /Users//.bash_profile.macports-saved_2021-08-29_at_16:38:31

MacPorts Installer addition on 2021-08-29_at_16:38:31: adding an appropriate PATH variable for use with MacPorts.

export PATH=”/opt/local/bin:/opt/local/sbin:$PATH”

Finished adapting your PATH environment variable for use with MacPorts.

● 将上述代码更改为以下代码:‌

text
Copy Code

.bash_profile for BASH

PROMPT_COMMAND=update_terminal_cwd

PS1=’\h:\W \u\$ ‘
PS2=’> ‘
PS4=’+ ‘
PATH=”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin”
PATH=”$PATH:/opt/macports/bin:/opt/macports/sbin”

Your previous /Users//.bash_profile file was backed up as /Users//.bash_profile.macports-saved_2021-08-29_at_16:38:31

MacPorts Installer addition on 2021-08-29_at_16:38:31: adding an appropriate PATH variable for use with MacPorts.

export PATH=”/opt/local/bin:/opt/local/sbin:$PATH”

export PATH

Finished adapting your PATH environment variable for use with MacPorts.

在上面,我们已从 PATH 中禁用了基于 MacPorts 的 port 软件包位置,但 MacPorts 包管理器本身的位置保留在 PATH 中。”PATH” 是一个基本的环境变量,它指示查找特定(可执行)程序的目录/文件夹的顺序。我们所做的更改将允许新安装的(MacPorts)软件包与其他不需要使用它们的软件保持隔离。这些(MacPorts)软件包是 OpenWRT 开发/构建所必需的,因此我们将创建一个单独的可执行文件(env.sh)来加载 PATH(和其他构建环境变量),该文件仅适用于在 shell 管理器的特定 shell 选项卡中使用,用于 openwrt 构建/开发目的。有关创建此 env.sh 文件的详细信息,请参见下面的步骤/部分 F。

MacPorts 用户提示:‌

搜索软件包:port search –name –glob ‘pkgName
查看软件包信息:port info pkgName
查看软件包需要哪些依赖项:port deps pkgName
安装软件包:sudo port install pkgName

  1. pkgsrc:‌
    它是适用于 NetBSD Unix 操作系统的开源且免费的(第三方)包管理器,但也可以被其他操作系统使用,包括 macOS/Darwin。它可以获取二进制软件包。下载:dev, 源码:gh, 更多信息:wp.

警告:‌ macOS 在 /etc/paths 文件中保留默认的 PATH,但请勿编辑/更改它,因为此类更改会影响整个或大部分 macOS 系统。我们只需要为 1 或 2 个 shell 实例更改构建环境,而不是为整个 macOS 系统,也不是为 macOS 中的所有其他应用程序。

D. 创建专用的区分大小写的文件系统:‌
为 OpenWRT 构建/编译目的创建一个专用的区分大小写的文件系统:

● 我们将使用一个 sparsebundle 来允许我们拥有一个区分大小写的文件系统。‌

● 您提供的大小将是用于处理 OpenWrt 的卷的最大大小。在终端 shell 实例中执行以下命令:‌

text
Copy Code
cd ~
hdiutil create -size 20g -type SPARSE -fs “Case-sensitive HFS+” -volname OpenWrt OpenWrt.sparseimage
hdiutil attach OpenWrt.sparseimage

上面的命令 cd ~ 将开发者用户带入 macOS 中用户帐户的 HOME 目录,然后在那里创建 OpenWrt.sparseimage 文件。但是,如果您想在不同的目录中创建 SPARSE 映像文件,请更改 cd ~ 行并进入您首选的卷/目录。

● 可选/信息性:‌

如果您想在创建后打开 OpenWRT 卷(也称为:驱动器,磁盘),则在上面使用以下命令作为第三个命令行:
hdiutil attach OpenWrt.sparseimage -autoopenrw
重启后,如果您的 macOS 中没有可用的 OpenWRT 卷,则运行:cd ~ && hdiutil attach OpenWrt.sparseimage -autoopenrw
如果您想始终保持 OpenWRT 卷处于连接状态,则:cd ~ && sudo hdiutil attach OpenWrt.sparseimage -notremovable -autoopenrw
如果您想分离(即:卸载)OpenWRT 卷,则:hdiutil detach /Volumes/OpenWrt
关于 hdiutil 的更多信息在此。

E. 转到 OpenWRT 构建卷:‌
在终端中使用以下命令进入 OpenWRT 构建卷:
cd /Volumes/OpenWrt

F. 创建位置指示器和构建环境文件:‌
● 在 /Volumes/OpenWrt 内创建一个名为 env.sh 的文件,以指示已安装软件包的位置。它还将帮助我们在 shell 管理器软件(如 Terminal)的特定 shell 选项卡/实例中创建 openwrt 构建友好的环境。‌

这是为了允许使用来自包管理器(我们将在下一步安装)的软件包,而不是 macOS 提供的软件包。

根据您的包管理器,请遵循以下适当部分之一:

● 对于 x86_64 Apple 硬件,并且当您有 MacPorts 包管理器时,请使用以下内容创建 env.sh 文件,并将其保存在 /Volumes/OpenWrt 位置:‌

env.sh‌

text
Copy Code

!/opt/local/bin/bash

PS1=’\h:\W \u\$ ‘;
PS2=’> ‘;
PS4=’+ ‘;

Bring PATH lines from the ~/.bash_profile file into below:

PATH=”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin”
PATH=”$PATH:/opt/macports/bin:/opt/macports/sbin”

Adding path of macports port packages, in ahead of others:

PATH=”/opt/local/libexec/gnubin:/opt/local/bin:/opt/local/sbin:/opt/local/libexec:/opt/local/x86_64-apple-darwin19.6.0/bin:$PATH”;

Load PATH into currently running shell:

export PATH;

Load other environment variables:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk7-zulu/Contents/Home

使用此命令将 env.sh 文件变为可执行的 shell 脚本文件:chmod +x /Volumes/OpenWrt/env.sh

对于 MacPorts,‌ 使用此命令在您的主目录 ~/ 中创建 MacPorts.sh 文件:sudo nano ~/MacPorts.sh

在您的 ~/.bash_profile 文件中找到 PATH 变量行,并添加到以下内容中,然后从以下复制所有内容并粘贴到 ~/MacPorts.sh 文件中。您也可以将以下代码下载为文件,然后更改上面的 2 个 PATH 变量,以匹配您 ~/.bash_profile 文件内的 PATH:

MacPorts.sh‌

text
Copy Code

!/opt/local/bin/bash

PS1=’\h:\W \u\$ ‘;
PS2=’> ‘;
PS4=’+ ‘;

Bring PATH lines from the ~/.bash_profile file into below:

PATH=”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin”
PATH=”$PATH:/opt/macports/bin:/opt/macports/sbin”

Bring last PATH line from the /Volumes/OpenWrt/env.sh file into below:

PATH=”/opt/local/libexec/gnubin:/opt/local/bin:/opt/local/sbin:/opt/local/libexec:/opt/local/x86_64-apple-darwin19.6.0/bin:$PATH”;

Load PATH into currently running shell program:

export PATH;

Load other environment variables:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk7-zulu/Contents/Home

使用此命令将 MacPorts.sh 文件变为可执行的 shell 脚本文件:chmod +x ~/MacPorts.sh

● 对于 x86_64 Apple 硬件,并且当您有 homebrew 时,请使用以下内容创建 env.sh 文件:‌

text
Copy Code
PATH=”/usr/local/opt/make/libexec/gnubin:$PATH”
PATH=”/usr/local/opt/gnu-getopt/bin:$PATH”
PATH=”/usr/local/opt/gettext/bin:$PATH”
PATH=”/usr/local/opt/coreutils/libexec/gnubin:$PATH”
PATH=”/usr/local/opt/findutils/libexec/gnubin:$PATH”
export PATH

● 对于 arm64(Apple Silicon (M1))Apple 硬件,并且当您有 homebrew 时,请使用以下内容创建 env.sh 文件:‌

text
Copy Code
PATH=”/opt/homebrew/opt/make/libexec/gnubin:$PATH”
PATH=”/opt/homebrew/opt/gnu-getopt/bin:$PATH”
PATH=”/opt/homebrew/opt/gettext/bin:$PATH”
PATH=”/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH”
PATH=”/opt/homebrew/opt/findutils/libexec/gnubin:$PATH”
export PATH

● 可选:‌
您可以在需要更多关于 PATH 变量或其他包管理器相关信息时查看 homebrew 官方页面或 MacPorts 指南。

将 env.sh 文件变为可执行的 shell 脚本文件:chmod +x /Volumes/OpenWrt/env.sh

G. 安装必要的软件包:‌
通过包管理器安装必要的软件包,这些软件包有助于构建 openwrt 组件。在终端的 shell 实例/选项卡中使用以下命令。注意:软件包将安装在 macOS 默认卷内,而不是 /Volumes/OpenWrt 内。

根据您的包管理器,请遵循以下适当部分之一:

● 如果您有 homebrew 包管理器,则运行此命令:‌
brew install coreutils findutils gawk grep gnu-getopt gnu-tar wget diffutils git-extras quilt svn make ncurses pkg-config
在上面,homebrew 命令‌不包含‌此处提到的先决条件软件包。

● 如果您有 MacPorts 包管理器,则运行以下 2 个命令:‌

text
Copy Code
source ~/MacPorts.sh
sudo port install libiconv gettext-runtime coreutils findutils gwhich gawk zlib pcre bzip2 ncurses grep getopt gettext-tools-libs gettext diffutils sharutils util-linux libxslt libxml2 help2man readline gtime gnutar unzip zip lzma xz libelf fastjar libusb libftdi0 expat sqlite3 openssl3 openssl kerberos5 dbus lz4 libunistring nettle icu gnutls p11-kit wget quilt subversion gmake pkgconfig libzip cdrtools ccache curl xxhash lib rsync libidn perl5 p5.28-xml-parser p5.30-xml-parser p5-extutils-makemaker p5-data-dumper boost-jam boost boost-build bash bash-completion binutils m4 flex intltool patchutils swig git-extras git openjdk17 openjdk7-zulu luajit libtool glib2 file python27 python310 libzzip mercurial asciidoc sdcc gnu-classpath

在上面,MacPorts 命令‌包含‌此处提到的先决条件软件包。所有这些软件包最初使用的空间:4,190,442,792 字节(磁盘上 2.57 GB)对应 129,623 个项目,(截至 2022 年 3 月 11 日)。注意:由于不同的软件包由其开发者、发布者、采用者或维护者不断修改和改进,因此它们占用的空间大小和项目计数在您计算机的不同时间会有所不同。

● 通过 MacPorts 安装的可选工具:‌

如果您需要 picocom 工具通过串行适配器/电缆与路由器通信,则:sudo port install picocom
如果您需要最后一个稳定的 openssh(即:ssh)、sftp、scp 工具用于安全通信或文件传输,则:sudo port install openssh
如果您需要使用最后一个稳定的 telnet、ftp、rsh、rlogin、tftp 工具以及相应的守护进程/服务器,则:sudo port install inetutils
如果您需要其他类型的捆绑软件包,请查看此处:。
如果您需要其他 TFTP 守护进程/服务器(tftpd),那么您可以尝试以下。TFTP 服务器允许从路由器接收文件,或允许(变砖的)路由器从 TFTP 服务器启动等:sudo port install tftp-hpa
如果您需要这些类型的工具,(更多信息:),则:sudo port install arm-elf-binutils i386-elf-binutils m68k-elf-binutils mips-elf-binutils x86_64-elf-binutils

H. 可选步骤:启动构建友好的 shell:‌
macOS 默认使用一个非常旧版本的 bash shell。因此,我们能够/应该启动一个构建/编译友好的、常见的最新+稳定或近期版本的 bash shell,在 macOS 终端的特定选项卡内,因为这样的近期版本可以被大多数开发者用户获取和使用。shell 管理器软件 Terminal 可以通过使用多个 Terminal 选项卡来运行多个 shell 实例。选择一个(或多个)Terminal 选项卡用于 openwrt 构建目的,然后运行以下命令以拥有相同(最新+稳定)的构建环境。

● 如果您安装了新的 bash 软件包,则在 Terminal 的特定选项卡内启动新的 bash shell,(当您有基于 MacPorts 的 bash 软件包时),使用此命令:‌
exec /opt/local/bin/bash

● 可选:‌

使用此命令在 macOS 中批准/允许新的 bash shell:echo “/opt/local/bin/bash” | sudo tee -a /private/etc/shells
如果您想始终继续使用新的 bash,则:单击顶部苹果  菜单栏中的苹果符号 > System Preferences… > Users & Groups > 解锁窗格 > 按住 Control 键单击您的用户名 > 选择 Advanced Options… > 然后将 Login shell 更新/更改为 /opt/local/bin/bash > 确定。

I. 加载构建环境:‌
我们需要将构建软件包位置指示器文件作为 shell 环境加载。OpenWRT 开发(即:构建、编译)是在一个合适的(即:构建友好的)shell 环境中完成的。因此,我们必须通过将构建软件包位置指示器文件 env.sh 加载到其中一个 Terminal shell 环境选项卡中,以创建那个 openwrt 构建友好且合适的 shell 环境,从而允许 openwrt 构建命令找到我们通过包管理器安装的软件包。

在开发(即:构建、编译)时,运行以下命令来设置构建友好的 PATH(和其他)变量。这使您的系统保持干净状态,无需创建符号链接。
source /Volumes/OpenWrt/env.sh

可选:‌ 因此,下次或重启后,当您想要进入 openwrt 构建模式时,则在您拥有基于 MacPorts 的 bash 软件包时,在 Terminal 的特定选项卡内运行以下 2 个命令:

text
Copy Code
exec /opt/local/bin/bash
source /Volumes/OpenWrt/env.sh

J. 构建:‌
现在正常进行,(即,开始遵循父级/上一页中显示的构建相关的其他步骤/过程)。

其他工具:‌
一些用户可能需要以下部分工具。

为 Broadcom (BCM) 43xx 芯片组开发 openwrt 固件的用户,需要这个 b43-fwcutter 工具从固件中提取无线驱动程序。‌
更多信息在此。

包管理器 homebrew 有此工具,而 MacPorts 没有。

MacPorts 用户‌ 可以获取源码[1,2,3,4] 并编译,或从 FreeBSD pkg 获取。

Golang:‌ 对于 darwin/arm64 和 linux/aarch64 golang 软件包(feed “packages”)golang C-bootstrap 方法不起作用,但可以使用外部 golang 引导程序。在 MacOS arm64 上,最简单的方法是使用 brew 安装 golang,并使用已安装的 golang 作为引导程序:
brew install golang
然后在 .config 文件中设置 CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT=”/opt/homebrew/opt/go/libexec”

可选工具:‌
可选工具、驱动程序、软件等,适用于 macOS,以协助构建/编译过程,并提高安全性。

除非您特别需要此类工具/应用程序/实用程序来协助您的构建相关工作,否则无需安装这些。以下是一些与 openwrt 软件代码构建、测试、使用和诊断相关的可选/额外工具的小列表,以及一些与网络设备测试/诊断相关的可选/额外工具列表,以便在 macOS(Apple Macintosh 操作系统)和 Apple 硬件上运行/使用。更多信息,请前往 wp。

● XQuartz(dev, wp, src, dnld):‌ 它允许跨平台(GNU-Linux 等)应用程序/工具(这些工具是为使用 X11 GUI 而开发的),以便在 macOS 上运行并使用 macOS 的原生 Quartz GUI 等。许多 GUI 应用程序/工具需要这个。它是开源工具。

● PeaZip(dev, dnld, src, wp, comparison):‌ 它是一个免费且开源的归档器(zip, compress)和解归档器(unzip, decompress)应用程序/工具。基于 GUI。允许创建:7Z, ARC, Brotli, BZ2 (BZip), GZ (GZip), PAQ/ZPAQ, PEA, QUAD/BALZ/BCM, sfx, TAR, WIM, XZ, ZPAQ, ZIP, Zstandard 等,并且 peazip 允许打开和提取 200+ 文件类型:ACE, CAB, DEB, ISO, RAR, UDF, ZIPX 等。请勿从任何其他网站下载此应用程序。

● GnuPG for OSX(dev, dnld):‌ 验证文件/消息的真实性。GnuPG 也称为 GPG。我们需要这个工具来验证/验证下载的文件(或消息),以查明文件(或消息)是否确实是实际文件(或消息)创建者/作者/开发者实际发布/共享/创建/发送的,因此这个工具将指示/告诉我们接收到的文件(或消息)是否在文件/消息传输路径的中间或在文件/消息传输路径期间被某人或某设备修改/更改/滥用/损坏,或者这个工具将向我们指示在文件/消息传输路径期间未进行任何修改。文件(或消息)的实际创建者/开发者共享他们的(GnuPG/GPG 或 PGP 或 OpenPGP 基于的)加密数字公钥文件作为 pub 文件或带有 public 的 asc 文件。获取此类公钥最值得信赖的方式是:前往 KSP 或会议并会见实际的文件/消息创建者/开发者并直接获取公钥文件,(或者,下一个(稍微不那么)值得信赖的解决方案是:使用 WoT 并检查公钥组件以进行比较和验证公钥的真实性)。文件/消息创建者/开发者使用他们的私钥对主文件(或主消息)进行签名,这会为主文件(或主消息)创建一个唯一的签名文件,然后文件/消息创建者/开发者与公众共享主文件(或主消息)和签名文件。这个(GnuPG)工具可以使用签名文件、公钥文件和主文件(或主消息),并且可以指示主文件(或主消息)是否确实是由实际持有该公钥的人发布的,或者不是。为这个工具安装一个 GUI 前端/包装器。

了解系统将通过 PATH 环境变量找到并使用的已安装 gpg2 的目录位置,运行:which gpg2
GnuPG 工具也可以通过 MacPorts 包管理器加载,当您运行此命令时:sudo port install gnupg2

GpgFrontend(dev, src, dnld):‌ 开源、免费的工具,用于验证文件、验证消息等。它包含 OpenPGP 加密工具,并且也可以作为 GnuPG 的前端/包装器运行。参见上面的 GnuPG for OSX 条目。

● DevUtils(dev, dnld, appstore):‌ 它具有各种功能来执行各种开发相关的活动。应用程序是免费且开源的,但源代码需要付费。

各种用于构建、部署等的工具/应用程序在此:。

● TimeUTC(AppStore):‌ 它可以在您的顶部苹果  菜单栏中添加第二个日期和时钟,以显示当前的 UTC 时间和日期。免费软件。

● PumpKIN(dev, src2, dnld):‌ 开源、免费且基于 GUI。它是一个 TFTP 服务器和客户端应用程序,(具有内置的 TFTP 服务器和客户端功能)。适用于 macOS(和 Windows)。它经过测试,可以在 macOS Mountain Lion 上运行。TFTP 可能被滥用/利用来做有害的事情,因此请将其防火墙保护或在您完成使用此应用程序后禁用它,并且在您暂停处理其他事情时也禁用它。不要让它保持运行。更多信息在此。

● FileZilla(dev, dnld, src, comparison):‌ 它是 FTP、基于 TLS 的 FTP (FTPS)、SFTP SSH、SFTP 的客户端应用程序。开源、免费且基于 GUI。请勿从任何其他网站下载此应用程序。

● ProFTPD(dev, dnld, src, comparison):‌ 用于 FTP / FTPS / SFTP 服务器。开源、免费。基于 CLI。为这个工具获取一个 GUI 前端/包装器。
并且也为 ProFTPD 获取基于 Web(GUI)的管理界面应用程序 proFTPd-admin(从此处)。当您暂停处理其他事情时,不要保持此应用程序运行。它可能被滥用/利用来做有害的事情。

● Github Desktop for Mac(dev):‌ 允许开发者用户访问、协作和开发软件等,在 Github.com 网站上。基于 GUI 的免费应用程序。

● TextMate(dev, dnld, comparison):‌ 一个文本编辑器。开源且基于 GUI 的免费应用程序。一些功能:多选项卡、多窗口、基于正则表达式的搜索和替换等。

● Kate(dev, dnld):‌ 开源且免费的代码/文本编辑器。

● LuLu(dev):‌ 它是基于 GUI 的、免费的、开源的防火墙应用程序,用于控制 macOS 中应用程序/工具的出站互联网数据流量。

● Loading(dev):‌ 当应用程序/工具正在使用网络时

😩抱歉,出了点小问题,请稍后重试

发表在 计算机技术 | 留下评论

Build system setup macOS

This method is NOT OFFICIALLY supported. A native GNU/Linux environment is recommended.

Tested with macOS 10.15.7 (Darwin v19.6.0), Xcode 12.1 build 12A7403, & packages from homebrew.
Tested with macOS 11.6 (Darwin v20.6.0) Xcode 13.0 build 13A233, arm64 kernel, & packages from homebrew.

● to view macOS version numbers, etc, run : sw_vers
● to view Darwin version numbers, etc, run : sysctl kern.osrelease

macOS & Darwin Unix:

You can skip this section (if you want to), & goto next section A. Obtain build toolchain.
Brief/short info on macOS and Darwin Unix : macOS contains APSL (Apple Public Source License) & BSD (Berkeley Software Distribution) and others licensed opensource123 Darwin Unix based XNU1 hybrid core/kernel, & also contains Darwin unix as internal subsystem to support commandline based tools (from various Unix & Linux distros). Darwin supports POSIX API because of its BSD unix based lineage and because of largely FreeBSD userland tools, etc. Most drivers, & GUI layer’s most components are proprietary (not-opensource) licensed. Build tools need to be compatible with “darwin”.

  • In macOS v10.15.x (Catalina) & earlier versions, the Kernel modules, hardware drivers, etc are known-as & usually loaded as kext (kernel extension) inside kernel space/layer, & uses LKM with KPI (kernel programming interface) & d-KPI1 (deprecated-KPI). But, since macOS v11 (Big Sur) & newer versions, the newer sext/sysext (system extension) and (older) kext without d-KPI are used in user space/layer. And newer dext (driver extension) in macOS v11 & later also runs in user space/layout, and replaces earlier I/O kit. So hardware/software developer/MFR should still supply sext/dext & kext (without d-KPI). Earlier macOS/darwin used HFS partition, now uses APFS.
  • A derivative, OpenDarwin project released last stable v7.2.1 on July 16, 2004, then shutdown on July 25, 2006. Some free software community, ISC, etc particiapted with Apple to develop OpenDarwin1, and some ideas were used to build GNU-Darwin12. Another derivative, PureDarwin1 released a preview based Darwin 9 with X11 GUI in 2015, followed by a command-line only 17.4 Beta based on Darwin 17 in 2019.
  • Drivers: Wireless: 12. NIC: 123. Zyxel modem: 1. Card-readers: 1. Ext2 & Ext3 (Linux filesystem support) under macOS: 12.

A. Obtain build toolchain:

Obtain build toolchain that is more suitable for Apple hardware & macOS & Darwin Unix.

● Install Xcode or CLT:

  1. Obtain Xcode1 from here. Note: installer file download is over/near 5 GB, and needs 17+ GB space. Xcode 11.5 : 16,958,217,326 bytes (10.5 GB on disk).
    • to view installed Xcode version number, run this command : xcodebuild -version . If output not-showing version number then Xcode is not-installed.
  2. If you prefer to not obtain Xcode, then one of the alternative is:
    • obtain Command-Line-Tools1 (CLT) from here, or Load it from App Store in macOS, or use below command, or obtain apple-gcc package via package manager software. CLT is also known as Command Line Developer Tools. Note: installer download is under/near 300 MB, and may need around ~ 2 GB space.
    • inside Terminal1 utility/app, run this command to load CLT:xcode-select –install
      • to view installed CLT version number, run this command : pkgutil --pkg-info=com.apple.pkg.CLTools_Executables . If output not-showing verison number or showing msg that “…No receipt…” then CLT is not installed, or its bundled inside+with Xcode. To view pre-installed pkgs you may run : pkgutil --pkgs

● To view toolchain version numbers, directory, etc info, run this command:

gcc -v && llvm-gcc -v && clang -v

● you may also run xcrun clang command, & see what it outputs:

UserMacBook:~ username$  xcrun clang
clang: error: no input files
  • if output is NOT this message clang: error: no input files, then either installation has error or executable files are not in PATH env var correctly.

● Build toolchain (Xcode or CLT) from apple is used (in first stage) to create a software components for openwrt build purpose, then (in second stage) those software components are used to create the final openwrt components, in order to create openwrt firmware, etc, that are widely compatible with cross-platform.

B. View hidden files/folders:

● We need to view full filename, file extensions, all files & directories, etc including hidden ones, very accurately, so that there is lesser mistakes.
● Use Finder to start Terminal1 in macOS:

  • Finder is very similar to Windows-Explorer file-browser app/tool. In macOS > click on any empty area in Desktop screen > then in top-side  menu, click on Window > click on Bring All to Front > in left-pane (in left side column) of Finder, go under Favorites and click on the Applications > then scroll down & go into Utilities sub-folder > then click on Terminal or Terminal.app to start it. macOS Terminal is very similar to Windows Command-Prompt, a command-line interface (CLI) tool.
  • Hotkeys to start Finder instantly : [Alt/Option] + [Command] + [Space-bar] then close the Search tab.
  • Hotkeys to start Terminal instantly : None. ( Note: Keep Terminal running, after a reboot Terminal will auto-start if you check-marked the option: Load previous running apps after reboot ).

● Run below command inside Terminal:

defaults write com.apple.Finder AppleShowAllFiles true
  • above only makes the files viewable inside file-browser software, it does not actually change any file-attributes.

● then you must reboot Mac-computer OR run (any one of the) below command:

  • /usr/bin/sudo /usr/bin/killall Finder /System/Library/CoreServices/Finder.appor, run just this:/usr/bin/sudo /usr/bin/killall Finderor, just this:sudo killall Finder
  • then Finder will auto start, and all hidden files+folders will by-default begin to be shown to user in macOS Finder.

● in macOS Finder or inside any other file browsing window in macOS, user can also press below THREE buttons altogether ONCE to show all HIDDEN files/folders:

  • [Command] + [Shift] + [.>]
  • if user press-es above three buttons again, file-browsing-window will HIDE the HIDDEN files/folders.

● By default in macOS, Finder will keep most of the file extension hidden. But we need to see all file’s extension to see FULL filename, so we can be sure & not make mistake. To view all file’s extension, do below steps:

  • in macOS > start “Finder” app > goto main menu > Finder > Preferences > Advanced > select the Show All Filename Extensions option.

C. Install Package-Manager:

Install any one of the (3rd-party) package manager (pkg-mngr) software in macOS:

(1) Homebrew, or (2) MacPorts, or (3) pkgsrc.

  • Notice/CAUTION : Usually most of the time, using source (or binary) packages distributed from primary/original author/developer is much much better than next-level (aka: downstream) package distributors: like, OS/distro developer (dev), computer MFR (manufacturer), etc distributed packages, And usually most of the time OS/distro dev’s or computer MFR’s distributed package is better than 3rd-party Package-Manager (pkg-mngr) maintainer distributed package. But often OS/distro dev or computer MFR does not update their pre-included packages, or uses older version, or does not include option for user to obtain other/related packages (from OS/distro dev or computer MFR). So in such cases, next best option is: obtain the (src/bin) package from original author’s website for your OS/distro via secure conneciton. (Package’s source (src) code/file needs to be compiled to build package’s binary/executable (bin) file⒮). If original author shares only source, then that means author wants you to compile source. So your next best option is: compile the source obtained from original author/developer, after you patched the source to make it compatible & compilable for your OS/distro. Compile (compilation) process builds package’s binary (aka: executable), etc file(s). If previous steps are not possible for you, (because, “patching” requires software development, and OS/distro platform, and harwdare platform based knowledge, etc) then in such cases using 3rd-party package-manager (pkg-mngr) may be necessary for you. Some (3rd-party) pkg-mngr by default downloads package’s source (and dependencies / pre-requisites) & also auto compiles it in your OS/distro to create/build binary file(s). Usually package’s maintainer patches the original-source to make it suitable for compile/run in target OS/distro. Some (3rd-party) pkg-mngr downloads binary that is pre-built with already patched source for your OS/distro. When binaries are properly compiled & built in your own OS/distro then that is more trustworthy & better, than faster & directly download (pre-built) binaries. “Trust” is more important & safer & secure, than “Fast”/“Slow”. macOS has native pkg-mngr known as App Store, it has various or too many unfair restrictions & walls, set by macOS dev apple, does not allow various types of open-source apps, etc, So that is why sometime we need to use 3rd-party pkg-mngr. You must not download & compile & use source (src) or binary (bin) from any non-original author website or post. Either download src/bin over secure/encrypted connection from original-author’s website, OR, you must use OpenPGP/GPG/PGP based authentication to make sure downloaded src/bin is indeed actually released by actual original author. Pkg-manager tool internally includes option to use (some form of) authentication & verification for any download.

1Homebrew:
it is opensource & free (3rd-party) pkg-mngr for macOS, etc. Homebrew was built 7yrs after MacPorts pkg-mngr (formerly known as DarwinPorts).

● Notice / WARNING / CAUTION : homebrew is opensource pkg-mngr but this tool uses Google Analytics to collect usage telemetry. If you use homebrew: use OPT OUT option/command,

brew analytics off

or by setting

export HOMEBREW_NO_ANALYTICS=1

2MacPorts:
it is opensource & free (3rd party) pkg-mngr (package manager) for macOS, etc, & it does not steal your usage/private data. MacPorts guide. It can obtain source or binary or both (for most) package. After downloading source, it can auto compile in your OS/distro to create/build trustworthy binary files. MacPorts was created 7yrs before homebrew. wp.
● download/obtain MacPorts installer dmg/pkg file, install it. More info here.
● Before MacPorts is installed, your ~/.bash_profile file (inside your home directory) may look close to like this:

# .bash_profile for BASH
# PROMPT_COMMAND=update_terminal_cwd
PS1='\h:\W \u\$ '
PS2='> '
PS4='+ '
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export PATH

● MacPorts installer webpage will instruct you to add macports pkg-mngr executable file locations in the end of your PATH variable, like this:

PATH="$PATH:/opt/macports/bin:/opt/macports/sbin"
  • after you add above line manually in ~/.bash_profile file, it will look like below:# .bash_profile for BASH # PROMPT_COMMAND=update_terminal_cwd PS1=’\h:\W \u\$ ‘ PS2=’> ‘ PS4=’+ ‘ PATH=”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin” PATH=”$PATH:/opt/macports/bin:/opt/macports/sbin” export PATH
  • you can use this command to edit the ~/.bash_profile file:sudo nano ~/.bash_profile

● When MacPorts is installed, installer will add locations in PATH where macports port package executables are stored, inside the ~/.bash_profile file. In that way, your macOS user account can find+use the installed macports port package files, after you login. But we have to change it little bit.
Here is what you will usually see in ~/.bash_profile file (after macports is installed):

# .bash_profile for BASH
# PROMPT_COMMAND=update_terminal_cwd
PS1='\h:\W \u\$ '
PS2='> '
PS4='+ '
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
PATH="$PATH:/opt/macports/bin:/opt/macports/sbin"
 
##
# Your previous /Users/<YOUR-USER-NAME>/.bash_profile file was backed up as /Users/<YOUR-USER-NAME>/.bash_profile.macports-saved_2021-08-29_at_16:38:31
##
 
# MacPorts Installer addition on 2021-08-29_at_16:38:31: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.

● Change above codes, into below code:

# .bash_profile for BASH
# PROMPT_COMMAND=update_terminal_cwd
PS1='\h:\W \u\$ '
PS2='> '
PS4='+ '
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
PATH="$PATH:/opt/macports/bin:/opt/macports/sbin"
 
##
# Your previous /Users/<YOUR-USER-NAME>/.bash_profile file was backed up as /Users/<YOUR-USER-NAME>/.bash_profile.macports-saved_2021-08-29_at_16:38:31
##
 
# MacPorts Installer addition on 2021-08-29_at_16:38:31: adding an appropriate PATH variable for use with MacPorts.
# export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
export PATH
# Finished adapting your PATH environment variable for use with MacPorts.
  • in above we have disabled MacPorts based port package locations from PATH, but locations of MacPorts pkg-mngr itself are kept in PATH. The “PATH” is an essential environment variable which indicates the sequence of directories/folders where to look for a specific (executable) program. The changes we made, will allow newly installed (MacPorts) packages stay out of touch of other software which does not need to use them. These (MacPorts) packages are needed for development/build purpose of OpenWRT, so we will create a separate executable file (env.sh) to load PATH (and other build environment variables), which is suitable for using inside a shell-manager’s specific shell TAB(s) only, for openwrt build/development purpose. See step/section F in below for details on creating this env.sh file.

Tips for MacPorts users:

  • to search for a pkg: port search --name --glob '*pkgName*'
  • to view info on a pkg: port info pkgName
  • to view what depencies are needed for a pkg: port deps pkgName
  • to install a pkg: sudo port install pkgName

3pkgsrc:
it is opensource & free (3rd-party) pkg-mngr (package-manager) for NetBSD unix OS, but can also be used by other OS, including macOS/darwin. It can obtain binary packages. Download: dev, Src: gh, More info: wp.

Warning : macOS keeps the default PATH in /etc/paths file, but do not edit/change it, because such change can affect entire or many parts of macOS system. We only need to change build environment only for 1 or 2 shell instance(s), and not for entire macOS system, and also not for all other apps in macOS.

D. Create Dedicated Case-Sensitive Filesystem:

Create a dedicated case-sensitive filesystem for OpenWRT build/compile purpose:
● We will be using a sparsebundle to allow us to have a case sensitive filesystem.
● The size that you provide will be the max size of the volume for working with OpenWrt. Execute below commands inside a Terminal shell instance:

cd ~
hdiutil create -size 20g -type SPARSE -fs "Case-sensitive HFS+" -volname OpenWrt OpenWrt.sparseimage
hdiutil attach OpenWrt.sparseimage
  • the command cd ~ in above is taking developer-user inside the HOME directory of user-account in macOS, then OpenWrt.sparseimage file is created there. But if you want to create the SPARSE image file in a different directory, then change the cd ~ line & go inside your preferred volume/directory.

● Optional/Informational:

  • if you want to open the OpenWRT Volume (aka: Drive, aka: Disk) after creating then use below command as 3rd-command line in above:hdiutil attach OpenWrt.sparseimage -autoopenrw
  • after a reboot, if OpenWRT volume is not available in your macOS, then run:cd ~ && hdiutil attach OpenWrt.sparseimage -autoopenrw
  • if you want to keep the OpenWRT volume always attached, then:cd ~ && sudo hdiutil attach OpenWrt.sparseimage -notremovable -autoopenrw
  • if you want to detach (aka: unmount) the OpenWRT volume, then:hdiutil detach /Volumes/OpenWrt
  • More info on hdiutil is here.

E. Goto OpenWRT build volume:

Go inside the OpenWRT build volume, with below command, in Terminal:

cd /Volumes/OpenWrt

F. Create location indicator & build environment file:

● Create a file called env.sh inside /Volumes/OpenWrt to indicate location of installed packages. It will also help us to create openwrt build friendly environment, inside a specific shell tab/instance in shell-manager software like Terminal.

  • This is to allow packages from pkg-mngr (which we will install in next step) to be used, instead of the macOS provided ones.

Based on your pkg-mngr (package-manager), follow one of the below appropriate section:

● For x86_64 Apple hardware, & when you have MacPorts pkg-mngr, then create env.sh file with below content, save it inside /Volumes/OpenWrt location:env.sh

#!/opt/local/bin/bash
PS1='\h:\W \u\$ ';PS2='> ';PS4='+ ';
# Bring PATH lines from the ~/.bash_profile file into below:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
PATH="$PATH:/opt/macports/bin:/opt/macports/sbin"
# Adding path of macports port packages, in ahead of others:
PATH="/opt/local/libexec/gnubin:/opt/local/bin:/opt/local/sbin:/opt/local/libexec:/opt/local/x86_64-apple-darwin19.6.0/bin:$PATH";
# Load PATH into currently running shell:
export PATH;
# Load other environment variables:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk7-zulu/Contents/Home
  • turn the env.sh file an executable shell script file with this command:chmod +x /Volumes/OpenWrt/env.sh
  • For MacPorts create MacPorts.sh file in your home ~/ directory with this command:sudo nano ~/MacPorts.sh
  • find the PATH variables lines in your ~/.bash_profile file, and add into below content, then copy all from below & paste into ~/MacPorts.sh file. You can also download below code as a file, then change upper 2 PATH variables, to match with your PATH inside your ~/.bash_profile file:MacPorts.sh#!/opt/local/bin/bash PS1=’\h:\W \u\$ ‘;PS2=’> ‘;PS4=’+ ‘; # Bring PATH lines from the ~/.bash_profile file into below: PATH=”/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin” PATH=”$PATH:/opt/macports/bin:/opt/macports/sbin” # Bring last PATH line from the /Volumes/OpenWrt/env.sh file into below: PATH=”/opt/local/libexec/gnubin:/opt/local/bin:/opt/local/sbin:/opt/local/libexec:/opt/local/x86_64-apple-darwin19.6.0/bin:$PATH“; # Load PATH into currently running shell program: export PATH; # Load other environment variables: export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk7-zulu/Contents/Home
  • turn the MacPorts.sh file an executable shell script file with this command:chmod +x ~/MacPorts.sh

● For x86_64 Apple hardware, & when you have homebrew, then create env.sh file with below content:

PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
PATH="/usr/local/opt/gnu-getopt/bin:$PATH"
PATH="/usr/local/opt/gettext/bin:$PATH"
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
export PATH

● For arm64 (Apple Silicon(M1)) Apple hardware, & when you have homebrew, then create env.sh file with below content:

PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gnu-getopt/bin:$PATH"
PATH="/opt/homebrew/opt/gettext/bin:$PATH"
PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
export PATH

● Optional:

  • you may check homebrew official page or MacPorts-guide if you need more information related to PATH variable, or other info on pkg-mngr.
  • turn env.sh file an executable shell script file: chmod +x /Volumes/OpenWrt/env.sh

G. Install necessary packages:

Install necessary packages via pkg-mngr, packages which help to build openwrt components. Use below commands inside a shell instance/tab in Terminal. Note: Packages will be installed inside macOS default volume, not inside /Volumes/OpenWrt

Based on your pkg-mngr (package-manager) follow one of the below appropriate section:

● if you have homebrew pkg-mngr then run this command:

brew install coreutils findutils gawk grep gnu-getopt gnu-tar wget diffutils git-extras quilt svn make ncurses pkg-config
  • in above, homebrew command does not include the pre-requisites (aka: dependencies) packages mentioned here.

● if you have MacPorts pkg-mngr then run below 2 commands:

source ~/MacPorts.sh
sudo port install libiconv gettext-runtime coreutils findutils gwhich gawk zlib pcre bzip2 ncurses grep getopt gettext-tools-libs gettext diffutils sharutils util-linux libxslt libxml2 help2man readline gtime gnutar unzip zip lzma xz libelf fastjar libusb libftdi0 expat sqlite3 openssl3 openssl kerberos5 dbus lz4 libunistring nettle icu gnutls p11-kit wget quilt subversion gmake pkgconfig libzip cdrtools ccache curl xxhashlib rsync libidn perl5 p5.28-xml-parser p5.30-xml-parser p5-extutils-makemaker p5-data-dumper boost-jam boost boost-build bash bash-completion binutils m4 flex intltool patchutils swig git-extras git openjdk17 openjdk7-zulu luajit libtool glib2 file python27 python310 libzzip mercurial asciidoc sdcc gnu-classpath
  • in above, MacPorts command includes the pre-requisites (aka: dependencies) packages mentioned here. Space initially used by all of these packages : 4,190,442,792 bytes (2.57 GB on disk) for 129,623 items, (as of March-11, 2022). Note: As different packages are continuously modified & improved by their devs or releaser or adopter or maintainer, so their occupying space size & items count will be different in your computer in different time.

● Optional tools via MacPorts:

  • if you need picocom tool to communicate with router via serial adapter/cable1 connection, then:sudo port install picocom
  • if you need last stable openssh (aka: ssh), sftpscp tools for secure communication or file-transfer, then:sudo port install openssh
  • if you need to use last stable telnet1ftprshrlogintftp1 tools and corresponding daemons/servers, then:sudo port install inetutils
    • if you need other type of bundled packages, then look here: 1.
    • if you need other TFTP daemon/server (tftpd), then you may try below. TFTP server alows to receive files from router, or allows (bricked) router to boot from TFTP server, etc:sudo port install tftp-hpa
  • if you need these type of tools, (more info: 1), then:sudo port install arm-elf-binutils i386-elf-binutils m68k-elf-binutils mips-elf-binutils x86_64-elf-binutils

H. Optional-step: Start build friendly shell:

macOS by default uses a very old version of bash shell. So, we can+should start a build/compile friendly common last+stable or recent version of bash shell inside macOS-Terminal’s specific tab, as such recent version can be obtained & used by most developer users. Shell-manager software Terminal can run multiple shell instances, by using multiple Terminal-tabs. Select one (or more) Terminal-tab(s) to use for openwrt build purpose, then run below command to have same (last+stable) build environment.

● If you installed new bash package, then start new bash shell inside a specific tab in Terminal, (when you have MacPorts based bash package), with this command:

exec /opt/local/bin/bash

● optional:

  • approve/permit new bash shell in macOS with this command:
    echo “/opt/local/bin/bash” | sudo tee -a /private/etc/shells
  • if you want to continue to use the new bash always, then: click on apple  symbol in topside apple menu-bar > System Preferences... > Users & Groups > Unlock the 🔒pane > control click on your user-name > select Advanced Options... > then update/change the Login shell into /opt/local/bin/bash > ok.

I. Load build environment:

We need to load build package locations indicator file as shell environment. OpenWRT developing (aka: building, aka: compiling, aka: compilation) is done inside a suitable (aka: build friendly) shell environment. So, we have to allow openwrt build commands to find packages that we installed via pkg-mngr, by loading build package location indicator file env.sh into one of the Terminal shell environment tab, to create that openwrt build friendly & suitable shell environment.

When developing (aka: building, aka: compiling), run below command to set up build-friendly PATH (and other) variable(s). This leaves your system in a clean state without symlinking.

source /Volumes/OpenWrt/env.sh
  • Optional : So from next time or after a reboot, when you want to enter into openwrt build mode, then run below 2 commands inside a specific tab in Terminal, when you have MacPorts based bash package:exec /opt/local/bin/bash source /Volumes/OpenWrt/env.sh

J. Build:

Now proceed normally, (that is, start to follow build related other steps/procedures shown in parent/previous page).

Other Tools:

Some users may need below some of the tool.

B43-FWCutter

Users who are developing openwrt firmware for Broadcom (BCM) 43xx chipset, (to use in OpenWRT), those users need this b43-fwcutter tool to extract wireless drivers from firmware.

  • More info here.
  • Package manager homebrew has this tool, and MacPorts does not.
    • Users of MacPorts can obtain source1234 & compile, or get it1 from FreeBSD pkg.

Golang1: For darwin/arm64 and linux/aarch64 golang package (feed “packages”) golang C-bootstrap method doesn’t work, but it is possible to use external golang bootstrap. On MacOS arm64 the easiest way is to install golang using brew and use installed golang as bootstrap:

  • brew install golang
  • Then set CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT=“/opt/homebrew/opt/go/libexec” in .config file

Optional Tools:

optional tools, drivers, software, etc for macOS, to assist into build/compile process, & to increase security.

Software Tools:

No need to install these, unless you specifically need such tool/app/utility to assist your build related works. Here is a small list of some optional/extra tools related to openwrt software code build & test & usage & diagnostics, etc, and also list of some optional/extra tools related to network device test/diagnostics, etc to run/use in macOS (apple macintosh operating system) and apple hardware. For more, goto wp.

● XQuartz (devwpsrcdnld) : it allows cross-platform (GNU-Linux, etc) apps/tools (which were developed to use X11 GUI), to run on macOS & use macOS’s native Quartz GUI, etc. Many GUI apps/tools need this. It is opensource tool.

● PeaZip (devdnldsrcwpcomparison) : it is a free & opensource archiver (zip, compress) & unarchiver (unzip, decompress) app/tool. GUI (Graphical User Interface) based. Allows to create: 7Z, ARC, Brotli, BZ2 (BZip), GZ (GZip), PAQ/ZPAQ, PEA, QUAD/BALZ/BCM, sfx, TAR, WIM, XZ, ZPAQ, ZIP, Zstandard, etc, and peazip allows to Open & Extract 200+ file types: ACE, CAB, DEB, ISO, RAR, UDF, ZIPX, etc. Do not download this app from any other website.

● GnuPG for OSX (devdnld) : verifies file’s/message’s authenticity. GnuPG is aka (also known as) GPG. We need this tool to verify/authenticate downloaded files (or messages) to find-out whether files (or messages) are indeed what actual file (or message) creator/author/developer actually released/shared/created/sent, So this tool will indicate/tell us whether received files (or messages) were modified/altered/changed/abused/corrupted by someone or some-device in the middle of file/msg travel path or during file/msg travel path, or this tool will indicate to us NO modification was done during file/msg travel path. File’s (or message’s) actual creator/developer shares their (GnuPG/GPG or PGP or OpenPGP based) crypto (cryptographic) digital pub-key file as pub file or as asc file with public. Most trustworthy way to obtain such pub-key is: goto a KSP or conference and meet actual file/msg creator/developer & obtain pub-key file directly, (or else, the next (slightly-less) trustworthy solution is: use WoT & inspect pub-key components to compare & verify a pub-key’s authenticity). File/msg creator/developer signs main-file (or main-msg) with their prv-key, & that creates an unique sig (signature) file for a main-file (or main-msg), then file/msg creator/dev shares main-file (or main-msg) & sig-file with public. This (GnuPG) tool can use sig-file, pub-key file, & main-file (or main-msg), & can indicate if the main-file (or main-msg) was actually released by the actual holder of the pub-key, or not. Install a GUI frontend / wrapper for this tool.

  • to know directory location of installed gpg2 which your system will find (via PATH env var) & use, run : which gpg2
  • the GnuPG tool can also be loaded via MacPorts pkg-mngr, when you run this command : sudo port install gnupg2
  • GpgFrontend (devsrcdnld) : opensource, free tool to authenticate file, to authenticate message, etc. it contains OpenPGP crypto tool and can also function as a frontend / wrapper for GnuPG. See GnuPG for OSX item in above.

● DevUtils (devdnldappstore) : it has various functionalities to perform various development related activities. App is free & opensource, but source-code requires a payment.

  • Various tools/apps for Build, Deployment, etc are here: 1.

● TimeUTC (AppStore) : it can add a second date & clock in your topside apple  menu bar, to display current UTC time & date. freeware.

● PumpKIN (devsrc2dnld) : opensource & free & GUI based. it is a TFTP server & client app, (with builtin TFTP server & client functionalities). For macOS (and Windows). It was tested & can run on macOS Mountain Lion. TFTP can abused/exploited to do harmful things, so keep it firewalled or disable it after you are done working with this app, and also disable it when you pause to work on something else. Do not keep this running. More info here.

● FileZilla (devdnldsrccomparison) : it is a client app for FTP, FTP over TLS (FTPS), SFTP SSH, SFTP. Opensource & free & GUI based. Do not download this app from any other website.

● ProFTPD (devdnldsrccomparison) : For FTP / FTPS / SFTP server. opensource & free. CLI based. Get a GUI frontend / wrapper for this tool.

  • And also get web (GUI) based admin interface app proFTPd-admin (from here) for ProFTPD. Do not keep this app running, when you pause to work on something else. It can be abused / exploited to do harmful things.

● Github Desktop for Mac (dev) : allows a developer user to access & collaborate & develop software, etc on Github.com site. GUI based free app.

● TextMate (devdnldcomparison) : a text editor. Opensource & GUI based free app. Few features : multi tabs, multi windows, regex based search & replacement, etc.

● Kate (devdnld) : opensource & free code/text editor.

● LuLu (dev) : it is GUI based & free & opensource firewall app to control outbound internet data traffic of apps/tools in macOS.

● Loading (dev) : it can show a spinning progress wheel in  menu bar when network is being used by app/tool. Clicking the icon can show the apps/tools that are using network, & holding down the option key can show individual processes. Opensource, free & GUI based tool.

● OpenSSH (Portable) (devsrcdnld-srccomparison) : opensource & free. it is a remote-access client tool to connect with SSH-servers1. It can encrypt all traffic into SSH-server to eliminate eavesdropping, connection hijacking, and other attacks, it has large suite of secure tunneling capabilities, several authentication methods, and sophisticated configuration options. Includes ssh, scp, sftp1, ssh-add, ssh-agent, ssh-keygen, ssh-keyscan. Source can be compiled/built in macOS, or download openssh from macports pkg-mngr, or download dependencies via macports & then build/compile. CLI based. Get a GUI wrapper / frontend for this tool.

● Fugu (devsrc-2, wp) : a free & opensource & GUI based frontend / wrapper for OpenSSH ssh,sftp,scp, etc commandline tools. Very old, but still useful to handle SSH keys, etc. It is a SFTP client, SSH app.

● PuTTY (devwpsrc) : it is a free & open-source terminal emulator, serial console and network file transfer tool, & supports several network protocols: SCP, SSH, Telnet, rlogin, and raw socket connection. Actually developed for Windows OS, but has been ported into MacPorts pkg-mngr to use in macOS. GUI based. To install via Macports pkg-mngr, run: sudo port install putty

  • PuTTY in MacPorts needs these dependencies (these wil be auto-loaded by macports): pkgconfig, gtk2. And gtk2 needs these dependenicies: gtk-doc, pkgconfig, perl5, autoconf, automake, libtool, xz, atk, pango, gdk-pixbuf2, gobject-introspection, xorg-libXi, xorg-libXrandr, xorg-libXcursor, xorg-libXinerama, xorg-libXdamage, xorg-libXcomposite, xorg-libXfixes, shared-mime-info, hicolor-icon-theme.

● Coccinellida (devdnld) : a simple SSH tunnel manager app. opensource, free. GUI based.

● STM (SSH Tunnel Manager) (devdocappstore) : it can manage multiple ssh tunnels / connections: local, remote, socks-proxy, etc. it is a GUI based fronend / wrapper for ssh tool, but for socks-proxy it can use builtin ssh on some situations. freeware. not-opensource. GUI based & also frontend for SSH.

● OpenVPN Connect (devdnldappstorecommunity-dnldwp) : opensource & free. VPN (virtual private network) connector client tool. GUI based. (There are many other types of VPN1 connector client/server app/tool).

● TunnelBlick (dev) : a free & opensource & GUI based frontend / wrapper for OpenVPN commandline tool.

● WireShark (devdnldsrccomparisonwiki) : it is a network data packet analyzer (aka: network protocol analyzer = NPA) software. Opensource, free & GUI based.

● VirtualBox (devdnldcomparison2) : a free & opensource & GUI based virtualizer software (from Oracle) to create (software based) virtual-machine (VM) inside a hardware based host machine. So with this app, user can run+use multiple+different operating systems (OS) simultaneously. User can create VM as client, VM as server, client+server VM, Desktop OS VM, Mobile OS VM, etc, etc. First version used codes from QEMU. It can emulate these (hardware) architectures as VM: x86, x86-64.

● QEMU (devdnldsrcwp) : it is free & opensource. It is a generic & open source machine emulator and virtualizer. It can emulate various (hardware) architectures as VM, such as: x86, x86-64, MIPS64 (up to Release 6), SPARC (sun4m and sun4u) (32/64), ARM (Integrator/CP and Versatile/PB), SuperH, PowerPC (PReP and Power Macintosh), ETRAX CRIS, MicroBlaze, and RISC-V, OpenRisc32, Alpha, LM32, M68k, S/390, SH4, Unicore32, Xtensa, etc.

● NTFS for Mac (Microsoft NTFS for Mac By Tuxera) (dev) : The functionality or ability to read NTFS partitions inside macOS is very helpful feature to transfer file(s) between Windows NTFS partition HDD/SSD and your APFS (apple macOS file-system). This “NTFS for Mac” by Tuxera tool is not free (aka: as freedom of software), it is proprietary (non-opensource) tool. Only trial version is freeware for 15days, tiral version has some helpful functionalities. Full functionalities (after 15 days trial) requires a payment.

  • HDD/SSD storage device MFR (aka: manufacturers) also includes NTFS for Mac (Microsoft NTFS for Mac By Paragon1, etc) software for macOS, with their some HDD/SSD storage device, So if you purchased such HDD/SSD or if your HDD/SSD drive (in your computer) matches with MFR’s such HDD/SSD then you may use that full-version NTFS for Mac (by Paragon) software (by obtaining it from HDD/SSD MFR’s website). a 10-day trial-version is here: 1.
  • Earlier helpful software FUSE for macOS123 is not anymore free (as in freedom of software) for macOS, it is now proprietary for macOS. The Mounty for NTFS1 and NTFS-3G12 are free & opensource, but slow. Linux kernel v5.15 & onward has began to support NTFS1 3.1 & earlier versions, NTFS driver was provided by Paragon.

● GPT fdisk (gdisk) (devdnldlist) : opensource & free partition manager tool. gdisk has TUI (text-based semi-graphical user interface) interface. gdisk can edit GUID partition table (GPT) definitions in Linux, FreeBSD, MacOS X, or Windows, it can convert MBR to GPT without data loss, convert BSD disklabels to GPT without data loss, create hybrid MBR or convert GPT to MBR without data loss, repair damaged GPT data structures, repair damaged MBR data structures (FixParts). macOS 10.11.x (“El Capitan”) and later created some areas (and layers) of partitions “rootless”, so users need to either disable1 SIP (System Integrity Protection), or Run it from a bootable USB/CD/DVD storage disk/media (by using partition manager tools like: PartedMagic1). Obviously using trustworthy bootable disk is better idea+method. gdisk can work on external / USB media / disk / drive fine (without disabling SIP in macOS). it can also be installed via MacPorts pkg-mngr: sudo port install gptfdisk

  • Paragon Hard Disk Manager for Mac (dev) : it is a commercial & non-opensource software, GUI based. it can manage drive/disk partitions. a 10-day trial version is here for macOS. A community edition of (Paragon Partition Manager) is avilable which is not-trial & can continue to function for non-commercial use purpose only, but available only for Windows 7 & higher OS, here.

● UNetbootin (devdnld2listcomparison) : opensource & free boot disk creator. GUI based. it allows to create bootable Live USB drives for booting Ubuntu, Fedora, and other Linux distributions without burning a CD. It can run on (Windows, Linux, and) macOS. You can either let UNetbootin download one of the many distributions supported out-of-the-box for you, or you can supply your own (Linux, etc) .iso file.

● Clonezilla (devsrcdnldcomparison-(clone), comparison-(img), list-(clone), list-(recovery) ) : it is opensource & free tool to clone/backup/copy drive & partitions, from Linux OS. it has TUI (text-based semi-graphical user interface) based interface. Supports: FAT12, FAT16, FAT32, NTFS, ext2, ext3, ext4, ReiserFS, Reiser4, xfs, jfs, btrfs, f2fs, NILFS2, HFS+, UFS, minix, VMFS3. Obtain Clonezilla’s bootable disk img file from Clonezilla dev site, After you boot from that, it will load Debian Linux & it will run Clonezilla. Usually it can be used on (almost) any computer (including Mac). Notice: Partitions which are proprietary & very recent & no API/access solution is yet found, support for those partitions are not yet available in this software.

  • You can also use (opensource) RescueZilla1 which is a Clonezilla GUI version from another developer, obtain from here: 1(it also requires booting from USB/external media/disk). You can also try (opensource) Redo Rescue1 (formerly “Redo Backup & Recovery”) software from here: dnld src, it is partly based on Clonezila, (and it also requires booting from USB/external media/disk).
  • Acronis True Image 2021 for Mac (dev) : it is non-opensource & commercial software to clone/backup/copy drive & partitions. GUI based. 30-day trial version is available here. Supports: FAT32, NTFS, HFS+, APFS, ext2, ext3, ext4 and ReiserFS. Some HDD/SSD storage drive MFR (manufacturers) include this with their HDD/SSD, so if you’ve purchased drive or if your drive in your computer matches thier drive, then you can obtain the full-version from HDD/SSD MFR’s website.

● Deluge (devdnldcomparison) : a bittorrent network based file-sharing software. free & opensource. Encrypt or Password protect files before sharing, & share password via a separate (private) channel. Filename can have contact info if you wish to be contacted, but remember that such contact info will also be abused by someone out there. More info here.

● Thunderbird (devdnldsrccomparison) : multi data communication-protocol supporting client, but more commonly known as an Email client app (for viewing, reading, sending emails), so it is a PIM1/PDM1 client (that supports personal/private information like: emails, address-book, calendar dates, emails, instant messages, passwords, alerts, browsing site data, etc, etc). Thunderbird is free & opensource. It is also client app/tool for: newsfeeds1/newsgroups12 (NNTP1 client, NNTPS) , web feeds12 (news aggregators1, like: Atom1, RSS1, etc) client, instant messaging1 (aka: chat1 networks, like IRC1, XMPP1, Google-Talk, Twitter, Odnoklassniki, etc) client, address auto-completion (LDAP) client, etc. Thunderbird contains core/engine of Mozilla Firefox web-browser, which allows thunderbird to connect with various types of web-servers / web-sites to use various web-services as HTTP/HTTPS protocols cleints & as other protocols cleints, and firefox web-browser core also allows thunderbird to open123 multiple web-browser tab(s) (inside thunderbird) to be used by users, manually. Send yourself (a HTML based) email (or chat-msg) with URL-links to various web-site services, then inside thinderbird right-click on link (inside email or chat-msg) & select the option to open the link inside a New Tab inside thunderbird1, in this way you can use/access various WebMails12, Twitter1, etc. More info on how to approve cookies & JS for such web-service website and dependent 3rd-party web-services (inside thunderbird), are explained here. Thunderbird addons can also allow access to various web-services more easily: Google-Chat1, Skype-WebApp1, Telegram-Web12, Google-Voice1, ProtonMail-Encryption-Status1, regimail1, Google-Calendar12, M-Hub Lite1, TbSync1, Exquilla-for-Exchange1, Google-Contacts12, Outlook AddressBook Enabler1, Display Mail User-Agnet T1 (Display Email Writer’s Email-Client), Google-Keep-(tab)1, Owl (OWA) for Exchange1. This type of app is very helpful to keep multi channel communications with openwrt & other various project developers, and to test your own servers. Get firefox addon uBlock Origin1, & load into Thunderbird, that addon allows you to stop un-approved Advertisements that are using+stealing your computing (CPU, GPU, etc) resources, & internet (limited & costly) data allotments from your ISP, etc, without your consent/permission/approval, and these advertisers also DO NOT PAY you any FEE after they used your computing & data resources.

● Apparency (devdnld) : it can inspect software application bundles (pkg, app, etc) for macOS, & then it can show info on code signing requirements, notarization, signatures, included frameworks, etc. it is a freeware.

● AppCleaner (dev) : open Finder > goto Application in any finder-tab > open this AppCleaner app, then drag the app that you want to remove/uninstall from Application folder/directory, & drop it inside the AppCleaner, it will inspect & find-out & show all elements used by that unwanted app, & also show you option to Remove. it is freeware.

Drivers:

various (opensource) drivers for macOS, are mentioned (with website links) in this page, inside the topside macOS & Darwin Unix section.

Serial-to-UART, USB-to-UART, USB-to-JTAG, etc cable/adapter’s macOS/darwin drivers, to communicate with router (from apple mac computer), are usually provided by the cable/adapter device’s manufacturer. a slow but opensource serial-to-UART driver is also available. For more info goto here.

发表在 计算机技术 | 留下评论

为新设备添加OpenWrt支持

为了全面了解如何添加新设备支持,我们建议您查看一台新设备相关的最新的commit,摸清楚哪些文件发生了修改和如何修改它们。这些文件非常方便理解,我们只需要去打开查看就能理解。

通过实例进行学习

一个好方法是通过示例学习,我们通过搜索mt300a这个版型文件来,找出需要修改的文件,所以你可以这样做:

grep -lri mt300a target/

显示结果是添加新板所需的最少文件列表:

target/linux/ramips/base-files/etc/board.d/01_leds

target/linux/ramips/base-files/etc/board.d/02_network

target/linux/ramips/base-files/lib/upgrade/platform.sh

target/linux/ramips/base-files/lib/ramips.sh

target/linux/ramips/dts/GL-MT300A.dts

target/linux/ramips/image/mt7620.mk

重要文件

最重要的文件一般存放于以下目录:

/target/linux/<arch_name>/base-files/etc/…

该目录的文件和文件夹最终将会存放于设备固件的/etc/目录。

它一般包含下列的文件和文件夹:

  • …board.d/ 定义设备专用的默认硬件的脚本,如LED和网络接口。
  • …hotplug.d/ 定义设备专用的,在插入热插拔设备时自动运行的脚本
  • …init.d/ 定义设备专用的在启动时自动运行的脚本
  • …uci-defaults/ 定义设备专用的UCI默认设置
  • …diag.sh 定义设备显示的错误代码

/target/linux/<arch_name>/base-files/lib/…

该文件夹下的文件夹和文件对应固件中的/lib目录下文件夹和文件。

它的子文件夹和文件有:

  • …<arch_name>.sh 将阅读友好的设备名转化为脚本安全的设备名的脚本
  • …preinit/ 通用<arch_name>预初始化脚本
  • …upgrade/ 通用<arch_name>升级脚本

/target/linux/<arch_name>/base-files/sbin

该文件夹对应固件中的/sbin文件夹, 一般为通用的<arch_name> sbin脚本和工具.

/target/linux/<arch_name>/dts/

设备树源文件(Device tree source files, 简写为dts).

/target/linux/<arch_name>/image/

用于构建写入用镜像的设置文件。

/target/linux/<arch_name>/<board_name>/

设备专用的设置文件

/target/linux/<arch_name>/modules.mk

menuconfig中使用的架构专用(Arch-specific)配置文件

使新设备出现在make menuconfig中

在编辑了上述的文件后, 你需要对Makefile使用touch命令

touch target/linux/*/Makefile

补丁

子目录 patches-xxx 是对一个 目标版本xxx 的内核补丁.
它包含的文件名(’3个数字-全小写字母的简介.patch’)称含义如下:

0xx – 上游需要回退的内容补丁
1xx – 等待上游合并的代码补丁
2xx – 内核构建、配置和头文件的补丁
3xx – 用于特定体系结构的补丁
4xx – MTD相关的补丁(系统和设备方面)
5xx – 文件系统相关的补丁
6xx – 网络通用补丁
7xx – 网络物理层驱动补丁
8xx – 其他设备补丁
9xx – 未分类的其他补丁

所有的补丁发布都必须具有相比现阶段潜在的优势,如:

– 补丁必须具有合适明确的主题
– 必须有一个明确清晰的commit信息来解析补丁作出了什么样的改变
– 补丁必须包含一个签署人

镜像测试

测试镜像固件通过ramdisk镜像而不通过烧写到Flash。

make menuconfig配置中选择Target Images,然后再选择ramdisk选项。

这样将会编译生成一个kernel+inittramfs(内核加上内存根文件系统)的镜像文件,它的名字中将会包含initramfs。通过BootLoader的tftp功能可以将这个镜像文件导入到设备,这样可以在不需要flash文件系统的支持下进行启动。

小窍门

使用目标设备中的shell

为了获取到某个你感兴趣的OpenWrt设备的端口的相关数据,需要进行shell访问。但是大多数设备都没有提供使用telnet或者ssh连接shell的方法。

通过PING或者NTP功能进入shell

某些路由器提供ping测试或NTP服务器配置,并且可能无法正确清理用户输入。尝试输入shell脚本,看看您是否幸运。您可能需要一些JavaScript知识才能禁用客户端输入验证。

使用telnetd
$( /bin/busybox telnetd -l/bin/sh -p23 & )
如果需要远程登录,请使用HTTP获取密码哈希或使用“sed”删除/更改默认密码
$( cp /etc/shadow /www )
$( cp /etc/passwd /www )

然后尝试将他们下载到您的电脑并且破解哈希密码。

降级固件

某些路由器可能会在启动之初尝试从特定的专用IP下载固件文件(例如TP-Link Archer C2 AC750),从而允许用户降级到较旧的固件。

HTTP服务器漏洞

一些路由器可能正在运行过时/不安全的HTTP服务器,并且可能容易受到缓冲区溢出或其他攻击的影响。

网件

使用 netgear-telnetenable 许多网件设备都可以通过telnet进入,也可以查看 GitHub: insanid/NetgearTelnetEnable。如果无法使用这种方法,则可以尝试从启用了telnetd的供应商发布的源中刷新映像构建。

通过 nmrpflash许多网件设备可以被烧录,但是无法确定能够使用该工具的设备有哪些。

收集相关数据

WikiDevi上面许多信息可以被查询到,例如:FCC ID:十分的有用处当你搜寻文件的时候,datasheets和网络照片:能够无需打开机壳就能区分使用过的芯片。

通常可以使用以下的命令:

  dmesg                          # log buffer might be to small, see note 1.
  cat /proc/cmdline
  cat /proc/cpuinfo
  cat /proc/meminfo
  cat /proc/devices
  ls /sys/devices/platform
  cat /proc/mtd
  cat /sys/class/mtd/mtd*/offset # Linux 4.1 and newer, see note 2.
  ifconfig -a
  ls /sys/class/net
  brctl show
  cat /sys/kernel/debug/gpio     # GPIO information

注意1:通过dmesg检索时,如果日志的缓存区太小,就会丢失掉最早的信息。如果从供应商发布的资源中构建库存及镜像文件,则可以在内核配置中设置更大的缓冲区大小。

注意2:http://lxr.free-electrons.com/source/Documentation/ABI/testing/sysfs-class-mtd

获取设置LED信息的另一个有用的工具是gpiodump,它是MT7620 GPIOMODE寄存器转储器(RAMIPS)。

从设备获取数据

由于空间有限,常见的文件传输实用程序(例如rsync/curl/ssh/scp/ftp/http/tftp)可能不可用,精简版version/applet可能在busybox中可用。

假设路由器ip为192.168.0.123,要传输的文件位于/tmp/important-data.txt

HTTP通过”httpd”和”busybox mount”

如果从/www提供Web界面

Sender
mount -o bind /tmp /www
Receiver
wget http://192.168.0.123/important-data.txt

FTP通过“busybox ftpput”

Receiver

设置一个FTP服务器,添加一个具有写权限的匿名账号。

python -m pyftpdlib -w -p 21
Sender
busybox ftpput 192.168.0.123 important-data.txt /tmp/important-data.txt 

netcat通过“buxybox nc”

Receiver
busybox nc -l -p 12345 > important-data.txt 
Sender
cat /tmp/important-data.txt | busybox nc 192.168.0.123:12345 

TFTP通过“busybox tftp”

Receiver

建立一个tftp服务器

Sender
busybox tftp -p -l /tmp/important-data.txt -r important-data.txt 192.168.0.123

通过终端(terminal)复制

如果上述所有工具/小工具都不可用,则可以从telnet终端进行复制,但不适用于二进制文件

发表在 计算机技术 | 留下评论

OpenWrt使用​SDK开发工具包

SDK是预编译工具链设计的交叉编译软件包为特定目标而无需从头编译整个系统.

您可以使用SDK完成的任务:

  • 为特定版本编译自定义软件及同时确保二进制和功能兼容性
  • 为特定版本编译某些软件包的较新版本
  • 使用自定义补丁或不同功能重新编译现有软件包

您无法使用SDK完成的任务:

  • 将其用作交叉编译工具链的插件以编译整个固件.

先决条件

SDK 与 buildroot 系统具有相同的先决条件, 因此请参阅 Build system – Installation 页面以安装所需的软件以在SDK上构建软件包.

  • 在没有 sudo 的情况下, 以非特权用户(而不是 root)的身份执行所有操作.
  • 确保构建目录的完整路径中没有空格.

获取SDK

您可以下载预编译号的 SDK 或可以从源代码中自行编译. 从源代码编译只需启用 menuconfig 选项 Build the OpenWrt SDK (CONFIG_SDK). 预编译的 SDK 位于您找到设备固件映像的同一下载文件夹中.

下载

  • development snapshot SDK → Platforms → Supplementary Files → openwrt-sdk-<Platform>_gcc-<version>_musl.Linux-x86_64.tar.xz
  • 21.02.3 → Platforms → Supplementary Files → openwrt-sdk-<Platform>_gcc-<version>_musl.Linux-x86_64.tar.xz
  • 19.07.10 → Platforms → Supplementary Files → openwrt-sdk-<Platform>_gcc-<version>_musl.Linux-x86_64.tar.xz

软件 feeds

解压 SDK 存档后, 可选择编辑该 feeds.conf.default 文件以添加您的软件 feeds. 默认情况下, 这将包含构建 SDK 时使用的feeds. 您可以添加自己的本地或远程feed, 就像使用 buildroot 一样. 如果您只是重新构建额外的软件, 则根本不需要这样做.

NOTE: 如果要覆盖来自现有feeds的软件, 则必须在包含要覆盖软件feed的行上方编写自定义feed.
例如, 你想制作一个已经在 Packages feed 中发行软件的自定义版本, 这就是你的 feeds.conf.default 的模板 (第一行是你自己的自定义软件 feed)

src-link local /path/to/local/custom/feed
src-git packages https://git.openwrt.org/feed/packages.git
src-git luci https://git.openwrt.org/project/luci.git
src-git routing https://git.openwrt.org/feed/routing.git
src-git telephony https://git.openwrt.org/feed/telephony.git
#src-git video https://github.com/openwrt/video.git
#src-git targets https://github.com/openwrt/targets.git
#src-git oldpackages http://git.openwrt.org/packages.git
#src-link custom /usr/src/openwrt/custom-feed

加载软件列表

  • 使用 ./scripts/feeds update -a 命令获取和更新定义软件.
  • 更新定义后, ./scripts/feeds install <packagename> 准备软件及其依赖项.

./scripts/feeds install -a 将再次使所有软件可用, 就像在 buildroot 一样.

用法

选择 packages

在 SDK 的文件夹中打开一个终端, 然后通过运行命令 make menuconfig 打开 SDK 的菜单. SDK menuconfig 系统与 buildroot 相同. 帮助说明位于顶部, 可通过 ? 按键获得帮助.

您 很可能 想要禁用一些默认设置, 这些设置会构建每个可用的软件. 进入 Global Build Settings 并在子菜单中, 取消选择/排除以下选项:

  • Select all target specific packages by default
  • Select all kernel module packages by default
  • Select all userspace packages by default

仍然在菜单中, 找到要构建的软件并按 “m” 选择它, 这也会选择所有依赖项, 您将在菜单中看到它们都带有 “<M>” 标记. 您也可以选择多个包.

保存配置并退出菜单.

编译软件

在Makefile就位之后,可以使用常规的构建命令,例如:

  • make package/example/download – 下载源代码的命令是 download
  • make package/example/prepare – 提取源代码、应用补丁并在必要时下载的命令
  • make package/example/compile – 编译example、准备并在必要时下载的命令
  • make package/example/clean – 清理源代码的命令
  • make package/index – 构建存储库索引以使输出目录可用作本地的opkg源的命令

或者,只需运行make来构建所选的所有内容。 您可以通过编写适合您的构建主机的make -j5或类似的命令来加快编译速度。

编译完成后,生成的.ipk文件将放置在您提取SDK的目录中的bin/packages和bin/targets目录中。

发表在 计算机技术 | 留下评论

NanoPi R4S使用sdk编译OpenWrt软件包

1. 安装编译环境

在64位的Ubuntu (版本18.04+)下载并运行如下脚本: How to setup the Compiling Environment on Ubuntu bionic

2 .在网盘上下载并解压sdk

sdk位于网盘的toolchain目录,解压后,需要先下载feeds软件包:

tar xvf openwrt-sdk-*-rockchip-armv8_gcc-11.2.0_musl.Linux-x86_64.tar.xz
# 路径太长会导致有些包编译出错,所以这里改一下目录名
mv openwrt-sdk-*-rockchip-armv8_gcc-11.2.0_musl.Linux-x86_64 sdk
cd sdk
./scripts/feeds update -a
./scripts/feeds install -a

3 .将软件包编译并打包成ipk文件

此处以mwarning的示例作为演示,下载例子的源代码(共3个分别为example1, example2, example3),并拷到package目录:

git clone https://github.com/mwarning/openwrt-examples.git
cp -rf openwrt-examples/example* package/
rm -rf openwrt-examples/

再通过以下命令进入配置菜单:

make menuconfig

在菜单中选中以下我们要编译的软件包(默认实际上已经选中):

"Utilities" => "example1"
"Utilities" => "example3"
"Network" => "VPN" => "example2"

退出配置菜单的界面,在提示是否保存设置时需要选择Yes,然后执下以下命令,分别编译这三个软件包:

make package/example1/compile V=99
make package/example2/compile V=99
make package/example3/compile V=99

编译成功后,可以在bin目录下找到ipk文件,如下所示:

$ find ./bin -name example*.ipk
./bin/packages/aarch64_generic/base/example3_1.0.0-220420.38257_aarch64_generic.ipk
./bin/packages/aarch64_generic/base/example1_1.0.0-220420.38257_aarch64_generic.ipk
./bin/packages/aarch64_generic/base/example2_1.0.0-220420.38257_aarch64_generic.ipk

4 .将编译生成的ipk安装到NanoPi上

可以用scp命令将ipk文件上传到NanoPi上:

cd ./bin/packages/aarch64_generic/base/
scp example*.ipk root@192.168.2.1:/root/

然后用opkg命令进行安装他们:

cd /root/
opkg install example3_1.0.0-220420.38257_aarch64_generic.ipk
opkg install example1_1.0.0-220420.38257_aarch64_generic.ipk
opkg install example2_1.0.0-220420.38257_aarch64_generic.ipk
发表在 计算机技术 | 留下评论

NanoPi R4S资源特性

  • SoC: Rockchip RK3399
    • CPU: big.LITTLE,Dual-Core Cortex-A72(up to 2.0GHz) + Quad-Core Cortex-A53(up to 1.5GHz)
    • GPU: Mali-T864 GPU,supports OpenGL ES1.1/2.0/3.0/3.1, OpenCL, DX11, and AFBC
    • VPU: 4K VP9 and 4K 10bits H265/H264 60fps decoding, Dual VOP, etc
  • PMU: RK808-D PMIC, cooperated with independent DC/DC, enabling DVFS, software power-down, RTC wake-up, system sleep mode
  • RAM: 1GB DDR3/4GB LPDDR4
  • Flash: no Onboard eMMC
  • Ethernet: one Native Gigabit Ethernet, and one PCIe Gigabit Ethernet
  • USB: two USB 3.0 Type-A ports
  • Pin header extension interface
    • 2×5-pin header: SPI x 1, I2C x 1
    • 4-pin header: USB 2.0
  • microSD Slot x 1
  • Debug: one Debug UART, 3 Pin 2.54mm header, 3V level, 1500000bps
  • LEDs: 1 x power LED and 3 x GPIO Controlled LED (SYS, LAN, WAN)
  • others:
    • 2 Pin 1.27/1.25mm RTC battery input connector
    • one User Button
    • one 5V Fan connector
  • Power supply: DC 5V/3A, via USB-C connector or Pin header
  • PCB: 8 Layer, 66 mm x 66 mm
  • Temperature measuring range: 0℃ to 80℃
发表在 计算机技术 | 留下评论

冬日记忆:从北国风雪到江南暖阳

北方:被雪花吻过的童话世界

清晨推开门时,那种咔嚓作响的雪声是北方冬天特有的交响乐。整个世界被覆上厚厚的棉絮,屋檐下垂着晶莹的冰棱,在阳光下折射出七彩光芒。记得儿时总爱在结霜的玻璃上画笑脸,看呼出的白气在空中打着旋儿消散。胡同里的糖葫芦摊亮起昏黄的灯泡,山楂裹着晶莹的冰糖,咬下去时“嘎嘣”一声,酸甜滋味瞬间驱散所有寒意。

南方:氤氲水汽中的温柔时节

南方的冬天藏在潮湿的空气里。晨起时窗玻璃上凝结着细密水珠,用手指划过会留下蜿蜒的轨迹。老人们在公园里边晒太阳边下象棋,竹椅旁放着冒热气的紫砂壶。最爱傍晚时分拐进巷口的面馆,老板舀起一勺奶白色的高汤,撒上翠绿葱花,捧着碗暖手时,觉得整颗心都被妥帖地安放了。

冬日仪式感:治愈每个寒冷时刻

无论南北,有些冬日仪式始终相通:

  • 藏书之乐:在落地窗边铺好地毯,把 postponed 的书单逐本翻阅
  • 暖饮之趣:手磨咖啡豆的香气与炉上咕嘟冒泡的奶茶各有拥趸
  • 夜话之暖:围坐火锅旁看红汤翻滚,氤氲水汽模糊了彼此的笑脸

写给冬天的情书

这个季节教会我们放缓脚步——看初雪如何温柔覆盖城市棱角,体会阳光如何珍贵地穿透云层。那些冬日里相互依偎的温暖,暖饮入喉的妥帖,窗前看雪的静谧,都成为岁月里发着光的珍珠。或许冬天真正的礼物,是让我们在万象俱寂时,听见内心最真实的声音。

发表在 生活 | 一条评论