快速笔记

Linux配置笔记

Git Pull

#初始化用户名
git config --system --unset credential.helper
  
git init
git add .
git commit -m "first commit"
git remote add origin https://git.pinecut.cn/ChampionYin/xxx.git
git push -u origin main

快速版
git add .&&git commit -m "0"&&git push -u origin master

Git Fork

git clone -b CRC_Fork https://git.pinecut.cn/ChampionYin/xxx.git
git add .
git commit -m "first commit"
git push origin CRC_Fork

systemctl命令

  • 启动服务:systemctl start vsftpd.service
  • 关闭服务:systemctl stop vsftpd.service
  • 重启服务:systemctl restart vsftpd.service
  • 显示服务的状态:systemctl status vsftpd.service
  • 在开机时启用服务:systemctl enable vsftpd.service
  • 在开机时禁用服务:systemctl disable vsftpd.service
  • 查看服务是否开机启动:systemctl is-enabled vsftpd.service
  • 查看已启动的服务列表:systemctl list-unit-files|grep enabled
  • 查看启动失败的服务列表:systemctl --failed

学习链接

Setuptools安装

wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg    #下载库
sh setuptools-0.6c11-py2.7.egg    #安装库

Linux 常用

调整SD卡大小fs_resize

  • 挂载硬盘

    fdisk -l
    mkfs.ext4 /dev/sda1
    cd /mnt
    mkdir Dogo
    mount /dev/sda1 /mnt/Dogo
    
  • 软链接

    ln -s /home/user/documents/report.txt /home/user/links/report_link.txt
    
  • 开机自启动

    nano /etc/rc.local
    sleep5
    mount /dev/sda1 /mnt/Dogo
    
  • ssh上传
    scp /Users/cpy/Desktop/frpc [email protected]:frpc
    scp -O /Users/cpy/Desktop/frpc [email protected]:frpc

  • 后台运行
    nohup cmd > nohupcmd.out 2>&1 &
    解压
    tar -zxvf

  • docker默认路径

    /etc/docker/daemon.json
    
    {
      "graph":"/mnt/Dogo/docker"
    }
    
    systemctl restart docker.service
    
  • docker代理

    {
        "registry-mirrors": [
        	"https://dockerproxy.com"
        ]
    }
    
  • 设置取消http代理

    export http_proxy=http://192.168.8.232:7890
    export https_proxy=http://192.168.8.232:7890
    
    unset http_proxy
    unset https_proxy
    
  • 拉取各种平台的 Docker 镜像

    #aarch64 (arm v8) CPU架构:
    docker pull --platform=linux/aarch64 ubuntu:22.04
    #x86_64 CPU架构:
    docker pull --platform=linux/x86_64 ubuntu:22.04
    
  • ESP32 Arduino开发板管理器

    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
    
  • Win10 21H1轻度精简镜像/vn7v

  • Win11 21H1轻度精简镜像/9xy7

  • Win10 LTSC2019 轻度精简/2co8

  • Mac改环境变量

    sudo nano /etc/paths
    
  • 用systemctl自启动
    cd /usr/lib/systemd/system

    [Unit]
    Description=Frpc service
    
    [Service]
    Type=simple
    ExecStart=/root/cmd.sh
    Restart=always
    RestartSec=5
    StartLimitInterval=0
    
    [Install]
    WantedBy=multi-user.target
    
  • 修改 Python3 指向

    nano ~/.zshrc
    
    # 暴露 which python3 查出的python3的路径
    export PATH=${PATH}:/opt/homebrew/bin/python3.9
    # 将路径命别名
    alias python3="/opt/homebrew/bin/python3.9"
    
  • 永久设置环境变量macOS已验证

    nano /etc/profile
    
    #最后一行添加,追加环境变量路径
    export PATH=$PATH:/root/bin
    export ADF_PATH=/usr/local
    source /etc/profile
    
  • 查看 buildroot 所有支持指令

    ls /bin /usr/bin /sbin /usr/sbin
    
  • 使用dpkg删除某个软件包
    dpkg -l |grep <package name>
    dpkg -r <package name>
    dpkg -r 卸载。
    dpkg -P 彻底卸载,包括配置文件等。

  • 开启虚拟内存

    sudo apt-get install dphys-swapfile
    sudo nano /etc/dphys-swapfile
    #应用更改(如果更改了)
    sudo /etc/init.d/dphys-swapfile stop
    sudo /etc/init.d/dphys-swapfile start
    

C语言

//float转字符串
char strValue[22];
snprintf(strValue, sizeof(strValue), "%.4f", test_float);
printf("%s\r\n",strValue);
printf("33518\r\n");

Printf

为了在gcc环境下也能流畅的使用printf

#include <stdio.h>

#ifdef __GNUC__
int _write(int fd, char *ptr, int len)  
{  
  HAL_UART_Transmit(&huart1, (uint8_t*)ptr, len, 0xFFFF);
  return len;
}
#endif

Cmake加入库

include_directories(Core/Components)
file(GLOB_RECURSE SOURCES "Core/Components/*.*")
void SysTick_Handler(void)
{
  /* USER CODE BEGIN SysTick_IRQn 0 */

  /* USER CODE END SysTick_IRQn 0 */
  HAL_IncTick();
  /* USER CODE BEGIN SysTick_IRQn 1 */
	HAL_SYSTICK_IRQHandler();
  /* USER CODE END SysTick_IRQn 1 */
}

void HAL_SYSTICK_Callback() {

}

删除特定的文件
find /root/test -type f -name '.*' -exec rm {} +

openOCD

C:\Components_cc\OpenOCD-20230712-0.12.0\bin\openocd.exe -s C:\Components_cc\OpenOCD-20230712-0.12.0\share\openocd\scripts -f board/daplink.cfg -c "tcl_port disabled" -c "gdb_port disabled" -c "tcl_port disabled" -c "program \"C:/Users/73877/Desktop/GPSOLED/cmake-build-debug/Kongzhihe20240314.elf\"" -c reset -c shutdown

UTF-8转化

find ./ -name "*.properties" -exec enca -x UTF-8 {} \;

ChatGPT

https://chat.openai.com/api/auth/session

ESP-IDF

https://github.com/espressif/esp-idf/tree/master/examples

ESP-ADF

https://github.com/espressif/esp-adf/tree/master/examples

ESP-32烧录IO

3V3
EN
MCUTX
MCURX
IO0
GND

Cmake 添加 ccache

set(CCACHE /opt/homebrew/bin/ccache)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE} CACHE STRING "CCache launcher")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE} CACHE STRING "CCache launcher")

使用Clion 看代码

cmake_minimum_required(VERSION 3.21)
project(CCC C)
set(CMAKE_C_STANDARD 99)
add_compile_options(-Ofast)
include_directories(Source Source/STM32F10x Source/STM32F10x/USB)
add_definitions(-DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB)
file(GLOB_RECURSE SOURCES
        "Source/*.*"
        "Source/STM32F10x/*.*"
        "Source/STM32F10x/USB/*.*")

add_executable(CCC ${SOURCES})