zeekhuge/BeagleScope

Some frequencies freezing the board

zeekhuge opened this issue · 1 comments

There are few sampling frequencies that I have found to freeze the board. Though other frequencies higher than that work well.

Initially, I did

echo 1 > scan_elements/in_voltage0_en
echo 100 > buffer/length

for each of them.

This is not that these frequencies never work, but mostly they don't

root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 793000 >   in_voltage0_sampling_frequency && dmesg | tail -n 3
[ 3715.476017] 125, 61, 61
[ 3715.478719] Requested sampling freqeuency 793000
[ 3715.483456] Available sampling freqeuency 793650
root@beaglebone:/sys/bus/iio/devices/iio:device0# cat /proc/interrupts | tail -n 12 && echo 1 > buffer/enable && sleep 100 && echo 0 > buffer/enable && cat /proc/interrupts | tail -n 12
189:          0      INTC   7 Level     tps65217
198:    4250758  4a320000.intc  16 Edge      remoteproc2
211:          0      INTC  71 Level     4802a000.i2c
IPI0:          0  CPU wakeup interrupts
IPI1:          0  Timer broadcast interrupts
IPI2:          0  Rescheduling interrupts
IPI3:          0  Function call interrupts
IPI4:          0  Single function call interrupts
IPI5:          0  CPU stop interrupts
IPI6:          0  IRQ work interrupts
IPI7:          0  completion interrupts
Err:          0

//Freezes here
root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 800000 > in_voltage0_sampling_frequency && dmesg | tail -n 3
[  199.314410] 123, 61, 61
[  199.316897] Requested sampling freqeuency 800000
[  199.321775] Available sampling freqeuency 800000
root@beaglebone:/sys/bus/iio/devices/iio:device0# cat /proc/interrupts | tail -n 12 &&  echo 1 > buffer/enable && sleep 100 && echo 0 > buffer/enable  && cat /proc/interrupts | tail -n 12
189:          0      INTC   7 Level     tps65217
198:          1  4a320000.intc  16 Edge      remoteproc2
211:          0      INTC  71 Level     4802a000.i2c
IPI0:          0  CPU wakeup interrupts
IPI1:          0  Timer broadcast interrupts
IPI2:          0  Rescheduling interrupts
IPI3:          0  Function call interrupts
IPI4:          0  Single function call interrupts
IPI5:          0  CPU stop interrupts
IPI6:          0  IRQ work interrupts
IPI7:          0  completion interrupts

//Freezes here
root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 850000 > in_voltage0_sampling_frequency | dmesg | tail -n 3
[  848.576385] 115, 57, 57
[  848.578873] Requested sampling freqeuency 850000
[  848.583719] Available sampling freqeuency 854700
root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 1 > buffer/enable 

//Freezes here

Frequencies higher that work well

root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 890000 > in_voltage0_sampling_frequency  | dmesg | tail -n 3
[   83.440654] 111, 53, 55
[   83.443365] Requested sampling freqeuency 890000
[   83.448093] Available sampling freqeuency 892857
root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 1 > buffer/enable 
root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 0 > buffer/enable 
  • In this case, the board was responding a bit slower, but that was probably because of its high speed data transfer
root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 900000 > in_voltage0_sampling_frequency  | dmesg | tail -n 3
[  134.428058] 109, 53, 55
[  134.430546] Requested sampling freqeuency 900000
[  134.435417] Available sampling freqeuency 900900
root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 1 > buffer/enable
root@beaglebone:/sys/bus/iio/devices/iio:device0# 
root@beaglebone:/sys/bus/iio/devices/iio:device0# echo 0 > buffer/enable 

Interesting !

To get the source of the bug, first I tested the PRU code, using single step mode described here and everything was fine there.

Then I found that there is something wrong with the callback method in the beaglescope_driver.c

callback -

static void beaglescope_driver_cb(struct rpmsg_channel *rpdev, void *data,
                  int len, void *priv, u32 src)
{
    struct beaglescope_state *st;
    struct iio_dev *indio_dev;
    int count;

    indio_dev = dev_get_drvdata(&rpdev->dev);
    st = iio_priv(indio_dev);

    if (get_beaglescope_read_mode(st) == RAW_READ){
        log_debug("callback - raw mode");
        st->raw_data=*((u32 *)data);
        st->got_raw = 1;
        wake_up_interruptible(&st->wait_list);
    }else{
        for (count =0; count < len; count++) {
            iio_push_to_buffers(indio_dev, &((u8 *)data)[count]);
        }
    }
}

On removing the callback from this structure, these frequencies dont lead to stall the board

structure -

static struct rpmsg_driver beaglescope_driver= {
    .drv.name   = KBUILD_MODNAME,
    .drv.owner  = THIS_MODULE,
    .id_table   = beaglescope_id,
    .probe      = beaglescope_driver_probe,
    .callback   = beaglescope_driver_cb,
    .remove     = beaglescope_driver_remove,
};

Then tried these 2 versions of the callback -

  • Commented out everything except the 'int count' instruction. And this version was working
static void beaglescope_driver_cb(struct rpmsg_channel *rpdev, void *data,
                  int len, void *priv, u32 src)
{
//  struct beaglescope_state *st;
//  struct iio_dev *indio_dev;
    int count;

//  indio_dev = dev_get_drvdata(&rpdev->dev);
//  st = iio_priv(indio_dev);

//  if (get_beaglescope_read_mode(st) == RAW_READ){
//      log_debug("callback - raw mode");
//      st->raw_data=*((u32 *)data);
//      st->got_raw = 1;
//      wake_up_interruptible(&st->wait_list);
//  }else{
//      for (count =0; count < len; count++) {
//          iio_push_to_buffers(indio_dev, &((u8 *)data)[count]);
//      }
//  }
}
  • Next version was with 'log_dbg()' and 'int count' instructions and the board got stalled.
static void beaglescope_driver_cb(struct rpmsg_channel *rpdev, void *data,
                  int len, void *priv, u32 src)
{
//  struct beaglescope_state *st;
//  struct iio_dev *indio_dev;
    int count;

//  indio_dev = dev_get_drvdata(&rpdev->dev);
//  st = iio_priv(indio_dev);

         log_debug("callback");
//  if (get_beaglescope_read_mode(st) == RAW_READ){
//      log_debug("callback - raw mode");
//      st->raw_data=*((u32 *)data);
//      st->got_raw = 1;
//      wake_up_interruptible(&st->wait_list);
//  }else{
//      for (count =0; count < len; count++) {
//          iio_push_to_buffers(indio_dev, &((u8 *)data)[count]);
//      }
//  }
}