> 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/man/man4/at45d.4.md).

# at45d.4

`at45d` — DataFlash(tm) 非易失性存储设备驱动

## 名称

`at45d`

## 概要

要将此驱动编译进内核，请将以下行放入你的内核配置文件中：

> device at45d

或者，要在引导时以模块形式加载该驱动，请在 loader.conf(5) 中加入以下行：

```sh
at45d_load="YES"
```

## 描述

`at45d` 驱动为统称为 DataFlash(tm) 的非易失性存储设备系列提供支持。DataFlash 芯片的部件号通常以 AT45DB 开头。`at45d` 驱动仅支持每个 AT45DB 设备的 SPI 总线版本，以部件号最后一位为 1 或 2 标识。

`at45d` 驱动使用操作码 0x9f 读取制造商和设备 ID 数据，以确定该设备是否受支持。设备 ID 使用驱动程序内的数据表进行查找，该表描述了每个支持设备的属性，如块大小、扇区大小和设备容量。找到受支持的设备时，`at45d` 驱动会创建一个磁盘设备，并可通过 `/dev/flash/at45d?` 访问。然后，新磁盘设备会像任何磁盘设备一样被可用的 [geom(4)](https://github.com/FreeBSD-Ask/freebsd-man-sc/blob/main/man4/geom.4.md) 模块品尝。

## 硬件

`at45d` 驱动为以下设备提供支持：

* AT45DB011B
* AT45DB021B
* AT45DB041x
* AT45DB081B
* AT45DB161x
* AT45DB321x
* AT45DB321x
* AT45DB641E
* AT45DB642x

## FDT 配置

在基于 [fdt(4)](/man/man4/fdt.4.md) 的系统上，`at45d` 设备定义为 SPI 总线控制器节点的从设备子节点。`spibus.txt` 绑定文档中记录的所有属性都可用于 `at45d` 设备。最常用的属性记录如下。

`at45d` 设备子节点中需要以下属性：

**`compatible`** 必须为字符串 "atmel,at45"。

**`reg`** 设备的芯片选择地址。

**`spi-max-frequency`** 与此从设备通信时使用的最大总线频率。实际总线速度可能更低，具体取决于 SPI 总线控制器硬件的能力。

以下属性对于 `at45d` 设备子节点是可选的：

**`freebsd,sectorsize`** 为此存储设备创建的磁盘的扇区大小。它必须是设备页面大小的倍数。默认为设备页面大小。

**`spi-cpha`** 空属性，指示从设备需要移位时钟相位（CPHA）模式。

**`spi-cpol`** 空属性，指示从设备需要反相时钟极性（CPOL）模式。

**`spi-cs-high`** 空属性，指示从设备需要高电平有效的芯片选择。

## HINTS 配置

在基于 [device.hints(5)](/man/man5/device.hints.5.md) 的系统（如 `MIPS`）上，可为 `at45d` 配置以下值：

**`hint.at45d.%d.at`** `at45d` 实例所连接的 spibus。

**`hint.at45d.%d.clock`** 与此设备通信时使用的最大总线频率。实际总线速度可能更低，具体取决于 SPI 总线控制器硬件的能力。

**`hint.at45d.%d.cs`** 为此设备执行 I/O 时要置位的芯片选择编号。设置最高位（1 << 31）以反转芯片选择线的逻辑电平。

**`hint.at45d.%d.mode`** 与此设备通信时使用的 SPI 模式（0-3）。

**`hint.at45d.%d.sectorsize`** 为此存储设备创建的磁盘的扇区大小。它必须是设备页面大小的倍数。默认为设备页面大小。

## 文件

**`/dev/flash/at45d?`** 提供对存储设备的读写访问。

**`/dev/flash/spi?`** `/dev/at45d?` 设备的别名，用于向后兼容旧版驱动。

## 参见

[fdt(4)](/man/man4/fdt.4.md), [geom(4)](https://github.com/FreeBSD-Ask/freebsd-man-sc/blob/main/man4/geom.4.md)

## 历史

`at45d` 驱动首次出现于 FreeBSD 6.0。


---

# 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/man/man4/at45d.4.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.
