Skip to contentSkip to conversation

how to bbappend(?) to u-boot-fw-utils to add a custom /etc/fw_env.config??

DISCUSSION Robert P. J. Day 2 participants 3 messages Jul 6, 2016

lore
Share & tools
lore
#0 lore raw

i may be looking at this entirely incorrectly at the moment, but
what is the preferred way to sneak in a custom, target-specific /etc/fw_env.config file when adding u-boot-fw-utils to one's image?

if i examine u-boot-fw-utils_2016.03.bb, i can see that that package
is based on (predictably) the source code for u-boot:

  SRC_URI = "git://git.denx.de/u-boot.git;branch=master"
  S = "${WORKDIR}/git"

which is fine, but if look at the overriding do_install() routine in that recipe file, i see:

  do_install () {
        install -d ${D}${base_sbindir}
        install -d ${D}${sysconfdir}
        install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_printenv
        install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_setenv
        install -m 0644 ${S}/tools/env/fw_env.config ${D}${sysconfdir}/fw_env.config

so as i read it, the last action of do_install() is to install ... the generic fw_env.config file sitting in u-boot's tools/env/ directory, which really has no value. so how does one overcome this?

i poked around and found a couple layers, here's meta-mender:

https://github.com/mendersoftware/meta-mender/blob/master/recipes-bsp/u-boot/u-boot-fw-utils_2015.10.bbappend

which adds a whole new task just to install a custom config file:

# Keep this separately from the rest of the .bb file in case that .bb file is

# overridden from another layer.
require u-boot-mender.inc

DEPENDS = "u-boot"

# Configure fw_printenv so that it looks in the right place for the environment.

do_configure_fw_printenv () {
    cat > ${D}${sysconfdir}/fw_env.config <<EOF

/uboot/uboot.env 0x0000 ${BOOTENV_SIZE}
EOF
}
addtask do_configure_fw_printenv before do_package after do_install

i was expecting to see SRC_URI appending that file; however, if i
look in u-boot.inc, i can see:

    if [ -e ${WORKDIR}/fw_env.config ] ; then
        install -d ${D}${sysconfdir}
        install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
    fi

which is sort of what i was looking for, but the fact that that is in u-boot.inc doesn't seem to affect the u-boot-fw-utils recipe.

so what is the recommended way to add a custom /etc/fw_env.config to
my image if i'm adding u-boot-fw-utils?

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
#1 lore raw
Quoted 55 lines · Robert P. J. Day

i may be looking at this entirely incorrectly at the moment, but
what is the preferred way to sneak in a custom, target-specific /etc/fw_env.config file when adding u-boot-fw-utils to one's image?

if i examine u-boot-fw-utils_2016.03.bb, i can see that that package
is based on (predictably) the source code for u-boot:

   SRC_URI = "git://git.denx.de/u-boot.git;branch=master"
   S = "${WORKDIR}/git"

which is fine, but if look at the overriding do_install() routine in that recipe file, i see:

   do_install () {
         install -d ${D}${base_sbindir}
         install -d ${D}${sysconfdir}
         install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_printenv
         install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_setenv
         install -m 0644 ${S}/tools/env/fw_env.config ${D}${sysconfdir}/fw_env.config

so as i read it, the last action of do_install() is to install ... the generic fw_env.config file sitting in u-boot's tools/env/ directory, which really has no value. so how does one overcome this?

i poked around and found a couple layers, here's meta-mender:

https://github.com/mendersoftware/meta-mender/blob/master/recipes-bsp/u-boot/u-boot-fw-utils_2015.10.bbappend

which adds a whole new task just to install a custom config file:

# Keep this separately from the rest of the .bb file in case that .bb file is

# overridden from another layer.
require u-boot-mender.inc

DEPENDS = "u-boot"

# Configure fw_printenv so that it looks in the right place for the environment.

do_configure_fw_printenv () {
     cat > ${D}${sysconfdir}/fw_env.config <<EOF

/uboot/uboot.env 0x0000 ${BOOTENV_SIZE}
EOF
}
addtask do_configure_fw_printenv before do_package after do_install

i was expecting to see SRC_URI appending that file; however, if i
look in u-boot.inc, i can see:

     if [ -e ${WORKDIR}/fw_env.config ] ; then
         install -d ${D}${sysconfdir}
         install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
     fi
Quoted 5 lines

which is sort of what i was looking for, but the fact that that is in u-boot.inc doesn't seem to affect the u-boot-fw-utils recipe.

so what is the recommended way to add a custom /etc/fw_env.config to
my image if i'm adding u-boot-fw-utils?

I do something like this in my machine layer, in a .u-boot-fw-utils_%.bbappend file:

====================================================================
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += "file://fw_env.config"

do_install_append() {
install -d ${D}${sysconfdir}
install -m 0644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
}

PACKAGE_ARCH = "${MACHINE_ARCH}"

====================================================================

Yes, this "installs" the same file twice, but it does what you need, it installs the desired file in the correct place. And, yes, it's too bad that this "info" is kept in two completely different recipes.

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#2 lore raw

On Wed, 6 Jul 2016, Gary Thomas wrote:

,,, snip ...

Quoted 13 lines

I do something like this in my machine layer, in a .u-boot-fw-utils_%.bbappend file:

====================================================================
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += "file://fw_env.config"

do_install_append() {
   install -d ${D}${sysconfdir}
   install -m 0644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
}
Quoted 8 lines

PACKAGE_ARCH = "${MACHINE_ARCH}"

====================================================================

Yes, this "installs" the same file twice, but it does what you need, it installs the desired file in the correct place. And, yes, it's too bad that this "info" is kept in two completely different recipes.

that is, pretty much, line for line what i came up with as well. as
you suggest, it just seems ... sloppy.

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================