esp32分区表分析总结

esp32分区表分析总结

要点

  • 分区表的首地址是0x8000。
  • 分区若偏移地址为空,则会紧跟着前一个分区之后开始;若为首个分区,则将紧跟着分区表开始。目前根据实际的代码和信息分析,第一个分区默认是从0x9000开始。
  • factory (0x00) 是默认的 app 分区。启动加载器将默认加载该应用程序。但如果存在类型为 data/ota 分区,则启动加载器将加载 data/ota 分区中的数据,进而判断启动哪个 OTA 镜像文件。
  • OTA 升级永远都不会更新 factory 分区中的内容。
  • 如果您希望在 OTA 项目中预留更多 flash,可以删除 factory 分区,转而使用 ota_0 分区
  • app 分区始终会被加密,不管 Flags 字段是否设置。
  • 如果您在项目配置菜单(idf.py menuconfig)中设置了分区表 CSV 文件的名称,然后构建项目或执行 idf.py partition_table。这时,转换将在编译过程中自动完成。
  • idf.py partition_table-flash :使用 esptool.py 工具烧写分区表。
  • idf.py flash :会烧写所有内容,包括分区表。

官方参考: https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/partition-tables.html

分区表

如下是Factory app, two OTA definitions 的内容

# ESP-IDF Partition Table
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x4000,
otadata,  data, ota,     0xd000,  0x2000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000,  1M,
ota_0,    app,  ota_0,   0x110000, 1M,
ota_1,    app,  ota_1,   0x210000, 1M,
  • nvs:系统的非易失区,wifi配置,校准数据,以及其他通过api写入的非易失数据在这里。
  • otadata:这个用户存储ota的过程数据,比如当前区标识,完整性,校验等等。
  • phy_init:针对不同PHY的初始配置信息
  • factory:出厂分区,内容是我们的用户代码,我们的程序主体。当ota区有效时,此区会被跳过,默认没有ota时,运行的就是此区,一旦有ota版本,系统会尝试去启动ota的内容。
  • ota_0:第1个ota分区。
  • ota_1:第2个ota分区,无论如何总有一个是当期使用的激活区,另一个作为ota缓存空间用。
  • nvs_key:nvs区的秘钥分区。

    解释

    分区表的长度是0xc00,后面还md5校验,签名等,所以整个内容在 0x1000以内。
    0x9000=0x8000+0x1000
    0xd000=0x9000+0x4000
    0xf000=0xd000+0x2000
    0x10000=0xf000+0x1000
    0x110000=0x10000+0x100000(1M)
    0x210000=0x110000+0x100000(1M)

从上面的计算中,我们就可以看到,偏移地址和容量都是连续的,这也就是为什么实际的分区表,只天容量,不填其实偏移地址,因为地址可以根据容量进行计算得出。

实际例子分析

分区表

# Name,   Type, SubType, Offset,   Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs,      data, nvs,     ,        0x4000,
otadata,  data, ota,     ,        0x2000,
phy_init, data, phy,     ,        0x1000,
ota_0,    app,  ota_0,   ,        0x180000,
ota_1,    app,  ota_1,   ,        0x180000,
fctry,    data, nvs,     ,        0x4000

系统运行日志

I (58) boot: ## Label            Usage          Type ST Offset   Length
I (65) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (72) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (80) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (87) boot:  3 ota_0            OTA app          00 10 00010000 00180000
I (95) boot:  4 ota_1            OTA app          00 11 00190000 00180000
I (102) boot:  5 fctry            WiFi data        01 02 00310000 00004000

从运行日志看,跟我们上面介绍的计算结果一致。

flash工具配置

烧录时的地址配置如下:
file

  • bootloader.bin: 默认从0地址开始。
  • partition-table.bin: 默认起始地址0x8000
  • ota_data_initial.bin: 对应的otadata和phy_init两个分区内容
  • app.bin:对应的是ota_0

从这个例子看,为了节省空间,factory分区被省掉了,直接是ota_0分区。

how to build an esp32 centos environment

esp32 centos开发环境搭建

系统:CentOS Linux release 7.8.2003 (Core)

chip:esp32c3

前言

重点:之前是在windows下工作的,因为编译烧录都比较方便。最近因为各种git的不稳定原因,导致无法正确编译和运行,所以才打算在海外搞个linux环境,这样就可以解决git相关的困扰。

环境安装

官方指导参考:https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32c3/get-started/index.html#id4

  1. 进入目标目录, 下载工具:

    git clone --recursive https://github.com/espressif/esp-idf.git
  2. 设置工具

    ./install.sh

    遇到的问题:

1)python版本问题

ESP-IDF supports Python 3.6 or newer but you are using Python 2.7.5. Please upgrade your installation as described in the documentation.

需要升级python,请参考网上文章,通过最新源码更新python。

2)ModuleNotFoundError: No module named '_ctypes' 问题

解决:

yum install libffi-devel -y

然后需要重新安装python3

make clean 
./configure
make&&make install
  1. 设置环境变量

    ./export.sh

遇到的问题:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'click'
env: idf.py: No such file or directory

解决:

python -m pip install click

由于是vps,所以 export.sh 实际上不会成功,一直卡死在 libusb-1.0 的错误中。所以只能手动设置环境变量,需要设置IDF_PYTHON_ENV_PATH 和PATH:

export PATH=/data/develop/esp/esp-idf/tools:$PATH
export PATH=/root/.espressif/python_env/idf4.4_py3.9_env/bin:$PATH
export IDF_PYTHON_ENV_PATH=/root/.espressif/python_env/idf4.4_py3.9_env

注意IDF_PYTHON_ENV_PATH一定要设置成 espressif的python路径,否则会一直提醒你执行 install.sh

验证idf.py环境ok:

idf.py --version
Setting IDF_PATH environment variable: /data/develop/esp/esp-idf
ESP-IDF v4.4-dev-1849-g8e3e65a-dirty

编译

找一个例子测试下

idf.py set-target esp32c3
idf.py build

出现错误:

  1. CMake 3.5 or higher is required. You are running version 2.8.12.2

升级cmake:

wget https://github.com/Kitware/CMake/releases/download/v3.21.0-rc2/cmake-3.21.0-rc2.tar.gz
tar zxvf cmake-3.21.0-rc2.tar.gz
make&&make install

添加cmake的环境变量
/usr/local/share/cmake-3.21

cmake --version
cmake version 3.21.0-rc2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
  1. 工具链错误 :
    
    riscv32-esp-elf-gcc

is not a full path and was not found in the PATH.


解决:把
> /root/.espressif/tools/riscv32-esp-elf/esp-2021r1-8.4.0/riscv32-esp-elf/bin 

添加到PATH环境变量里

排除完问题后,以前在windows下无法正常编译的demo,编译通过,

centos python2.7 升级 python3

安装一个软件要求python3.6 以上版本,当前的版本是2.7.5

系统配置

CentOS Linux release 7.8.2003 (Core)

python源码下载

https://www.python.org/downloads/source/
我们下载最新的版本。

wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
tar zxvf Python-3.9.6.tgz

编译

./configure
make
make install

设置系统默认的python版本

检查版本

python -V
Python 2.7.5
python3 -V
Python 3.9.6

我们需要设置环境变量,默认使用python3

cd /usr/bin
ls -al /usr/bin | grep python
lrwxrwxrwx    1 root root          7 Jul 10  2020 python -> python2
lrwxrwxrwx    1 root root          9 Jul 10  2020 python2 -> python2.7
-rwxr-xr-x    1 root root       7144 Apr  2  2020 python2.7
-rwxr-xr-x    1 root root       1835 Apr  2  2020 python2.7-config
lrwxrwxrwx    1 root root         16 Jul 10  2020 python2-config -> python2.7-config
lrwxrwxrwx    1 root root         14 Jul 10  2020 python-config -> python2-config

照猫画虎,将建立python3的软连接

