Board:emulation/spike-riscv: Difference between revisions

From coreboot
Jump to navigation Jump to search
(fix boot log)
(Replace the boot log with a newer one.)
 
(14 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
* select <tt>Emulation</tt>/<tt>Spike ucb riscv</tt>
* TODO: payload linker script foo
* in the Payload menu of <code>menuconfig</code>, select "ELF Payload" and enter the path to the vmlinux binary
* TODO: patching the console output handler
* run <code>make</code> and the <code>make-spike-elf.sh</code> script as described above
* 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==
For general spike usage, look at [https://github.com/riscv/riscv-isa-sim/ its GitHub page].


* apply the same coreboot patches as above, and select <tt>Emulation</tt>/<tt>Spike ucb riscv</tt>
=Boot log=
* 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


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


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.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)
  coreboot-4.4-652-gbfb3fee Thu Jun 30 01:03:13 UTC 2016 bootblock starting...
CBFS: Locating 'fallback/romstage'
  CBFS @ 20100 size 3dff00
  CBFS: Found @ offset 80 size 3013
  CBFS: 'Master Header Locator' located CBFS at [20100:400000)
  CBFS: Locating 'fallback/romstage'
  CBFS: Checking offset 0
coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 romstage starting...
  CBFS: File @ offset 0 size 20
0x40000000 bytes of memory at 0x80000000
  CBFS: Unmatched 'cbfs master header' at 0
CBFS @ 20100 size 7dff00
  CBFS: Checking offset 80
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
  CBFS: File @ offset 80 size 2d17
CBFS: Locating 'fallback/ramstage'
  CBFS: Found @ offset 80 size 2d17
CBFS: Found @ offset 3100 size 5403
  ?
 
 
  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 ramstage starting...
  CBFS @ 20100 size 3dff00
BS: Entering BS_PRE_DEVICE state.
  CBFS: 'Master Header Locator' located CBFS at [20100:400000)
BS: Exiting BS_PRE_DEVICE state.
  CBFS: Locating 'fallback/ramstage'
----------------------------------------
  CBFS: Checking offset 0
BS: Entering BS_DEV_INIT_CHIPS state.
  CBFS: File @ offset 0 size 20
BS: Exiting BS_DEV_INIT_CHIPS state.
  CBFS: Unmatched 'cbfs master header' at 0
----------------------------------------
  CBFS: Checking offset 80
BS: Entering BS_DEV_ENUMERATE state.
  CBFS: File @ offset 80 size 2d17
Enumerating buses...
  CBFS: Unmatched 'fallback/romstage' at 80
Show all devs... Before device enumeration.
  CBFS: Checking offset 2e00
Root Device: enabled 1
  CBFS: File @ offset 2e00 size 4ed7
CPU_CLUSTER: 0: enabled 1
  CBFS: Found @ offset 2e00 size 4ed7
I2C: 00:06: enabled 1
  ?
Compare with tree...
 
Root Device: enabled 1
  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
   CPU_CLUSTER: 0: enabled 1
   I2C: 00:06: enabled 1
   I2C: 00:06: enabled 1
  Finalize devices...
CBMEM:
  Devices finalized
IMD: root @ 00000000bffff000 254 entries.
  Writing coreboot table at 0xbffdc000
IMD: root @ 00000000bfffec00 62 entries.
  memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841a18
Root Device scanning...
  memalign 0000000080841a18
root_dev_scan_bus for Root Device
  memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841a38
CPU_CLUSTER: 0 enabled
  memalign 0000000080841a38
I2C: 00:06 enabled
  0. 0000000080000000-00000000bffdbfff: RAM
root_dev_scan_bus for Root Device done
  1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
scan_bus: scanning of bus Root Device took 0 usecs
  CBFS @ 20100 size 3dff00
done
  CBFS: 'Master Header Locator' located CBFS at [20100:400000)
BS: Exiting BS_DEV_ENUMERATE state.
  FMAP: Found "FLASH" version 1.1 at 20000.
----------------------------------------
  FMAP: base = 0 size = 400000 #areas = 4
BS: Entering BS_DEV_RESOURCES state.
  Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum f468
Allocating resources...
  coreboot table: 360 bytes.
Reading resources...
  IMD ROOT    0. 00000000bffff000 00001000
Root Device read_resources bus 0 link: 0
  IMD SMALL  1. 00000000bfffe000 00001000
CPU_CLUSTER: 0 missing read_resources
  CONSOLE    2. 00000000bffde000 00020000
I2C: 00:06 missing read_resources
   COREBOOT    3. 00000000bffdc000 00002000
Root Device read_resources bus 0 link: 0 done
   IMD small region:
Done reading resources.
    IMD ROOT   0. 00000000bfffec00 00000400
Show resources in subtree (Root Device)...After reading.
  CBFS @ 20100 size 3dff00
   Root Device child on link 0 CPU_CLUSTER: 0
  CBFS: 'Master Header Locator' located CBFS at [20100:400000)
   Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  CBFS: Locating 'fallback/payload'
   CPU_CLUSTER: 0
  CBFS: Checking offset 0
  I2C: 00:06
  CBFS: File @ offset 0 size 20
Setting resources...
  CBFS: Unmatched 'cbfs master header' at 0
Root Device assign_resources, bus 0 link: 0
  CBFS: Checking offset 80
Root Device assign_resources, bus 0 link: 0
   CBFS: File @ offset 80 size 2d17
  Done setting resources.
  CBFS: Unmatched 'fallback/romstage' at 80
Show resources in subtree (Root Device)...After assigning values.
  CBFS: Checking offset 2e00
  Root Device child on link 0 CPU_CLUSTER: 0
  CBFS: File @ offset 2e00 size 4ed7
   Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  CBFS: Unmatched 'fallback/ramstage' at 2e00
  CPU_CLUSTER: 0
  CBFS: Checking offset 7d40
  I2C: 00:06
  CBFS: File @ offset 7d40 size 114
  Done allocating resources.
  CBFS: Unmatched 'config' at 7d40
BS: Exiting BS_DEV_RESOURCES state.
  CBFS: Checking offset 7ec0
  ----------------------------------------
  CBFS: File @ offset 7ec0 size 239
BS: Entering BS_DEV_ENABLE state.
  CBFS:  Unmatched 'revision' at 7ec0
Enabling resources...
  CBFS: Checking offset 8140
done.
  CBFS: File @ offset 8140 size 120258
BS: Exiting BS_DEV_ENABLE state.
  CBFS: Found @ offset 8140 size 120258
----------------------------------------
  Loading segment from rom address 0x0000000080028278
BS: Entering BS_DEV_INIT state.
    code (compression=1)
Initializing devices...
  memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841a58
Root Device init ...
  memalign 0000000080841a58
Devices initialized
    New segment dstaddr 0x80000000 memsize 0x7e40 srcaddr 0x800282e8 filesize 0x3525
Show all devs... After init.
  Loading segment from rom address 0x0000000080028294
Root Device: enabled 1
    code (compression=1)
CPU_CLUSTER: 0: enabled 1
  memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841a90
I2C: 00:06: enabled 1
  memalign 0000000080841a90
BS: Exiting BS_DEV_INIT state.
    New segment dstaddr 0x80008000 memsize 0x1000 srcaddr 0x8002b80d filesize 0x86
BS: callback (000000008083e308) @ src/vboot/bootmode.c:68.
  Loading segment from rom address 0x00000000800282b0
----------------------------------------
    data (compression=1)
BS: Entering BS_POST_DEVICE state.
  memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841ac8
Finalize devices...
  memalign 0000000080841ac8
Devices finalized
    New segment dstaddr 0x81000000 memsize 0x3314c8 srcaddr 0x8002b893 filesize 0x11cc3d
BS: Exiting BS_POST_DEVICE state.
  Loading segment from rom address 0x00000000800282cc
----------------------------------------
    Entry Point 0x0000000080000000
BS: Entering BS_OS_RESUME_CHECK state.
  memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b00
BS: Exiting BS_OS_RESUME_CHECK state.
  memalign 0000000080841b00
----------------------------------------
  memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b20
BS: Entering BS_WRITE_TABLES state.
  memalign 0000000080841b20
Writing coreboot table at 0xbffdc000
  memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b40
   0. 0000000080000000-00000000bffdbfff: RAM
  memalign 0000000080841b40
   1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
  memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b60
CBFS @ 20100 size 7dff00
  memalign 0000000080841b60
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
  Bounce Buffer at 00000000bffb6000, 153648 bytes
FMAP: Found "FLASH" version 1.1 at 20000.
  Loading Segment: addr: 0x0000000080000000 memsz: 0x0000000000007e40 filesz: 0x0000000000003525
FMAP: base = 0 size = 800000 #areas = 4
  lb: [0x0000000080832000, 0x0000000080844c18)
Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum d4c8
  Post relocation: addr: 0x0000000080000000 memsz: 0x0000000000007e40 filesz: 0x0000000000003525
coreboot table: 360 bytes.
  using LZMA
IMD ROOT    0. 00000000bffff000 00001000
  [ 0x80000000, 80007d7c, 0x80007e40) <- 800282e8
IMD SMALL   1. 00000000bfffe000 00001000
  Clearing Segment: addr: 0x0000000080007d7c memsz: 0x00000000000000c4
CONSOLE    2. 00000000bffde000 00020000
  dest 0000000080000000, end 0000000080007e40, bouncebuffer bffb6000
COREBOOT    3. 00000000bffdc000 00002000
  Loading Segment: addr: 0x0000000080008000 memsz: 0x0000000000001000 filesz: 0x0000000000000086
IMD small region:
   lb: [0x0000000080832000, 0x0000000080844c18)
  IMD ROOT    0. 00000000bfffec00 00000400
   Post relocation: addr: 0x0000000080008000 memsz: 0x0000000000001000 filesz: 0x0000000000000086
BS: Exiting BS_WRITE_TABLES state.
  using LZMA
----------------------------------------
  [ 0x80008000, 80009000, 0x80009000) <- 8002b80d
BS: Entering BS_PAYLOAD_LOAD state.
  dest 0000000080008000, end 0000000080009000, bouncebuffer bffb6000
CBFS @ 20100 size 7dff00
  Loading Segment: addr: 0x0000000081000000 memsz: 0x00000000003314c8 filesz: 0x000000000011cc3d
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
  lb: [0x0000000080832000, 0x0000000080844c18)
  CBFS: Locating 'fallback/payload'
  Post relocation: addr: 0x0000000081000000 memsz: 0x00000000003314c8 filesz: 0x000000000011cc3d
CBFS: Found @ offset 8900 size 34081c
  using LZMA
Loading segment from ROM address 0x0000000080028a38
  [ 0x81000000, 813314c8, 0x813314c8) <- 8002b893
  code (compression=0)
  dest 0000000081000000, end 00000000813314c8, bouncebuffer bffb6000
  New segment dstaddr 0x81000000 memsize 0x300000 srcaddr 0x80028a8c filesize 0x2ffa78
   Loaded segments
Loading segment from ROM address 0x0000000080028a54
  Jumping to boot code at 0000000080000000(00000000bffdc000)
  data (compression=0)
  CPU0: stack: 0000000080800000 - 0000000080810000, lowest used address 0000000080800004, stack used: 65532 bytes
  New segment dstaddr 0x81300000 memsize 0x40d50 srcaddr 0x80328504 filesize 0x40d50
  handle_command([255,255,80203a00])
Loading segment from ROM address 0x0000000080028a70
                vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  Entry Point 0xffffffff81000000
                    vvvvvvvvvvvvvvvvvvvvvvvvvvvv
Loading Segment: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
  rrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv
lb: [0x0000000080832000, 0x0000000080847170)
  rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvv
  Post relocation: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
  rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
it's not compressed!
  rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
[ 0x81000000, 812ffa78, 0x81300000) <- 80028a8c
  rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
Clearing Segment: addr: 0x00000000812ffa78 memsz: 0x0000000000000588
  rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv  
dest 0000000081000000, end 0000000081300000, bouncebuffer ffffffffffffffff
  rrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv   
Loading Segment: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
  rr                vvvvvvvvvvvvvvvvvvvvvv     
lb: [0x0000000080832000, 0x0000000080847170)
  rr            vvvvvvvvvvvvvvvvvvvvvvvv      rr
Post relocation: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
  rrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv      rrrr
it's not compressed!
  rrrrrr      vvvvvvvvvvvvvvvvvvvvvv      rrrrrr
[ 0x81300000, 81340d50, 0x81340d50) <- 80328504
  rrrrrrrr      vvvvvvvvvvvvvvvvvv      rrrrrrrr
dest 0000000081300000, end 0000000081340d50, bouncebuffer ffffffffffffffff
  rrrrrrrrrr      vvvvvvvvvvvvvv      rrrrrrrrrr
Loaded segments
  rrrrrrrrrrrr      vvvvvvvvvv      rrrrrrrrrrrr
  BS: Exiting BS_PAYLOAD_LOAD state.
  rrrrrrrrrrrrrr      vvvvvv      rrrrrrrrrrrrrr
----------------------------------------
  rrrrrrrrrrrrrrrr      vv      rrrrrrrrrrrrrrrr
BS: Entering BS_PAYLOAD_BOOT state.
  rrrrrrrrrrrrrrrrrr          rrrrrrrrrrrrrrrrrr
Jumping to boot code at ffffffff81000000(00000000bffdc000)
  rrrrrrrrrrrrrrrrrrrr      rrrrrrrrrrrrrrrrrrrr
Stack overrun on CPU0 (address 0000000080800000 overwritten). Increase stack from current 4096 bytes
  rrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrr
ERROR: BUG ENCOUNTERED at file 'src/lib/stack.c', line 40
 
Config string: 'platform {
        INSTRUCTION SETS WANT TO BE FREE
   vendor ucb;
  [    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
  arch spike;
  [    0.000000] Available physical memory: 2044MB
};
  [    0.000000] Zone ranges:
rtc {
  [    0.000000]  Normal  [mem 0x0000000080200000-0x00000000ffdfffff]
  addr 0x40000000;
  [    0.000000] Movable zone start for each node
};
  [   0.000000] Early memory node ranges
uart {
  [    0.000000]  node  0: [mem 0x0000000080200000-0x00000000ffdfffff]
  addr 0x40001000;
  [   0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000ffdfffff]
};
  [    0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 516110
ram {
  [    0.000000] Kernel command line:
   0 {
  [    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
    addr 0x80000000;
  [    0.000000] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
    size 0x40000000;
  [    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 cma-reserved)
core {
  [   0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
   0 {
  [   0.000000] NR_IRQS:0 nr_irqs:0 0
    0 {
  [    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 191126044627 ns
      isa rv64imafdc;
  [    0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=100000)
      timecmp 0x40000008;
  [    0.000000] pid_max: default: 32768 minimum: 301
      ipi 0x40002000;
  [    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
Virtual memory status enabled
   [    0.000000] NET: Registered protocol family 2
-----------------------------
  [    0.000000] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
Initializing virtual memory...
  [    0.000000] TCP bind hash table entries: 16384 (order: 5, 131072 bytes)
Finished initializing virtual memory
  [   0.000000] TCP: Hash tables configured (established 16384 bind 16384)
OK, let's go
  [    0.000000] UDP hash table entries: 1024 (order: 3, 32768 bytes)
Getting hart id...
  [    0.000000] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[    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] NET: Registered protocol family 1
[    0.000000] bootconsole [early0] enabled
  [    0.010000] console [sbi_console0] enabled
Querying memory, CPU #0...
  [    0.010000] futex hash table entries: 256 (order: 0, 6144 bytes)
[    0.000000] Available physical memory: 1008MB
  [    0.010000] workingset: timestamp_bits=61 max_order=19 bucket_order=0
[    0.000000] Initial ramdisk at: 0xffffffff81013758 (1415600 bytes)
  [    0.020000] jitterentropy: Initialization failed with host not compliant with requirements: 2
[    0.000000] Zone ranges:
  [    0.020000] io scheduler noop registered
[    0.000000]   Normal   [mem 0x0000000081000000-0x00000000bfffffff]
  [    0.020000] io scheduler cfq registered (default)
[    0.000000] Movable zone start for each node
  [    0.020000] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    0.000000] Early memory node ranges
  [    0.020000] Please append a correct "root=" boot option; here are the available partitions:
[    0.000000]  node  0: [mem 0x0000000081000000-0x00000000bfffffff]
  [    0.020000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    0.000000] Initmem setup node 0 [mem 0x0000000081000000-0x00000000bfffffff]
  [    0.020000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.6.3 #1
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 254520
  [    0.020000] Call Trace:
[    0.000000] Kernel command line: earlyprintk=sbi_console0 keep init=/bin/sh
  [    0.020000] [<ffffffff80011f5c>] walk_stackframe+0x0/0xc8
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
  [    0.020000] [<ffffffff80053a00>] panic+0xe0/0x1f4
[    0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
  [    0.020000] [<ffffffff8000115c>] mount_block_root+0x234/0x310
[    0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
  [    0.020000] [<ffffffff800013f0>] prepare_namespace+0x138/0x188
[    0.000000] Sorting __ex_table...
  [    0.020000] [<ffffffff80000d48>] kernel_init_freeable+0x1b0/0x1e8
[    0.000000] Memory: 1013124K/1032192K available (1317K kernel code, 77K rwdata, 288K rodata, 1464K init, 180K bss, 19068K reserved, 0K cma-reserved)
  [    0.020000] [<ffffffff801f41ac>] rest_init+0x7c/0x80
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
  [    0.020000] [<ffffffff801f41c0>] kernel_init+0x10/0x110
[    0.000000] NR_IRQS:0 nr_irqs:0 0
  [    0.020000] [<ffffffff801f41ac>] rest_init+0x7c/0x80
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446 ns
  [    0.020000] [<ffffffff80010bdc>] ret_from_syscall+0x10/0x14
Setting timer to 0000000000989680 (current time is 0000000000000000)...
  [    0.020000] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
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#

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#