Difference between revisions of "Recans A0"

From iagent
Jump to: navigation, search
 
(9 intermediate revisions by the same user not shown)
Line 18: Line 18:
  
 
<pre>
 
<pre>
sudo ip link set can0 type can bitrate 1000000
+
sudo ip link set can0 type can bitrate 125000
 +
sudo ip link set can0 txqueuelen 128
 
sudo ip link set up can0
 
sudo ip link set up can0
sudo ifconfig can0 txqueuelen 128
 
 
</pre>
 
</pre>
  
Line 39: Line 39:
 
<pre>
 
<pre>
 
~/klippy-env/bin/python ~/klipper/scripts/canbus_query.py can0
 
~/klippy-env/bin/python ~/klipper/scripts/canbus_query.py can0
 +
</pre>
 +
 +
<pre>
 +
candump -tz -Ddex can0,#FFFFFFFF
 
</pre>
 
</pre>
  
Line 57: Line 61:
  
  
===Errata===
+
===Hardware Errata===
 
* SPI_CLK and SPI_MOSI are interchanged and need to be fixed.  
 
* SPI_CLK and SPI_MOSI are interchanged and need to be fixed.  
 
* /RESET is floating.
 
* /RESET is floating.
  
 +
===Error messages===
 +
When sending:
 +
- write: No buffer space available
 +
 +
Got error -1 in can write: (105)No buffer space available
 +
 +
After that I get:
 +
                                         
 +
DROPCOUNT: dropped 109 CAN frames on 'can0' socket (total drops 576)
 +
 +
(302.908159)  can0  RX - -  20000004  [8]  00 01 00 00 00 00 00 00  ERRORFRAME                 
 +
        controller-problem{rx-overflow} 
 +
 +
And the INT pin remains low. Needs a restart.
  
 
===Debug===
 
===Debug===

Latest revision as of 00:28, 25 February 2024

Recans A0 has two controllers, one is based on RP2040, the other on MCP2515.

The MCP2515 CAN controller

sudo mount -o remount,rw /boot
sudo armbian-add-overlay /boot/overlay-user/sun50i-a64-mcp251x.dts
sudo mount -o remount,ro /boot

After booting:

sudo gpioset 1 165=0
sudo modprobe -r mcp251x
sudo modprobe mcp251x
dmesg | grep mcp
sudo ip link set can0 type can bitrate 125000
sudo ip link set can0 txqueuelen 128
sudo ip link set up can0

Interrupt: STEP7 = PL11

sudo apt install net-tools can-utils
cansend can1 5A1#11.2233.44556677.88
ip -details link show can0
~/klippy-env/bin/python ~/klipper/scripts/canbus_query.py can0
candump -tz -Ddex can0,#FFFFFFFF

To compile the RP2040 with klipper:

cd ~/klipper
cp test/configs/rp2040.config .config
make menuconfig
-- Communication interface = RP2040
-- RX = GPIO4
-- TX = GPIO5
make
sudo apt install libusb-1.0-0-dev
sudo FLASH_DEVICE="2e8a:0003" make flash


Hardware Errata

  • SPI_CLK and SPI_MOSI are interchanged and need to be fixed.
  • /RESET is floating.

Error messages

When sending: - write: No buffer space available

Got error -1 in can write: (105)No buffer space available

After that I get:

DROPCOUNT: dropped 109 CAN frames on 'can0' socket (total drops 576)

(302.908159) can0 RX - - 20000004 [8] 00 01 00 00 00 00 00 00 ERRORFRAME

       controller-problem{rx-overflow}   

And the INT pin remains low. Needs a restart.

Debug

During init/reset:

TX: 0xC0 = RESET

TX: 0x03 0x0E 0x00 = READ CANSTAT
RX: 0x00 0x00 0x80 = Device is in Configuration mode

TX: 0x03 0x0F 0x00 = READ CANCTRL
RX: ? 

TX: 0x02 0x0F 0x20 = WRITE CANCTL = Sleep Mode


When trying to set interface up:

TX: 0x02 0x0F 0x80 = WRITE CANCTRL REQOP2 = Configuration Mode
RX: 0x00 0x00 0x00 
TX: 0x03 0x0E 0x00 = READ CANSTAT
RX: 0x00 0x00 0x64 = OPMOD[2:0] = 0b011, ICOD[2:0] = 0b010

Device is in Listen-Only mode, Wake-up interrupt


It seems that the bring up sequence interferes with the initialization. Must make sure the mcp2515 probing is done after power is applied.