<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Subject/I2C on Dingfan X.</title><link>https://dingfanx.com/tags/subject/i2c/</link><description>Recent content in Subject/I2C on Dingfan X.</description><generator>Hugo</generator><language>zh-cn</language><copyright>2026 Dingfan. 本站内容采用 CC BY-NC-SA 4.0 协议</copyright><lastBuildDate>Fri, 08 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://dingfanx.com/tags/subject/i2c/index.xml" rel="self" type="application/rss+xml"/><item><title>eeprom-page-wrap-around-debug</title><link>https://dingfanx.com/tech/eeprom-page-wrap-around-debug/</link><pubDate>Fri, 08 May 2026 00:00:00 +0000</pubDate><guid>https://dingfanx.com/tech/eeprom-page-wrap-around-debug/</guid><description>&lt;blockquote&gt;
&lt;p&gt;记录一下今天遇到的一个 bug，由于软硬件错配导致遇到 eeprom 写回绕的，最终解决方案比较简单，但搜集线索和排查问题耗费了较多时间。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="现象"&gt;现象&lt;/h2&gt;
&lt;p&gt;设备从远端持续下载数据过程中始终失败，预期应该持续接收直到传输完成。&lt;/p&gt;
&lt;h2 id="线索"&gt;线索&lt;/h2&gt;
&lt;p&gt;通过与触发问题的同事交流以及自己调试排查，收集到几条线索：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;问题只在带真实 EEPROM/Flash 的硬件上复现，在 mock 掉 EEPROM 和 Flash 的纯软件仿真环境里，下载流程完全正常。&lt;/li&gt;
&lt;li&gt;出问题的数据都集中在 EEPROM 地址的起始区域，几份数据的存储地址很近。&lt;/li&gt;
&lt;li&gt;问题点并不集中于传输，设备启动阶段也观察到异常，共同点是两者都依赖 EEPROM 里的同一片区域。&lt;/li&gt;
&lt;li&gt;仅一款设备存在问题，其它型号正常。&lt;/li&gt;
&lt;li&gt;连续操作下，第一次下载前数据正常；第一次下载失败后读出&amp;quot;异常 A&amp;quot;；第二次下载失败后读出&amp;quot;异常 B&amp;quot;。异常本身有确定的模式，不是随机扰动。&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="推测"&gt;推测&lt;/h2&gt;
&lt;p&gt;基于上述几条线索，基本可以确定&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;代码逻辑无问题：因为 mock 的 eeprom 和 flash 并不存在问题。而且若程序有问题，如何解释问题不集中在一处呢？&lt;/li&gt;
&lt;li&gt;问题与 eeprom 有关，但与 eeprom 硬件故障无关：异常点处数据集中，异常模式稳定，若 eeprom 硬件故障，则不会保持稳定的异常模式&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="验证"&gt;验证&lt;/h2&gt;
&lt;p&gt;查看工程配置，发现 EEPROM 的 &lt;code&gt;PAGE_SIZE&lt;/code&gt; 被配置为了 512 bytes。&lt;/p&gt;
&lt;p&gt;翻芯片 datasheet：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Page Write&lt;/strong&gt;
The Page Write mode allows up to 256 bytes to be written in a single Write cycle, provided that they are all located in the same page in the memory: that is, the most significant memory address bits, b16–b8, are the same. If more bytes are sent than will fit up to the end of the page, a &amp;ldquo;roll-over&amp;rdquo; occurs, i.e. the bytes exceeding the page end are written on the same page, from location 0.&lt;/p&gt;</description></item></channel></rss>