User Profile
K606
Joined 1 year ago
User Widgets
Contributions
Linux mSGDMA Driver Agilex 5
I am trying to use stream-to-memory DMA to move data. This is the design, showing the important Quartus connections: Which corresponds to this address config: # address map write_sdram = 0x00000000 read = NULL (has no meaning in streaming to MM mode) msgdma_csr = 0x22000040 msgdma_descriptor = 0x22000060 # msgdma offsets msgdma_csr_control = 0x4 + 0x22000040 = 0x22000044 msgdma_descriptor_write_low = 0x4 + 0x22000060 = 0x22000064 msgdma_descriptor_length = 0x8 + 0x22000060 = 0x22000068 msgdma_descriptor_control = 0xc + 0x22000060 = 0x2200006c The oscillator IP generates a group of known numbers, so the readbacks change each time - but are predictable and so the hardware is verifiable. In U-Boot; I have verified that this design. This script asks the DMA to make two transfers, and reads back the results each time. SOCFPGA_AGILEX5 # mw 0x22000044 0x1 # Stop Dispatcher SOCFPGA_AGILEX5 # mw 0x22000044 0x20 # Stop descriptors SOCFPGA_AGILEX5 # mw 0x22000044 0x2 # Reset Dispatcher SOCFPGA_AGILEX5 # mw 0x22000064 0x00000000 # Write address SOCFPGA_AGILEX5 # mw 0x22000068 0x8 # Write length in bytes SOCFPGA_AGILEX5 # md 0x22000040 1 # Check status 22000040: 00000002 .... SOCFPGA_AGILEX5 # mw 0x2200006c 0x02000000 # Wait for response SOCFPGA_AGILEX5 # sleep 1 SOCFPGA_AGILEX5 # mw 0x2200006c 0x82000000 # execute SOCFPGA_AGILEX5 # md 0x22000040 1 # Check status 22000040: 00000002 .... SOCFPGA_AGILEX5 # md 0x00000000 1 # read 00000000: 00000000 .... SOCFPGA_AGILEX5 # mw 0x22000044 0x2 # reset SOCFPGA_AGILEX5 # mw 0x2200006c 0x82000000 # execute SOCFPGA_AGILEX5 # md 0x00000000 1 # read 00000000: 67676767 .... When trying to do the same in linux using 'devmem2', I found that the readbacks did not change, so I decided to look for some examples. I found this stream-to-mapped mSGDMA driver built for the Cyclone V, and so re-purposed it. The driver example above both reads and writes to the device using the ‘dd’ utility in linux, but I am for now only interested in the read command. To do so I needed some information... Based on the .qsys design file output of my project, the mSGDMA block generates this interrupt: ... <altera:connection altera:kind="interrupt" altera:version="24.3" altera:start="subsys_hps.f2h_irq0_in" altera:end="msgdma_0.csr_irq"> <altera:connection_parameter altera:parameter_name="irqNumber" altera:parameter_value="2"> </altera:connection_parameter> </altera:connection> ... And according to the interrupt docs, the above csr interrupt value=2 maps to the GIC interrupt 51, which is 19 when referenced from the linux device tree. With this information, I have defined the following mSGDMA element in the .dts: ... msgdma_test: msgdma_test@22000000 { compatible = "msgdma_test"; reg = <0x0 0x22000000 0x0 0x100>; interrupt-parent = <&intc>; interrupts = <0 19 4>; }; ... Which only differs from the original in that it has a different interrupt number, and different base address - also accounting for the lwhps2fpga offset, due to it being the Agilex5 and not the Cyclone. The driver code from the REDS blog post has also been edited in the following way: I need to change a deprecated function in the main driver code: devm_ioremap_nocache to demv_ioremap. I want to see the data which has been moved - to do so have added an info print to the msgdma_read method: printk(KERN_INFO "MSGDMA: Read buffer content: %.*s\n", (int)read_ret, (char*)data->dma_buf_rd); There is only 1 interrupt, so we set data->msgdma1_irq = platform_get_irq(pdev, 0); Since there is no ability coded to fabric to perform msgdma_write - we can also remove memory allocations, remaps and references to msgdma0 and other write related objects. I think the following shows that the DMA is firing interrupts, and so I am confident that I have connected the correct interrupt: cat /proc/interrupts | grep msgdma 50: 2 0 0 0 GICv3 51 Level msgdma1 However, when looking at the kernel outputs after requesting reads via dd: $ dd if=/dev/msgdma_test of=/dev/null bs=8 count=1 $ dmesg | tail [ ... ] MSGDMA: Read buffer (hex): 00 00 00 00 00 00 00 00 [ ... ] MSGDMA: Read buffer (hex): 00 00 00 00 00 00 00 00 The driver code in question is included in msgdma.c and header_msgdma.c, attached to the post (This forum does not seem to like .h files...) I was hoping someone might have an idea of where I went wrong! Any helpers are much appreciated! Thanks for your time, KSolved2.7KViews0likes9Comments- 55Views0likes1Comment
Ticket Update
Hi - I have posted a follow up question on an old thread an would appreciate any help! I am making this post, as it is not clear where I can submit an official ticket otherwise. Can be seen here: Transceiver data corruption | Altera Community Please do feel free to delete this post when somone is assigned to the issue. Thanks.101Views0likes3CommentsRe: Transceiver data corruption
Hi CheepinC_altera Sorry I did not get back to you earlier - this message was buried in my inbox. The analogue settings for the GTS TX/RX: TX: Post_tap_1:0 Main_tap:55 Pre_tap_1:0 Pre_tap_2:0 RX: High Frequency VGA Gain:0 High Frequency Boost:0 DFE Data Tap 1:0 I added the transceiver toolkit in my design: ... .intel_directphy_gts_0_i_reconfig_clk_clk (CLK_100_B2B_p), .intel_directphy_gts_0_i_reconfig_reset_reset (agilex_reset), .intel_directphy_gts_0_reconfig_write (1'b0), .intel_directphy_gts_0_reconfig_read (1'b0), .intel_directphy_gts_0_reconfig_address (17'b0), // single PMA lane .intel_directphy_gts_0_reconfig_byteenable (4'b0), .intel_directphy_gts_0_reconfig_writedata (32'b0), .intel_directphy_gts_0_reconfig_readdata (), .intel_directphy_gts_0_reconfig_waitrequest (), .intel_directphy_gts_0_reconfig_readdatavalid (), ... In SignalTap: So as you can see, the GTS clocks are locked well. In the TransceiverToolkit (TT): Dec 18, 2025 3:05:34 PM Intel Agilex 5 _ Agilex 3 Transceiver Toolkit: agilex_5_agilex_3_transceiver_toolkit1766070211497 INFO: Finished eye width measure Dec 18, 2025 3:05:34 PM Intel Agilex 5 _ Agilex 3 Transceiver Toolkit: agilex_5_agilex_3_transceiver_toolkit1766070211497 INFO: 0.132 Dec 18, 2025 3:05:34 PM Intel Agilex 5 _ Agilex 3 Transceiver Toolkit: agilex_5_agilex_3_transceiver_toolkit1766070211497 INFO: 26.304 ps Dec 18, 2025 3:05:34 PM Intel Agilex 5 _ Agilex 3 Transceiver Toolkit: agilex_5_agilex_3_transceiver_toolkit1766070211497 INFO: Starting eye height measure Dec 18, 2025 3:05:39 PM Intel Agilex 5 _ Agilex 3 Transceiver Toolkit: agilex_5_agilex_3_transceiver_toolkit1766070211497 INFO: Core0_Pos_middle_eye 46.550000000000004 Core0_Neg_middle_eye -39.900000000000006 Core0_Total_middle_eye 86.45 Core1_Pos_middle_eye 54.53 Core1_Neg_middle_eye -38.57 Core1_Total_middle_eye 93.10000000000001 status true Dec 18, 2025 3:05:39 PM Intel Agilex 5 _ Agilex 3 Transceiver Toolkit: agilex_5_agilex_3_transceiver_toolkit1766070211497 SEVERE: An error occurred while running script "callback_pkg::eye_viewer_callback 0 ": Intel Agilex 5 _ Agilex 3 Transceiver Toolkit: agilex_5_agilex_3_transceiver_toolkit1766070211497: key "core0_pos_middle_eye" not known in dictionary while executing "dict get $eye_ehm_values "core0_pos_middle_eye" " (procedure "get_eye_data" line 8) invoked from within "get_eye_data $chan" (procedure "eye_viewer_callback_handler" line 75) invoked from within "eye_viewer_callback_handler $chan" (procedure "callback_pkg::eye_viewer_callback" line 2) invoked from within "callback_pkg::eye_viewer_callback 0" Which can be summarised as: Eye Vewer: ========== Eye Width UI : 0.132 Eye Width Time : 26.304 Core0_Pos_middle_eye : 46.550000000000004 Core0_Neg_middle_eye : -39.900000000000006 Core0_Total_middle_eye : 86.45 Core1_Pos_middle_eye : 54.53 Core1_Neg_middle_eye : -38.57 Core1_Total_middle_eye : 93.10000000000001 It seems that starting the PRBS check in the TT and checking the BER in TT work - and the BER is 0. However, the Eye Viewer test seems to fail... Please do advise! How would I go about using the data I have so far to tune the GTS, and is it possible to fix this eye viewer test?2Views0likes0CommentsRe: Agilex 5 EMAC GMII loopthrough: signals are not toggling in Fabric
In answer to the first question - yes, for instance using these commands: sudo ip addr flush dev eth0 sudo ip addr add 192.168.70.5/24 dev eth0 sudo ip link set eth0 up sudo ip addr flush dev eth1 sudo ip addr add 192.168.71.1/24 dev eth1 sudo ip link set eth1 up We can observe effects in Linux: root@localhost:~# cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fid lo: 181360 2510 0 0 0 0 0 0 181360 2510 0 0 0 eth0: 6660 25 0 0 0 0 0 0 9662 61 0 0 0 eth1: 6360 20 0 0 0 0 0 0 10132 68 0 0 0 eth2: 0 0 0 0 0 0 0 0 0 0 0 0 0 root@localhost:~# ping -I 192.168.71.1 192.168.70.5 PING 192.168.70.5 (192.168.70.5) from 192.168.71.1 : 56(84) bytes of data. 64 bytes from 192.168.70.5: icmp_seq=1 ttl=64 time=0.148 ms 64 bytes from 192.168.70.5: icmp_seq=2 ttl=64 time=0.030 ms 64 bytes from 192.168.70.5: icmp_seq=3 ttl=64 time=0.061 ms 64 bytes from 192.168.70.5: icmp_seq=4 ttl=64 time=0.017 ms 64 bytes from 192.168.70.5: icmp_seq=5 ttl=64 time=0.029 ms root@localhost:~# cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fid lo: 204920 2840 0 0 0 0 0 0 204920 2840 0 0 0 eth0: 6660 25 0 0 0 0 0 0 9662 61 0 0 0 eth1: 6360 20 0 0 0 0 0 0 10132 68 0 0 0 eth2: 0 0 0 0 0 0 0 0 0 0 0 0 0 Similarly: root@localhost:~# ip -s link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group defaul0 link/ether aa:b3:a3:d6:4e:04 brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 7200 34 0 0 0 0 TX: bytes packets errors dropped carrier collsns 9662 61 0 0 0 0 root@localhost:~# ping -I 192.168.70.5 192.168.71.1 PING 192.168.71.1 (192.168.71.1) from 192.168.70.5 : 56(84) bytes of data. 64 bytes from 192.168.71.1: icmp_seq=1 ttl=64 time=0.155 ms 64 bytes from 192.168.71.1: icmp_seq=2 ttl=64 time=0.033 ms 64 bytes from 192.168.71.1: icmp_seq=3 ttl=64 time=0.025 ms ... root@localhost:~# ip -s link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group defaul0 link/ether aa:b3:a3:d6:4e:04 brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 7200 34 0 0 0 0 TX: bytes packets errors dropped carrier collsns 9662 61 0 0 0 0 And arping has the same effect: root@localhost:~# sudo arping -I eth1 -c 50 192.168.70.5 ARPING 192.168.70.5 Timeout Timeout Timeout Timeout root@localhost:~# cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fid lo: 250716 3484 0 0 0 0 0 0 250716 3484 0 0 0 eth0: 6960 30 0 0 0 0 0 0 9662 61 0 0 0 eth1: 6360 20 0 0 0 0 0 0 10422 73 0 0 0 eth2: 0 0 0 0 0 0 0 0 0 0 0 0 0 I think it means that the packets are not even trying to exit via the GMII interface. Is this correct? If so - maybe there is a solution?0Views0likes3CommentsRe: Agilex 5 EMAC GMII loopthrough: signals are not toggling in Fabric
Hi thanks for the suggestion, So as you suggested to do, I have set trigger points on these two nodes: emac0_mac_txen_wire emac1_mac_txen_wire When running SignalTap with these as triggers, I am seeing some toggling on the txd line: I am noticing that for the first few seconds or so, this pattern will continue - and then it will settle here and not update again (i.e. enable will not toggle) This all happens without making any network commands in the Linux terminal. When making networking command through the linux terminal, these GMII signals still seem to not be affected still. Maybe you have some idea? Perhaps the EMAC is expecting some specific GMII packets back? I have not yet hooked it up to the external PHY - so perhaps it needs some signals from an external PHY? In terms of dummy packet generation, I have been using this module: module gmii_rx_test_pattern #( parameter CLK_FREQ = 125_000_000 // RX clock frequency in Hz )( input wire rx_clk, // GMII RX clock (usually 125 MHz) input wire rstn, // Active low reset output reg [7:0] rxd, // GMII RX data to MAC output reg rx_dv, // Receive data valid output reg rx_er // Receive error ); // Pattern ROM (16 bytes example) reg [7:0] pattern [0:15]; initial begin pattern[0] = 8'h55; // Ethernet preamble pattern[1] = 8'h55; pattern[2] = 8'h55; pattern[3] = 8'h55; pattern[4] = 8'h55; pattern[5] = 8'h55; pattern[6] = 8'h55; pattern[7] = 8'hD5; // SFD pattern[8] = 8'hDE; // Example payload pattern[9] = 8'hAD; pattern[10] = 8'hBE; pattern[11] = 8'hEF; pattern[12] = 8'hCA; pattern[13] = 8'hFE; pattern[14] = 8'hBA; pattern[15] = 8'hBE; end reg [3:0] index; reg sending; always @(posedge rx_clk or negedge rstn) begin if (!rstn) begin rxd <= 8'd0; rx_dv <= 1'b0; rx_er <= 1'b0; index <= 4'd0; sending <= 1'b0; end else begin // Simple state machine to send pattern repeatedly if (!sending) begin rx_dv <= 1'b1; // Start of frame rx_er <= 1'b0; rxd <= pattern[0]; index <= 4'd1; sending <= 1'b1; end else begin rxd <= pattern[index]; index <= index + 1'b1; if (index == 4'd15) begin rx_dv <= 1'b0; // End of frame sending <= 1'b0; end end end end endmodule I think it is OK. Please do correct me if not.16Views0likes5CommentsRe: Agilex 5 EMAC GMII loopthrough: signals are not toggling in Fabric
Hi, So far, the ping has never produced GMII toggles on SignalTap. I have also tried using a PLL generated 250MHz clock to measure on signal tap (as can be seen in the following diagrams). In the following, I disconnected the loopback and instead added a 'dummy' rx packet generator - then sent them to the EMAC rxd wire via Fabric: gmii_rx_test_pattern u_rx_pattern ( .rx_clk(emac1_mac_tx_clk_o_wire), .rstn(~system_reset), .rxd(emac0_mac_rxd_wire), .rx_dv(emac0_mac_rxdv_wire), .rx_er(emac0_mac_rxer_wire) ); Which produces the following: But it seems that on the Linux side these packets are not being acknowledged by the kernel: root@localhost:~# cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls card lo: 115040 1600 0 0 0 0 0 0 115040 1600 0 0 0 0 0 eth0: 0 0 0 0 0 0 0 0 9136 56 0 0 0 0 0 eth1: 0 0 0 0 0 0 0 0 9316 58 0 0 0 0 0 eth2: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 It also seems that sending ARPs do not produce GMII tx toggle in Fabric: root@localhost:~# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.70.5 netmask 255.255.255.0 broadcast 0.0.0.0 ether ... RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 56 bytes 9136 (9.1 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 23 eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.71.1 netmask 255.255.255.0 broadcast 0.0.0.0 ether ... RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 67 bytes 9838 (9.8 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 40 root@localhost:~# sudo arping -I eth1 192.168.70.5 ARPING 192.168.70.5 Timeout Timeout ...3Views0likes7CommentsRe: Agilex 5 EMAC GMII loopthrough: signals are not toggling in Fabric
Hi - so I changed this line. However, it seems the issue persists. Do you know why this might be? Please also note that the SoC system clocks are confirgured as followed: root@localhost:~# cat /sys/kernel/debug/clk/clk_summary enable prepare protect duty hardware clock count count count rate accuracy phase cycle enable ------------------------------------------------------------------------------------------------------- qspi-clk 1 1 0 200000000 0 0 50000 Y osc1 2 2 0 25000000 0 0 50000 Y periph_pll 1 1 0 2500000000 0 0 50000 Y peri_pll_c3 1 1 0 500000000 0 0 50000 Y psi_ref_free_clk 0 0 0 500000000 0 0 50000 Y psi_ref_clk 0 0 0 500000000 0 0 50000 Y s2f_user1_free_clk 0 0 0 500000000 0 0 50000 Y s2f_user1_clk 0 0 0 500000000 0 0 50000 Y s2f_user0_free_clk 0 0 0 500000000 0 0 50000 Y s2f_user0_clk 0 0 0 500000000 0 0 50000 Y emaca_free_clk 3 3 0 250000000 0 0 50000 Y emac2_clk 1 1 0 250000000 0 0 50000 Y emac1_clk 1 1 0 250000000 0 0 50000 Y emac0_clk 1 1 0 250000000 0 0 50000 Y So it seems the clocks are active, but when sending a 'ping' from EMAC0 to EMAC1 - there is no activity on the GMII lines in Fabric (even though it seems the ping is working in userland in the HPS) root@localhost:~# sudo ip addr add 192.168.70.5/24 dev eth0 root@localhost:~# sudo ip addr add 192.168.70.1/24 dev eth1 root@localhost:~# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.70.5 netmask 255.255.255.0 broadcast 0.0.0.0 ether 3e:17:2e:db:8b:f6 txqueuelen 1000 (Ethernet) RX packets 60 bytes 19080 (19.0 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 168 bytes 27408 (27.4 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 23 eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.70.1 netmask 255.255.255.0 broadcast 0.0.0.0 ether 62:6f:4c:21:f2:f4 txqueuelen 1000 (Ethernet) RX packets 59 bytes 18762 (18.7 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 170 bytes 27588 (27.5 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 40 ... root@localhost:~# ping -I 192.168.70.1 192.168.70.5 PING 192.168.70.5 (192.168.70.5) from 192.168.70.1 : 56(84) bytes of data. 64 bytes from 192.168.70.5: icmp_seq=1 ttl=64 time=0.189 ms 64 bytes from 192.168.70.5: icmp_seq=2 ttl=64 time=0.034 ms 64 bytes from 192.168.70.5: icmp_seq=3 ttl=64 time=0.168 ms 64 bytes from 192.168.70.5: icmp_seq=4 ttl=64 time=0.042 ms 64 bytes from 192.168.70.5: icmp_seq=5 ttl=64 time=0.022 ms 64 bytes from 192.168.70.5: icmp_seq=6 ttl=64 time=0.009 ms 64 bytes from 192.168.70.5: icmp_seq=7 ttl=64 time=0.029 ms 64 bytes from 192.168.70.5: icmp_seq=8 ttl=64 time=0.020 ms 64 bytes from 192.168.70.5: icmp_seq=9 ttl=64 time=0.009 ms 64 bytes from 192.168.70.5: icmp_seq=10 ttl=64 time=0.034 ms 64 bytes from 192.168.70.5: icmp_seq=11 ttl=64 time=0.014 ms 64 bytes from 192.168.70.5: icmp_seq=12 ttl=64 time=0.012 ms 64 bytes from 192.168.70.5: icmp_seq=13 ttl=64 time=0.052 ms 64 bytes from 192.168.70.5: icmp_seq=14 ttl=64 time=0.025 ms 64 bytes from 192.168.70.5: icmp_seq=15 ttl=64 time=0.019 ms ^C --- 192.168.70.5 ping statistics --- 15 packets transmitted, 15 received, 0% packet loss, time 14335ms19Views0likes9Comments