OpenWrt-從門口到入門

***以下操作不要使用root用戶***

1.下載源碼並更新。(注意:不要用root用戶下載)

#git clone https://github.com/openwrt/openwrt.git
#git pull

2.Updating Feeds

(1) update

#./scripts/feeds update -a

(2) install

單個安裝

#./scripts/feeds install <PACKAGENAME>

全部安裝(默認全部安裝)

#./scripts/feeds install -a

3.下載所有依賴原文件(需要耐心等待)

首先,進入make menuconfig配置硬件平臺


配置好後,開始編譯,先用make download下載配置所需庫,再make V=s編譯。這兩步時間較長,請耐心等待……

#make download 
#make V=s

 

#1編譯錯誤:

#make[2]: *** [tools/pkg-config/compile] Error 2

處理方式

#cd /build_dir/host/pkg-config-0.29.2/glib

#./configure --disable-option-checking --prefix=/opt/openwrt/openwrt/staging_dir/host CC=gcc CFLAGS='-O2 -I/opt/openwrt/opeing_dir/host/usr/include' CPPFLAGS='-I/opt/openwrt/openwrt/staging_dir/host/include -I/opt/openwrt/openwrt/staging_dir/host/usr/include' LDFLAGS='-L/opt/openwrt/openwrt/staging_dir/host/usr/lib' --enable-iconv=no --with-libiconv=gnu --with-internal-glib

#make

這一步編譯生成的系統BIN只有3.5M左右

 

#2運行問題:

燒錄運行後出現:

bootconsole [early0] disabled

根據menuconfig中target profile選項去target/linux/ramips/dts/xxx.dts修改bootargs參數。

vi target/linux/ramips/dts/LINKIT7688.dts

我這裏是使用ttyS0,波特率設置爲57600。(這裏根據硬件不同有所不同)

 

#3 Luci安裝

進入menuconfig界面後,選擇luci/ Collections/luci爲[*]後,開始編譯

make V=s

編譯後生成的BIN文件大約增加0.5M。

安裝中文包

修改源碼文件默認爲中文:feeds/luci/modules/luci-base/root/etc/config/luci

config core main

    option resourcebase '/luci-static/resources'

    #設置默認語言

    option lang 'zh_cn'

    #設置默認主題

    option mediaurlbase '/luci-static/bootstrap'

#設置可選擇的語言       

config internal languages

    option zh_cn 'chinese'

    option en 'English'#設置可選擇的主題

config internal themes

    option Bootstrap '/luci-static/bootstrap'

 

修改默認IP:

vi package/base-files/files/bin/config_generate

 

默認打開wifi,並修改SSID爲YLFM-OpenWrt

vi package/kernel/mac80211/files/lib/wifi/mac80211.sh

 

#4 配置參考

開發指南 https://blog.csdn.net/u013162035/article/details/78872218

https://www.jianshu.com/p/66c7b0969a31

 

#5 設置root密碼

先連接平臺,使用passwd命令設置密碼;再使用cat /etc/shadow命令查看密碼。

將紅色框複製到 package/base-files/files/etc/shadow文件中。然後編譯重新燒錄。

 

#6 修改hostname

修改源碼:package/base-files/files/bin/config_generate

如下圖設置了hostname和時區(CST-8)

 

#修改啓動信息

$cat package/base-files/files/etc/banner

字符可在http://www.network-science.de/ascii/ 網站生成,openwrt 風格爲 rectangles ;  

_______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
-----------------------------------------------------
OpenWrt SNAPSHOT, r10075-ace2410
-----------------------------------------------------

 

#7 USB熱插拔自動掛載

https://blog.csdn.net/u011641885/article/details/46530327

添加USB支持

Kernel modules —> USB Support —> <*> kmod-usb-core.  ##默認已經選了
Kernel modules —> USB Support —> <*> kmod-usb-ohci.  ##默認已選 old usb1.0
Kernel modules —> USB Support —> <*> kmod-usb-uhci.  ## usb1.1
Kernel modules —> USB Support —> <*> kmod-usb-storage.
Kernel modules —> USB Support —> <*> kmod-usb-storage-extras.
Kernel modules —> USB Support —> <*> kmod-usb2.  ##默認已經選了 usb2.0
Kernel modules —> USB Support —> <*> kmod-usb3.  

添加SCSI支持

Kernel modules —> Block Devices —> <*>kmod-scsi-core  ##默認已經選了 usb3.0

添加USB掛載

Base system —> <*>block-mount  ##添加USB掛載
Utilities —> Filesystem —> <*> badblocks  ##添加自動掛載工具

添加文件系統

Kernel modules —> Filesystems —> <*> kmod-fs-ext4 (移動硬盤EXT4格式選擇)
Kernel modules —> Filesystems —> <*> kmod-fs-vfat(FAT16 / FAT32 格式 選擇)
Kernel modules —> Filesystems —> <*> kmod-fs-ntfs (NTFS 格式 選擇)

添加編碼

Kernel modules —> Native Language Support —> <*> kmod-nls-utf8
Utilities  ---> disc ---> <*> fdisk.................................... manipulate disk partition table
Utilities  ---> <*> usbutils................................... USB devices listing utilities

編譯 make

修改 /etc/config/fstab

option 'enabled'  '1'

自動掛載U盤:編輯系統文件 /etc/hotplug.d/block/10-mount 寫入以下內容

(源碼中如何修改暫沒找到方法)

#!/bin/ash

case "$ACTION" in
    add)
        for i in $(ls /dev/ | grep 'sd[a-z][1-9]')
        do
            mkdir -p /mnt/$i
            mount -o iocharset=utf8,rw /dev/$i /mnt/$i
            if [ $? -ne 0 ]
            then
                mount -o rw /dev/$i /mnt/$i
            fi
        done
        ;;
    remove)
        MOUNT=`mount | grep -o '/mnt/sd[a-z][1-9]'`
        for i in $MOUNT
        do
            umount $i
            if [ $? -eq 0 ]
            then
                rm -r $i
            fi
        done
        ;;
esac

 

#添加多用戶,並分配不同的權限

https://blog.csdn.net/xingyuzhe/article/details/47299825

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章