timvideos / litex-buildenv

An environment for building LiteX based FPGA designs. Makes it easy to get everything you need!
BSD 2-Clause "Simplified" License
215 stars 79 forks source link

tftp: rootfs.cpio is zero size #341

Closed pdp7 closed 4 years ago

pdp7 commented 4 years ago

from tutorial: HowTo-LCA2018-FPGA-Miniconf-VexRiscv-Renode

I am trying the section "Boot Linux via tftp". This gist has the full log.

Overview:

$ export CPU=vexriscv CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=linux
$ source ./scripts/enter-env.sh
(LX P=arty C=vexriscv.linux F=linux) $
(LX P=arty C=vexriscv.linux F=linux) $ make gateware
(LX P=arty C=vexriscv.linux F=linux) $ ./scripts/build-linux.sh

Here is the part with tftp:

(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ make tftpd_stop
# FIXME: This is dangerous...
(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ make tftpd_start
mkdir -p build/tftpd/
Starting atftpd
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]: Advanced Trivial FTP server started (0.7)
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   running in daemon mode on port 6069
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   bound to IP address 192.168.100.100 only
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   logging level: 6
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   directory: build/tftpd//
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   user: pdp7.pdp7
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   log file: /dev/stdout
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   not forcing to listen on local interfaces.
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   server timeout: Not used
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   tftp retry timeout: 5
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   maximum number of thread: 100
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   option timeout:   enabled
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   option tzise:     enabled
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   option blksize:   enabled
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:   option multicast: enabled
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:      address range: 239.255.0.0-255
Feb 19 23:35:16 x1 atftpd[16880.139858938175552]:      port range:    1758
(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ make tftp
mkdir -p build/arty_net_vexriscv.linux/
time python -u ./make.py --platform=arty --target=net --cpu-type=vexriscv --iprange=192.168.100 -Ob toolchain_path /home/pdp7/dev/litex-buildenv/build/Xilinx/opt/Xilinx/  --cpu-variant=linux --cpu-variant=linux  --no-compile-gateware \
    2>&1 | tee -a /home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux//output.20200219-233522.log; (exit ${PIPESTATUS[0]})
[WARNING] Deprecated, please update : shadow_base replaced by IO regions.
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/libcompiler_rt'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/libcompiler_rt'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/libbase'
 CC       exception.o
 CC       system.o
 CC       id.o
 CC       uart.o
 CC       time.o
 CC       spiflash.o
 CC       mdio.o
 AR       libbase.a
 AR       libbase-nofloat.a
make[1]: Leaving directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/libbase'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/libnet'
 CC       microudp.o
 AR       libnet.a
make[1]: Leaving directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/libnet'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/bios'
 CC       isr.o
 CC       sdram.o
 CC       main.o
 CC       boot.o
 LD       bios.elf
chmod -x bios.elf
 OBJCOPY  bios.bin
chmod -x bios.bin
python -m litex.soc.software.mkmscimg bios.bin --little
make[1]: Leaving directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/bios'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/uip'
 CC       clock-arch.o
 CC       liteethmac-drv.o
 AR       libuip.a
make[1]: Leaving directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/uip'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/firmware'
 CC       bist.o
 CC       ci.o
/home/pdp7/dev/litex-buildenv/firmware/ci.c: In function 'status_short_print':
/home/pdp7/dev/litex-buildenv/firmware/ci.c:368:15: warning: unused variable 'underflows' [-Wunused-variable]
  unsigned int underflows;
               ^~~~~~~~~~
/home/pdp7/dev/litex-buildenv/firmware/ci.c: In function 'status_print':
/home/pdp7/dev/litex-buildenv/firmware/ci.c:467:15: warning: unused variable 'underflows' [-Wunused-variable]
  unsigned int underflows;
               ^~~~~~~~~~
At top level:
/home/pdp7/dev/litex-buildenv/firmware/ci.c:1002:21: warning: 'log2' defined but not used [-Wunused-function]
 static unsigned int log2(unsigned int v)
                     ^~~~
 CC       config.o
 CC       encoder.o
 CC       etherbone.o
 CC       ethernet.o
 CC       fx2.o
 CC       hdmi_in0.o
 CC       hdmi_out0.o
 CC       hdmi_out1.o
 CC       heartbeat.o
 CC       isr.o
 CC       main.o
 CC       mdio.o
 CC       mmcm.o
/home/pdp7/dev/litex-buildenv/firmware/mmcm.c: In function 'mmcm_dump_all':
/home/pdp7/dev/litex-buildenv/firmware/mmcm.c:110:6: warning: unused variable 'i' [-Wunused-variable]
  int i;
      ^
 CC       oled.o
 CC       opsis_eeprom.o
bash /home/pdp7/dev/litex-buildenv/firmware/version_data.sh
# Check the version files exist
[ -e /home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/include/../..//software/firmware/version_data.h ]
[ -e /home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/include/../..//software/firmware/version_data.c ]
 CC       pattern.o
 CC       pll.o
 CC       processor.o
/home/pdp7/dev/litex-buildenv/firmware/processor.c: In function 'fb_set_mode':
/home/pdp7/dev/litex-buildenv/firmware/processor.c:532:15: warning: unused variable 'hdmi_out1_enabled' [-Wunused-variable]
  unsigned int hdmi_out1_enabled;
               ^~~~~~~~~~~~~~~~~
/home/pdp7/dev/litex-buildenv/firmware/processor.c:531:15: warning: unused variable 'hdmi_out0_enabled' [-Wunused-variable]
  unsigned int hdmi_out0_enabled;
               ^~~~~~~~~~~~~~~~~
/home/pdp7/dev/litex-buildenv/firmware/processor.c: In function 'processor_service':
/home/pdp7/dev/litex-buildenv/firmware/processor.c:793:29: warning: unused variable 'm' [-Wunused-variable]
  const struct video_timing *m = &video_modes[processor_mode];
                             ^
At top level:
/home/pdp7/dev/litex-buildenv/firmware/processor.c:449:13: warning: 'fb_clkgen_write' defined but not used [-Wunused-function]
 static void fb_clkgen_write(int m, int d)
             ^~~~~~~~~~~~~~~
 CC       reboot.o
 CC       stdio_wrap.o
 CC       tofe_eeprom.o
 CC       uptime.o
 CC       version.o
 CC       pcie.o
 CC       /home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/include/../..//software/firmware/hdmi_in1.o
 LD       firmware.elf
chmod -x firmware.elf
 OBJCOPY  firmware.bin
chmod -x firmware.bin
python -m litex.soc.software.mkmscimg -f --little firmware.bin -o firmware.fbi
make[1]: Leaving directory '/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux/software/firmware'

real    0m5.673s
user    0m3.277s
sys 0m0.425s
rm -rf build/tftpd/
mkdir -p build/tftpd/
cp build/arty_net_vexriscv.linux//software/linux/firmware.bin build/tftpd//Image
cp build/arty_net_vexriscv.linux//software/linux/riscv32-rootfs.cpio build/tftpd//rootfs.cpio
cp build/arty_net_vexriscv.linux//software/linux/rv32.dtb build/tftpd/
cp build/arty_net_vexriscv.linux//emulator/emulator.bin build/tftpd/

The I run:

make gateware-load
make firmware-connect

meanwhile I get this error:

(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ make gateware-load
openocd -f board/digilent_arty.cfg -c "init; pld load 0 build/arty_net_vexriscv.linux//gateware/top.bit; exit"
Open On-Chip Debugger 0.10.0+dev-01012-ged8fa09cf-dirty (2020-01-15-04:14)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
jtagspi_program
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 10000 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x0362d093 (mfg: 0x049 (Xilinx), part: 0x362d, ver: 0x0)
(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ Feb 19 23:37:04 x1 atftpd[16880.139858938087168]: socket may listen on any address, including broadcast
Feb 19 23:37:04 x1 atftpd[16880.139858938087168]: Serving Image to 192.168.100.50:7642
Feb 19 23:37:10 x1 atftpd[16880.139858938087168]: Server thread exiting
Feb 19 23:37:10 x1 atftpd[16880.139858929694464]: socket may listen on any address, including broadcast
Feb 19 23:37:10 x1 atftpd[16880.139858929694464]: Serving rootfs.cpio to 192.168.100.50:7642
Feb 19 23:37:10 x1 atftpd[16880.139858929694464]: Server thread exiting
Feb 19 23:37:10 x1 atftpd[16880.139858929694464]: socket may listen on any address, including broadcast
Feb 19 23:37:10 x1 atftpd[16880.139858929694464]: Serving boot.bin to 192.168.100.50:7642
Feb 19 23:37:10 x1 atftpd[16880.139858929694464]: File build/tftpd//boot.bin not found
Feb 19 23:37:10 x1 atftpd[16880.139858929694464]: Server thread exiting
pdp7 commented 4 years ago

this is reference I find to boot.bin:

Makefile:       cp $(FIRMWARE_FILEBASE).bin $(TFTPD_DIR)/boot.bin
pdp7 commented 4 years ago
(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ ls -latr build/tftpd/
total 2488
drwxr-xr-x 7 pdp7 pdp7    4096 Feb 19 23:35 ..
-rw-r--r-- 1 pdp7 pdp7       0 Feb 19 23:35 rootfs.cpio
-rwxr-xr-x 1 pdp7 pdp7 2717924 Feb 19 23:35 Image
-rw-r--r-- 1 pdp7 pdp7    1842 Feb 19 23:35 rv32.dtb
-rwxr-xr-x 1 pdp7 pdp7    2992 Feb 19 23:35 emulator.bin
pdp7 commented 4 years ago
(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ make firmware-connect
flterm --port=/dev/ttyUSB2 --speed=115200
[FLTERM] v2.4-29-g47d3b15 Starting...

litex> 
litex> reboot

        __   _ __      _  __
       / /  (_) /____ | |/_/
      / /__/ / __/ -_)>  <
     /____/_/\__/\__/_/|_|

 (c) Copyright 2012-2019 Enjoy-Digital

 BIOS built on Feb 19 2020 23:27:55
 BIOS CRC passed (93665d52)

 Migen git sha1: d11565a
 LiteX git sha1: 02bfda5e

--=============== SoC ==================--
CPU:       VexRiscv @ 100MHz
ROM:       64KB
SRAM:      32KB
L2:        8KB
MAIN-RAM:  262144KB

--========== Initialization ============--
Ethernet init...
Initializing SDRAM...
SDRAM now under software control
Read leveling:
m0, b0: |11111111110000000000000000000000| delays: 05+-05
m0, b1: |00000000000000011111111111100000| delays: 21+-06
m0, b2: |00000000000000000000000000000001| delays: 31+-00
m0, b3: |00000000000000000000000000000000| delays: -
m0, b4: |00000000000000000000000000000000| delays: -
m0, b5: |00000000000000000000000000000000| delays: -
m0, b6: |00000000000000000000000000000000| delays: -
m0, b7: |00000000000000000000000000000000| delays: -
best: m0, b1 delays: 21+-06
m1, b0: |11111111110000000000000000000000| delays: 05+-05
m1, b1: |00000000000000011111111111000000| delays: 20+-05
m1, b2: |00000000000000000000000000000001| delays: 31+-00
m1, b3: |00000000000000000000000000000000| delays: -
m1, b4: |00000000000000000000000000000000| delays: -
m1, b5: |00000000000000000000000000000000| delays: -
m1, b6: |00000000000000000000000000000000| delays: -
m1, b7: |00000000000000000000000000000000| delays: -
best: m1, b1 delays: 20+-05
SDRAM now under hardware control
Memtest OK

--============== Boot ==================--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Timeout
Loading emulator.bin from flash...
Error: Invalid image length 0xffffffff
Booting from flash...
Error: Invalid image length 0xffffffff
Booting from network...
Local IP : 192.168.100.50
Remote IP: 192.168.100.100
Fetching from: UDP/6069
Feb 19 23:40:31 x1 atftpd[18125.139949813991168]: socket may listen on any address, including broadcast
Feb 19 23:40:31 x1 atftpd[18125.139949813991168]: Serving Image to 192.168.100.50:7642
Feb 19 23:40:36 x1 atftpd[18125.139949813991168]: Server thread exiting
Feb 19 23:40:36 x1 atftpd[18125.139949805598464]: socket may listen on any address, including broadcast
Feb 19 23:40:36 x1 atftpd[18125.139949805598464]: Serving rootfs.cpio to 192.168.100.50:7642
Feb 19 23:40:36 x1 atftpd[18125.139949805598464]: Server thread exiting
Feb 19 23:40:36 x1 atftpd[18125.139949805598464]: socket may listen on any address, including broadcast
Feb 19 23:40:36 x1 atftpd[18125.139949805598464]: Serving boot.bin to 192.168.100.50:7642
Feb 19 23:40:36 x1 atftpd[18125.139949805598464]: File build/tftpd//boot.bin not found
Feb 19 23:40:36 x1 atftpd[18125.139949805598464]: Server thread exiting
Downloaded 2717924 bytes from Image over TFTP to 0xc0000000
Unable to download rootfs.cpio over TFTP
No rootfs.cpio found
Unable to download Linux images, falling back to boot.bin
Unable to download boot.bin over TFTP
Network boot failed
No boot medium found

--============= Console ================--
litex> 
pdp7 commented 4 years ago

Note: rootfs.cpio is 0

pdp7@x1:~/dev/litex-buildenv$ ls -tlar ./build/tftpd/
total 2488
drwxr-xr-x 7 pdp7 pdp7    4096 Feb 19 23:35 ..
-rw-r--r-- 1 pdp7 pdp7       0 Feb 19 23:35 rootfs.cpio
-rwxr-xr-x 1 pdp7 pdp7 2717924 Feb 19 23:35 Image
-rw-r--r-- 1 pdp7 pdp7    1842 Feb 19 23:35 rv32.dtb
-rwxr-xr-x 1 pdp7 pdp7    2992 Feb 19 23:35 emulator.bin
drwxr-xr-x 2 pdp7 pdp7    4096 Feb 19 23:35 .
pdp7@x1:~/dev/litex-buildenv$ ls -ltar ./build/arty_net_vexriscv.linux/software/linux/
total 20692
-rw-r--r--  1 pdp7 pdp7    1842 Jul 26  2019 rv32.dtb
drwxr-xr-x 10 pdp7 pdp7    4096 Feb  2 17:05 ..
-rw-r--r--  1 pdp7 pdp7       0 Feb  2 17:05 riscv32-rootfs.cpio
drwxr-xr-x  4 pdp7 pdp7    4096 Feb  2 17:05 include
drwxr-xr-x  3 pdp7 pdp7    4096 Feb  2 17:05 arch
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 .tmp_versions
drwxr-xr-x  6 pdp7 pdp7    4096 Feb  2 17:06 scripts
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 usr
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 certs
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 init
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 ipc
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 security
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 crypto
drwxr-xr-x  3 pdp7 pdp7    4096 Feb  2 17:06 block
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 sound
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 firmware
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 net
drwxr-xr-x  2 pdp7 pdp7    4096 Feb  2 17:06 mm
drwxr-xr-x  3 pdp7 pdp7    4096 Feb  2 17:06 virt
drwxr-xr-x 11 pdp7 pdp7    4096 Feb  2 17:06 fs
drwxr-xr-x 11 pdp7 pdp7    4096 Feb  2 17:06 kernel
drwxr-xr-x  6 pdp7 pdp7   12288 Feb  2 17:06 lib
drwxr-xr-x 42 pdp7 pdp7    4096 Feb  2 17:06 drivers
-rw-r--r--  1 pdp7 pdp7       2 Feb  2 17:06 .version
-rw-r--r--  1 pdp7 pdp7  176108 Feb  2 17:06 built-in.a
-rw-r--r--  1 pdp7 pdp7 6121292 Feb  2 17:06 vmlinux.o
-rw-r--r--  1 pdp7 pdp7       0 Feb  2 17:06 Module.symvers
-rwxr-xr-x  1 pdp7 pdp7 3016688 Feb  2 17:06 .tmp_vmlinux1
-rw-r--r--  1 pdp7 pdp7  811924 Feb  2 17:06 .tmp_kallsyms1.S
-rw-r--r--  1 pdp7 pdp7  140564 Feb  2 17:06 .tmp_kallsyms1.o
-rwxr-xr-x  1 pdp7 pdp7 3156196 Feb  2 17:06 .tmp_vmlinux2
-rw-r--r--  1 pdp7 pdp7  811924 Feb  2 17:06 .tmp_kallsyms2.S
-rw-r--r--  1 pdp7 pdp7  140564 Feb  2 17:06 .tmp_kallsyms2.o
-rwxr-xr-x  1 pdp7 pdp7 3156196 Feb  2 17:06 vmlinux
-rw-r--r--  1 pdp7 pdp7  371777 Feb  2 17:06 System.map
-rw-r--r--  1 pdp7 pdp7  371777 Feb  2 17:06 .tmp_System.map
-rw-r--r--  1 pdp7 pdp7     155 Feb  2 17:06 .vmlinux.cmd
-rw-r--r--  1 pdp7 pdp7 2717932 Feb 19 22:33 firmware.fbi
-rw-r--r--  1 pdp7 pdp7   22648 Feb 19 23:34 .config.old
-rw-r--r--  1 pdp7 pdp7   22648 Feb 19 23:34 .config
lrwxrwxrwx  1 pdp7 pdp7      47 Feb 19 23:34 source -> /home/pdp7/dev/litex-buildenv/third_party/linux
-rw-r--r--  1 pdp7 pdp7     437 Feb 19 23:34 Makefile
-rw-r--r--  1 pdp7 pdp7       0 Feb 19 23:34 modules.order
-rw-r--r--  1 pdp7 pdp7    1186 Feb 19 23:34 .missing-syscalls.d
lrwxrwxrwx  1 pdp7 pdp7      97 Feb 19 23:34 firmware.bin -> /home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux//software/linux/arch/riscv/boot/Image
drwxr-xr-x 22 pdp7 pdp7    4096 Feb 19 23:34 .
pdp7 commented 4 years ago

from https://github.com/timvideos/litex-buildenv/blob/master/scripts/build-linux.sh#L70

    export ARCH=riscv
    ROOTFS_LOCATION="https://antmicro.com/projects/renode/litex-buildenv/"
    ROOTFS=${ARCH}32-rootfs.cpio

and later:

                if [ ! -e $TARGET_LINUX_BUILD_DIR/$ROOTFS ]; then
                        wget $ROOTFS_LOCATION/$ROOTFS -O $TARGET_LINUX_BUILD_DIR/$ROOTFS
                fi

This turns out to be: $TARGET_LINUX_BUILD_DIR = /home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux//software/linux

$TARGET_LINUX_BUILD_DIR/$ROOTFS = /home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux//software/linux/riscv32-rootfs.cpio

$ROOTFS_LOCATION/$ROOTFS = https://antmicro.com/projects/renode/litex-buildenv//riscv32-rootfs.cpio

(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ wget https://antmicro.com/projects/renode/litex-buildenv//riscv32-rootfs.cpio
--2020-02-20 00:00:54--  https://antmicro.com/projects/renode/litex-buildenv//riscv32-rootfs.cpio
Resolving antmicro.com (antmicro.com)... 151.80.152.88
Connecting to antmicro.com (antmicro.com)|151.80.152.88|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4059136 (3.9M) [application/x-cpio]
Saving to: ‘riscv32-rootfs.cpio’

riscv32-rootfs.cpio                                  100%[=====================================================================================================================>]   3.87M  8.68MB/s    in 0.4s    

2020-02-20 00:00:55 (8.68 MB/s) - ‘riscv32-rootfs.cpio’ saved [4059136/4059136]

This does seem to work:

(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ wget https://antmicro.com/projects/renode/litex-buildenv//riscv32-rootfs.cpio -O /home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux//software/linux/riscv32-rootfs.cpio
--2020-02-20 00:02:20--  https://antmicro.com/projects/renode/litex-buildenv//riscv32-rootfs.cpio
Resolving antmicro.com (antmicro.com)... 151.80.152.88
Connecting to antmicro.com (antmicro.com)|151.80.152.88|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4059136 (3.9M) [application/x-cpio]
Saving to: ‘/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux//software/linux/riscv32-rootfs.cpio’

/home/pdp7/dev/litex-buildenv/build/arty_net_vexrisc 100%[=====================================================================================================================>]   3.87M  6.50MB/s    in 0.6s    

2020-02-20 00:02:21 (6.50 MB/s) - ‘/home/pdp7/dev/litex-buildenv/build/arty_net_vexriscv.linux//software/linux/riscv32-rootfs.cpio’ saved [4059136/4059136]
GitHub
timvideos/litex-buildenv
An environment for building LiteX based FPGA designs. Makes it easy to get everything you need! - timvideos/litex-buildenv
pdp7 commented 4 years ago

Now running again and rootfs.cpio is no longer zero:

(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ make tftp

(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ ls -ltar build/tftpd/
total 6452
drwxr-xr-x 7 pdp7 pdp7    4096 Feb 20 00:03 ..
-rwxr-xr-x 1 pdp7 pdp7 2717924 Feb 20 00:03 Image
-rw-r--r-- 1 pdp7 pdp7 4059136 Feb 20 00:03 rootfs.cpio
-rw-r--r-- 1 pdp7 pdp7    1842 Feb 20 00:03 rv32.dtb
-rwxr-xr-x 1 pdp7 pdp7    2992 Feb 20 00:03 emulator.bin
drwxr-xr-x 2 pdp7 pdp7    4096 Feb 20 00:03 .
pdp7 commented 4 years ago

Now it boots ok:

make gateware-load && make firmware-connect

Log:

(LX P=arty C=vexriscv.linux F=linux) pdp7@x1:~/dev/litex-buildenv$ make gateware-load && make firmware-connect
openocd -f board/digilent_arty.cfg -c "init; pld load 0 build/arty_net_vexriscv.linux//gateware/top.bit; exit"
Open On-Chip Debugger 0.10.0+dev-01012-ged8fa09cf-dirty (2020-01-15-04:14)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
jtagspi_program
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 10000 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x0362d093 (mfg: 0x049 (Xilinx), part: 0x362d, ver: 0x0)
flterm --port=/dev/ttyUSB2 --speed=115200
[FLTERM] v2.4-29-g47d3b15 Starting...
Initializing SDRAM...
SDRAM now under software control
Read leveling:
m0, b0: |11111111110000000000000000000000| delays: 05+-05
m0, b1: |00000000000000011111111111100000| delays: 21+-06
m0, b2: |00000000000000000000000000000001| delays: 31+-00
m0, b3: |00000000000000000000000000000000| delays: -
m0, b4: |00000000000000000000000000000000| delays: -
m0, b5: |00000000000000000000000000000000| delays: -
m0, b6: |00000000000000000000000000000000| delays: -
m0, b7: |00000000000000000000000000000000| delays: -
best: m0, b1 delays: 21+-06
m1, b0: |11111111110000000000000000000000| delays: 05+-05
m1, b1: |00000000000000011111111111000000| delays: 20+-05
m1, b2: |00000000000000000000000000000001| delays: 31+-00
m1, b3: |00000000000000000000000000000000| delays: -
m1, b4: |00000000000000000000000000000000| delays: -
m1, b5: |00000000000000000000000000000000| delays: -
m1, b6: |00000000000000000000000000000000| delays: -
m1, b7: |00000000000000000000000000000000| delays: -
best: m1, b1 delays: 20+-05
SDRAM now under hardware control
Memtest OK

--============== Boot ==================--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Timeout
Loading emulator.bin from flash...
Error: Invalid image length 0xffffffff
Booting from flash...
Error: Invalid image length 0xffffffff
Booting from network...
Local IP : 192.168.100.50
Remote IP: 192.168.100.100
Fetching from: UDP/6069
Feb 20 00:08:11 x1 atftpd[18125.139949805598464]: socket may listen on any address, including broadcast
Feb 20 00:08:11 x1 atftpd[18125.139949805598464]: Serving Image to 192.168.100.50:7642
Feb 20 00:08:15 x1 atftpd[18125.139949805598464]: Server thread exiting
Feb 20 00:08:15 x1 atftpd[18125.139949813991168]: socket may listen on any address, including broadcast
Feb 20 00:08:15 x1 atftpd[18125.139949813991168]: Serving rootfs.cpio to 192.168.100.50:7642
Downloaded 2717924 bytes from Image over TFTP to 0xc0000000
Feb 20 00:08:22 x1 atftpd[18125.139949813991168]: Server thread exiting
Feb 20 00:08:22 x1 atftpd[18125.139949805598464]: socket may listen on any address, including broadcast
Feb 20 00:08:22 x1 atftpd[18125.139949805598464]: Serving rv32.dtb to 192.168.100.50:7642
Feb 20 00:08:22 x1 atftpd[18125.139949805598464]: Server thread exiting
Feb 20 00:08:22 x1 atftpd[18125.139949813991168]: socket may listen on any address, including broadcast
Feb 20 00:08:22 x1 atftpd[18125.139949813991168]: Serving emulator.bin to 192.168.100.50:7642
DownloFeb 20 00:08:22 x1 atftpd[18125.139949813991168]: Server thread exiting
aded 4059136 bytes from rootfs.cpio over TFTP to 0xc0800000
Downloaded 1842 bytes from rv32.dtb over TFTP to 0xc1000000
Downloaded 2992 bytes from emulator.bin over TFTP to 0x50000000
Executing booted program at 0x50000000

--============= Liftoff! ===============--
*** VexRiscv BIOS ***
*** Supervisor ***
No DTB passed to the kernel
Linux version 5.0.0 (pdp7@x1) (gcc version 9.1.0 (9.1.0)) #1 Sun Feb 2 17:06:01 CET 2020
Initial ramdisk at: 0x(ptrval) (8388608 bytes)
Zone ranges:
  Normal   [mem 0x00000000c0000000-0x00000000c1ffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x00000000c0000000-0x00000000c1ffffff]
Initmem setup node 0 [mem 0x00000000c0000000-0x00000000c1ffffff]
elf_hwcap is 0x1101
Built 1 zonelists, mobility grouping on.  Total pages: 8128
Kernel command line: mem=32M@0x40000000 rootwait console=hvc0 root=/dev/ram0 init=/sbin/init swiotlb=32
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Sorting __ex_table...
Memory: 21596K/32768K available (1950K kernel code, 90K rwdata, 318K rodata, 104K init, 184K bss, 11172K reserved, 0K cma-reserved)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 25483472618 ns
sched_clock: 32 bits at 75MHz, resolution 13ns, wraps every 28633115129ns
Console: colour dummy device 80x25
printk: console [hvc0] enabled
Calibrating delay loop (skipped), value calculated using timer frequency.. 150.00 BogoMIPS (lpj=300000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
devtmpfs: initialized
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
futex hash table entries: 256 (order: -1, 3072 bytes)
clocksource: Switched to clocksource riscv_clocksource
Unpacking initramfs...
Initramfs unpacking failed: junk in compressed archive
workingset: timestamp_bits=30 max_order=13 bucket_order=0
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler mq-deadline registered
io scheduler kyber registered
random: get_random_bytes called from init_oops_id+0x4c/0x60 with crng_init=0
Freeing unused kernel memory: 104K
This architecture does not have kernel memory protection.
Run /init as init process
mount: mounting tmpfs on /dev/shm failed: Invalid argument
mount: mounting tmpfs on /tmp failed: Invalid argument
mount: mounting tmpfs on /run failed: Invalid argument
Starting syslogd: OK
Starting klogd: OK
Initializing random number generator... random: dd: uninitialized urandom read (512 bytes read)
done.
Starting network: ip: socket: Function not implemented
ip: socket: Function not implemented
FAIL

Welcome to Buildroot
buildroot login: ooot
Password: 
Login incorrect
buildroot login: root

login[48]: root login on 'hvc0'
# 
# cat /proc/cpuinfo 
processor   : 0
hart        : 0
isa     : rv32ima
mmu     : sv32
uarch       : spinalhdl,vexriscv

# 
# uname -a
Linux buildroot 5.0.0 #1 Sun Feb 2 17:06:01 CET 2020 riscv32 GNU/Linux
# 
# dmesg |head
No DTB passed to the kernel
Linux version 5.0.0 (pdp7@x1) (gcc version 9.1.0 (9.1.0)) #1 Sun Feb 2 17:06:01 CET 2020
Initial ramdisk at: 0x(ptrval) (8388608 bytes)
Zone ranges:
  Normal   [mem 0x00000000c0000000-0x00000000c1ffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x00000000c0000000-0x00000000c1ffffff]
Initmem setup node 0 [mem 0x00000000c0000000-0x00000000c1ffffff]
On node 0 totalpages: 8192
# 
# 
mateusz-holenko commented 4 years ago

That's a quite nice analysis of the problem - @pdp7 :)

It looks like some initial wget failed (network problem?) and it created an empty riscv32-rootfs.cpio file. From this moment on the (broken, empty) cached version was served by the tftp server.

The trivial solution would be to not only check if the rootfs file exists, but also verify it's not empty. I sense more problems though - what if the file is only partially downloaded (i.e., it's not a proper rootfs image but it's not empty)?

We should probably add some CRC checking to make sure that files downloaded with wget are correct.

BTW: I also noticed a problem in build-linux.sh script in your log: https://gist.github.com/pdp7/287a0a5159d1877480aaaf6e513c23b1#file-litex-tftp-linux-txt-L3011. It's not related to your issue, but should be fixed anyway.

Gist
tftp linux litex
tftp linux litex. GitHub Gist: instantly share code, notes, and snippets.
pdp7 commented 4 years ago

@mateusz-holenko thanks, that makes sense, so I could have also just deleted the empty rootfs.cpio as a workaround.

mateusz-holenko commented 4 years ago

347 added checksum verification of downloaded files, so this problem should not happen again.