GPIO pin configuration issue for UART communication

Refer to this link for CAN network setup: Create Your Own CAN Network With MCP2515 Modules and Arduino

In this tutorial, the CAN network is established between two Arduinos. You can achieve the same setup between the Vaaman board and an Arduino, or between the Vaaman board and an ESP.

You need to bring up the CAN interface link. To bring up can0 with a bitrate of 500 kbps, run:

sudo ip link set can0 up type can bitrate 500000

After this, you can proceed to perform CAN communication.

@firmware02 can you please send me mcp2515 driver zip file

mcp251x-driver.zip (72.5 KB)

@Aman4532 Plz Check the file

@vatsal plz check

I am sending and receiving data through a USB CAN tool (external tool), but it is not working

Refer to this video: https://www.youtube.com/watch?v=spVgKZkNpT8 , it explains how communication occurs between two MCP2515 modules, where the CAN network is established between two ESP32 boards. In our case, we have the Vaaman board on one side, and you can connect any compatible device on the other side to establish communication.

Also, refer to this link for a better understanding:https://www.youtube.com/watch?v=ZH_CCs12ptg&t=3s

You can refer to this code for the ESP, as I have tested it and it works correctly,


// Simple sketch that querries OBD2 over CAN for coolant temperature
// Showcasing simple use of ESP32-TWAI-CAN library driver.

// Default for ESP32
#define CAN_TX        21
#define CAN_RX        20

CanFrame rxFrame;

void sendObdFrame(uint8_t obdId) {
    CanFrame obdFrame = { 0 };
    obdFrame.identifier = 0x7DF; // Default OBD2 address;
    obdFrame.extd = 0;
    obdFrame.data_length_code = 8;
    obdFrame.data[0] = 2;
    obdFrame.data[1] = 1;
    obdFrame.data[2] = obdId;
    obdFrame.data[3] = 0xAA;    // Best to use 0xAA (0b10101010) instead of 0
    obdFrame.data[4] = 0xAA;    // CAN works better this way as it needs
    obdFrame.data[5] = 0xAA;    // to avoid bit-stuffing
    obdFrame.data[6] = 0xAA;
    obdFrame.data[7] = 0xAA;
    // Accepts both pointers and references 
    ESP32Can.writeFrame(obdFrame);  // timeout defaults to 1 ms

    Serial.println("Sending frame");
}

void setup() {
    // Setup serial for debbuging.
    Serial.begin(115200);

    // Set pins
    ESP32Can.setPins(CAN_TX, CAN_RX);

    // You can set custom size for the queues - those are default
    ESP32Can.setRxQueueSize(5);
    ESP32Can.setTxQueueSize(5);

    // .setSpeed() and .begin() functions require to use TwaiSpeed enum,
    // but you can easily convert it from numerical value using .convertSpeed()
    ESP32Can.setSpeed(ESP32Can.convertSpeed(500));

    // You can also just use .begin()..
    if(ESP32Can.begin()) {
        Serial.println("CAN bus started!");
    } else {
        Serial.println("CAN bus failed!");
    }

    // or override everything in one command;
    // It is also safe to use .begin() without .end() as it calls it internally
    if(ESP32Can.begin(ESP32Can.convertSpeed(500), CAN_TX, CAN_RX, 10, 10)) {
        Serial.println("CAN bus started!");
    } else {
        Serial.println("CAN bus failed!");
    }
}

void loop() {
    static uint32_t lastStamp = 0;
    uint32_t currentStamp = millis();

    if(currentStamp - lastStamp > 1000) {   // sends OBD2 request every second
        lastStamp = currentStamp;
        sendObdFrame(5); // For coolant temperature
    }

    // You can set custom timeout, default is 1000
    if(ESP32Can.readFrame(rxFrame, 1000)) {
        // Comment out if too many frames
        Serial.printf("Received frame: %03X  \r\n", rxFrame.identifier);
        if(rxFrame.identifier == 0x7E8) {   // Standard OBD2 frame responce ID
            Serial.printf("Collant temp: %3d°C \r\n", rxFrame.data[3] - 40); // Convert to °C
        }
    }
}

Once the setup is properly completed, you can send the following command from the Vaaman board cansend can0 7E8#0341058700000000

To receive data from the ESP, run the following command on the Vaaman board to monitor incoming messages: candump can0

@vatsal The CAN is working now, the problem is with the wire length

Hello, @vatsal @Avi_Shihora @Akshar


image

I am using FPGA GPIO pins for firmware flashing on an STM32F105.

Pin 29 → GPIOR_168

Pin 33 → GPIOL_20

These GPIOs are connected to the STM32 and are used during the firmware flashing process.

However, I am facing an issue where the GPIOs are not getting handled properly.

Even though I am running the code and flashing the firmware from the Vicharak board to the STM32, the GPIO pins are not responding / not toggling, due to which the required functionality is not working.

Please help to identify why the GPIO handling is not working and how to debug or fix this issue.

I am testing the same scenario on my side and will get back to you soon.

Okay, Thanks please let me know as soon as possible

Hello, @vatsal @Avi_Shihora @Akshar
Could you please share the following files related to the Yocto image?

conf/bblayers.conf
conf/local.conf

Additionally, please share the Yocto image for eMMC as well.

This will help me review and understand the current Yocto setup.

Please share it at the earliest

You can checkout GitHub - vicharak-in/meta-rockchip: // Yocto BSP layer for Vicharak SBC boards

Let me build and share

https://downloads.vicharak.in/vicharak-vaaman/yocto/V1.0.0-core-image-full-cmdline-mickledore-5.10-rk3399-vaaman-2025111352703-sdcard.rootfs.tar.gz

Extract this image,

tar -xvf <download_path>/V1.0.0-core-image-full-cmdline-mickledore-5.10-rk3399-vaaman-2025111352703-sdcard.rootfs.tar.gz

You can flash to eMMC or SD Card,

For eMMC,

Step - 1

Download the rk3399_loader, https://downloads.vicharak.in/vicharak-vaaman/rk3399_loader_v1.30.130.bin

After downloading you can use upgrade_tool or rkdeveloptool,

sudo ./upgrade_tool db <download_path>/rk3399_loader_v1.30.130.bin	

Step-2

Flash the image,

sudo ./upgrade_tool wl 0 <download_path>/<extracted_image>

SDCard

You can use either balenaEtcher or dd.
BalenaEtcher - Open and select the image and select the SDCard device and click on flash.
For dd you can do this way,

sudo dd if=<download_path>/<extracted_image> of=/dev/sdX status=progress

Here X should be replaced with the corresponding SD card device number.

Thank you, I will check and update you

1 Like

Have you checked this scenario on your side ?

Hello, @vatsal @Avi_Shihora @djkabutar @Akshar

Is there any update on GPIO handling?

We have already recreated the same scenario, we have found a bug and it will be fixed in a day or two, after the verification we will let you know.

Please let me know when it is fixed.
Also, tell me which gpiochip these two pins belong to (gpiochip1 or gpiochip2): Pin 29 → GPIOR_168, Pin 33 → GPIOL_20