<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[D1在uboot下的spi nor flash读写操作]]></title><description><![CDATA[<p dir="auto">回复: <a href="/topic/1684/%E5%9C%A8uboot%E4%B8%8B%E8%B0%83%E7%94%A8spi%E7%9A%84sf_dataflash%E9%A9%B1%E5%8A%A8%E6%8A%A5%E9%94%99">在uboot下调用spi的sf_dataflash驱动报错</a></p>
<p dir="auto">求各位大佬有没有人尝试过在uboot下操作spi nor flash的读写。我用的是drivers/mtd/spi/sf_dataflash.c</p>
]]></description><link>https://bbs.aw-ol.com/topic/1686/d1在uboot下的spi-nor-flash读写操作</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 19:00:40 GMT</lastBuildDate><atom:link href="https://bbs.aw-ol.com/topic/1686.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Jul 2022 06:25:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to D1在uboot下的spi nor flash读写操作 on Tue, 05 Jul 2022 01:32:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://bbs.aw-ol.com/uid/317">@yuzukitsuru</a><br />
1.大佬是用什么sdk的呀？我用的是韦东山提供的buildroot工程neza-d1-buildroot，<br />
2.然后感觉那个uboot有点问题，不会遍历dts中第二层级的device，我在源码上参照那个clocks的来遍历第二层，第三层的device，在uboot 输入dm tree可以正常显示device对应的层级关系。只是第三层级的spinor没有绑定成功</p>
<pre><code>///drivers/core/root.c
  350     /* bind fixed-clock */
  351     node = ofnode_path("/clocks");
  352     /* if no DT "clocks" node, no need to go further */
~ 353     if (!ofnode_valid(node)){
+ 354         pr_debug("debug, not found ofnode_valid node\n");
  355         return ret;
+ 356     }
+ 364
+ 365         //直接进入到这里执行
+ 366         pr_debug("debug, dm_scan_fdt_node\n\n");
  367         ret = dm_scan_fdt_node(gd-&gt;dm_root, gd-&gt;fdt_blob, node.of_offset,
  368                        pre_reloc_only);
  369     if (ret)
~ 370         pr_debug("dm_scan_fdt_node() failed: %d\n", ret);
+ 371
+ 372
+ 373     pr_debug("\n\n");
+ 374     node = ofnode_path("/hello_dts_name@1234");
+ 375     if (!ofnode_valid(node)){
+ 376         pr_debug("find node faile\n");
+ 377         return ret;
+ 378     }
+ 379
+ 380     ret = uclass_get_device_by_name(UCLASS_HELLO_CJ, "hello_dts_name@1234", &amp;getdev);
+ 381     if (ret){
+ 382         pr_debug("debug, can not get device hello\n");
+ 383         ret = uclass_get_device_by_driver(UCLASS_HELLO_CJ, DM_GET_DRIVER(hello_drv), &amp;getdev);
+ 384         if (ret){
+ 385             pr_debug("debug, stil can not find device\n");
+ 386         }
+ 387     }
+ 388     ret = dm_scan_fdt_node(getdev, gd-&gt;fdt_blob, node.of_offset,pre_reloc_only);
+ 389     if (ret){
+ 390         pr_debug("dm_scan_fdt node faile\n");
+ 391     }

</code></pre>
<p dir="auto">修改后的串口dm tree打印</p>
<pre><code>=&gt; dm tree
 Class      Probed  Driver      Name
----------------------------------------
 root       [ + ]   root_drive  root_driver
 hello_cj_c [ + ]   hello_drv   |-- hello_dts_name@1234
 hello_cj_c [   ]   hello_drv_  |   `-- hello_dts_child@5678
 spi_flash  [   ]   spi_flash_  `-- spi@04026000
=&gt; 
</code></pre>
<p dir="auto">uboot的spi1 dts配置</p>
<pre><code>//uboot-origin_master/arch/riscv/dts/sun20iw1p1-soc-system.dts
  6 /dts-v1/;
   11 / {
   12     model = "sun20iw1";
   13     compatible = "allwinner,riscv", "arm,sun20iw1p1";
   14     #address-cells = &lt;2&gt;;
   15     #size-cells = &lt;2&gt;;
+  18     hellohqh: hello_dts_name@1234 {
+  19
+  20         #address-cells = &lt;1&gt;;
+  21         #size-cells = &lt;0&gt;;
+  22         compatible = "hello_dts";
+  23         reg = &lt;0x02000000&gt;;
+  24         pinctrl-names = "default", "sleep";
+  25         pinctrl-0 = &lt;&amp;gpiotest_pins&gt;;
+  26
+  27         hellohqh1: hello_dts_child@5678 {
+  28             compatible = "hello_child_dts";
+  29             reg = &lt;0x31&gt;;
+  30             hellohqh2: hello_dts_child_child@99991 {
+  31                 compatible = "hello_child_child_dts";
+  32
+  33                 };
+  34           };
+  35     };

   37     soc: soc@29000000 {
   38         #address-cells = &lt;2&gt;;
   39         #size-cells = &lt;2&gt;;

+ 427         spi1: spi@04026000 {
+ 428             //#address-cells = &lt;1&gt;;
+ 429             //#size-cells = &lt;0&gt;;
+ 430             compatible = "allwinner,sun20i-spi";
+ 431             device_type = "spi1";
+ 432             reg = &lt;0x0 0x04026000 0x0 0x1000&gt;;
+ 433             //interrupts-extended = &lt;&amp;plic0 31 IRQ_TYPE_LEVEL_HIGH&gt;;
+ 434             //clocks = &lt;&amp;ccu CLK_PLL_PERIPH0&gt;, &lt;&amp;ccu CLK_SPI0&gt;, &lt;&amp;ccu CLK_BUS_SPI0&gt;;
+ 435             //clock-names = "pll", "mod", "bus";
+ 436             //resets = &lt;&amp;ccu RST_BUS_SPI0&gt;;
+ 437             clock-frequency = &lt;100000000&gt;;
+ 438             pinctrl-names = "default", "sleep";
+ 439             spi1_cs_number = &lt;1&gt;;
+ 440             spi1_cs_bitmap = &lt;1&gt;;
+ 441             spi_slave_mode = &lt;0&gt;;
+ 442             //dmas = &lt;&amp;dma 22&gt;, &lt;&amp;dma 22&gt;;
+ 443             //dma-names = "tx", "rx";
+ 444             pinctrl-0 = &lt;&amp;spi1_pins_a &amp;spi1_pins_b&gt;;
+ 445             pinctrl-1 = &lt;&amp;spi1_pins_c&gt;;
+ 446             status = "okay";
+ 447             spi-nor {
+ 448                 compatible = "jedec,spi-nor";
+ 449                 spi-max-frequency=&lt;0x5F5E100&gt;;
+ 450                 reg = &lt;0x0&gt;;
+ 451                 spi-rx-bus-width=&lt;0x01&gt;;
+ 452                 spi-tx-bus-width=&lt;0x01&gt;;
+ 453                 status="okay";
+ 454             };
+ 455         };
+ 273             spi1_pins_a: spi1@0 {
+ 274                 allwinner,pins = "PD11", "PD12", "PD13","PD14", "PD15";
+ 275                 allwinner,pname = "spi1_sclk", "spi1_mosi","spi1_miso", "spi1_hold", "spi1_wp";
+ 276                 allwinner,function = "spi1";
+ 277                 allwinner,muxsel = &lt;4&gt;;
+ 278                 allwinner,drive = &lt;1&gt;;
+ 279                 allwinner,pull = &lt;0&gt;;
+ 280             };
+ 281
+ 282             spi1_pins_b: spi1@1 {
+ 283                 allwinner,pins = "PD10";
+ 284                 allwinner,pname = "spi1_cs0";
+ 285                 allwinner,function = "spi1";
+ 286                 allwinner,muxsel = &lt;4&gt;;
+ 287                 allwinner,drive = &lt;1&gt;;
+ 288                 allwinner,pull = &lt;1&gt;;   // only CS should be pulled up
+ 289             };
+ 290
+ 291             spi1_pins_c: spi1@2 {
+ 292                 allwinner,pins = "PD10", "PD11", "PD12", "PD13","PD14", "PD15";
+ 293                 allwinner,function = "gpio_in";
+ 294                 allwinner,muxsel = &lt;0&gt;;
+ 295                 allwinner,drive = &lt;1&gt;;
+ 296                 allwinner,pull = &lt;0&gt;;
+ 297             };
  307         };

</code></pre>
<p dir="auto">3.我看了一下drivers/sunxi_flash/sunxi_flash.c，貌似不是基于DM模型的驱动，这个是怎么调用的呀？大佬是否可以指导指导，还在学习阶段好多东西都不懂</p>
]]></description><link>https://bbs.aw-ol.com/post/8302</link><guid isPermaLink="true">https://bbs.aw-ol.com/post/8302</guid><dc:creator><![CDATA[haiqianghuang69]]></dc:creator><pubDate>Tue, 05 Jul 2022 01:32:58 GMT</pubDate></item><item><title><![CDATA[Reply to D1在uboot下的spi nor flash读写操作 on Fri, 01 Jul 2022 07:23:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://bbs.aw-ol.com/uid/1364">@haiqianghuang69</a> 参考sunxi_flash，我用的是这个</p>
]]></description><link>https://bbs.aw-ol.com/post/8261</link><guid isPermaLink="true">https://bbs.aw-ol.com/post/8261</guid><dc:creator><![CDATA[YuzukiTsuru]]></dc:creator><pubDate>Fri, 01 Jul 2022 07:23:41 GMT</pubDate></item></channel></rss>