Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    D1在uboot下的spi nor flash读写操作

    MR Series
    2
    3
    1484
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      haiqianghuang69 LV 3 last edited by haiqianghuang69

      回复: 在uboot下调用spi的sf_dataflash驱动报错

      求各位大佬有没有人尝试过在uboot下操作spi nor flash的读写。我用的是drivers/mtd/spi/sf_dataflash.c

      YuzukiTsuru 1 Reply Last reply Reply Quote Share 0
      • YuzukiTsuru
        柚木 鉉 LV 9 @haiqianghuang69 last edited by

        @haiqianghuang69 参考sunxi_flash,我用的是这个

        H 1 Reply Last reply Reply Quote Share 0
        • H
          haiqianghuang69 LV 3 @YuzukiTsuru last edited by haiqianghuang69

          @yuzukitsuru
          1.大佬是用什么sdk的呀?我用的是韦东山提供的buildroot工程neza-d1-buildroot,
          2.然后感觉那个uboot有点问题,不会遍历dts中第二层级的device,我在源码上参照那个clocks的来遍历第二层,第三层的device,在uboot 输入dm tree可以正常显示device对应的层级关系。只是第三层级的spinor没有绑定成功

          ///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->dm_root, gd->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", &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), &getdev);
          + 384         if (ret){
          + 385             pr_debug("debug, stil can not find device\n");
          + 386         }
          + 387     }
          + 388     ret = dm_scan_fdt_node(getdev, gd->fdt_blob, node.of_offset,pre_reloc_only);
          + 389     if (ret){
          + 390         pr_debug("dm_scan_fdt node faile\n");
          + 391     }
          
          

          修改后的串口dm tree打印

          => 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
          => 
          

          uboot的spi1 dts配置

          //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 = <2>;
             15     #size-cells = <2>;
          +  18     hellohqh: hello_dts_name@1234 {
          +  19
          +  20         #address-cells = <1>;
          +  21         #size-cells = <0>;
          +  22         compatible = "hello_dts";
          +  23         reg = <0x02000000>;
          +  24         pinctrl-names = "default", "sleep";
          +  25         pinctrl-0 = <&gpiotest_pins>;
          +  26
          +  27         hellohqh1: hello_dts_child@5678 {
          +  28             compatible = "hello_child_dts";
          +  29             reg = <0x31>;
          +  30             hellohqh2: hello_dts_child_child@99991 {
          +  31                 compatible = "hello_child_child_dts";
          +  32
          +  33                 };
          +  34           };
          +  35     };
          
             37     soc: soc@29000000 {
             38         #address-cells = <2>;
             39         #size-cells = <2>;
          
          + 427         spi1: spi@04026000 {
          + 428             //#address-cells = <1>;
          + 429             //#size-cells = <0>;
          + 430             compatible = "allwinner,sun20i-spi";
          + 431             device_type = "spi1";
          + 432             reg = <0x0 0x04026000 0x0 0x1000>;
          + 433             //interrupts-extended = <&plic0 31 IRQ_TYPE_LEVEL_HIGH>;
          + 434             //clocks = <&ccu CLK_PLL_PERIPH0>, <&ccu CLK_SPI0>, <&ccu CLK_BUS_SPI0>;
          + 435             //clock-names = "pll", "mod", "bus";
          + 436             //resets = <&ccu RST_BUS_SPI0>;
          + 437             clock-frequency = <100000000>;
          + 438             pinctrl-names = "default", "sleep";
          + 439             spi1_cs_number = <1>;
          + 440             spi1_cs_bitmap = <1>;
          + 441             spi_slave_mode = <0>;
          + 442             //dmas = <&dma 22>, <&dma 22>;
          + 443             //dma-names = "tx", "rx";
          + 444             pinctrl-0 = <&spi1_pins_a &spi1_pins_b>;
          + 445             pinctrl-1 = <&spi1_pins_c>;
          + 446             status = "okay";
          + 447             spi-nor {
          + 448                 compatible = "jedec,spi-nor";
          + 449                 spi-max-frequency=<0x5F5E100>;
          + 450                 reg = <0x0>;
          + 451                 spi-rx-bus-width=<0x01>;
          + 452                 spi-tx-bus-width=<0x01>;
          + 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 = <4>;
          + 278                 allwinner,drive = <1>;
          + 279                 allwinner,pull = <0>;
          + 280             };
          + 281
          + 282             spi1_pins_b: spi1@1 {
          + 283                 allwinner,pins = "PD10";
          + 284                 allwinner,pname = "spi1_cs0";
          + 285                 allwinner,function = "spi1";
          + 286                 allwinner,muxsel = <4>;
          + 287                 allwinner,drive = <1>;
          + 288                 allwinner,pull = <1>;   // 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 = <0>;
          + 295                 allwinner,drive = <1>;
          + 296                 allwinner,pull = <0>;
          + 297             };
            307         };
          
          

          3.我看了一下drivers/sunxi_flash/sunxi_flash.c,貌似不是基于DM模型的驱动,这个是怎么调用的呀?大佬是否可以指导指导,还在学习阶段好多东西都不懂

          1 Reply Last reply Reply Quote Share 0
          • 1 / 1
          • First post
            Last post

          Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

          行为准则 | 用户协议 | 隐私权政策