FAQ_MA35D1_Add a New Recipe in Yocto

Post Reply
ytliu6
Posts: 80
Joined: 08 Nov 2022, 10:28

22 Nov 2022, 14:05

This sample show how to create a recipe which can compile a source and install to MA35D1 Image

1. Create a new folder named helloworld under meta-ma35d1/recipes-support

Code: Select all

~/shared/yocto/sources/meta-ma35d1/recipes-support$ mdkir helloworld
2. Create a new folder named files under helloworld folder

Code: Select all

~/shared/yocto/sources/meta-ma35d1/recipes-support/hello$ mkdir files
3. Create a C file named helloworld.c and the content is shown below

Code: Select all

#include <stdio.h>

int main()
{
    printf("Hello, World!\n");
    return 0;
} 
4. Create a bb file named helloworld.bb and the content is shown below

Code: Select all

SUMMARY = "Demo how to compile a C code and add to root filesystem"
LICENSE = "CLOSED"
SRC_URI = "file://helloworld.c \
      "
S = "${WORKDIR}"

do_compile() {
    ${CC} helloworld.c -o helloworld
}

do_install() {
    install -d ${D}/${bindir}
    install -m 0777 ${S}/helloworld ${D}${bindir}/helloworld
}
INSANE_SKIP_${PN} += "ldflags"
FILES_${PN} = "${bindir}" 
5. Add the recipe to ~/build/conf/local.conf

Code: Select all

IMAGE_INSTALL_append += "  helloworld "
6. Rebuild the image and the helloworld will be in the /usr/bin

#MA35D1 #recipe #Yocto

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests