Board:emulation/spike-riscv

From coreboot
Jump to: navigation, search

SPIKE is RISC-V's primary emulator. The Spike support in coreboot is mostly being developed by jn as part of his GSoC 2016.

Build instructions

These instructions may easily become out of date as coreboot or RISC-V moves forward. If that happens, please complain on the discussion page or IRC (or just fix it).

Building the toolchain

Building spike

Building coreboot without a payload

  • run make menuconfig and select Emulation/SPIKE ucb riscv from the Mainboard menu
  • run make
  • run util/riscvtools/make-spike-elf.sh build/coreboot.rom build/coreboot.elf to create an ELF file (spike can only load ELF files)
  • run spike build/coreboot.elf

For general spike usage, look at its GitHub page.

Building Linux

  • git clone https://github.com/riscv/riscv-linux
  • download linux 4.6.x from kernel.org
  • cd linux-4.6.x/arch; ln -s ../../riscv-linux/arch/riscv .
  • make ARCH=riscv defconfig
  • make ARCH=riscv menuconfig, configure General setup/Cross-compiler tool prefix
  • make ARCH=riscv

Building bbl

Using bbl to boot linux will be deprecated. The preferred (but not yet working) way is to directly select linux as a payload.

  • TODO: bbl requires a libc by using autoconf and libc headers. I had to patch around to make it work with the coreboot toolchain.
  • TODO: I had to move the payload section around in the linker script, so that it didn't overwrite something else.
  • TODO: I patched the SBI putchar handler to use my UART
  • mkdir build
  • cd build; ../configure --with-payload=path/to/vmlinux CC=path/to/riscv64-unknown-elf-gcc LD=path/to/riscv64-unknown-elf-ld
  • make

Building coreboot with bbl

  • select Emulation/Spike ucb riscv
  • in the Payload menu of menuconfig, select "ELF Payload" and enter the path to the bbl binary
  • run make and the make-spike-elf.sh script as described above

Boot log