ln -s /usr/local/bin/python3 /usr/bin/python
python -V
Python 3.9.6
[root@li1974-11

可见python3已生效。

还原yum

因为yum是用的默认版本,python3会导致yum失效。需要对yum的python做指定。修改以下2个文件:

vi /usr/bin/yum
vi /usr/libexec/urlgrabber-ext-down

修改首行的 #!/usr/bin/python 为 #!/usr/bin/python2.7

验证yum修改后的效果:

yum --version
3.4.3
  Installed: rpm-4.11.3-43.el7.x86_64 at 2020-07-10 12:34
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2020-04-01 04:21
  Committed: Panu Matilainen <pmatilai@redhat.com> at 2019-10-04

  Installed: subscription-manager-1.24.45-1.el7.centos.x86_64 at 2021-04-29 18:18
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2020-12-15 16:38
  Committed: William Poteat <wpoteat@redhat.com> at 2020-11-24

  Installed: yum-3.4.3-167.el7.centos.noarch at 2020-07-10 12:36
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2020-04-02 15:56
  Committed: CentOS Sources <bugs@centos.org> at 2020-03-31

  Installed: yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch at 2020-07-10 12:36
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2020-05-12 16:27
  Committed: Michal Domonkos <mdomonko@redhat.com> at 2020-03-12

yum 正常。

ESP32 下载工具说明

ESP32系列 flash下载

环境

硬件: esp32c3

环境: windows7

目前最新的IDF环境编译和下载都是python脚本完成的,但是对于非开发人员,测试或者工厂等下载最简单的方式还是通过下载工具,而不是配置负载的开发环境。

工具获取

去乐鑫官网下载最新的下载工具,工具页面:
https://www.espressif.com/zh-hans/support/download/other-tools

V3.8.8下载链接:
https://www.espressif.com/sites/default/files/tools/flash_download_tool_v3.8.8.zip

下载

解压后,运行工具,chip选择esp32c3,workmode选择develop

确定后,进入主页面,需要选择3个对应的bin档,他们分别是:

build\bootloader\bootloader.bin
build\partition_table\partition_table.bin
build\xxx.bin

其中xxx.bin是你的工程名称,也就是你的用户代码bin。
3个bin对应的地址分别是 0x0,0x8000,0x1000。以上bin的名称和地址都是根据命令行模式下载的日志中找到的,根据对应的size和地址,基本就能找到以上的信息。具体如图所示:

注意设置正确的串口,点击开始后,工具会自动读取正确的spiflash信息。

完成

完成后,绿色的按钮会显示完成字样,中间不要断电或者中断。
工具下载完成后不像命令行,不会自动重启,需要手动重启。

esp apsta lwip config

when you are developing an apsta app of esp, you should config int the menuconfig procedure, such as below:

  • Component config -> LWIP > [x] Enable copy between Layer2 and Layer3 packets.
  • Component config -> LWIP > [x] Enable IP forwarding.
  • Component config -> LWIP > [x] Enable NAT (new/experimental).

esp8266-window7-environment-installation

esp8266 window7开发环境搭建

最新代码

https://github.com/espressif/ESP8266_RTOS_SDK

安装toolchain

下载msys32

在windows环境下我们需要msys32,在linux不需要

https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_toolchain-20181001.zip

下载8266对应的toolchain

在默认的msys下是没有8266的toolchain的,我们需要下载:

https://dl.espressif.com/dl/xtensa-lx106-elf-gcc8_4_0-esp-2020r3-win32.zip

将解压后的xtensa-lx106-elf放到/msys32/opt/下

安装python环境

# python -m pip install --user -r $IDF_PATH/requirements.txt
Requirement already satisfied: setuptools in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 4)) (40.4.3)
Collecting click>=5.0 (from -r requirements.txt (line 8))
  Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB)
    49% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒                | 40kB 450kB/s eta 0:00    61% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒            | 51kB 248kB/s eta     74% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒        | 61kB 296kB/s     86% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    | 71kB 344k    98% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒| 81kB     100% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒| 92kB 385kB/s
Requirement already satisfied: pyserial>=3.0 in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 9)) (3.4)
Requirement already satisfied: future>=0.15.2 in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 10)) (0.16.0)
Requirement already satisfied: cryptography>=2.1.4 in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 11)) (2.3.1)
Requirement already satisfied: pyparsing<2.4.0,>=2.0.3 in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 12)) (2.2.0)
Collecting pyelftools>=0.22 (from -r requirements.txt (line 13))
  Using cached https://files.pythonhosted.org/packages/6f/50/3d7729d64bb23393aa4c166af250a6e6f9def40c90bf0e9af3c5ad25b6f7/pyelftools-0.27-py2.py3-none-any.whl
Requirement already satisfied: idna>=2.1 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (2.7)
Requirement already satisfied: asn1crypto>=0.21.0 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (0.24.0)
Requirement already satisfied: six>=1.4.1 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (1.11.0)
Requirement already satisfied: cffi!=1.11.3,>=1.7 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (1.10.0)
Requirement already satisfied: enum34 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (1.1.6)
Requirement already satisfied: ipaddress in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (1.0.22)
Requirement already satisfied: pycparser in g:/msys32/mingw32/lib/python2.7/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=2.1.4->-r requirements.txt (line 11)) (2.19)
Installing collected packages: click, pyelftools
Successfully installed click-7.1.2 pyelftools-0.27

编译工程

设置环境变量

因为我们使用的是msys32的虚拟环境,所以我们只要设置msys32的虚拟环境变量即可,不需要设置windows的环境变量。这样正好可以让我们在window系统下同时兼容esp32和esp8266的开发环境。
修改/home/xxx[用户]/.bashrc

新增:

export IDF_PATH=~/esp/ESP8266_RTOS_SDK
export PATH=/opt/xtensa-lx106-elf/bin:$PATH

检验环境变量:
重新打开mingw32.exe,执行

xtensa-lx106-elf-gcc -v
# xtensa-lx106-elf-gcc -v
Using built-in specs.
COLLECT_GCC=G:\msys32\opt\xtensa-lx106-elf\bin\xtensa-lx106-elf-gcc.exe
COLLECT_LTO_WRAPPER=g:/msys32/opt/xtensa-lx106-elf/bin/../libexec/gcc/xtensa-lx106-elf/8.4.0/lto-wrapper.exe
Target: xtensa-lx106-elf
Configured with: /builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=i686-host_w64-mingw32 --target=xtensa-lx106-elf --prefix=/builds/idf/crosstool-NG/builds/xtensa-lx106-elf --with-local-prefix=/builds/idf/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf --with-headers=/builds/idf/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG esp-2020r3-49-gd5524c1' --disable-__cxa_atexit --enable-cxx-flags=-ffunction-sections --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/buildtools/complibs-host --with-mpfr=/builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/buildtools/complibs-host --with-mpc=/builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/buildtools/complibs-host --with-isl=/builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/buildtools/complibs-host --enable-lto --enable-target-optspace --without-long-double-128 --disable-nls --enable-multiarch --enable-languages=c,c++ --disable-libstdcxx-verbose --enable-threads=posix --enable-libstdcxx-time=yes
Thread model: posix
gcc version 8.4.0 (crosstool-NG esp-2020r3-49-gd5524c1)

下载最新代码

务必git pull,不要zip解压,windows下很多隐藏文件容易出问题

git pull https://github.com/espressif/ESP8266_RTOS_SDK.git

menuconfig

进入需要编译的工程例子目录

make menuconfig

进行必要的配置。为了接下来的下载,我们需要配置串口:Serial flasher config > Default serial port,根据实际的串口来配置。

On Windows, serial ports have names like COM1. On MacOS, they start with /dev/cu.. On Linux, they start with /dev/tty

编译

make

# make
Toolchain path: /opt/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
Toolchain version: esp-2020r3-49-gd5524c1
Compiler version: 8.4.0
Python requirements from G:/msys32/home/zcj/esp/ESP8266_RTOS_SDK/requirements.txt are satisfied.
App "wifi_softAP" version: v3.4-28-g08e225dd
To flash all build output, run 'make flash' or:
python /home/zcj/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 2MB 0x0 /home/zcj/esp/ESP8266_RTOS_SDK/examples/wifi/getting_started/softAP/build/bootloader/bootloader.bin 0x10000 /home/zcj/esp/ESP8266_RTOS_SDK/examples/wifi/getting_started/softAP/build/wifi_softAP.bin 0x8000 /home/zcj/esp/ESP8266_RTOS_SDK/examples/wifi/getting_started/softAP/build/partitions_singleapp.bin

编译 & 下载

make flash

esp32 menuconfig 中Example Configuration及sdkconfig.h中宏的生成

在esp32的框架中,我们发现例子引用的sdkconfig.h在 build\config\ 目录下,因为build目录是生成的,所以我们很容易判断这个头文件也是动态生成的。

那么这个头文件的内容我们怎么控制呢?
经过验证,文件中大概分两类宏,用户自定义宏和硬件默认规格宏。用户自定义宏都是CONFIG_ESP_ 开头,其他的都是默认规格宏。

那么这些用户自定义宏又是在什么地方定义的呢,答案是 \main\Kconfig.projbuild 文件,这个文件是类似yaml的脚本,当你执行 idf.py menuconfig 时,会加载这个文件,进行对应的修改。

esp32 win7开发环境搭建

环境

系统:win7
hw target:esp32c3

注意:很多问题都跟git的网络有关,要仔细看错误提示。很多错误需要尝试多遍,才有可能成功。

安装包

离线包安装 https://dl.espressif.com/dl/esp-idf/?idf=4.4

更新最新代码

将安装的IDF_PATH更新成最新的git版本 https://github.com/espressif/esp-idf

更新submodule

git submodule update --init --recursive

安装python virtual environment

install.bat

设置环境变量

export.bat

编译工程

设置hw 平台类型

idf.py set-target esp32c3

错误1:

Unable to checkout '4f5e89fa84ce1d178a6765b8b46f2b6f91216677' in submodule path 'components/libsodium/libsodium'

解决1:
看日志是git无法成功,我们改为手动git pull,如果提示 openssl 10054错误。则

git config --global http.sslVerify "false"

其后还有很多的失败,基本需要逐个确认,多次执行

git submodule update --init --recursive

配置成功

-- Configuring done
-- Generating done
-- Build files have been written to: G:/esp/esp-idf/examples/wifi/getting_started/softAP/build

菜单配置

idf.py menuconfig

component config->esp32c3-specific,选择rev 2:
file

编译成功

idf.py build
[84/85] Generating binary image from built executable
esptool.py v3.1-dev
Merged 1 ELF section Generated G:/esp/espidf/examples/wifi/getting_started/softAP/build/bootloader/bootloader.bin
[85/85] cmd.exe /C "cd /D G:\esp\espidf\examples\wifi\getting_started\softAP\build\bootloader\esp-idf\esptool_py &&g:\esp\espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe G:/esp/espidf/components/partition_table/check_sizes.py --
offset 0x8000 bootloader 0x0 G:/esp/espidf/examples/wifi/getting_started/softAP
/build/bootloader/bootloader.bin"
Bootloader binary size 0x48a0 bytes. 0x3760 bytes (76%) free.
[954/955] Generating binary image from built executable
esptool.py v3.1-dev
Merged 1 ELF section
Generated G:/esp/esp-idf/examples/wifi/getting_started/softAP/build/wifi_softAP.bin
[955/955] cmd.exe /C "cd /D G:\esp\esp..._started/softAP/build/wifi_softAP.bin"
wifi_softAP.bin binary size 0xa3490 bytes. Smallest app partition is 0x100000 by
tes. 0x5cb70 bytes (36%) free.

Project build complete. To flash, run this command:
g:\esp\espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe ..\..\..\..\comp
onents\esptool_py\esptool\esptool.py -p (PORT) -b 460800 --before default_reset
--after hard_reset --chip esp32c3  write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x0 build\bootloader\bootloader.bin 0x8000 build\partition_
table\partition-table.bin 0x10000 build\wifi_softAP.bin
or run 'idf.py -p (PORT) flash'

烧录

idf.py -p COM105 flash
esptool.py v3.1-dev
Serial port COM105
Connecting....
Chip is ESP32-C3 (revision 2)
Features: Wi-Fi
Crystal is 40MHz
MAC: 7c:df:a1:86:4a:94
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00010000 to 0x000b3fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Compressed 18592 bytes to 11216...
Writing at 0x00000000... (100 %)
Wrote 18592 bytes (11216 compressed) at 0x00000000 in 0.6 seconds (effective 253
.8 kbit/s)...
Hash of data verified.
Compressed 668816 bytes to 372018...
Writing at 0x00010000... (4 %)
Writing at 0x0001bf69... (8 %)
Writing at 0x00025854... (13 %)
Writing at 0x0002c95b... (17 %)
Writing at 0x0003382e... (21 %)
Writing at 0x0003ae72... (26 %)
Writing at 0x00041d6a... (30 %)
Writing at 0x0004886c... (34 %)
Writing at 0x0004fb4e... (39 %)
Writing at 0x00056b56... (43 %)
Writing at 0x0005d1f1... (47 %)
Writing at 0x0006332e... (52 %)
Writing at 0x00068eeb... (56 %)
Writing at 0x0006f110... (60 %)
Writing at 0x0007537e... (65 %)
Writing at 0x0007b840... (69 %)
Writing at 0x00081ae0... (73 %)
Writing at 0x00087df9... (78 %)
Writing at 0x0008df30... (82 %)
Writing at 0x000945f7... (86 %)
Writing at 0x0009b5fe... (91 %)
Writing at 0x000a66e9... (95 %)
Writing at 0x000ae4bc... (100 %)
Wrote 668816 bytes (372018 compressed) at 0x00010000 in 11.2 seconds (effective
476.2 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 258.7
kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Done

擦除flash

idf.py erase_flash

查看日志

idf.py -p COMXXX monitor

esp32 windows environment issue of python requirements

pc系统:win7 x64

按照指导文档,无论是命令行安装还是msi安装,都一直卡在:

G:\esp\esp-idf-src\examples\wifi\getting_started\softAP>idf.py build
The following Python requirements are not satisfied:
pyserial>=3.0
future>=0.15.2
cryptography>=2.1.4
pyparsing>=2.0.3,<2.4.0
pyelftools>=0.22
gdbgui==0.13.2.0
pygdbmi<=0.9.0.2
reedsolo>=1.5.3,<=1.5.4
bitstring>=3.1.6
ecdsa>=0.16.0
esp-windows-curses; sys_platform == 'win32'
To install the missing packages, please run "G:\esp\esp-idf\install.bat"
Diagnostic information:
    IDF_PYTHON_ENV_PATH: D:\Programs\Python\Python38
    Python interpreter used: D:\Programs\Python\Python38\python.exe

ESP-IDF v4.2.1

解决:
python -m pip install --user -r \xxx\xxx\requirements.txt

docker Permissiissuon denied issue

realpath(): Permission denied
System.UnauthorizedAccessException: Access to the path '/app' is denied

同样的操作,在另一台同样系统版本的机器上正常。

确认了需要link的volume 目录权限,没有问题。

因为是权限问题,所以怀疑是否是selinux的问题,对比了下,确实不一样,是开启的。

尝试去disable

然后就正常了

centos6 repo update for the yum issue

yum 安装时报错:

YumRepo Error: All mirror URLs are not using ftp, http[s] or file.YumRepo Error: All mirror URLs are not using ftp, http[s] or file.

centos6 repo源一键修复:

sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo 
yum clean all
yum makecache

千牛操作纪要

开通花呗付款:交易管理=》分期管理=》花呗
关闭聊天机器人:
1)店铺管理=》子账号管理=》分流设置=》设置=》店铺服务助手。一个bug式的存在是因为阿里总是把在线客服状态判断为离线,所以如果你开启了旺旺分流里面的“离线分流”,你将仍然收到自动回复。
2)禁用店小蜜中的自动接待和智能辅助

淘宝多客服自定义代码

其中xxx是子账号的URL编码,根据实际需要自己填写:

<div class="tb-module tshop-um tshop-um-kfzx">
    <div>
         
    </div>
    <div class="kefu190">
        <div class="hd"></div>
        <div class="bd">
            <div class="one">
                <h3 style="border-bottom:1px solid #D8D8D8;" > 售前客服</h3>
                <ul>
                    <li style="width:145px;line-height:35px;overflow:hidden;" class="item item0">
                         <a target="_blank" href="http://amos.alicdn.com/getcid.aw?v=2&uid=xxx&site=cntaobao&s=1&groupid=0&charset=utf-8">
<img border="0" src="http://amos.alicdn.com/online.aw?v=2&uid=%E6%9E%81%E9%80%9F%E7%89%A9%E8%81%94%3A%E5%BC%A0%E5%85%88%E7%94%9F&site=cntaobao&s=1&charset=utf-8" alt="给我发消息" /></a> <b style="margin-top:5px;width:30px;height:15px;right:3px;top:1px;"> AAA </b>
                    </li>
                </ul>
            </div>
            <div class="one">
                <h3 style="border-bottom:1px solid #D8D8D8;"> 售后客服</h3>
                <ul>
                    <li style="width:145px;line-height:35px;overflow:hidden;" class="item item0">
                         <a target="_blank" href="http://amos.alicdn.com/getcid.aw?v=2&uid=xxx&site=cntaobao&s=1&groupid=0&charset=utf-8">
<img border="0" src="http://amos.alicdn.com/online.aw?v=2&uid=%E6%9E%81%E9%80%9F%E7%89%A9%E8%81%94%3A%E8%82%96%E5%85%88%E7%94%9F&site=cntaobao&s=1&charset=utf-8" alt="给我发消息" /></a> <b style="margin-top:5px;width:30px;height:15px;right:3px;top:1px;"> BBB </b>
                    </li>
                </ul>
            </div>
            <div class="onez" style="padding-bottom:5px;padding-left:0px;margin-left:0px;width:100%;">
                <ul>
                    <h3 style="border-top:1px solid #D8D8D8;border-bottom:none;margin-bottom:0px;padding-top:8px;width:100%;"> 工作时间:9:00-18:00</h3>
                    <li style="height:46px;margin:0;padding-top:5px;width:100%;color:#888;background:none;line-height:23px;text-align:center;">
                         周日和法定节假日休息
                        <p style="color:#888;">只接单不发货</p>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

certbot renew errors

certbot renew时,突然出错:

ImportError: cannot import name UnrewindableBodyError

尝试安装更新:

pip install requests urllib3 pyOpenSSL --force --upgrade

安装后,依然有错:

pkg_resources.DistributionNotFound: The 'urllib3<1.23,>=1.21.1' distribution was not found and is required by requests

从提示看是urllib3版本不满足要求导致的问题,尝试安装最新版:

pip install urllib3
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: urllib3 in /usr/local/lib/python3.9/site-packages (1.21.1)

安装完最新的1.21.1 错误提示依然,说明还需要处理路径的问题。

首先需要找到的是目前到底是哪个版本,哪个路径?

find / -name "urllib3-*"
/usr/lib/python2.7/site-packages/urllib3-1.10.2-py2.7.egg-info
/usr/local/lib/python3.6/site-packages/urllib3-1.23-py3.6.egg
/usr/local/lib/python3.6/site-packages/urllib3-1.21.1-py3.6.egg
/usr/local/lib/python3.6/site-packages/urllib3-1.25.11.dist-info
/usr/local/lib/python3.9/site-packages/urllib3-1.21.1.dist-info

从上面的后缀看基本都是大于1.21的,那么当前系统索引的应该就是 urllib3-1.10.2 这个版本了。

解决

问题分析清楚了,解决就很简单了。
将前面安装时提示的最新的1.21.1对应的相关文件 手动拷贝到 1.10.2 对应的路径就好了。
分别拷贝 urllib3 和 urllib3-1.21.1.dist-info 两个目录

再去测试 certbot renew, 一切恢复正常

unraid中使用docker安装Lychee荔枝相册

管理自己的私人照片,目前的选择是群晖的moments,偶然看到荔枝相册Lychee的效果,觉得做公开图片管理很合适,所以准备学习下。

github

https://github.com/LycheeOrg/Lychee
https://github.com/LycheeOrg/Lychee-Docker

准备工作

在宝塔中创建需要的数据库lychee。

docker安装

docker run -d --name lychee --link=baota -p 50003:80 --restart always -e DB_CONNECTION=mysql -e DB_HOST=baota -e DB_DATABASE=lychee -e DB_USERNAME=lychee -e DB_PASSWORD=xxx --network=myNetwork --ip 172.18.0.203 -v /mnt/user/appdata/lychee/conf:/conf -v /mnt/user/appdata/lychee/uploads:/uploads  -v /mnt/user/appdata/lychee/sym:/sym linuxserver/lychee

安装完,系统初始化要等一会儿,然后按照设置的端口登录。
第一次要设置帐户密码,然后就可以使用了。

版本更新

4.2.2发现有升级的问题,解决办法就是删了image重新装,因为数据都在本地和数据库,所以更新后数据没问题。

群晖moments的正确玩法

很多人装黑群晖就是因为看了网上推荐的photo station+moments的文章。

之所以这里说正确玩法,因为网上大部分推荐的photo station+moment的玩法是不合适的,或者说不是最佳的方案。

从群晖官方对moments的定位看,drive是和moments强绑定的,但photo station不是,看目录结构就能看出来:
file

我们推荐的正确基本玩法是drive+moments,也就是官方默认配置,高级玩法是drive+resilio sync+moments+sync(resilio/cloud)。

为什么说photo station方案不是最佳?

  • 我们先说下网上推荐的moments+photo station的方案。这个方案需要在moments开启“共享照片库”,然后在首页的左上角就会出现下拉框,多出来一个“共享照片库”的选项,对于有强迫症的人就会觉得不爽,因为你需要选一下,才能看到共享照片库里面的内容。当然如果你用相册模式,从不care照片模式,也许这个也不算什么大问题。

  • 其次,用photo station主要是为了规避moments按照日期归档的毛病,在photo station中可以手动归档,不会显得凌乱,这个作用完全被Drive替代了,在drive下的moments目录里面手动整理照片,就可以在moments直接看了。

  • drive是系统默认的组件,而photo station是一个独立的应用,需要额外安装,就显得多余了。

高级用法

上面提到的只是一套照片管理的方法,但是你还是需要把内容拷贝到drive下才可以,因为群晖大部分人可能是虚拟机安装的,把文件直接放到虚拟机里面我们是不放心的,所以我们的照片的实际源头在unraid下面,这样容量问题我们就不甚care了,unraid下全部磁盘空间可见,随时可以扩容。所以最后我们还要个能把unraid下内容同步到群晖中drive中的方案。

我们首先想到的是群晖原生支持的webdav方案,但是unraid不是原生支持的,需要自己安装app,自己搜索安装app后,结合cloud sync可以实现自动同步的效果,但是发现因为webdav的部署,unraid的照片路径的权限被破坏了,samba不能正确访问这些目录了,所以最终这个方案被毙。

然后就出现了我们上面提到的resilio sync方案,按照说明部署后,发现功能正常,也没有权限的问题。

至此,drive+moments+resilio sync已经可以解决本地或者局域网的问题了,但是对于google相册,百度云和其他在线云盘相册的照片,我们怎么同步呢,这里我们就要用cloud sync了。所以最终的方案就是drive+moments+resilio sync+cloud sync,兼顾本地存储和各种云盘,我们所有所有的照片都可以在moments中出现了,也不会破坏原始内容,不用担心群晖虚拟机出故障后,珍贵的照片丢失的风险。

resilio-sync 设置

同步源地址


file
file
拷贝以上地址,后面设置同步的目的地址时需要。

同步目的地址


file
这里需要填的就是上面拷贝的地址。

设置成功后,就能看到同步状态和日志:
file

chrome 实时翻译插件

如果你想练英语,啃英语生肉,这个是个轻量级的很好的选择。体验了下,目前针对英语,准确性还好。

安装:
chrome://flags/#enable-accessibility-live-captions

Live Caption =》enable

安装后重启浏览器。

然后在高级=》无障碍=》字幕中进行设置

卡西欧GA-140GB-1A1表盘功能及相关符号说明

如果有强迫症,相信第一次拿到这个表应该有点挠头,因为很多显示符号和表盘元素看不懂。

手表表盘

GA-140GB-1A1

手表功能的在线视频
https://www.casio.com.cn/support/guidevideo/wat/GA-140.html

表盘符号

  • STW:秒表
  • SNZ:间歇闹铃标识
  • SIG:整点提示标识
  • AL :闹铃标识
  • LAP:间断计时
  • SPL:中途计时
  • DST:夏令时
  • LT :自动照明标识

FAQ

  • 如何激活表盘上面的LT标识?
    这个视频没有讲,但是附送的手册里面有讲,那就是长按reverse按键(B)三秒激活。

  • 如何设置亮屏时间?
    默认按下B键,亮屏1.5s。系统提供LT1 LT3两种模式,LT1表示亮屏1.5秒,LT3表示亮屏3秒。
    如何设置:计时模式下-》长按A->按C-》循环按C-》出现LT1时-》按D进行设置-》按A-》回到计时模式

  • 表盘上面的速度区段和速度指针怎么计算速度?
    这个手册里面没官方视频里面也没有讲,所以稍微多花了点时间才弄清楚。
    区段和速度指针是组合的关系,单位是KM/h,区段表示整百部分的数值,指针表示100以内的部分。这个功能是跟秒表功能一起展示的,所以当你发现开启秒表功能时,指针和区段指示就会变化。
    这里测试的模型是假设你跑完1公里(出厂默认,可以自己设置,如果设置了,下面讲的计算方法也要对应调整)所用的秒数。
    速度计可用于计算经过一公里所需要的时间(60 秒内),然后用得到的结果来确定大致的平均(小时)速度。
    假设你1KM,用了11.039s,计算出来是326.116KM/h,那么速度区段部分就是3块,表示300,指针是26左右,整体表示326km/h。

W600/W800之WebServer页面修改

在路径 \Src\App\web 下我们能看到相关的web页面,是一些简单的web配置页面。

需要修改时,参考:http://www.wdyichen.cn/?log=blog&id=68

文中写的已经算比较清楚了,需要补充的是,除了文章中提到的makefs还有另外一个命令goall,这些都是linux 脚本,需要在linux环境下执行,区别也很简单,自己点看看内容就能明了。

原文引用:

web server也即http server,在w600官方sdk中默认就有一个,主要被用来softap下网页配网,遗憾的是官方一点没有其webserver二次开发的教程,大多数小白朋友看着那个丑陋的网页完全无法下手修改,所以本文就以web server如何进行二次开发来一番介绍。

先说下这种嵌入式webserver的特点,因为w600没有文件系统,而通常我们用的webserver都是要访问server根目录下的网页文件的,所以这个webserver就对网页文件做了一点特殊处理,那就是直接把网页文件转化成c语言的数组在编译时直接编进代码中去,这样就相当于形成了一个内存文件系统,webserver在收到访问请求时,直接在内存中查找到这个网页文件,回馈给用户。当然你也可以拿spi flash或者tf/sd这些搞个实际的文件系统,本文不在讨论。

webserver主要就是前端的网页式样和后端的代码处理。其源码在在Src/App/web目录下,这里面像web.c、httpd.c、fs.c是代码实现,而fs_ap_config这种文件夹下存放的是网页(或者其它的fs*文件)。

所以当你想修改网页式样的时候,就在fs文件夹下的网页中去改,改完之后,使用web目录下的那个makefs脚本把网页转化为c数组。如:./makefs ./fs_ap_config ./fsdata_ap_config.c(当然最后面的./fs_ap_config.c可以不写就会默认生成一个叫fsdata_lwip.c的文件),最后不管你起的啥名或者用默认的名字,只要你把它在fs.c中这个地方:#include "fsdata_ap_config.c"填写的名称保持一致就行。最后我想说的是这个makefs脚本是需要在shell环境下去执行,是linux这种shell环境,不是windows下的cmd里面搞。还有就是修改网页的时候,最好不要改的太大,要考虑嵌入式资源,如果你把网页搞得太大,c数组也就很大,最后搞出来的w600固件也就很大而没法烧进去了。

改完网页之后,通常你的网页不会只是一个静态显示页面,总会需要显示一点实时信息,更有甚者还需要交互操作,所以还需要改webserver让其支持你的各种表单请求交互操作。这个webserver仅支持最简单的html,所以网页交互就是靠html 表单了,如果你对表单的概念一脸懵逼不懂我在说啥,那么我建议你花十来分钟去看看html语法,这是世界上最简单的语法了,学会它你才能进行下一部开发。

访问网页时,必然会走到这里Web_parse_line,所以网页被访问时,需要读取的实时数据就是在这里更新的;当表单提交之后,必然会走到这里do_cgi_webindex,所以需要更新给模块的数据都是在这里进行解析处理。这里需要注意web_id_tbl这个表,其IdName就是用来和网页中的各id进行匹配的所以要填一样,Value_Offset是数出来的长度如果不是固定的那我建议直接填个0起调更快捷。

最后,启动webserver就是使用httpd_init,停止就使用httpd_deinit。至于为啥不用tls_webserver_init,是因w600没有deinit我感觉比较别扭所以不想用~~~

find issue in windows command line

编译rda8910的代码时,突然提示错误,之前都是正常的:

find: ‘/I’: No such file or directory
find: ‘;xxxx\\..\\prebuilts\\win32\\bin;’: No such file or directory

先根据 /I 的关键字,在项目找到了对应的命令行:

(echo ";%PATH%;" | find /C /I ";%1;" > nul) || set "PATH=%1;%PATH%"

很显然,出错的原因是 find 没有识别 /I 选项,导致 %1前面的;号被识别到了后面的有效路径上。

知道原因了,就有解决思路了:
用搜索工具搜了下整机,找到不同路径的几个版本的find.exe,然后针对不同的find 用 /I 进行测试,发现c盘系统路径下的正常,而Git 下的find会提示跟上面错误类似的提示,基本判断find可能因为环境变量的原因使用的是Git下对应的版本。

解决

把不不出错的find.exe的版本的路径加到 Path 环境变量里:

C:\Windows\SysWOW64;C:\Windows\System32;

退出当前命令行,重进,再编译,正常了。。。

windows7禁用管理员批准模式

环境

windows7,windows10 不一定适用。

问题

不知道是不是被电脑管家修改的缘故,突然之间很多的程序执行都需要右键管理员权限才可以。
导致的一个问题是,很多编译脚本调用的工具或者命令行,都会提示没有权限,出现大量告警日志。

禁用

secpol.msc =》本地策略=》安全选项=》
用户控制:以管理员批准模式运行所有管理员

设置成禁用,然后重启

如何在unraid的linux vm中安装群晖synology

参考

  1. https://post.smzdm.com/p/az50d36r/
  2. https://www.bilibili.com/video/av86018391/
    以上两个内容关于系统安装主要不一样的地方是vDisk Bus的选择,一个选的是USB,一个推荐的是SATA,这个需要网友们根据自己配置,自己确认下哪个合适。

安装盘

  1. img 引导盘
  2. pat 系统盘
    具体下载点可以网上自己找,有很多不同的版本。

要点

  1. 在xml下改网卡model type 为e1000。
  2. 安装成功的界面是这个:
    file
    这个只是表示系统起来了,但是你能不能通过默认的5000端口访问还不一定,比如你的网卡配置不对等。
  3. 通过Synology Assistant工具或者 http://find.synology.com/ 在线扫描,寻找有效的群晖主机IP。

只知道一个手机号,如何对其定位?[骗局揭秘]

现实中,一些人受影视剧影响,想通过电话号码定位一个人,结果被各种套路,骗了钱,还影响了心情。所以今天很有必要就这种骗局做些介绍,避免有更多的人受骗。因为除了大众能感受到的金钱的受骗,其实还有一个更重要的危害就是隐私位置泄露。

在网上搜索"手机号定位",能搜出来很多号称只要输入手机号,就能定位对方位置的网站或者APP,很多网站看似很正规,app也评价好几万,很多网友因为不了解技术原理,所以心存侥幸,于是就放松了警惕,上当受骗。

一般这种网站和APP刚开始都是免费的,骗你试用,你发现根本不好用后,对方就通过提示暗示或者客服电话诱导你付费升级,因为你心存幻想,也很着急,于是就被诱导着各种充值,于是很多人就交了费,最后发现被骗了,但一切都晚了,客服电话没人接或者微信qq被拉黑。

那么从科学技术原理上,只通过手机号能精准定位吗(这里说的是只有一个手机号,跟基站定位技术没关系,因为基站定位技术还是要获取基线相关的运营商和小区号等,不是我们讨论的单单只有手机号而已)?

答案是,对国家或者有关部门和电信运营商可以,但对普通人答案是否定的。

一般套路是这样的,你通过搜索引擎关键字被诱导下载某个app或者进入某个网址页面,然后输入你想要定位的人的电话号码,想知道这个手机号码主人当前的位置,实际操作时却被套路一步步诱骗。而且即使你交了钱,也发现根本定不到真实位置,或者定出来一个没有意义的地址。

怎么回事?市面上凡是声称能通过手机号码查到对方位置的,前提是要对方曾经因为某种原因使用过这个APP软件或者网站,泄漏了位置,你才可能查到对方当时泄漏的位置。这种软件或者网站在提供所谓定位别人的功能的同时,会要求使用人开启位置权限,私自收集使用者位置暴露给第三方查询。你查别人的位置时,同时也就上传了你自己的位置。同时,所谓的能定位,只是碰概率,理论上你查到了,也不是实时的,只是大概的老旧时间位置,如果查不到,平台或者APP收集了你的位置,也许别人就可以查到你了。总之这种平台或者软件要么骗到你的钱,要么收集到你的隐私位置,供别人查询。

所以这种软件千万不要碰,这种软件都是利用大家不懂技术原理猎奇的心里,对技术存在幻想,贩卖大家的隐私。应避之,弃之,抵制之。

如果有人说收钱帮你定位,就更要警惕了,能做到这个的只有电信内部系统和国家相关部门了,不要心存幻想,才能从根本避免被骗。

最后希望大家明白能对对方定位的唯一方式,都是双方安装同样的定位软件,并且对方同意位置授权和数据网络权限,这样才能获取到对方的位置,比如我们日常使用的微信位置分享功能,这个也是建立在对方安装了微信这样的app的前提下并且同意加为好友,才能定位的,而不是只知道对方一个电话号码,就幻想能定位。苹果 APP store有很多类似的定位软件,但是真正好用的寥寥,需要大家仔细去甄选和验证,然后双方共同使用,成为好友,授权合法使用位置。

好了,技术原理就讲到这里了,不知道是否大家都明白其中的原理了。

如果你因为看到了本文,而避免一次可能的受骗,可以告诉小编,也让小编一起高兴和欣慰下。

unraid 增加Docker磁盘空间

默认20G,所以没用多久,你就会看到类似的提示:

Docker image disk utilization of 93%
Docker utilization of image file /mnt/user/system/docker/docker.img

container瘦身

docker system prune --all --volumes

这样会瘦身些,但是一般小不了多少。

增大image size

在unraid 主界面:settings-->docker
Enable Docker 选择No,在Yes时,你无法看到设置size的选项。
file

修改后,告警消失了:)

unraid环境下用koel搭建自己的家庭音乐库

koel是一个可以将本地音乐展示为在线web服务形式的php框架:https://koel.dev/

刚开始参考 https://post.smzdm.com/p/a3gv68v7/
发现pc上的web正常,但是手机端不行,因为版本不是最新的,初步猜疑是不是版本太旧的bug。

本来想自己弄一个最新版的docker版本,后面发现https://hub.docker.com 上有活跃的最新版本:https://hub.docker.com/r/hyzual/koel/

准备工作,设置自定义网络

为了确保宝塔的ip不会变动,保证数据库的稳定访问,我们需要创建自定义网络:

docker network create --subnet=172.18.0.0/16 myNetwork

创建后可以用 docker network ls来查看,如果已经创建,则进行下一步。

把baota加进自定义网络

docker network connect --ip 172.18.0.200 myNetwork baota

添加完成后可以用 docker inspect baota来确认,同时在另一个docker中来ping 172.18.0.200这个地址,确认是否能ping通。

安装

上面的网络确认好了后,就可以真正安装了:

docker run -d --name koel --link=baota -p xxx:80 --privileged=true --restart always -e DB_CONNECTION=mysql -e DB_HOST=baota -e DB_DATABASE=xxx -e DB_USERNAME=xxx -e DB_PASSWORD=xxx --network=myNetwork --ip 172.18.0.201 -v /mnt/user/media/music/songs:/music -v /mnt/user/media/music/covers:/var/www/html/public/img/covers -v /mnt/user/media/music/search_indexs:/var/www/html/storage/search-indexes hyzual/koel

这里连接了第三方的docker,用于数据库支持。因为我自己的是用的宝塔里面的mysql数据库,所以里面设置了相关的参数:
--link=baota

数据库访问参数:
DB_CONNECTION=mysql -e DB_HOST=baota -e DB_DATABASE=xxx -e DB_USERNAME=xxx -e DB_PASSWORD=xxx

网络设置,保证和数据库docker使用共同的自定义网络:
--network=myNetwork --ip 172.18.0.201

也可以用官方的docker镜像,经过测试也是可以正常:

docker run -d --name koel \
    -p xxx:80 \
    -e DB_CONNECTION=mysql \
    -e DB_HOST=baota \
    -e DB_DATABASE=koel \
    -e DB_USERNAME=koel \
    -e DB_PASSWORD=xxx \
    --network=myNetwork  \
    --ip 172.18.0.201 \
    -v /mnt/user/media/music/songs:/music \
    -v  /mnt/user/media/music/covers:/var/www/html/public/img/covers \
    -v /mnt/user/media/music/search_indexs:/var/www/html/storage/search-indexes \
    phanan/koel

安装后需要进入docker内部,执行初始账号初始化:

#php artisan koel:init --no-assets
Attempting to install or upgrade Koel.
Remember, you can always install/upgrade manually following the guide here:
📙  https://docs.koel.dev

App key exists -- skipping
Migrating database
Creating default admin account
Seeding initial data
The absolute path to your media directory. If this is skipped (left blank) now, you can set it later via the web interface.

 Media path [/music]:
 > 

🎆  Success! Koel can now be run from localhost with `php artisan serve`.
Log in with email xxx@koel.dev and password xxxxxx
You can also scan for media with `php artisan koel:sync`.
Again, visit 📙 https://docs.koel.dev for the official documentation.
Feeling generous and want to support Koel's development? Check out https://github.com/users/phanan/sponsorship 🤗
Thanks for using Koel. You rock! 🤘

安装完成后,按照设定的端口去访问,出现熟悉的首页。

默认账户:admin@koel.dev
默认密码:KoelIsCool

安装要点

  1. 需要的keol数据库,访问权限刚开始要设置成“所有人”。等安装成功了,再将访问权限设置成“指定IP”,比如示例docker对应的ip 172.18.0.201

版本更新

默认unraid界面的更新链接是无法更新的,会提示:

Configuration not found. Was this container created using this plugin?

解决的办法就是把image删掉,重新run。因为你的数据都在数据库,所以更新后,不会影响数据。

源码安装gcc9.3.0

环境

centos7

准备工作

