Generation of Rootfs

From Release_to_customer.sh As you can see, when the flash type is NAND and the chip type is ssd201, and the FastBoot mode is not turned on, the following steps are executed in the “project “ directory:

# ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.glibc.011a.64

The Release_to_customer.sh script content of project in is as follows:

#build project
cd ${RELEASEDIR}/project
if [ "${flashtype}" = "nor" ]; then
    if [ "${fastboot}" = "fastboot" ]; then
        echo test fastboot
        ./setup_config.sh ./configs/nvr/i2m/8.2.1/nor.glibc-ramfs.011a.64
    else
        if [ "${project}" = "ssd201" ]; then
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/nor.glibc-squashfs.011a.64
        fi
        if [ "${project}" = "ssd202" ]; then
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/nor.glibc-squashfs.011a.128
        fi
    fi
else
    if [ "${fastboot}" = "fastboot" ]; then
        echo fast project
        if [ "${project}" = "ssd201" ]; then 
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.ram-glibc-squashfs.011a.64
        elif [ "${project}" = "ssd202" ]; then    
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.ram-glibc-squashfs.011a.128
        fi
    else
        if [ "${project}" = "ssd201" ]; then
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.glibc.011a.64
        fi
        if [ "${project}" = "ssd202" ]; then
            ./setup_config.sh ./configs/nvr/i2m/8.2.1/spinand.glibc.011a.128
        fi
    fi
# vi project/configs/nvr/i2m/8.2.1/spinand.glibc.011a.64


spinand.glibc.011a.64 defines:
IMAGE_CONFIG(Partition configuration)=spinand.ubifs.p2.partition.config
CUSTOMER_TAILOR(APP configuration)=nvr_i2m_display_glibc_tailor.mk
BOOTLOGO_FILE(logo file name)=sigmastar1024_600.jpg
DISP_OUT_NAME(Screen model)=SAT070CP50


  • IMAGE_CONFIG

    # vi project/image/configs/i2m/spinand.ubifs.p2.partition.config

    The spinand.ubifs.p2.partition.config contents are as follows:

      IMAGE_LIST = cis ipl ipl_cust uboot logo kernel rootfs miservice customer appconfigs
      OTA_IMAGE_LIST = ipl ipl_cust uboot logo kernel miservice customer appconfigs
      FLASH_TYPE = spinand
      UBI_MLC_TYPE = 0
      PAT_TABLE  = ubi
      PHY_TEST = no
      #overwrite CIS(BL0,BL1,UBOOT) PBAs
      CIS_PBAs = 10 0 0
      CIS_COPIES = 5
      USR_MOUNT_BLOCKS:=miservice customer appconfigs
      ENV_CFG = /dev/mtd6 0 0x20000 0x60000
    
      cis$(RESOUCE) = $(IMAGEDIR)/cis.bin
      cis$(DATASIZE) = 0x40000
      cis$(PGSIZE) = 2k
      cis$(COPIES) = $(CIS_COPIES)
      cis$(PATSIZE) = 0x140000
      cis$(BOOTTAB) = $(ipl$(MTDPART)),$(ipl_cust$(MTDPART)),$(uboot$(MTDPART))
      cis$(SYSTAB) = $(key_cust$(MTDPART)),$(logo$(MTDPART)),$(kernel$(MTDPART)),-(UBI)
    
      ipl$(RESOUCE) = $(PROJ_ROOT)/board/$(CHIP)/boot/ipl/IPL.bin
      ipl$(DATASIZE) = 0x20000
      ipl$(COPIES) = 3
      ipl$(BKCOUNT) = 2
      ipl$(PATSIZE) = $(call multiplyhex, $(ipl$(COPIES)), $(ipl$(DATASIZE)))
      ipl$(PATCOUNT) = 2
      ipl$(MTDPART) = $(ipl$(DATASIZE))@$(cis$(PATSIZE))(IPL0)$(ipl$(BKCOUNT)),$(ipl$(DATASIZE))(IPL1)$(ipl$(BKCOUNT))
      ipl$(OTABLK) = /dev/mtdblock0 /dev/mtdblock1
    
      ipl_cust$(RESOUCE) = $(PROJ_ROOT)/board/$(CHIP)/boot/ipl/IPL_CUST.bin
      ipl_cust$(DATASIZE) = 0x20000
      ipl_cust$(COPIES) = 3
      ipl_cust$(BKCOUNT) = 2
      ipl_cust$(PATSIZE) = $(call multiplyhex, $(ipl_cust$(COPIES)), $(ipl_cust$(DATASIZE)))
      ipl_cust$(PATCOUNT) = 2
      ipl_cust$(MTDPART) = $(ipl_cust$(DATASIZE))(IPL_CUST0)$(ipl_cust$(BKCOUNT)),$(ipl_cust$(DATASIZE))(IPL_CUST1)$(ipl_cust$(BKCOUNT))
      ipl_cust$(OTABLK) = /dev/mtdblock2 /dev/mtdblock3
    
      uboot$(RESOUCE) = $(PROJ_ROOT)/board/$(CHIP)/boot/$(FLASH_TYPE)/uboot/u-boot_$(FLASH_TYPE).xz.img.bin
      uboot$(DATASIZE) = 0x40000
      uboot$(COPIES) = 3
      uboot$(BKCOUNT) = 4
      uboot$(PATSIZE) = $(call multiplyhex, $(uboot$(COPIES)), $(uboot$(DATASIZE)))
      uboot$(PATCOUNT) = 2
      uboot$(MTDPART) =$(uboot$(DATASIZE))(UBOOT0)$(uboot$(BKCOUNT)),$(uboot$(DATASIZE))(UBOOT1)$(uboot$(BKCOUNT)),0x60000(ENV)
      uboot$(OTABLK) = /dev/mtdblock4 /dev/mtdblock5
    
      wifi24mclkcmd = mw 1f001cc0 11
      wifirstoffcmd = gpio out 8 0
      wifirstoncmd = gpio out 8 1
    
      key_cust$(PATSIZE) = 0x20000
      key_cust$(MTDPART) = $(key_cust$(PATSIZE))(KEY_CUST)
    
      logo$(RESOUCE) = $(IMAGEDIR)/logo
      logo$(PATSIZE) = 0x60000
      logo$(MTDPART) = $(logo$(PATSIZE))(LOGO)
      logo$(OTABLK) = /dev/mtdblock8
    
      kernel$(RESOUCE)   = $(PROJ_ROOT)/release/$(PRODUCT)/$(CHIP)/$(BOARD)/$(TOOLCHAIN)/$(TOOLCHAIN_VERSION)/bin/kernel/$(FLASH_TYPE)/uImage.xz
      kernel$(PATSIZE)   = 0x500000
      kernel$(BOOTENV)   = $(KERNEL_BOOT_ENV)
      kernel$(MTDPART)   = $(kernel$(PATSIZE))(KERNEL),$(kernel$(PATSIZE))(RECOVERY)
      kernel$(OTABLK) = /dev/mtdblock9
    
      rootfs$(RESOUCE)   = $(OUTPUTDIR)/rootfs
      rootfs$(FSTYPE)    = ubifs
      rootfs$(PATSIZE)   = 0xA00000
      rootfs$(BOOTENV)   = console=ttyS0,115200 ubi.mtd=UBI,2048 root=ubi:rootfs ro rootfstype=ubifs init=/linuxrc rootwait=1
    
      miservice$(RESOUCE)   = $(OUTPUTDIR)/miservice/config
      miservice$(FSTYPE)    = ubifs
      miservice$(PATSIZE)   = 0xA00000
      miservice$(MOUNTTG)  = /config
      miservice$(MOUNTPT)  = ubi0:miservice
      miservice$(OPTIONS)   = rw
      miservice$(OTABLK)    = /dev/ubi0_1
    
      customer$(RESOUCE)   = $(OUTPUTDIR)/customer
      customer$(FSTYPE)    = ubifs
      customer$(PATSIZE)   = 0x5100000
      customer$(MOUNTTG)  = /customer
      customer$(MOUNTPT)  = ubi0:customer
      customer$(OPTIONS)   = rw
      customer$(OTABLK)    = /dev/ubi0_2
    
      appconfigs$(RESOUCE)   = $(OUTPUTDIR)/appconfigs
      appconfigs$(FSTYPE)    = ubifs
      appconfigs$(PATSIZE)   = 0x500000
      appconfigs$(MOUNTTG)  = /appconfigs
      appconfigs$(MOUNTPT)  = ubi0:appconfigs
      appconfigs$(OPTIONS)   = rw
      appconfigs$(OTABLK)    = /dev/ubi0_3
  • CUSTOMER_TAILOR

    # vi project/release/customer_tailor/nvr_i2m_display_glibc_tailor.mk

    The nvr_i2m_display_glibc_tailor.mk contents are as follows:

include $(PROJ_ROOT)/release/customer_tailor/nvr_default.mk
#interface_ai:=disable
#interface_ao:=disable
#interface_gfx:=disable
interface_hdmi:=disable
#interface_divp:=disable
#interface_disp:=disable
#interface_panel:=disable
interface_rgn:=disable
interface_shadow:=disable
interface_uac:=disable
interface_vdf:=disable
interface_vdisp:=disable
interface_vdec:=enable
interface_venc:=enable
interface_wlan:=enable

misc_fbdev:=enable
#verify_zk_full:=enable
#mhal
#mhal_aio:=disable
mhal_csi:=disable
#mhal_disp:=disable
#mhal_divp:=disable
mhal_isp:=disable
mhal_ispalgo:=disable
mhal_ispmid:=disable
mhal_ldc:=disable
mhal_mload:=disable
#mhal_panel:=disable
#mhal_rgn:=disable
mhal_sensorif:=disable
#mhal_venc:=disable
mhal_vif:=disable
mhal_vpe:=disable
mhal_hdmitx:=disable

This file is about some kernel module switches and app configuration. Like interface_wlan, when building rootfs, WiFi function will be added according to whether it is enabled or not:

# vi project/image/configs/i2m/rootfs.mk
if [ $(interface_wlan) = "enable" ]; then \
        mkdir -p  $(miservice$(RESOUCE))/wifi ; \
        if [ $(FLASH_TYPE) = "spinand" ]; then \
            cp -rf $(LIB_DIR_PATH)/wifi/libs/ap/*   $(miservice$(RESOUCE))/wifi ; \
            cp -rf $(LIB_DIR_PATH)/wifi/bin/ap/*   $(miservice$(RESOUCE))/wifi ; \
        fi;    \
        find $(LIB_DIR_PATH)/wifi/bin/ -maxdepth 1 -type f -exec cp -P {}  $(miservice$(RESOUCE))/wifi \; ;\
        find $(LIB_DIR_PATH)/wifi/bin/ -maxdepth 1 -type l -exec cp -P {}  $(miservice$(RESOUCE))/wifi \; ;\
        find $(LIB_DIR_PATH)/wifi/libs/ -maxdepth 1 -type f -exec cp -P {}  $(miservice$(RESOUCE))/wifi \; ;\
        find $(LIB_DIR_PATH)/wifi/libs/ -maxdepth 1 -type l -exec cp -P {}  $(miservice$(RESOUCE))/wifi \; ;\
        cp -rf $(LIB_DIR_PATH)/wifi/modules/*   $(miservice$(RESOUCE))/wifi ; \
        cp -rf $(LIB_DIR_PATH)/wifi/configs/*   $(miservice$(RESOUCE))/wifi ; \
    fi;
  • BOOTLOGO_FILE
# vi project/image/image.mk
logo_nofsimage:
  @echo [[$@]]
  $(PROJ_ROOT)/image/makefiletools/bin/dispcfggen -c -o $(logo$(RESOUCE)) -p $(LOGO_ADDR) -s $(BOOTLOGO_BUFSIZE) -d $(DISP_OUT_NAME)
  $(PROJ_ROOT)/image/makefiletools/bin/logogen -a -i $(PROJ_ROOT)/board/ini/misc/$(BOOTLOGO_FILE) -o $(logo$(RESOUCE))
  $(PROJ_ROOT)/image/makefiletools/bin/logogen -a -i $(PROJ_ROOT)/board/ini/misc/upgrade.jpg -o $(logo$(RESOUCE))

As you can see, the boot logo image** BOOTLOGO_FILE** should be in the** project/board/ini/misc/** directory

  • DISP_OUT_NAME

project/image/makefiletools/bin/dispcfggen used to initialize the screen


As you can see, DISP_OUT_NAME passed as a parameter to dispcfggen, and dispcfggen by project/image/makefiletools/src/rawgenerator/disp_data_main.c:

# vi project/image/makefiletools/src/rawgenerator/disp_data_main.c


disp_data_main.c is as follows:

/*
* main.c- Sigmastar
*
* Copyright (C) 2018 Sigmastar Technology Corp.
*
* Author: malloc.peng <malloc.peng@sigmastar.com.cn>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
*/

#include <stdio.h>
#include <fcntl.h>  //open
#include <unistd.h> //getopt
#include <string.h> //memset
#include <stdlib.h> //strtol
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "ss_raw_header.h"

#include "mhal_pnl_datatype.h"
#include "pnl_table_RM68200.h"
#include "SAT070CP50_1024x600.h"
#include "SAT070BO30I21Y0_1024x600_MIPI.h"

typedef enum
{
    EN_DISPLAY_DEVICE_NULL,
    EN_DISPLAY_DEVICE_LCD,
    EN_DISPLAY_DEVICE_HDMI,
    EN_DISPLAY_DEVICE_VGA
}SS_SHEADER_DisplayDevice_e;
typedef struct
{
    SS_SHEADER_DataInfo_t stDataInfo;
    u32 u32FirstUseOffset;
    u32 u32DispBufSize;
    u32 u32DispBufStart;
}SS_SHEADER_DispInfo_t;

typedef struct
{
    SS_SHEADER_DisplayDevice_e enDevice;
    u8 au8ResName[32];
    u32 u32Width;
    u32 u32Height;
    u32 u32Clock;
}SS_SHEADER_DispConfig_t;

typedef struct __attribute__((packed)) {
    SS_SHEADER_DisplayDevice_e enDevice;
    u8 au8PanelName[32];
    MhalPnlParamConfig_t stPnlParaCfg;
    MhalPnlMipiDsiConfig_t stMipiDsiCfg;
}SS_SHEADER_PnlPara_t;

typedef struct
{
    const char *pName;
    MhalPnlParamConfig_t *pstMPnlParaConfig;
    MhalPnlMipiDsiConfig_t *pMipiDsiConfig;
}SS_SHEADER_TableHandler_t;


#ifndef ALIGN_UP
#define ALIGN_UP(val, alignment) ((( (val)+(alignment)-1)/(alignment))*(alignment))
#endif
#ifndef ALIGN_DOWN
#define ALIGN_DOWN(val, alignment) (( (val)/(alignment))*(alignment))
#endif


static unsigned Atoi(const char * pStr)
{
    int intStrLen = strlen(pStr);
    unsigned short bUseHex = 0;
    unsigned int intRetNumber = 0;
    int i = 0;

    if (pStr == NULL)
    {
        return 0xFFFFFFFF;
    }

    if (intStrLen > 2)
    {
        if (pStr[0] == '0' &&(pStr[1] == 'X' || pStr[1] == 'x'))
        {
            bUseHex = 1;
            pStr += 2;
        }
    }
    if (bUseHex == 1)
    {
        for (i = 0; i < intStrLen - 2; i++)
        {
            if ((pStr[i] > '9' || pStr[i] < '0')    \
                && (pStr[i] > 'f' || pStr[i] < 'a') \
                && (pStr[i] > 'F' || pStr[i] < 'A'))
            {
                return 0xFFFFFFFF;
            }
        }
        sscanf(pStr, "%x", &intRetNumber);
    }
    else
    {
        for (i = 0; i < intStrLen; i++)
        {
            if (pStr[i] > '9' || pStr[i] < '0')
            {
                return 0xFFFFFFFF;
            }
        }
        intRetNumber =  atoi(pStr);
    }
    return intRetNumber;
}
#ifdef __x86_64__
    #You must use gcc xxx -m32 for 32bit cpu!!!!!
#endif

static s32 SS_SHEADER_InsertTimmingTable(FILE *fp, SS_SHEADER_DispInfo_t *pstDispHead, SS_SHEADER_DispConfig_t *pstTable, u32 u32TableCnt, const s8 *pFirstUse)
{
    u32 i = 0;
    SS_SHEADER_DispConfig_t stDispCfg;

    pstDispHead->u32FirstUseOffset = ftell(fp);
    for (i = 0; i < u32TableCnt; i++)
    {
        if (!strcmp(pFirstUse, (s8 *)pstTable[i].au8ResName))
        {
            pstDispHead->u32FirstUseOffset = ftell(fp);
        }
        memcpy(&stDispCfg, &pstTable[i], sizeof(SS_SHEADER_DispConfig_t));
        fwrite(&stDispCfg, 1, sizeof(SS_SHEADER_DispConfig_t), fp);
        pstDispHead->stDataInfo.u32DataTotalSize += sizeof(SS_SHEADER_DispConfig_t);
        pstDispHead->stDataInfo.u32SubNodeCount++;
    }
    printf("Data count %d, total size %d(0x%x), first use addr %d(0x%x)\n", pstDispHead->stDataInfo.u32SubNodeCount,
                                                                            pstDispHead->stDataInfo.u32DataTotalSize,
                                                                            pstDispHead->stDataInfo.u32DataTotalSize,
                                                                            pstDispHead->u32FirstUseOffset,
                                                                            pstDispHead->u32FirstUseOffset);

    return 0;
}
static s32 SS_SHEADER_InsertPanelTable(FILE *fp, SS_SHEADER_DispInfo_t *pstDispHead, SS_SHEADER_TableHandler_t *pstTabelHandler, u32 u32TableCnt, const s8 *pFirstUse)
{
    u32 i = 0;
    SS_SHEADER_PnlPara_t stPnlPara;
    s32 s32Alignment = 0xFF;
    s32 s32AlignSize = 0;

    pstDispHead->u32FirstUseOffset = ftell(fp);
    for (i = 0; i < u32TableCnt; i++)
    {
        memset(&stPnlPara, 0, sizeof(SS_SHEADER_PnlPara_t));
        stPnlPara.enDevice = EN_DISPLAY_DEVICE_LCD;
        if (!strcmp(pFirstUse, pstTabelHandler[i].pName))
        {
            pstDispHead->u32FirstUseOffset = ftell(fp);
        }
        if (pstTabelHandler[i].pstMPnlParaConfig)
        {
            memcpy(&stPnlPara.stPnlParaCfg, pstTabelHandler[i].pstMPnlParaConfig, sizeof(MhalPnlParamConfig_t));
        }
        if (pstTabelHandler[i].pMipiDsiConfig)
        {
            memcpy(&stPnlPara.stMipiDsiCfg, pstTabelHandler[i].pMipiDsiConfig, sizeof(MhalPnlMipiDsiConfig_t));
        }
        strncpy((s8 *)stPnlPara.au8PanelName, pstTabelHandler[i].pName, 20);
        fwrite(&stPnlPara, 1, sizeof(SS_SHEADER_PnlPara_t), fp);
        pstDispHead->stDataInfo.u32DataTotalSize += sizeof(SS_SHEADER_PnlPara_t);
        printf("Insert disp name: %s\n",stPnlPara.au8PanelName);
        if (stPnlPara.stMipiDsiCfg.u32CmdBufSize != 0)
        {
            fwrite(stPnlPara.stMipiDsiCfg.pu8CmdBuf, 1, stPnlPara.stMipiDsiCfg.u32CmdBufSize, fp);
            pstDispHead->stDataInfo.u32DataTotalSize += stPnlPara.stMipiDsiCfg.u32CmdBufSize;
        }
        printf("Disp header size (%d) mhal pnl para size(%d) spi cmd size(%d)\n", sizeof(SS_SHEADER_PnlPara_t), sizeof(MhalPnlParamConfig_t), stPnlPara.stMipiDsiCfg.u32CmdBufSize);
        pstDispHead->stDataInfo.u32SubNodeCount++;
        /*Warning!!!!! uboot ddr memory start address must be 4 byte alignment*/
        s32AlignSize = ALIGN_UP(pstDispHead->stDataInfo.u32DataTotalSize, 4) - pstDispHead->stDataInfo.u32DataTotalSize;
        if (s32AlignSize)
        {
            fwrite(&s32Alignment, 1, s32AlignSize, fp);
            pstDispHead->stDataInfo.u32DataTotalSize += s32AlignSize;
        }
    }
    printf("Data count %d, total size %d(0x%x), first use addr %d(0x%x)\n", pstDispHead->stDataInfo.u32SubNodeCount,
                                                                            pstDispHead->stDataInfo.u32DataTotalSize,
                                                                            pstDispHead->stDataInfo.u32DataTotalSize,
                                                                            pstDispHead->u32FirstUseOffset,
                                                                            pstDispHead->u32FirstUseOffset);

    return 0;
}
static s32 SS_SHEADER_InsertDispTable(FILE *fp, u64 u64Start, u32 u32Size, SS_SHEADER_DisplayDevice_e enDevice, const s8 *pFirstUse)
{
    s32 s32BeginPos = 0;
    s32 s32CurPos = 0;
    SS_SHEADER_DispInfo_t stDispInfo;
    SS_SHEADER_DispConfig_t stTimmingTable[] = {{EN_DISPLAY_DEVICE_HDMI, "HDMI_1080P60", 1920, 1080, 60},
                                                {EN_DISPLAY_DEVICE_HDMI, "HDMI_720P60", 1280, 720, 60},
                                                {EN_DISPLAY_DEVICE_VGA, "VGA_1080P60", 1920, 1080, 60},
                                                {EN_DISPLAY_DEVICE_VGA, "VGA_720P60", 1280, 720, 60}};
    SS_SHEADER_TableHandler_t stTable[] = {{"SAT070CP50", &stPanel_SAT070CP50_1024x600, NULL},
                                           {"SAT070BO30I21Y0", &stPanel_SAT070BO30I21Y0_1024x60, &stMipiDsiConfig_SAT070BO30I21Y0_1024x600}};

    memset(&stDispInfo, 0, sizeof(SS_SHEADER_DispInfo_t));
    stDispInfo.u32DispBufStart = u64Start;
    stDispInfo.u32DispBufSize = u32Size;
    s32CurPos = ftell(fp);
    printf("LOGO header size %d\n", sizeof(SS_SHEADER_DispInfo_t));
    memcpy(stDispInfo.stDataInfo.au8DataInfoName, "DISP", 4);
    stDispInfo.stDataInfo.u32SubHeadSize = sizeof(SS_SHEADER_DispInfo_t);
    fwrite(&stDispInfo, 1, sizeof(SS_SHEADER_DispInfo_t), fp);
    switch (enDevice)
    {
        case EN_DISPLAY_DEVICE_LCD:
        {
            printf("First use: %s\n", pFirstUse);
            SS_SHEADER_InsertPanelTable(fp, &stDispInfo, stTable, sizeof(stTable) / sizeof(SS_SHEADER_TableHandler_t), (const s8 *)pFirstUse);
        }
        break;
        case EN_DISPLAY_DEVICE_HDMI:
        case EN_DISPLAY_DEVICE_VGA:
        {
            printf("First use: %s\n", pFirstUse);
            SS_SHEADER_InsertTimmingTable(fp, &stDispInfo, stTimmingTable, sizeof(stTimmingTable) / sizeof(SS_SHEADER_DispConfig_t), (const s8 *)pFirstUse);
        }
        break;
        default:
            return -1;
    }
    s32BeginPos = ftell(fp);
    fseek(fp, s32CurPos, SEEK_SET);
    fwrite(&stDispInfo, 1, sizeof(SS_SHEADER_DispInfo_t), fp);
    fseek(fp, s32BeginPos, SEEK_SET);
    printf("dipslay_start=0x%08x\n", (stDispInfo.u32DispBufStart));
    printf("dipslay_size=0x%08x\n", (unsigned int)(stDispInfo.u32DispBufSize));

    return 0;
}

void printHelp(void)
{
    printf("USAGE:");
    return;
}
int main(int argc, char *argv[]) {
    s32 s32Result;
    s8 s8UsedName[20];
    s8 s8DstFile[256];
    FILE *fp = NULL;
    u64 u64Start = 0;
    u32 u32Size = 0;
    u8 bCreate = 0;
    u8 bAppend = 0;
    SS_HEADER_Desc_t stHeader;
    SS_SHEADER_DisplayDevice_e enInterface = 0;

    memset(&stHeader, 0, sizeof(SS_HEADER_Desc_t));
    memset(&s8UsedName, 0, 20);
    memset(s8DstFile, 0, 256);

    while((s32Result = getopt(argc, argv, "p:s:d:o:ca")) != -1 )
    {
        switch(s32Result) {
        case 'p': {
            u64Start = Atoi(optarg);
        }
        break;
        case 's': {
            u32Size = Atoi(optarg);
        }
        break;
        case 'd': {
            if (!strncasecmp(optarg, "HDMI", 4))
            {
                strncpy(s8UsedName, optarg, 20);
                enInterface = EN_DISPLAY_DEVICE_HDMI;
            }
            else if (!strncasecmp(optarg, "VGA", 3))
            {
                strncpy(s8UsedName, optarg, 20);
                enInterface = EN_DISPLAY_DEVICE_VGA;
            }
            else
            {
                strncpy(s8UsedName, optarg, 20);
                enInterface = EN_DISPLAY_DEVICE_LCD;
            }
        }
        break;
        case 'o': {
            strncpy(s8DstFile, optarg, 256);
        }
        break;
        case 'c': {
            bCreate = 1;
        }
        break;
        case 'a': {
            bAppend = 1;
        }
        break;
        default:
            printf("no argv");
            printHelp();

            return -1;
        }
    }
    if (!(bCreate ^ bAppend))
    {
        printHelp();

        return -1;
    }
    if (bCreate)
    {
        fp = SS_HEADER_Create(s8DstFile, &stHeader);
    }
    else if (bAppend)
    {
        fp = SS_HEADER_OpenAppend(s8DstFile, &stHeader);
    }
    if (fp == NULL)
    {
        printf("Open error\n");
        return -1;
    }
    SS_SHEADER_InsertDispTable(fp, u64Start, u32Size, enInterface, s8UsedName);
    stHeader.u32DataInfoCnt++;
    SS_HEADER_Update(fp, &stHeader);
    SS_HEADER_Close(fp);


    return 0;
}
文档更新时间: 2021-03-22 13:55   作者:Aeeditor