跳转至

通用定制

APT 软件源配置

查看系统版本

lsb_release -a

输出示例:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

配置文件路径

格式类型 配置文件路径 适用系统
One-Line-Style(旧) /etc/apt/sources.list Debian ≤11 / Ubuntu ≤22.04
DEB822(新) /etc/apt/sources.list.d/debian.sources Debian ≥12
DEB822(新) /etc/apt/sources.list.d/ubuntu.sources Ubuntu ≥24.04

切换为中科大镜像源

sources.list 格式

sudo sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" /etc/apt/sources.list
sudo apt update

DEB822 格式

# Debian
sudo sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" /etc/apt/sources.list.d/debian.sources

# Ubuntu
sudo sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" /etc/apt/sources.list.d/ubuntu.sources

sudo apt update

Note

国内用户建议替换为 mirrors.ustc.edu.cn;可替换为 mirrors.aliyun.commirrors.tuna.tsinghua.edu.cn 等其他镜像站

开机自启脚本

系统预置开机自启脚本 /etc/init.d/kickpi.sh,直接在脚本末尾追加命令即可实现开机执行。

操作示例

sudo vim /etc/init.d/kickpi.sh

dmesg -n1 后追加:

sudo sh /usr/bin/test_boot.sh

开机自启服务(systemd)

使用 systemd 服务单元管理开机自启任务。

Step 1:创建服务单元

sudo vim /usr/lib/systemd/system/test-boot.service

内容:

[Unit]
Description=boot test service
After=graphical.target

[Service]
Type=simple
ExecStart=/usr/bin/test.sh
User=root
Environment=DISPLAY=:0

[Install]
WantedBy=graphical.target

Step 2:创建执行脚本

sudo vim /usr/bin/test.sh
#!/bin/bash
echo "hello test boot service" > /tmp/test.log
sudo chmod 777 /usr/bin/test.sh

Step 3:启用 / 禁用服务

# 启用(开机自启)
sudo systemctl enable test-boot.service

# 禁用
sudo systemctl disable test-boot.service

Tip

启动后可检查 /tmp/test.log 确认服务运行状态。

串口自动登录

serial-getty@.service 管理串口(/dev/ttyS0/ttyS1 等)的终端登录。修改 /lib/systemd/system/serial-getty@.serviceExecStart 行实现自动登录。

配置对照

场景 ExecStart 行
默认(需输入凭证) ExecStart=-/sbin/agetty -o "-p -- \\u" --keep-baud 115200,57600,38400,9600 - $TERM
自动以 kickpi 登录 ExecStart=-/sbin/agetty --autologin kickpi --keep-baud 115200,38400,9600 %I $TERM
自动以 root 登录 ExecStart=-/sbin/agetty --autologin root --keep-baud 115200,38400,9600 %I $TERM

用户管理

默认账号

系统 用户名 密码
Debian linaro linaro
Debian kickpi kickpi
Debian root root
Ubuntu kickpi kickpi
Ubuntu root root
Buildroot root root

修改密码

sudo passwd root           # 修改 root 密码
sudo passwd $(whoami)      # 修改当前用户密码

切换用户

桌面版默认登录用户为 kickpi。需 root 权限时,可在命令前加 sudo,或 su root 切换

su <username>              # 如:su root

桌面登录配置

确认当前显示管理器

cat /etc/X11/default-display-manager

SLiM

sudo vim /etc/slim.conf

修改:

#default_user        kickpi    →    default_user        root

重启生效。

LightDM

配置文件路径(视系统而异):

/etc/lightdm/lightdm.conf
/etc/lightdm/lightdm.conf.d/50-myconfig.conf

修改自动登录用户:

autologin-user=kickpi

启用 root 登录(注释掉限制行):

sudo vim /etc/pam.d/lightdm-autologin
#auth required pam_succeed_if.so user != root quiet_success

命令行/桌面模式切换

查看当前模式

sudo systemctl get-default

设置命令行模式(无桌面)

sudo systemctl set-default multi-user.target
sudo reboot

恢复桌面模式

sudo systemctl set-default graphical.target
sudo reboot

语言配置

修改完成后,需重启后生效。

设为英文

sudo locale-gen en_US.UTF-8
sudo sed -i "s/^# *\\(en_US.UTF-8\\)/\\1/" /etc/locale.gen
sudo sh -c 'echo "LANG=en_US.UTF-8" >> /etc/default/locale'
sudo sh -c 'echo "export LC_ALL=en_US.UTF-8" >> /etc/profile.d/lang.sh'
sudo sh -c 'echo "export LANG=en_US.UTF-8" >> /etc/profile.d/lang.sh'
sudo sh -c 'echo "export LANGUAGE=en_US:en" >> /etc/profile.d/lang.sh'

设为中文

sudo locale-gen zh_CN.UTF-8
sudo sed -i "s/^# *\\(zh_CN.UTF-8\\)/\\1/" /etc/locale.gen
sudo sh -c 'echo "LANG=zh_CN.UTF-8" >> /etc/default/locale'
sudo sh -c 'echo "export LC_ALL=zh_CN.UTF-8" >> /etc/profile.d/lang.sh'
sudo sh -c 'echo "export LANG=zh_CN.UTF-8" >> /etc/profile.d/lang.sh'
sudo sh -c 'echo "export LANGUAGE=zh_CN:zh" >> /etc/profile.d/lang.sh'
sudo reboot

时区配置

时区修改完成后,需重启生效。

# 查看当前时区
timedatectl

# 设置为上海时区
sudo timedatectl set-timezone Asia/Shanghai

# 验证
date

备选方案(兼容所有系统):

# 设为北京时间
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 设为纽约时间
sudo ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

时间配置

系统时间

date -s "2026-04-14 15:30:00"           # 同时设日期和时间
date -s "2026-04-14"                    # 只设日期
date -s "15:35:00"                      # 只设时间
date                                    # 查看系统时间

硬件 RTC 时间

hwclock -r                              # 读取 RTC
hwclock -r --rtc=/dev/rtc0              # 指定 RTC 设备
hwclock -w                              # 系统时间 → RTC
hwclock --systohc                       # 系统时间 → RTC
hwclock -s                              # RTC → 系统时间
hwclock --hctosys                       # RTC → 系统时间

RTC 节点

cat /sys/class/rtc/rtc0/date
cat /sys/class/rtc/rtc0/time

开机自动同步 RTC → 系统时间

编辑 /etc/init.d/kickpi.sh,将:

[ -f /dev/rtc0 ] && hwclock --systohc

改为:

[ -f /dev/rtc0 ] && hwclock --hctosys

Note

--systohc = 系统时间写入 RTC;--hctosys = RTC 时间写入系统。

网络配置

常用 ifconfig 命令

ifconfig -a                                          # 查看所有接口
ifconfig eth0                                        # 查看指定接口
ifconfig eth0 192.168.1.101 netmask 255.255.255.0    # 设定 IP(临时)
ifconfig eth0 up                                     # 启用接口
ifconfig eth0 down                                   # 禁用接口
ifconfig eth0 hw ether 00:11:22:33:44:55             # 设定 MAC(需先 down)

静态 IP 配置

注意:两种方法选一种即可,不要同时使用,以免冲突

方法 A:Netplan(Debian 需安装,Ubuntu 通常已预装)

sudo apt update
sudo apt install -y netplan.io
sudo mkdir -p /etc/netplan
sudo tee /etc/netplan/01-static-ip.yaml << "EOF"
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.199.100/24
      routes:
        - to: 0.0.0.0/0
          via: 192.168.199.3
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
EOF
sudo netplan apply

验证:

ip addr show eth0                       # 查看IP
ping -c 3 192.168.199.3                 # 测试网关
ping -c 3 8.8.8.8                       # 测试外网

恢复 DHCP:

sudo rm /etc/netplan/01-static-ip.yaml && sudo reboot

方法 B:nmcli(NetworkManager)

nmcli con show  # 查看连接名(如 "Wired connection 1")
nmcli con mod "Wired connection 1" \
  ipv4.method manual \
  ipv4.addresses 192.168.199.100/24 \
  ipv4.gateway 192.168.199.3 \
  ipv4.dns "8.8.8.8 8.8.4.4"
nmcli con down "Wired connection 1" && nmcli con up "Wired connection 1"

恢复 DHCP:

nmcli con mod "Wired connection 1" ipv4.method auto ipv4.addresses "" ipv4.gateway "" ipv4.dns ""
nmcli con down "Wired connection 1" && nmcli con up "Wired connection 1"

参数参考

参数 示例值 说明
IP 地址 192.168.199.100 按需修改
子网掩码 255.255.255.0(即 /24) 按实际子网调整
网关 192.168.199.3 通过 ip route \| grep default 查询
DNS 8.8.8.8, 8.8.4.4 可选 114.114.114.114

WiFi 热点

检查 AP 模式支持

iw list | grep AP

输出包含 AP / AP/VLAN 即表示硬件支持

方案一:虚拟接口热点(不影响原 WiFi 连接)

# 1. 安装依赖
sudo apt-get install -y util-linux hostapd dnsmasq iptables iproute2 haveged make

# 2. 创建虚拟网卡(wlan0 → wlo2)
sudo iw dev wlan0 interface add wlo2 type __ap

# 3. 为虚拟网卡设置 MAC
sudo ip link set dev wlo2 address 22:33:44:55:66:00

# 4. 安装 create_ap
git clone https://github.com/oblique/create_ap
cd create_ap && sudo make install

# 5. 启动热点(-c 11 = 信道)
sudo create_ap -c 11 wlo2 wlan0 MySSID MyPassword

Note

重启后虚拟网卡失效,需重新创建

遇到 Device or resource busy 时,先停止:

sudo create_ap --stop wlo2

方案二:物理接口热点(独占 WiFi 网卡)

# 1. 安装依赖 + create_ap
sudo apt-get install -y util-linux hostapd dnsmasq iptables iproute2 haveged make
git clone https://github.com/oblique/create_ap
cd create_ap && sudo make install

# 2. 修改防火墙,切换 iptables 后兼容模式
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

# 3. 创建热点 MyAccessPoint 密码 12345678 共享 eth0 网络(后台运行)
sudo create_ap --no-virt wlan0 eth0 MyAccessPoint 12345678 &

# 4. 恢复 WiFi 节点
sudo create_ap --fix-unmanaged

编译工具链

包含 gcc、g++、make 等核心编译工具

sudo apt update && sudo apt install -y build-essential manpages-dev

Samba 共享

# 1. 安装
sudo apt install samba samba-common

# 2. 设置目录权限
sudo chmod 777 /home/kickpi/

# 3. 添加 Samba 用户
sudo smbpasswd -a <username>

# 4. 编辑配置
sudo vim /etc/samba/smb.conf

在文件末尾追加:

[kickpi]
    comment = kickpi
    path = /home/kickpi
    public = yes
    writable = yes
    workgroup = kickpi
# 5. 重启服务
sudo systemctl restart smbd

Tip

Windows 访问:\\<主板IP>\\kickpi

NFS 共享

环境安装

sudo apt install nfs-kernel-server rpcbind nfs-common

服务端

# 配置共享的文件
mkdir -p /home/kickpi/nfs_share
chmod 777 /home/kickpi/nfs_share

sudo vim /etc/exports

添加:

/home/kickpi/nfs_share *(rw,sync,no_subtree_check,insecure)
# 启动服务
sudo service nfs-kernel-server restart

# 查看当前服务器共享文件
showmount -e localhost

客户端

# 查看服务端共享列表
showmount -e <服务器IP>

# 挂载
mkdir nfs_tmp
sudo mount -t nfs <服务器IP>:/home/kickpi/nfs_share nfs_tmp/

# 验证
ls nfs_tmp/

SSH 配置

SSH 连接

ssh <username>@<board-ip>

启用 root 登录

方式一(传统)

sudo vim /etc/ssh/sshd_config           # 添加 PermitRootLogin yes
sudo /etc/init.d/ssh restart

方式二(推荐 — 升级不覆盖)

echo "PermitRootLogin yes" | sudo tee /etc/ssh/sshd_config.d/root.conf
sudo systemctl restart ssh

SDK 中预置此配置的路径:

debian/overlay/etc/ssh/sshd_config.d/root.conf

清理旧密钥

目标 Linux 主机重装系统 / 重置 SSH → 密钥指纹变了,Windows 本地还保存着旧的无效密钥 → 拒绝连接

ssh-keygen -R <board-ip>

SCP 文件传输

scp <local_path> <username>@<board-ip>:<target_path>

示例

scp ./1.wav linaro@192.168.77.165:/home/linaro/Desktop/
参数 含义
$local_path 本地文件路径
$username 主板用户名
$ip 主板 IP
$target_path 目标路径

常见问题

Q1:烧录后首次开机自动重启

首次启动时系统会根据芯片型号自动安装差异包(libmali、ISP 等),安装完成后重启显示服务。此为正常现象。独立项目可在制作镜像时预先处理差异包。

Q2:create_ap dnsmasq 端口冲突

dnsmasq: failed to bind DHCP server socket: Address already in use

解决:

sudo lsof -i | grep dnsmasq             # 查找 PID
sudo kill -9 <PID>

Q3:create_ap 与 iw ≥6.7 兼容问题

iw 6.7+ 输出频率带小数(如 2412.0 MHz),create_ap 正则不匹配。需修改 /usr/bin/create_ap

@@ -321,9 +321,9 @@ can_transmit_to_channel() {

    if [[ $USE_IWCONFIG -eq 0 ]]; then
        if [[ $FREQ_BAND == 2.4 ]]; then
-           CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep " 24[0-9][0-9] MHz \[${CHANNEL_NUM}\]")
+           CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep " 24[0-9][0-9]\(\.0\+\)\? MHz \[${CHANNEL_NUM}\]")
        else
-           CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep " \(49[0-9][0-9]\|5[0-9]\{3\}\) MHz \[${CHANNEL_NUM}\]")
+           CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep " \(49[0-9][0-9]\|5[0-9]\{3\}\)\(\.0\+\)\? MHz \[${CHANNEL_NUM}\]")
        fi
        [[ -z "${CHANNEL_INFO}" ]] && return 1
        [[ "${CHANNEL_INFO}" == *no\ IR* ]] && return 1
@@ -339,7 +339,9 @@ can_transmit_to_channel() {

# taken from iw/util.c
ieee80211_frequency_to_channel() {
-   local FREQ=$1
+   local FREQ_MAYBE_FRACTIONAL=$1
+   local FREQ=${FREQ_MAYBE_FRACTIONAL%.*}

    if [[ $FREQ -eq 2484 ]]; then
        echo 14
    elif [[ $FREQ -lt 2484 ]]; then
@@ -356,7 +358,7 @@ ieee80211_frequency_to_channel() {
}

is_5ghz_frequency() {
-    [[ $1 =~ ^(49[0-9]{2})|(5[0-9]{3})$ ]]
+   [[ $1 =~ ^(49[0-9]{2})|(5[0-9]{3})(\.0+)?$ ]]
}

is_wifi_connected() {
    return 1
}

Q4:SLiM 登录器修改用户名异常

# 1. 修改 hostname
sudo hostnamectl set-hostname <新用户名>

# 2. 更新自动登录配置
/etc/lightdm/lightdm.conf
/etc/pam.d/lightdm-autologin
/lib/systemd/system/serial-getty@.service

# 3. 修改用户名
sudo usermod -l <新用户名> <旧用户名>

# 4. 迁移 home 目录
sudo mv /home/<旧用户名> /home/<新用户名>
sudo usermod -d /home/<新用户名> -m <新用户名>

# 5. 清理图形缓存
rm -f /home/<新用户名>/.Xauthority
sudo rm -rf /var/run/slim/*
sudo rm -rf /var/lib/slim/

# 6. 重新配置 slim
sudo pam-auth-update