yum install zstd

yum install glibc-headers
yum install gcc-c++

预下载

https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz

解压后进入目录,启动预下载,可能会很慢,或者卡死:
./contrib/download_prerequisites

后面发现下载bz2文件都提示无法解压,可能是工具环境的问题,也可能是下载完整性问题。

于是改为手动下载最新版:

https://mirrors.sjtug.sjtu.edu.cn/gnu/gmp/gmp-6.2.1.tar.zst
https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz
https://mirrors.sjtug.sjtu.edu.cn/gnu/mpc/mpc-1.2.1.tar.gz
http://isl.gforge.inria.fr/isl-0.23.tar.gz

zst文件解压: tar -I zstd -vxf xxxx

改名

解压后,都改成不带后缀版本的文件名,比如 gmp mpfr

编译

./configure --prefix=/usr/local/gcc --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release  --enable-plugin --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux --disable-multilib

make

目标文件替换

编译完成后,所有目标文件都是在prefix路径下,但是系统环境可能还是旧的。这时需要升级替换。
主要有:

bin => /usr/bin
lib => /usr/lib/gcc/x86_64-redhat-linux/9.3.0/
lib64 => /usr/lib64
libexec => /usr/libexec

玩转NAS之搞清楚端口映射

玩NAS的因为解决外网访问的问题,经常需要将外网映射成内网。

如果你用的是unraid, 那么大部分的软件都是通过docker的方式安装的,也不可避免的要映射端口,将本地局域网端口映射成docker 内部应用的服务端口。

这里就有3层端口:外网->内部局域网->docker内部
两层映射:一次在路由器上映射,一次在启动docker时映射。

搞清楚了这3层端口两层映射行为,那么大部分的网络问题就都能迎刃而解。

宝塔面板中phpmyadmin404问题

宝塔是一套web面板,类似于webmin。

我们在unraid中安装后,一般都会套件安装 nginx,php,mysql,phpmyadmin等。

使用中在mysql页面点击phpMyAdmin按钮时,提示404:
http://192.168.x.x:123/phpmyadmin_94fece33f6f785c2/index.php

然后登录进baota daocker里面,确认了下nginx的配置文件。找到了nginx 123 server的root,发现是对应的路径问题。

解决

既然定位了原因,那么解决就很简单了,对症下药,通过ln -s 源 目的 创建目录的软连接。

OK...

enable clang-format in VSC

之前的环境都是好用的,一次深度垃圾清理后,发现所有配置和clang-format都不好用了。

clang-format要起作用:

  1. 装clang-format插件
  2. 装clang-format.exe,这个需要安装LLVM或者 cpptools插件
  3. 正确的配置文件

安装

  1. 安装clang-format 插件。xaver出品那个
  2. 配置Clang-format: Executable 有效路径。

配置

网上配置很多,只列举几个比较重要的:

配置vsc用的格式化工具为clang-foramt

  • Default Formatter(editor.defaultFormatter)

clang-format.exe路径配置

Clang-format:Executable(clang-format.executable)

保存文件自动格式化文件

  • format on save(editor.formatOnSave):yes
  • Format On Save Mode:file(默认)

格式的控制文件

方式1: 填写file。表示在项目根目录下搜索.clang-format
方式2: 修改VSC的Clang_format_style属性,直接填入键值对,也就是.clang-format的有效内容,这样就相当于全局配置文件了:

BasedOnStyle: LLVM
BreakBeforeBraces: Linux
Language: Cpp
ColumnLimit: 120
ReflowComments: false
SortIncludes: false
BreakBeforeBraces: Custom
BraceWrapping:
  AfterEnum: false
  AfterStruct: false
  SplitEmptyFunction: false
AlignConsecutiveAssignments: true
AlignConsecutiveMacros: true
AllowShortFunctionsOnASingleLine: None

windows touchpad driver

型号:151SK lenovo

最近深度清理后,发现鼠标的控制面板管理touchpad标签页不见了,touchpad无法禁用,一直在打字过程中光标乱飞。

找了lenovo的151sk的驱动页面,找了对应的touchpad驱动,不好用。

这个是显示win10的,也不是针对151sk的,但是实际测试可用:
ce0j06af.exe

通过nginx无插件方式实现git hook的方式

git hook 是一种很有用的方式。

一般的实现就是在本地开启一个监听hook url的http server,然后对url进行处理。

因为很多服务器都有nginx作为web server,所以我们优先考虑如何利用nginx。

一般网上比较多的推荐是用nginx的衍生版本openresty,通过lua来实现。

这里记录一个简单的思路:
通过nginx的lacation来匹配hook url特征,然后产生特定的access 或者error日志,然后通过脚本监控日志的变化,来判断是否有hook消息触发。这样nginx是现成的,且实现方法是无阻塞的,只要实现个一直监控文件大小的脚本就可以了,非常简单。

nginx部分简单配置

location /xxx/xxx/x {
        return 200 "xxx";
        access_log  /xxx.log;
    }

这里需要确认hook的触发是成功access还是失败error,才能正确的触发日志文件.

监控文件大小的脚本

这个脚本负责日志变化时,执行我们的git hook动作。

#!/bin/sh

# 要监控的文件
mfile=/xxx.log

#启动一个循环,定时检查文件是否存在
while true; do
    #监控文件大小
    fsize=`stat -c "%s" $mfile`
    if [ $fsize !=  1  ]; then
        echo "">$mfile
        echo "log file update"
        #TODO:需要的逻辑放这里
        ...
    fi
    sleep 5
done

监控脚本开机启动

脚本好了,然后就是要设置开机启动,否则服务器重启后,hook就失效了。
开机启动,有很多办法设置,比如最简单的rc.local脚本

Linux errno详解

存档文章。原始链接:https://www.cnblogs.com/Jimmy1988/p/7485133.html

Linux errno

  1. 错误码 / errno
    Linux中系统调用的错误都存储于 errno中,errno由操作系统维护,存储就近发生的错误,即下一次的错误码会覆盖掉上一次的错误。

PS: 只有当系统调用或者调用lib函数时出错,才会置位errno!

查看系统中所有的errno所代表的含义,可以采用如下的代码:

/* Function: obtain the errno string
*   char *strerror(int errno)
*/

#include <stdio.h>
#include <string.h>     //for strerror()
//#include <errno.h>
int main()
{
    int tmp = 0;
    for(tmp = 0; tmp <=256; tmp++)
    {
        printf("errno: %2d\t%s\n",tmp,strerror(tmp));
    }
    return 0;
}

输出信息如下:

errno:  0       Success
errno:  1       Operation not permitted
errno:  2       No such file or directory
errno:  3       No such process
errno:  4       Interrupted system call
errno:  5       Input/output error
errno:  6       No such device or address
errno:  7       Argument list too long
errno:  8       Exec format error
errno:  9       Bad file descriptor
errno: 10       No child processes
errno: 11       Resource temporarily unavailable
errno: 12       Cannot allocate memory
errno: 13       Permission denied
errno: 14       Bad address
errno: 15       Block device required
errno: 16       Device or resource busy
errno: 17       File exists
errno: 18       Invalid cross-device link
errno: 19       No such device
errno: 20       Not a directory
errno: 21       Is a directory
errno: 22       Invalid argument
errno: 23       Too many open files in system
errno: 24       Too many open files
errno: 25       Inappropriate ioctl for device
errno: 26       Text file busy
errno: 27       File too large
errno: 28       No space left on device
errno: 29       Illegal seek
errno: 30       Read-only file system
errno: 31       Too many links
errno: 32       Broken pipe
errno: 33       Numerical argument out of domain
errno: 34       Numerical result out of range
errno: 35       Resource deadlock avoided
errno: 36       File name too long
errno: 37       No locks available
errno: 38       Function not implemented
errno: 39       Directory not empty
errno: 40       Too many levels of symbolic links
errno: 41       Unknown error 41
errno: 42       No message of desired type
errno: 43       Identifier removed
errno: 44       Channel number out of range
errno: 45       Level 2 not synchronized
errno: 46       Level 3 halted
errno: 47       Level 3 reset
errno: 48       Link number out of range
errno: 49       Protocol driver not attached
errno: 50       No CSI structure available
errno: 51       Level 2 halted
errno: 52       Invalid exchange
errno: 53       Invalid request descriptor
errno: 54       Exchange full
errno: 55       No anode
errno: 56       Invalid request code
errno: 57       Invalid slot
errno: 58       Unknown error 58
errno: 59       Bad font file format
errno: 60       Device not a stream
errno: 61       No data available
errno: 62       Timer expired
errno: 63       Out of streams resources
errno: 64       Machine is not on the network
errno: 65       Package not installed
errno: 66       Object is remote
errno: 67       Link has been severed
errno: 68       Advertise error
errno: 69       Srmount error
errno: 70       Communication error on send
errno: 71       Protocol error
errno: 72       Multihop attempted
errno: 73       RFS specific error
errno: 74       Bad message
errno: 75       Value too large for defined data type
errno: 76       Name not unique on network
errno: 77       File descriptor in bad state
errno: 78       Remote address changed
errno: 79       Can not access a needed shared library
errno: 80       Accessing a corrupted shared library
errno: 81       .lib section in a.out corrupted
errno: 82       Attempting to link in too many shared libraries
errno: 83       Cannot exec a shared library directly
errno: 84       Invalid or incomplete multibyte or wide character
errno: 85       Interrupted system call should be restarted
errno: 86       Streams pipe error
errno: 87       Too many users
errno: 88       Socket operation on non-socket
errno: 89       Destination address required
errno: 90       Message too long
errno: 91       Protocol wrong type for socket
errno: 92       Protocol not available
errno: 93       Protocol not supported
errno: 94       Socket type not supported
errno: 95       Operation not supported
errno: 96       Protocol family not supported
errno: 97       Address family not supported by protocol
errno: 98       Address already in use
errno: 99       Cannot assign requested address
errno: 100      Network is down
errno: 101      Network is unreachable
errno: 102      Network dropped connection on reset
errno: 103      Software caused connection abort
errno: 104      Connection reset by peer
errno: 105      No buffer space available
errno: 106      Transport endpoint is already connected
errno: 107      Transport endpoint is not connected
errno: 108      Cannot send after transport endpoint shutdown
errno: 109      Too many references: cannot splice
errno: 110      Connection timed out
errno: 111      Connection refused
errno: 112      Host is down
errno: 113      No route to host
errno: 114      Operation already in progress
errno: 115      Operation now in progress
errno: 116      Stale file handle
errno: 117      Structure needs cleaning
errno: 118      Not a XENIX named type file
errno: 119      No XENIX semaphores available
errno: 120      Is a named type file
errno: 121      Remote I/O error
errno: 122      Disk quota exceeded
errno: 123      No medium found
errno: 124      Wrong medium type
errno: 125      Operation canceled
errno: 126      Required key not available
errno: 127      Key has expired
errno: 128      Key has been revoked
errno: 129      Key was rejected by service
errno: 130      Owner died
errno: 131      State not recoverable
errno: 132      Operation not possible due to RF-kill
errno: 133      Memory page has hardware error
errno: 134~255  unknown error!

Linux中,在头文件 /usr/include/asm-generic/errno-base.h 对基础常用errno进行了宏定义:

#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H

#define EPERM        1  /* Operation not permitted */
#define ENOENT       2  /* No such file or directory */
#define ESRCH        3  /* No such process */
#define EINTR        4  /* Interrupted system call */
#define EIO      5  /* I/O error */
#define ENXIO        6  /* No such device or address */
#define E2BIG        7  /* Argument list too long */
#define ENOEXEC      8  /* Exec format error */
#define EBADF        9  /* Bad file number */
#define ECHILD      10  /* No child processes */
#define EAGAIN      11  /* Try again */
#define ENOMEM      12  /* Out of memory */
#define EACCES      13  /* Permission denied */
#define EFAULT      14  /* Bad address */
#define ENOTBLK     15  /* Block device required */
#define EBUSY       16  /* Device or resource busy */
#define EEXIST      17  /* File exists */
#define EXDEV       18  /* Cross-device link */
#define ENODEV      19  /* No such device */
#define ENOTDIR     20  /* Not a directory */
#define EISDIR      21  /* Is a directory */
#define EINVAL      22  /* Invalid argument */
#define ENFILE      23  /* File table overflow */
#define EMFILE      24  /* Too many open files */
#define ENOTTY      25  /* Not a typewriter */
#define ETXTBSY     26  /* Text file busy */
#define EFBIG       27  /* File too large */
#define ENOSPC      28  /* No space left on device */
#define ESPIPE      29  /* Illegal seek */
#define EROFS       30  /* Read-only file system */
#define EMLINK      31  /* Too many links */
#define EPIPE       32  /* Broken pipe */
#define EDOM        33  /* Math argument out of domain of func */
#define ERANGE      34  /* Math result not representable */

#endif

在 /usr/include/asm-asm-generic/errno.h 中,对剩余的errno做了宏定义:

#ifndef _ASM_GENERIC_ERRNO_H
#define _ASM_GENERIC_ERRNO_H

#include <asm-generic/errno-base.h>

#define EDEADLK     35  /* Resource deadlock would occur */
#define ENAMETOOLONG    36  /* File name too long */
#define ENOLCK      37  /* No record locks available */
#define ENOSYS      38  /* Function not implemented */
#define ENOTEMPTY   39  /* Directory not empty */
#define ELOOP       40  /* Too many symbolic links encountered */
#define EWOULDBLOCK EAGAIN  /* Operation would block */
#define ENOMSG      42  /* No message of desired type */
#define EIDRM       43  /* Identifier removed */
#define ECHRNG      44  /* Channel number out of range */
#define EL2NSYNC    45  /* Level 2 not synchronized */
#define EL3HLT      46  /* Level 3 halted */
#define EL3RST      47  /* Level 3 reset */
#define ELNRNG      48  /* Link number out of range */
#define EUNATCH     49  /* Protocol driver not attached */
#define ENOCSI      50  /* No CSI structure available */
#define EL2HLT      51  /* Level 2 halted */
#define EBADE       52  /* Invalid exchange */
#define EBADR       53  /* Invalid request descriptor */
#define EXFULL      54  /* Exchange full */
#define ENOANO      55  /* No anode */
#define EBADRQC     56  /* Invalid request code */
#define EBADSLT     57  /* Invalid slot */

#define EDEADLOCK   EDEADLK

#define EBFONT      59  /* Bad font file format */
#define ENOSTR      60  /* Device not a stream */
#define ENODATA     61  /* No data available */
#define ETIME       62  /* Timer expired */
#define ENOSR       63  /* Out of streams resources */
#define ENONET      64  /* Machine is not on the network */
#define ENOPKG      65  /* Package not installed */
#define EREMOTE     66  /* Object is remote */
#define ENOLINK     67  /* Link has been severed */
#define EADV        68  /* Advertise error */
#define ESRMNT      69  /* Srmount error */
#define ECOMM       70  /* Communication error on send */
#define EPROTO      71  /* Protocol error */
#define EMULTIHOP   72  /* Multihop attempted */
#define EDOTDOT     73  /* RFS specific error */
#define EBADMSG     74  /* Not a data message */
#define EOVERFLOW   75  /* Value too large for defined data type */
#define ENOTUNIQ    76  /* Name not unique on network */
#define EBADFD      77  /* File descriptor in bad state */
#define EREMCHG     78  /* Remote address changed */
#define ELIBACC     79  /* Can not access a needed shared library */
#define ELIBBAD     80  /* Accessing a corrupted shared library */
#define ELIBSCN     81  /* .lib section in a.out corrupted */
#define ELIBMAX     82  /* Attempting to link in too many shared libraries */

#define ELIBEXEC    83  /* Cannot exec a shared library directly */
#define EILSEQ      84  /* Illegal byte sequence */
#define ERESTART    85  /* Interrupted system call should be restarted */
#define ESTRPIPE    86  /* Streams pipe error */
#define EUSERS      87  /* Too many users */
#define ENOTSOCK    88  /* Socket operation on non-socket */
#define EDESTADDRREQ    89  /* Destination address required */
#define EMSGSIZE    90  /* Message too long */
#define EPROTOTYPE  91  /* Protocol wrong type for socket */
#define ENOPROTOOPT 92  /* Protocol not available */
#define EPROTONOSUPPORT 93  /* Protocol not supported */
#define ESOCKTNOSUPPORT 94  /* Socket type not supported */
#define EOPNOTSUPP  95  /* Operation not supported on transport endpoint */
#define EPFNOSUPPORT    96  /* Protocol family not supported */
#define EAFNOSUPPORT    97  /* Address family not supported by protocol */
#define EADDRINUSE  98  /* Address already in use */
#define EADDRNOTAVAIL   99  /* Cannot assign requested address */
#define ENETDOWN    100 /* Network is down */
#define ENETUNREACH 101 /* Network is unreachable */
#define ENETRESET   102 /* Network dropped connection because of reset */
#define ECONNABORTED    103 /* Software caused connection abort */
#define ECONNRESET  104 /* Connection reset by peer */
#define ENOBUFS     105 /* No buffer space available */
#define EISCONN     106 /* Transport endpoint is already connected */
#define ENOTCONN    107 /* Transport endpoint is not connected */
#define ESHUTDOWN   108 /* Cannot send after transport endpoint shutdown */
#define ETOOMANYREFS    109 /* Too many references: cannot splice */
#define ETIMEDOUT   110 /* Connection timed out */
#define ECONNREFUSED    111 /* Connection refused */
#define EHOSTDOWN   112 /* Host is down */
#define EHOSTUNREACH    113 /* No route to host */
#define EALREADY    114 /* Operation already in progress */
#define EINPROGRESS 115 /* Operation now in progress */
#define ESTALE      116 /* Stale file handle */
#define EUCLEAN     117 /* Structure needs cleaning */
#define ENOTNAM     118 /* Not a XENIX named type file */
#define ENAVAIL     119 /* No XENIX semaphores available */
#define EISNAM      120 /* Is a named type file */
#define EREMOTEIO   121 /* Remote I/O error */
#define EDQUOT      122 /* Quota exceeded */

#define ENOMEDIUM   123 /* No medium found */
#define EMEDIUMTYPE 124 /* Wrong medium type */
#define ECANCELED   125 /* Operation Canceled */
#define ENOKEY      126 /* Required key not available */
#define EKEYEXPIRED 127 /* Key has expired */
#define EKEYREVOKED 128 /* Key has been revoked */
#define EKEYREJECTED    129 /* Key was rejected by service */

/* for robust mutexes */
#define EOWNERDEAD  130 /* Owner died */
#define ENOTRECOVERABLE 131 /* State not recoverable */

#define ERFKILL     132 /* Operation not possible due to RF-kill */

#define EHWPOISON   133 /* Memory page has hardware error */

#endif
  1. 打印错误信息
    1). 打印错误信息 / perror
    作用:
    打印系统错误信息

头文件:

include

函数原型:

void perror(const char *s)
参数:

