liteos 从入门到放弃

这两天收到一份sdk,hisi 3516cv200 liteos的sdk

正好手头有硬件,就随便编译玩玩.

解压sdk.

Hi3518E_SDK_V5.0.5.0

ll@ubuntu:~/work2016/liteos/Hi3518E_SDK_V5.0.5.0$ ls -lh
total 32K
drwxrwxr-x 4 ll ll 4.0K Oct 25 19:15 drv
drwxrwxr-x 8 ll ll 4.0K Oct 25 19:16 mpp
drwxrwxr-x 4 ll ll 4.0K Oct 25 19:16 osal
drwxrwxr-x 6 ll ll 4.0K Feb 27 09:54 osdrv
drwxrwxr-x 2 ll ll 4.0K Oct 25 19:16 package
drwxrwxr-x 2 ll ll 4.0K Oct 25 19:16 scripts
-rwxrwxr-x 1 ll ll  675 Oct 25 19:16 sdk.cleanup
-rwxrwxr-x 1 ll ll 2.2K Oct 25 19:16 sdk.unpack

和其他版本sdk也没什么区别.

1.安装交叉编译工具

交叉工具在osdrv/toolchain 和以前版本没有区别,

ll@ubuntu:~/work2016/liteos/Hi3518E_SDK_V5.0.5.0/osdrv/toolchain$ ls -lh
total 273M
-rwxrwxr-x 1 ll ll 1.9K Oct 25 19:16 arm-hisiv500-linux.install
-rw-rw-r-- 1 ll ll 273M Oct 25 19:16 arm-hisiv500-linux.tar.bz2

 

2.目录结构和以前sdk版本没有区别,唯一的区别就多了一个liteos 目录,这个目录就是liteos 内核所在目录

ll@ubuntu:~/work2016/liteos/Hi3518E_SDK_V5.0.5.0/osdrv/opensource$ ls -lh
total 8.0K
drwxrwxr-x 3 ll ll 4.0K Feb 27 09:56 liteos
drwxrwxr-x 3 ll ll 4.0K Feb 27 09:54 u-boot

3.编译整个系统,具体的请参考01.software\board\document_cn\Hi35xx Huawei LiteOS开发环境用户指南.pdf 这个文档

统一编译。用户需要在开发包解压根目录下输入:“ make”。 make 工具将会根据当
Makefile 设置编译进行统一编译,统一编译结果将在 pub 目录下得到两个目录
boot tools。两者分别保存 U-boot 镜像与文件系统镜像制作工具。由统一编译
生成的 U-boot 镜像可直接用于烧写到单板,文件系统镜像工具可用于制作 yaffs
jffs2 文件系统镜像,具体使用可参考本文档 4.2.3 挂载文件系统镜像

因为makefile都配置好了,直接make就可以了..编译整个sdk相当快,因为liteos是假开源,都是给的.a文件.都没有源代码...

4.编译boot,这个有其他sdk版本uboot没区别.可以共用.

 

5.编译sample.liteos 版本和linux版本的mpp基本一样,还有流程都没区别...我这儿编个venc玩玩.

ll@ubuntu:~/work2016/liteos/Hi3518E_SDK_V5.0.5.0/mpp/sample/venc$ ls -lh
total 12M
-rw-rw-r-- 1 ll ll  173 Oct 25 19:16 Makefile
-rwxrwxr-x 1 ll ll 4.3M Feb 27 14:16 sample_venc
-rwxrwxr-x 1 ll ll 3.5M Feb 27 14:16 sample_venc.bin
-rw-rw-r-- 1 ll ll  47K Oct 25 19:16 sample_venc.c
-rw-rw-r-- 1 ll ll 3.7M Feb 27 14:16 sample_venc.map
-rw-rw-r-- 1 ll ll  40K Feb 27 14:16 sample_venc.o
sample_venc.bin 就是编译出来的程序,有4.3M,这个程序可以理解为linux的kernel+rootfs+venc所有的功能..uboot起来后直接加载这个玩意就可以跑venc这个app了.

6.烧写uboot.直接用hiburn工具搞进去.uboot sdk下已经自带了.也可以自己编译,编译流程和以前版本sdk基本没区别.

7.烧写sample_venc.bin 可以用网络,因为我这没有以太网接口,也只能用hiburn+com,烧写在1M开始的地方.
8.修改bootargs.
hisilicon # printenv 
bootargs=mem=160M console=ttyAMA0,115200 root=/dev/mtdblock3 rootfstype=jffs2 mtdparts=hi_sfc:1M(boot),2688K(kernel),384K(cfg),12M(rootfs)
bootdelay=1
baudrate=115200
ethaddr=00:00:23:34:45:66
ipaddr=192.168.1.10
serverip=192.168.1.2
netmask=255.255.255.0
bootfile="uImage"
bootcmd=sf probe 0;sf read 0x80008000 0x100000 0x700000;go 0x80008000
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Oct 25 2016 - 19:13:43)

Environment size: 438/262140 bytes

和linux也没啥差别

bootcmd=sf probe 0;sf read 0x80008000 0x100000 0x700000;go 0x80008000

spi flash 如下

setenv bootcmd 'sf probe 0;sf read 80008000 0x100000 0x700000;go 80008000'
saveenv


这行是关键行,因为我的sample_venc.bin 烧写在1M的地址~go 80008000这个写死的,因为liteos提供的是.a,所以你没没法修改了....

9.保存bootargs 系统就可以起来了.起来log如下.

System startup


U-Boot 2010.06 (Oct 25 2016 - 19:13:43)

Check Flash Memory Controller v100 ... Found
SPI Nor(cs 0) ID: 0xc2 0x20 0x18
Block:64KB Chip:16MB Name:"MX25L128XX"
SPI Nor total size: 16MB
MMC:   
EMMC/MMC/SD controller initialization.
Card did not respond to voltage select!
No EMMC/MMC/SD device found !
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0 
16384 KiB hi_fmc at 0:0 is now current device

## Starting application at 0x80008000 ...
********hello Huawei LiteOS ARM926********

version : Huawei LiteOS V100R002C00SPC001B011
open-version : Huawei LiteOS 1.2.2
build data : Feb 27 2017 09:56:29

**********************************
osAppInit
os vfs init ...
Mount procfs finished.
uart init ...
shell init ...

Huawei LiteOS # spi nor flash init ...
Spi Nor ID:0xC2 0x20 0x18 0xC2 0x20 0x18 0xC2 0x20 
Spi Nor Flash Info:
Name:"MX25L128XX" Size:16MB Block:64KB
<5>Inode #2 was a directory with children - removing those too...
<5>Inode #5 was a directory with children - removing those too...
<5>Inode #6 was a directory with children - removing those too...
<5>Inode #8 was a directory with children - removing those too...
<5>Inode #9 was a directory with children - removing those too...
<5>Inode #139 was a directory with children - removing those too...
<5>Inode #14 was a directory with children - removing those too...
<5>Inode #143 was a directory with children - removing those too...
<5>Inode #18 was a directory with children - removing those too...
<5>Inode #19 was a directory with children - removing those too...
<5>Inode #23 was a directory with children - removing those too...
<5>Inode #151 was a directory with children - removing those too...
<5>Inode #24 was a directory with children - removing those too...
<5>Inode #152 was a directory with children - removing those too...
<5>Inode #153 was a directory with children - removing those too...
<5>Inode #163 was a directory with children - removing those too...
<5>Inode #177 was a directory with children - removing those too...
<5>Inode #589 was a directory with children - removing those too...
<5>Inode #594 was a directory with children - removing those too...
<5>Inode #227 was a directory with children - removing those too...
<5>Inode #363 was a directory with children - removing those too...
<5>Inode #365 was a directory with children - removing those too...
<5>Inode #366 was a directory with children - removing those too...
<5>Inode #367 was a directory with children - removing those too...
<5>Inode #368 was a directory with children - removing those too...
<5>Inode #587 was a directory with children - removing those too...
<5>Inode #546 was a directory with children - removing those too...
spi bus init ...
i2c bus init ...
gpio init ...
dmac init
random init ...
net init ...

Calling lwIPRegSecSspCbk
enter hisi_eth_init!

hisi_eth init begin.
hisi_eth: User did not set phy mode, use default=rmii
hisi_eth: User did not set phy addr, auto scan...
Can't find PHY device - id: ffffffff
cmd_startnetwork : DHCP_BOUND finished
usb init ...

******** usb_init in **********
usb v2.10 2016-09-18 10:28
usb 0 ~+ 256 KB
*** usb init memory error!! ***

sd/mmc host init ...

********mmc host init ! ********
Now shell working dir is :/
g_sys_mem_addr_end=0x82000000,
done init!
Date:Feb 27 2017.
Time:14:16:10.
<6>Hisilicon Media Memory Zone Manager
load sys.ko for Hi3518EV200...OK!
load tde.ko ...OK!
load region.ko for Hi3518EV200...OK!
load vgs.ko for Hi3518EV200...OK!
load viu.ko for Hi3518EV200...OK!

 Do not support tasklet. 
ISP Mod init!
load vpss.ko for Hi3518EV200...OK!
load vou.ko for Hi3518EV200...OK!
Load hifb.ko OK!
load rc.ko for Hi3518EV200...OK!
load venc.ko for Hi3518EV200...OK!
load chnl.ko for Hi3518EV200...OK!
load h264e.ko for Hi3518EV200...OK!
load jpege.ko for Hi3518EV200...OK!
Load hi_cipher.ko success. mipi_init
init phy power successful!
load hi_mipi driver successful!
acodec [acodec_device_init ,1091]: misc addr:0x20120000, acodec addr:0x201200c4

acodec [acodec_device_init ,1107]: crg addr:0x20030000, acodec crg addr:0x2003008c

load ive.ko for Hi3518EV200...OK!
SDK init ok...

Huawei LiteOS # 

系统起来相当快,大概3秒的样子吧。所有的都加载完成了..回车可以输入命令.

支持的命令主要有下面这些.不能tab补全,像我这样拼音不太好的,输一条目录好苦逼.

Huawei LiteOS # help
*******************shell commands:*************************

arp           call          cat           cat_logmpp    cd            cp            cpup          dns           
findsym       format        free          help          himd          himm          hwi           i2c_read      
i2c_write     ifconfig      lddrop        ldinit        ls            mclose        memcheck      mkdir         
mopen         mount         nand_bad      netstat       ntpdate       partition     ping          pwd           
readreg       reset         rm            rmdir         sample        sem           ssp_read      ssp_write     
statfs        swtmr         sync          systeminfo    task          telnet        tftp          touch         
uart_close    uart_config   uart_read     uart_write    umount        uname         writeproc     writereg      

 

10.执行sample,直接在shell里面输入sample 会车,就会跑venc这个app了.

因为代码里面sample 注册了一个shell的回调函数.这个地方我也琢磨了下代码,才明白怎么运行sample.大致代码如下

void app_sample(int argc, char **argv )
{
    int i = 0, ret = 0;
    int len = 0;
    char *pch = NULL;
    TSK_INIT_PARAM_S stappTask;

    if(argc < 1) {
        dprintf("illegal parameter!\n");
    }

    if (taskid != -1) {
        dprintf("There's a app_main task existed.");
    }
    args_buf_t = zalloc(ARG_BUF_LEN_T);
    memset(&stappTask, 0, sizeof(TSK_INIT_PARAM_S));
    pch = args_buf_t;
    for(i=0; i<ARGS_SIZE_T; i++) {
        ptask_args[i] = NULL;
    }
    argc++;
    ptask_args[0] = "app_sample";

    for(i = 1; i < argc; i++)
    {
        len =  strlen(argv[i-1]);
        memcpy(pch , argv[i-1], len);
        ptask_args[i] = pch;
        //keep a '\0' at the end of a string.
        pch = pch + len + 1;
        if (pch >= args_buf_t +ARG_BUF_LEN_T) {
            dprintf("args out of range!\n");
            break;
        }
    }
    memset(&stappTask, 0, sizeof(TSK_INIT_PARAM_S));
    stappTask.pfnTaskEntry = (TSK_ENTRY_FUNC)com_app;
    stappTask.uwStackSize  = 0x80000;
    stappTask.pcName = "app_sample";
    stappTask.usTaskPrio = 10;
    stappTask.uwResved   = LOS_TASK_STATUS_DETACHED;
    stappTask.auwArgs[0] = argc;
    stappTask.auwArgs[1] = (UINT32)ptask_args;
    ret = LOS_TaskCreate((UINT32 *)&taskid, &stappTask);

    dprintf("camera_Task %d,ret is %d\n", taskid,ret);

    //chdir("/sd0");
    chdir("/nfs");

}

void sample_command(void)
{
    osCmdReg(CMD_TYPE_EX, "sample", 0, (CMD_CBK_FUNC)app_sample);
}
View Code

 

注意最后一行代码,因为这个玩意没有文件系统的概念..所以venc 里面程序的在根目录下生存.h264文件也没法生成,刚刚开始的时候我改成写入sd卡了.后面在代码里面发现这个,估计这个切换到哪儿,哪儿就是根目录吧...这个是猜的...可能不靠谱...

chdir("/nfs");

 

11.到这儿...就可以录像拍照了....

 

总结下:

主要功能都可以去sdk下瞧瞧文档,没怎么开源,不敢轻易上这系统做商业产品.

速度确实快.

从linux版本切换到这儿也很简单,主要就看sdk文档就可以了.

 

说下功耗吧:

3516cv200 + mn34227 :不跑编码110mA 5V

跑venc,1*1080P H264 + 1*VGA H264.  +sd写入:180mA-200mA 5V

这两个是参考值,我这板子可能还有其他外设要点功耗!。

 

posted @ 2017-02-28 17:56  码工木木  阅读(37797)  评论(3编辑  收藏  举报