Skip to contentSkip to conversation

Sharing code between Linux and bootloader (U-boot) ?

DISCUSSION Sebastian Frias 4 participants 5 messages May 20, 2016 – May 30, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

Some bootloaders (like U-boot) support several HW devices: serial, network, NAND, USB, etc. most of which are also supported by Linux.

So the question is: is code shared? I mean, I understand that the drivers need to talk to the appropriate API, and such API could be different between Linux and U-boot. But putting that aside, would it be naive to imagine that some "core" functionality could be shared? Or would that part be so small it is not worth the effort?

Since many companies use both, U-boot and Linux, I would figure they try their best to optimize engineering resources and share code, right? In that case, I also wonder how do they share DT descriptions that right now are being stored in the Linux kernel tree.

We'd like to share code/DT for obvious reasons, what would you guys suggest?

Best regards,

Sebastian

#1 lore raw
Quoted 4 lines · Sebastian Frias

Some bootloaders (like U-boot) support several HW devices: serial, network, NAND, USB, etc. most of which are also supported by Linux.

So the question is: is code shared?

A little bit -- sort of. I've seen chunks of code that have been copied from Linux to U-Boot, and chunks of code in Linux and U-Boot that appear to have come from the same place at some silicon vendor or other. And there are bits of code I've written that ended up in both places.

But Linux and U-Boot don't share actual files, and any changes to the "common" code has to be done twice.

Signature · 3 lines
Grant Edwards               grant.b.edwards        Yow! Are we THERE yet?
                                  at               
                              gmail.com            
#2 lore raw
In reply to Sebastian Frias
Quoted 12 lines · Sebastian Frias

Hi,

Some bootloaders (like U-boot) support several HW devices: serial, network, NAND, USB, etc. most of which are also supported by Linux.

So the question is: is code shared? I mean, I understand that the drivers need to talk to the appropriate API, and such API could be different between Linux and U-boot.
But putting that aside, would it be naive to imagine that some "core" functionality could be shared? Or would that part be so small it is not worth the effort?

Quoted 8 lines

Since many companies use both, U-boot and Linux, I would figure they try their best to optimize engineering resources and share code, right?
In that case, I also wonder how do they share DT descriptions that right now are being stored in the Linux kernel tree.

We'd like to share code/DT for obvious reasons, what would you guys suggest?

So, in all cases, Linux is always the primary. In some cases in U-Boot we port drivers over (NAND is a good example here). In other cases, things are similar enough that it's having done it in one place it's easy enough to do it again in the other.

Signature · 1 line
Tom
#3 lore raw

Hi Tom,

Quoted 20 lines · Tom Rini
Quoted 18 lines · Sebastian Frias

Hi,

Some bootloaders (like U-boot) support several HW devices: serial, network, NAND, USB, etc. most of which are also supported by Linux.

So the question is: is code shared? I mean, I understand that the drivers need to talk to the appropriate API, and such API could be different between Linux and U-boot.
But putting that aside, would it be naive to imagine that some "core" functionality could be shared? Or would that part be so small it is not worth the effort?

Since many companies use both, U-boot and Linux, I would figure they try their best to optimize engineering resources and share code, right?
In that case, I also wonder how do they share DT descriptions that right now are being stored in the Linux kernel tree.

Quoted 4 lines
Quoted 2 lines

We'd like to share code/DT for obvious reasons, what would you guys suggest?

So, in all cases, Linux is always the primary.

For drivers and DT?

Quoted 4 lines

In some cases in U-Boot
we port drivers over (NAND is a good example here).

From your message, I get that first you write the driver for Linux and then port to U-boot, is that right?

I would have thought that the opposite way could be easier, since the U-boot driver could be simpler (maybe no DMA) w.r.t the one in Linux.

Quoted 4 lines

In other cases,
things are similar enough that it's having done it in one place it's easy enough to do it again in the other.

So, basically people just do it again, duplicating code?

Best regards,

Sebastian