2023-06-16 16:56:16    10    0    0

一.环境简述

之前一直使用公网ip来连接各个机房的服务器,现在ip不太够用了,而且有些机器也不需要用到公网ip.通过openvpn将多个机房连接起来,组成一个局域网,机器ip可以做到唯一性,便于标识.既节省了ip.又方便管理.

本例环境如下,服务器使用的系统为centos 7.1

北京机房内网网段 172.16.2.0/24,服务器公网ip 20.20.20.20,内网网关172.16.2.1

广州机房内网网段 172.16.1.0/24,服务器公网ip 10.10.10.10,内网网关172.16.1.1

公司内网网段 172.16.3.0/24,防火墙公网ip 30.30.30.30,内网网关172.16.3.1,内网服务器ip 172.16.3.88

实现思路:

1.在广州机房搭建一个openvpn服务端,北京和公司内网各选一台服务器做openvpn的客户端连接广州.

2.openvpn使用桥接模式,开启client-to-client.北京和公司都连上后,这3台机器默认就能互访.

3.各内网网段的互通使用静态路由.

二.广州安装openvpn服务端

安装前需注意服务器的系统时间要一致,可按如下方法同步:

/usr/sbin/ntpdate cn.pool.ntp.org

1.安装openvpn

如果没epel源,先添加下

wget  http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh epel-release-7-5.noarch.rpm
yum -y install openvpn easy-rsa

2.创建证书

cp -r /usr/share/easy-rsa/ /etc/openvpn/
cd /etc/openvpn/easy-rsa/2.*/
vim vars

设置如下内容

export KEY_COUNTRY="CN"
export KEY_PROVINCE="GD"
export KEY_CITY="guangzhou"
export KEY_ORG="test"
export KEY_EMAIL="me@myhost.mydomain"
export KEY_OU="MyOrganizationalUnit"
# X509 Subject Field
export
2023-05-16 08:48:51    15    0    0

0. Make Workspace

# download source code packages
#wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.25.0.tar.xz
#wget http://mirrors.ustc.edu.cn/gnu/libtool/libtool-2.4.tar.xz
wget http://ftpmirror.gnu.org/binutils/binutils-2.28.1.tar.xz
wget https://ftp.gnu.org/gnu/gcc/gcc-5.5.0/gcc-5.5.0.tar.xz
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.10.107.tar.xz
wget http://ftpmirror.gnu.org/glibc/glibc-2.18.tar.xz
wget http://ftpmirror.gnu.org/mpfr/mpfr-3.1.5.tar.xz
wget http://ftpmirror.gnu.org/gmp/gmp-6.1.1.tar.xz
wget http://ftpmirror.gnu.org/mpc/mpc-1.0.3.tar.gz
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz

# create soft link
for f in *.tar*; do tar xf $f; done
cd gcc-5.5.0
#ln -s ../mpfr-3.1.5 mpfr
#ln -s ../gmp-6.1.1 gmp
#ln -s ../mpc-1.0.3 mpc
#ln -s ../isl-0.12.2 isl
#ln -s ../cloog-0.18.1 cloog
cd ..

# make target folder and add path environment
sudo mkdir -p /
2023-05-16 08:48:49    13    0    0


sudo mkdir -p /opt/gcc
export PATH=/opt/gcc/bin:$PATH
mkdir build-binutils
../binutils-2.26.1/configure --prefix=/opt/gcc --target=arm-linux-gnueabi --sysconfdir=/opt/gcc/etc --localstatedir=/opt/gcc/var --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --disable-multilib --disable-werror --with-sysroot=/opt/gcc/arm-linux-gnueabi/sysroot --enable-poison-system-directories --without-debuginfod --disable-sim --disable-gdb
make -j8 MAKEINFO=true
make -j8 MAKEINFO=true install
cd ..
cd linux-3.10.107
make ARCH=arm INSTALL_HDR_PATH=/opt/gcc/arm-linux-gnueabi/sysroot/usr headers_install
cd ..
mkdir build-gmp
cd build-gmp
../gmp-6.1.1/configure --prefix=/opt/gcc --sysconfdir=/opt/gcc/etc --localstatedir=/opt/gcc/var --enable-static --disable-shared
make -j8
make install
cd ..
mkdir build-mpfr
cd build-mpfr
../mpfr-3.1.5/configure --prefix=/opt/gcc --sysconfdi
2023-04-25 14:41:30    239    0    0

环境准备:

买个最便宜的随身WiFi(15以下可以入手,有的车甚至可以几毛钱)
一个小螺丝刀、WiFi网络环境、Windows电脑

环境软件准备

  • 9008驱动
  • MIKO(系统备份还原工具)
  • adb
  • Debian系统镜像

文末参考链接中有大佬们提供的环境包和系统镜像包:
https://wwz.lanzoub.com/i9LWO0bib0zg

[链接]123云盘  提取码:OncH
本教程有错误的地方欢迎指正

备份原系统

