The aim of this project is to make a prototype of a open-hardware/software CAN Bus to USB Sniffer for Linux/Windows-based machines. The CAN communication goes through a MCP 2515 controller which is connected to a RI5CY processor. The processor hosts a FreeRTOS kernel which provides a Virtual COM on the end-user machine as shown below:
There is no dynamic (heap) allocation at the application layer, but still there are heap allocations at the official middleware/driver layer due to using dynamic semaphores. A polling mechanism is designed for almost efficient data fetching from the SPI (not as efficient as the DMA mechanism), but due to lack of succifient stability the usage has been ignored in the final version.
The dependencies of the project in hardware and software categories are as follows:
- RV32M1 VEGAboard (runs only on PULP RI5CY RISC-V core)
- MCP2515 (Stand-Alone CAN Controller with SPI Interface)
- SEGGER J-Link EDU Mini (for JTAG programming and HIL debugging)
- C Standard: 99
- Cmake mimimum version: 2.6
- Compiler: GCC RISC-V Embedded 7.1.1
- FreeRTOS kernel: 9.0.0
- RV32M1 SDK: 1.0.0
- OpenOCD: 0.10.0 (only for debugging)
- Connect the MCP2515 module to the VEGAboard
SPI0
pins (i.e., J2 pin 6, 8, 10, and 12) with a common ground; - Connect the other CAN device to the MCP2515 module with a common ground while setting the bus speed to 5 kbps;
- Set the
RISCV32SDK_DIR
environment variable to the path where the RV32M1 SDK has been installed; - Use the mentioned RISC-V Toolchain to compile the firmware;
- Flash the compiled firmware (
open_can_sniffer.elf
) to the VEGAboard using the JTAG programmer; - Connect the VEGAboard USB port to the PC;
- Connect the VEGAboard OpenSDA port to the PC to see the debugging logs (optional);
- Power up the MCP2515 module and the VEGAboard;
- Use the in-house USBCAN-GUI software on the PC to see the received CAN packets;
- Use a 3rd-party serial port terminal (e.g., Putty) on the PC to connect to the OpenSDA COM port for monitoring the logs (optional).