Skip to contentSkip to conversation

u-boot: Add {gen|deploy}_default_envs tasks to generate environment images

PATCH In review Lukasz Majewski 6 participants 25 messages Apr 27, 2018 – May 9, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 u-boot: Add {gen|deploy}_default_envs tasks to generate environment images

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
 meta/recipes-bsp/u-boot/u-boot.inc | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
meta/recipes-bsp/u-boot/u-boot.inc +35 -0
index c2bcf99840..2796e503cf 100644
@@ -305,3 +305,38 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot environment(s)"
+do_gen_default_envs () {
+	${B}/source/scripts/get_default_envs.sh ${B} > ${B}/${DEFAULT_ENVS}
+
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}
+
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}
+
+	rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after do_compile
+
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot environment to deployment directory"
+do_deploy_default_envs () {
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT} ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r
+
+	rm ${B}/${UBOOT_ENVS_DEFAULT}
+	rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after do_gen_default_envs
Signature · 1 line
2.11.0
#1 lore raw
Quoted 9 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

Quoted 18 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
 meta/recipes-bsp/u-boot/u-boot.inc | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
meta/recipes-bsp/u-boot/u-boot.inc +3 -0
index c2bcf99840..2796e503cf 100644
@@ -305,3 +305,38 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 320

Quoted 10 lines
meta/recipes-bsp/u-boot/u-boot.inc +10 -0
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot environment(s)"
+do_gen_default_envs () {
+	${B}/source/scripts/get_default_envs.sh ${B} > ${B}/${DEFAULT_ENVS}
+
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

Does this actually work during cross build , when mkenvimage architecture is different than host architecture ?

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 323

Quoted 2 lines
meta/recipes-bsp/u-boot/u-boot.inc +2 -0
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

Is redundant env always needed on all systems ?

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 336

Quoted 12 lines
meta/recipes-bsp/u-boot/u-boot.inc +12 -0
+	rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after do_compile
+
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot environment to deployment directory"
+do_deploy_default_envs () {
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT} ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r

Does this work with multiple machines or will it overwrite the deployed image ?

Quoted 6 lines
meta/recipes-bsp/u-boot/u-boot.inc +5 -0
+	rm ${B}/${UBOOT_ENVS_DEFAULT}
+	rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after do_gen_default_envs
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

Hi Marek,

Thanks for prompt feedback.

Quoted 5 lines · Lukasz Majewski
Quoted 4 lines

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

Quoted 7 lines
Quoted 5 lines

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

If your default env is correct, why do you need this ?

Some users wants to have the working board (i.e. without any warnings that CRC for envs is bad) after flashing the SPI-NOR/eMMC

Quoted 3 lines

I can see some
use with non-default env, but then that can be wrapped into a separate recipe.

I can add this functionality as a separate recipe. This is v1, so ideas are welcome.

Quoted 25 lines
Quoted 25 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
 meta/recipes-bsp/u-boot/u-boot.inc | 35

+++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)

(quoted diff) +0 -0

b/meta/recipes-bsp/u-boot/u-boot.inc index c2bcf99840..2796e503cf 100644 --- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc

meta/recipes-bsp/u-boot/u-boot.inc +8 -0
@@ -305,3 +305,38 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)" +do_gen_default_envs () {

Quoted 8 lines
Quoted 5 lines
(quoted diff) +1 -0
+	${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS} +

(quoted diff) +2 -0
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

Does this actually work during cross build , when mkenvimage architecture is different than host architecture ?

Yes. This was tested.

Quoted 6 lines
Quoted 4 lines
(quoted diff) +2 -0
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

Is redundant env always needed on all systems ?

No, they are not. However, it shall not be a problem if it is build anyway - user can adjust wic to only put primary env image.

Quoted 17 lines
Quoted 14 lines
meta/recipes-bsp/u-boot/u-boot.inc +4 -0
+	rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after

do_compile +

(quoted diff) +2 -0
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot

environment to deployment directory" +do_deploy_default_envs () {

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT}

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}

(quoted diff) +1 -0
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r
Quoted 1 line

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r

Does this work with multiple machines

Unfortunately not.

For multiple machines one needs to add ${target}, which would add machine name into path:

target=${MACHINE}_defconfig

and change ${B} -> ${B}/${target}

I suppose, that I would need to adjust this script to be similar to do_install() and do_compile() in this matter.

Quoted 2 lines

or will it overwrite the
deployed image ?

As it is now - it will overwrite the image.

Quoted 10 lines
Quoted 8 lines
meta/recipes-bsp/u-boot/u-boot.inc +5 -0
+	rm ${B}/${UBOOT_ENVS_DEFAULT}
+	rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after

do_gen_default_envs

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]

#3 lore raw
Quoted 13 lines · Lukasz Majewski

Hi Marek,

Thanks for prompt feedback.

Quoted 9 lines · Lukasz Majewski
Quoted 8 lines

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

If your default env is correct, why do you need this ?

Some users wants to have the working board (i.e. without any warnings that CRC for envs is bad) after flashing the SPI-NOR/eMMC

And the board is not working when it tells you your env is not populated? Then maybe the board port is broken.

Quoted 6 lines
Quoted 3 lines

I can see some
use with non-default env, but then that can be wrapped into a separate recipe.

I can add this functionality as a separate recipe. This is v1, so ideas are welcome.

I think that only makes sense.

Quoted 33 lines
Quoted 24 lines
Quoted 24 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
 meta/recipes-bsp/u-boot/u-boot.inc | 35

+++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)

(quoted diff) +0 -0

b/meta/recipes-bsp/u-boot/u-boot.inc index c2bcf99840..2796e503cf 100644 --- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc

meta/recipes-bsp/u-boot/u-boot.inc +8 -0
@@ -305,3 +305,38 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)" +do_gen_default_envs () {

Quoted 8 lines
Quoted 5 lines
(quoted diff) +1 -0
+	${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS} +

(quoted diff) +2 -0
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

Does this actually work during cross build , when mkenvimage architecture is different than host architecture ?

Quoted 1 line

Yes. This was tested.

How can it work if this binary cannot be executed ? :)

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
(quoted diff) +2 -0
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

Is redundant env always needed on all systems ?

No, they are not. However, it shall not be a problem if it is build anyway - user can adjust wic to only put primary env image.

So many wasted CPU cycles for a feature barely anyone needs. Nope :)

Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
meta/recipes-bsp/u-boot/u-boot.inc +4 -0
+	rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after

do_compile +

(quoted diff) +2 -0
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot

environment to deployment directory" +do_deploy_default_envs () {

Quoted 8 lines
Quoted 6 lines
meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT}

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}

(quoted diff) +1 -0
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r

Does this work with multiple machines

Unfortunately not.

For multiple machines one needs to add ${target}, which would add machine name into path:

Quoted 7 lines

target=${MACHINE}_defconfig

and change ${B} -> ${B}/${target}

I suppose, that I would need to adjust this script to be similar to do_install() and do_compile() in this matter.

Yep

Quoted 4 lines
Quoted 2 lines

or will it overwrite the
deployed image ?

As it is now - it will overwrite the image.

Yep

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

Hi Marek,

Quoted 16 lines · Lukasz Majewski
Quoted 15 lines

Hi Marek,

Thanks for prompt feedback.

Quoted 11 lines · Lukasz Majewski
Quoted 9 lines

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

If your default env is correct, why do you need this ?

Some users wants to have the working board (i.e. without any warnings that CRC for envs is bad) after flashing the SPI-NOR/eMMC

And the board is not working when it tells you your env is not populated?

It complains that CRC is wrong, which is true as without this patch (and some wic adjustments) we don't have proper envs in expected non-volatile area.

Quoted 1 line

Then maybe the board port is broken.

Then it proceeds with default envs - and boots.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

I can see some
use with non-default env, but then that can be wrapped into a separate recipe.

I can add this functionality as a separate recipe. This is v1, so ideas are welcome.

I think that only makes sense.

Ok.

Quoted 35 lines
Quoted 35 lines
Quoted 34 lines
Quoted 30 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
 meta/recipes-bsp/u-boot/u-boot.inc | 35

+++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)

(quoted diff) +0 -0

b/meta/recipes-bsp/u-boot/u-boot.inc index c2bcf99840.cdd7703db9ea580308d4ebcd6d0ae3209b761daa.2796e503cf 100644 --- a/meta/recipes-bsp/u-boot/u-boot.inc +++ b/meta/recipes-bsp/u-boot/u-boot.inc @@ -305,3 +305,38 @@ do_deploy () { }

addtask deploy before do_build after do_compile

meta/recipes-bsp/u-boot/u-boot.inc +8 -0
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)" +do_gen_default_envs () {

(quoted diff) +1 -0
+	${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS} +

(quoted diff) +2 -0
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o
Quoted 1 line

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

Does this actually work during cross build , when mkenvimage architecture is different than host architecture ?

Quoted 3 lines
Quoted 1 line

Yes. This was tested.

How can it work if this binary cannot be executed ? :)

Could you be more specific here?

I do follow normal u-boot recipe build. If mkenvimage is build in a wrong way (as other tools) - then I suppose that the whole u-boot recipe is broken.

The get_default_envs.sh script is prepared to use either native or cross-compiled set of binutils (that thought I had in mind when I said that it was tested).

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
(quoted diff) +2 -0
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

Is redundant env always needed on all systems ?

No, they are not. However, it shall not be a problem if it is build anyway - user can adjust wic to only put primary env image.

So many wasted CPU cycles for a feature barely anyone needs. Nope :)

I will try to craft some OE magic to make it not build when not needed... :-)

Quoted 25 lines
Quoted 25 lines
Quoted 17 lines
Quoted 14 lines
meta/recipes-bsp/u-boot/u-boot.inc +4 -0
+	rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after

do_compile +

(quoted diff) +2 -0
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot

environment to deployment directory" +do_deploy_default_envs () {

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT}

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}

(quoted diff) +1 -0
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r
Quoted 1 line

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r

Does this work with multiple machines

Unfortunately not.

For multiple machines one needs to add ${target}, which would add machine name into path:

target=${MACHINE}_defconfig

Quoted 7 lines
Quoted 5 lines

and change ${B} -> ${B}/${target}

I suppose, that I would need to adjust this script to be similar to do_install() and do_compile() in this matter.

Yep

Ok.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

or will it overwrite the
deployed image ?

As it is now - it will overwrite the image.

Yep

Ok.

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]

#5 lore raw
Quoted 1 line · Lukasz Majewski

Hi Marek,

Hello Lukasz,

Quoted 21 lines
Quoted 21 lines · Lukasz Majewski
Quoted 19 lines

Hi Marek,

Thanks for prompt feedback.

Quoted 5 lines · Lukasz Majewski
Quoted 4 lines

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

Quoted 7 lines
Quoted 5 lines

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

If your default env is correct, why do you need this ?

Some users wants to have the working board (i.e. without any warnings that CRC for envs is bad) after flashing the SPI-NOR/eMMC

Quoted 6 lines
Quoted 2 lines

And the board is not working when it tells you your env is not populated?

It complains that CRC is wrong, which is true as without this patch (and some wic adjustments) we don't have proper envs in expected non-volatile area.

This is NOT an error, this is warning and a correct behavior. If your default U-Boot environment is not correct, that is a bug in your U-Boot port.

If you need to adjust that environment later in the product life cycle, that's a different topic.

Quoted 3 lines
Quoted 1 line

Then maybe the board port is broken.

Then it proceeds with default envs - and boots.

I think I might not quite understand the problem anymore. Is the issue here that U-Boot informs you that it's using default environment which you do not like ?

[...]

Quoted 18 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
(quoted diff) +2 -0
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)" +do_gen_default_envs () {

(quoted diff) +1 -0
+	${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS} +

(quoted diff) +2 -0
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

Does this actually work during cross build , when mkenvimage architecture is different than host architecture ?

Quoted 3 lines
Quoted 1 line

Yes. This was tested.

How can it work if this binary cannot be executed ? :)

Could you be more specific here?

Quoted 7 lines

I do follow normal u-boot recipe build. If mkenvimage is build in a wrong way (as other tools) - then I suppose that the whole u-boot recipe is broken.

The get_default_envs.sh script is prepared to use either native or cross-compiled set of binutils (that thought I had in mind when I said that it was tested).

Consider you crosscompile mkenvimage for ARM and try to run it on x86 host.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
(quoted diff) +2 -0
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

Is redundant env always needed on all systems ?

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

No, they are not. However, it shall not be a problem if it is build anyway - user can adjust wic to only put primary env image.

So many wasted CPU cycles for a feature barely anyone needs. Nope :)

I will try to craft some OE magic to make it not build when not needed... :-)

Can't you just patch a correct default env into the U-Boot port ?

Signature · 2 lines
Best regards,
Marek Vasut
#6 lore raw
In reply to Marek Vasut
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Lukasz Majewski

I can add this functionality as a separate recipe. This is v1, so ideas are welcome.

I think that only makes sense.

Also, we likely need to make use of the mkimage recipe so we use the tools and not build it all again.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#7 lore raw
Quoted 10 lines · Otavio Salvador
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Lukasz Majewski

I can add this functionality as a separate recipe. This is v1, so ideas are welcome.

I think that only makes sense.

Also, we likely need to make use of the mkimage recipe so we use the tools and not build it all again.

And -- based on the offlist discussion -- I realized that env tools are machine specific, they bundle default env with them.

Signature · 2 lines
Best regards,
Marek Vasut
#8 lore raw
In reply to Marek Vasut
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

Quoted 54 lines
Quoted 18 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
 meta/recipes-bsp/u-boot/u-boot.inc | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
meta/recipes-bsp/u-boot/u-boot.inc +3 -0
index c2bcf99840..2796e503cf 100644
@@ -305,3 +305,38 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 320

Quoted 10 lines
meta/recipes-bsp/u-boot/u-boot.inc +10 -0
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot environment(s)"
+do_gen_default_envs () {
+	${B}/source/scripts/get_default_envs.sh ${B} > ${B}/${DEFAULT_ENVS}
+
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

Does this actually work during cross build , when mkenvimage architecture is different than host architecture ?

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 323

Quoted 2 lines
meta/recipes-bsp/u-boot/u-boot.inc +2 -0
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

Is redundant env always needed on all systems ?

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 336

Quoted 12 lines
meta/recipes-bsp/u-boot/u-boot.inc +12 -0
+	rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after do_compile
+
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot environment to deployment directory"
+do_deploy_default_envs () {
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT} ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r

Does this work with multiple machines or will it overwrite the deployed image ?

Quoted 8 lines

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 342

Quoted 6 lines
meta/recipes-bsp/u-boot/u-boot.inc +5 -0
+	rm ${B}/${UBOOT_ENVS_DEFAULT}
+	rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after do_gen_default_envs

Regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#9 lore raw
Quoted 17 lines · Stefano Babic
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

Quoted 7 lines

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

I think in that case, the real solution is to either build fw_setenv per machine OR fix fw_setenv to take env defaults from a file or somesuch ?

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#10 lore raw
Quoted 26 lines · Marek Vasut
Quoted 17 lines · Stefano Babic
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

Quoted 7 lines

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

Quoted 2 lines

I think in that case, the real solution is to either build fw_setenv per machine

This is how we try to do now, fw_setenv is built per machine but it is enough that u-boot-fw-utils is built in a different version as u-boot to get a mess.

Quoted 1 line

OR fix fw_setenv to take env defaults from a file or somesuch ?

Right, I interprete this patch as a step in this direction. This patch generates a default that can be used as input for fw_setenv.

Regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#11 lore raw
Quoted 27 lines · Stefano Babic
Quoted 26 lines · Marek Vasut
Quoted 24 lines · Stefano Babic
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

Quoted 6 lines
Quoted 2 lines

I think in that case, the real solution is to either build fw_setenv per machine

This is how we try to do now, fw_setenv is built per machine but it is enough that u-boot-fw-utils is built in a different version as u-boot to get a mess.

Well yes, if you mix and match packages, it becomes a mess. Isn't that to be expected ?

Quoted 4 lines
Quoted 1 line

OR fix fw_setenv to take env defaults from a file or somesuch ?

Right, I interprete this patch as a step in this direction. This patch generates a default that can be used as input for fw_setenv.

It generates environment images which can be written -- on certain specific setups -- into the flash. It doesn't generate any sort of input for the fw_setenv to my knowledge ?

Signature · 2 lines
Best regards,
Marek Vasut
#12 lore raw

Hi Marek, Stefano,

Quoted 40 lines · Stefano Babic
Quoted 29 lines · Marek Vasut
Quoted 28 lines · Stefano Babic
Quoted 26 lines · Marek Vasut
Quoted 10 lines · Lukasz Majewski
Quoted 9 lines

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

Quoted 6 lines
Quoted 2 lines

I think in that case, the real solution is to either build fw_setenv per machine

This is how we try to do now, fw_setenv is built per machine but it is enough that u-boot-fw-utils is built in a different version as u-boot to get a mess.

Well yes, if you mix and match packages, it becomes a mess. Isn't that to be expected ?

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

OR fix fw_setenv to take env defaults from a file or somesuch ?

Right, I interprete this patch as a step in this direction. This patch generates a default that can be used as input for fw_setenv.

It generates environment images which can be written -- on certain specific setups -- into the flash. It doesn't generate any sort of input for the fw_setenv to my knowledge ?

I think that it would be great if:

1. We would have this code as a separate recipe - as suggested by Marek and Stefano already. This recipe would end up as a package to be installed on the rootfs

2. As input I would use default_envs.txt (or any other name) - either extracted from u-boot build or provided from external file

3. For now I do use mkenvimage -> and I do have env image [*] to be flashed on the board.

However, I do wonder if for the default fw_setenv envs we could:

- modify fw_setenv to read (and store) [*] when no correct default env is available

I must check if fw_setenv handles images generated by mkenvimage (or boot.src [1] generated by mkimage).

[1] - <u-boot repo>/board/samsung/common/bootscripts/autoboot.cmd

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]

#13 lore raw
Quoted 58 lines · Lukasz Majewski

Hi Marek, Stefano,

Quoted 40 lines · Stefano Babic
Quoted 29 lines · Marek Vasut
Quoted 28 lines · Stefano Babic
Quoted 26 lines · Marek Vasut
Quoted 10 lines · Lukasz Majewski
Quoted 9 lines

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

Quoted 6 lines
Quoted 2 lines

I think in that case, the real solution is to either build fw_setenv per machine

This is how we try to do now, fw_setenv is built per machine but it is enough that u-boot-fw-utils is built in a different version as u-boot to get a mess.

Well yes, if you mix and match packages, it becomes a mess. Isn't that to be expected ?

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

OR fix fw_setenv to take env defaults from a file or somesuch ?

Right, I interprete this patch as a step in this direction. This patch generates a default that can be used as input for fw_setenv.

It generates environment images which can be written -- on certain specific setups -- into the flash. It doesn't generate any sort of input for the fw_setenv to my knowledge ?

I think that it would be great if:

1. We would have this code as a separate recipe - as suggested by Marek and Stefano already. This recipe would end up as a package to be installed on the rootfs

Quoted 5 lines

2. As input I would use default_envs.txt (or any other name) - either extracted from u-boot build or provided from external file

3. For now I do use mkenvimage -> and I do have env image [*] to be flashed on the board.

Sounds about good. I think this approach fails with NAND, so be careful there.

Quoted 4 lines

However, I do wonder if for the default fw_setenv envs we could:

- modify fw_setenv to read (and store) [*] when no correct default env is available

Or add some build-time option to build it with blank default env. Then you can apply your file-based approach, the setenv would be board-agnostic and it should do I guess ?

Signature · 2 lines
Best regards,
Marek Vasut
#14 lore raw

Hi Marek, Stefano,

Quoted 56 lines · Lukasz Majewski
Quoted 55 lines

Hi Marek, Stefano,

Quoted 52 lines · Stefano Babic
Quoted 30 lines · Marek Vasut
Quoted 29 lines · Stefano Babic
Quoted 27 lines · Marek Vasut
Quoted 10 lines · Lukasz Majewski
Quoted 9 lines

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

Quoted 6 lines
Quoted 2 lines

I think in that case, the real solution is to either build fw_setenv per machine

This is how we try to do now, fw_setenv is built per machine but it is enough that u-boot-fw-utils is built in a different version as u-boot to get a mess.

Well yes, if you mix and match packages, it becomes a mess. Isn't that to be expected ?

Quoted 6 lines
Quoted 2 lines

OR fix fw_setenv to take env defaults from a file or somesuch ?

Right, I interprete this patch as a step in this direction. This patch generates a default that can be used as input for fw_setenv.

It generates environment images which can be written -- on certain specific setups -- into the flash. It doesn't generate any sort of input for the fw_setenv to my knowledge ?

Quoted 5 lines
Quoted 5 lines

I think that it would be great if:

1. We would have this code as a separate recipe - as suggested by Marek and Stefano already. This recipe would end up as a package to be installed on the rootfs

I've looked a bit more on the topic, and I do have some further questions:

1. It seems like u-boot is compiled at least twice - once when do_comiple() is invoked in u-boot.inc (here we support multiple configs, and targets) and in u-boot-fw-utils (also u-boot-mkimage compiles u-boot for sandbox_defconfig).

It seems like the synchronization of the built package (and envs) is ensured with u-boot-common_2018.03.inc package.

2. It seems like it would be feasible to have a separate recipe - u-boot-envs_2018.03.bb [*] which would:

- Use u-boot-env.txt provided as an external file (from e.g. SRC += "./file/u-boot-env.txt"). This is the approach similar to
https://github.com/webosose/meta-webosose/blob/master/meta-webos-raspberrypi/recipes-bsp/u-boot/u-boot-env.bb

- If above input *.txt file is not present then get the envs extracted from built u-boot.

The main question for above item - how and where to extract this file?

- The most feasible would be to extend do_compile of u-boot.inc to run get_default_envs.sh script there (as it builds all the kind of u-boot variants/binaries).

- Then "export" those generated *.txt files to [*] recipe. What would be the best way?

Via ${DEPLOYDIR} ? Install it on /boot directory (exported by u-boot) ?

Quoted 10 lines
Quoted 6 lines

2. As input I would use default_envs.txt (or any other name) - either extracted from u-boot build or provided from external file

3. For now I do use mkenvimage -> and I do have env image [*] to be flashed on the board.

Sounds about good. I think this approach fails with NAND, so be careful there.

Quoted 8 lines
Quoted 4 lines

However, I do wonder if for the default fw_setenv envs we could:

- modify fw_setenv to read (and store) [*] when no correct default env is available

Or add some build-time option to build it with blank default env. Then you can apply your file-based approach, the setenv would be board-agnostic and it should do I guess ?

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]

#15 lore raw
Quoted 92 lines · Lukasz Majewski

Hi Marek, Stefano,

Quoted 56 lines · Lukasz Majewski
Quoted 55 lines

Hi Marek, Stefano,

Quoted 52 lines · Stefano Babic
Quoted 30 lines · Marek Vasut
Quoted 29 lines · Stefano Babic
Quoted 27 lines · Marek Vasut
Quoted 10 lines · Lukasz Majewski
Quoted 9 lines

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

Quoted 6 lines
Quoted 2 lines

I think in that case, the real solution is to either build fw_setenv per machine

This is how we try to do now, fw_setenv is built per machine but it is enough that u-boot-fw-utils is built in a different version as u-boot to get a mess.

Well yes, if you mix and match packages, it becomes a mess. Isn't that to be expected ?

Quoted 6 lines
Quoted 2 lines

OR fix fw_setenv to take env defaults from a file or somesuch ?

Right, I interprete this patch as a step in this direction. This patch generates a default that can be used as input for fw_setenv.

It generates environment images which can be written -- on certain specific setups -- into the flash. It doesn't generate any sort of input for the fw_setenv to my knowledge ?

Quoted 5 lines
Quoted 5 lines

I think that it would be great if:

1. We would have this code as a separate recipe - as suggested by Marek and Stefano already. This recipe would end up as a package to be installed on the rootfs

I've looked a bit more on the topic, and I do have some further questions:

1. It seems like u-boot is compiled at least twice - once when do_comiple() is invoked in u-boot.inc (here we support multiple configs, and targets) and in u-boot-fw-utils (also u-boot-mkimage compiles u-boot for sandbox_defconfig).

It seems like the synchronization of the built package (and envs) is ensured with u-boot-common_2018.03.inc package.

2. It seems like it would be feasible to have a separate recipe - u-boot-envs_2018.03.bb [*] which would:

- Use u-boot-env.txt provided as an external file (from e.g. SRC += "./file/u-boot-env.txt"). This is the approach similar to
https://github.com/webosose/meta-webosose/blob/master/meta-webos-raspberrypi/recipes-bsp/u-boot/u-boot-env.bb

- If above input *.txt file is not present then get the envs extracted from built u-boot.

The main question for above item - how and where to extract this file?

- The most feasible would be to extend do_compile of u-boot.inc to run get_default_envs.sh script there (as it builds all the kind of u-boot variants/binaries).

Quoted 5 lines

- Then "export" those generated *.txt files to [*] recipe. What would be the best way?

Via ${DEPLOYDIR} ? Install it on /boot directory (exported by u-boot) ?

Compile the fw env utils per-machine for now and in parallel add option to compile it with blank env and use env from file into upstream u-boot fwutils ?

Signature · 2 lines
Best regards,
Marek Vasut
#16 lore raw
In reply to Marek Vasut

Hi Marek,

Quoted 31 lines · Marek Vasut
Quoted 30 lines · Stefano Babic
Quoted 28 lines · Marek Vasut
Quoted 17 lines · Stefano Babic
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

Quoted 7 lines

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

I think in that case, the real solution is to either build fw_setenv per machine

Quoted 7 lines
Quoted 3 lines

This is how we try to do now, fw_setenv is built per machine but it is enough that u-boot-fw-utils is built in a different version as u-boot to get a mess.

Well yes, if you mix and match packages, it becomes a mess. Isn't that to be expected ?

Well, quite. But in the specific case, it is weird that the environment tools are built by a separate recipe. u-boot-fw-utils generates binaries from the same sources as u-boot (or it should), and building the tool per machine means for me to have a single recipe for it, that generates as additional package the env tools. This guarantees that they are always in sync.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

OR fix fw_setenv to take env defaults from a file or somesuch ?

Having a separate recipe as now means for me to try to have the tools not per machine, and then makes sense to pass as input the default environment to the tools.

Quoted 6 lines
Quoted 2 lines

Right, I interprete this patch as a step in this direction. This patch generates a default that can be used as input for fw_setenv.

It generates environment images which can be written -- on certain specific setups -- into the flash. It doesn't generate any sort of input for the fw_setenv to my knowledge ?

Not the current patch - we are discussing how it could evolve ;-)

Regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#17 lore raw
Quoted 42 lines · Stefano Babic

Hi Marek,

Quoted 31 lines · Marek Vasut
Quoted 30 lines · Stefano Babic
Quoted 28 lines · Marek Vasut
Quoted 17 lines · Stefano Babic
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

Quoted 6 lines
Quoted 1 line

If your default env is correct, why do you need this ? I can see some use with non-default env, but then that can be wrapped into a separate recipe.

Quoted 7 lines

A use case is when the environment must be changed from user space. fw_setenv will report the CRC error and it needs the default environment to add changes. The default environment is linked together to fw_setenv, but this prohibites to use fw_setenv for multiple boards and must be explicitely built for that machine and with the same sources as u-boot (at least, they must share the same CONFIG_EXTRA_ENV). If the default environment is extracted, we could have a general (distro ?) fw_setenv.

I think in that case, the real solution is to either build fw_setenv per machine

Quoted 7 lines
Quoted 3 lines

This is how we try to do now, fw_setenv is built per machine but it is enough that u-boot-fw-utils is built in a different version as u-boot to get a mess.

Well yes, if you mix and match packages, it becomes a mess. Isn't that to be expected ?

Quoted 6 lines

Well, quite. But in the specific case, it is weird that the environment tools are built by a separate recipe. u-boot-fw-utils generates binaries from the same sources as u-boot (or it should), and building the tool per machine means for me to have a single recipe for it, that generates as additional package the env tools. This guarantees that they are always in sync.

Patches welcome ? :)

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

OR fix fw_setenv to take env defaults from a file or somesuch ?

Having a separate recipe as now means for me to try to have the tools not per machine, and then makes sense to pass as input the default environment to the tools.

Cfr the conclusion (?) we reached with Lukasz I think ?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Right, I interprete this patch as a step in this direction. This patch generates a default that can be used as input for fw_setenv.

It generates environment images which can be written -- on certain specific setups -- into the flash. It doesn't generate any sort of input for the fw_setenv to my knowledge ?

Not the current patch - we are discussing how it could evolve ;-)

Ah, I wonder if we shouldn't start a new thread for this and crosspost it to the U-Boot ML too then ?

Signature · 2 lines
Best regards,
Marek Vasut
#18 lore raw
In reply to Lukasz Majewski

Hi Lukasz,

Quoted 7 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

I think we should create a separate recipe to install the native mkenvimage binary (e.g. u-boot-mkenvimage_%.bb) or update u-boot-mkimage_%.bb install it.

Then a new recipe to create the environment images can depend on u-boot-mkenvimage-native.

Also note the recently added upstream support for external environment definitions:
http://git.denx.de/?p=u-boot.git;a=commit;h=f3d8f7dd73ac5dde258eb786d4a01869395b56d7

For our usecase we need the ability to generate environment images in yocto from such external definitions.

// Martin

Quoted 54 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
  meta/recipes-bsp/u-boot/u-boot.inc | 35 +++++++++++++++++++++++++++++++++++
  1 file changed, 35 insertions(+)
meta/recipes-bsp/u-boot/u-boot.inc +35 -0
index c2bcf99840..2796e503cf 100644
@@ -305,3 +305,38 @@ do_deploy () {
  }
 
  addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot environment(s)"
+do_gen_default_envs () {
+	${B}/source/scripts/get_default_envs.sh ${B} > ${B}/${DEFAULT_ENVS}
+
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}
+
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}
+
+	rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after do_compile
+
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot environment to deployment directory"
+do_deploy_default_envs () {
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT} ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r
+
+	rm ${B}/${UBOOT_ENVS_DEFAULT}
+	rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after do_gen_default_envs
#19 lore raw

Hi Martin,

Quoted 7 lines

Hi Lukasz,

Quoted 4 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

Quoted 7 lines
Quoted 3 lines

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

I think we should create a separate recipe to install the native mkenvimage binary (e.g. u-boot-mkenvimage_%.bb) or update u-boot-mkimage_%.bb install it.

I see your point.
I suppose that the above idea is more OE style than:

${B}/tools/mkenvimage
and DEPENDS = "u-boot:compile"

Quoted 3 lines

Then a new recipe to create the environment images can depend on u-boot-mkenvimage-native.

Ok.

Quoted 4 lines

Also note the recently added upstream support for external environment definitions:
http://git.denx.de/?p=u-boot.git;a=commit;h=f3d8f7dd73ac5dde258eb786d4a01869395b56d7

Those features are complementary.

1. Envs definition from CONFIG_EXTRA_ENV_SETTINGS are provided externally,

2. The one generated by source/scripts/get_default_envs.sh are simply the ones from u-boot's "default environment" (extracted from the binary).

They both produce *.txt file which is the input for mkenvimage.

Quoted 3 lines

For our usecase we need the ability to generate environment images in yocto from such external definitions.

Ok. I see.

Quoted 50 lines

// Martin

Quoted 47 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
  meta/recipes-bsp/u-boot/u-boot.inc | 35

+++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)

(quoted diff) +0 -0

b/meta/recipes-bsp/u-boot/u-boot.inc index c2bcf99840..2796e503cf 100644 --- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc

meta/recipes-bsp/u-boot/u-boot.inc +8 -0
@@ -305,3 +305,38 @@ do_deploy () {
  }
 
  addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)" +do_gen_default_envs () {

(quoted diff) +1 -0
+	${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS} +

(quoted diff) +2 -0
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS} +

(quoted diff) +2 -0
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS} +

meta/recipes-bsp/u-boot/u-boot.inc +4 -0
+	rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after

do_compile +

(quoted diff) +2 -0
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot

environment to deployment directory" +do_deploy_default_envs () {

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT}

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}

Quoted 8 lines
Quoted 8 lines
(quoted diff) +1 -0
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r +

meta/recipes-bsp/u-boot/u-boot.inc +5 -0
+	rm ${B}/${UBOOT_ENVS_DEFAULT}
+	rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after

do_gen_default_envs

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]

#20 lore raw
In reply to Martin Hundebøll

u-boot-mkimage already builds mkenvimage, you just need to install it in do_install:

    install -m 0755 tools/mkenvimage ${D}${bindir}/uboot-mkenvimage
    ln -sf uboot-mkenvimage ${D}${bindir}/mkenvimage

This is what we have in recipes-bsp/u-boot/u-boot-mkimage_%.bbappend and it works fine.

Quoted 98 lines · Martin Hundebøll

Hi Lukasz,

Quoted 8 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

I think we should create a separate recipe to install the native mkenvimage binary (e.g. u-boot-mkenvimage_%.bb) or update u-boot-mkimage_%.bb install it.

Then a new recipe to create the environment images can depend on u-boot-mkenvimage-native.

Also note the recently added upstream support for external environment definitions:
http://git.denx.de/?p=u-boot.git;a=commit;h=f3d8f7dd73ac5dde
258eb786d4a01869395b56d7

For our usecase we need the ability to generate environment images in yocto from such external definitions.

// Martin

Quoted 54 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
  meta/recipes-bsp/u-boot/u-boot.inc | 35 ++++++++++++++++++++++++++++++
+++++
  1 file changed, 35 insertions(+)
meta/recipes-bsp/u-boot/u-boot.inc +8 -0
index c2bcf99840..2796e503cf 100644
@@ -305,3 +305,38 @@ do_deploy () {
  }
    addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)"

meta/recipes-bsp/u-boot/u-boot.inc +2 -0
+do_gen_default_envs () {
+       ${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+
+       # Generate env image
+       ${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+
+       # Generate redundant env image
+       ${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +8 -0
+
+       rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after do_compile
+
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot

environment to deployment directory"

meta/recipes-bsp/u-boot/u-boot.inc +4 -0
+do_deploy_default_envs () {
+       install -d ${DEPLOYDIR}
+
+       install ${B}/${UBOOT_ENVS_DEFAULT} ${DEPLOYDIR}/${UBOOT_ENVS_DEFA

ULT}
+ install ${B}/${UBOOT_ENVS_DEFAULT}_r
${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () {

Quoted 8 lines
meta/recipes-bsp/u-boot/u-boot.inc +6 -1
+
+       rm ${B}/${UBOOT_ENVS_DEFAULT}
+       rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after do_gen_default_envs
 
--

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#21 lore raw

And here is example how we're using it:

https://github.com/webosose/meta-webosose/blob/master/meta-webos-raspberrypi/recipes-bsp/u-boot/u-boot-env.bb

To make it compatible with raspberrypi3 and raspberrypi3-64, I've updated it a bit to select correct IMAGETYPE and BOOTCMD based on the environment:

do_compile() {
    sed -e 's/@@KERNEL_IMAGETYPE@@/${KERNEL_IMAGETYPE}/' \
        -e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \
        "${WORKDIR}/uboot-env.txt.in" > "${WORKDIR}/uboot-env.txt"
    uboot-mkenvimage -s 16384 -o uboot.env ${WORKDIR}/uboot-env.txt
}
Quoted 112 lines · Martin Jansa

u-boot-mkimage already builds mkenvimage, you just need to install it in do_install:

    install -m 0755 tools/mkenvimage ${D}${bindir}/uboot-mkenvimage
    ln -sf uboot-mkenvimage ${D}${bindir}/mkenvimage

This is what we have in recipes-bsp/u-boot/u-boot-mkimage_%.bbappend and it works fine.

Quoted 99 lines · Martin Hundebøll

Hi Lukasz,

Quoted 9 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase,
as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

I think we should create a separate recipe to install the native mkenvimage binary (e.g. u-boot-mkenvimage_%.bb) or update u-boot-mkimage_%.bb install it.

Then a new recipe to create the environment images can depend on u-boot-mkenvimage-native.

Also note the recently added upstream support for external environment definitions:
http://git.denx.de/?p=u-boot.git;a=commit;h=f3d8f7dd73ac5dde
258eb786d4a01869395b56d7

For our usecase we need the ability to generate environment images in yocto from such external definitions.

// Martin

Quoted 54 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
  meta/recipes-bsp/u-boot/u-boot.inc | 35 ++++++++++++++++++++++++++++++
+++++
  1 file changed, 35 insertions(+)
meta/recipes-bsp/u-boot/u-boot.inc +8 -0
index c2bcf99840..2796e503cf 100644
@@ -305,3 +305,38 @@ do_deploy () {
  }
    addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)"

meta/recipes-bsp/u-boot/u-boot.inc +2 -0
+do_gen_default_envs () {
+       ${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+
+       # Generate env image
+       ${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+
+       # Generate redundant env image
+       ${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +8 -0
+
+       rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after do_compile
+
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot

environment to deployment directory"

meta/recipes-bsp/u-boot/u-boot.inc +4 -0
+do_deploy_default_envs () {
+       install -d ${DEPLOYDIR}
+
+       install ${B}/${UBOOT_ENVS_DEFAULT} ${DEPLOYDIR}/${UBOOT_ENVS_DEFA

ULT}
+ install ${B}/${UBOOT_ENVS_DEFAULT}_r
${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () {

Quoted 8 lines
meta/recipes-bsp/u-boot/u-boot.inc +6 -1
+
+       rm ${B}/${UBOOT_ENVS_DEFAULT}
+       rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after do_gen_default_envs
 
--

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#22 lore raw

Hi Martin,

Quoted 8 lines

And here is example how we're using it:

https://github.com/webosose/meta-webosose/blob/master/meta-webos-raspberrypi/recipes-bsp/u-boot/u-boot-env.bb

To make it compatible with raspberrypi3 and raspberrypi3-64, I've updated it a bit to select correct IMAGETYPE and BOOTCMD based on the environment:

Quoted 7 lines
do_compile() {
    sed -e 's/@@KERNEL_IMAGETYPE@@/${KERNEL_IMAGETYPE}/' \
        -e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \
        "${WORKDIR}/uboot-env.txt.in" > "${WORKDIR}/uboot-env.txt"
    uboot-mkenvimage -s 16384 -o uboot.env ${WORKDIR}/uboot-env.txt
}

Thanks for sharing the code (and detailed explanation).

Quoted 109 lines
Quoted 105 lines · Martin Jansa

u-boot-mkimage already builds mkenvimage, you just need to install it in do_install:

    install -m 0755 tools/mkenvimage ${D}${bindir}/uboot-mkenvimage
    ln -sf uboot-mkenvimage ${D}${bindir}/mkenvimage

This is what we have in recipes-bsp/u-boot/u-boot-mkimage_%.bbappend and it works fine.

Quoted 94 lines · Martin Hundebøll

Hi Lukasz,

Quoted 9 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase,
as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

I think we should create a separate recipe to install the native mkenvimage binary (e.g. u-boot-mkenvimage_%.bb) or update u-boot-mkimage_%.bb install it.

Then a new recipe to create the environment images can depend on u-boot-mkenvimage-native.

Also note the recently added upstream support for external environment definitions:
http://git.denx.de/?p=u-boot.git;a=commit;h=f3d8f7dd73ac5dde
258eb786d4a01869395b56d7

For our usecase we need the ability to generate environment images in yocto from such external definitions.

// Martin

Quoted 62 lines

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
  meta/recipes-bsp/u-boot/u-boot.inc | 35
++++++++++++++++++++++++++++++ +++++
  1 file changed, 35 insertions(+)
meta/recipes-bsp/u-boot/u-boot.inc +8 -0
index c2bcf99840..2796e503cf 100644
@@ -305,3 +305,38 @@ do_deploy () {
  }
    addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)"

meta/recipes-bsp/u-boot/u-boot.inc +2 -0
+do_gen_default_envs () {
+       ${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+
+       # Generate env image
+       ${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+
+       # Generate redundant env image
+       ${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc +5 -0
+
+       rm ${B}/${DEFAULT_ENVS}
+}
+
+addtask gen_default_envs before do_deploy_default_envs after

do_compile +

meta/recipes-bsp/u-boot/u-boot.inc +2 -0
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot

environment to deployment directory"

meta/recipes-bsp/u-boot/u-boot.inc +4 -0
+do_deploy_default_envs () {
+       install -d ${DEPLOYDIR}
+
+       install ${B}/${UBOOT_ENVS_DEFAULT}

${DEPLOYDIR}/${UBOOT_ENVS_DEFA ULT}
+ install ${B}/${UBOOT_ENVS_DEFAULT}_r
${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r

meta/recipes-bsp/u-boot/u-boot.inc +6 -0
+
+       rm ${B}/${UBOOT_ENVS_DEFAULT}
+       rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after

do_gen_default_envs

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]

#23 lore raw
In reply to Lukasz Majewski

Hi Lukasz,

Quoted 35 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
 meta/recipes-bsp/u-boot/u-boot.inc | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
meta/recipes-bsp/u-boot/u-boot.inc +10 -0
index c2bcf99840..2796e503cf 100644
@@ -305,3 +305,38 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot environment(s)"
+do_gen_default_envs () {
+	${B}/source/scripts/get_default_envs.sh ${B} > ${B}/${DEFAULT_ENVS}

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 327

Quoted 10 lines
meta/recipes-bsp/u-boot/u-boot.inc +10 -0
+
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS}
+
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o ${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS}
+
+	rm ${B}/${DEFAULT_ENVS}
+}
+

Why do we need a separate task ? Is it not part of do_compile ?

Quoted 6 lines
meta/recipes-bsp/u-boot/u-boot.inc +5 -0
+addtask gen_default_envs before do_deploy_default_envs after do_compile
+
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot environment to deployment directory"
+do_deploy_default_envs () {

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 342

Quoted 10 lines
meta/recipes-bsp/u-boot/u-boot.inc +10 -0
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT} ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r ${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r
+
+	rm ${B}/${UBOOT_ENVS_DEFAULT}
+	rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after do_gen_default_envs

I would like to see that the default environment is installed and delivered as (additional) package. I could then add it to my rootfs and use it to set up the environment in user space in case a CRC error is reported by the env tools.

Regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#24 lore raw
Quoted 42 lines · On Thu, 3 May 2018 18:24:32 +0200 Stefano Babic <[email protected]> wrote:

Hi Lukasz,

Quoted 39 lines · Lukasz Majewski

This commit provides the ability to generate u-boot environment(s) as images, which afterwards can be used to produce image (with wic) for flashing (eMMC or SPI-NOR).

This change removes the need to run "env default" during production phase, as proper environment (including redundant one) is already stored on persistent memory (the CRC is also correct).

---
This patch depends on "u-boot: Upgrade to 2018.03 release"
https://patchwork.openembedded.org/patch/149998/

---
 meta/recipes-bsp/u-boot/u-boot.inc | 35

+++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)

(quoted diff) +0 -0

b/meta/recipes-bsp/u-boot/u-boot.inc index c2bcf99840..2796e503cf 100644 --- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc

meta/recipes-bsp/u-boot/u-boot.inc +8 -0
@@ -305,3 +305,38 @@ do_deploy () {
 }
 
 addtask deploy before do_build after do_compile
+
+# Create new rules to extract default envs
+UBOOT_ENVS_DEFAULT ?= "uboot-envs-default"
+DEFAULT_ENVS ?= "u-boot-env-default.txt"
+DEFAULT_ENVS_SIZE ?= "65536"
+
+# Generate default environment
+do_gen_default_envs[doc] = "Generate image with default U-Boot

environment(s)" +do_gen_default_envs () {

(quoted diff) +1 -0
+	${B}/source/scripts/get_default_envs.sh ${B} >

${B}/${DEFAULT_ENVS} +

(quoted diff) +2 -0
+	# Generate env image
+	${B}/tools/mkenvimage -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT} ${B}/${DEFAULT_ENVS} +

Quoted 8 lines

meta/recipes-bsp/u-boot/u-boot.inc do_deploy () { · line 327

Quoted 6 lines
(quoted diff) +2 -0
+	# Generate redundant env image
+	${B}/tools/mkenvimage -r -s ${DEFAULT_ENVS_SIZE} -o

${B}/${UBOOT_ENVS_DEFAULT}_r ${B}/${DEFAULT_ENVS} +

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+	rm ${B}/${DEFAULT_ENVS}
+}
+  

Why do we need a separate task ? Is it not part of do_compile ?

The get_default_envs.sh script requires the build-in.o to be already build. For that reason I've added a separate task, which goes just after the do_compile for u-boot.

Quoted 24 lines
Quoted 17 lines

+addtask gen_default_envs before do_deploy_default_envs after do_compile +

(quoted diff) +2 -0
+# Deploy default environment
+do_deploy_default_envs[doc] = "Copy images with default U-Boot

environment to deployment directory" +do_deploy_default_envs () {

meta/recipes-bsp/u-boot/u-boot.inc +3 -0
+	install -d ${DEPLOYDIR}
+
+	install ${B}/${UBOOT_ENVS_DEFAULT}

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}

(quoted diff) +1 -0
+	install ${B}/${UBOOT_ENVS_DEFAULT}_r

${DEPLOYDIR}/${UBOOT_ENVS_DEFAULT}_r +

meta/recipes-bsp/u-boot/u-boot.inc +5 -0
+	rm ${B}/${UBOOT_ENVS_DEFAULT}
+	rm ${B}/${UBOOT_ENVS_DEFAULT}_r
+}
+
+addtask deploy_default_envs before do_deploy after
Quoted 1 line

do_gen_default_envs

I would like to see that the default environment is installed and delivered as (additional) package. I could then add it to my rootfs and use it to set up the environment in user space in case a CRC error is reported by the env tools.

Quoted 3 lines

Regards,
Stefano

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]