Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
Merge branch 'z9s_luci' into x9s
Browse files Browse the repository at this point in the history
* z9s_luci:
  disable some services.
  update porting note.
  update doc.
  use https opkg feed.
  Update porting.md
  • Loading branch information
jjm2473 committed Apr 11, 2019
2 parents d0cbc15 + 4a6b98a commit 21ff305
Show file tree
Hide file tree
Showing 53 changed files with 634 additions and 27 deletions.
32 changes: 27 additions & 5 deletions docs/porting.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
### 适配记录
## 移植笔记
### 1. 系统init流程
系统启动时挂载的根目录是mmcblk0p9, 对应镜像squashfs1.img, 内核启动的第一个进程是/etc/init, 这个init大概流程是(只讨论双系统启动):
1. ```fork```一个进程, 子进程使用新的PID命名空间```exec /etc/preinit```(OpenWrt的初始化进程)
2. 挂载tmpfs到```/android```, 再把/mnt/android复制到/android
3. 切换工作目录到```/android```
4. 等待```.coldplug_done```文件出现 (这个文件实际是由OpenWrt的procd写入的, 表示驱动加载完了), 最多等待10秒
5. 改变根目录到当前目录, 使用新的文件系统命名空间```exec /init```(Android的初始化进程)

可以发现, 在Android里面可以看到OpenWrt的进程, 反过来就不行,
OpenWrt里面的/rom/android目录实际就是Android的根目录, 挂载为可写以后, 写入的文件在Android里也能看到.

代码在 https://github.com/jjm2473/rtd1295-toolchain/tree/master/src/openwrt_android/init ,
实际上X9S的/etc/init是一段shell脚本, 功能完全一样.

### 2. Android中控制OpenWrt的服务
实现方式是用UBus, 但UBus的监听地址跟原版OpenWrt不一样, 原版的是普通命名方式(/var/run/ubus.sock), 而此双系统为了跨根目录提供服务, 使用了抽象命名方式(@/var/run/ubus.sock)

UBus的监听地址跟官方Openwrt不一样, 官方的是普通命名方式(/var/run/ubus.sock), 而此双系统为了跨根目录提供服务, 使用了抽象命名方式(@/var/run/ubus.sock)
参考 https://blog.csdn.net/q1007729991/article/details/71175679
----------
...
#### 2. 抽象 unix 域套接字地址
使用这种套接字地址,它并不会在文件系统中产生真正的套接字文件,而是由内核帮我们维护一个抽象套接字文件,它总是以 '@'开头,比如 @dog。所以,它的好处自然很明显,不用产生实际文件了。
Expand Down Expand Up @@ -35,7 +51,13 @@ UBus的监听地址跟官方Openwrt不一样, 官方的是普通命名方式(/va
addr.sun_path[0] = 0; // 设置成抽象 unix 域套接字地址
```
...
----------

由于Zidoo的bug, 计算len使用的是``` len = sizeof(addr) ```, 所以为了兼容Zidoo也应该用 sizeof,

实现了一个代理来兼容Zidoo的Android系统, 代码在 https://github.com/jjm2473/rtd1295-toolchain/tree/master/src/openwrt_android/xubus

NFSD 不能导出 /mnt, 可以导出其中的挂载点
VSFTPD 可以导出 /mnt, 不能导出其中的挂载点, 但可以访问
SAMBA4 可以导出 /mnt, 也能导出其中的挂载点, 但是客户端挂载 /mnt 访问不了其中的挂载点
## 网络共享的限制
* NFSD 不能导出 /mnt, 可以导出其中的挂载点
* VSFTPD 可以导出 /mnt, 不能导出其中的挂载点, 但客户端可以访问
* SAMBA4 可以导出 /mnt, 也能导出其中的挂载点, 但是客户端挂载 /mnt 访问不了其中的挂载点
2 changes: 1 addition & 1 deletion overlay_pack.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# use opkg offline mode `opkg -o / -f /etc/opkg.conf install ??` to install, then
# run this on device /overlay/upper/ to package
find etc/init.d/ -type f|xargs -n1 sh -c '/$0 enable'
find -type f -o -type l|grep -v ./mnt|grep -v dropbear_rsa_host_key|grep -v urandom.seed|grep -v board.json|xargs tar -czf /tmp/update.tar.gz
find -type f -o -type l|grep -v ./mnt|grep -v ./root/|grep -v dropbear_rsa_host_key|grep -v urandom.seed|grep -v board.json|grep -v ./etc/config/|grep -v ./etc/samba/|xargs tar -czf /tmp/update.tar.gz
16 changes: 13 additions & 3 deletions root/etc/init.d/afpd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ config_instance()
sed -i "/^hostname =/c\hostname = $hostname" $CONF_FILE
}

start_service() {
gen_config()
{
local enabled
config_load afpd

Expand All @@ -30,6 +31,13 @@ start_service() {

config_foreach config_instance netatalk

return 0
}

start_service() {

gen_config || return 1

mkdir -p /var/netatalk/CNID/files

procd_open_instance
Expand All @@ -45,7 +53,9 @@ start_service() {
}

service_triggers() {
PROCD_RELOAD_DELAY=2000

procd_add_reload_trigger "afpd"
}

reload_service() {
gen_config || stop
}
4 changes: 1 addition & 3 deletions root/etc/init.d/transmission
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ transmission() {
}

service_triggers() {
PROCD_RELOAD_DELAY=2000

procd_add_reload_trigger "transmission"
}

Expand All @@ -157,4 +155,4 @@ reload_service() {
stop
sleep 2
start
}
}
10 changes: 5 additions & 5 deletions root/etc/opkg/distfeeds.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
src/gz openwrt_core http://mirror.0x.sg/openwrt/snapshots/targets/sunxi/cortexa53/packages
src/gz openwrt_base http://mirror.0x.sg/openwrt/snapshots/packages/aarch64_cortex-a53/base
src/gz openwrt_luci http://mirror.0x.sg/openwrt/snapshots/packages/aarch64_cortex-a53/luci
src/gz openwrt_packages http://mirror.0x.sg/openwrt/snapshots/packages/aarch64_cortex-a53/packages
src/gz openwrt_routing http://mirror.0x.sg/openwrt/snapshots/packages/aarch64_cortex-a53/routing
src/gz openwrt_core https://mirror.0x.sg/openwrt/snapshots/targets/sunxi/cortexa53/packages
src/gz openwrt_base https://mirror.0x.sg/openwrt/snapshots/packages/aarch64_cortex-a53/base
src/gz openwrt_luci https://mirror.0x.sg/openwrt/snapshots/packages/aarch64_cortex-a53/luci
src/gz openwrt_packages https://mirror.0x.sg/openwrt/snapshots/packages/aarch64_cortex-a53/packages
src/gz openwrt_routing https://mirror.0x.sg/openwrt/snapshots/packages/aarch64_cortex-a53/routing
1 change: 0 additions & 1 deletion root/etc/rc.d/K85odhcpd

This file was deleted.

1 change: 0 additions & 1 deletion root/etc/rc.d/S19firewall

This file was deleted.

1 change: 0 additions & 1 deletion root/etc/rc.d/S35odhcpd

This file was deleted.

Loading

0 comments on commit 21ff305

Please sign in to comment.