litex-hub / linux-on-litex-vexriscv

Linux on LiteX-VexRiscv
BSD 2-Clause "Simplified" License
552 stars 174 forks source link

ac701 board no eth0 interface #261

Closed cyntem closed 2 years ago

cyntem commented 2 years ago

Hi, big thanks for great project! I'm trying to get linux with ethernet and sdcard on ac701 board. My problems with this board was: 1) The board has low voltage on USB-UART CP2103GM. VIO port has 1.7V, but 1.8V is minimal for CP2103GM. I don't know is it problem with my board or design mistake, but similar KC705 use CP2103GM with 2.5V, thats why KC705 has no such problem. I use external USB-UART converter with J48 3.3V header and serial interface become to work. 2) Another problem with DDR3 memory. In file litex_boards/targets/xilinx_ac701.py
PHYPadsReducer(platform.request("ddram"), [0, 1, 2, 3]), always produce memory test errors. For my board working sequence PHYPadsReducer(platform.request("ddram"), [1, 2, 3, 4]), . With current sequence linux start boot. 3) Last problem - is ethernet interface. TFTP boot is working, but eth0 interface is missing. I got errors [ 1.980624] liteeth f0002000.mac: unable to get rx-fifo-depth [ 1.982475] liteeth: probe of f0002000.mac failed with error -22

Is it problem with linux image or with board?

full log is ` _ _ / / () /____ | |// / // / / -)> < /____//_/_//|| Build your hardware, easily!

(c) Copyright 2012-2021 Enjoy-Digital (c) Copyright 2007-2015 M-Labs

BIOS built on Dec 28 2021 20:15:20 BIOS CRC passed (1334d4e5)

Migen git sha1: ac70301 LiteX git sha1: a6ed4c5c

--=============== SoC ==================-- CPU: VexRiscv SMP-LINUX @ 100MHz BUS: WISHBONE 32-bit @ 4GiB CSR: 32-bit data ROM: 64KiB SRAM: 8KiB SDRAM: 524288KiB 32-bit @ 800MT/s (CL-7 CWL-5)

--========== Initialization ============-- Ethernet init... Initializing SDRAM @0x40000000... Switching SDRAM to software control. Write latency calibration: m0:0 m1:6 m2:6 m3:6 Read leveling: m0, b00: |00000000000000000000000000000000| delays: - m0, b01: |00000000000000000000000000000000| delays: - m0, b02: |00000000000000000000000000000000| delays: - m0, b03: |11111111111000000000000000000000| delays: 05+-05 m0, b04: |00000000000000011111111111100000| delays: 21+-06 m0, b05: |00000000000000000000000000000000| delays: - m0, b06: |00000000000000000000000000000000| delays: - m0, b07: |00000000000000000000000000000000| delays: - best: m0, b04 delays: 21+-05 m1, b00: |00000000000000000000000000000000| delays: - m1, b01: |00000000000000000000000000000000| delays: - m1, b02: |00000000000000000000000000000000| delays: - m1, b03: |11111111100000000000000000000000| delays: 04+-04 m1, b04: |00000000000000111111111110000000| delays: 19+-05 m1, b05: |00000000000000000000000000000001| delays: 31+-00 m1, b06: |00000000000000000000000000000000| delays: - m1, b07: |00000000000000000000000000000000| delays: - best: m1, b04 delays: 19+-05 m2, b00: |00000000000000000000000000000000| delays: - m2, b01: |00000000000000000000000000000000| delays: - m2, b02: |00000000000000000000000000000000| delays: - m2, b03: |11111111111100000000000000000000| delays: 06+-06 m2, b04: |00000000000000011111111111110000| delays: 21+-06 m2, b05: |00000000000000000000000000000001| delays: 31+-00 m2, b06: |00000000000000000000000000000000| delays: - m2, b07: |00000000000000000000000000000000| delays: - best: m2, b04 delays: 21+-06 m3, b00: |00000000000000000000000000000000| delays: - m3, b01: |00000000000000000000000000000000| delays: - m3, b02: |00000000000000000000000000000000| delays: - m3, b03: |11111100000000000000000000000000| delays: 03+-03 m3, b04: |00000000001111111111100000000000| delays: 15+-05 m3, b05: |00000000000000000000000000011111| delays: 29+-02 m3, b06: |00000000000000000000000000000000| delays: - m3, b07: |00000000000000000000000000000000| delays: - best: m3, b04 delays: 15+-05 Switching SDRAM to hardware control. Memtest at 0x40000000 (2.0MiB)... Write: 0x40000000-0x40200000 2.0MiB
Read: 0x40000000-0x40200000 2.0MiB
Memtest OK Memspeed at 0x40000000 (Sequential, 2.0MiB)... Write speed: 31.7MiB/s Read speed: 34.6MiB/s

--============== Boot ==================-- Booting from serial... Press Q or ESC to abort boot completely. sL5DdSMmkekro Timeout Booting from SDCard in SD-Mode... Booting from boot.json... Copying Image to 0x40000000 (7420864 bytes)... [########################################] Copying rv32.dtb to 0x40ef0000 (3102 bytes)... [########################################] Copying rootfs.cpio to 0x41000000 (4010496 bytes)... [########################################] Copying opensbi.bin to 0x40f00000 (53640 bytes)... [########################################] Executing booted program at 0x40f00000

--============= Liftoff! ===============--

OpenSBI v0.8-1-gecf7701


/ \ / __ _ _ __ (___ _) ' \ / \ '_ \ ___ \ _ < __ _) __/ ____) _) _ ____/ ./ _ _ _ _____/ __/___
_

Platform Name : LiteX / VexRiscv-SMP Platform Features : timer,mfdeleg Platform HART Count : 8 Boot HART ID : 0 Boot HART ISA : rv32imas BOOT HART Features : time BOOT HART PMP Count : 0 Firmware Base : 0x40f00000 Firmware Size : 124 KB Runtime SBI Version : 0.2

MIDELEG : 0x00000222 MEDELEG : 0x0000b101 [ 0.000000] Linux version 5.12.0-rc4 (florent@panda) (riscv32-buildroot-linux-gnu-gcc.br_real (Buildroot 2020.11-281-g69e5046e7b) 10.2.0, GNU ld (GNU Binutils) 2.35.2) #2 SMP Mon Mar 29 10:07:39 CEST 2021 [ 0.000000] earlycon: sbi0 at MMIO 0xf0001000 (options '') [ 0.000000] printk: bootconsole [sbi0] enabled [ 0.000000] Zone ranges: [ 0.000000] Normal [mem 0x0000000040000000-0x000000005fffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000040000000-0x000000005fffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000005fffffff] [ 0.000000] SBI specification v0.2 detected [ 0.000000] SBI implementation ID=0x1 Version=0x8 [ 0.000000] SBI v0.2 TIME extension detected [ 0.000000] SBI v0.2 IPI extension detected [ 0.000000] SBI v0.2 RFENCE extension detected [ 0.000000] SBI v0.2 HSM extension detected [ 0.000000] riscv: ISA extensions aim [ 0.000000] riscv: ELF capabilities aim [ 0.000000] percpu: Embedded 10 pages/cpu s19148 r0 d21812 u40960 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 130048 [ 0.000000] Kernel command line: console=liteuart earlycon=sbi,0xf0001000 rootwait root=/dev/ram0 [ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear) [ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes, linear) [ 0.000000] Sorting __ex_table... [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [ 0.000000] Memory: 503536K/524288K available (5596K kernel code, 572K rwdata, 860K rodata, 214K init, 221K bss, 20752K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 [ 0.000000] rcu: Hierarchical RCU implementation. [ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies. [ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 [ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0 [ 0.000000] riscv-intc: 32 local interrupts mapped [ 0.000000] plic: interrupt-controller@f0c00000: mapped 32 interrupts with 2 handlers for 4 contexts. [ 0.000000] random: get_random_bytes called from start_kernel+0x360/0x4d0 with crng_init=0 [ 0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0] [ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x171024e7e0, max_idle_ns: 440795205315 ns [ 0.000016] sched_clock: 64 bits at 100MHz, resolution 10ns, wraps every 4398046511100ns [ 0.003390] Console: colour dummy device 80x25 [ 0.004759] Calibrating delay loop (skipped), value calculated using timer frequency.. 200.00 BogoMIPS (lpj=400000) [ 0.007925] pid_max: default: 32768 minimum: 301 [ 0.011188] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.013367] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.031489] ASID allocator using 9 bits (512 entries) [ 0.034426] rcu: Hierarchical SRCU implementation. [ 0.040063] smp: Bringing up secondary CPUs ... [ 0.049729] smp: Brought up 1 node, 2 CPUs [ 0.055926] devtmpfs: initialized [ 0.079474] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns [ 0.082481] futex hash table entries: 512 (order: 3, 32768 bytes, linear) [ 0.087687] NET: Registered protocol family 16 [ 0.208157] FPGA manager framework [ 0.217747] clocksource: Switched to clocksource riscv_clocksource [ 0.353498] NET: Registered protocol family 2 [ 0.361386] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear) [ 0.364216] TCP established hash table entries: 4096 (order: 2, 16384 bytes, linear) [ 0.367066] TCP bind hash table entries: 4096 (order: 3, 32768 bytes, linear) [ 0.369909] TCP: Hash tables configured (established 4096 bind 4096) [ 0.372224] UDP hash table entries: 256 (order: 1, 8192 bytes, linear) [ 0.374383] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear) [ 0.384952] Unpacking initramfs... [ 0.892597] Initramfs unpacking failed: invalid magic at start of compressed archive [ 0.939340] Freeing initrd memory: 8192K [ 0.947664] workingset: timestamp_bits=30 max_order=17 bucket_order=0 [ 1.096347] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253) [ 1.098370] io scheduler mq-deadline registered [ 1.099492] io scheduler kyber registered [ 1.108921] LiteX SoC Controller driver initialized: subreg:4, align:4 [ 1.943809] f0001000.serial: ttyLXU0 at MMIO 0x0 (irq = 0, base_baud = 0) is a liteuart [ 1.947919] printk: console [liteuart0] enabled [ 1.947919] printk: console [liteuart0] enabled [ 1.950251] printk: bootconsole [sbi0] disabled [ 1.950251] printk: bootconsole [sbi0] disabled [ 1.978367] libphy: Fixed MDIO Bus: probed [ 1.980624] liteeth f0002000.mac: unable to get rx-fifo-depth [ 1.982475] liteeth: probe of f0002000.mac failed with error -22 [ 1.986026] i2c /dev entries driver [ 2.006144] litex-mmc f0006000.mmc: Requested clk_freq=12500000: set to 12500000 via div=8 [ 2.045537] NET: Registered protocol family 10 [ 2.055988] Segment Routing with IPv6 [ 2.057809] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver [ 2.067912] NET: Registered protocol family 17 [ 2.079082] Freeing unused kernel memory: 208K [ 2.080167] Kernel memory protection not selected by kernel config. [ 2.082153] Run /init as init process [ 2.084144] litex-mmc f0006000.mmc: Requested clk_freq=0: set to 390625 via div=256 [ 2.106411] litex-mmc f0006000.mmc: Requested clk_freq=12500000: set to 12500000 via div=8 [ 2.147306] litex-mmc f0006000.mmc: Requested clk_freq=25000000: set to 25000000 via div=4 [ 2.150296] mmc0: new SDXC card at address 0001 [ 2.158874] mmcblk0: mmc0:0001 SD64G 58.2 GiB [ 2.169367] mmcblk0: p1 Starting syslogd: OK Starting klogd: OK Running sysctl: OK Saving random seed: [ 3.220688] random: dd: uninitialized urandom read (512 bytes read) OK Starting network: OK

Welcome to Buildroot buildroot login: `

cyntem commented 2 years ago

Finally i got eth0 worked! Prebuilt linux images produce current bug ( linux_2020_12_30.zip and linux_2021_03_29 ). I built new linux image and get it work.

For now linux image from this man is not work.

$ git clone http://github.com/buildroot/buildroot
$ cd buildroot
$ make BR2_EXTERNAL=../linux-on-litex-vexriscv/buildroot/ litex_vexriscv_defconfig
$ make

It's failed because of headers 5.15.

I use buildroot https://github.com/buildroot/buildroot/archive/refs/tags/2021.02.3.tar.gz And built successfully. Thanks for great project!

smosanu commented 1 year ago

Hi @cyntem,

Please help! I am stuck with the same issue and would like to try your solution. I am building and deploying the bitstream for KC705 board with ethernet interface and tested that it works in BIOS by booting Linux via TFTP. However, once Linux boots, I don't see the eth0 interface when running ifconfig -a. Here is a log of how it looks. kc705noeth0.txt

I generated several versions of the Linux image (and root fs): using buildroot version that you linked, using an older LiteX Linux version, using the latest versions (buildroot, etc), modified the default_config file to specifically add the ethernet, but with no luck. Each time I also looked under /etc/ and /var/ trying to see the ethernet interfaces available, manually setting an eth0 interface - no luck.

root@buildroot:~# cat /etc/network/interfaces 
# interface file auto-generated by buildroot

auto lo
iface lo inet loopback

headers 5.15

Can you please go into more detail about the headers issue?

Dolu1990 commented 1 year ago

Hi, Could you show the dts which was generated (in build/??? folder) ? Maybe it is missing there ?

cyntem commented 1 year ago

Hi @smosanu , My last work version was with kernels 5.14, with 5.15 it's not worked. You can make menuconfig and choose custom 5.14 kernel to build image. For me it's work. Also AC701 has two ethernet interface A7_1000BASEX and RGMII. Only RGMII work's stable on the board. I spent hours to understand what's wrong with 1000BASEX, but it's not works stable. Sometimes works, sometimes not, may be my board has a bug, I don't know.

smosanu commented 1 year ago

@cyntem Thank you! I will attempt to use the 5.14 kernels, though several suggestions are to investigate the device tree (dts) file so I plan to compare with a known-to-work platform such as the Arty A7. @Dolu1990 Thank you! Here is the dts file and a log file. I do want to ask about the .dts file - it seems it is not generated by the litex-boards/target scripts (but it is generated in linux-on-vexriscv). I should probably enable it somehow?! The log attached is on an image build within linux-on-vexriscv(-smp) though I often use a system with NaxRISC-V from litex-boards/target. It seems to work just fine though I am not sure it's supposed to be compatible. netboot_eth0_missing_log.txt kc705.dts.txt

Dolu1990 commented 1 year ago

I should probably enable it somehow?

I don't know how to do it either ^^

the dts seems fine to me. But weird there is realy nothing is the boot logs. Can you send the linux .config from the linux repo ?

smosanu commented 1 year ago

Hi @Dolu1990 sorry for the late reply. I experimented with several buildroot configurations, all based on the original one from this repository. The boot log previously attached was with the original image downloaded from this repo, though it was as unsuccessful with images I generated with variations of this config. litex_vexriscv_defconfig.txt I added (not all at once) lines 21, 44-46 (for benchmarks), 60. Will update here if I find a solution.

Dolu1990 commented 1 year ago

@smosanu Ahh i mean the linux defconfig, not the buildroot one.

Dolu1990 commented 1 year ago

more precisly, the .config from the output/build/linux-xxxxx folder :)

smosanu commented 1 year ago

Here it is! I am uploading several - the file name describes the differences. Thank you for the precise instructions - I did need them. :) config_default.txt - this is the default configuration config_withDhryStone.txt config_Dhrystn_plusEthAttempt.txt config_EthAttempt2.txt config_with_buildroot2021_02_3.txt

Dolu1990 commented 1 year ago

hmm seems ok to me.

I guess in those case, the way is to edit the probe function of the liteeth linux driver to add some printk, to see if the code is called or not. That would show on which side is the issue (setup with dts / absence of driver, or instead, something going bad futher the probe)