SD card image with Debian 8.0, Red Pitaya web server and SDK

Just about everything about Red Pitaya
Post Reply
fbalakirev
Posts: 109
Joined: Thu Sep 03, 2015 6:56 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by fbalakirev » Fri Apr 05, 2024 1:30 pm

pavel wrote:
Fri Apr 05, 2024 1:14 pm
Are you using something like the following command to run the script?

Code: Select all

sudo sh scripts/image.sh scripts/debian.sh red-pitaya-debian-12-armhf.img 1024
Yes, I just copy-paste your step-by-step instructions from the red pitaya notes lad blinker page.

pavel
Posts: 802
Joined: Sat May 23, 2015 5:22 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by pavel » Fri Apr 05, 2024 2:01 pm

There should be some earlier error messages. Maybe some commands are missing on your system.

fbalakirev
Posts: 109
Joined: Thu Sep 03, 2015 6:56 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by fbalakirev » Fri Apr 05, 2024 5:52 pm

I successfully build the boot.bin file using 'make NAME=led_blinker boot.bin' command and copied it over the original boot.bin on your latest pre-built SD image. The boot sequence failed though at the following step:

Code: Select all

Mounting boot media...
 * Mounting boot media: ls: /media/mmcblk0p1/*.apkovl.tar.gz: No such file or directory
Mounting boot media: failed.
failed.
initramfs emergency recovery shell launched. Type 'exit' to continue boot
sh: can't access tty; job control turned off

fbalakirev
Posts: 109
Joined: Thu Sep 03, 2015 6:56 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by fbalakirev » Fri Apr 05, 2024 6:14 pm

pavel wrote:
Fri Apr 05, 2024 2:01 pm
There should be some earlier error messages. Maybe some commands are missing on your system.
At the start of ''sudo sh scripts/image.sh scripts/debian.sh red-pitaya-debian-12-armhf.img 1024' I see the following error messages:

Code: Select all

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.378468 s, 2.8 GB/s
Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
mkfs.fat 4.2 (2021-01-31)
mkfs.vfat: unable to open /dev/: Is a directory
mke2fs 1.46.5 (30-Dec-2021)
mkfs.ext4: Device size reported to be zero.  Invalid partition specified, or
        partition table wasn't reread after running fdisk, due to
        a modified partition being busy and in use.  You may need to reboot
        to re-read your partition table.

mount: /tmp/BOOT.MO1OVWjQdp: /dev is not a block device.
mount: /tmp/ROOT.AB5dbsCKVh: /dev is not a block device.

pavel
Posts: 802
Joined: Sat May 23, 2015 5:22 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by pavel » Fri Apr 05, 2024 8:22 pm

The correct command to create boot.bin for Debian Linux based SD card image is

Code: Select all

make boot-rootfs.bin
Then you will need to rename it to boot.bin.

I do not know how to solve your problem with the debian.sh script. It may be enough to restart the system, as the error messages suggest.

fbalakirev
Posts: 109
Joined: Thu Sep 03, 2015 6:56 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by fbalakirev » Sat Apr 06, 2024 12:04 am

pavel wrote:
Fri Apr 05, 2024 8:22 pm
The correct command to create boot.bin for Debian Linux based SD card image is

Code: Select all

make boot-rootfs.bin
Then you will need to rename it to boot.bin.
Thank you again Pavel. The flck is running and large buffer allocation works. although I might need to increase the CMA size in the dts, it didn't let allocate full 256M, just a bit less.

fbalakirev
Posts: 109
Joined: Thu Sep 03, 2015 6:56 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by fbalakirev » Fri Apr 12, 2024 10:32 pm

pavel,

I'm trying to use Red Pitaya Notes framework with 125-14 4CH unit. I tried to use the playground project example to record a number of ADC samples into a FIFO and then print them. I noticed that FIFO would drop a couple of readings early on and the at the very end, which I didn't expect. I then put together a simple logic to record a free running 64-bit counter and noticed that on top of dropping couple of readings early on, the FIFO now also drops every other reading, while a few others appear to be out of order as well, as in the example below:

P.S. my guess is that xilinx binary counter ip output is zero every other clock transition? In any case it looks like the readings occasionally come out or order, Is it a feature of memcpy in conjunction with the hub? I think I recall seeing a similar issue somewhere before.

Code: Select all

0	561584192178
1	0
2	561584192184
3	0
4	561584192186
5	0
6	561584192188
7	0
8	0
9	0
10	561584192192
11	0
12	561584192194
13	0
14	561584192196
15	0
16	561584192180
17	0
18	561584192200
19	0
20	561584192202
21	0
22	561584192204
23	0
24	0
25	0
26	561584192208
27	0
28	561584192210
29	0
30	561584192212
31	0
32	561584192182
33	0
34	561584192216
35	0
36	561584192218
37	0
38	561584192220
39	0
40	561584192190
41	0
42	561584192224
I wonder if I do not understand your FIFO+hub architecture and I really appreciate if you could find time to look at the attached block diagram and the test app code?

Code: Select all

# Create clk_wiz
cell xilinx.com:ip:clk_wiz pll_0 {
  PRIMITIVE PLL
  PRIM_IN_FREQ.VALUE_SRC USER
  PRIM_IN_FREQ 125.0
  PRIM_SOURCE Differential_clock_capable_pin
  CLKOUT1_USED true
  CLKOUT1_REQUESTED_OUT_FREQ 125.0
  USE_RESET false
} {
  clk_in1_p adc_clk_p_i
  clk_in1_n adc_clk_n_i
}

# Create processing_system7
cell xilinx.com:ip:processing_system7 ps_0 {
  PCW_IMPORT_BOARD_PRESET cfg/red_pitaya.xml
} {
  M_AXI_GP0_ACLK pll_0/clk_out1
}

# Create all required interconnections
apply_bd_automation -rule xilinx.com:bd_rule:processing_system7 -config {
  make_external {FIXED_IO, DDR}
  Master Disable
  Slave Disable
} [get_bd_cells ps_0]

# Create xlconstant
cell xilinx.com:ip:xlconstant const_0

# Create proc_sys_reset
cell xilinx.com:ip:proc_sys_reset rst_0 {} {
  ext_reset_in const_0/dout
  dcm_locked pll_0/locked
  slowest_sync_clk pll_0/clk_out1
}


# Create axi_hub
cell pavel-demin:user:axi_hub hub_0 {
  CFG_DATA_WIDTH 192
  STS_DATA_WIDTH 96
} {
  S_AXI ps_0/M_AXI_GP0
  aclk pll_0/clk_out1
  aresetn rst_0/peripheral_aresetn
}

# Create port_slicer
cell pavel-demin:user:port_slicer slice_start {
  DIN_WIDTH 192 DIN_FROM 0 DIN_TO 0
} {
  din hub_0/cfg_data
}

# Create c_counter_binary
cell xilinx.com:ip:c_counter_binary cntr_adc {
  Output_Width 64
} {
  CLK pll_0/clk_out1
}

# Create axis_fifo
cell pavel-demin:user:axis_fifo fifo_0 {
  S_AXIS_TDATA_WIDTH 64
  M_AXIS_TDATA_WIDTH 32
  WRITE_DEPTH 65536
} {
  S_AXIS_tdata cntr_adc/Q
  S_AXIS_tvalid const_0/dout
  M_AXIS hub_0/S00_AXIS
  aclk pll_0/clk_out1
  aresetn slice_start/dout
}

# Create xlconcat
cell xilinx.com:ip:xlconcat concat_0 {
  NUM_PORTS 6
  IN0_WIDTH 32
  IN1_WIDTH 32
  IN2_WIDTH 1
  IN3_WIDTH 1
  IN4_WIDTH 3
  IN5_WIDTH 1
} {
  In0 fifo_0/read_count
  In1 fifo_0/write_count
  dout hub_0/sts_data
 }

Code: Select all

#include <stdio.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/ioctl.h>

int main(int argc, char *argv[])
{
  int fd, i;
  int samples=4096;
  volatile uint8_t *rst;
  volatile void *cfg, *sts, *fifo;
  uint64_t *buffer;

  if (argc >=2 ) {
	uint32_t tmp = atoi(argv[2]);
	if (tmp > 0 ) samples=tmp;
  }

  if((buffer = (uint64_t *)malloc(samples*8)) == NULL)
  {
    perror("malloc");
    return EXIT_FAILURE;
  }

  if((fd = open("/dev/mem", O_RDWR)) < 0)
  {
    perror("open");
    return EXIT_FAILURE;
  }

  cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40000000);
  sts = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x41000000);
  fifo = mmap(NULL, 32*sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x42000000);

  close(fd);

  
  rst = (uint8_t *)(cfg + 0);

  // reset fifo
  *rst &= ~1;

  // wait 1 second
  sleep(1);

  *rst |= 1;

  // wait 1 second
  sleep(1);

  memcpy(buffer, (const void *) fifo, samples*8);
  // print samples
  for(i = 0; i < samples; ++i)
  {
    printf("%d\t%" PRIu64 "\n",i, buffer[i]);
  }

  return EXIT_SUCCESS;
}

fbalakirev
Posts: 109
Joined: Thu Sep 03, 2015 6:56 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by fbalakirev » Sat Apr 13, 2024 7:52 pm

I recalled that memcpy often moves words out of order behind the scenes while it looks like the hub expects the stream slave to be read in order. Once I replaced memcpy with repeated reads from *(uint32_t*)fifo, the input from all 4 ADCs is all good:

Code: Select all

  
  uint32_t data;
  for(i = 0; i < samples; ++i)
  {
    data =  *(uint32_t *)fifo;
    printf("%5d\t%5d\t%5d",i, data&0xffff, (data>>16)&0xffff);
    data =  *(uint32_t *)fifo;
    printf("\t%5d\t%5d\n", data&0xffff, (data>>16)&0xffff);
   }

pavel
Posts: 802
Joined: Sat May 23, 2015 5:22 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by pavel » Sat Apr 13, 2024 9:33 pm

If you use the playground project with a SD card image based on Debian Linux, then the glibc implementation of memcpy for the ARM processor sometimes reads memory addresses out of order.

However, the playground application works well with the SD card images based on Alpine Linux. The musl implementation of memcpy for the ARM processor always reads memory addresses in order. Additionally, memcpy initiates burst transfers that significantly improve the throughput of the AXI interface.

fbalakirev
Posts: 109
Joined: Thu Sep 03, 2015 6:56 pm

Re: SD card image with Debian 8.0, Red Pitaya web server and SDK

Post by fbalakirev » Tue Apr 16, 2024 5:03 pm

Thank you for the confirmation pavel.

I've been using an enlarged cma buffer build with relative success following your suggested modifications. On occasion though the allocation request returns an error. For example:

Code: Select all

cma: cma_alloc: reserved: alloc failed, req-size: 65536 pages, ret: -16
ioctl: Cannot allocate memory
After reboot command, the error does not repeat.

Would you happen to have any advice how to avoid this problem?

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 1 guest