您的位置:  首页 > 技术杂谈 > 正文

在芒果派麻雀全志D1s上运行国产开源rt-smart系统

2023-02-15 11:00 https://my.oschina.net/u/6169614/blog/7812059 神棍地海棠 次阅读 条评论

想必RT-Thread系统大家不陌生了,RT-Thread Smart(简称 rt-smart)是基于 RT-Thread 操作系统衍生的新分支,面向带 MMU,中高端应用的芯片,例如 ARM Cortex-A 系列芯片,MIPS 芯片,带 MMU 的 RISC-V 芯片等。rt-smart 在 RT-Thread 操作系统的基础上启用独立、完整的进程方式,同时以混合微内核模式执行。
官方文档:https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart

内核:rt_smart_kernel.bin

硬件:麻雀,MQ1或MQ1W

RT-smart包(自带编译器):mango_rtsmart_app.zip

1. 分区

使用fdisk分区。
将u盘挂载到ubuntu系统后,笔者设备路径是/dev/sdb。使用的32GB TF卡,扇区大小512字节,根据说明预留8M的空闲,那么计算得知分区扇区开始于:16384
命令:sudo fdisk /dev/sdb
选:o,n,p,1,16384,回车

Command (m for help): o
Created a new DOS disklabel with disk identifier 0x3668b987.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-62410751, default 2048): 16384
Last sector, +sectors or +size{K,M,G,T,P} (16384-62410751, default 62410751): 

Created a new partition 1 of type 'Linux' and of size 29.8 GiB.

Command (m for help): w
The partition table has been altered.

正确的分区效果如下:

mango@virtual:/dev$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 29.8 GiB, 31954305024 bytes, 62410752 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3668b987

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1       16384 62410751 62394368 29.8G 83 Linux
mango@virtual:/dev$ 

然后格式化sdb1:

$ sudo mkfs -t fat /dev/sdb1

2. 刷入RT-SMART内核

$ sudo dd if=rt_smart_kernel.bin of=/dev/sdb bs=1024
2888+1 records in
2888+1 records out
2957313 bytes (3.0 MB, 2.8 MiB) copied, 8.32574 s, 355 kB/s
$ sync

3. 启动RTT

此时将TF卡放入麻雀,串口0(底部排针的7,8脚),串口波特率500000,然后上电:

[26]HELLO! BOOT0 is starting!
[27]BOOT0 commit : fb73c68
[28]set pll start
[28]periph0 has been enabled
[29]set pll end
[30]board init ok
[30]ZQ value = 0x2f***********
[31]get_pmu_exist() = -1
[32]ddr_efuse_type: 0xa
[33][AUTO DEBUG] single rank and full DQ!
[34]ddr_efuse_type: 0xa
[35][AUTO DEBUG] rank 0 row = 13
[36][AUTO DEBUG] rank 0 bank = 4
[37][AUTO DEBUG] rank 0 page size = 2 KB
[37]DRAM BOOT DRIVE INFO: V0.24
[38]DRAM CLK = 528 MHz
[39]DRAM Type = 2 (2:DDR2,3:DDR3)
[40]DRAMC read ODT  off.
[40]DRAM ODT off.
[41]ddr_efuse_type: 0xa
[42]DRAM SIZE =64 M
[44]DRAM simple test OK.
[45]dram size =64
[45]card no is 0
[45]sdcard 0 line count 4
[46][mmc]: mmc driver ver 2021-04-2 16:45
[52][mmc]: Wrong media type 0x0
[53][mmc]: ***Try SD card 0***
[60][mmc]: HSSDR52/SDR25 4 bit
[61][mmc]: 50000000 Hz
[61][mmc]: 30474 MB
[62][mmc]: ***SD/MMC 0 init OK!!!***
[98]Loading boot-pkg Succeed(index=0).
[99]*******************TOC1 Item Message*************************
[100]Entry_name        = opensbi
[101]Entry_data_offset = 0x600
[102]Entry_data_len    = 0x188e0
[103]encrypt           = 0x0
[103]Entry_type        = 0x0
[104]run_addr          = 0x40000000
[105]index             = 0x0
[105]Entry_end         = 0x3b454949
[106]*************************************************************
[108]*******************TOC1 Item Message*************************
[109]Entry_name        = dtb
[110]Entry_data_offset = 0x19000
[111]Entry_data_len    = 0x7475
[111]encrypt           = 0x0
[112]Entry_type        = 0x0
[113]run_addr          = 0x40200000
[114]index             = 0x0
[114]Entry_end         = 0x3b454949
[115]*************************************************************
[117]*******************TOC1 Item Message*************************
[118]Entry_name        = kernel
[119]Entry_data_offset = 0x20600
[120]Entry_data_len    = 0xa6cf0
[120]encrypt           = 0x0
[121]Entry_type        = 0x0
[122]run_addr          = 0x40400000
[123]index             = 0x0
[123]Entry_end         = 0x3b454949
[124]*************************************************************
[126]Jump to second Boot.

OpenSBI v0.9-165-gefbc2b8
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : Allwinner D1 NeZha
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 24000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sunxi-wdt-reset
Platform Shutdown Device  : ---
Firmware Base             : 0x40000000
Firmware Size             : 248 KB
Runtime SBI Version       : 0.3

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000014008000-0x000000001400bfff (I)
Domain0 Region01          : 0x0000000014000000-0x0000000014007fff (I)
Domain0 Region02          : 0x0000000040000000-0x000000004003ffff ()
Domain0 Region03          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000040400000
Domain0 Next Arg1         : 0x0000000040200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcvsux
Boot HART Features        : scounteren,mcounteren,mcountinhibit,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 2048
Boot HART PMP Address Bits: 38
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b1ff
heap: [0x404fbdf4 - 0x41cfbdf4]
[I/I2C] I2C bus [i2c2] registered

 \ | /
- RT -     Thread Smart Operating System
 / | \     5.0.0 build Dec 31 2021
 2006 - 2020 Copyright by rt-thread team
lwIP-2.1.2 initialized!
SDC:hal_sdc_create host:000000004051bdf8 id:0
SDC:Not implement __mci_restore_io,798
SDC:Not imp hal_sdc_init,2218
SDC:hal_sdc_init,2251 no imp
SDC:hal_sdc_init,2259 no imp
SDC:SDC Host Capability:0x3820f Ocr avail:0x3f0000
SDC:SDC cd_mode:2 present_val:0
SDC:SDC id:0 dma_use:1 present:1
 driver version SD/MMC/SDIO Host Controller Driver(v0.27 2021-04-30 16:50) init ok.
card_detect insert
SD:mmc_card_create card:000000004052e1a8 id:0
SDC:Not implement __mci_restore_io,798
SDC:SDC clock=400000 kHz,src:0, n:1, m:14
SDC:SDC clock=400000 kHz,src:0, n:1, m:14
SD:***** Try sd *****
SD:card ocr: ffffffffc0ff8000
SD:Card CID number:55
SD:card raw cid:
SD:card raw csd:
SD:card raw scr:
SD:card raw SD status:
SDC:SDC clock=50000000 kHz,src:1, n:0, m:5
SD:card is switched to high speed mode, clk:50000 KHz
SD:Set bus width type: 2
SD:
============= card information ==============
SD:Card Type     : SDHC
SD:Card Spec Ver : 5.0
SD:Card RCA      : 0x0001
SD:Card OCR      : 0x40ff8000
SD:    vol_window  : 0x00ff8000
SD:    to_1v8_acpt : 0
SD:    high_capac  : 0
SD:Card CSD      :
SD:    speed       : 50000 KHz
SD:    cmd class   : 0x5b5
SD:    capacity    : 30474MB
SD:Card CUR_STA  :
SD:    speed_mode  : HS: 50 MHz
SD:    bus_width   : 2
SD:    speed_class : 10
SD:=============================================
SD:***** sd init ok *****
Initial card success
[I/sal.skt] Socket Abstraction Layer initialize success.
file system initialization done!
gt9xx_probe
Hello RISC-V
msh />[D/TOUCH.gt9xx] 39 31 31 0 0
[I/TOUCH.gt9xx] Found chip gt911
[I/TOUCH.gt9xx] GT9xx Config version: 0x00
[I/TOUCH.gt9xx] GT9xx Sensor id: 0xFF

msh />

4. 运行应用程序

祭出祖传hello程序:根据说明自行编译,输出为:hello.elf 文件,直接
拷贝到TF卡的文件系统中
QQ截图20220104132056.png
然后重新将tf卡放进麻雀,开机启动:

msh />ls
Directory /:
System Volume Information<DIR>
etc                 <DIR>
hello.elf           237512
vi.elf              398544
msh />
msh />./hello.elf
msh />hello world!

至此,hello程序就运行起来了!

5. 扩展之编译

  • 请在Linux下使用此开发环境包(已经自带64位Linux系统的编译器环境),如果要在Windows下使用,请自行配置安装编译在tools目录下,然后参照smart-env.sh里的脚本配置好环境变量。
  • 在Linux下使用步骤:
    • 首先执行source smart-env.sh riscv64,也可以根据自己的环境稍作修改。
    • 进入userapp目录进行应用编译,例如编译自带的hello应用程序,只需要执行scons --app=hello
    • 编译好的应用程序会生成在root/bin目录下,将其拷贝到SD卡中(注意是8M偏移的起始分区),然后进入rt-smart系统中,启动挂载成功后即可运行。

本帖整理自全志在线:https://bbs.aw-ol.com/topic/908/

展开阅读全文
  • 0
    感动
  • 0
    路过
  • 0
    高兴
  • 0
    难过
  • 0
    搞笑
  • 0
    无聊
  • 0
    愤怒
  • 0
    同情
热度排行
友情链接