进入9008模式

按住随身wifi上的按键不松然后插入电脑,插入电脑后听到提示音或等待5秒后即可松开按键。


此时设备会进入9008模式,进入设备管理器检查是否有端口为9008的设备。
右击此电脑,选择管理。


查看是否有9008设备


使用MIKO进行备份

设备进入9008模式后,即可打开MIKO加载分区,如图进行点击


点击Read Full Image,选择保存位置进行备份,大约5分钟,看到Success代表备份完成。


一键刷Debian

备份完成后,重新插拔随身WIFI(无需按住按键,直接拔掉后在插入)

# 输入以下命令检查设备连接是否正常
adb devices
# 重启设备进入fastboot刷机模式
adb reboot bootloader

解压Debian镜像,双击flash.bat


碰到“请按任意键继续. . .”的提示时回车,出现all done!!代表完成


配置网络与SSH连接

# 进入adb目录,使用以下命令进入debian系统shell
adb shell


关闭随身WiFi的热点,并连接自己的WiFi网络以获得IP

export TERM=linux
nmtui
# 删除wifi,路径: 编辑连接/网桥/bridge/从机/wifi
# 连接wifi网络,路径:启用连接/Wi-Fi,连接自己的WiFi即可
# WiFi连接后,查看IP
ifconfig


然后即可使用如下连接信息来连接你的Debian系统

#用户名=root
#密码=1
ssh root@ipaddress


硬盘空间太小?Wi-Fi网络不稳定?

开启USB拓展

在命令行输入以下命令,即可开启拓展USB拓展

# 开启usb拓展
echo host > /sys/kernel/debug/usb/ci_hdrc.0/role

可以加入到开启启动脚本中,即可每次重启自动启用USB拓展


开启拓展后即可对随身WIFI使用拓展坞以进行扩展,如下是我的拓

2023-04-25 14:12:46    10    0    0

This article is splitted from Installation of ArchLinux ARM on an out-of-tree Amlogic device for a better structure. Check that article if you are interesting on an ArchLinux ARM installation done in the ArchLinux way.
这篇文章是从在不被官方支持的Amlogic设备上安装ArchLinux ARM中为了更好的布局而分割出来的。如果你对以ArchLinux的方式安装ArchLinux ARM感兴趣,看一下那篇文章

Background / 背景

If you know the bootloader machanism on Amlogic platform very well, you can jump to setups to choose one of the setups. Otherwise better get yourself acknowledged for Amlogic’s boot flow from this part
如果你熟知Amlogic平台上的启动机制,你可以直接跳到安装方法章节来选择一种安装方法。不然的话最好通过这一章节充分了解Amlogic的启动流程

Several different bootloader/pre-boot environment combination can be chosen depending on the support status of your hardware in the upstream u-boot project due to the following boot flow:
根据你的硬件在上游u-boot项目里的支持情况不同,几种不同的引导程序/启动前环境的组合可以选择,这是因为以下的启动流程:

 media-independent | load BL1 from ROM in SoC
    early boot     |            v
--------------------------------v-------------------------------
 med
2023-04-24 12:07:48    89    0    0

Windows 系统复制文件时保留文件夹时间戳+文件时间戳(原封不动复制文件)

使用Windows powershell里的robocopy即可实现。

Robocopy.exe /copy:TDA /dcopy:T SourceFolder DestFolder /MIR /xd "System Volume Information" "`$RECYCLE.BIN"​

这里 /copy 后面的 TDA 分别表示:T:保留源文件时间戳,D:复制源文件数据部分,A:复制源文件属性部分 /dcopy 后面的T表示:保留源目录时间戳。

使用 robocopy 备份整个驱动器时,想排除 (/xd) 系统卷信息和 $RECYCLE.BIN(垃圾箱)。

2023-04-21 16:26:53    14    0    0

修改 nginx 配置文件 nginx.conf,添加如下配置

#点播/直播功能实现配置rtmp协议
rtmp {
    server {
        listen 8099;
        chunk_size 4096; #//数据传输块的大小
        application vod {
            play /usr/share/nginx/html/vod/flvs/; #点播媒体存放目录
        }
        application live {
            live on;
        }
		#HLS直播配置
        application hls {
            live on;
            hls on;
            hls_path /usr/share/nginx/html/hls; #视频流存放地址
            hls_fragment 5s;
            hls_playlist_length 15s;
            hls_continuous on; #连续模式。
            hls_cleanup on;    #对多余的切片进行删除。
            hls_nested on;     #嵌套模式。
        }
    }
}


如果没有安装 rtmp 模块支持,则执行以下命令安装

apt install -y libnginx-mod-rtmp


使用 ffmpeg 进行推流

ffmpeg -i /dev/video1 -preset:v ultrafast -tune:v zerolatency -vf scale=iw/2:-1 -f v4l2 -f flv rtmp://127.0.0.1:8099/live/video1


2023-04-14 17:38:56    14    0    0

1.ARM的概念

嵌入式处理器种类繁多,有ARM、MIPS、PPC等多种架构。ARM处理器的文档丰富,各类嵌入式软件大多(往往首选)支持ARM处理器,使用ARM开发板来学习嵌入式开发是个好选择。基于不同架构CPU的开发是相通的,掌握ARM架构之后,在使用其他CPU时也会很快上手。当然,作为产品进行选材时,需要考虑的因素就非常多了,这不在本书的介绍范围之内。

ARM(Advanced RISC Machine),既可以认为是一个公司的名字,也可以认为是对一类微处理器的通称,还可以认为是一种技术的名字。ARM公司是32位嵌入式RISC微处理器技术的领导者,自从1990年创办公司以来,基于ARM技术IP核的微处理器的销售量已经超过了100亿。

ARM公司并不生产芯片,而是出售芯片技术授权。其合作公司针对不同需求搭配各类硬件部件,比如UART、SDI、I2C等,设计出不同的SoC芯片。

ARM公司在技术上的开放性使得它的合作伙伴既有世界顶级的半导体公司,也有各类中、小型公司。随着合作伙伴的增多,也使得ARM处理器可以得到更多的第三方工具、制造和软件支持,又使整个系统成本降低,使新品上市时间加快,从而具有更大的竞争优势。

基于ARM的处理器以其高速度、低功耗、价格低等优点得到非常广泛的应用,它可以应用于以下领域:

① 为无级通信、消费电子、成像设备等产品提供可运行复杂操作系统的开放应用平台;

② 在海量存储、汽车电子、工业控制和网络应用等领域提供实时嵌入式应用;

③ 安全系统,比如信用卡、SIM卡等。

2.ARM体系架构的版本

ARM体系架构的版本就是它所使用的指令集的版本。ARM架构支持32位的ARM指令集和16位的Thumb指令集,后者使得代码的存储空间大大减小。还提供了一些扩展功能,比如Java加速器(Jazelle)、用以提高安全性能的TrustZone技术、智能能源管理(IEM,Intelligent Energy Manager)、SIMD和NEONTM等技术。

还在使用的ARM指令集(ISA,Instruction Set Architecture)有以下版本。

(1)ARMv4。

这是当今市场上最老的版本,ARMv4只支持32位的指令集,支持32位的地址空间。一些ARM7系列的处理器和Intel公司的StrongARM处理采用ARMv4指令集。

(2)ARMv4T。

增加了16位的Thum

2023-03-29 11:37:53    67    0    0

The S7 has the family types

S7 200 / 300 / 400 / 1200

and the

S7-1500

If the "optimized" data blocks need to be used set the check mark on the "1500" in the protocol settings.

S7 200 / 300 / 400 / 1200

For non-configurable connections (= default connections), so-called standard TSAPs are used. For these, the following rules apply:

First group

contains device IDs for which resources are provided in the S7:

01: PG or PC

02: OS (operating or monitoring device)

03: Others, such as OPC server, Simatic S7 PLC...

Second group

contains the addresses of these components

Left character (bits 7....4):

Rack number multiplied by 2

Right character (bits 3...0):

CPU slot (< 16). S7-300 always uses slot 2

The standard TSAPs MUST be used on the PLC side (Dest TSAP field of the device).

The local TSAP of the device (Own TSAP field) may be selected freely, but should have the same format. We recommend to use 01 01 in the Own TSAP field.

Examples:

03 02 Communication with the S7 CPU in rack 0, slot 2

03 43 Communication with t

2023-03-29 09:20:17    10    0    0

快速排序算法和二分查找算法整合

  1. #include <stdio.h>
  2. // 快速排序函数
  3. void quickSort(int arr[], int low, int high) {
  4. int i = low, j = high, pivot = arr[(low + high) / 2];
  5. while (i <= j) {
  6. while (arr[i] < pivot) i++;
  7. while (arr[j] > pivot) j--;
  8. if (i <= j) {
  9. int temp = arr[i];
  10. arr[i] = arr[j];
  11. arr[j] = temp;
  12. i++; j--;
  13. }
  14. }
  15. if (low < j) quickSort(arr, low, j);
  16. if (i < high) quickSort(arr, i, high);
  17. }
  18. // 二分查找函数
  19. int binarySearch(int arr[], int left, int right, int x)
  20. {
  21. if (right >= left) {
  22. int mid = left + (right - left) / 2;
  23. if (arr[mid] == x)
  24. return mid;
  25. if (arr[mid] > x)
  26. return binarySearch(arr, left, mid - 1, x);
  27. return binarySearch(arr, mid + 1, right, x);
  28. }
  29. return -1;
  30. }
  31. int main()
  32. {
  33. int arr[] = { 10, 7, 8, 9, 1, 5 };
  34. int n = sizeof(arr) / sizeof(arr[0]);
  35. int x = 8;
  36. // 调用快速排序函数对数组进行排序
  37. quickSort(arr,
2/3