Boot log of coreboot/bbl/linux booting (and then failing because linux can't find any block devices.

we don't have virtual memory...
?

coreboot-4.4-652-gbfb3fee Thu Jun 30 01:03:13 UTC 2016 bootblock starting...
CBFS @ 20100 size 3dff00
CBFS: 'Master Header Locator' located CBFS at [20100:400000)
CBFS: Locating 'fallback/romstage'
CBFS: Checking offset 0
CBFS: File @ offset 0 size 20
CBFS:  Unmatched 'cbfs master header' at 0
CBFS: Checking offset 80
CBFS: File @ offset 80 size 2d17
CBFS: Found @ offset 80 size 2d17
?

coreboot-4.4-652-gbfb3fee Thu Jun 30 01:03:13 UTC 2016 romstage starting...
CBFS @ 20100 size 3dff00
CBFS: 'Master Header Locator' located CBFS at [20100:400000)
CBFS: Locating 'fallback/ramstage'
CBFS: Checking offset 0
CBFS: File @ offset 0 size 20
CBFS:  Unmatched 'cbfs master header' at 0
CBFS: Checking offset 80
CBFS: File @ offset 80 size 2d17
CBFS:  Unmatched 'fallback/romstage' at 80
CBFS: Checking offset 2e00
CBFS: File @ offset 2e00 size 4ed7
CBFS: Found @ offset 2e00 size 4ed7
?

coreboot-4.4-652-gbfb3fee Thu Jun 30 01:03:13 UTC 2016 ramstage starting...
Enumerating buses...
Show all devs... Before device enumeration.
Root Device: enabled 1
CPU_CLUSTER: 0: enabled 1
I2C: 00:06: enabled 1
Compare with tree...
Root Device: enabled 1
 CPU_CLUSTER: 0: enabled 1
 I2C: 00:06: enabled 1
memalign Enter, boundary 8, size 3584, free_mem_ptr 0000000080840c18
memalign 0000000080840c18
CBMEM:
IMD: root @ 00000000bffff000 254 entries.
IMD: root @ 00000000bfffec00 62 entries.
Root Device scanning...
root_dev_scan_bus for Root Device
CPU_CLUSTER: 0 enabled
I2C: 00:06 enabled
root_dev_scan_bus for Root Device done
scan_bus: scanning of bus Root Device took 0 usecs
done
Allocating resources...
Reading resources...
Root Device read_resources bus 0 link: 0
CPU_CLUSTER: 0 missing read_resources
I2C: 00:06 missing read_resources
Root Device read_resources bus 0 link: 0 done
Done reading resources.
Show resources in subtree (Root Device)...After reading.
 Root Device child on link 0 CPU_CLUSTER: 0
 Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  CPU_CLUSTER: 0
  I2C: 00:06
Setting resources...
Root Device assign_resources, bus 0 link: 0
Root Device assign_resources, bus 0 link: 0
Done setting resources.
Show resources in subtree (Root Device)...After assigning values.
 Root Device child on link 0 CPU_CLUSTER: 0
 Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  CPU_CLUSTER: 0
  I2C: 00:06
Done allocating resources.
Enabling resources...
done.
Initializing devices...
Root Device init ...
Devices initialized
Show all devs... After init.
Root Device: enabled 1
CPU_CLUSTER: 0: enabled 1
I2C: 00:06: enabled 1
Finalize devices...
Devices finalized
Writing coreboot table at 0xbffdc000
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841a18
memalign 0000000080841a18
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841a38
memalign 0000000080841a38
 0. 0000000080000000-00000000bffdbfff: RAM
 1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
CBFS @ 20100 size 3dff00
CBFS: 'Master Header Locator' located CBFS at [20100:400000)
FMAP: Found "FLASH" version 1.1 at 20000.
FMAP: base = 0 size = 400000 #areas = 4
Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum f468
coreboot table: 360 bytes.
IMD ROOT    0. 00000000bffff000 00001000
IMD SMALL   1. 00000000bfffe000 00001000
CONSOLE     2. 00000000bffde000 00020000
COREBOOT    3. 00000000bffdc000 00002000
IMD small region:
  IMD ROOT    0. 00000000bfffec00 00000400
CBFS @ 20100 size 3dff00
CBFS: 'Master Header Locator' located CBFS at [20100:400000)
CBFS: Locating 'fallback/payload'
CBFS: Checking offset 0
CBFS: File @ offset 0 size 20
CBFS:  Unmatched 'cbfs master header' at 0
CBFS: Checking offset 80
CBFS: File @ offset 80 size 2d17
CBFS:  Unmatched 'fallback/romstage' at 80
CBFS: Checking offset 2e00
CBFS: File @ offset 2e00 size 4ed7
CBFS:  Unmatched 'fallback/ramstage' at 2e00
CBFS: Checking offset 7d40
CBFS: File @ offset 7d40 size 114
CBFS:  Unmatched 'config' at 7d40
CBFS: Checking offset 7ec0
CBFS: File @ offset 7ec0 size 239
CBFS:  Unmatched 'revision' at 7ec0
CBFS: Checking offset 8140
CBFS: File @ offset 8140 size 120258
CBFS: Found @ offset 8140 size 120258
Loading segment from rom address 0x0000000080028278
  code (compression=1)
memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841a58
memalign 0000000080841a58
  New segment dstaddr 0x80000000 memsize 0x7e40 srcaddr 0x800282e8 filesize 0x3525
Loading segment from rom address 0x0000000080028294
  code (compression=1)
memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841a90
memalign 0000000080841a90
  New segment dstaddr 0x80008000 memsize 0x1000 srcaddr 0x8002b80d filesize 0x86
Loading segment from rom address 0x00000000800282b0
  data (compression=1)
memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841ac8
memalign 0000000080841ac8
  New segment dstaddr 0x81000000 memsize 0x3314c8 srcaddr 0x8002b893 filesize 0x11cc3d
Loading segment from rom address 0x00000000800282cc
  Entry Point 0x0000000080000000
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b00
memalign 0000000080841b00
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b20
memalign 0000000080841b20
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b40
memalign 0000000080841b40
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b60
memalign 0000000080841b60
Bounce Buffer at 00000000bffb6000, 153648 bytes
Loading Segment: addr: 0x0000000080000000 memsz: 0x0000000000007e40 filesz: 0x0000000000003525
lb: [0x0000000080832000, 0x0000000080844c18)
Post relocation: addr: 0x0000000080000000 memsz: 0x0000000000007e40 filesz: 0x0000000000003525
using LZMA
[ 0x80000000, 80007d7c, 0x80007e40) <- 800282e8
Clearing Segment: addr: 0x0000000080007d7c memsz: 0x00000000000000c4
dest 0000000080000000, end 0000000080007e40, bouncebuffer bffb6000
Loading Segment: addr: 0x0000000080008000 memsz: 0x0000000000001000 filesz: 0x0000000000000086
lb: [0x0000000080832000, 0x0000000080844c18)
Post relocation: addr: 0x0000000080008000 memsz: 0x0000000000001000 filesz: 0x0000000000000086
using LZMA
[ 0x80008000, 80009000, 0x80009000) <- 8002b80d
dest 0000000080008000, end 0000000080009000, bouncebuffer bffb6000
Loading Segment: addr: 0x0000000081000000 memsz: 0x00000000003314c8 filesz: 0x000000000011cc3d
lb: [0x0000000080832000, 0x0000000080844c18)
Post relocation: addr: 0x0000000081000000 memsz: 0x00000000003314c8 filesz: 0x000000000011cc3d
using LZMA
[ 0x81000000, 813314c8, 0x813314c8) <- 8002b893
dest 0000000081000000, end 00000000813314c8, bouncebuffer bffb6000
Loaded segments
Jumping to boot code at 0000000080000000(00000000bffdc000)
CPU0: stack: 0000000080800000 - 0000000080810000, lowest used address 0000000080800004, stack used: 65532 bytes
handle_command([255,255,80203a00])
              vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
                  vvvvvvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrr       vvvvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv  
rrrrrrrrrrrrr       vvvvvvvvvvvvvvvvvvvvvv    
rr                vvvvvvvvvvvvvvvvvvvvvv      
rr            vvvvvvvvvvvvvvvvvvvvvvvv      rr
rrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv      rrrr
rrrrrr      vvvvvvvvvvvvvvvvvvvvvv      rrrrrr
rrrrrrrr      vvvvvvvvvvvvvvvvvv      rrrrrrrr
rrrrrrrrrr      vvvvvvvvvvvvvv      rrrrrrrrrr
rrrrrrrrrrrr      vvvvvvvvvv      rrrrrrrrrrrr
rrrrrrrrrrrrrr      vvvvvv      rrrrrrrrrrrrrr
rrrrrrrrrrrrrrrr      vv      rrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrr          rrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrr      rrrrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrrrr  rrrrrrrrrrrrrrrrrrrrrr

       INSTRUCTION SETS WANT TO BE FREE
[    0.000000] Linux version 4.6.3 (jn@latitude) (gcc version 6.1.0 (coreboot toolchain v1.40 May 4th, 2016) ) #1 Sun Jun 26 02:48:43 CEST 2016
[    0.000000] Available physical memory: 2044MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000080200000-0x00000000ffdfffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080200000-0x00000000ffdfffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000ffdfffff]
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 516110
[    0.000000] Kernel command line: 
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
[    0.000000] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.000000] Sorting __ex_table...
[    0.000000] Memory: 2058448K/2093056K available (1952K kernel code, 104K rwdata, 396K rodata, 64K init, 221K bss, 34608K reserved, 0K dma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:0 nr_irqs:0 0
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 191126044627 ns
[    0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=100000)
[    0.000000] pid_max: default: 32768 minimum: 301
[    0.000000] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] devtmpfs: initialized
[    0.000000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.000000] NET: Registered protocol family 16
[    0.000000] clocksource: Switched to clocksource riscv_clocksource
[    0.000000] NET: Registered protocol family 2
[    0.000000] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[    0.000000] TCP bind hash table entries: 16384 (order: 5, 131072 bytes)
[    0.000000] TCP: Hash tables configured (established 16384 bind 16384)
[    0.000000] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[    0.000000] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[    0.000000] NET: Registered protocol family 1
[    0.010000] console [sbi_console0] enabled
[    0.010000] futex hash table entries: 256 (order: 0, 6144 bytes)
[    0.010000] workingset: timestamp_bits=61 max_order=19 bucket_order=0
[    0.020000] jitterentropy: Initialization failed with host not compliant with requirements: 2
[    0.020000] io scheduler noop registered
[    0.020000] io scheduler cfq registered (default)
[    0.020000] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    0.020000] Please append a correct "root=" boot option; here are the available partitions:
[    0.020000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    0.020000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.6.3 #1
[    0.020000] Call Trace:
[    0.020000] [<ffffffff80011f5c>] walk_stackframe+0x0/0xc8
[    0.020000] [<ffffffff80053a00>] panic+0xe0/0x1f4
[    0.020000] [<ffffffff8000115c>] mount_block_root+0x234/0x310
[    0.020000] [<ffffffff800013f0>] prepare_namespace+0x138/0x188
[    0.020000] [<ffffffff80000d48>] kernel_init_freeable+0x1b0/0x1e8
[    0.020000] [<ffffffff801f41ac>] rest_init+0x7c/0x80
[    0.020000] [<ffffffff801f41c0>] kernel_init+0x10/0x110
[    0.020000] [<ffffffff801f41ac>] rest_init+0x7c/0x80
[    0.020000] [<ffffffff80010bdc>] ret_from_syscall+0x10/0x14
[    0.020000] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)