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

這兩個是參考值,我這板子可能還有其他外設要點功耗!。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM