在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

RZ MPU工業(yè)控制教程連載(62)Yocto系統(tǒng)添加程序

瑞薩MCU小百科 ? 來源: 瑞薩MCU小百科 ? 2025-03-07 14:40 ? 次閱讀

14.7

Yocto系統(tǒng)添加程序

14.7.1 快速增加軟件包

在Yocto中如果我們期望在rootfs中添加一些軟件,例如可能是bash,可能是lsusb等,那么,我們可以有兩種方法:

手動(dòng)添加,一個(gè)個(gè)文件的拷貝。

或者在bb文件中添加安裝項(xiàng)目,讓Yocto自動(dòng)幫助我們添加。

第一種方法需要手動(dòng)將軟件包的所有文件以及依賴都一個(gè)個(gè)添加進(jìn)去,耗時(shí)耗力且易錯(cuò),因此使用第二中方法比較合適。

Yocto中Rootfs中添加軟件包的步驟

找到打包rootfs的最終bb

如果我們使用的是bitbake myir-image-full編譯命令。

那么,我們可以按照如下來搜索myir-image-full這個(gè)軟件包(任務(wù)),使用的是哪個(gè)bb文件:

11ba669c-fa40-11ef-9310-92fbcf53809c.png

在meta-myir-remi/recipes-images/images/myir-image-full.bb里面添加我們需要的軟件包。

我們只需要在IMAGE_INSTALL后面參考添加需要的軟件包。

11c8cf3e-fa40-11ef-9310-92fbcf53809c.png

參考下圖所示,在最底部增加一個(gè)lsusb軟件包,增加完成后,保存退出即可。

11d5a4ca-fa40-11ef-9310-92fbcf53809c.png

再次回到編譯空間~/renesas/yocto/myir-renesas-yocto/build-remi-1g目錄內(nèi),執(zhí)行bitbake myir-image-full-k命令就可以自動(dòng)將我們增加的lsusb編譯至最終系統(tǒng)內(nèi)。

14.7.2 自定義本地bb軟件包

Yocto中一個(gè)軟件包是放在bb文件中的,然后很多的bb 文件集成一個(gè)recipe(配方),然后許多的recipe又組成一個(gè)meta layer,因此,要添加一個(gè)包其實(shí)就是在recipe下面添加一個(gè)bb(bitbake配置文件)。下面使用helloworld作為一個(gè)例子。

1

創(chuàng)建hello bb文件

例如下面就是到了meta-myir-remi layer里面找到一個(gè)名為recipes-demo配方增加我們的hello bb文件。

一個(gè)軟件包的結(jié)構(gòu)使用tree可以看到,其有一個(gè)bb文件,然后其中還有一個(gè)目錄放著Makefile與source code:

11ebae5a-fa40-11ef-9310-92fbcf53809c.png

2

bb文件內(nèi)容

其中的bb文件內(nèi)容如下:

左右滑動(dòng)查看完整內(nèi)容

DESCRIPTION = "Hello World and Zlib test"
DEPENDS = "zlib"
SECTION = "libs"
LICENSE = "MIT"
PV = "3"
PR = "r0"


SRC_URI = " 
 file://helloYocto.c 
 file://zlibtest.c 
 file://makefile 
 "
 
LIC_FILES_CHKSUM = "file://helloYocto.c;md5=4c53a1f5243efa8c4d5ec1c3909d2c1f"
S = "${WORKDIR}"
do_compile () {
 make
}


do_install () {
install -d ${D}/usr/bin 


install -m 0755 ${S}/helloYocto ${D}/usr/bin
install -m 0755 ${S}/zlibtest ${D}/usr/bin
}


FILES_${PN} = " 
/usr/bin 
"

可以看到,bb文件中指定了下面幾個(gè)變量的值:

SRC_URI

LIC_FILES_CHKSUM:這個(gè)是checksum,如果是基于版本管理的source,那么不需要,例如git 與svn

FILES_$(PN):PN是Package number,指代軟件版本使用的PV與PR結(jié)合表示,即前面bitbake -s中看到的3-r0

還有兩個(gè)方法,這2個(gè)方法重載了bitbake中默認(rèn)方法:

do_compile

do_install

這兩個(gè)方法,對(duì)應(yīng)了Package中的compile與install task。

3

應(yīng)用程序編寫

左右滑動(dòng)查看完整內(nèi)容

ubuntu@ubuntu2004:~/renesas/yocto/myir-renesas-yocto/layers/meta-myir-remi/recipes-d
emos/hello$ cd hello/
ubuntu@ubuntu2004:~/renesas/yocto/myir-renesas-yocto/layers/meta-myir-remi/recipes-d
emos/hello/hello$ ls
helloYocto.c makefile zlibtest.c

左右滑動(dòng)查看完整內(nèi)容

ubuntu@ubuntu2004:~/renesas/yocto/myir-renesas-yocto/layers/meta-myir-remi/recipes-d
emos/hello/hello$ cat helloYocto.c 
#include
#include
#include 


int main(int argc,char *argv[])
{


 printf("Hello World Yocto-SDK !!!");
 return 0;
}

左右滑動(dòng)查看完整內(nèi)容

ubuntu@ubuntu2004:~/renesas/yocto/myir-renesas-yocto/layers/meta-myir-remi/recipes-d
emos/hello/hello$ cat makefile 
TARGET=helloYocto zlibtest
LDFLAGS= -lz


all: $(TARGET)
helloYocto: helloYocto.o
$(CC) $(CFLAGS) -o $@ $^ 


zlibtest: zlibtest.o
$(CC) $(CFLAGS1) -o $@ $^ $(LDFLAGS)


clean:
rm -f $(OBJS) $(TARGET)

左右滑動(dòng)查看完整內(nèi)容

ubuntu@ubuntu2004:~/renesas/yocto/myir-renesas-yocto/layers/meta-myir-remi/recipes-d
emos/hello/hello$ cat zlibtest.c 
/* gun.c -- simple gunzip to give an example of the use of inflateBack()
* Copyright (C) 2003, 2005, 2008, 2010, 2012 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
 Version 1.7 12 August 2012 Mark Adler */
 
/* Version history:
 1.0 16 Feb 2003 First version for testing of inflateBack()
 1.1 21 Feb 2005 Decompress concatenated gzip streams
 Remove use of "this" variable (C++ keyword)
 Fix return value for in()
 Improve allocation failure checking

左右滑動(dòng)查看完整內(nèi)容

Add typecasting for void * structures
 Add -h option for command version and usage
 Add a bunch of comments
 1.2 20 Mar 2005 Add Unix compress (LZW) decompression
 Copy file attributes from input file to output file
 1.3 12 Jun 2005 Add casts for error messages [Oberhumer]
 1.4 8 Dec 2006 LZW decompression speed improvements
 1.5 9 Feb 2008 Avoid warning in latest version of gcc
 1.6 17 Jan 2010 Avoid signed/unsigned comparison warnings
 1.7 12 Aug 2012 Update for z_const usage in zlib 1.2.8
*/


/*
 gun [ -t ] [ name ... ]
 
 decompresses the data in the named gzip files. If no arguments are given,
 gun will decompress from stdin to stdout. The names must end in .gz, -gz,
 .z, -z, _z, or .Z. The uncompressed data will be written to a file name
 with the suffix stripped. On success, the original file is deleted. On
 failure, the output file is deleted. For most failures, the command will
 continue to process the remaining names on the command line. A memory
 allocation failure will abort the command. If -t is specified, then the
 listed files or stdin will be tested as gzip files for integrity (without
 checking for a proper suffix), no output will be written, and no files
 will be deleted.
 
 Like gzip, gun allows concatenated gzip streams and will decompress them,
 writing all of the uncompressed data to the output. Unlike gzip, gun allows
 an empty file on input, and will produce no error writing an empty output
 file.
 
 gun will also decompress files made by Unix compress, which uses LZW
 compression. These files are automatically detected by virtue of their
 magic header bytes. Since the end of Unix compress stream is marked by the
 end-of-file, they cannot be concantenated. If a Unix compress stream is
 encountered in an input file, it is the last stream in that file.
 
 Like gunzip and uncompress, the file attributes of the orignal compressed
 file are maintained in the final uncompressed file, to the extent that the
 user permissions allow it.
 
 On my Mac OS X PowerPC G4, gun is almost twice as fast as gunzip (version
 1.2.4) is on the same file, when gun is linked with zlib 1.2.2. Also the
 LZW decompression provided by gun is about twice as fast as the standard
 Unix uncompress command.
 */
 
/* external functions and related types and constants */
#include  /* fprintf() */
#include  /* malloc(), free() */
#include  /* strerror(), strcmp(), strlen(), memcpy() */
#include  /* errno */
#include  /* open() */
#include  /* read(), write(), close(), chown(), unlink() */
#include 
#include  /* stat(), chmod() */

左右滑動(dòng)查看完整內(nèi)容

#include  /* utime() */
#include "zlib.h" /* inflateBackInit(), inflateBack(), */
 /* inflateBackEnd(), crc32() */
 
/* function declaration */
#define local static


/* buffer constants */
#define SIZE 32768U /* input and output buffer sizes */
#define PIECE 16384 /* limits i/o chunks for 16-bit int case */


/* structure for infback() to pass to input function in() -- it maintains the
 input file and a buffer of size SIZE */
struct ind {
 int infile;
 unsigned char *inbuf;
};


/* Load input buffer, assumed to be empty, and return bytes loaded and a
 pointer to them. read() is called until the buffer is full, or until it
 returns end-of-file or error. Return 0 on error. */
local unsigned in(void *in_desc, z_const unsigned char **buf)
{
 int ret;
 unsigned len;
 unsigned char *next;
 struct ind *me = (struct ind *)in_desc;
 
 next = me->inbuf;
 *buf = next;
 len = 0;
 do {
 ret = PIECE;
 if ((unsigned)ret > SIZE - len)
 ret = (int)(SIZE - len);
 ret = (int)read(me->infile, next, ret);
 if (ret == -1) {
 len = 0;
 break;
 }
 next += ret;
 len += ret;
 } while (ret != 0 && len < SIZE);
 return len;
}


/* structure for infback() to pass to output function out() -- it maintains the
 output file, a running CRC-32 check on the output and the total number of
 bytes output, both for checking against the gzip trailer. (The length in
 the gzip trailer is stored modulo 2^32, so it's ok if a long is 32 bits and
 the output is greater than 4 GB.) */
struct outd {
 int outfile;
 int check; /* true if checking crc and total */
 unsigned long crc;
 unsigned long total;

左右滑動(dòng)查看完整內(nèi)容

};


/* Write output buffer and update the CRC-32 and total bytes written. write()
 is called until all of the output is written or an error is encountered.
 On success out() returns 0. For a write failure, out() returns 1. If the
 output file descriptor is -1, then nothing is written.
*/
local int out(void *out_desc, unsigned char *buf, unsigned len)
{
 int ret;
 struct outd *me = (struct outd *)out_desc;
 
 if (me->check) {
 me->crc = crc32(me->crc, buf, len);
 me->total += len;
 }
 if (me->outfile != -1)
 do {
 ret = PIECE;
 if ((unsigned)ret > len)
 ret = (int)len;
 ret = (int)write(me->outfile, buf, ret);
 if (ret == -1)
 return 1;
 buf += ret;
 len -= ret;
 } while (len != 0);
 return 0;
}


/* next input byte macro for use inside lunpipe() and gunpipe() */
#define NEXT() (have ? 0 : (have = in(indp, &next)), 
 last = have ? (have--, (int)(*next++)) : -1)


/* memory for gunpipe() and lunpipe() --
 the first 256 entries of prefix[] and suffix[] are never used, could
 have offset the index, but it's faster to waste the memory */
unsigned char inbuf[SIZE]; /* input buffer */
unsigned char outbuf[SIZE]; /* output buffer */
unsigned short prefix[65536]; /* index to LZW prefix string */
unsigned char suffix[65536]; /* one-character LZW suffix */
unsigned char match[65280 + 2]; /* buffer for reversed match or gzip
 32K sliding window */


/* throw out what's left in the current bits byte buffer (this is a vestigial
 aspect of the compressed data format derived from an implementation that
 made use of a special VAX machine instruction!) */
#define FLUSHCODE() 
 do { 
 left = 0; 
 rem = 0; 
 if (chunk > have) { 
 chunk -= have; 
 have = 0; 
 if (NEXT() == -1) 
 break; 

左右滑動(dòng)查看完整內(nèi)容

chunk--; 
 if (chunk > have) { 
 chunk = have = 0; 
 break; 
 } 
 } 
 have -= chunk; 
 next += chunk; 
 chunk = 0; 
 } while (0)
 
/* Decompress a compress (LZW) file from indp to outfile. The compress magic
 header (two bytes) has already been read and verified. There are have bytes
 of buffered input at next. strm is used for passing error information back
 to gunpipe().
 
 lunpipe() will return Z_OK on success, Z_BUF_ERROR for an unexpected end of
 file, read error, or write error (a write error indicated by strm->next_in
 not equal to Z_NULL), or Z_DATA_ERROR for invalid input.
*/
local int lunpipe(unsigned have, z_const unsigned char *next, struct ind *indp,
 int outfile, z_stream *strm)
{
 int last; /* last byte read by NEXT(), or -1 if EOF */
 unsigned chunk; /* bytes left in current chunk */
 int left; /* bits left in rem */
 unsigned rem; /* unused bits from input */
 int bits; /* current bits per code */
 unsigned code; /* code, table traversal index */
 unsigned mask; /* mask for current bits codes */
 int max; /* maximum bits per code for this stream */
 unsigned flags; /* compress flags, then block compress flag */
 unsigned end; /* last valid entry in prefix/suffix tables */
 unsigned temp; /* current code */
 unsigned prev; /* previous code */
 unsigned final; /* last character written for previous code */
 unsigned stack; /* next position for reversed string */
 unsigned outcnt; /* bytes in output buffer */
 struct outd outd; /* output structure */
 unsigned char *p;
 
 /* set up output */
 outd.outfile = outfile;
 outd.check = 0;
 
 /* process remainder of compress header -- a flags byte */
 flags = NEXT();
 if (last == -1)
 return Z_BUF_ERROR;
 if (flags & 0x60) {
 strm->msg = (char *)"unknown lzw flags set";
 return Z_DATA_ERROR;
 }
 max = flags & 0x1f;
 if (max < 9 || max > 16) {
 strm->msg = (char *)"lzw bits out of range";

左右滑動(dòng)查看完整內(nèi)容

return Z_DATA_ERROR;
 }
 if (max == 9) /* 9 doesn't really mean 9 */
 max = 10;
 flags &= 0x80; /* true if block compress */
 
 /* clear table */
 bits = 9;
 mask = 0x1ff;
 end = flags ? 256 : 255;
 
 /* set up: get first 9-bit code, which is the first decompressed byte, but
 don't create a table entry until the next code */
 if (NEXT() == -1) /* no compressed data is ok */
 return Z_OK;
 final = prev = (unsigned)last; /* low 8 bits of code */
 if (NEXT() == -1) /* missing a bit */
 return Z_BUF_ERROR;
 if (last & 1) { /* code must be < 256 */
 strm->msg = (char *)"invalid lzw code";
 return Z_DATA_ERROR;
 }
 rem = (unsigned)last >> 1; /* remaining 7 bits */
 left = 7;
 chunk = bits - 2; /* 7 bytes left in this chunk */
 outbuf[0] = (unsigned char)final; /* write first decompressed byte */
 outcnt = 1;
 
 /* decode codes */
 stack = 0;
 for (;;) {
 /* if the table will be full after this, increment the code size */
 if (end >= mask && bits < max) {
 FLUSHCODE();
 bits++;
 mask <<= 1;
 mask++;
 }
 /* get a code of length bits */
 if (chunk == 0) /* decrement chunk modulo bits */
 chunk = bits;
 code = rem; /* low bits of code */
 if (NEXT() == -1) { /* EOF is end of compressed data */
 /* write remaining buffered output */
 if (outcnt && out(&outd, outbuf, outcnt)) {
 strm->next_in = outbuf; /* signal write error */
 return Z_BUF_ERROR;
 }
 return Z_OK;
 }
 code += (unsigned)last << left; /* middle (or high) bits of code */
 left += 8;
 chunk--;
 if (bits > left) { /* need more bits */
 if (NEXT() == -1) /* can't end in middle of code */

左右滑動(dòng)查看完整內(nèi)容

return Z_BUF_ERROR;
 code += (unsigned)last << left; /* high bits of code */
 left += 8;
 chunk--;
 }
 code &= mask; /* mask to current code length */
 left -= bits; /* number of unused bits */
 rem = (unsigned)last >> (8 - left); /* unused bits from last byte */


 /* process clear code (256) */
 if (code == 256 && flags) {
 FLUSHCODE();
 bits = 9; /* initialize bits and mask */
 mask = 0x1ff;
 end = 255; /* empty table */
 continue; /* get next code */
 }
 
 /* special code to reuse last match */
 temp = code; /* save the current code */
 if (code > end) {
 /* Be picky on the allowed code here, and make sure that the code
 we drop through (prev) will be a valid index so that random
 input does not cause an exception. The code != end + 1 check is
 empirically derived, and not checked in the original uncompress
 code. If this ever causes a problem, that check could be safely
 removed. Leaving this check in greatly improves gun's ability
 to detect random or corrupted input after a compress header.
 In any case, the prev > end check must be retained. */
 if (code != end + 1 || prev > end) {
 strm->msg = (char *)"invalid lzw code";
 return Z_DATA_ERROR;
 }
 match[stack++] = (unsigned char)final;
 code = prev;
 }
 
 /* walk through linked list to generate output in reverse order */
 p = match + stack;
 while (code >= 256) {
 *p++ = suffix[code];
 code = prefix[code];
 }
 stack = p - match;
 match[stack++] = (unsigned char)code;
 final = code;


 /* link new table entry */
 if (end < mask) {
 end++;
 prefix[end] = (unsigned short)prev;
 suffix[end] = (unsigned char)final;
 }
 
 /* set previous code for next iteration */
 prev = temp;

左右滑動(dòng)查看完整內(nèi)容

/* write output in forward order */
 while (stack > SIZE - outcnt) {
 while (outcnt < SIZE)
 outbuf[outcnt++] = match[--stack];
 if (out(&outd, outbuf, outcnt)) {
 strm->next_in = outbuf; /* signal write error */
 return Z_BUF_ERROR;
 }
 outcnt = 0;
 }
 p = match + stack;
 do {
 outbuf[outcnt++] = *--p;
 } while (p > match);
 stack = 0;
 
 /* loop for next code with final and prev as the last match, rem and
 left provide the first 0..7 bits of the next code, end is the last
 valid table entry */
 }
}


/* Decompress a gzip file from infile to outfile. strm is assumed to have been
 successfully initialized with inflateBackInit(). The input file may consist
 of a series of gzip streams, in which case all of them will be decompressed
 to the output file. If outfile is -1, then the gzip stream(s) integrity is
 checked and nothing is written.
 
 The return value is a zlib error code: Z_MEM_ERROR if out of memory,
 Z_DATA_ERROR if the header or the compressed data is invalid, or if the
 trailer CRC-32 check or length doesn't match, Z_BUF_ERROR if the input ends
 prematurely or a write error occurs, or Z_ERRNO if junk (not a another gzip
 stream) follows a valid gzip stream.
*/
local int gunpipe(z_stream *strm, int infile, int outfile)
{
 int ret, first, last;
 unsigned have, flags, len;
 z_const unsigned char *next = NULL;
 struct ind ind, *indp;
 struct outd outd;
 
 /* setup input buffer */
 ind.infile = infile;
 ind.inbuf = inbuf;
 indp = &ind;
 
 /* decompress concatenated gzip streams */
 have = 0; /* no input data read in yet */
 first = 1; /* looking for first gzip header */
 strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */
 for (;;) {
 /* look for the two magic header bytes for a gzip stream */
 if (NEXT() == -1) {
 ret = Z_OK;

左右滑動(dòng)查看完整內(nèi)容

break; /* empty gzip stream is ok */
 }
 if (last != 31 || (NEXT() != 139 && last != 157)) {
 strm->msg = (char *)"incorrect header check";
 ret = first ? Z_DATA_ERROR : Z_ERRNO;
 break; /* not a gzip or compress header */
 }
 first = 0; /* next non-header is junk */
 /* process a compress (LZW) file -- can't be concatenated after this */
 if (last == 157) {
 ret = lunpipe(have, next, indp, outfile, strm);
 break;
 }
 
 /* process remainder of gzip header */
 ret = Z_BUF_ERROR;
 if (NEXT() != 8) { /* only deflate method allowed */
 if (last == -1) break;
 strm->msg = (char *)"unknown compression method";
 ret = Z_DATA_ERROR;
 break;
 }
 flags = NEXT(); /* header flags */
 NEXT(); /* discard mod time, xflgs, os */
 NEXT();
 NEXT();
 NEXT();
 NEXT();
 NEXT();
 if (last == -1) break;
 if (flags & 0xe0) {
 strm->msg = (char *)"unknown header flags set";
 ret = Z_DATA_ERROR;
 break;
 }
 if (flags & 4) { /* extra field */
 len = NEXT();
 len += (unsigned)(NEXT()) << 8;
 if (last == -1) break;
 while (len > have) {
 len -= have;
 have = 0;
 if (NEXT() == -1) break;
 len--;
 }
 if (last == -1) break;
 have -= len;
 next += len;
 }
 if (flags & 8) /* file name */
 while (NEXT() != 0 && last != -1)
 ;
 if (flags & 16) /* comment */
 while (NEXT() != 0 && last != -1)
 ;

左右滑動(dòng)查看完整內(nèi)容

if (flags & 2) { /* header crc */
 NEXT();
 NEXT();
 }
 if (last == -1) break;
 /* set up output */
 outd.outfile = outfile;
 outd.check = 1;
 outd.crc = crc32(0L, Z_NULL, 0);
 outd.total = 0;
 
 /* decompress data to output */
 strm->next_in = next;
 strm->avail_in = have;
 ret = inflateBack(strm, in, indp, out, &outd);
 if (ret != Z_STREAM_END) break;
 next = strm->next_in;
 have = strm->avail_in;
 strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */
 
 /* check trailer */
 ret = Z_BUF_ERROR;
 if (NEXT() != (int)(outd.crc & 0xff) ||
 NEXT() != (int)((outd.crc >> 8) & 0xff) ||
 NEXT() != (int)((outd.crc >> 16) & 0xff) ||
 NEXT() != (int)((outd.crc >> 24) & 0xff)) {
 /* crc error */
 if (last != -1) {
 strm->msg = (char *)"incorrect data check";
 ret = Z_DATA_ERROR;
 }
 break;
 }
 if (NEXT() != (int)(outd.total & 0xff) ||
 NEXT() != (int)((outd.total >> 8) & 0xff) ||
 NEXT() != (int)((outd.total >> 16) & 0xff) ||
 NEXT() != (int)((outd.total >> 24) & 0xff)) {
 /* length error */
 if (last != -1) {
 strm->msg = (char *)"incorrect length check";
 ret = Z_DATA_ERROR;
 }
 break;
 }
 /* go back and look for another gzip stream */
 }
 /* clean up and return */
 return ret;
}


/* Copy file attributes, from -> to, as best we can. This is best effort, so
 no errors are reported. The mode bits, including suid, sgid, and the sticky
 bit are copied (if allowed), the owner's user id and group id are copied

左右滑動(dòng)查看完整內(nèi)容

(again if allowed), and the access and modify times are copied. */
local void copymeta(char *from, char *to)
{
 struct stat was;
 struct utimbuf when;
 
 /* get all of from's Unix meta data, return if not a regular file */
 if (stat(from, &was) != 0 || (was.st_mode & S_IFMT) != S_IFREG)
 return;
 
 /* set to's mode bits, ignore errors */
 (void)chmod(to, was.st_mode & 07777);
 
 /* copy owner's user and group, ignore errors */
 (void)chown(to, was.st_uid, was.st_gid);
 
 /* copy access and modify times, ignore errors */
 when.actime = was.st_atime;
 when.modtime = was.st_mtime;
 (void)utime(to, &when);
}


/* Decompress the file inname to the file outnname, of if test is true, just
 decompress without writing and check the gzip trailer for integrity. If
 inname is NULL or an empty string, read from stdin. If outname is NULL or
 an empty string, write to stdout. strm is a pre-initialized inflateBack
 structure. When appropriate, copy the file attributes from inname to
 outname.
 
 gunzip() returns 1 if there is an out-of-memory error or an unexpected
 return code from gunpipe(). Otherwise it returns 0.
*/
local int gunzip(z_stream *strm, char *inname, char *outname, int test)
{
 int ret;
 int infile, outfile;
 
 /* open files */
 if (inname == NULL || *inname == 0) {
 inname = "-";
 infile = 0; /* stdin */
 }
 else {
 infile = open(inname, O_RDONLY, 0);
 if (infile == -1) {
 fprintf(stderr, "gun cannot open %s
", inname);
 return 0;
 }
 }
 if (test)
 outfile = -1;
 else if (outname == NULL || *outname == 0) {
 outname = "-";
 outfile = 1; /* stdout */
 }
 else {

左右滑動(dòng)查看完整內(nèi)容

outfile = open(outname, O_CREAT | O_TRUNC | O_WRONLY, 0666);
 if (outfile == -1) {
 close(infile);
 fprintf(stderr, "gun cannot create %s
", outname);
 return 0;
 }
 }
 errno = 0;
 
 /* decompress */
 ret = gunpipe(strm, infile, outfile);
 if (outfile > 2) close(outfile);
 if (infile > 2) close(infile);
 
 /* interpret result */
 switch (ret) {
 case Z_OK:
 case Z_ERRNO:
 if (infile > 2 && outfile > 2) {
 copymeta(inname, outname); /* copy attributes */
 unlink(inname);
 
 }
 if (ret == Z_ERRNO)
 fprintf(stderr, "gun warning: trailing garbage ignored in %s
",
 inname);
 break;
 case Z_DATA_ERROR:
 if (outfile > 2) unlink(outname);
 fprintf(stderr, "gun data error on %s: %s
", inname, strm->msg);
 break;
 case Z_MEM_ERROR:
 if (outfile > 2) unlink(outname);
 fprintf(stderr, "gun out of memory error--aborting
");
 return 1;
 case Z_BUF_ERROR:
 if (outfile > 2) unlink(outname);
 if (strm->next_in != Z_NULL) {
 fprintf(stderr, "gun write error on %s: %s
",
 outname, strerror(errno));
 }
 else if (errno) {
 fprintf(stderr, "gun read error on %s: %s
",
 inname, strerror(errno));
 }
 else {
 fprintf(stderr, "gun unexpected end of file on %s
",
 inname);
 }
 break;
 default:
 if (outfile > 2) unlink(outname);
 fprintf(stderr, "gun internal error--aborting
");
 return 1;
 }
 return 0;
}

左右滑動(dòng)查看完整內(nèi)容

/* Process the gun command line arguments. See the command syntax near the
 beginning of this source file. */
int main(int argc, char **argv)
{
 int ret, len, test;
 char *outname;
 unsigned char *window;
 z_stream strm;
 
 /* initialize inflateBack state for repeated use */
 window = match; /* reuse LZW match buffer */
 strm.zalloc = Z_NULL;
 strm.zfree = Z_NULL;
 strm.opaque = Z_NULL;
 ret = inflateBackInit(&strm, 15, window);
 if (ret != Z_OK) {
 fprintf(stderr, "gun out of memory error--aborting
");
 return 1;
 }
 
 /* decompress each file to the same name with the suffix removed */
 argc--;
 argv++;
 test = 0;
 if (argc && strcmp(*argv, "-h") == 0) {
 fprintf(stderr, "gun 1.6 (17 Jan 2010)
");
 fprintf(stderr, "Copyright (C) 2003-2010 Mark Adler
");
 fprintf(stderr, "usage: gun [-t] [file1.gz [file2.Z ...]]
");
 return 0;
 }
 if (argc && strcmp(*argv, "-t") == 0) {
 test = 1;
 argc--;
 argv++;
 }
 if (argc)
 do {
 if (test)
 outname = NULL;
 else {
 len = (int)strlen(*argv);
 if (strcmp(*argv + len - 3, ".gz") == 0 ||
 strcmp(*argv + len - 3, "-gz") == 0)
 len -= 3;
 else if (strcmp(*argv + len - 2, ".z") == 0 ||
 strcmp(*argv + len - 2, "-z") == 0 ||
 strcmp(*argv + len - 2, "_z") == 0 ||
 strcmp(*argv + len - 2, ".Z") == 0)
 len -= 2;
 else {
 fprintf(stderr, "gun error: no gz type on %s--skipping
",
 *argv);
 continue;
 }
 outname = malloc(len + 1);

左右滑動(dòng)查看完整內(nèi)容

if (outname == NULL) {
 fprintf(stderr, "gun out of memory error--aborting
");
 ret = 1;
 break;
 }
 memcpy(outname, *argv, len);
 outname[len] = 0;
 }
 ret = gunzip(&strm, *argv, outname, test);
 if (outname != NULL) free(outname);
 if (ret) break;
 } while (argv++, --argc);
 else
 ret = gunzip(&strm, NULL, NULL, test);
 
 /* clean up */
 inflateBackEnd(&strm);
 return ret;
}
ubuntu@ubuntu2004:~/renesas/yocto/myir-renesas-yocto/layers/meta-myir-remi/recipes-d
emos/hello/hello$

4

單獨(dú)編譯

ubuntu@ubuntu2004:~/renesas/yocto/myir-renesas-yocto/build-remi-1g$ bitbake-v hello

11f8ba0a-fa40-11ef-9310-92fbcf53809c.png

5

解決錯(cuò)誤

~/renesas/yocto/myir-renesas-yocto/layers/meta-myir-

remi/recipes-demos/hello/

ubuntu@ubuntu2004:~/renesas/yocto/myir-renesas-

yocto/layers/meta-myir-remi/recipes-demos/hello$ vi hello.bb

120c3062-fa40-11ef-9310-92fbcf53809c.png

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • mcu
    mcu
    +關(guān)注

    關(guān)注

    146

    文章

    17455

    瀏覽量

    354248
  • MPU
    MPU
    +關(guān)注

    關(guān)注

    0

    文章

    378

    瀏覽量

    49142
  • 瑞薩電子
    +關(guān)注

    關(guān)注

    37

    文章

    2883

    瀏覽量

    72688
  • 工業(yè)控制
    +關(guān)注

    關(guān)注

    38

    文章

    1480

    瀏覽量

    86210
  • yocto
    +關(guān)注

    關(guān)注

    0

    文章

    10

    瀏覽量

    5340

原文標(biāo)題:Yocto系統(tǒng)添加程序——RZ MPU工業(yè)控制教程連載(62)

文章出處:【微信號(hào):瑞薩MCU小百科,微信公眾號(hào):瑞薩MCU小百科】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。

收藏 人收藏

    評(píng)論

    相關(guān)推薦

    RZ/G2L Linux系統(tǒng)如何添加新的內(nèi)核模塊

    RZ/G2L Linux系統(tǒng)的鏡像基于yocto構(gòu)建,本篇介紹如何添加新的內(nèi)核模塊。
    的頭像 發(fā)表于 01-04 12:19 ?1936次閱讀
    <b class='flag-5'>RZ</b>/G2L Linux<b class='flag-5'>系統(tǒng)</b>如何<b class='flag-5'>添加</b>新的內(nèi)核模塊

    請(qǐng)問在Multisim14中如何為MSP430添加程序啊?

    就可以添加程序,后面還可以調(diào)試程序等等,但是8051越來越滿足不了電路控制的需求了,想要用性能更好一點(diǎn)的單片機(jī)進(jìn)行電路模擬。。
    發(fā)表于 06-25 20:24

    數(shù)據(jù)庫添加程序哪里

    各位大神,各位高手幫忙看看,這個(gè)數(shù)據(jù)庫添加程序問題出在哪里,我硬是沒搞明白。。。。。多指教現(xiàn)象是:無法正常添加至數(shù)據(jù)庫,數(shù)據(jù)庫已經(jīng)創(chuàng)建好,連接測試成功,而這里卻是始終無法添加
    發(fā)表于 08-10 16:50

    yocto項(xiàng)目添加程序和腳本的步驟簡析

    1 配方(recipe)文件創(chuàng)建在哪里?為了最快讓未接觸過yocto的同學(xué)完成helloworld程序添加,這里選擇把配方文件加在已有的layers中,并確保該layers會(huì)加入編譯。1.1 確認(rèn)
    發(fā)表于 11-04 15:20

    RZ/T2M電機(jī)控制MPU怎么樣?有哪些特征應(yīng)用?

    新推出的的RZ/T2M電機(jī)控制微處理器單元,該單元在單芯片上結(jié)合了快速、高精度的實(shí)時(shí)電機(jī)控制功能和工業(yè)以太網(wǎng),同時(shí)還支持功能安全操作。通過提供電機(jī)
    發(fā)表于 03-01 14:42

    VLP v3.0.0 的 RZ/G2 組 Yocto 配方啟動(dòng)指南

    VLP v3.0.0 的 RZ/G2 組 Yocto 配方啟動(dòng)指南
    發(fā)表于 01-11 19:00 ?0次下載
    VLP v3.0.0 的 <b class='flag-5'>RZ</b>/G2 組 <b class='flag-5'>Yocto</b> 配方啟動(dòng)指南

    RZ/V2L Yocto 配方啟動(dòng)指南

    RZ/V2L Yocto 配方啟動(dòng)指南
    發(fā)表于 01-13 19:04 ?1次下載
    <b class='flag-5'>RZ</b>/V2L <b class='flag-5'>Yocto</b> 配方啟動(dòng)指南

    新品發(fā)布 | 瑞薩電子發(fā)布全新RZ/T2L工業(yè)MPU,可通過EtherCAT通信實(shí)現(xiàn)快速、準(zhǔn)確的實(shí)時(shí)控制

    新品速遞 全球半導(dǎo)體解決方案供應(yīng)商瑞薩電子(TSE:6723)今日宣布,推出一款支持EtherCAT通信協(xié)議的全新工業(yè)用微處理器(MPU)——RZ/T2L,為工業(yè)
    的頭像 發(fā)表于 03-25 06:45 ?809次閱讀

    VLP v3.0.0 的 RZ/G2組 Yocto 配方啟動(dòng)指南

    VLP v3.0.0 的 RZ/G2 組 Yocto 配方啟動(dòng)指南
    發(fā)表于 06-30 20:55 ?0次下載
    VLP v3.0.0 的 <b class='flag-5'>RZ</b>/G2組 <b class='flag-5'>Yocto</b> 配方啟動(dòng)指南

    RZ/V2L Yocto 配方啟動(dòng)指南

    RZ/V2L Yocto 配方啟動(dòng)指南
    發(fā)表于 07-03 19:45 ?0次下載
    <b class='flag-5'>RZ</b>/V2L <b class='flag-5'>Yocto</b> 配方啟動(dòng)指南

    高性能、多功能MPU RZ/T2M簡介

    RZ/T2M是一款行業(yè)領(lǐng)先的高性能、多功能MPU,可實(shí)現(xiàn)AC伺服系統(tǒng)工業(yè)電機(jī)等工業(yè)設(shè)備的高速處理、高精度
    的頭像 發(fā)表于 09-04 14:07 ?1939次閱讀
    高性能、多功能<b class='flag-5'>MPU</b> <b class='flag-5'>RZ</b>/T2M簡介

    RZ/T2M和RZ/N2L中Printf添加方法(使用查詢模式實(shí)現(xiàn)UART)

    RZ/N2L是一種工業(yè)以太網(wǎng)通信用MPU,可輕松將網(wǎng)絡(luò)功能添加工業(yè)設(shè)備中。
    的頭像 發(fā)表于 05-21 14:08 ?792次閱讀
    在<b class='flag-5'>RZ</b>/T2M和<b class='flag-5'>RZ</b>/N2L中Printf<b class='flag-5'>添加</b>方法(使用查詢模式實(shí)現(xiàn)UART)

    產(chǎn)品簡介 | RZ/A系列MPU

    產(chǎn)品簡介 | RZ/A系列MPU
    的頭像 發(fā)表于 05-24 08:06 ?528次閱讀
    產(chǎn)品簡介 | <b class='flag-5'>RZ</b>/A系列<b class='flag-5'>MPU</b>

    瑞薩RZ/T系列MPU的中斷重入實(shí)現(xiàn)

    基于Arm的RZ/T系列MPU通過工業(yè)以太網(wǎng)通信提供高性能和高速實(shí)時(shí)控制,為自動(dòng)化市場構(gòu)建高性能系統(tǒng)R
    的頭像 發(fā)表于 07-23 14:47 ?749次閱讀
    瑞薩<b class='flag-5'>RZ</b>/T系列<b class='flag-5'>MPU</b>的中斷重入實(shí)現(xiàn)

    工業(yè)MPU新標(biāo)桿,多協(xié)議工業(yè)以太網(wǎng)+運(yùn)動(dòng)控制 - 瑞薩RZ/T2H 新產(chǎn)品

    先進(jìn)高端工業(yè)專用MPU RZ/T2H于2024年11月上市,集成了強(qiáng)大的應(yīng)用處理功能和高精度實(shí)時(shí)控制性能,高達(dá)9軸電機(jī)控制。這款產(chǎn)品是在現(xiàn)有
    的頭像 發(fā)表于 12-06 16:57 ?611次閱讀
    <b class='flag-5'>工業(yè)</b><b class='flag-5'>MPU</b>新標(biāo)桿,多協(xié)議<b class='flag-5'>工業(yè)</b>以太網(wǎng)+運(yùn)動(dòng)<b class='flag-5'>控制</b> - 瑞薩<b class='flag-5'>RZ</b>/T2H 新產(chǎn)品
    主站蜘蛛池模板: 作爱在线观看 | 欧美精彩狠狠色丁香婷婷 | 日本高清色视频在线观看免费 | 精品精品国产理论在线观看 | 欧美性一区二区三区五区 | 一区二区三区免费视频网站 | 五月天婷婷在线视频国产在线 | 天天干天天干天天干 | 亚洲色图视频在线 | 国产网站黄| 亚洲电影在线看 | 精品国产一二三区 | 欧美色香蕉 | 亚洲成人精品 | 日韩写真在线 | a级精品九九九大片免费看 a级毛毛片看久久 | 97影院理论在线观看 | 男女艹逼软件 | 国产性较精品视频免费 | 欧美性色视频 | 夜色爽| 日本欧洲亚洲一区在线观看 | 成年免费大片黄在线观看免费 | 亚洲综合亚洲综合网成人 | 国产最好的精华液网站 | 红怡院欧洲 | 侵犯希崎中文字幕在线 | 欧美精品一区二区三区视频 | 大香伊人网 | 在线免费公开视频 | 亚洲国产精品嫩草影院 | 欧美福利二区 | 五月婷婷视频在线 | 94久久国产乱子伦精品免费 | 黄色大片视频网站 | 天天插天天色 | 国产精品一区牛牛影视 | 夜色伊人 | 女人18毛片水多 | 午夜在线视频免费 | 午夜影视剧场 |