LinuxCNC-RIO - RealtimeIO for LinuxCNC based on FPGA (ICE40 / ECP5)

More
More
09 Dec 2024 13:34 #316334 by MirkoCNC
As I have no hardware yet, I am wondering if it is good decision to remove IO_TYPE completely.

It was just my mistake because I have not realized that it can be set within your tool.

The IDE shows me in the Pin Report that all pins are on LVCMOS18 now.

I

Please Log in or Create an account to join the conversation.

More
09 Dec 2024 13:53 #316336 by MirkoCNC
I give up on the portable Python....toolchain. It is easy to use the IDE.

It would be good to have the IO_TYPE back in the pin list and the graphic in the Tab Overview

Please Log in or Create an account to join the conversation.

More
09 Dec 2024 14:36 #316337 by MirkoCNC
I do not know why, but Tab Overview shows graphic again.
IO_TYPE is better to have back, please :-)

Please Log in or Create an account to join the conversation.

More
09 Dec 2024 14:44 #316338 by digiex_chris
@meister have you done any investigation on running the iceshield on a rpi5? it seems the spi and gpio hardware is different. I am unable to get a clock signal on pin 7, it seems like it was not a well supported feature. I used an rp2040 to generate a clock signal instead, wired to pin 7, and flashed using a pi4, and have the blinking light but I'm getting EMCMOT timeouts from linuxcnc. I suspect the SPI interface is different. It's definitely there, I have the expected /dev/spidev0.1, /dev/spidev0.0 devices. I'd love to use the pi5, it's MUCH faster and has better jitter. 

Please Log in or Create an account to join the conversation.

More
09 Dec 2024 15:11 #316340 by meister

I do not know why, but Tab Overview shows graphic again.
IO_TYPE is better to have back, please :-)
 

i have fixed the overview today.

IO_TYPE, no not at the moment, have to check some things first.

@digiex_chris
i have no RPI5, so i can not test it :(
i only know that there is a general problem with RPI5 and SPI,
but someone on youtube got it to work with RIO

Please Log in or Create an account to join the conversation.

More
09 Dec 2024 15:51 #316345 by meister
ok, IO_TYPE for cst pins are back, but only if it is set to non-default value

Please Log in or Create an account to join the conversation.

More
09 Dec 2024 15:57 #316346 by digiex_chris
ah thank you! Knowing that it's possible is helpful. I will look into it and let you know if there is something we can adjust to make it easy.
The following user(s) said Thank You: meister

Please Log in or Create an account to join the conversation.

More
09 Dec 2024 22:34 #316359 by Zayoo
Regarding rpi5 I swap to riocore so there is some changes.
For old rio follow instructions on rio page 11

Here is changes for riocore:

I have a raspberry pi5 and this is the code of how I started the SPI communication of the RPI5 - TangNano9K. (Not yet machine tested)

OS:  In /boot/broadcom/config.txt check is SPI is enabled (reboot if not)

# uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on

In /dev/
Check do you have listed spidev0.0, should be!

Generate output files as for raspberry pi4. When you have generated them, find the file 'riocomp.c' and open it. In general, you need to find and replace the code responsible for rpi4 SPI communication. You need to swap approximately 4200 lines of code with around 60 lines, swap FROM:
/*
    interface: SPI
*/

INSERT CODE:
#include <linux/spi/spidev.h>
#include <sys/ioctl.h>  
int spifd;
static uint8_t mode = SPI_MODE_0;
static uint8_t bits = 8;
static uint32_t speed = 1500000;
int spi_init(void) {
   
    rtapi_print("Info: Initialize SPI5 connection\n");
    spifd = open("/dev/spidev0.0", O_RDWR);
    if (spifd < 0) {
        rtapi_print_msg(RTAPI_MSG_ERR,"Failed to open SPI device\n");
        return -1;
    }
    // Set SPI mode
    if (ioctl(spifd, SPI_IOC_WR_MODE, &mode) == -1) {
        rtapi_print_msg(RTAPI_MSG_ERR,"Failed to set SPI mode\n");
        close(spifd);
        return -1;
    }
    // Set bits per word
    if (ioctl(spifd, SPI_IOC_WR_BITS_PER_WORD, &bits) == -1) {
        rtapi_print_msg(RTAPI_MSG_ERR,"Failed to set bits per word\n");
        close(spifd);
        return -1;
    }
    // Set max speed
    if (ioctl(spifd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) == -1) {
        rtapi_print_msg(RTAPI_MSG_ERR,"Failed to set max speed\n");
        close(spifd);
        return -1;
    }
}
int spi_trx(uint8_t *txBuffer, uint8_t *rxBuffer, uint16_t size) {
        struct spi_ioc_transfer tr = {
        .tx_buf = (uint64_t)txBuffer,
        .rx_buf = (uint64_t)rxBuffer,
        .len = size,
        .speed_hz = speed,
        .delay_usecs = 0,
        .bits_per_word = bits,
    };
    // Perform SPI transfer
    if (ioctl(spifd, SPI_IOC_MESSAGE(1), &tr) == -1) {
rtapi_print_msg(RTAPI_MSG_ERR,"Failed to perform SPI transfer\n");
    }
    return 1;
}
 
TO:
int interface_init(void)  {
     spi_init();
}

/*
   hal functions
*/


Find and add:
//ADD to rtapi_app_exit ->> close(spifd);
void rtapi_app_exit(void) {
    close(spifd);
    hal_exit(comp_id);
}
 

And that's all. This procedure with 'riocomp.c' must be repeated every time the output files are regenerated.
 
The following user(s) said Thank You: meister

Please Log in or Create an account to join the conversation.

More
10 Dec 2024 08:03 #316381 by meister
Many thanks Zayoo !

i have add the code to the dev branch for testing.

if you want to use it, you can add
"rpi5": true,
to your json config

like this:
{
"name": "IceShield",
"description": "RIO-IceShield on Raspberry PI5",
"boardcfg": "IceShield",
"protocol": "SPI",
"rpi5": true,
....
The following user(s) said Thank You: digiex_chris

Please Log in or Create an account to join the conversation.

Time to create page: 0.120 seconds
Powered by Kunena Forum