Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[arch][riscv][nuclei] Add Nuclei RISC-V processsor support #281

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fanghuaqi
Copy link

@fanghuaqi fanghuaqi commented Oct 28, 2020

Add Nuclei RISC-V Processor Support

* This PR add Nuclei RISC-V Processor which use CLIC interrupt
  system instead of PLIC and CLINT interrupt system
* This PR is also using Nuclei NMSIS and SDK,
  see https://github.com/Nuclei-Software/NMSIS and
  https://github.com/Nuclei-Software/nuclei-sdk
* In this PR, the context switch is done using CLIC software
  interrupt
* For RISC-V CLIC spec, please check https://github.com/riscv/riscv-fast-interrupt/blob/master/clic.adoc
* To evaluate this support, Nuclei HummingBird RISC-V SoC
  is supported, please check https://nucleisys.com/developboard.php
  for this board introduction

Signed-off-by: Huaqi Fang <578567190@qq.com>
@fanghuaqi
Copy link
Author

How to use this PR

Here are steps used in Linux, similar steps could be done in Windows.

Prerequisites

Assume you have extracted Nuclei Studio IDE into ~/NucleiStudio_IDE_202009, then you can open setup toolchain path before build program by command:

export PATH=$HOME/NucleiStudio_IDE_202009/NucleiStudio/toolchain/gcc/bin:$PATH

Build Project for Nuclei HummingBird Evaluation Board

  1. cd /path/to/lk

  2. make TOOLCHAIN_PREFIX=riscv-nuclei-elf- nuclei-hbird

    linking build-nuclei-hbird/lib/io.mod.o
    generating build-nuclei-hbird/linker-twosegment.ld
    linking build-nuclei-hbird/lk.elf
       text    data     bss     dec     hex filename
        195       0       0     195      c3 ./build-nuclei-hbird/app.mod.o
         34       0       0      34      22 ./build-nuclei-hbird/app/shell.mod.o
      22895      84     188   23167    5a7f ./build-nuclei-hbird/app/tests.mod.o
          0       0       0       0       0 ./build-nuclei-hbird/arch.mod.o
       2938       1    2112    5051    13bb ./build-nuclei-hbird/arch/riscv.mod.o
       1468       0       0    1468     5bc ./build-nuclei-hbird/dev.mod.o
       1992       4      52    2048     800 ./build-nuclei-hbird/external/platform/hbird.mod.o
      13770       0     593   14363    381b ./build-nuclei-hbird/kernel.mod.o
       1989       0      72    2061     80d ./build-nuclei-hbird/kernel/novm.mod.o
       1622       0       0    1622     656 ./build-nuclei-hbird/lib/cbuf.mod.o
       3488      29       9    3526     dc6 ./build-nuclei-hbird/lib/console.mod.o
        860      12       0     872     368 ./build-nuclei-hbird/lib/debug.mod.o
       2778       8       5    2791     ae7 ./build-nuclei-hbird/lib/heap.mod.o
       2272       0      52    2324     914 ./build-nuclei-hbird/lib/heap/miniheap.mod.o
        550      16       4     570     23a ./build-nuclei-hbird/lib/io.mod.o
       8600      16      12    8628    21b4 ./build-nuclei-hbird/lib/libc.mod.o
        233       0       0     233      e9 ./build-nuclei-hbird/platform.mod.o
        417       0     176     593     251 ./build-nuclei-hbird/platform/nuclei-hbird.mod.o
          8       0       0       8       8 ./build-nuclei-hbird/target.mod.o
          6       0       0       6       6 ./build-nuclei-hbird/target/nuclei-hbird.mod.o
       1129       0      16    1145     479 ./build-nuclei-hbird/top.mod.o
      67244     170    3291   70705   11431 (TOTALS)
    generating image: build-nuclei-hbird/lk.bin
       text    data     bss     dec     hex filename
      57568     200    3304   61072    ee90 build-nuclei-hbird/lk.elf
    generating listing: build-nuclei-hbird/lk.elf.lst
    generating listing: build-nuclei-hbird/lk.elf.debug.lst
    generating symbols: build-nuclei-hbird/lk.elf.sym
    generating sorted symbols: build-nuclei-hbird/lk.elf.sym.sorted
    generating size map: build-nuclei-hbird/lk.elf.size
    generating objdump: build-nuclei-hbird/lk.elf.dump
    generating build-nuclei-hbird/srcfiles.txt
    
  3. Open Nuclei Studio IDE(~/NucleiStudio_IDE_202009/NucleiStudio/eclipse), and create a Nuclei SDK project for HummingBird SoC by following guidance here in Chinese

  4. Open the debug configuration for that project and select executable using the build-nuclei-hbird/lk.elf, and download it and run it, here is the sample output.

    Nuclei SDK Build Time: Oct 28 2020, 11:46:22
    Download Mode: ILM
    CPU Frequency 32000245 Hz
    
    welcome to lk
    
    boot args 0x0 0xa 0x2f 0x2f
    initializing heap
    calling constructors
    initializing mp
    initializing threads
    initializing timers
    initializing ports
    creating bootstrap completion thread
    top of bootstrap2()
    RISCV: Machine mode
    RISCV: mvendorid 0x536 marchid 0x205 mimpid 0x1 mhartid 0x0
    RISCV: misa 0x40101105
    initializing platform
    initializing target
    initializing apps
    starting app shell
    entering main console loop
    ] fibo 4
    fibo 3
    took 3 msecs to calculate
    ] threads
    thread list:
    dump_thread: t 00x90001348 (shell)
           state run, priority 16, remaining quantum -450
           stack 0x900013c8, stack_size 1280, stack_used 464
           entry 0x80000b14, arg 0x8000e044, flags 0x27
           wait queue 0x0, wait queue ret 0
    dump_thread: t 0x90000b04 (idle)
           state rdy, priority 0, remaining quantum 0
           stack 0x0, stack_size 0, stack_used 0
           entry 0x0, arg 0x0, flags 0x11
           wait queue 0x0, wait queue ret 0
           arch: sp 0x0
    ]
    

Thanks
Huaqi

@travisg
Copy link
Member

travisg commented Oct 28, 2020

Oh very neat! Very interesting.

The context switch thing we might have to work out a bit, but I'm always interested in new hardware.

Signed-off-by: Huaqi Fang <578567190@qq.com>
Signed-off-by: Huaqi Fang <578567190@qq.com>
Signed-off-by: Huaqi Fang <578567190@qq.com>
@travisg
Copy link
Member

travisg commented Dec 15, 2020

Still looking at this one. Trouble is that context switch stuff is far too intrusive. Is it mandatory that the context switch be done via the CLIC? I'd love for this to look much more like the other riscv with the core kernel stuff.

@fanghuaqi
Copy link
Author

Yes, it should be done via CLIC, since CLIC introduced, CORE will have exception and interrupt state, if we use current context switch, then we can't get out of interrupt state, which will affect normal interrupt handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants