litex-hub / linux-on-litex-vexriscv

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

Issue booting linux on ArtyA7 #15

Closed Dolu1990 closed 5 years ago

Dolu1990 commented 5 years ago

Hi,

I tested the flow on the ArtyA7 and got an issue at the moment it liftoff in linux.

Commands used :

git clone https://github.com/enjoy-digital/linux-on-litex-vexriscv.git

git clone https://github.com/enjoy-digital/linux-on-litex-vexriscv-prebuilt
cp -r linux-on-litex-vexriscv-prebuilt/* linux-on-litex-vexriscv

wget https://raw.githubusercontent.com/enjoy-digital/litex/master/litex_setup.py
chmod +x litex_setup.py
sudo ./litex_setup.py init install --user

cd linux-on-litex-vexriscv
./make.py --board=arty --build
sudo ./make.py --board=arty --flash

ttyUSB =>

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

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

 BIOS built on May 15 2019 14:36:07
 BIOS CRC passed (6772ad38)

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

--========= Peripherals init ===========--
Initializing SDRAM...
SDRAM now under software control
Read leveling:
m0, b0: |11111110000000000000000000000000| delays: 03+-03
m0, b1: |00000000000000111111111000000000| delays: 18+-04
m0, b2: |00000000000000000000000000000011| delays: 31+-01
m0, b3: |00000000000000000000000000000000| delays: -
m0, b4: |00000000000000000000000000000000| delays: -
m0, b5: |00000000000000000000000000000000| delays: -
m0, b6: |00000000000000000000000000000000| delays: -
m0, b7: |00000000000000000000000000000000| delays: -
best: m0, b1 delays: 18+-04
m1, b0: |11111111111000000000000000000000| delays: 05+-05
m1, b1: |00000000000000111111111111000000| delays: 20+-06
m1, b2: |00000000000000000000000000000011| delays: 31+-01
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 sequence =============--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Timeout
Loading Image from flash...
Loading rootfs.cpio from flash...
Loading rv32.dtb from flash...
Loading emulator.bin from flash...
Executing booted program at 0x20000000
--============= Liftoff! ===============--

And that's all. The ./sim.py work and boot the linux properly.

Currently, i'm not sure where the problem is. Maybe somebody else can try on their own the same procedure to cross check ? Or I did something wrong ?

Dolu1990 commented 5 years ago

In the bios, the memtest command pass.

enjoy-digital commented 5 years ago

Hi @Dolu1990,

i can test it tomorrow. Your issue is probably specific to the boot from the SPI Flash. Can you test booting from serial?: https://github.com/enjoy-digital/linux-on-litex-vexriscv#load-the-linux-images-over-serial

Dolu1990 commented 5 years ago

Hi @enjoy-digital I tested both flash and serial and got the same issue.

Let's me know how it go :)

futaris commented 5 years ago

I suspect it is because of the changes to the memory / device-tree. I will try booting this again soon.

https://github.com/enjoy-digital/linux-on-litex-vexriscv/commit/6b6f12660e23c217c7f9790f2f023addffc52213 was the last build that I tested working.

Dolu1990 commented 5 years ago

Unfortunatly, testing with 6b6f12660e23c217c7f9790f2f023addffc52213 endup into a flow error, as some stuff changed in the repo dependancies :)

enjoy-digital commented 5 years ago

@Dolu1990: i just did the test with the prebuild binaries and rebuilding and both are working here:

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

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

 BIOS built on May 16 2019 21:22:33
 BIOS CRC passed (685c0ba9)

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

--========= Peripherals init ===========--
Initializing SDRAM...
SDRAM now under software control
Read leveling:
m0, b0: |11111000000000000000000000000000| delays: 02+-02
m0, b1: |00000000000011111111000000000000| delays: 16+-04
m0, b2: |00000000000000000000000000001111| delays: 30+-02
m0, b3: |00000000000000000000000000000000| delays: -
m0, b4: |00000000000000000000000000000000| delays: -
m0, b5: |00000000000000000000000000000000| delays: -
m0, b6: |00000000000000000000000000000000| delays: -
m0, b7: |00000000000000000000000000000000| delays: -
best: m0, b1 delays: 16+-04
m1, b0: |11111111100000000000000000000000| delays: 04+-04
m1, b1: |00000000000011111111111000000000| delays: 17+-05
m1, b2: |00000000000000000000000000001111| delays: 30+-02
m1, b3: |00000000000000000000000000000000| delays: -
m1, b4: |00000000000000000000000000000000| delays: -
m1, b5: |00000000000000000000000000000000| delays: -
m1, b6: |00000000000000000000000000000000| delays: -
m1, b7: |00000000000000000000000000000000| delays: -
best: m1, b1 delays: 17+-05
SDRAM now under hardware control
Memtest OK

--========== Boot sequence =============--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Timeout
Loading Image from flash...
Loading rootfs.cpio from flash...
Loading rv32.dtb from flash...
Loading emulator.bin from flash...
Executing booted program at 0x20000000
--============= Liftoff! ===============--
VexRiscv Machine Mode software built May 10 2019 10:54:08
--========== Booting Linux =============--
[    0.000000] No DTB passed to the kernel
[    0.000000] Linux version 5.0.9 (florent@lab) (gcc version 8.3.0 (Buildroot 2019.05-git-00938-g75f9fcd0c9-dirty)) #2 Fri May 10 15:14:31 CEST 2019
[    0.000000] Initial ramdisk at: 0x(ptrval) (8388608 bytes)
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x00000000c0000000-0x00000000c7ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00000000c0000000-0x00000000c7ffffff]
[    0.000000] Initmem setup node 0 [mem 0x00000000c0000000-0x00000000c7ffffff]
[    0.000000] elf_hwcap is 0x1101
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32512
[    0.000000] Kernel command line: mem=128M@0x40000000 rootwait console=hvc0 root=/dev/ram0 init=/sbin/init swiotlb=32
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Sorting __ex_table...
[    0.000000] Memory: 119052K/131072K available (1957K kernel code, 92K rwdata, 317K rodata, 104K init, 184K bss, 12020K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x114c1bade8, max_idle_ns: 440795203839 ns
[    0.000280] sched_clock: 64 bits at 75MHz, resolution 13ns, wraps every 2199023255546ns
[    0.002599] Console: colour dummy device 80x25
[    0.183162] printk: console [hvc0] enabled
[    0.189125] Calibrating delay loop (skipped), value calculated using timer frequency.. 150.00 BogoMIPS (lpj=300000)
[    0.202375] pid_max: default: 32768 minimum: 301
[    0.219334] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.227555] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.295654] devtmpfs: initialized
[    0.341423] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.353723] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.507087] clocksource: Switched to clocksource riscv_clocksource
[    0.838126] Unpacking initramfs...
[    2.596535] Initramfs unpacking failed: junk in compressed archive
[    2.625433] workingset: timestamp_bits=30 max_order=15 bucket_order=0
[    3.017800] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
[    3.026768] io scheduler mq-deadline registered
[    3.032653] io scheduler kyber registered
[    5.120470] random: get_random_bytes called from init_oops_id+0x4c/0x60 with crng_init=0
[    5.162457] Freeing unused kernel memory: 104K
[    5.167914] This architecture does not have kernel memory protection.
[    5.175873] 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... [    8.035845] 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: root

   __   _                                  __   _ __      _  __   _   __         ___  _
  / /  (_)__  __ ____ _________  ___  ____/ /  (_) /____ | |/_/__| | / /____ __ / _ \(_)__ _____  __
 / /__/ / _ \/ // /\ \ /___/ _ \/ _ \/___/ /__/ / __/ -_)>  </___/ |/ / -_) \ // , _/ (_-</ __/ |/ /
/____/_/_//_/\_,_//_\_\    \___/_//_/   /____/_/\__/\__/_/|_|    |___/\__/_\_\/_/|_/_/___/\__/|___/

                32-bits VexRiscv CPU with MMU integrated in a LiteX SoC
login[48]: root login on 'hvc0'
root@buildroot:~# 

If you abort the boot with escape and type the following command, are you able to see the emulator.bin binary:

--============= Console ================--
BIOS> mr 0x50f80000 1024
Memory dump:
0x50f80000  6f 00 00 0b 13 00 00 00 13 00 00 00 13 00 00 00  o...............
0x50f80010  13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00  ................
0x50f80020  23 2e 11 fe 23 2c 51 fe 23 2a 61 fe 23 28 71 fe  #...#,Q.#*a.#(q.
0x50f80030  23 26 a1 fe 23 24 b1 fe 23 22 c1 fe 23 20 d1 fe  #&..#$..#"..# ..
0x50f80040  23 2e e1 fc 23 2c f1 fc 23 2a 01 fd 23 28 11 fd  #...#,..#*..#(..
0x50f80050  23 26 c1 fd 23 24 d1 fd 23 22 e1 fd 23 20 f1 fd  #&..#$..#"..# ..
0x50f80060  13 01 01 fc ef 00 40 09 83 20 c1 03 83 22 81 03  ......@.. ..."..
0x50f80070  03 23 41 03 83 23 01 03 03 25 c1 02 83 25 81 02  .#A..#...%...%..
0x50f80080  03 26 41 02 83 26 01 02 03 27 c1 01 83 27 81 01  .&A..&...'...'..
0x50f80090  03 28 41 01 83 28 01 01 03 2e c1 00 83 2e 81 00  .(A..(..........
0x50f800a0  03 2f 41 00 83 2f 01 00 13 01 01 04 73 00 20 30  ./A../......s. 0
0x50f800b0  17 41 00 00 13 01 01 f5 17 05 00 00 13 05 85 f6  .A..............
0x50f800c0  73 10 55 30 17 25 00 00 13 05 45 2e 97 25 00 00  s.U0.%....E..%..
0x50f800d0  93 85 85 40 63 08 b5 00 23 20 05 00 13 05 45 00  ...@c...# ....E.
0x50f800e0  6f f0 5f ff 37 15 00 00 13 05 05 88 73 10 45 30  o._.7.......s.E0
0x50f800f0  ef 00 c0 61 6f 00 00 00 f3 27 00 fc 73 27 00 bc  ...ao....'..s'..
0x50f80100  b3 77 f7 00 93 f7 17 00 63 84 07 00 6f 00 50 0a  .w......c...o.P.
0x50f80110  67 80 00 00 73 11 01 34 23 22 11 00 23 26 31 00  g...s..4#"..#&1.
0x50f80120  23 28 41 00 23 2a 51 00 23 2c 61 00 23 2e 71 00  #(A.#*Q.#,a.#.q.
0x50f80130  23 20 81 02 23 22 91 02 23 24 a1 02 23 26 b1 02  # ..#"..#$..#&..
0x50f80140  23 28 c1 02 23 2a d1 02 23 2c e1 02 23 2e f1 02  #(..#*..#,..#...
0x50f80150  23 20 01 05 23 22 11 05 23 24 21 05 23 26 31 05  # ..#"..#$!.#&1.
0x50f80160  23 28 41 05 23 2a 51 05 23 2c 61 05 23 2e 71 05  #(A.#*Q.#,a.#.q.
0x50f80170  23 20 81 07 23 22 91 07 23 24 a1 07 23 26 b1 07  # ..#"..#$..#&..
0x50f80180  23 28 c1 07 23 2a d1 07 23 2c e1 07 23 2e f1 07  #(..#*..#,..#...
0x50f80190  ef 00 80 08 83 20 41 00 83 21 c1 00 03 22 01 01  ..... A..!..."..
0x50f801a0  83 22 41 01 03 23 81 01 83 23 c1 01 03 24 01 02  ."A..#...#...$..
0x50f801b0  83 24 41 02 03 25 81 02 83 25 c1 02 03 26 01 03  .$A..%...%...&..
0x50f801c0  83 26 41 03 03 27 81 03 83 27 c1 03 03 28 01 04  .&A..'...'...(..
0x50f801d0  83 28 41 04 03 29 81 04 83 29 c1 04 03 2a 01 05  .(A..)...)...*..
0x50f801e0  83 2a 41 05 03 2b 81 05 83 2b c1 05 03 2c 01 06  .*A..+...+...,..
0x50f801f0  83 2c 41 06 03 2d 81 06 83 2d c1 06 03 2e 01 07  .,A..-...-......
0x50f80200  83 2e 41 07 03 2f 81 07 83 2f c1 07 73 11 01 34  ..A../.../..s..4
0x50f80210  73 00 20 30 67 80 00 00 73 27 20 34 63 5a 07 02  s. 0g...s' 4cZ..
0x50f80220  13 77 f7 0f 93 07 70 00 63 1c f7 00 93 07 00 02  .w....p.c.......
0x50f80230  73 a0 47 14 93 07 00 08 73 b0 47 30 67 80 00 00  s.G.....s.G0g...
0x50f80240  b7 27 00 f0 13 07 10 00 23 a0 e7 00 6f 00 00 00  .'......#...o...
0x50f80250  93 05 20 00 63 0e b7 00 93 07 90 00 63 00 f7 2a  .. .c.......c..*
0x50f80260  b7 27 00 f0 13 07 10 00 23 a0 e7 00 6f 00 00 00  .'......#...o...
0x50f80270  13 01 01 ff 23 26 11 00 23 24 81 00 23 22 91 00  ....#&..#$..#"..
0x50f80280  23 20 21 01 73 29 10 34 f3 25 00 30 73 24 30 34  # !.s).4.%.0s$04
0x50f80290  13 06 f0 02 93 76 f4 07 93 57 c4 00 63 8e c6 00  .....v...W..c...
0x50f802a0  13 06 30 07 63 82 c6 18 b7 27 00 f0 13 07 10 00  ..0.c....'......
0x50f802b0  23 a0 e7 00 6f 00 00 00 93 f7 77 00 63 9e e7 14  #...o.....w.c...
0x50f802c0  93 57 d4 00 37 36 00 20 13 06 46 c5 93 f7 c7 07  .W..76. ..F.....
0x50f802d0  b3 87 c7 00 03 a5 07 00 93 57 24 01 93 f7 c7 07  .........W$.....
0x50f802e0  93 56 b4 01 b3 87 c7 00 13 54 74 00 83 a7 07 00  .V.......Tt.....
0x50f802f0  13 74 f4 01 b7 08 02 00 73 a0 08 30 97 08 00 00  .t......s..0....
0x50f80300  93 88 88 01 73 90 58 30 13 08 10 00 03 27 05 00  ....s.X0.....'..
0x50f80310  13 08 00 00 b7 08 02 00 73 b0 08 30 63 00 08 02  ........s..0c...
0x50f80320  03 24 81 00 83 20 c1 00 83 24 41 00 13 05 09 00  .$... ...$A.....
0x50f80330  03 29 01 00 13 01 01 01 6f 00 40 37 13 08 c0 01  .)......o.@7....
0x50f80340  63 60 d8 0c 37 28 00 20 93 96 26 00 13 08 c8 b7  c`..7(. ..&.....
0x50f80350  b3 86 06 01 83 a6 06 00 67 80 06 00 b3 87 e7 00  ........g.......
0x50f80360  37 08 02 00 73 20 08 30 17 08 00 00 13 08 88 01  7...s .0........
0x50f80370  73 10 58 30 93 06 10 00 23 20 f5 00 93 06 00 00  s.X0....# ......
0x50f80380  37 08 02 00 73 30 08 30 e3 9c 06 f8 13 14 24 00  7...s0.0......$.
0x50f80390  33 04 c4 00 23 20 e4 00 13 09 49 00 73 10 19 34  3...# ....I.s..4
0x50f803a0  b7 07 00 20 93 87 47 11 73 90 57 30 83 20 c1 00  ... ..G.s.W0. ..
0x50f803b0  03 24 81 00 83 24 41 00 03 29 01 00 13 01 01 01  .$...$A..)......
0x50f803c0  67 80 00 00 b3 c7 e7 00 6f f0 9f f9 b3 f7 e7 00  g.......o.......
0x50f803d0  6f f0 1f f9 b3 e7 e7 00 6f f0 9f f8 e3 52 f7 f8  o.......o....R..
0x50f803e0  93 07 07 00 6f f0 df f7 e3 dc e7 f6 6f f0 5f ff  ....o.......o._.
0x50f803f0  e3 78 f7 f6 6f f0 df fe e3 f4 e7 f6 6f f0 5f fe  .x..o.......o._.
BIOS> 
Dolu1990 commented 5 years ago

I tried again with the --flash, and got the same issue, but here we got something interresting :

Memtest OK

--========== Boot sequence =============--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Cancelled

--============= Console ================--
BIOS> mr 0x50f80000 1024   
Memory dump:
0x50f80000  00 0b 13 00 00 00 13 00 00 00 13 00 00 00 13 00  ................
0x50f80010  00 00 13 00 00 00 13 00 00 00 13 00 00 00 23 2e  ..............#.
0x50f80020  11 fe 23 2c 51 fe 23 2a 61 fe 23 28 71 fe 23 26  ..#,Q.#*a.#(q.#&
0x50f80030  a1 fe 23 24 b1 fe 23 22 c1 fe 23 20 d1 fe 23 2e  ..#$..#"..# ..#.
0x50f80040  e1 fc 23 2c f1 fc 23 2a 01 fd 23 28 11 fd 23 26  ..#,..#*..#(..#&
0x50f80050  c1 fd 23 24 d1 fd 23 22 e1 fd 23 20 f1 fd 13 01  ..#$..#"..# ....
0x50f80060  01 fc ef 00 40 09 83 20 c1 03 83 22 81 03 03 23  ....@.. ..."...#
0x50f80070  41 03 83 23 01 03 03 25 c1 02 83 25 81 02 03 26  A..#...%...%...&

All bytes are two bytes off XD

Then i tried with the serial boot, and it worked :D

enjoy-digital commented 5 years ago

@thanks for the test, can you give me the reference of the SPI Flash mounted on your board?

You should get it to work by changing https://github.com/enjoy-digital/linux-on-litex-vexriscv/blob/master/soc_linux.py#L59 to 11 +-4.

Dolu1990 commented 5 years ago

That's it, thanks :D Your fix did it.

It is an Arty A7 revision E (On the bottom of the PCB, on the right of the big Xilinx logo)

The mounted flash is a Spansion FL128SAIF00.

Thanks for the help ^^

enjoy-digital commented 5 years ago

Thanks for the feedback. In the future, we should make this dummy parameter dynamically configurable.