博远日志

记事本

OpenWrt logo

OpenWrt Project is a Linux operating system targeting embedded devices. Instead
of trying to create a single, static firmware, OpenWrt provides a fully
writable filesystem with package management. This frees you from the
application selection and configuration provided by the vendor and allows you
to customize the device through the use of packages to suit any application.
For developers, OpenWrt is the framework to build an application without having
to build a complete firmware around it; for users this means the ability for
full customization, to use the device in ways never envisioned.

Sunshine!

Development

To build your own firmware you need a GNU/Linux, BSD or MacOSX system (case
sensitive filesystem required). Cygwin is unsupported because of the lack of a
case sensitive file system.

Requirements

You need the following tools to compile OpenWrt, the package names vary between
distributions. A complete list with distribution specific packages is found in
the Build System Setup
documentation.

1
2
binutils bzip2 diff find flex gawk gcc-6+ getopt grep install libc-dev libz-dev
make4.1+ perl python3.6+ rsync subversion unzip which

Quickstart

  1. Run ./scripts/feeds update -a to obtain all the latest package definitions
    defined in feeds.conf / feeds.conf.default

  2. Run ./scripts/feeds install -a to install symlinks for all obtained
    packages into package/feeds/

  3. Run make menuconfig to select your preferred configuration for the
    toolchain, target system & firmware packages.

  4. Run make to build your firmware. This will download all sources, build the
    cross-compile toolchain and then cross-compile the GNU/Linux kernel & all chosen
    applications for your target system.

The main repository uses multiple sub-repositories to manage packages of
different categories. All packages are installed via the OpenWrt package
manager called opkg. If you’re looking to develop the web interface or port
packages to OpenWrt, please find the fitting repository below.

Support Information

For a list of supported devices see the OpenWrt Hardware Database

Documentation

Support Community

  • Forum: For usage, projects, discussions and hardware advise.
  • Support Chat: Channel #openwrt on oftc.net.

Developer Community

License

OpenWrt is licensed under GPL-2.0

#nc

man

help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
nc -h
nc [-46AacCDdEFhklMnOortUuvz] [-K tc] [-b boundif] [-i interval] [-p source_port]
[--apple-recv-anyif] [--apple-awdl-unres]
[--apple-boundif ifbound]
[--apple-no-cellular] [--apple-no-expensive]
[--apple-no-flowadv] [--apple-tcp-timeout conntimo]
[--apple-tcp-keepalive keepidle] [--apple-tcp-keepintvl keepintvl]
[--apple-tcp-keepcnt keepcnt] [--apple-tclass tclass]
[--tcp-adp-rtimo num_probes] [--apple-initcoproc-allow]
[--apple-tcp-adp-wtimo num_probes]
[--setsockopt-later] [--apple-no-connectx]
[--apple-delegate-pid pid] [--apple-delegate-uuid uuid]
[--apple-kao] [--apple-ext-bk-idle]
[--apple-netsvctype svc] [---apple-nowakefromsleep]
[--apple-notify-ack] [--apple-sockev]
[--apple-tos tos] [--apple-tos-cmsg]
[-s source_ip_address] [-w timeout] [-X proxy_version]
[-x proxy_address[:port]] [hostname] [port[s]]

#常用命令

扫描端口(nc)
1
2
# 使用检测端口可用 
nc [IP] [端口] -zv

https://openwrt.org/toh/phicomm/phicomm_k3_a1

刷机

1
2
3
4
5
6
7
8
9
10
11
12
# 上传文件
scp /本地file [user@local:] setFilePath
# 找到 linux 位置 mtd3/mtd2 我之前是mtd2 刷完梅林会变mtd3
cat /proc/mtd
# mtdblock3 对应mtd3 mtdblock2 对应mtd2
cat /tmp/K3.bin >/dev/mtdblock3 && reboot

报错:Segmentation fault
#不用管它 等待5分钟后 将设备重启

#LEDE Open互刷使用
mtd -r write /tmp/k3.bin firmware

TTL 刷机

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
screen /dev/tty.usbserial-14710 115200
# 设置ip
ifconfig -addr=192.168.2.1 -mask=255.255.255.0
# tftp
sudo launchctl start com.apple.tftpd
sudo chmod 777 /private/tftpboot
# 将 k3.bin 放入 /private/tftpboot
cp k3.bin /private/tftpboot/k3.bin

# 设置本机地址 192.168.2.2/24

# 刷机
show devices

flash -noheader 192.168.1.2:k3.bin nflash0.trx

Phicomm K2P A1


硬件参数

  • CPU MT7621A/N

CPU MT7621A/N

Specifications

CPU & GPU

  • CPU Type: MIPS1004Kc
  • CPU Bit:32-bit
  • CPU Core: Dual (2)
  • CPU Frequency:880MHz

Connectivity

  • Ethernet:5 port Fast Ethernet Switch + RGMII
  • PCI-Express:Host(3)
  • USB:USB 3.0 (1), USB 2.0 (1)
  • I/O:GPIO, I2C, JTAG, MDC, MDIO, UART(3)

Hardware Features

  • Network Accelerator:2Gbps IPv4/6 routing, NAT, NAPT+HQoS
  • DRAM:16b DDR2, 16b DDR3
  • Flash:SPI, SLC NAND
  • Storage Accelerator:Yes
  • Audio Interface:I2S, PCM, S/PDIF

Software

  • Crypto: 200Mbps Crypto Suite
  • iNIC: Linux 2.4/2.6 (RGMII)
  • OS: Linux 2.6.36 SDK, Linux 3.10 SDK, OpenWRT

Bundled Platform

  • MT7621A:embedded 5p GbE Switch
  • MT7621N:no 5p GbE Switch

参考

https://openwrt.org/toh/phicomm/phicomm_k2p

Ubuntu 16.04 install shadowsocks

1.1更新apt

apt update &&apt upgrade

##1.2安装python pip

apt install python-pip python-dev

##1.3升级pip到9.0版本

pip install -U pip

###如果pip报错

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/dist-packages/pip/__main__.py", line 19, in 
    sys.exit(pip.main())
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python2.7/locale.py", line 581, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

则需要设置locale环境变量

export LC_ALL=C

如果还报错则需要安装

apt install libssl-dev -y
apt install libffi-dev

##2.1安装shdowsocks

pip install shadowsocks

添加shadowsocks 配置文件

mkdir /config &&
mkdir /config/shadowsocks

echo "{\"server\":\"服务器IP\",\"server_port\":端口号,\"password\":\"密码\",\"timeout\":300,\"method\":\"aes-256-cfb\",\"fast_open\":true,\"workers\":1}" > /config/shadowsocks/shadowsocks.json

添加自启,将

sudo ssserver -c /config/shadowsocks/shadowsocks.json -d start

添加到 /etc/rc.local exit 0 的前面

http://people.redhat.com/~rjones/virt-what/files/

wget http://people.redhat.com/~rjones/virt-what/files/virt-what-1.18.tar.gz
tar zxvf virt-what-1.18.tar.gz
cd virt-what-1.18/
./configure
make && make install
virt-what

#centos 6.x 安装nodejs

##1.安装g++ 4.9.4 以上版本

  • 1.1需要安装gcc-c++老版本

    yum -y install make clang clang++ gcc gcc-c++;
    

    不然编译时会报错:

    make[2]: *** [all-stage1-target-libgcc] 错误 2
    make[2]: Leaving directory '/gcc-4.9.4/gcc-build'
    make[1]: *** [stage1-bubble] 错误 2
    make[1]: Leaving directory '/gcc-4.9.4/gcc-build'
    make: *** [all] 错误 2
    
  • 1.2下载gcc 4.9.4

    wget http://ftp.gnu.org/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.bz2 &&tar -xf gcc-4.9.4.tar.bz2 &&cd gcc-4.9.4 &&./contrib/download_prerequisites
    
  • 1.3 生成编译目录

    mkdir gcc-build && cd gcc-build
    
  • 1.4 生成makefile

    ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
    
  • 1.5 编译(注意:此步骤非常耗时,搬瓦工单核我用了大约30分钟)

    make
    //如果是多核服务器请加上 -j4 会快一些
    
  • 1.6 安装

    make install 
    //如果安装失败 请加上sudo权限
    //成功后验证版本
    gcc -v  
    

##2.安装nodejs最新版本

  • 2.1 下载nodejs code

    wget https://nodejs.org/dist/v8.9.4/node-v8.9.4.tar.gz && tar -xf node-v8.9.4.tar.gz &&cd node-v8.9.4
    
  • 2.2 开始安装

    ./configure --coverage &&make coverage &&make install
    //如果失败 需要加上sudo
    

###阻止笔记本合盖休眠

1
2
3
4
5
6
7
8
9
10
11
12
# 在PVE7.0 中vim 出现乱码 具体原因未知 使用nano
vi /etc/systemd/logind.conf
# 1
#HandleLidSwitch=suspend
#修改后如下
HandleLidSwitch=ignore
# 2 修改完退出并保存
Ctrl+X -> y ->Enter
# 3 重启

# 重启机器 reboot 或者重启服务
systemctl restart systemd-logind.service
0%