s: 字符串提示符

输出形式:
const char *s: strerror(errno) //提示符:发生系统错误的原因
返回值:
无返回值
2). 字符串显示错误信息 / strerror
作用:
将错误码以字符串的信息显示出来

头文件:

include

函数原型:

char *strerror(int errnum);
参数:

errnum: 即errno

返回值:
返回错误码字符串信息

eclipse console build日志乱码

现象

windows中通过免安装eclipse工具包,编译时部分日志:

make[1]: 杩涘叆鐩綍鈥?/home/w600/project/w600_sdk/app鈥?
make[1]: 绂诲紑鐩綍鈥?/home/w600/project/w600_sdk/app鈥?
make[1]: 杩涘叆鐩綍鈥?/home/w600/project/w600_sdk/demo鈥?
make[2]: 杩涘叆鐩綍鈥?/home/w600/project/w600_sdk/demo/console鈥?
make[2]: 绂诲紑鐩綍鈥?/home/w600/project/w600_sdk/demo/console鈥?
make[1]: 绂诲紑鐩綍鈥?/home/w600/project/w600_sdk/demo鈥?
make[1]: 杩涘叆鐩綍鈥?/home/w600/project/w600_sdk/platform/boot/gcc鈥?
make[1]: 绂诲紑鐩綍鈥?/home/w600/project/w600_sdk/platform/boot/gcc鈥?

定位

首先根据make[1]在全工程搜索,根据搜出的内容对比,大概知道乱码的部分内容是“进入目录”和“离开目录”, 尾部的是中文的双引号。所以基本可以知道内容是对的,只是UTF8的中文支持问题了。

解决

  • 网上的方案1:在eclipse中修改相关的配置,修改为UTF8,无效。
  • 网上的方案2:在eclipse.ini 中增加-Dfile_encoding=UTF-8。这个思路应该时对了,但是在我本地无法生效,应该是eclipse目录中的eclipse.ini没生效,具体原因,没有细究。
  • 可用的方案3:最终的方案就是在windows系统环境变量中增加:JAVA_TOOL_OPTIONS,值为:-Dfile_encoding=UTF-8。由此联想 通过启动命令脚本带参数的方式应该也可以。

CD walkman D-EJ785

淘了个D-EJ785,来听一些买来的唱片CD。

关机

没有关机键,按下停止键(实心方块)后,就相当于关机了,可以进行CD或者电池操作。

G-PROTECTION

G-PROTECTION:防止声音跳动,这个一般是机器震动后者光盘划伤造成。

AVLS

AVLS:AVLS即自动音量限制系统的简称。它的作用就是:控制音量,避免用户在使用耳机收听音乐时因音量过大而导致听力受损。设定为limit时,保护听力,限制最大音量。

MODE

1:单首播放
SHUF:随机播放
PGM:按照喜欢顺序播放

SOUND

BASS1/2:加强的低音模式,BASS2比BASS1低音强

echo命令行和网页方式下base64编码不一致问题

发现的问题

同样的测试内容:chabctimes
在centos7下面:

# echo "chabctimes"|base64
Y2hhYmN0aW1lcwo=

在线测试平台 https://tool.oschina.net/encrypt?type=3 测试如下:

Y2hhYmN0aW1lcw==

根据第三方的验证,下面的内容是通过验证可以正常用的,上面的不行。从对比看,下面跟上面的结果比较,末尾倒数第2个字符一个是=一个是o

分析

一阵g搜索,再结合只有尾部一个字符差异,而且所有内容都是倒数第二个差异,所以初步猜测可能是尾部回车换行的差异导致。
经过不同内容的验证,基本确认以上的猜测:在linux环境下echo命令行的模式,比在线的方式多一个尾部的回车换行。
再就回车换行问题进一步进行确认,因为是1个字符也会多回车换行,还不是经典的76字符回车换行问题,所以怀疑是echo的问题,经搜索,确认是echo的问题。

解决

在echo中增加参数-n 去掉结尾回车换行,验证OK:

echo -n "chabctimes"|base64

centos下privoxy安装及使用

下载

###下载安装文件
wget http://www.privoxy.org/sf-download-mirror/Sources/3.0.26%20%28stable%29/privoxy-3.0.26-stable-src.tar.gz
tar -zxvf privoxy-3.0.26-stable-src.tar.gz
cd privoxy-3.0.26-stable

privoxy-3.0.26-stable 是目前最新的稳定版,建议在下载前去 Privoxy 官网下载页 检查一下版本。

新建用户

Privoxy 强烈不建议使用 root 用户运行,所以我们使用 useradd privoxy 新建一个用户.

安装

autoheader && autoconf
./configure
make && make install

配置

```vi /usr/local/etc/privoxy/config```

找到以下两句,确保没有注释掉

listen-address 127.0.0.1:8118   # 8118 是默认端口,不用改,下面会用到
forward-socks5t / 127.0.0.1:0 . # 这里的端口写 shadowsocks 的本地端口(注意最后那个 . 不要漏了)

启动

privoxy --user privoxy /usr/local/etc/privoxy/config

开启系统代理

配置 /etc/profile

vi /etc/profile

添加下面两句:

export http_proxy=http://127.0.0.1:8118       #这里的端口和上面 privoxy 中的保持一致
export https_proxy=http://127.0.0.1:8118

运行以下:

source /etc/profile

测试生效

curl www.google.com

返回一大堆 HTML 则说明 shadowsocks 正常工作了。

CentOS 7 安装 shadowsocks libev 客户端

installation

download yum repo on Fedora Copr and put it inside /etc/yum.repos.d/. The release Epel is for RHEL and its derivatives.

Then, install shadowsocks-libev via dnf:

su -c 'dnf update'
su -c 'dnf install shadowsocks-libev'

config

shadowsocks-libev 默认读取位于 /etc/shadowsocks-libev/config.json 的配置文件,我们可以根据需要参考以下配置文件进行修改:

{
    "server": "example.zzz.buzz",
    "server_port": 10443,
    "local_port": 1080,
    "password": "zzz.buzz",
    "method": "aes-256-cfb",
    "mode": "tcp_and_udp",
    "timeout": 600
}

"server": 必填,填入要连接的 shadowsocks 服务器域名或 IP。

"server_port": 必填,填入服务器上 shadowsocks 所监听的端口。

"local_port": 必填,填入本地 shadowsocks 客户端 SOCKS5 代理要监听的端口。

"password": 必填,密码,需与 shadowsocks 服务器端配置一致。

"method": 必填,加密方法,需与 shadowsocks 服务器端配置一致。

"mode": 选填,默认 "tcp_only"。

shadowsocks 所要监听的协议,可填 "tcp_only", "udp_only" 和 "tcp_and_udp"。
填入 "tcp_and_udp" 相当于命令行上提供 -u 参数;填入 "udp_only" 相当于命令行上提供 -U 参数。

"timeout": 选填,不活动连接的保持时间。

默认 60 秒,设置较长时间有助于保持 HTTP 长连接等。设置时间过长则会导致不必要地占用过多 shadowsocks 服务器资源。

对于配置客户端,完成以上几项配置就足够了。

如果想要变更默认的配置文件,或者提供其他命令行参数,我们可以修改 /etc/sysconfig/shadowsocks-libev:

# Configuration file
CONFFILE="/etc/shadowsocks-libev/config.json"

# Extra command line arguments
DAEMON_ARGS="-u"

其中 CONFFILE 指定了 shadowsocks-libev 所读取的配置文件;DAEMON_ARGS 则指定了额外的命令行参数,此处的 "-u" 表示启用 UDP 协议。

需要注意的是,命令行参数 DAEMON_ARGS 比配置文件 CONFFILE 中指定的选项优先级要更高一些。

start

systemctl enable --now shadowsocks-libev-local

wordpress更新时弹出ftp登录

原因

因为更新本身就是对本地文件的更新覆盖,而wordpress的更新程序无法完成本地文件更新所以就会出现ftp的方式提示,所以就是文件的更新权限问题。

权限检查

因为是wordpress的php部分的逻辑负责更新,所以就是查看这部分php的运行用户权限。如果我们的php是运行在fpm模式,这个我们可以用:

ps aux |grep  php-fpm

这条指令来查看,输出第一列就是当前归属的用户组信息。然后我们对当前的wordpress根目录或者主题插件的目录进行用户权限修改:

 chown -R xxx:xxx /DDD

xxx为用户和组,DDD为需要更新权限的目录,-R表示递归所有子目录。

mysql 中文乱码

默认:
mysql> show variables like "character_set%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     |
| character_set_connection | latin1                     |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | latin1                     |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
*************************************************************
*************************************************************
1.修改/etc/my.cnf文件,改成这样:
[mysqld]
default-character-set=utf8
init_connect='SET NAMES utf8'
[client]
default-character-set=utf8
2./etc/init.d/mysqld restart 重新启动mysql;
mysql重启后字符集更改仍然生效。
mysql> show variables like "character_set%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
*************************************************************
*************************************************************
注意执行命令:
SET NAMES 'utf8';
它相当于下面的三句指令:
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;

cosmic 编译器未调用函数优化

Q. Can the compiler automatically remove unused functions from my application?

A. Yes, the default behavior includes all code linked however, you can add the +split compiler command line option to split the object into multiple sections. i.e. One section per function such that individual functions may be removed by the linker if they are not called. You then mark one or more segments in the link command file with the -k (keep) option to specifiy which segments need to be kept. Typically, you just need to add the -k segment option to the segment containing the vecotr table. This usually coversl all of the applications call trees.

stvd-cosmic