Git Product home page Git Product logo

risc-v64-naruto-pi's Introduction

1. 概述

Naruto Pi是基于QEMU构建的RISC-V64 SOC,支持Linuxbaremetal, RTOS等,适合用来学习Linux,后续还会添加大量的controller,实现无需实体开发板即可学习LinuxRISC-V架构,是用来探索嵌入式的奥秘的绝佳之选,本项目长期更新,后续会支持SPII2CUSBEthernetBoot FlowI2SADCRTCPower等经典常用IPDriver,同时也设有文档手把手跟学,非常适合想从零了解CPU实现和bringup的小伙伴。

登录用户名和密码:

  • Ubuntu

    username:jihongz

    password:1

  • busybox(root):

    username:root

    password:root

  • busybox(naruto):

    username:naruto

    password:naruto

2. 环境部署基于Ubuntu20.04

在开始编译之前需要部署一下依赖,安装以下依赖

sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build
# 建议安装的额外的包, qemu: 为了额外的功能
sudo apt-get install git-email
sudo apt-get install libaio-dev libbluetooth-dev libcapstone-dev libbrlapi-dev libbz2-dev
sudo apt-get install libcap-ng-dev libcurl4-gnutls-dev libgtk-3-dev
sudo apt-get install libibverbs-dev libjpeg8-dev libncurses5-dev libnuma-dev
sudo apt-get install librbd-dev librdmacm-dev
sudo apt-get install libsasl2-dev libsdl2-dev libseccomp-dev libsnappy-dev libssh-dev
sudo apt-get install libvde-dev libvdeplug-dev libvte-2.91-dev libxen-dev liblzo2-dev
sudo apt-get install valgrind xfslibs-dev
sudo apt-get install python3.8-venv
sudo apt-get install texinfo
sudo apt-get install gawk
sudo apt-get install device-tree-compiler
sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev

#ssh服务,需要的再装
sudo apt install openssh-server
#缺啥安装啥
sudo apt-get install flex
sudo apt-get install bison

3. 整体编译Naruto Pi

在开始编译之前需要部署一下依赖,安装以下依赖

  • 编译器需要RISCV64的编译器,需要支持Linux,如果需要跑bare-metal则还需要newlib-c

  • 编译交叉编译工具链,这一步会很慢,我估计普通电脑需要三个小时,所以可以先去玩一会再回来

./build.sh compile

3.1 整体编译(如果使用ubuntu 文件系统)

  • 如果使用FreeRTOS作为trusted domain 就加freertos,如果用baremetal则加baremetal
./build.sh all busybox freertos
./build.sh all busybox baremetal

3.1 整体编译(如果使用busybox 文件系统)

./build.sh all ubuntu freertos
./build.sh all ubuntu baremetal

4. 模块化编译Naruto Pi

  • 如果后期开发只是更改部分部分内容,则可以使用下列命令去编译对应的代码即可,这样速度比较快.

4.1 编译qemu

QEMU是虚拟机软件,将RISCV指令集翻译成x86指令集运行的环境。

./build.sh qemu_defconfig
./build.sh qemu

4.2 编译lowinit

lowinitbootrom跳转出来的第一个程序,主要负责把BL1~BL3的程序从模拟的pFLASH中拷贝到DDR中。

./build.sh lowinit

4.3 编译opensbi 设备树

./build.sh sbi_dtb

4.4 编译Opensbi

./build.sh sbi

4.5 编译uboot 和kernel 设备树

  • Naruto PiKernelU-boot使用的是同一个设备树,统一管理。
./build.sh uboot_dtb

4.6 编译uboot

./build.sh uboot_defconfig
./build.sh uboot

4.7 编译kernel

./build.sh kernel_defconfig
./build.sh kernel

4.8 编译ubuntu文件系统(如使用busybox可以不编译)

./build.sh ubuntu

4.9 压缩ubuntu

  • 如果改过Ubuntu文件系统,想再次打包可以直接调用脚本,这个主要是我用来把Ubuntu的文件系统拆分,这样才能使每个文件小于10Mb上传于GIT
./build.sh tar_ubuntu

4.10 编译Busybox(同样和Ubuntu二选一即可)

./build.sh busybox

4.11 编译bare-metal

  • 我想讲解一些裸机的驱动,所以我想弄个裸机的目录,你们也可以用来跑裸机,裸机是core 7在运行。
./build.sh barematel

4.12 编译FreeRTOS

  • 用于运行FreeRTOS,同样是跑在core 7上,所以和bare-metal 二选一
./build.sh freertos

打包所以Image 并运行Naruto Pi

  • 打包
./build.sh image
  • 运行
./run.sh

3 内存分布

  • 目前已经集成的Memory及其基地址如下(不断更新):
地址 大小 内存区域描述
0x0000_0000 2Kb ROM
0x0000_8000 2Kb SRAM
0x2000_0000 32Mb PFLASH
0x8000_0000 1Gb DDR

4 程序分区

地址 大小 内存区域描述
0x0000_0000 2Kb ROM 启动程序
0x2000_0000 512Kb lowinit
0x2008_0000 512Kb opensbi_dtb
0x2010_0000 512Kb uboot_dtb
0x2018_0000 512Kb reserved
0x2020_0000 512Kb opensbi
0x2028_0000 1.5Mb reserved
0x2040_0000 4Mb trusted domain
0x2080_0000 4Mb uboot
0x20C0_0000 20Mb reserved

5 设备地址映射

  • 目前已经集成的设备名称基地址寄存器总大小如下(不断更新):
static const MemMapEntry naruto_soc_memmap[] = {
	[NARUTO_SOC_ROM]			= {0x00000000,	0x8000},
	[NARUTO_SOC_SRAM]			= {0x00008000,	0x8000},
	[NARUTO_SOC_SYSCON]			= {0x00100000,	0x1000},
	[NARUTO_SOC_CLINT]			= {0x02000000,	0x10000},
	[NARUTO_SOC_PLIC]			= {0x0c000000,	0x4000000},
	[NARUTO_SOC_UART0]			= {0x10000000,	0x1000},
	[NARUTO_SOC_UART1]			= {0x10001000,	0x1000},
	[NARUTO_SOC_UART2]			= {0x10002000,	0x1000},
	[NARUTO_SOC_RTC]			= {0x10003000,	0x1000},
	[NARUTO_SOC_VIRTIO0]		= {0x10100000,	0x1000},
	[NARUTO_SOC_VIRTIO1]		= {0x10101000,	0x1000},
	[NARUTO_SOC_VIRTIO2]		= {0x10102000,	0x1000},
	[NARUTO_SOC_VIRTIO3]		= {0x10103000,	0x1000},
	[NARUTO_SOC_VIRTIO4]		= {0x10104000,	0x1000},
	[NARUTO_SOC_VIRTIO5]		= {0x10105000,	0x1000},
	[NARUTO_SOC_VIRTIO6]		= {0x10106000,	0x1000},
	[NARUTO_SOC_VIRTIO7]		= {0x10107000,	0x1000},
	[NARUTO_SOC_FW_CFG]			= {0x10108000,	0x18},
	[NARUTO_SOC_PFLASH]			= {0x20000000,	0x2000000},
	[NARUTO_SOC_DRAM]			= {0x80000000,	0},
};

risc-v64-naruto-pi's People

Contributors

dsmguoguo avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.