since the SystemCore device is based on a CM5, I’m wondering if the WPIlib suite, including DS communication and actuator heartbeat, will be able to run on a raspberry pi? for training scenarios in the lab, we don’t need everything the SystemCore offers, in fact we really only need an RPi with a CAN hat. Would that work?
Keep in mind the SystemCore is an expansion board. Even if you can run the full systemcore OS/Image on it there will be issues like “DEVICE NOT FOUND” galore
Assuming when you say Training, you meant programming, then your best bet is the XRP. It doesn’t have a CAN hat - no SW support yet in the WPILIB as far as I know but I haven’t been keeping up with the XRP in a while so I can be off here.
The ROMI should still work too but I haven’t touched one in a long while so I could also be wrong.
Well the HAL expects everything to be there, an alternate HAL would need to be created for a more limited device. Which takes work and time to do and support.
Additionally, we don’t own the heartbeat and DS comm code, so that’s not really a WPILib decision to make. The actuator heartbeat is a kernel module, so at minimum you’d need to compile a custom Pi kernel to add that in.
I flashed a Pi 5 with the Systemcore Alpha 3 image just to test. Driver Station is able to connect, and robot.local is reachable, but as expected, it doesn’t fully work. Although WPILib is able to successfully deploy the robot code, the Driver Station reports no robot code.
Note: for the use case it’s intended for, it seems like the forthcoming SystemCore will be terrific, and I don’t want my interest to seem unsupportive. We should support this project! We should buy lots of them! But if you already have dozens of Raspberry Pi’s, as we do, it would be cool to be able to use them too.
I am trying to communicate with an MCP2515 connected to an Arduino using an MCP2515 connected to a Raspberry Pi, to test if SPI-CAN communication is doable. At 500 kbps, messages are delivered both ways without any issues, but when I go above that speed, it starts causing problems.
I’m currently using bit banging because I couldn’t get the Python spidev library installed, and the MOSI-MISO loopback test failed as well. I’m guessing the loopback failure might be because the GPIO setup was originally made for the CM5.
I’m not an expert in this area and I have no idea what I am doing, so any guidance would be much appreciated.
Also, sorry — I meant to reply to my own message but accidentally replied to truher instead.
This is on the Raspberry Pi side? You should use the mcp2515 kernel driver and socketcan instead. On a Raspberry Pi you can enable this by applying one of the device tree overlays for use with the mcp2515.
I’ll note that even using that driver, it may struggle to reliably receive all messages at high bitrates on a bus with high utilization- this is due to the fact that the mcp2515 can only hold 2 received messages at a time, and if the host processor (the pi, in this case) hasn’t read the message before more messages arrive, the incoming messages will be dropped. The pi receives an interrupt request every time a message is received, but most of the interrupt routine implemented in the Linux driver is executed in a threaded (non-hard IRQ) context, so depending on system configuration and load, it can still be overwhelmed. These are really designed to be used with a bare metal microcontroller that can service interrupts quickly.
If you’re wanting to match the functionality of the SystemCore CAN interfaces, this hat will work well. It uses the same CAN controllers as SystemCore (MCP2518FD), which have good driver support in Linux and don’t suffer the issue I mentioned above as they are able to queue quite a few messages onboard.
To answer your question, it shouldn’t matter that much. The software theoretically could check if it’s running on a computer module or not, but I don’t think there’s much of a point to that and it’s not difficult to work around from what I remember.
Thank you, yes it is on the raspberry side. I edited the Systemcore boot config to enable spi and I can see that MCP2515 was initialized after reboot but clock reports as 4MHz. Also “sudo ip link set can0 type can bitrate 1000000” returns invalid argument. “sudo ip link set can0 type can bitrate 500000” sets the bitrate to 500kbps successfully but I believe I need 1Mbit/s for FRCCAN communication.
I actually bought that 2-channel CanFD Hat, but it won’t arrive for another week . I got a few 2515s someone gave me so I am just trying to get them working.
I’d recommend not doing this with the systemcore image, at least while you’re trying to get it working. If you must, I’d recommend disabling the systemcore CAN interface overlays.
You’re currently telling the driver that the controller is using an 8MHz external oscillator. Is this what you actually have attached? If it’s not, you’ll need to set the correct frequency in the overlay configuration in config.txt.
Linux won’t let you set the bitrate to 1Mbps because that bitrate isn’t achievable with the MCP2515 using an 8Mhz oscillator. On the MCP2515, 1 time quanta is 2 cycles of the external oscillator (which is why the clock is reported as 4Mhz). To achieve 1Mbps reliably on this chip you’ll need an oscillator with a frequency of at least 16MHz.
I got the can_s0 and can_s1 working on the PI 5 with 2-ch CAN FD hat, Ryan_Blue mentioned. I haven’t been able to get Tuner or the Java code to control any motor controllers, but they do show up in Phoenix Tuner, and I was able to update the firmware on the Kraken
All good with the reply but I have it working on a rpi5 5 I had to rename the kernel to kernel_2712.img and changed that in config.txt the rpi5 had a weird firmware requirement where it needs to see kernel_2712.img