> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/di-42-zhang-qian-ru-shi-ping-tai-ji-kai-fa-huan-jing/di-42.2-jie-shu-mei-pai-freebsd-shi-yong.md).

# 42.2 树莓派 FreeBSD 使用

树莓派安装 FreeBSD 后需完成 SSH 配置、时区校正与固件更新。

## SSH 登录方法

使用 XShell 等终端模拟软件登录树莓派时，默认用户名和密码均为 `freebsd`。如需获取 root 权限，登录成功后执行 `su` 命令并输入 root 密码。

## 时区设置的重要性与方法

时区配置是系统初始化的必要步骤。系统时区不正确可能影响时间戳、日志分析等操作的准确性。

执行以下命令启动时区配置工具：

```sh
# tzsetup
```

在交互式配置界面中，依次选择 `No`（不将硬件时钟设为 UTC）→ `Asia`（亚洲）→ `China`（中国）→ `Beijing Time`（北京时间）。当系统提示“Is the above information correct?”或类似确认信息时，选择 `Yes` 确认配置。

## NTP 服务配置

时区配置完成后，还需配置系统时间同步机制。

树莓派 5 之前的所有型号均未配备板载实时时钟（Real Time Clock，RTC）硬件模块，系统时间依赖网络时间协议（Network Time Protocol，NTP）服务校时。树莓派 5 是该系列首款内置 RTC 模块的型号，可通过板载 J5 电池接口外接电池，在断电后维持时钟运行。

系统时间不准确可能影响 SSL/TLS 证书验证、日志时间戳准确性以及多个网络服务的正常运行。

在 **/etc/rc.conf** 文件中添加以下配置：

```ini
ntpd_enable="YES"               # 启用 NTP 守护进程
```

使用 `ntpd` 服务同步系统时间：

```sh
# ntpd -q -g pool.ntp.org
```

查看当前系统日期和时间：

```sh
# date
Tue Aug  1 16:45:55 CST 2023
```

### 主机名配置

主机名是系统在网络环境中的标识符，设置易识别的主机名有助于网络管理和设备识别。编辑 **/etc/rc.conf**，修改 `hostname` 参数，将 `hostname="generic"` 中的 `generic` 替换为实际所需的主机名。

## 频率调节机制配置

合理配置 CPU 频率动态调节机制，可在计算性能与功耗之间取得平衡。可调频率范围通常为 600 MHz 至 1500 MHz（树莓派 4）或 600 MHz 至 2400 MHz（树莓派 5），具体取决于硬件型号。实际最大频率取决于 powerd 动态调节策略和固件限制，sysctl 输出可能显示较低的最大频率（如 2000 MHz）。

执行以下命令启用并配置 `powerd` 服务：

```sh
# sysrc powerd_enable="YES"     # 设置开机时启用 powerd 服务，以实现 CPU 频率的动态调节
# service powerd restart        # 重启 powerd 服务，使配置立即生效
```

## 温度信息查询方法

持续监控 CPU 温度有助于及时发现散热异常问题。执行以下命令列出所有系统内核参数，并筛选出包含温度信息的条目：

```sh
# sysctl -a | grep temperature
hw.cpufreq.temperature: 50598
dev.cpu.0.temperature: 51.0C
```

如果需要单独查看各个 CPU 核心的温度信息，可执行以下命令：

```sh
# sysctl dev.cpu | grep temperature
dev.cpu.0.temperature: 50.1C
```

## CPU 频率等级与当前频率

执行以下命令显示 CPU 核心 0 的可用频率等级列表与当前频率：

```sh
# sysctl dev.cpu.0.freq_levels
dev.cpu.0.freq_levels: 2000/-1 600/-1
```

## 参考文献

* FreeBSD Project. FreeBSD/ARM on the Raspberry Pi family\[EB/OL]. \[2026-03-25]. <https://wiki.freebsd.org/arm/Raspberry%20Pi>. FreeBSD 官方 wiki 关于树莓派 ARM 架构支持的详细文档。
* FreeBSD 中文社区. Raspberry Pi 树莓派中文文档\[EB/OL]. \[2026-03-25]. <https://rpicn.bsdcn.org>. 该文档是树莓派在 FreeBSD 上的安装、配置与使用指南。
* Raspberry Pi Ltd. Real Time Clock (RTC)\[EB/OL]. \[2026-04-17]. <https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#real-time-clock-rtc>. 树莓派 5 内置 RTC 模块的官方文档，涵盖电池接口与唤醒功能说明。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/di-42-zhang-qian-ru-shi-ping-tai-ji-kai-fa-huan-jing/di-42.2-jie-shu-mei-pai-freebsd-shi-yong.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
