PolyOS 是面向 RISC-V 架构的智能终端和 AIoT 开源操作系统(基于开源鸿蒙)

发布于:2025-02-23 ⋅ 阅读:(11) ⋅ 点赞:(0)

PolyOS 是面向 RISC-V 架构的智能终端和 AIoT 开源操作系统

官网:PolyOS | PolyOS

PolyOS Mobile,作为一款面向 RISC-V 架构的智能终端操作系统,我们希望能够构建卓越的特性和创新的生态系统来引领未来移动操作系统技术的发展。该操作系统基于开源项目 OpenHarmony,旨在为 RISC-V 潜在的硬件和软件市场构建一个强大的移动操作系统和生态系统。

当前特性与目标

PolyOS Mobile 是一个处在早期阶段的社区驱动项目,我们目前的特性请求界面还在建设当中,但我们已经有了一些短期和长期未来工作目标。

丰富的虚拟化支持

目前,PolyOS Mobile 以 QEMU 虚拟化平台为硬件基础,我们正在努力为开发者提供一个强大的开发和测试环境。我们希望帮助开发者可以在虚拟环境中轻松运行和测试他们的应用程序,从而加快开发周期,降低开发成本。

实践

该项目从2023年8月未再更新,很遗憾啊,只能浅尝即止了。

下载软件

下载:

curl --remote-name \
     --location https://polyos.iscas.ac.cn/downloads/polyos-mobile-latest.img.tar.xz

下载qemu编译包

curl --remote-name \
     --location https://polyos.iscas.ac.cn/downloads/polyos-qemu-riscv64-7.1.0-1.x86_64.deb

也可以直接到网站下载:

PolyOS Files

Linux下安装

安装qemu

sudo dpkg -i /path/to/polyos-qemu-riscv64-7.1.0-1.x86_64.deb

Linux下操作类似,可能需要手工添加一些库:

需要的库

sudo apt-get install libpixman-1-0 libepoxy0 libv4l-0 libpng16-16 \
                     libsdl2-2.0-0 libsdl2-image-2.0-0 libglib2.0-0 \
                     libasound2 libpulse0 osspd-alsa \
                     libusb-1.0-0 \
                     libncursesw5 \
                     libgtk-3-0 libgdk-pixbuf2.0-0 \
                     libx11-6
(可选)配置 QEMU 环境

您可以选择将 /opt/qemu-7.1.0 加入到您的环境变量中。

cat << EOF >> ~/.bashrc
export PATH=/opt/qemu-7.1.0/bin:$PATH
EOF
source ~/.bashrc

使用 tar 命令来解压 PolyOS Mobile 镜像文件:

tar -Jxvf /path/to/polyos-mobile-latest.img.tar.xz

启动 PolyOS Mobile

  • 使用脚本启动
  • manual

您可以选择直接使用一个初始化脚本来启动 PolyOS Mobile,该脚本附带在镜像文件中。

sh /path/to/qemu_riscv64_run_linux.sh

手动

手动调用 /opt/qemu-7.1.0/bin/qemu-system-riscv64 的方式来启动 PolyOS Mobile。

/opt/qemu-7.1.0/bin/qemu-system-riscv64 \
    -machine virt \
    -m 8096\
    -smp 8 \
    -drive if=none,file=./updater.img,format=raw,id=updater,index=3 \
    -device virtio-blk-device,drive=updater \
    -drive if=none,file=./system.img,format=raw,id=system,index=2 \
    -device virtio-blk-device,drive=system \
    -drive if=none,file=./vendor.img,format=raw,id=vendor,index=1 \
    -device virtio-blk-device,drive=vendor \
    -drive if=none,file=./userdata.img,format=raw,id=userdata,index=0 \
    -device virtio-blk-device,drive=userdata \
    -append "ip=dhcp loglevel=7 console=ttyS0,115200 init=init root=/dev/ram0 rw rootwait ohos.boot.hardware=riscv64_virt default_boot_device=10007000.virtio_mmio sn=8823456789 ohos.required_mount.system=/dev/block/vdb@/usr@ext4@ro,barrier=1@wait,required ohos.required_mount.vendor=/dev/block/vdc@/vendor@ext4@ro,barrier=1@wait,required ohos.required_mount.data=/dev/block/vdd@/data@ext4@nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc@wait,reservedsize=104857600" \
    -kernel ./Image \
    -initrd ./ramdisk.img \
    -nographic \
    -vga none \
    -device virtio-gpu-pci,xres=550,yres=920,max_outputs=1,addr=08.0 \
    -vnc :20 \
    -device virtio-mouse-pci \
    -netdev tap,id=net0,ifname=tap0,script=no,downscript=no \
    -device virtio-net-pci,netdev=net0 \
    -device virtio-camera-device,v4ldev=/dev/video0 \
    -netdev bridge,id=net0 -device virtio-net-device,netdev=net0,mac=12:22:33:44:55:66\
    -device virtio-keyboard-pci \
    -device ac97 \
    -k en-us \
    -display gtk,gl=off

windows10下仿真使用

安装qemu

点击下方的按钮直接获取 PolyOS 官方站点提供的 QEMU 预构建包。

下载 QEMU

下载后,双击 .exe 文件直接以默认选项进行安装,QEMU 默认将被安装至 C:\Porgram Files\PolyOS QEMU 文件夹。

当然这次是装到e:盘,E:\Porgram Files\PolyOS QEMU 文件夹。

解压polyos-mobile包

解压下载的polyos-mobile包。windows10下也支持tar了

tar -Jxvf /path/to/polyos-mobile-latest.img.tar.xz

Windows下执行仿真虚拟

windows下执行,注意要以管理员身份启动powershell 。进入解压的polyos-mobile的目录,比如是:E:\360Downloads\polyos-mobile-latest.img\images> ,执行:

.\qemu_riscv64_run_windows.ps1

如果报签名错,可以这样执行:

powershell -ExecutionPolicy Bypass -File.\qemu_riscv64_run_windows.ps1

 等待较长时间,就能看到启动画面了

一些组合键

退出用Ctrl+Alt+G组合键

最大化用 Ctrl+Alt+F

速度太慢了,放弃。

尝试一下

修改配置文件,把内存和cpu核数减少,试试

$cpu = [System.Environment]::ProcessorCount / 2
$mem = (Get-CimInstance CIM_ComputerSystem).TotalPhysicalMemory/2MB -as [int]
$cpu = 4
$mem = 4096

速度还是一样慢。

怪不得这个项目没进展了....

另外连浏览器也没有,所以根本没法用啊!

调试

windows下无法执行ps1文件

晕,用错斜线了

E:\360Downloads\polyos-mobile-latest.img\images>./qemu_riscv64_run_linux.sh
'.' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

E:\360Downloads\polyos-mobile-latest.img\images>.\qemu_riscv64_run_linux.sh

用第二条命令就行了

还是不执行,加上这句试试

$env:Path = "E:\Porgram Files\PolyOS QEMU" + $env:Path
[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine")

后来才知道其实是走了弯路了,需要 以管理员身份启动powershell 。

报错未对文件 E:\360Downloads\polyos-mobile-latest.img\images\qemu_riscv64_run_windows.ps1 进行数字签名

.\qemu_riscv64_run_windows.ps1 : 无法加载文件 E:\360Downloads\polyos-mobile-latest.img\images\qemu_riscv64_run_windows.
ps1。未对文件 E:\360Downloads\polyos-mobile-latest.img\images\qemu_riscv64_run_windows.ps1 进行数字签名。无法在当前系统
上运行该脚本。有关运行脚本和设置执行策略的详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Exe
cution_Policies。
所在位置 行:1 字符: 1
+ .\qemu_riscv64_run_windows.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

可以这样执行就不报签名的错了:

powershell -ExecutionPolicy Bypass -File.\qemu_riscv64_run_windows.ps1

终于执行成功,出来了启动界面

启动输出

dsound: Could not initialize DirectSoundCapture
dsound: Reason: No sound driver is available for use, or the given GUID is not a valid DirectSound device ID

OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 12
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 340 KB
Runtime SBI Version       : 0.3

Domain0 Name              : root
Domain0 Boot HART         : 11
Domain0 HARTs             : 0*,1*,2*,3*,4*,5*,6*,7*,8*,9*,10*,11*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x00000000bfe00000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 11
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcsuh
Boot HART Features        : scounteren,mcounteren,mcountinhibit,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 16
Boot HART MIDELEG         : 0x0000000000001666
Boot HART MEDELEG         : 0x0000000000f0b509

启动后gui是黑色的,且无法退出

退出用Ctrl+Alt+G组合键

黑色,是因为慢。等待较长时间,就能看到启动画面了