Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>sessyargc.jp's answer was sufficient; however, just for completeness, I wanted to offer a bit of C code that I used to print out some basic tree info from inside the driver:</p> <pre><code>#include &lt;linux/of_device.h&gt; #include &lt;linux/of_platform.h&gt; ... print_device_tree_node(of_find_node_by_path("/"), 0); ... static void print_device_tree_node(struct device_node *node, int depth) { int i = 0; struct device_node *child; struct property *properties; char indent[255] = ""; for(i = 0; i &lt; depth * 3; i++) { indent[i] = ' '; } indent[i] = '\0'; ++depth; for_each_child_of_node(node, child) { printk(KERN_INFO "%s{ name = %s\n", indent, child-&gt;name); printk(KERN_INFO "%s type = %s\n", indent, child-&gt;type); for (properties = child-&gt;properties; properties != NULL; properties = properties-&gt;next) { printk(KERN_INFO "%s %s (%d)\n", indent, properties-&gt;name, properties-&gt;length); } print_device_tree_node(child, depth); printk(KERN_INFO "%s}\n", indent); } } </code></pre> <p>I wish I knew how to determine each properties type, so I could format the value and output it correctly. Any suggestions?</p> <p>Lastly, here is the original snippet, modified oh-so slightly:</p> <pre><code>char *path = "/fpga_dt@c0000000"; struct device_node *dt_node; const u32 *property; int len; dt_node = of_find_node_by_path(path); if (!dt_node) { printk(KERN_ERR "(E) Failed to find device-tree node: %s\n", path); return -ENODEV; } printk(KERN_INFO "(I) Found device-tree node. Now retrieving property.\n"); property = of_get_property(dt_node, "reg", &amp;len); printk(KERN_INFO "(I) len=%d\n", len); printk(KERN_INFO "(I) reg[0]=0x%08lX\n", (unsigned long) property[0]); printk(KERN_INFO "(I) reg[1]=0x%08lX\n", (unsigned long) property[1]); printk(KERN_INFO "(I) reg[2]=0x%08lX\n", (unsigned long) property[2]); printk(KERN_INFO "(I) reg[3]=0x%08lX\n", (unsigned long) property[3]); </code></pre> <p>The seg-fault was happening on some bad device-tree paths. Apparently, there was some typeo error. I ultimately fixed the problem by probing the root path, and then some other basic nodes (like, /cpu0, /memory, etc.), and finally I was able to probe my fpga. I am not sure what really changed, but I am able to reference my FPGA's device-tree node correctly now, when using the above code.</p> <p>Thanks for all the help! :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload