<?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[CAN Bus: using MCP2515 with Omega2]]></title><description><![CDATA[<p dir="auto">I built a board with Omega2S+ and MCP2515.<br />
MCP2515 is connected to the SPI bus.<br />
CS1 and GPIO11 is used for CS# and INT# pins.</p>
<p dir="auto">Here's the device tree modification I made in <code>target/linux/ramips/dts/mt7628an_onion_omega2.dtsi</code> file.</p>
<pre><code>

&amp;spi0 {
	status = "okay";

	pinctrl-names = "default";
	pinctrl-0 = &lt;&amp;spi_pins&gt;, &lt;&amp;spi_cs1_pins&gt;;

	flash0: flash@0 {
		...
	};

	can0: can@1 {
		compatible = "microchip,mcp2515";
		reg = &lt;1&gt;;
		spi-max-frequency = &lt;5000000&gt;;
		clock-frequency  =  &lt;20000000&gt;;
		interrupt-parent = &lt;&amp;gpio&gt;;
		interrupts = &lt;11 IRQ_TYPE_EDGE_FALLING&gt;;
	};
};
</code></pre>
<p dir="auto">I choose <code>kmod-can-mcp251x</code> in configuration.<br />
After guilding and flashing, I could check the MCP2515 initialization success by <code>dmesg</code>.</p>
<p dir="auto">The <code>cansend</code> command worked, and I could see the correct CAN bus signal is outputting from MCP2515.<br />
But when I tried <code>candump</code> to get packets from external sensor modules, it didn't work.</p>
<p dir="auto">Did anyone successfully used MCP2515 in this way?</p>
]]></description><link>http://community.onion.io/topic/4892/can-bus-using-mcp2515-with-omega2</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 16:53:15 GMT</lastBuildDate><atom:link href="http://community.onion.io/topic/4892.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Nov 2022 11:12:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 11:20:57 GMT]]></title><description><![CDATA[<p dir="auto">I built a board with Omega2S+ and MCP2515.<br />
MCP2515 is connected to the SPI bus.<br />
CS1 and GPIO11 is used for CS# and INT# pins.</p>
<p dir="auto">Here's the device tree modification I made in <code>target/linux/ramips/dts/mt7628an_onion_omega2.dtsi</code> file.</p>
<pre><code>

&amp;spi0 {
	status = "okay";

	pinctrl-names = "default";
	pinctrl-0 = &lt;&amp;spi_pins&gt;, &lt;&amp;spi_cs1_pins&gt;;

	flash0: flash@0 {
		...
	};

	can0: can@1 {
		compatible = "microchip,mcp2515";
		reg = &lt;1&gt;;
		spi-max-frequency = &lt;5000000&gt;;
		clock-frequency  =  &lt;20000000&gt;;
		interrupt-parent = &lt;&amp;gpio&gt;;
		interrupts = &lt;11 IRQ_TYPE_EDGE_FALLING&gt;;
	};
};
</code></pre>
<p dir="auto">I choose <code>kmod-can-mcp251x</code> in configuration.<br />
After guilding and flashing, I could check the MCP2515 initialization success by <code>dmesg</code>.</p>
<p dir="auto">The <code>cansend</code> command worked, and I could see the correct CAN bus signal is outputting from MCP2515.<br />
But when I tried <code>candump</code> to get packets from external sensor modules, it didn't work.</p>
<p dir="auto">Did anyone successfully used MCP2515 in this way?</p>
]]></description><link>http://community.onion.io/post/24896</link><guid isPermaLink="true">http://community.onion.io/post/24896</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Thu, 10 Nov 2022 11:20:57 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 13:12:44 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://community.onion.io/search?term=MCP2515&amp;in=titlesposts" rel="nofollow">https://community.onion.io/search?term=MCP2515&amp;in=titlesposts</a></p>
]]></description><link>http://community.onion.io/post/24897</link><guid isPermaLink="true">http://community.onion.io/post/24897</guid><dc:creator><![CDATA[crispyoz]]></dc:creator><pubDate>Thu, 10 Nov 2022 13:12:44 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 13:26:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/6184">@crispyoz</a> I've checked all these threads before.<br />
They were using bitbanged version, modified MCP251x driver.<br />
Can't it be done with non-bitbanged driver of GBert?</p>
]]></description><link>http://community.onion.io/post/24898</link><guid isPermaLink="true">http://community.onion.io/post/24898</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Thu, 10 Nov 2022 13:26:30 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 13:46:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a> Alas not my area of expertise. However if my project require robust full duplex, I'd use something that supported it. <em><strong>duck from flames</strong></em></p>
]]></description><link>http://community.onion.io/post/24899</link><guid isPermaLink="true">http://community.onion.io/post/24899</guid><dc:creator><![CDATA[crispyoz]]></dc:creator><pubDate>Thu, 10 Nov 2022 13:46:05 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 13:54:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/6184">@crispyoz</a><br />
Indeed. I totally agree with you.<br />
Unfortunately, I am now working on the existing project.<br />
Moving to some other platform will require a lot of work of porting existing software, that are already developed for Omega2.</p>
]]></description><link>http://community.onion.io/post/24900</link><guid isPermaLink="true">http://community.onion.io/post/24900</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Thu, 10 Nov 2022 13:54:00 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 13:59:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a> I think <a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/1033">@luz</a> and <a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/95">@Lazar-Demin</a> have expertise in this area so tagging them here.</p>
]]></description><link>http://community.onion.io/post/24901</link><guid isPermaLink="true">http://community.onion.io/post/24901</guid><dc:creator><![CDATA[crispyoz]]></dc:creator><pubDate>Thu, 10 Nov 2022 13:59:04 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 15:25:17 GMT]]></title><description><![CDATA[<p dir="auto">For the Kernel update from 5.4 -&gt; 5.5, the MCP251x driver has updated to support half-duplex SPI masters.<br />
It automatically detects the SPI mode whether it is full or half duplex like this.</p>
<pre><code class="language-c">    if (spi-&gt;controller-&gt;flags &amp; SPI_CONTROLLER_HALF_DUPLEX) {
</code></pre>
<p dir="auto">I am now working with OpenWrt 22.03, which has Kernel 5.10 version.<br />
Thus it should work out of the box. At least, I expected so.<br />
But it seems like still IRQ problem is in my device tree setting.</p>
]]></description><link>http://community.onion.io/post/24902</link><guid isPermaLink="true">http://community.onion.io/post/24902</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Thu, 10 Nov 2022 15:25:17 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 18:21:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a> Two avenues to pursue here:</p>
<h2>1) SPI issue</h2>
<p dir="auto">The Omega2 family does not support full-duplex SPI transmissions because of a hardware bug in the underlying MT7688 SoC used in the Omega2. More details in <a href="https://community.onion.io/topic/3300/faq-i-heard-there-is-some-issue-with-hardware-spi-and-full-duplex-spi" rel="nofollow">this FAQ post</a>.</p>
<p dir="auto">The MT7688 is intended to support full-duplex, so it will have all of the full-duplex flags. I'm not sure how that will impact your driver.<br />
An alternative would be to setup software based SPI and instantiate your mcp2515 driver on the software SPI. We have <a href="https://community.onion.io/topic/4500/faq-how-can-i-make-a-software-based-bit-bang-spi-bus-i-need-2-spi-devices-can-i-use-any-4-gpios-as-an-spi-bus" rel="nofollow">information on how to setup a sw SPI bus from userspace</a>, but we don't have experience with sw SPI using the DTS file.</p>
<h2>2) IRQ GPIO in DTS</h2>
<p dir="auto">If I'm reading the DTS file correctly, these lines mean that GPIO11 being is used for the interrupt line?</p>
<pre><code>		interrupt-parent = &lt;&amp;gpio&gt;;
		interrupts = &lt;11 IRQ_TYPE_EDGE_FALLING&gt;;
</code></pre>
<p dir="auto">Using GPIO11 might be causing the issue. From our <a href="http://docs.onion.io/omega2-docs/using-gpios.html#important-special-gpios" rel="nofollow">GPIO documentation article</a>:<br />
<img src="/assets/uploads/files/1668104374360-78073147-ff6f-41d7-8f7f-741771ddefbb-image.png" alt="78073147-ff6f-41d7-8f7f-741771ddefbb-image.png" class="img-responsive img-markdown" /></p>
<p dir="auto">Is there any way you can use a different GPIO for the interrupt line? Even if it's temporary, just to confirm this is causing the issue.<br />
Any GPIO not listed as a <a href="http://docs.onion.io/omega2-docs/using-gpios.html#important-special-gpios" rel="nofollow">special pin</a> will do fine.</p>
]]></description><link>http://community.onion.io/post/24903</link><guid isPermaLink="true">http://community.onion.io/post/24903</guid><dc:creator><![CDATA[Lazar Demin]]></dc:creator><pubDate>Thu, 10 Nov 2022 18:21:05 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Fri, 27 Jan 2023 03:12:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/95">@Lazar-Demin</a><br />
Thank you for thorough reply.</p>
<h3>1) SPI issue</h3>
<p dir="auto">If so - MT7688 is designed for full-duplex but working as half-duplex by design bug, it may not have <code>SPI_CONTROLLER_HALF_DUPLEX</code> flag. Thus the <code>kmod-can-mcp251x</code> may go into full duplex mode.</p>
<p dir="auto">I will try to insert <code>printk</code> statements to see the half-duplex mode activation via <code>dmesg</code></p>
<p dir="auto">I cannot use software SPI, as it requires the MCP2515 wired to GPIO pins, instead of hardware SPI pins.<br />
I designed my board with Omega2S+, build PCBA prototyping using <a href="https://pcbcrew.com" rel="nofollow">PCBCrew</a> prototyping service.<br />
So it's not so simple to change wiring at the moment.</p>
<h3>2) IRQ GPIO in DTS</h3>
<p dir="auto">Yes, GPIO11 is used for interrupt pin. The reason I used it is like this. There was old project based on OpenWrt 18.06. The old hardware used GPIO11 for interrupt pin. We lost connection with the old developer team.</p>
<p dir="auto">The old developers patched the MCP251x driver of Kernel 4.14 for half-duplex support.<br />
At the time of their working, half-duplex MCP251x driver was not yet there in Linux mainline.<br />
However, since Linux kernel upgrade 5.5+, MCP251x driver changed a certain amount.<br />
I tried to use the old patched version of driver, but it was written for Kernel 4.14 and not compatible with current 5.10 of OpenWrt 22.03.</p>
<p dir="auto">The old DTS has the following GPIO configuration. It might be related the issue you mentioned.</p>
<pre><code>		canInt {
			label = "canInt";
			gpios = &lt;&amp;gpio 11 GPIO_ACTIVE_LOW&gt;;
		};
</code></pre>
<p dir="auto">By the way, I am using OpenWrt 22.03 custom build.<br />
Does my built image is boot by Omega2's bootloader?<br />
I thought <code>u-boot</code> is managing boot sequence in custom built image.</p>
]]></description><link>http://community.onion.io/post/24904</link><guid isPermaLink="true">http://community.onion.io/post/24904</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Fri, 27 Jan 2023 03:12:40 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 10 Nov 2022 20:31:08 GMT]]></title><description><![CDATA[<p dir="auto">Current hardware schematics is here.<br />
<a href="https://github.com/dumtux/omega2-4g-gateway/blob/develop/doc/schematics-v3.0a2.pdf" rel="nofollow">https://github.com/dumtux/omega2-4g-gateway/blob/develop/doc/schematics-v3.0a2.pdf</a></p>
<p dir="auto"><img src="/assets/uploads/files/1668111302010-screenshot-from-2022-11-11-04-14-36.png" alt="Screenshot from 2022-11-11 04-14-36.png" class="img-responsive img-markdown" /></p>
<p dir="auto">The following picture shows the board in action.<br />
The module in my hand is an angle sensor, that is emitting CAN messages.<br />
I checked it's working correctly with oscilloscope.<br />
I am trying to get the CAN packet with <code>candump</code> command.</p>
<p dir="auto"><img src="/assets/uploads/files/1668111730154-screenshot-from-2022-11-11-04-21-47.png" alt="Screenshot from 2022-11-11 04-21-47.png" class="img-responsive img-markdown" /></p>
<p dir="auto">I could see the <code>can0</code> is present by <code>ipconfig</code>, and I could up the link, send packets by <code>cansend</code> command.<br />
What I am stuck is that <code>candump</code> is not working. As there is IRQ issue.</p>
<pre><code class="language-text">root@OpenWrt:~# dmesg | grep -i mcp251x
[  395.392687] mcp251x spi0.1 can0: MCP2515 successfully initialized.
root@OpenWrt:~# ip l | grep -i can
6: can0: &lt;NOARP,ECHO&gt; mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can 
root@OpenWrt:~# ip link set can0 up type can bitrate 125000
root@OpenWrt:~# candump can0
(nothing happens from here ...)
</code></pre>
]]></description><link>http://community.onion.io/post/24905</link><guid isPermaLink="true">http://community.onion.io/post/24905</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Thu, 10 Nov 2022 20:31:08 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Fri, 11 Nov 2022 01:29:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/95">@Lazar-Demin</a> and <a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/6184">@crispyoz</a><br />
I added the following debug lines into <code>mcp251x.c</code> to check if it's going into half-duplex mode correctly.</p>
<pre><code class="language-c">		...
		printk("MCP251x-MT7688 : spi-&gt;controller-&gt;flags : %d", spi-&gt;controller-&gt;flags);
		printk("MCP251x-MT7688 : SPI_CONTROLLER_HALF_DUPLEX : %ld", SPI_CONTROLLER_HALF_DUPLEX);
		if (spi-&gt;controller-&gt;flags &amp; SPI_CONTROLLER_HALF_DUPLEX) {
			printk("MCP251x-MT7688 : set as half-duplex mode");
			...
</code></pre>
<p dir="auto">And made it as a temporal <code>mcp251x-mt7688</code> module and installed it after compilation.<br />
Here's <code>dmesg</code> result.</p>
<pre><code class="language-text">root@OpenWrt:~# dmesg | grep -i mt7688
[    0.000000] SoC Type: MediaTek MT7688 ver:1 eco:2
[   52.310755] MCP251x-MT7688 : spi-&gt;controller-&gt;flags : 1
[   52.310769] MCP251x-MT7688 : SPI_CONTROLLER_HALF_DUPLEX : 1
[   52.325683] MCP251x-MT7688 : set as half-duplex mode
[   52.331336] MCP251x-MT7688 : spi-&gt;controller-&gt;flags : 1
[   52.336382] MCP251x-MT7688 : SPI_CONTROLLER_HALF_DUPLEX : 1
[   52.355689] MCP251x-MT7688 : set as half-duplex mode
root@OpenWrt:~# 
</code></pre>
<p dir="auto">As we can see, the MCP251x driver works as half-duplex mode on MT7688 CPU.<br />
Thus my problem certainly related to the IRQ only.<br />
Still need your helps.</p>
]]></description><link>http://community.onion.io/post/24906</link><guid isPermaLink="true">http://community.onion.io/post/24906</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Fri, 11 Nov 2022 01:29:09 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Fri, 11 Nov 2022 02:07:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/95">@Lazar-Demin</a></p>
<h4>2) IRQ GPIO in DTS</h4>
<p dir="auto">After confirming that the MCP251x driver is initialized as half-duplex mode as desired, I came back to investigate IRQ issue.<br />
I measured the GPIO11 with an oscilloscope. The result was exactly like you mentioned.<br />
BPIO11 was always HIGH and never tirggered even though there are incoming packets.</p>
<p dir="auto">Is there a quick way to check if GPIO11 is released from Omega2's bootloader for general-purpose use?<br />
In other word, how can I check the IRQ is properly configured on GPIO11?</p>
]]></description><link>http://community.onion.io/post/24907</link><guid isPermaLink="true">http://community.onion.io/post/24907</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Fri, 11 Nov 2022 02:07:16 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Fri, 11 Nov 2022 20:58:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a> said in <a href="/post/24907">CAN Bus: using MCP2515 with Omega2</a>:</p>
<blockquote>
<p dir="auto">Is there a quick way to check if GPIO11 is released from Omega2's bootloader for general-purpose use?</p>
</blockquote>
<p dir="auto">If you can "export" it via the '/sys/class/gpio' interface (before loading your driver that may try to use it, and possibly block it even if not successful establishing it as IRQ), then it should be available.</p>
<p dir="auto">However, when you are using unpatched 22.03, the <code>/sys/class/gpio</code> interface (deprecated by now) will have completely strange GPIO numbering: GPIO 0..31 -&gt; 480..511, GPIO 32..63 = 448..479.<br />
So you'd need to export GPIO 491 to get GPIO 11.</p>
<p dir="auto">I am using <a href="https://gist.github.com/plan44/2db24a1238cbc1447df9a962c35ddbc2" rel="nofollow">a patch on top of 22.03</a> to bring back the <code>gpio-base</code> DT property which allows to revert the numbering back to what it was in 19.07. New projects should use the new gpiod interface, but this is not entirely ready yet, <a href="https://forum.openwrt.org/t/state-of-userland-access-to-gpio-based-hardware/130505" rel="nofollow">see my attempt to find out what the status of GPIOs in OpenWrt is</a>.</p>
]]></description><link>http://community.onion.io/post/24910</link><guid isPermaLink="true">http://community.onion.io/post/24910</guid><dc:creator><![CDATA[luz]]></dc:creator><pubDate>Fri, 11 Nov 2022 20:58:12 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Fri, 11 Nov 2022 23:44:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a> said in <a href="/post/24912">CAN Bus: using MCP2515 with Omega2</a>:<br />
Fabulous!<br />
After a few seconds of power on, GPIO11 went to HIGH status and never dropped to LOW level while MCP2515 operating. Instead, after CAN bus enabling, the GPIO11 voltage was ~2.0V.<br />
I think it was because MCP2515 was trying to pull down, while Omega2 is trying to output HIGH.</p>
<p dir="auto">But with that GPIO number fixing, it dropped to LOW after CAN bus enabling.<br />
Here's the results.</p>
<pre><code class="language-text">root@OpenWrt:~# ls /sys/class/gpio/
export       gpiochip416  gpiochip448  gpiochip480  unexport
root@OpenWrt:~# echo 491 &gt; /sys/class/gpio/export 
root@OpenWrt:~# ls /sys/class/gpio/
export       gpio491      gpiochip416  gpiochip448  gpiochip480  unexport
root@OpenWrt:~# cat /sys/class/gpio/gpio491/direction 
out
root@OpenWrt:~# echo in &gt; /sys/class/gpio/gpio491/direction 
root@OpenWrt:~# cat /sys/class/gpio/gpio491/direction 
in
root@OpenWrt:~# insmod /lib/modules/5.10.146/mcp251x.ko 
root@OpenWrt:~# ip l | grep can
6: can0: &lt;NOARP,ECHOmtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can 
root@OpenWrt:~# ip link set can0 up type can bitrate 125000
root@OpenWrt:~# 
</code></pre>
<p dir="auto">Just after this <code>ip link set can0 up</code> command ran, the GPIO11 dropped to LOW.<br />
I think MCP2515 is pulling down the INT# pin as it is constantly receiving packets from external sensor.</p>
<p dir="auto">I'll keep my further working results posted.</p>
]]></description><link>http://community.onion.io/post/24913</link><guid isPermaLink="true">http://community.onion.io/post/24913</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Fri, 11 Nov 2022 23:44:07 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Sun, 13 Nov 2022 18:59:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/1033">@luz</a> <a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/95">@Lazar-Demin</a> <a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/6184">@crispyoz</a> and all!<br />
I am still having trouble with CAN bus driving.</p>
<h3>Current behavior</h3>
<ul>
<li><strong>I set GPIO11 as input and load the MCP251x kernel module as per above discussion.</strong></li>
<li><strong>Now enable <code>can0</code> and send packets using these commands.</strong></li>
</ul>
<pre><code class="language-text">root@OpenWrt:~# ip link set can0 up type can bitrate 125000
root@OpenWrt:~# cansend can0 01a#11223344AABBCCDD
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1668353150700-screenshot-from-2022-11-13-23-25-25.png" alt="Screenshot from 2022-11-13 23-25-25.png" class="img-responsive img-markdown" /></p>
<ul>
<li><strong>I can see the waveform on bus by oscilloscope correctly.</strong></li>
<li><strong>Restart the bus as loopback mode to test somthing different.</strong></li>
</ul>
<pre><code class="language-text">root@OpenWrt:~# ip link set can0 down
root@OpenWrt:~# ip link set can0 up type can bitrate 125000 loopback on
</code></pre>
<ul>
<li><strong>Now the INT# (GPIO11) falls to LOW. MCP2515 stopped working.<br />
*** MCP2515 does not recover even though I disable/enable the bus again like this.</strong></li>
</ul>
<pre><code class="language-text">root@OpenWrt:~# ip link set can0 down
root@OpenWrt:~# ip link set can0 up type can bitrate 125000
</code></pre>
<ul>
<li><strong>I have to turn off the board power and turn it on again to make MCP2515 INT# recovered.</strong></li>
<li><strong><code>dmesg</code> shows nothing except success logs like this during all these operation.</strong></li>
</ul>
<pre><code class="language-text">...
[   68.586340] mcp251x spi0.1 can0: MCP2515 successfully initialized.
[   69.759118] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[  124.360819] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
...
</code></pre>
<ul>
<li><strong>The same situation goes for when I connect external sensor module, that emits CAN message periodically.</strong></li>
<li><strong>As soon as any external packet is coming in, the MCP2515 INT# falls to LOW. I can read nothing via <code>candump</code>.</strong></li>
<li><strong>All this behavior were the same no matter of setting GPIO11 as IN or not before loading the MCP251x kernel module.</strong></li>
</ul>
<h3>Questions</h3>
<ul>
<li>Is this still IRQ problem?</li>
<li>Is there any way to check MCP2515 resistor values using <code>canutils</code> package commands?</li>
<li>Is there other reading method except <code>candump</code> ? For example, instead of inturrupt-based <code>candump</code>, manual polling.</li>
</ul>
]]></description><link>http://community.onion.io/post/24923</link><guid isPermaLink="true">http://community.onion.io/post/24923</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Sun, 13 Nov 2022 18:59:14 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 17 Nov 2022 15:06:55 GMT]]></title><description><![CDATA[<p dir="auto">I am going to try to modify the bootloader to not handle GPIO11 for the dock power supply.<br />
There is a <a href="https://github.com/OnionIoT/omega2-bootloader" rel="nofollow">bootloader on OnionIoT GitHub account</a>, but it seems like outdated.<br />
And I could not find the current OpenWrt 22.03 build using it.</p>
<p dir="auto">Thus, I guess GPIO11 handling is somewhere patched inside OpenWrt 22.03's specific config files.<br />
I could see some MediaTek related config patches under <code>openwrt/package/boot/uboot-mediatek/</code>.<br />
There I either cannot find specific configs related to Omega2.<br />
As MT76x8 is used in router products a lot, I don't believe the Omega2 specific config will be under this location.</p>
<p dir="auto">Where can I find the OpenWrt 22.03 bootloader for Omega2?</p>
]]></description><link>http://community.onion.io/post/24946</link><guid isPermaLink="true">http://community.onion.io/post/24946</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Thu, 17 Nov 2022 15:06:55 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 17 Nov 2022 15:22:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a> The bootloader is independent of the firmware. If you've reflashed your Omega2, it will still be running the factory bootloader.</p>
<p dir="auto">The factory bootloader is compiled from this source code: <a href="https://github.com/OnionIoT/omega2-bootloader/" rel="nofollow">https://github.com/OnionIoT/omega2-bootloader/</a><br />
GPIO11 is set high to be compatible with the reset button on the Omega2 Docks. You can find that here in the bootloader: <a href="https://github.com/OnionIoT/omega2-bootloader/blob/master/lib_mips/board.c#L3028" rel="nofollow">https://github.com/OnionIoT/omega2-bootloader/blob/master/lib_mips/board.c#L3028</a></p>
<p dir="auto">When you've compiled your own bootloader, follow these instructions to update your device: <a href="http://docs.onion.io/omega2-docs/Web-Recovery-flash-bootloader.html" rel="nofollow">http://docs.onion.io/omega2-docs/Web-Recovery-flash-bootloader.html</a></p>
]]></description><link>http://community.onion.io/post/24947</link><guid isPermaLink="true">http://community.onion.io/post/24947</guid><dc:creator><![CDATA[Lazar Demin]]></dc:creator><pubDate>Thu, 17 Nov 2022 15:22:32 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Thu, 17 Nov 2022 23:39:34 GMT]]></title><description><![CDATA[<pre><code class="language-c">void gpio_init(void)
{
  ....
  RALINK_REG(RT2880_REG_PIODIR+0x04)=val;

  /*
  //zh@onion.io
  //setting GPIO 11 High, required for the reset button to work
  val=RALINK_REG(RT2880_REG_PIODIR);
  val|=1&lt;&lt;11;
  RALINK_REG(RT2880_REG_PIODIR) = val; // GPIO 11 direction output
  val=RALINK_REG(RT2880_REG_PIODATA);
  val|=1&lt;&lt;11;
  RALINK_REG(RT2880_REG_PIODATA) = val; // GPIO 11 High
  */

  //jeffzhou@onion.io
  //adding for read wifi MAC address.
  unsigned char macbuf[6];
	raspi_read(macbuf, CFG_FACTORY_ADDR - CFG_FLASH_BASE + 0x04, 6);
	printf("wifi mac address = %02X%02X%02X%02X%02X%02X.\n",
      macbuf[0],macbuf[1],macbuf[2],macbuf[3],macbuf[4],macbuf[5]);
}
</code></pre>
<p dir="auto">I commented the GPIO11 related part in the bootloader source code, and built it.<br />
Just used <code>make</code> command.</p>
<p dir="auto">After entering to Web recovery mode on Omega2's boot, I went to uBoot upgrade page.<br />
There was <strong>Very dangerous</strong> warning, but I proceeded.<br />
And after done, that dangerous result happened - not booting.</p>
<p dir="auto"><img src="/assets/uploads/files/1668727662047-screenshot-from-2022-11-18-07-25-31.png" alt="Screenshot from 2022-11-18 07-25-31.png" class="img-responsive img-markdown" /></p>
<p dir="auto">Is there some <code>make</code> option to build a bootloader specfic for Omega2+ ?</p>
]]></description><link>http://community.onion.io/post/24952</link><guid isPermaLink="true">http://community.onion.io/post/24952</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Thu, 17 Nov 2022 23:39:34 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Fri, 18 Nov 2022 02:07:44 GMT]]></title><description><![CDATA[<p dir="auto">As a comparison, this is normal booting screenshot from the factory bootloader.<br />
It is showing DRAM size 128MB, while my above wrong bootloader shows as 64MB.<br />
Also, flash memory is wrongly recognized.</p>
<p dir="auto"><img src="/assets/uploads/files/1668737123803-screenshot-from-2022-11-18-10-05-07.png" alt="Screenshot from 2022-11-18 10-05-07.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://community.onion.io/post/24959</link><guid isPermaLink="true">http://community.onion.io/post/24959</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Fri, 18 Nov 2022 02:07:44 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Fri, 18 Nov 2022 20:56:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a> Make sure to run <code>setup_env.sh</code> and then you can use <code>build.sh</code> to build the bootloader binaries.</p>
]]></description><link>http://community.onion.io/post/24971</link><guid isPermaLink="true">http://community.onion.io/post/24971</guid><dc:creator><![CDATA[Lazar Demin]]></dc:creator><pubDate>Fri, 18 Nov 2022 20:56:40 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Sun, 20 Nov 2022 21:11:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/95">@Lazar-Demin</a><br />
How can I build a U-Boot image for Omega2+ ?</p>
]]></description><link>http://community.onion.io/post/24983</link><guid isPermaLink="true">http://community.onion.io/post/24983</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Sun, 20 Nov 2022 21:11:39 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Mon, 21 Nov 2022 02:57:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a> The process is:</p>
<p dir="auto">git clone <a href="https://github.com/OnionIoT/omega2-bootloader/" rel="nofollow">https://github.com/OnionIoT/omega2-bootloader/</a><br />
cd omega2-bootloader<br />
./setup_env.sh<br />
chmod +x <a href="http://build.sh" rel="nofollow">build.sh</a><br />
./build.sh</p>
<p dir="auto">This produces 2 files:</p>
<p dir="auto">uboot-omega2-&lt;date&gt;.bin<br />
uboot-omega2p-&lt;date&gt;.bin</p>
<p dir="auto">The latter is the Omega2+ uboot</p>
]]></description><link>http://community.onion.io/post/24986</link><guid isPermaLink="true">http://community.onion.io/post/24986</guid><dc:creator><![CDATA[crispyoz]]></dc:creator><pubDate>Mon, 21 Nov 2022 02:57:21 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Mon, 28 Nov 2022 11:04:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/6184">@crispyoz</a> <a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/95">@Lazar-Demin</a><br />
Yes, it worked. I choose the <code>omgega2-bootloader</code> instead of <code>omega2p-bootloader</code> accidentally.<br />
After soldering with a brand new Omeba2S+ module, I carefully upgraded bootloader.</p>
<p dir="auto">Here's the pre-compiled bootloader for others' future reference.<br />
<a href="https://github.com/dumtux/omega2-bootloader/releases/tag/tower-bootloader-v0.1" rel="nofollow">https://github.com/dumtux/omega2-bootloader/releases/tag/tower-bootloader-v0.1</a></p>
<p dir="auto">After disabling GPIO11 default behavior from Omega2's bootloader, I could see some different behavior of MCP2515 kernel driver.<br />
I could see some short impulses while initializing MCP2515 driver and enabling <code>can0</code> interface.<br />
I didn't see such impulses before with the default bootloader.</p>
<p dir="auto">I'll keep posting further results.</p>
]]></description><link>http://community.onion.io/post/25018</link><guid isPermaLink="true">http://community.onion.io/post/25018</guid><dc:creator><![CDATA[DumTux]]></dc:creator><pubDate>Mon, 28 Nov 2022 11:04:30 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Tue, 29 Nov 2022 13:47:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/8969">@DumTux</a><br />
AFAIK the main problem is related to the wrong GPIO/IRQ mapping:<br />
<a href="https://forum.openwrt.org/t/can-mcp2515-gpio-irq-problem/92879/3" rel="nofollow">https://forum.openwrt.org/t/can-mcp2515-gpio-irq-problem/92879/3</a></p>
<p dir="auto">Maybe luz or Lazar could give a hint ?</p>
]]></description><link>http://community.onion.io/post/25021</link><guid isPermaLink="true">http://community.onion.io/post/25021</guid><dc:creator><![CDATA[Gerhard Bertelsmann]]></dc:creator><pubDate>Tue, 29 Nov 2022 13:47:36 GMT</pubDate></item><item><title><![CDATA[Reply to CAN Bus: using MCP2515 with Omega2 on Wed, 30 Nov 2022 00:16:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/3384">@Gerhard-Bertelsmann</a> Yes, the 19.07 version of <code>gpio-mt7621.c</code> interrupt routing implementation is broken for GPIO interrupts assigned via DT.</p>
<p dir="auto">I made ugly patches to fix that back then, I can dig them out if someone wants to use them, but I can't exactly recommend (it was kind of an emergency hack for an urgent project).</p>
<p dir="auto">As far as I know, the issue should be fixed in the 22.03 version of <code>gpio-mt7621.c</code>, as the entire driver has been reworked to align with other modern GPIO drivers and handles the banks differently.</p>
<p dir="auto">But I haven't had the chance to test it so far, and the link to the OpenWrt forum you posted saying it is <em>not</em> yet fixed in 21.02 makes me doubt a bit, because I thought the rework already happened in the 21.02 time frame, but I can't verify or test that right now.</p>
]]></description><link>http://community.onion.io/post/25026</link><guid isPermaLink="true">http://community.onion.io/post/25026</guid><dc:creator><![CDATA[luz]]></dc:creator><pubDate>Wed, 30 Nov 2022 00:16:35 GMT</pubDate></item></channel></rss>