WLS2Linux 子系统(二)
WLS2Linux 子系統(tǒng)編譯 Openwrt
上一篇文章中講解 windows 安裝 WSL2Linux 子系統(tǒng)的簡單安裝過程。如今有了 WSL 子系統(tǒng)可以完成很多以前不能完成的事,例如編譯源代碼、轉(zhuǎn)換音視頻、轉(zhuǎn)換文檔格式(pdf 轉(zhuǎn) word,word 轉(zhuǎn) md,word 轉(zhuǎn) html),定制私有 OpenWRT 路由器等。說到這個系統(tǒng)比較陌生,提到路由器生活中處處可見,二者聯(lián)系—路由器基于openwrt 開發(fā)。
此篇文章詳解 如何從源碼編譯 OpenWRT 文件系統(tǒng)。
提示:WSL2Linux 編譯 Openwrt,下一篇 WSL2Linux 編譯 uboot。
文章目錄
- WLS2Linux 子系統(tǒng)編譯 Openwrt
- 1. 編譯OpenWRT 準(zhǔn)備
- wsl2 install library
- 獲取 openwrt 源碼
- 2. 開啟 OpenWRT 編譯踩坑
- a) 配置編譯選項
- b) 編譯固件
- c) 刷機(jī)
- 總結(jié)
1. 編譯OpenWRT 準(zhǔn)備
wsl2 install library
sudo apt update sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev unzip python -y獲取 openwrt 源碼
獲取代碼盡量在 WSL 根目錄下, 否則被win10訪問權(quán)限被篡改
# openwrt source # https://git.openwrt.org/openwrt/openwrt.git # https://github.com/openwrt/openwrt.git git clone https://git.openwrt.org/openwrt/openwrt.git # 因網(wǎng)絡(luò)異常導(dǎo)致下載失敗,重新下載即可 git checkout -t origin/openwrt-21.02 # git end of EOF2. 開啟 OpenWRT 編譯踩坑
a) 配置編譯選項
cd ~/openwrt ./scripts/feeds update -a #更新組件 ./scripts/feeds install -a #安裝組件 make menuconfig -j1 V=99看到編譯配置界面,根據(jù)自己設(shè)備型號配置相關(guān)屬性。
以樹梅派4B 為例子構(gòu)建 openwrt
文件夾 files/etc/config 創(chuàng)建 network 與 wireless 網(wǎng)卡配置文件。
# network config config wifi-device 'radio0'option type 'mac80211'option channel '36'option hwmode '11a'option path 'platform/soc/fe300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:00 01:1'option htmode 'VHT40'config wifi-iface 'default_radio0'option device 'radio0'option mode 'ap'option encryption 'none'option ssid 'RPI4'option network 'lan' # wireless config config wifi-device 'radio0'option type 'mac80211'option channel '36'option hwmode '11a'option path 'platform/soc/fe300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:00 01:1'option htmode 'VHT40'config wifi-iface 'default_radio0'option device 'radio0'option mode 'ap'option encryption 'none'option ssid 'RPI4'option network 'lan'b) 編譯固件
開機(jī)相關(guān)代碼包下載
make download -j4 V=s火力全開編譯
make -j12 V=99編譯完成生成固件幾種固件
ls bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4* bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-ext4-sysupgrade.img.gz bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-squashfs-factory.img.gz bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade.img.gz#切換系統(tǒng)環(huán)境變量 再執(zhí)行編譯命令
source /etc/environment編譯過程出錯誤
- 使用 root 權(quán)限編譯錯誤提示
方法一:強(qiáng)制在不安全模式下編譯
make FORCE_UNSAFE_CONFIGURE=1 -j1 V=s方法二: 保存剛在配置文件,改用普通用戶重新下載代碼 初始化剛剛的配置文件繼續(xù)編譯
- libsoncpp-dev missing
fatal error: json/json.h: No such file or directory
安裝 相關(guān)庫既可以解決
sudo apt-get install libjsoncpp-dev sudo ln -s /usr/include/jsoncpp/json/ /usr/include/json如需重新編譯可選擇如下幾種方式:
make clean -j4 #清除 bin
make dirclean -j4 #清除 toolchain bin
make distclean -4 #清除 config feed package 等文件
c) 刷機(jī)
編譯完成 生成固件路徑
ls `~/openwrt/bin/targets/bcm27xx/bcm2711/` bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-ext4-sysupgrade.img.gz bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-squashfs-factory.img.gz bin/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade.img.gz選 ext4 格式鏡像文件,制作成 sd 卡啟動;上TF卡開機(jī)測試
login IP: 192.168.1.1
login user: root
login passwd: password
Tips:
想單獨(dú)編譯某個插件,然后手動安裝;編譯后生成文件路徑
總結(jié)
人生貴在生生不息,今天分享折騰路由器方法你 get 到?jīng)]!
總結(jié)
以上是生活随笔為你收集整理的WLS2Linux 子系统(二)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: causalml安装记录
- 下一篇: 华为固件解包工具linux,华为app固