Skip to contentSkip to conversation

barebox: Add recipe

PATCH In review David Vincent 5 participants 10 messages Jul 28, 2014 – Jul 30, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 barebox: Add recipe

barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel. This commit adds the possibility to use it as a virtual/bootloader instead of U-Boot.

---
 meta/recipes-bsp/barebox/barebox.inc          |   73 +++++++++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +++++
 2 files changed, 88 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb
meta/recipes-bsp/barebox/barebox.inc new file +73 -0
new file mode 100644
index 0000000..68aeb68
@@ -0,0 +1,73 @@
+SUMMARY = "The Barebox Bootloader"
+DESCRIPTION = "Barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel: The size and look-and-feel of u-boot, with driver model and lots of design concepts from the kernel."
+HOMEPAGE = "http://www.barebox.org"
+SECTION = "bootloaders"
+PROVIDES = "virtual/bootloader"
+
+inherit cml1 deploy kernel-arch
+
+EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}"'
+
+BAREBOX_BINARY ?= "barebox.bin"
+BAREBOX_IMAGE ?= "barebox-${MACHINE}-${PV}-${PR}.bin"
+BAREBOX_SYMLINK ?= "barebox-${MACHINE}.bin"
+
+do_configure () {
+	# Copy defconfig to .config if .config does not exist. This allows
+	# recipes to manage the .config themselves in do_configure_prepend().
+	if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
+		cp "${WORKDIR}/defconfig" "${B}/.config"
+	fi
+
+	# Use board default defconfig if .config does not exist. This allows
+	# recipes to manage the .config themselves in do_configure_prepend().
+	if [ ! -f "${B}/.config" ]; then
+		oe_runmake_call ${BAREBOX_TARGET}
+	fi
+
+	cml1_do_configure
+}
+
+do_compile () {
+	if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then
+		sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' ${S}/Makefile
+	fi
+
+	unset CFLAGS CPPFLAGS LDFLAGS
+	oe_runmake
+}
+
+do_install () {
+	install -d ${D}/boot
+	install ${S}/barebox-flash-image ${D}/boot/${BAREBOX_IMAGE}
+	ln -sf ${BAREBOX_IMAGE} ${D}/boot/${BAREBOX_BINARY}
+
+	# Install target tools if available
+	install -d ${D}${sbindir}
+
+	if [ -e ${WORKDIR}/scripts/bareboxenv-target ]; then
+		install -m 0755 ${WORKDIR}/scripts/bareboxenv-target ${D}${sbindir}/bareboxenv
+	fi
+
+	if [ -e ${WORKDIR}/scripts/bareboxcrc32-target ]; then
+		install -m 0755 ${WORKDIR}/scripts/bareboxcrc32-target ${D}${sbindir}/bareboxcrc32
+	fi
+
+	if [ -e ${WORKDIR}/scripts/kernel-install-target ]; then
+		install -m 0755 ${WORKDIR}/scripts/kernel-install-target ${D}${sbindir}/kernel-install
+	fi
+}
+
+FILES_${PN} = "/boot ${sbindir}"
+
+do_deploy () {
+	install -d ${DEPLOYDIR}
+	install ${S}/barebox-flash-image ${DEPLOYDIR}/${BAREBOX_IMAGE}
+
+	cd ${DEPLOYDIR}
+	rm -f ${BAREBOX_BINARY} ${BAREBOX_SYMLINK}
+	ln -sf ${BAREBOX_IMAGE} ${BAREBOX_SYMLINK}
+	ln -sf ${BAREBOX_IMAGE} ${BAREBOX_BINARY}
+}
+
+addtask deploy before do_build after do_compile
meta/recipes-bsp/barebox/barebox_2014.07.0.bb new file +15 -0
new file mode 100644
index 0000000..6adbff4
@@ -0,0 +1,15 @@
+require barebox.inc
+
+# To build barebox for your machine, provide the following lines in your machine
+# config, replacing the assignments as appropriate for your machine.
+# BAREBOX_MACHINE = "sandbox"
+# BAREBOX_TARGET = "sandbox_defconfig"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=057bf9e50e1ca857d0eb97bfe4ba8e5d"
+
+SRC_URI = "http://www.barebox.org/download/${PN}-${PV}.tar.bz2"
+SRC_URI[md5sum] = "f3a93950777916d4b1c2cd366aec8d91"
+SRC_URI[sha256sum] = "6dca5c78de8565a15aaa404edbf1bc4663415f0dc69e094f3b621636876285f2"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 11 lines · David Vincent

barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel. This commit adds the possibility to use it as a virtual/bootloader instead of U-Boot.

---
 meta/recipes-bsp/barebox/barebox.inc          |   73 +++++++++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +++++
 2 files changed, 88 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb

I have to admit I don't know a lot about this. To make it into OE-Core we need some kind of story about why its necessary and commonly used. Are there a number of BSPs using this? Can you give some background to why this is needed?

Cheers,

Richard

#6 lore raw
In reply to David Vincent

Hi David,

Quoted 44 lines · David Vincent

barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel. This commit adds the possibility to use it as a virtual/bootloader instead of U-Boot.

---
 meta/recipes-bsp/barebox/barebox.inc          |   73 +++++++++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +++++
 2 files changed, 88 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb
meta/recipes-bsp/barebox/barebox.inc new file +25 -0
new file mode 100644
index 0000000..68aeb68
@@ -0,0 +1,73 @@
+SUMMARY = "The Barebox Bootloader"
+DESCRIPTION = "Barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel: The size and look-and-feel of u-boot, with driver model and lots of design concepts from the kernel."
+HOMEPAGE = "http://www.barebox.org"
+SECTION = "bootloaders"
+PROVIDES = "virtual/bootloader"
+
+inherit cml1 deploy kernel-arch
+
+EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}"'
+
+BAREBOX_BINARY ?= "barebox.bin"
+BAREBOX_IMAGE ?= "barebox-${MACHINE}-${PV}-${PR}.bin"
+BAREBOX_SYMLINK ?= "barebox-${MACHINE}.bin"
+
+do_configure () {
+	# Copy defconfig to .config if .config does not exist. This allows
+	# recipes to manage the .config themselves in do_configure_prepend().
+	if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
+		cp "${WORKDIR}/defconfig" "${B}/.config"
+	fi
+
+	# Use board default defconfig if .config does not exist. This allows
+	# recipes to manage the .config themselves in do_configure_prepend().
+	if [ ! -f "${B}/.config" ]; then
+		oe_runmake_call ${BAREBOX_TARGET}

meta/recipes-bsp/barebox/barebox.inc line 35

Quoted 10 lines
meta/recipes-bsp/barebox/barebox.inc new file +10 -0
+	fi
+
+	cml1_do_configure
+}
+
+do_compile () {
+	if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then
+		sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' ${S}/Makefile
+	fi
+

I had to add that a few year ago : is that still needed ?

Quoted 16 lines
meta/recipes-bsp/barebox/barebox.inc new file +16 -0
+	unset CFLAGS CPPFLAGS LDFLAGS
+	oe_runmake
+}
+
+do_install () {
+	install -d ${D}/boot
+	install ${S}/barebox-flash-image ${D}/boot/${BAREBOX_IMAGE}
+	ln -sf ${BAREBOX_IMAGE} ${D}/boot/${BAREBOX_BINARY}
+
+	# Install target tools if available
+	install -d ${D}${sbindir}
+
+	if [ -e ${WORKDIR}/scripts/bareboxenv-target ]; then
+		install -m 0755 ${WORKDIR}/scripts/bareboxenv-target ${D}${sbindir}/bareboxenv
+	fi
+

meta/recipes-bsp/barebox/barebox.inc line 61

Quoted 10 lines
meta/recipes-bsp/barebox/barebox.inc new file +10 -0
+	if [ -e ${WORKDIR}/scripts/bareboxcrc32-target ]; then
+		install -m 0755 ${WORKDIR}/scripts/bareboxcrc32-target ${D}${sbindir}/bareboxcrc32
+	fi
+
+	if [ -e ${WORKDIR}/scripts/kernel-install-target ]; then
+		install -m 0755 ${WORKDIR}/scripts/kernel-install-target ${D}${sbindir}/kernel-install
+	fi
+}
+
+FILES_${PN} = "/boot ${sbindir}"

Why not splitting the tools in their own package so that we can have the tools on the target without having the binary in /boot ?

meta/recipes-bsp/barebox/barebox.inc line 66

Quoted 5 lines
meta/recipes-bsp/barebox/barebox.inc new file +5 -0
+
+do_deploy () {
+	install -d ${DEPLOYDIR}
+	install ${S}/barebox-flash-image ${DEPLOYDIR}/${BAREBOX_IMAGE}
+

Why don't you use $BAREBOX_BINARY instead of hardcoding barebox-flash-image which won't work on old versions of barebox where barebox's binary is named barebox.bin ?

Best regards,
Eric

#2 lore raw
In reply to Richard Purdie

Sorry, the patch alone was maybe a little harsh, I should have submitted it as a RFC.
For me, this recipe was needed because I don't use u-boot as the bootloader for my custom board but barebox. More generically, I know that the meta-fsl-arm has also a recipe for barebox and since my board was not based on a Freescale MPU but an Atmel one, I thought that the work could be shared by the two layers in oe-core or, at least, in meta-oe instead of being also redeveloped in meta-atmel or another BSP layer.

Since barebox also supports many architectures like ARM, MIPS, Blackfin,... and many vendors like Atmel, Freescale, TI,... I think it provides a good alternative for the 'virtual/bootloader' task. People who want to use it should not put more effort than what they need to do for u-boot currently.

I've cc'ed the barebox mailing list for more technical details if needed.

Greetings,

David

2014-07-28 12:23 GMT+02:00 Richard Purdie <[email protected]>:

Quoted 13 lines · David Vincent
Quoted 11 lines

barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel. This commit adds the possibility to use it as a virtual/bootloader instead of U-Boot.

---
 meta/recipes-bsp/barebox/barebox.inc          |   73 +++++++++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +++++
 2 files changed, 88 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb
Quoted 9 lines

I have to admit I don't know a lot about this. To make it into OE-Core we need some kind of story about why its necessary and commonly used. Are there a number of BSPs using this? Can you give some background to why this is needed?

Cheers,

Richard

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw

PATCH 1/1 barebox: Add recipe

Sorry, the patch alone was maybe a little harsh, I should have submitted it as a RFC.
For me, this recipe was needed because I don't use u-boot as the bootloader for my custom board but barebox. More generically, I know that the meta-fsl-arm has also a recipe for barebox and since my board was not based on a Freescale MPU but an Atmel one, I thought that the work could be shared by the two layers in oe-core or, at least, in meta-oe instead of being also redeveloped in meta-atmel or another BSP layer.

Since barebox also supports many architectures like ARM, MIPS, Blackfin,... and many vendors like Atmel, Freescale, TI,... I think it provides a good alternative for the 'virtual/bootloader' task. People who want to use it should not put more effort than what they need to do for u-boot currently.

I've cc'ed the barebox mailing list for more technical details if needed.

Greetings,

David

2014-07-28 12:23 GMT+02:00 Richard Purdie <[email protected]>:

Quoted 22 lines · David Vincent
Quoted 11 lines

barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel. This commit adds the possibility to use it as a virtual/bootloader instead of U-Boot.

---
 meta/recipes-bsp/barebox/barebox.inc          |   73 +++++++++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +++++
 2 files changed, 88 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb

I have to admit I don't know a lot about this. To make it into OE-Core we need some kind of story about why its necessary and commonly used. Are there a number of BSPs using this? Can you give some background to why this is needed?

Cheers,

Richard

#7 lore raw
In reply to Eric Bénard

Hi Eric,

2014-07-28 13:58 GMT+02:00 Eric Bénard <[email protected]>:

Quoted 52 lines

Hi David,

Quoted 47 lines · David Vincent

barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel. This commit adds the possibility to use it as a virtual/bootloader instead of U-Boot.

---
 meta/recipes-bsp/barebox/barebox.inc          |   73 +++++++++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +++++
 2 files changed, 88 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb
meta/recipes-bsp/barebox/barebox.inc new file +28 -0
new file mode 100644
index 0000000..68aeb68
@@ -0,0 +1,73 @@
+SUMMARY = "The Barebox Bootloader"
+DESCRIPTION = "Barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel: The size and look-and-feel of u-boot, with driver model and lots of design concepts from the kernel."
+HOMEPAGE = "http://www.barebox.org"
+SECTION = "bootloaders"
+PROVIDES = "virtual/bootloader"
+
+inherit cml1 deploy kernel-arch
+
+EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}"'
+
+BAREBOX_BINARY ?= "barebox.bin"
+BAREBOX_IMAGE ?= "barebox-${MACHINE}-${PV}-${PR}.bin"
+BAREBOX_SYMLINK ?= "barebox-${MACHINE}.bin"
+
+do_configure () {
+     # Copy defconfig to .config if .config does not exist. This allows
+     # recipes to manage the .config themselves in do_configure_prepend().
+     if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
+             cp "${WORKDIR}/defconfig" "${B}/.config"
+     fi
+
+     # Use board default defconfig if .config does not exist. This allows
+     # recipes to manage the .config themselves in do_configure_prepend().
+     if [ ! -f "${B}/.config" ]; then
+             oe_runmake_call ${BAREBOX_TARGET}
+     fi
+
+     cml1_do_configure
Quoted 8 lines

meta/recipes-bsp/barebox/barebox.inc line 35

Quoted 7 lines
meta/recipes-bsp/barebox/barebox.inc new file +7 -0
+}
+
+do_compile () {
+     if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then
+             sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' ${S}/Makefile
+     fi
+

I had to add that a few year ago : is that still needed ?

Don't know, I've taken that directly from u-boot recipe (didn't want to reinvent the wheel)

Quoted 22 lines
Quoted 22 lines
meta/recipes-bsp/barebox/barebox.inc new file +21 -0
+     unset CFLAGS CPPFLAGS LDFLAGS
+     oe_runmake
+}
+
+do_install () {
+     install -d ${D}/boot
+     install ${S}/barebox-flash-image ${D}/boot/${BAREBOX_IMAGE}
+     ln -sf ${BAREBOX_IMAGE} ${D}/boot/${BAREBOX_BINARY}
+
+     # Install target tools if available
+     install -d ${D}${sbindir}
+
+     if [ -e ${WORKDIR}/scripts/bareboxenv-target ]; then
+             install -m 0755 ${WORKDIR}/scripts/bareboxenv-target ${D}${sbindir}/bareboxenv
+     fi
+
+     if [ -e ${WORKDIR}/scripts/bareboxcrc32-target ]; then
+             install -m 0755 ${WORKDIR}/scripts/bareboxcrc32-target ${D}${sbindir}/bareboxcrc32
+     fi
+
+     if [ -e ${WORKDIR}/scripts/kernel-install-target ]; then
Quoted 8 lines

meta/recipes-bsp/barebox/barebox.inc line 61

Quoted 5 lines
meta/recipes-bsp/barebox/barebox.inc new file +5 -0
+             install -m 0755 ${WORKDIR}/scripts/kernel-install-target ${D}${sbindir}/kernel-install
+     fi
+}
+
+FILES_${PN} = "/boot ${sbindir}"

Why not splitting the tools in their own package so that we can have the tools on the target without having the binary in /boot ?

Create a barebox-tools recipe should also solve some problems I have building the said tools (but it is more a question related to barebox team than OE). I can do it if this request gets accepted. Could be a v2 for this patch.

Quoted 9 lines

meta/recipes-bsp/barebox/barebox.inc line 66

Quoted 6 lines
meta/recipes-bsp/barebox/barebox.inc new file +5 -0
+
+do_deploy () {
+     install -d ${DEPLOYDIR}
+     install ${S}/barebox-flash-image ${DEPLOYDIR}/${BAREBOX_IMAGE}
+

Why don't you use $BAREBOX_BINARY instead of hardcoding barebox-flash-image which won't work on old versions of barebox where barebox's binary is named barebox.bin ?

I didn't know that, but I am not sure I can use $BAREBOX_BINARY since this variable is used in $DEPLOY_DIR. I tried to mimic u-boot recipe behavior as much as possible.

Quoted 3 lines

Best regards,
Eric

Greetings,

David

#8 lore raw

Hi David,

Quoted 8 lines · David Vincent
Quoted 3 lines

Why don't you use $BAREBOX_BINARY instead of hardcoding barebox-flash-image which won't work on old versions of barebox where barebox's binary is named barebox.bin ?

I didn't know that, but I am not sure I can use $BAREBOX_BINARY since this variable is used in $DEPLOY_DIR. I tried to mimic u-boot recipe behavior as much as possible.

you can use the variable as it's defined upper. u-boot recipe does it this way :
http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-bsp/u-boot/u-boot.inc#n19
http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-bsp/u-boot/u-boot.inc#n63

FWIW you can find here the initial barebox recipe we have in meta-fsl-arm :
https://github.com/Freescale/meta-fsl-arm/tree/master/recipes-bsp/barebox

Best regards,
Eric

#9 lore raw

Hi all,

Sorry to come back on this subject, but what is the current status of this request?

Do you need more background? Are you waiting for more opinions or a vote on this subject? Should I submit a v2 of this patch with what we have discussed to make it more polished for OE-Core (or another layer)?

Again, sorry for the noise!

Greetings,
David

2014-07-28 16:42 GMT+02:00 Eric Bénard <[email protected]>:

Quoted 23 lines

Hi David,

Quoted 8 lines · David Vincent
Quoted 3 lines

Why don't you use $BAREBOX_BINARY instead of hardcoding barebox-flash-image which won't work on old versions of barebox where barebox's binary is named barebox.bin ?

I didn't know that, but I am not sure I can use $BAREBOX_BINARY since this variable is used in $DEPLOY_DIR. I tried to mimic u-boot recipe behavior as much as possible.

you can use the variable as it's defined upper. u-boot recipe does it this way :
http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-bsp/u-boot/u-boot.inc#n19
http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-bsp/u-boot/u-boot.inc#n63

FWIW you can find here the initial barebox recipe we have in meta-fsl-arm :
https://github.com/Freescale/meta-fsl-arm/tree/master/recipes-bsp/barebox

Best regards,
Eric

#4 lore raw
In reply to Richard Purdie

Hello everybody,

it happened that I am also preparing our barebox recipe for OE-core. I started similar to David but it evolved already. I added support for packages, configuration fragments and an the ipl, needed for some SoCs. I will send it to the list for comments. Even if it will not be accepted, it might be useful for some people. I will provide an explanation for the maintainer.

Regards, Stefan

Quoted 22 lines · Richard Purdie
Quoted 11 lines · David Vincent

barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel. This commit adds the possibility to use it as a virtual/bootloader instead of U-Boot.

---
  meta/recipes-bsp/barebox/barebox.inc          |   73 +++++++++++++++++++++++++
  meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +++++
  2 files changed, 88 insertions(+)

create mode 100644 meta/recipes-bsp/barebox/barebox.inc create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb

I have to admit I don't know a lot about this. To make it into OE-Core we need some kind of story about why its necessary and commonly used. Are there a number of BSPs using this? Can you give some background to why this is needed?

Cheers,

Richard

#5 lore raw
Quoted 7 lines · Stefan Müller-Klieser

it happened that I am also preparing our barebox recipe for OE-core. I started similar to David but it evolved already. I added support for packages, configuration fragments and an the ipl, needed for some SoCs. I will send it to the list for comments. Even if it will not be accepted, it might be useful for some people. I will provide an explanation for the maintainer.

could you both merge your changes and propose single recipe ? We could put it in meta-oe and later decide to move to or-core if that becomes the case.
so also send to oe-devel ml when you send v2