Aug 18

FORCE_UNSAFE_CONFIGURE=1 make toolchain

直接上脚本:(https://gist.github.com/rampageX/28ca79a9812fe684650be9ac18df84fe)

安装,替换默认设置:

apt-get install -y distcc distcc-pump ccache
sed -ie 's/STARTDISTCC="false"/STARTDISTCC="true"/' /etc/default/distcc
sed -ie 's/ALLOWEDNETS="127.0.0.1"/ALLOWEDNETS="192.168.0.0\/16 172.16.0.0\/12 10.0.0.0\/8"/' /etc/default/distcc
sed -ie 's/LISTENER="127.0.0.1"/LISTENER="0.0.0.0"/' /etc/default/distcc
sed -ie "s/JOBS=\"\"/JOBS=\"`grep processor /proc/cpuinfo | wc -l`\"/" /etc/default/distcc
sed -ie 's/ZEROCONF="false"/ZEROCONF="true"/' /etc/default/distcc

添加 Tomatoware 编译工具路径:
#PATH here? https://midnightyell.wordpress.com/2012/10/14/a-good-compromise-cross-compiling-with-distcc/
echo "PATH=/opt/tomatoware/arm-soft-mmc/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> /etc/default/distcc

#for tomatoware, arm-linux-gcc etc. must in service path, or error code 110 on Router.
sed -ie 's~/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin~/opt/tomatoware/arm-soft-mmc/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin~' /etc/init.d/distcc

service distcc restart

添加 ccache 支持,可选:
echo 'CCACHE_PREFIX="distcc"' > /etc/profile.d/ccache-distcc.sh
echo 'CC="ccache gcc"' >> /etc/profile.d/ccache-distcc.sh

distcc 3.3 如果编译了白名单支持,还需要添加编译工具到白名单:
#add arm-linux-gcc/g++ to whitelist of distcc (error: CRITICAL! arm-linux-gcc not in /usr/lib/distcc whitelist.)
cd /usr/lib/distcc
sudo ln -s ../../bin/distcc ./arm-linux-gcc
sudo ln -s ../../bin/distcc ./arm-linux-g++

其他参考:
#Tomatoware REF: https://github.com/lancethepants/tomatoware/wiki/Using-distcc

#apt-get install Error and Fix: https://github.com/distcc/distcc/issues/311
#`Traceback (most recent call last): File "/usr/bin/update-distcc-symlinks", line 39, in for gnu_host in os.listdir(gcccross_dir): FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/gcc-cross'`

#Fixed by disable following code:
#`for gnu_host in os.listdir(gcccross_dir): consider_gcc("%(gnu_host)s-" % vars(), "") for version in os.listdir(gcccross_dir + "/" + gnu_host): consider_gcc("", "-%(version)s" % vars()) consider_gcc("%(gnu_host)s-" % vars(), "-%(version)s" % vars())`

调试命令:
PATH=/opt/tomatoware/arm-soft-mmc/usr/bin/:/opt/tomatoware/mipsel-soft-mmc/usr/bin/:$PATH distccd --verbose --no-detach --daemon --allow 192.168.2.0/16 --log-level debug --log-file /tmp/distccd.log


Aug 18

软件源配置文件是 /etc/apt/sources.list。将系统自带的该文件做个备份,将该文件替换为下面内容,即可使用 TUNA 的软件源镜像。

如果遇到无法拉取 https 源的情况,请先使用 http 源并安装:
$ sudo apt install apt-transport-https

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free

清华大学开源软件镜像站
镜像使用帮助


Mar 30

NFS 比 SAMBA 稳定,速度也快,所以决定用 NFS 取代 PHICOMM N1上的 SAMBA 共享。

一. 服务端,N1 运行 Ubuntu 18.04 版本,IP 为 192.168.2.20。

1. 首先停用 SAMBA。

sudo systemctl stop smbd
sudo systemctl disable smbd

2. 安装 NFS 服务组件:

sudo apt-get install nfs-kernel-server

3. 配置 NFS:

sudo nano /etc/exports

添加需要共享的目录,例如:

#共享目录 #允许的客户端网段(挂载选项)
/sync 192.168.2.0/24(rw,sync,no_subtree_check)

如果要为 Android 系统(例如电视盒子等)或者 OSX 等提供服务,需要加 insecure 参数:

#共享目录 #允许的客户端网段(挂载选项)
/sync 192.168.2.0/24(rw,async,insecure,no_subtree_check)

4. 重启 NFS 服务即可:

sudo systemctl restart nfs-server

二. 客户端,Windows 10,需要企业版。

1. 首先启用 NFS 客户端:控制面板\程序\程序和功能 - 启用或关闭 Windows 功能,选中 NFS 服务 下的 NFS 客户端

2. 此时进入 CMD 命令行可以测试连接:

showmount -e 192.168.2.20

完整用法

showmount -e [server] 显示 NFS 服务器导出的所有共享。
showmount -a [server] 列出客户端主机名或 IP 地址,以及使用“主机:目录”格式显示的安装目录。
showmount -d [server] 显示 NFS 服务器上当前由某些 NFS 客户端安装的目录。

3. 此时挂载后只能读不能写,如需读写,需要修改注册表:
通过修改注册表将 Windows 10 访问 NFS 时的 UID 和 GID 改成 0 即可(其实就是 Linux 下的 root),步骤如下:
a、在运行中输入 regedit,打开注册表编辑器;
b、进入 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default 条目;
c、选择新建 DWORD 值,新建 AnonymousUid,AnonymousGid 两个值,值为 0;
d、重启系统;

4. 如临时使用,可用命令行挂载:

mount \\192.168.2.20\sync S:

注意,如果挂载后在我的电脑里不显示盘符,请退出管理员权限的 CMD,卸载后在普通权限的 CMD 下重新挂载!

完整用法:

用法: mount [-o options] [-u:username] [-p: ] <\\computername\sharename>

-o rsize=size 设置读取缓冲区的大小(以 KB 为单位)。
-o wsize=size 设置写入缓冲区的大小(以 KB 为单位)。
-o timeout=time 设置 RPC 调用的超时值(以秒为单位)。
-o retry=number 设置软装载的重试次数。
-o mtype=soft|hard 设置装载类型。
-o lang=euc-jp|euc-tw|euc-kr|shift-jis|big5|ksc5601|gb2312-80|ansi
指定用于文件和目录名称的编码。
-o fileaccess=mode 指定文件的权限模式。
这些模式用于在 NFS 服务器上创建的
新文件。使用 UNIX 样式模式位指定。
-o anon 作为匿名用户装载。
-o nolock 禁用锁定。
-o casesensitive=yes|no 指定在服务器上执行区分大小写的文件查找。
-o sec=sys|krb5|krb5i|krb5p

5. 如需要重启后自动挂载,可以向添加 SAMBA 共享一样使用磁盘映射,格式也一样,但需要注意:卸载时不要使用资源管理器的 “断开网络驱动器”,要去命令行用:

umount S:

卸载,如果要卸载全部 NFS 网络驱动器,用:

umount -f -a


May 10

其实就是注意 -ldl 放的位置,之前放在 LDFLAGS 最后老是提示 -lcrypto 错误(这样放,在路由器上编译好像没事~~ :evil: ):

make clean

LIBS="-ldl" LDFLAGS="-Wl,-static -static -static-libgcc" ./configure --host=arm-brcm-linux-uclibcgnueabi CC=arm-brcm-linux-uclibcgnueabi-gcc --with-openssl=/home/punk/arm_apps/libs/openssl

make -j`nproc`


Apr 18

出错提示为:

/opt/brcm-arm/bin/../libexec/gcc/arm-brcm-linux-uclibcgnueabi/4.5.3/cc1: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory

或者:

configure: error: C compiler cannot create executables

执行:

ldd /opt/brcm-arm/libexec/gcc/arm-brcm-linux-uclibcgnueabi/4.5.3/cc1

发现有库未找到:

linux-gate.so.1 => (0xf77bf000)
libmpc.so.2 => not found
libmpfr.so.4 => not found
libgmp.so.10 => not found
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf77aa000)
libelf.so.1 => /usr/lib/i386-linux-gnu/libelf.so.1 (0xf7792000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf75e3000)
/lib/ld-linux.so.2 (0xf77c0000)

解决方法,编译前执行:

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/brcm-arm/lib:/usr/local/lib:/usr/lib

再用上面的命令检查依赖库,结果没有依赖库未找到了:

linux-gate.so.1 => (0xf76f4000)
libmpc.so.2 => /opt/brcm-arm/lib/libmpc.so.2 (0xf76de000)
libmpfr.so.4 => /opt/brcm-arm/lib/libmpfr.so.4 (0xf768e000)
libgmp.so.10 => /opt/brcm-arm/lib/libgmp.so.10 (0xf7631000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7620000)
libelf.so.1 => /usr/lib/i386-linux-gnu/libelf.so.1 (0xf7608000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7459000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7412000)
/lib/ld-linux.so.2 (0xf76f5000)

编译也没问题了 :mrgreen: