当前位置:网站首页>Yocto add application

Yocto add application

2022-06-09 06:04:00 SlamDunk31598

1、 Already exist meta Add to layer

such as yocto Project directory meta-semidrive/recipes-bsp Under the folder , newly build hello-bsp Folder ,

hello-bsp Add the following source files to the folder :

.
├── hello-bsp
│   ├── inc
│   ├── LICENSE
│   ├── Makefile
│   └── src
│       └── hello_bsp.c
└── hello-bsp.bb

2、bb Document writing

hello-bsp.bb In file SRC_URI Specify the file path used for compilation ,S Specifies that the generated image path is located at build/work/ Next ;

do_compile、do_install Specify compilation and deployment methods

  1 SUMMARY = "hello examples demo"                                                                                                                                
  2                                                                                 
  3 LICENSE = "BSD"                                                                 
  4 LIC_FILES_CHKSUM = "file://LICENSE;md5=b30cbe0b980e98bfd9759b1e6ba3d107"        
  5                                                                                 
  6                                                                                 
  7 SRC_URI = "\                                                                    
  8         file://LICENSE \                                                        
  9         file://Makefile \                                                       
 10         file://src/hello_bsp.c \                                                
 11         "                                                                       
 12                                                                                 
 13 S = "${WORKDIR}"                                                                
 14                                                                                 
 15 FILES_${PN} = "\                                                                
 16         /usr/bin/hello_bsp\                                                     
 17 "                                                                               
 18 do_compile() {                                                                  
 19     make MACHINE=${MACHINE}                                                     
 20 }                                                                               
 21                                                                                 
 22 do_install () {                                                                 
 23         install -d ${D}/usr/bin                                                 
 24         install -m 0755 hello_bsp ${D}/usr/bin/hello_bsp                        
 25 } 

3、Makefile

  1 APP := hello_bsp                                                                                                                                               
  2                                                                                 
  3 HELLO_BSP_OBJ  := src/hello_bsp.o                                               
  4                                                                                 
  5 CFLAGS += -Wall -Werror                                                         
  6                                                                                 
  7 all: $(APP)                                                                     
  8                                                                                 
  9 hello_bsp: $(HELLO_BSP_OBJ)                                                     
 10         $(CC) $(LDFLAGS) -o [email protected] $^ $(LDLIBS) -lpthread                           
 11                                                                                 
 12 %.o: %.c                                                                        
 13         $(CC) -c $(CFLAGS) -o [email protected] $^ -I inc/                                     
 14                                                                                 
 15 clean:                                                                          
 16         rm -rf $(APP)  hello_bsp src/*.o  

4、hello_bsp.c Source file

 1 /*                                                                              
  2  * hello.c                                                                      
  3  *                                                                              
  4  * Copyright (c) 2020 Slamdunk.                                                 
  5  * All rights reserved.                                                         
  6  *                                                                              
  7  * Description:                                                                 
  8  *                                                                              
  9  * Revision History:                                                            
 10  * -----------------                                                            
 11  */                                                                             
 12 #include <stdio.h>                                                              
 13                                                                                                                                                                
 14 int main()                                                                      
 15 {                                                                               
 16         printf("hello yfve bsp\r\n");                                           
 17         return 0;                                                               
 18 } 

5、 compile

bitbake hello-bsp 

$ bitbake hello-bsp 
WARNING: Layer x9-gen1 should set LAYERSERIES_COMPAT_x9-gen1 in its conf/layer.conf file to list the core layer names it is compatible with.
WARNING: Layer x9-gen1 should set LAYERSERIES_COMPAT_x9-gen1 in its conf/layer.conf file to list the core layer names it is compatible with.
WARNING: You have included the meta-gnome layer, but 'x11' has not been enabled in your DISTRO_FEATURES. Some bbappend files may not take effect. See the meta-gnome README for details on enabling meta-gnome support.
Loading cache: 100% |###############################################################################################################################| Time: 0:00:00
Loaded 3118 entries from dependency cache.
Parsing recipes:  85% |###########################################################################################################                  | ETA:  0:00:00

The compiled file is located in :

tmp/work/aarch64-sdrv-linux/hello-bsp/1.0-r0/image/usr/bin/hello_bsp

file tmp/work/aarch64-sdrv-linux/hello-bsp/1.0-r0/image/usr/bin/hello_bsp 
tmp/work/aarch64-sdrv-linux/hello-bsp/1.0-r0/image/usr/bin/hello_bsp: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.14.0, BuildID[sha1]=ae7bf505abc6b562980916ef1f64c519055ce77e, not stripped

6、 Add to yocto Integration of rootfs in

 

IMAGE_INSTALL_append = "hello-bsp \"

Recompile the whole project :bitbake core-image-base

tmp/work/x9h_ref_serdes-sdrv-linux/core-image-base/1.0-r0/rootfs/usr/bin/hello_bsp

 

原网站

版权声明
本文为[SlamDunk31598]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203021426384980.html