Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
rt-smart
全志
全志_RISCV_D1_D1S
优雅の在D1S上运行RT-Smart
1.00
发布于 2022-11-01 18:31:10 浏览:3312
订阅该版
[tocm] # 【优雅】D1S上运行RT-Smart ### 前言 > 最近在学习 RT-Smart ,正巧有在全志开发者论坛看到这么一篇帖子[【惊】在麻雀上运行国产rt-smart系统](https://debugdump.com/topic/908/惊-在麻雀上运行国产rt-smart系统?_=1662991709982&lang=zh-CN),看到很多人都在关注 D1S 在 Smart 上的运行情况。如今该 BSP 已经合并到 [RT-Thread](https://github.com/RT-Thread/rt-thread) 主仓库,于是我来展示一下 D1S 运行 RT-Smart 的步骤,供大家参考~ 做嵌入式开发的人对 `RT-Thread` 操作系统平台应该都是非常熟悉的,而 RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简称为 rt-smart,它把应用从内核中独立出来,形成独立的用户态应用程序,并具备独立的地址空间。相比较于 linux 操作系统而言,RT-Thread Smart 是实时的操作系统。 ### 环境及所需工具 **软件环境:** - Ubuntu20.0.4 **硬件环境:** - 全志F系列—F133 芯片 - 柿饼派M7 - 麻雀MQ ### 下载代码 下载 RT-Smart 用户态应用代码: ``` git clone https://github.com/RT-Thread/userapps.git ```  进入到 `userapps` 目录,克隆 RT-Thread 仓库 ```shell git clone https://github.com/RT-Thread/rt-thread.git ```  ### 配置工具链 在 userapps\tools 目录下运行 `get_toolchain.py` 的脚本,会下载对应的工具链并展开到 userapps\tools\gun_gcc 目录。后面的工具链名称可以是 arm | riscv64。 因为 D1S 是 RISCV-64 架构的,所以输入下面的命令: ``` python3 get_toolchain.py riscv64 ``` 在 userapps 目录下,运行 `smart-env.sh` 配置工具链路径,目前支持的参数可以是 arm | riscv64 ``` source smart-env.sh riscv64 ```  ### 编译内核程序 进入 `rt-thread/bsp/allwinner/d1s` 目录下,执行以下命令拉取一下软件包 * 注:若系统没有安装 env,需要手动输入 `scons --menuconfig` 命令手动下载 env ```shell source ~/.env/env.sh pkgs --update ```  使用 scons 命令进行编译,编译成功后会在 `userapps/rt-thread/bsp/allwinner/d1s` 目录下生成 sd.bin,这个文件就是我们需要烧录到开发板中的文件,它包括了 uboot.dtb,opensbi,rtthread.bin。 ### 烧录程序 接下来介绍两种烧录方式: * 第一种针对使用 EMMC 启动方式的 D1S,例:柿饼派M7 详见:[D1S/README.md](https://github.com/RT-Thread/rt-thread/blob/master/bsp/allwinner/d1s/README-M7.md) 文档中的 **真实硬件环境搭建** 章节。 --- * 第二种是针对使用 TF卡 作为启动方式的开发板,例:麻雀 D1S 1、首先准备一张容量在 128G 以内的空白 TF卡 2、使用 fdisk 分区。将 TF卡 挂载到 ubuntu 系统后,使用 df 查看设备路径。笔者使用的 32GB TF卡,扇区大小 512 字节,我们需要预留前 8M 的空间,那么计算得知分区扇区开始于:16384,使用命令:`sudo fdisk /dev/sdb`,选择:o,n,p,1,16384,回车。 ```shell 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. ``` 正确的分区效果如下:  然后格式化 sdb1 分区为 fat32 格式: ```shell $ sudo mkfs -t fat /dev/sdb1 ``` 这里可以使用 **Gparted** 工具可视化查看一下分区状况:  3、接下来使用以下命令烧录 RT-SMART 内核: ```shell sudo dd if=boot0_sdcard_sun20iw1p1.bin of=/dev/sdb bs=1024 seek=8 sudo dd if=sd.bin of=/dev/sdb bs=1024 seek=56 ``` * 注:**boot0_sdcard_sun20iw1p1.bin** 文件在 `userapps/rt-thread/bsp/allwinner/d1s/tools` 路径下 * 这里的 /dev/sdb 设备要根据自己的选择 下面是烧录成功的显示:  ### 启动 RT-Smart 方式一(EMMC)启动: 串口0 波特率 500000,然后上电即可。 --- 方式二(TF 卡)启动: 此时将 TF 卡放入开发板,串口0(底部排针的7,8脚),串口波特率 500000,然后上电,如下 RT-Smart 已经成功启动!(真的快,啪的一下就进入系统了  ```shell \ | / - RT - Thread Smart Operating System / | \ 5.0.0 build Nov 1 2022 2006 - 2022 Copyright by rt-thread team lwIP-2.0.2 initialized! hal_sdc_create 0 card_detect insert Initial card success. capacity :30436MB sdmmc bytes_per_secotr:200, sector count:3b72400 found part[0], begin: 8388608, size: 29.732GB found partition:sd0 of mbr at offset 0000000000004000, size:0000000003b6e400 hal_sdc_create 1 card_detect insert Initial card failed!! [E/drv-sdmmc] init sdmmc failed! [E/drv-sdmmc] sdmmc_init failed! [I/sal.skt] Socket Abstraction Layer initialize success. [D/FAL] (fal_flash_init:47) Flash device | sdcard0 | addr: 0x00000000 | len: 0x76e480000 | blk_size: 0x00000200 |initialized finish. [I/FAL] ==================== FAL partition table ==================== [I/FAL] | name | flash_dev | offset | length | [I/FAL] ------------------------------------------------------------- [I/FAL] | download | sdcard0 | 0x00800000 | 0x00800000 | [I/FAL] | easyflash | sdcard0 | 0x01000000 | 0x00100000 | [I/FAL] | filesystem | sdcard0 | 0x01100000 | 0x00c00000 | [I/FAL] ============================================================= [I/FAL] RT-Thread Flash Abstraction Layer initialize success. Hello RISC-V [W/DBG] disp:[parser_disp_init_para 575]of_property_read screen1_output_type fail msh />Mount "sd0p0" on "/" success msh /> ``` ### 编译用户态程序 进入 `userapps` 目录下,使用 scons 编译用户态程序,编译好的文件会生成在 `root/bin` 目录下。  ### 运行用户态程序 从 `root/bin` 目录下拷贝出祖传 hello 程序,到 TF卡 的文件系统中。  拔出 TF 卡,插入到开发板,上电。即可体验属于自己的 helloworld 程序了。 ```shell msh /bin>ls Directory /bin: dbkit_client.elf 616960 elmFATKit.elf 373880 em.elf 585504 hdc_test.elf 339976 hello.elf 339624 lvgl.elf 1382168 lwIPKit.elf 976784 mmapctrl.elf 339976 ntp.elf 363560 ping.elf 344208 pmq.elf 345176 pong.elf 339624 syslog.elf 364736 syslogd.elf 377560 vi.elf 446568 webclient.elf 358048 msh /bin> msh /bin>hello.elf msh /bin>hello world! ``` ### Q&A --- Q:不小心把 TF 卡分区烧录错了/如何格式化分区? A:首先使用 `sudo fdisk /dev/sdX` 命令,输入 p ,查看 SD卡 现有分区,如下图该 SD卡有一个分区。  然后输入 d,删除这个分区。  使用 `sudo fdisk -l` 查看SD卡分区情况,可以看到已经没有分区了,接着按照教程方式重新制作分区即可。  更多 QA 可详见:[D1S/README.md](https://gitee.com/rtthread/rt-thread/blob/rt-smart/bsp/allwinner/d1s/README.md) 文档中的 **QA** 章节。
20
条评论
默认排序
按发布时间排序
登录
注册新账号
关于作者
Rb君
这家伙很懒,什么也没写!
文章
19
回答
15
被采纳
0
关注TA
发私信
相关文章
1
rt-smart发布时间
2
rt-smart qemu-vexpress-a9 编译报错
3
rt-smart分支编译rasp4-32bsp报错
4
rt-smart qemu-vexpress-a9 win10编译脚本问题
5
rt-smart qemu-vexpress-a9 linux 下crtl+c
6
rt-smart + pthread 编译报错
7
rt-smart的rt_channel实现问题
8
关于rt-smart的musl-libc
9
RT-Smart Windows 编译 qemu-vexpress-a9 出错
10
用户程序在RT-Smart存在的方式
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
机器人操作系统 (ROS2) 和 RT-Thread 通信
4
五分钟玩转RT-Thread新社区
5
国产MCU移植系列教程汇总,欢迎查看!
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
热门标签
RT-Thread Studio
串口
LWIP
Env
SPI
AT
FinSH
Bootloader
CAN总线
ART-Pi
Hardfault
文件系统
USB
DMA
RT-Thread
线程
SCons
RT-Thread Nano
stm32
MQTT
ESP8266
ota
UART
RTC
freemodbus
rtthread
rt-smart
packages_软件包
I2C
WIZnet_W5500
flash
cubemx
FAL
定时器
BSP
AB32VG1
PWM
ADC
SDIO
msh
socket
LVGL
keil
Debug
C++_cpp
中断
编译报错
SFUD
SMP
MicroPython
本月问答贡献
出出啊
1431
个答案
317
次被采纳
小小李sunny
1342
个答案
267
次被采纳
crystal266
505
个答案
149
次被采纳
whj467467222
1212
个答案
142
次被采纳
张世争
590
个答案
135
次被采纳
本月文章贡献
出出啊
3
篇文章
5
次点赞
小小李sunny
1
篇文章
1
次点赞
crystal266
1
篇文章
3
次点赞
whj467467222
2
篇文章
4
次点赞
张世争
6
篇文章
14
次点赞
回到
顶部
发布
问题
投诉
建议
回到
底部