APP下载

IoT | Raspberry: Pi5应用与实践(一)

原创

Raspberry

想尽办法,把事情做成!

硬件组装

系统烧录

TIPS: 由于个人一直使用且熟悉ubuntu系统,所以选择ubuntu24 server。

1. 安装ubuntu24 server

1.1 安装与系统下载地址文档: https://ubuntu.com/download/raspberry-pi  ,系统文件大小 1GB 左右。

1.2 问题一:安装错了系统

小编还有一个Pi 4B,三年前买的,一直在运行,因为好久没折腾的原因,很多东西都忘了,只记得Raspberry CPU是arm64系统架构的,所以就直接下了对应的iso镜像,“2.6G”的大小,下了将近2个小时,结果烧录的时候一直报下面的错误:

               
  • 1
partition does not have a fat file system COPY

由于最近在“三中全会”期间,VPN基本废了,GPT和网络一直断,查资料很困难,从晚上7点折腾到11点,又困又累有糟心。最后才想起这茬,赶紧换烧录系统。

所幸,后面就没啥问题了。

这部分按照文档来就好,问题不大。

1.3 强烈建议:一定要装散热设置,小风扇非常不错,效果非常好。

环境准备

这里提一下该设备的主要用途:安装一个私有gitlab,搭建一个私用的、稳定且强大的工程环境。

小编个人非常重视“工程化思维”和系统工程化建设,但不管是现在的公司还是我个人,在这一块都做得非常不够。

1. 安装完系统后

  1. 预览
               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-1007-raspi aarch64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro System information as of Mon Jul 15 09:24:31 CST 2024 System load: 0.0 Temperature: 54.0 C Usage of /: 1.8% of 116.65GB Processes: 137 Memory usage: 3% Users logged in: 1 Swap usage: 0% IPv4 address for wlan0: 192.168.31.111 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s just raised the bar for easy, resilient and secure K8s cluster deployment. https://ubuntu.com/engage/secure-kubernetes-at-the-edge This power supply is not capable of supplying 5A; power to peripherals will be restricted See man:pemmican-cli(1) for information on suppressing this warning, or https://rptl.io/rpi5-power-supply-info for more information on the Raspberry Pi 5 power supply Expanded Security Maintenance for Applications is not enabled. 0 updates can be applied immediately. Enable ESM Apps to receive additional future security updates. See https://ubuntu.com/esm or run: sudo pro status Last login: Mon Jul 15 08:39:44 2024 from 192.168.31.51 # view architucture uname -u aarch64 COPY

2. 更新源

Ubuntu24.04的源地址配置文件发生改变,不再使用以前的sources.list文件,升级24.04之后,该文件内容变成了一行注释:

# Ubuntu sources have moved to /etc/apt/sources.list.d/ubuntu.sources新的官方源配置放在了/etc/apt/sources.list.d/ubuntu.sources中,升级前的三方源被放在了/etc/apt/sources.list.d/third-party.sources中。

2.1 使用命令查看下:

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
cat /etc/apt/sources.list # Ubuntu sources have moved to the /etc/apt/sources.list.d/ubuntu.sources # file, which uses the deb822 format. Use deb822-formatted .sources files # to manage package sources in the /etc/apt/sources.list.d/ directory. # See the sources.list(5) manual page for details. COPY

2.2 禁用系统源

使用vim编辑:

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
Enabled: no Types: deb URIs: http://archive.ubuntu.com/ubuntu Suites: noble noble-updates Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Enabled: no Types: deb URIs: http://security.ubuntu.com/ubuntu Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg COPY

2.3 编辑 /etc/apt/sources.list.d/third-party.sources文件,填入国内源地址,没有就新建:

清华源

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
Enabled: yes Types: deb URIs: http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg COPY

中科大源

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
Enabled: yes Types: deb URIs: http://mirrors.ustc.edu.cn/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg COPY

阿里源

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
Enabled: yes Types: deb URIs: http://mirrors.aliyun.com/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg COPY

网易源

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
Enabled: yes Types: deb URIs: http://mirrors.163.com/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg COPY

腾讯源

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
Enabled: yes Types: deb URIs: http://mirrors.tencent.com/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg COPY

2.4 推荐使用阿里云源

文档:https://developer.aliyun.com/mirror/ubuntu-ports?spm=a2c6h.13651104.d-1008.11.1dc44763Vto18m 

3. 开发环境准备

3.1 安装node.js 和 npm

3.1.1 直接安装,新版的默认版本是18.19.1,完全可以

               
  • 1
sudo apt install nodejs npm COPY

3.2 安装Rust

3.2.1 使用命令

               
  • 1
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh COPY

3.3 安装docker

3.4 安装gitlab

3.4.1 文档: https://about.gitlab.com/install/#ubuntu 

3.5 配置pip

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
~/.pip/pip.conf # 添加 [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com COPY

3.6 安装Rust

阿里云镜像地址:https://developer.aliyun.com/mirror/rustup?spm=a2c6h.13651102.0.0.3b291b11CFvmy5 

3.6.1 执行下面的命令

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
# 永久替换 # bash用户 echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.aliyun.com/rustup/rustup' >> ~/.bash_profile echo 'export RUSTUP_DIST_SERVER=https://mirrors.aliyun.com/rustup' >> ~/.bash_profile source ~/.bash_profile # zsh用户 echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.aliyun.com/rustup/rustup' >> ~/.zshrc echo 'export RUSTUP_DIST_SERVER=https://mirrors.aliyun.com/rustup' >> ~/.zshrc source ~/.zshrc # 安装 # 使用阿里云安装脚本 curl --proto '=https' --tlsv1.2 -sSf https://mirrors.aliyun.com/repo/rust/rustup-init.sh | sh # 使用官方安装脚本 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # 安装成功 Rust is installed now. Great! COPY

3.6.2 配置crates.io 镜像

在 cargo 配置文件: ~/.cargo/config 中,添加以下内容: (Windows 系统配置文件地址默认为:%USERPROFILE%.cargo\config)

目前该镜像仅支持稀疏索引配置,需要您的 cargo 版本 >=1.68:

               
  • 1
  • 2
  • 3
  • 4
[source.crates-io] replace-with = 'aliyun' [source.aliyun] registry = "sparse+https://mirrors.aliyun.com/crates.io-index/" COPY

随记

  1. ubuntu 查看swap的大小
               
  • 1
  • 2
  • 3
free -m # 单位为M free -h # 单位为G COPY
  1. 修改swap的大小

安装dphys-swapfile:https://manpages.ubuntu.com/manpages/noble/en/man8/dphys-swapfile.8.html 

修改 swap 分区配置:

               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
sudo vim /etc/dphys-swapfile # 重启服务 sudo /etc/init.d/dphys-swapfile restart # 查看 free -h COPY
  1. systemd的服务延时启动,以frpc为例
               
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
[Unit] # 服务名称,可自定义 Description = frpc server After = network.target syslog.target Wants = network.target [Service] Type = simplei # 延时启动,单位为s ExecStartPre=/bin/sleep 45 # 启动frps的命令,需修改为您的frps的安装路径 ExecStart = /home/cogito/CustomServices/Frpc/frpc -c /home/cogito/CustomServices/Frpc/frpc.toml [Install] WantedBy = multi-user.target COPY
  1. 查看服务/应用日志
               
  • 1
sudo journalctl -u frpc COPY

参考资料

  1. 阿里官方镜像站:https://developer.aliyun.com/mirror/?spm=a2c6h.13651104.mirror-detail.d1002.44883317mgubDM 

评论区

写评论

登录

所以,就随便说点什么吧...

这里什么都没有,快来评论吧...