悠瞅博客,VPS评测、VPS推荐、VPS促销信息、VPS技术脚本...

FriendlyARM R1S-H3 开发笔记02(定制开发)

OpenWRT cr_3 1958℃ 0评论

friendlywrt定制与开发

源代码目录结构

├── friendlywrt
│   ├── friendlywrt -> friendlywrt源代码
|   └── configs -> 保存预设好的friendlywrt defconfig文件
|   └── toolchain -> 交叉编译器,仅用于编译u-boot与kernel
│   ├── [build.sh](<http://build.sh/>) -> 全自动编译脚本
│   ├── device/friendlyelec -> 用于适配友善电子开发板的相关文件
│   ├── kernel -> 内核
│   └── u-boot -> u-boot
│   └── scripts -> 打包img的相关脚本

配置friendlywrt的软件包

使用make menuconfig更改配置 (以h3为例)

cd friendlywrt-h3/friendlywrt
make menuconfig

另存你个人的软件包配置

make menuconfig
./scripts/diffconfig.sh> ../configs/my_config

以NanoPi-R1为例,编辑以下文件:

device/friendlyelec/h3/nanopi_r1.mk

将TARGET_FRIENDLYWRT_CONFIG的值改为你的配置。

重新编译friendlywrt并制成sd启动镜像

./build.sh friendlywrt
./build.sh sd-img

固化个人文件到friendlywrt

以H3平台为例, 将文件或目录放入以下目录即可,打包img时会把它们都打包进去:

device/friendlyelec/h3/common-files

也可以放在新建的目录里,以NanoPi-R1为例,然后编辑以下文件:

device/friendlyelec/h3/nanopi_r1.mk

在文件中新增一行 (XXX替换为你的目录名):

FRIENDLYWRT_FILES+=(device/friendlyelec/h3/XXX)

修改friendlywrt系统的默认配置(如网络、防火墙等)

编辑如下目录中的文件:

device/friendlyelec/h3/default-settings/files
friendlywrt/package/base-files/files

定制其他插件

插件库如下:

<https://github.com/kenzok8/openwrt-packages>
<https://github.com/liuran001/openwrt-packages>

这里以kenzok8的插件库为例,在feeds.conf.default文件中增加以下内容:

src-git small <https://github.com/kenzok8/small>
src-git kenzo <https://github.com/kenzok8/openwrt-packages>

执行以下指令,选择合适的插件:

./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig

插件说明如下:

openwrt 固件编译自定义主题与软件
luci-app-vssr ------------------vssr老竭力
luci-app-dnsfilter ------------------基于DNS的广告过滤
luci-app-openclash ------------------openclash图形
luci-app-advancedsetting ------------------系统高级设置
luci-app-serverchan ------------------Server酱 微信/Telegram 推送的插件
luci-theme-ifit ------------------透明主题(适配18.06修复主机名错误)
luci-theme-atmaterial_new ------------------atmaterial 三合一主题(适配18.06)
luci-app-aliddns ------------------阿里云ddns
luci-app-eqos ------------------依IP地址限速
luci-app-gost ------------------隐蔽的https代理
luci-app-adguardhome ------------------去广告
luci-app-smartdns ------------------smartdns防污染
luci-app-passwall ------------------Lienol大神
luci-theme-argon_new ------------------二合蓝 紫主题
luci-app-ssr-plus ------------------Lean大神
luci-theme-opentomcat ------------------修复主机名错误(适配18.06)
luci-theme-opentomato ------------------修复主机名错误(适配18.06)

之后正常编译kernel:

make -j8 download V=s
make -j1 V=s

生成SD-image,并烧录,这里的SD为sdb:

./build.sh sd-img
sudo dd if=out/FriendlyWrt_20210823_NanoPi-R1_armhf_sd.img bs=1M of=/dev/sdb

更改u-boot和kernel配置 (以H3为例)

同样是编辑如下文件:

device/friendlyelec/h3/nanopi_r1.mk

可通过以下设置,将uboot的配置改为你自已的:

TARGET_UBOOT_CONFIG=nanopi_h3_defconfig

可通过以下设置,将kernel的配置改为你自已的:

TARGET_KERNEL_CONFIG=sunxi_defconfig

更换其他源代码

编辑如下 xml 文件,即可替换 kernel 、uboot以及friendlywrt的源代码:

.repo/manifests/h3.xml

想了解 xml 文件各个节点的含义和用法,请参考:repo Manifest Format

编辑完成后,需要用 repo 命令同步一下,比如更换了 kernel 的源代码,用以下命令同步一次:

repo sync --force-sync kernel

同步后单独重新内核即可:

./build.sh kernel

FriendlyWrt:使用技巧

访问FriendlyWrt管理页面

在电脑浏览器上输入 http://friendlywrt/ 或者IP地址即可进入FriendlyWrt管理页面,默认情况下,LAN口的IP地址为192.168.2.1,WAN会从你的主路由器动态获取IP地址。

挂载其他设备的网络共享目录

mount -t cifs [//192.168.1.10/shared](<https://192.168.1.10/shared>) /movie -o username=xxx,password=yyy,file_mode=0644

常见问题及注意事项

  • Ubuntu下不能使用 root 用户来编译,需要使用普通用户
  • 在 vnc 环境下编译可能会编译失败

转载请注明:悠瞅の博客 » FriendlyARM R1S-H3 开发笔记02(定制开发)

喜欢 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址