系统介绍:
RT-Thread是一个集实时操作系统(RTOS)内核、中间件组件的物联网操作系统;
rt-thread特点:
资源占用极低,超低功耗设计,组件丰富,支持高性能应用,跨平台;类似vxWorks 6.8bsp;
参考书记:<<嵌入式实时操作系统:RT-Thread设计与实现>>rtt创始人熊谱翔编写;
rt-thread官网:
https://www.rt-thread.org/
源码地址:https://github.com/RT-Thread/rt-thread.git
重要配置文件:.git/config(url = https://github.com/RT-Thread/rt-thread.git);
源码目录文件
jdm@jdm:~/os/rt-thread/rt-thread$ ls
AUTHORS
bsp //各个平台的工程目录
ChangeLog.md
components //组件源码目录
documentation //文档目录
examples //测试用例目录
include //头文件目录
Jenkinsfile Kconfig
libcpu //存放各个平台底层启动程序,线程切换程序
LICENSE README.md README_zh.md
src //rtt内核源码目录
tools //脚本目录
针对体系结构的bsp介绍:
jdm@jdm:~/os/rt-thread/rt-thread/bsp/ls2kdev$ ls //此为工程bsp目录
applications 应用层代码
drivers //rt-thread提供的底层驱动
figures //此目录有loongsonpi的插图
Kconfig ls2k_ram.lds
README.md //应该关注的说明文档
rtconfig.h rtconfig.py SConscript Sconstruct
ubuntu开发环境搭建:
安装qemu,命令如下:
sudo apt-get install qemu
安装scons,命令如下:
sudo apt-get install scons
安装 ncurses 库,使用命令:
sudo apt-get install libncurses5-dev
下面编译以龙芯2K1000为例:
1.参照README.md配置文件进行配置,主要是下载龙芯编译器,并配置rtconfig.py指定EXEC_PATH编译器路径;
2.配置完后,如果是刚安装的64位系统,会报错如下:
root@jdm:/home/jdm/os/rt-thread/rt-thread/bsp/ls2kdev# scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
CC build/applications/main.o
sh: 1: mips-sde-elf-gcc: not found
scons: *** [build/applications/main.o] Error 127
scons: building terminated because of errors.
此为未安装32位库的原因,安装即可,下面是ubuntu1604的安装命令:
sudo apt-get install lib32z1
sudo apt-get install lib32ncurses5
3.上述完后,可以直接通过scons编译工程,编译完如下:
也可以在编译之前通过scons –menuconfig配置驱动组件等,界面如下:
启动rtt,在龙芯2k上进入pmon后加载编译好的rtthread.elf文件,然后输入g,即可进入rtt;
rtt系统命令:
msh />help
RT-Thread shell commands:
reboot - reset cpu
poweroff - shutdown cpu
list_fd - list file descriptor
clear - clear the terminal screen
version - show RT-Thread version information
list_thread - list thread
list_sem - list semaphore in system
list_event - list event in system
list_mutex - list mutex in system
list_mailbox - list mail box in system
list_msgqueue - list message queue in system
list_mempool - list memory pool in system
list_timer - list timer in system
list_device - list device in system
exit - return to RT-Thread shell mode.
help - RT-Thread shell help.
ps - List threads in the system.
free - Show the memory usage in the system.
ls - List information about the FILEs.
cp - Copy SOURCE to DEST.
mv - Rename SOURCE to DEST.
cat - Concatenate FILE(s)
rm - Remove(unlink) the FILE(s).
cd - Change the shell working directory.
pwd - Print the name of the current working directory.
mkdir - Create the DIRECTORY.
mkfs - format disk with file system
df - disk free
echo - echo string to file
ifconfig - list the information of all network interfaces
ping - ping network host
dns - list and set the information of dns
netstat - list the information of TCP / IP
查看系统时间;
msh />date
Wed Nov 3 17:56:30 B275
列举所有的设备
msh />list_device
device type ref count
------------------------------ -------------------- ----------
e0 Network Interface 0
rtc RTC 0
pin Miscellaneous Device 0
uart Character Device 2
rtt使用总结:
龙芯2k上的rtt bsp,可以直接在官网上下载,有人已经移植好了(哈哈哈,小白也蹭了一波热度),跑起来不难,但目前能用的驱动比较少,仅仅能起,如果基于此开发的话,甚至想要把这个架构做的标准,高效和贴近需求,工作量和难度还有很多很多.
TO BE CONTINUED