Board:emulation/spike-riscv: Difference between revisions

From coreboot
Jump to navigation Jump to search
(Replace the boot log with a newer one.)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
[https://riscv.org/software-tools/risc-v-isa-simulator/ SPIKE] is [https://riscv.org/ RISC-V]'s primary emulator. The Spike support in coreboot is mostly being developed by [[User:Jn|jn]] as part of his GSoC 2016.
[https://riscv.org/software-tools/risc-v-isa-simulator/ SPIKE] is [https://riscv.org/ RISC-V]'s primary emulator. The Spike support in coreboot is maintained by Ron Minnich and [[User:Jn|jn]].


=Build instructions=
=Build instructions=


These instructions may easily become out of date as coreboot or RISC-V moves forward. If that happens, please complain on the [[Talk:Board:emulation/spike-riscv|discussion page]] or IRC (or just fix it).
These instructions may easily become out of date as coreboot or RISC-V moves forward. If that happens, please complain on the [[Talk:Board:emulation/spike-riscv|discussion page]] or IRC (or just fix it).
The instructions are also not yet complete.


==Building the toolchain==
==Building the toolchain==
Line 11: Line 9:
* clone the coreboot git repository
* clone the coreboot git repository
* download and apply the following patches:
* download and apply the following patches:
** [https://review.coreboot.org/#/c/14604/ 14604: xcompile: rename riscv to riscv64]
** [https://review.coreboot.org/#/c/14604/11 14604: buildgcc: Update to GCC 6.1.0, and binutils riscv update (version 11)].
** [https://review.coreboot.org/#/c/14257/ 14257: buildgcc: Update to GCC 6.1.0, and binutils riscv update].
* run <code>make crossgcc-riscv</code> and a have a cup of $BEVERAGE
* run <code>make crossgcc-riscv</code> and a have a cup of $BEVERAGE


Line 20: Line 17:
* download and apply [https://github.com/neuschaefer/riscv-isa-sim/commit/664118976cd487c9dec8cc6b5b3b9d52bd3f861c this patch that implements an 8250 UART]
* download and apply [https://github.com/neuschaefer/riscv-isa-sim/commit/664118976cd487c9dec8cc6b5b3b9d52bd3f861c this patch that implements an 8250 UART]
* TODO: fesvr: patch device_list_t::handle_command to ignore HTIF writes
* TODO: fesvr: patch device_list_t::handle_command to ignore HTIF writes
* TODO: running make
* Edit riscv/processor.cc, processor_t::get_csr(), and add "case CSR_TIME: return 0;"
 
* run make
==Building coreboot without a payload==
 
* You need the following patches:
** [https://review.coreboot.org/#/c/15290/ 15290: change all eret instructions to mret]
** [https://review.coreboot.org/#/c/15289/ 15289: Remove HTIF and SBI related code]
** [https://review.coreboot.org/#/c/15288/ 15288: Provide a tohost symbol so Spike doesn't hang]
** [https://review.coreboot.org/#/c/15284/ 15284: Move CBMEM into RAM]
* run <code>make menuconfig</code> and select <tt>Emulation</tt>/<tt>SPIKE ucb riscv</tt> from the Mainboard menu
* run <code>make</code>
* run <code>util/riscvtools/make-spike-elf.sh build/coreboot.rom build/coreboot.elf</code> to create an ELF file (spike can only load ELF files)
* run <code>spike build/coreboot.elf</code>
 
For general spike usage, look at [https://github.com/riscv/riscv-isa-sim/ its GitHub page].


==Building Linux==
==Building Linux==
Line 45: Line 29:
* <code>make ARCH=riscv</code>
* <code>make ARCH=riscv</code>


==Building bbl==
==Building coreboot==
 
* TODO: libc stuff
* TODO: payload linker script foo
* TODO: patching the console output handler
* 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==
* apply the same coreboot patches as above
* you need these additional patches:
** [https://review.coreboot.org/#/c/15510| 15510: arch/riscv: Make SBI support optional]
** [https://review.coreboot.org/#/c/15511| 15511: spike-riscv: Register RAM resource at 0x80000000]
* select <tt>Emulation</tt>/<tt>Spike ucb riscv</tt>
* select <tt>Emulation</tt>/<tt>Spike ucb riscv</tt>
* deselect "<tt>Run payload in S-mode and provide SBI</tt>" in the <tt>Payload</tt> menu
* in the Payload menu of <code>menuconfig</code>, select "ELF Payload" and enter the path to the vmlinux binary
* in the Payload menu of <code>menuconfig</code>, select "ELF Payload" and enter the path to the bbl binary
* run <code>make</code> and the <code>make-spike-elf.sh</code> script as described above
* run <code>make</code> and the <code>make-spike-elf.sh</code> script as described above
For general spike usage, look at [https://github.com/riscv/riscv-isa-sim/ its GitHub page].


=Boot log=
=Boot log=


Boot log of coreboot/bbl/linux booting (and then failing because linux can't find any block devices.
Boot log of coreboot/linux booting. I included bash in the initrd.


  we don't have virtual memory...
 
?
   
   
  coreboot-4.4-652-gbfb3fee Thu Jun 30 01:03:13 UTC 2016 bootblock starting...
  coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 bootblock starting...
  CBFS @ 20100 size 3dff00
  CBFS @ 20100 size 7dff00
  CBFS: 'Master Header Locator' located CBFS at [20100:400000)
  CBFS: 'Master Header Locator' located CBFS at [20100:800000)
  CBFS: Locating 'fallback/romstage'
  CBFS: Locating 'fallback/romstage'
CBFS: Checking offset 0
  CBFS: Found @ offset 80 size 3013
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...
  coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 romstage starting...
  CBFS @ 20100 size 3dff00
0x40000000 bytes of memory at 0x80000000
  CBFS: 'Master Header Locator' located CBFS at [20100:400000)
  CBFS @ 20100 size 7dff00
  CBFS: 'Master Header Locator' located CBFS at [20100:800000)
  CBFS: Locating 'fallback/ramstage'
  CBFS: Locating 'fallback/ramstage'
CBFS: Checking offset 0
  CBFS: Found @ offset 3100 size 5403
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...
  coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 ramstage starting...
BS: Entering BS_PRE_DEVICE state.
BS: Exiting BS_PRE_DEVICE state.
----------------------------------------
BS: Entering BS_DEV_INIT_CHIPS state.
BS: Exiting BS_DEV_INIT_CHIPS state.
----------------------------------------
BS: Entering BS_DEV_ENUMERATE state.
  Enumerating buses...
  Enumerating buses...
  Show all devs... Before device enumeration.
  Show all devs... Before device enumeration.
Line 109: Line 75:
   CPU_CLUSTER: 0: enabled 1
   CPU_CLUSTER: 0: enabled 1
   I2C: 00:06: enabled 1
   I2C: 00:06: enabled 1
memalign Enter, boundary 8, size 3584, free_mem_ptr 0000000080840c18
memalign 0000000080840c18
  CBMEM:
  CBMEM:
  IMD: root @ 00000000bffff000 254 entries.
  IMD: root @ 00000000bffff000 254 entries.
Line 121: Line 85:
  scan_bus: scanning of bus Root Device took 0 usecs
  scan_bus: scanning of bus Root Device took 0 usecs
  done
  done
BS: Exiting BS_DEV_ENUMERATE state.
----------------------------------------
BS: Entering BS_DEV_RESOURCES state.
  Allocating resources...
  Allocating resources...
  Reading resources...
  Reading resources...
Line 143: Line 110:
   I2C: 00:06
   I2C: 00:06
  Done allocating resources.
  Done allocating resources.
BS: Exiting BS_DEV_RESOURCES state.
----------------------------------------
BS: Entering BS_DEV_ENABLE state.
  Enabling resources...
  Enabling resources...
  done.
  done.
BS: Exiting BS_DEV_ENABLE state.
----------------------------------------
BS: Entering BS_DEV_INIT state.
  Initializing devices...
  Initializing devices...
  Root Device init ...
  Root Device init ...
Line 152: Line 125:
  CPU_CLUSTER: 0: enabled 1
  CPU_CLUSTER: 0: enabled 1
  I2C: 00:06: enabled 1
  I2C: 00:06: enabled 1
BS: Exiting BS_DEV_INIT state.
BS: callback (000000008083e308) @ src/vboot/bootmode.c:68.
----------------------------------------
BS: Entering BS_POST_DEVICE state.
  Finalize devices...
  Finalize devices...
  Devices finalized
  Devices finalized
BS: Exiting BS_POST_DEVICE state.
----------------------------------------
BS: Entering BS_OS_RESUME_CHECK state.
BS: Exiting BS_OS_RESUME_CHECK state.
----------------------------------------
BS: Entering BS_WRITE_TABLES state.
  Writing coreboot table at 0xbffdc000
  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
   0. 0000000080000000-00000000bffdbfff: RAM
   1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
   1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
  CBFS @ 20100 size 3dff00
  CBFS @ 20100 size 7dff00
  CBFS: 'Master Header Locator' located CBFS at [20100:400000)
  CBFS: 'Master Header Locator' located CBFS at [20100:800000)
  FMAP: Found "FLASH" version 1.1 at 20000.
  FMAP: Found "FLASH" version 1.1 at 20000.
  FMAP: base = 0 size = 400000 #areas = 4
  FMAP: base = 0 size = 800000 #areas = 4
  Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum f468
  Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum d4c8
  coreboot table: 360 bytes.
  coreboot table: 360 bytes.
  IMD ROOT    0. 00000000bffff000 00001000
  IMD ROOT    0. 00000000bffff000 00001000
Line 173: Line 152:
  IMD small region:
  IMD small region:
   IMD ROOT    0. 00000000bfffec00 00000400
   IMD ROOT    0. 00000000bfffec00 00000400
  CBFS @ 20100 size 3dff00
BS: Exiting BS_WRITE_TABLES state.
  CBFS: 'Master Header Locator' located CBFS at [20100:400000)
----------------------------------------
BS: Entering BS_PAYLOAD_LOAD state.
  CBFS @ 20100 size 7dff00
  CBFS: 'Master Header Locator' located CBFS at [20100:800000)
  CBFS: Locating 'fallback/payload'
  CBFS: Locating 'fallback/payload'
CBFS: Checking offset 0
  CBFS: Found @ offset 8900 size 34081c
CBFS: File @ offset 0 size 20
  Loading segment from ROM address 0x0000000080028a38
CBFS:  Unmatched 'cbfs master header' at 0
   code (compression=0)
CBFS: Checking offset 80
   New segment dstaddr 0x81000000 memsize 0x300000 srcaddr 0x80028a8c filesize 0x2ffa78
CBFS: File @ offset 80 size 2d17
  Loading segment from ROM address 0x0000000080028a54
CBFS:  Unmatched 'fallback/romstage' at 80
   data (compression=0)
CBFS: Checking offset 2e00
   New segment dstaddr 0x81300000 memsize 0x40d50 srcaddr 0x80328504 filesize 0x40d50
CBFS: File @ offset 2e00 size 4ed7
  Loading segment from ROM address 0x0000000080028a70
CBFS:  Unmatched 'fallback/ramstage' at 2e00
   Entry Point 0xffffffff81000000
CBFS: Checking offset 7d40
  Loading Segment: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
CBFS: File @ offset 7d40 size 114
  lb: [0x0000000080832000, 0x0000000080847170)
CBFS:  Unmatched 'config' at 7d40
  Post relocation: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
CBFS: Checking offset 7ec0
  it's not compressed!
CBFS: File @ offset 7ec0 size 239
  [ 0x81000000, 812ffa78, 0x81300000) <- 80028a8c
CBFS:  Unmatched 'revision' at 7ec0
  Clearing Segment: addr: 0x00000000812ffa78 memsz: 0x0000000000000588
CBFS: Checking offset 8140
  dest 0000000081000000, end 0000000081300000, bouncebuffer ffffffffffffffff
CBFS: File @ offset 8140 size 120258
  Loading Segment: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
  CBFS: Found @ offset 8140 size 120258
  lb: [0x0000000080832000, 0x0000000080847170)
  Loading segment from rom address 0x0000000080028278
  Post relocation: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
   code (compression=1)
  it's not compressed!
memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841a58
  [ 0x81300000, 81340d50, 0x81340d50) <- 80328504
memalign 0000000080841a58
  dest 0000000081300000, end 0000000081340d50, bouncebuffer ffffffffffffffff
   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
  Loaded segments
  Jumping to boot code at 0000000080000000(00000000bffdc000)
BS: Exiting BS_PAYLOAD_LOAD state.
  CPU0: stack: 0000000080800000 - 0000000080810000, lowest used address 0000000080800004, stack used: 65532 bytes
----------------------------------------
  handle_command([255,255,80203a00])
BS: Entering BS_PAYLOAD_BOOT state.
              vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  Jumping to boot code at ffffffff81000000(00000000bffdc000)
                  vvvvvvvvvvvvvvvvvvvvvvvvvvvv
  Stack overrun on CPU0 (address 0000000080800000 overwritten). Increase stack from current 4096 bytes
  rrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv
  ERROR: BUG ENCOUNTERED at file 'src/lib/stack.c', line 40
  rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvv
Config string: 'platform {
rrrrrrrrrrrrrrrrrr   vvvvvvvvvvvvvvvvvvvvvvvv
  vendor ucb;
  rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
  arch spike;
  rrrrrrrrrrrrrrrrrr   vvvvvvvvvvvvvvvvvvvvvvvv
  };
  rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv  
  rtc {
rrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv    
   addr 0x40000000;
rr                vvvvvvvvvvvvvvvvvvvvvv      
  };
rr            vvvvvvvvvvvvvvvvvvvvvvvv     rr
  uart {
  rrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv      rrrr
   addr 0x40001000;
  rrrrrr     vvvvvvvvvvvvvvvvvvvvvv     rrrrrr
  };
  rrrrrrrr      vvvvvvvvvvvvvvvvvv      rrrrrrrr
  ram {
  rrrrrrrrrr      vvvvvvvvvvvvvv      rrrrrrrrrr
   0 {
  rrrrrrrrrrrr      vvvvvvvvvv      rrrrrrrrrrrr
     addr 0x80000000;
  rrrrrrrrrrrrrr      vvvvvv      rrrrrrrrrrrrrr
     size 0x40000000;
  rrrrrrrrrrrrrrrr      vv      rrrrrrrrrrrrrrrr
  };
  rrrrrrrrrrrrrrrrrr          rrrrrrrrrrrrrrrrrr
  };
  rrrrrrrrrrrrrrrrrrrr      rrrrrrrrrrrrrrrrrrrr
  core {
  rrrrrrrrrrrrrrrrrrrrrr  rrrrrrrrrrrrrrrrrrrrrr
  0 {
   
     0 {
        INSTRUCTION SETS WANT TO BE FREE
      isa rv64imafdc;
  [    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
      timecmp 0x40000008;
  [    0.000000] Available physical memory: 2044MB
      ipi 0x40002000;
     };
  };
  };
  '
  -----------------------------
  Virtual memory status enabled
  -----------------------------
  Initializing virtual memory...
  Finished initializing virtual memory
  OK, let's go
  Getting hart id...
  [    0.000000] Linux version 4.6.3-riscv-g1ef29a9 (jn@latitude) (gcc version 6.1.0 (coreboot toolchain v1.44 October 3nd, 2016) ) #144 Fri Nov 25 02:18:13 CET 2016
[    0.000000] bootconsole [early0] enabled
Querying memory, CPU #0...
  [    0.000000] Available physical memory: 1008MB
[    0.000000] Initial ramdisk at: 0xffffffff81013758 (1415600 bytes)
  [    0.000000] Zone ranges:
  [    0.000000] Zone ranges:
  [    0.000000]  Normal  [mem 0x0000000080200000-0x00000000ffdfffff]
  [    0.000000]  Normal  [mem 0x0000000081000000-0x00000000bfffffff]
  [    0.000000] Movable zone start for each node
  [    0.000000] Movable zone start for each node
  [    0.000000] Early memory node ranges
  [    0.000000] Early memory node ranges
  [    0.000000]  node  0: [mem 0x0000000080200000-0x00000000ffdfffff]
  [    0.000000]  node  0: [mem 0x0000000081000000-0x00000000bfffffff]
  [    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000ffdfffff]
  [    0.000000] Initmem setup node 0 [mem 0x0000000081000000-0x00000000bfffffff]
  [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 516110
  [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 254520
  [    0.000000] Kernel command line:  
  [    0.000000] Kernel command line: earlyprintk=sbi_console0 keep init=/bin/sh
  [    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
  [    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] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
  [    0.000000] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
  [    0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
  [    0.000000] Sorting __ex_table...
  [    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] Memory: 1013124K/1032192K available (1317K kernel code, 77K rwdata, 288K rodata, 1464K init, 180K bss, 19068K reserved, 0K cma-reserved)
  [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
  [    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] NR_IRQS:0 nr_irqs:0 0
  [    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 191126044627 ns
  [    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446 ns
  [    0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=100000)
Setting timer to 0000000000989680 (current time is 0000000000000000)...
mcall_set_timer is currently not implemented, ignoring
  [    0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 2000.00 BogoMIPS (lpj=10000000)
  [    0.000000] pid_max: default: 32768 minimum: 301
  [    0.000000] pid_max: default: 32768 minimum: 301
  [    0.000000] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)
  [    0.000000] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes)
  [    0.000000] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes)
  [    0.000000] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes)
  [    0.000000] devtmpfs: initialized
  [    0.000000] devtmpfs: initialized
  [    0.000000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
  [    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] clocksource: Switched to clocksource riscv_clocksource
  [    0.000000] NET: Registered protocol family 2
  [    0.000000] Trying to unpack rootfs image as initramfs...
  [    0.000000] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
  [    0.000000] console [sbi_console0] enabled
[   0.000000] TCP bind hash table entries: 16384 (order: 5, 131072 bytes)
  [    0.000000] console [sbi_console0] enabled
  [    0.000000] TCP: Hash tables configured (established 16384 bind 16384)
  [    0.000000] bootconsole [early0] disabled
[   0.000000] UDP hash table entries: 1024 (order: 3, 32768 bytes)
  [    0.000000] bootconsole [early0] disabled
  [    0.000000] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
  [    0.000000] futex hash table entries: 256 (order: 0, 6144 bytes)
[   0.000000] NET: Registered protocol family 1
  [    0.000000] io scheduler noop registered
  [    0.010000] console [sbi_console0] enabled
  [    0.000000] io scheduler cfq registered (default)
  [    0.010000] futex hash table entries: 256 (order: 0, 6144 bytes)
  [    0.000000] brd: module loaded
  [    0.010000] workingset: timestamp_bits=61 max_order=19 bucket_order=0
  [    0.000000] Freeing unused kernel memory: 1464K (ffffffff81000000 - ffffffff8116e000)
[    0.020000] jitterentropy: Initialization failed with host not compliant with requirements: 2
  [    0.000000] This architecture does not have kernel memory protection.
[    0.020000] io scheduler noop registered
  init: cannot set terminal process group (-1): Inappropriate ioctl for device
  [    0.020000] io scheduler cfq registered (default)
  init: no job control in this shell
  [    0.020000] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
  init-4.3#
  [    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)

Latest revision as of 01:33, 25 November 2016

SPIKE is RISC-V's primary emulator. The Spike support in coreboot is maintained by Ron Minnich and jn.

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 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 coreboot

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

For general spike usage, look at its GitHub page.

Boot log

Boot log of coreboot/linux booting. I included bash in the initrd.

�

coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 bootblock starting...
CBFS @ 20100 size 7dff00
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
CBFS: Locating 'fallback/romstage'
CBFS: Found @ offset 80 size 3013
�

coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 romstage starting...
0x40000000 bytes of memory at 0x80000000
CBFS @ 20100 size 7dff00
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
CBFS: Locating 'fallback/ramstage'
CBFS: Found @ offset 3100 size 5403
�

coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 ramstage starting...
BS: Entering BS_PRE_DEVICE state.
BS: Exiting BS_PRE_DEVICE state.
----------------------------------------
BS: Entering BS_DEV_INIT_CHIPS state.
BS: Exiting BS_DEV_INIT_CHIPS state.
----------------------------------------
BS: Entering BS_DEV_ENUMERATE state.
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
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
BS: Exiting BS_DEV_ENUMERATE state.
----------------------------------------
BS: Entering BS_DEV_RESOURCES state.
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.
BS: Exiting BS_DEV_RESOURCES state.
----------------------------------------
BS: Entering BS_DEV_ENABLE state.
Enabling resources...
done.
BS: Exiting BS_DEV_ENABLE state.
----------------------------------------
BS: Entering BS_DEV_INIT state.
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
BS: Exiting BS_DEV_INIT state.
BS: callback (000000008083e308) @ src/vboot/bootmode.c:68.
----------------------------------------
BS: Entering BS_POST_DEVICE state.
Finalize devices...
Devices finalized
BS: Exiting BS_POST_DEVICE state.
----------------------------------------
BS: Entering BS_OS_RESUME_CHECK state.
BS: Exiting BS_OS_RESUME_CHECK state.
----------------------------------------
BS: Entering BS_WRITE_TABLES state.
Writing coreboot table at 0xbffdc000
 0. 0000000080000000-00000000bffdbfff: RAM
 1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
CBFS @ 20100 size 7dff00
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
FMAP: Found "FLASH" version 1.1 at 20000.
FMAP: base = 0 size = 800000 #areas = 4
Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum d4c8
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
BS: Exiting BS_WRITE_TABLES state.
----------------------------------------
BS: Entering BS_PAYLOAD_LOAD state.
CBFS @ 20100 size 7dff00
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
CBFS: Locating 'fallback/payload'
CBFS: Found @ offset 8900 size 34081c
Loading segment from ROM address 0x0000000080028a38
  code (compression=0)
  New segment dstaddr 0x81000000 memsize 0x300000 srcaddr 0x80028a8c filesize 0x2ffa78
Loading segment from ROM address 0x0000000080028a54
  data (compression=0)
  New segment dstaddr 0x81300000 memsize 0x40d50 srcaddr 0x80328504 filesize 0x40d50
Loading segment from ROM address 0x0000000080028a70
  Entry Point 0xffffffff81000000
Loading Segment: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
lb: [0x0000000080832000, 0x0000000080847170)
Post relocation: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
it's not compressed!
[ 0x81000000, 812ffa78, 0x81300000) <- 80028a8c
Clearing Segment: addr: 0x00000000812ffa78 memsz: 0x0000000000000588
dest 0000000081000000, end 0000000081300000, bouncebuffer ffffffffffffffff
Loading Segment: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
lb: [0x0000000080832000, 0x0000000080847170)
Post relocation: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
it's not compressed!
[ 0x81300000, 81340d50, 0x81340d50) <- 80328504
dest 0000000081300000, end 0000000081340d50, bouncebuffer ffffffffffffffff
Loaded segments
BS: Exiting BS_PAYLOAD_LOAD state.
----------------------------------------
BS: Entering BS_PAYLOAD_BOOT state.
Jumping to boot code at ffffffff81000000(00000000bffdc000)
Stack overrun on CPU0 (address 0000000080800000 overwritten). Increase stack from current 4096 bytes
ERROR: BUG ENCOUNTERED at file 'src/lib/stack.c', line 40
Config string: 'platform {
  vendor ucb;
  arch spike;
};
rtc {
  addr 0x40000000;
};
uart {
  addr 0x40001000;
};
ram {
  0 {
    addr 0x80000000;
    size 0x40000000;
  };
};
core {
  0 {
    0 {
      isa rv64imafdc;
      timecmp 0x40000008;
      ipi 0x40002000;
    };
  };
};
'
-----------------------------
Virtual memory status enabled
-----------------------------
Initializing virtual memory...
Finished initializing virtual memory
OK, let's go
Getting hart id...
[    0.000000] Linux version 4.6.3-riscv-g1ef29a9 (jn@latitude) (gcc version 6.1.0 (coreboot toolchain v1.44 October 3nd, 2016) ) #144 Fri Nov 25 02:18:13 CET 2016
[    0.000000] bootconsole [early0] enabled
Querying memory, CPU #0...
[    0.000000] Available physical memory: 1008MB
[    0.000000] Initial ramdisk at: 0xffffffff81013758 (1415600 bytes)
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000081000000-0x00000000bfffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000081000000-0x00000000bfffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000081000000-0x00000000bfffffff]
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 254520
[    0.000000] Kernel command line: earlyprintk=sbi_console0 keep init=/bin/sh
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
[    0.000000] Sorting __ex_table...
[    0.000000] Memory: 1013124K/1032192K available (1317K kernel code, 77K rwdata, 288K rodata, 1464K init, 180K bss, 19068K 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 0
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446 ns
Setting timer to 0000000000989680 (current time is 0000000000000000)...
mcall_set_timer is currently not implemented, ignoring
[    0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 2000.00 BogoMIPS (lpj=10000000)
[    0.000000] pid_max: default: 32768 minimum: 301
[    0.000000] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes)
[    0.000000] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes)
[    0.000000] devtmpfs: initialized
[    0.000000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.000000] clocksource: Switched to clocksource riscv_clocksource
[    0.000000] Trying to unpack rootfs image as initramfs...
[    0.000000] console [sbi_console0] enabled
[    0.000000] console [sbi_console0] enabled
[    0.000000] bootconsole [early0] disabled
[    0.000000] bootconsole [early0] disabled
[    0.000000] futex hash table entries: 256 (order: 0, 6144 bytes)
[    0.000000] io scheduler noop registered
[    0.000000] io scheduler cfq registered (default)
[    0.000000] brd: module loaded
[    0.000000] Freeing unused kernel memory: 1464K (ffffffff81000000 - ffffffff8116e000)
[    0.000000] This architecture does not have kernel memory protection.
init: cannot set terminal process group (-1): Inappropriate ioctl for device
init: no job control in this shell
init-4.3#