Building kernel for more than one SoC
I'm told that it should be possible to build a kernel that will run on two different SoC chips. They're closely related (same ARM9 core, many identical internal peripherals -- AT91SAM9G20 and 'G25), and would likely have identical external hardware.
In order to handle the internal periphals that differ, it was recommended that I use loadable modules to keep the kernel size small. However, my root filesystem is in RAM, so I don't see how loadable modules helps unless I remove all of the .ko files from the root filesystem after the kernel has booted.
It seems it would be simpler to just link in all required drivers for both chips and discard the ones that aren't needed after kernel initialization. But, I'm not sure if there's a mechanism for doing that. I know there's a way to declare a function or data that will be discarded after kernel init, but is ther a way to that conditionally depending on probed hardware or the device-tree used at boot-time?
Signature · 3 lines
Grant Edwards grant.b.edwards Yow! Let me do my TRIBUTE
at to FISHNET STOCKINGS ...
gmail.com Dear Grant Edwards,
(Adding Boris and Alexandre in Cc, since they do a lot of AT91 stuff these days.)
Quoted 11 lines · Grant Edwards
I'm told that it should be possible to build a kernel that will run on two different SoC chips. They're closely related (same ARM9 core, many identical internal peripherals -- AT91SAM9G20 and 'G25), and would likely have identical external hardware.
In order to handle the internal periphals that differ, it was recommended that I use loadable modules to keep the kernel size small. However, my root filesystem is in RAM, so I don't see how loadable modules helps unless I remove all of the .ko files from the root filesystem after the kernel has booted.
Quoted 6 lines
It seems it would be simpler to just link in all required drivers for both chips and discard the ones that aren't needed after kernel initialization. But, I'm not sure if there's a mechanism for doing that. I know there's a way to declare a function or data that will be discarded after kernel init, but is ther a way to that conditionally depending on probed hardware or the device-tree used at boot-time?
I don't think there's much point in worrying about this: the 9G20 and 9G25 will use identical device drivers for the vast majority of the hardware blocks of the SoC, so the overhead of having the drivers for both SoCs inside the same kernel is going to be really low.
Make a test, a build a kernel only for 9G20, another only for 9G25, and another with both.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Quoted 3 lines · Thomas Petazzoni
I don't think there's much point in worrying about this: the 9G20 and 9G25 will use identical device drivers for the vast majority of the hardware blocks of the SoC,
Really identical drivers, or just compiled from the same source file? One thing I'm worried about is that they might share a driver that has code conditionally compiled one way for the G20 and the other for the G25. I haven't _found_ any code like that yet, but it would be a pain to have to deal with something like that...
Signature · 4 lines
Grant Edwards grant.b.edwards Yow! I want to dress you
at up as TALLULAH BANKHEAD and
gmail.com cover you with VASELINE and
WHEAT THINS ...Quoted 10 lines · Grant Edwards
I'm told that it should be possible to build a kernel that will run on two different SoC chips. They're closely related (same ARM9 core, many identical internal peripherals -- AT91SAM9G20 and 'G25), and would likely have identical external hardware.
In order to handle the internal periphals that differ, it was recommended that I use loadable modules to keep the kernel size small. However, my root filesystem is in RAM, so I don't see how loadable modules helps unless I remove all of the .ko files from the root filesystem after the kernel has booted.
I think whoever made that recommendation probably isn't aware of the direction that mainline kernels are heading.
Where we're going with mainline kernels is to have a set of drivers which work irrespective of the hardware you have.
We've actually had this policy for about the last decade - we've supported building the same family of SoCs into one single kernel (identified by their mach-* directory) and expecting that their drivers will cope with the differences between the SoCs at runtime. (Note that the CPU itself has never really come into it; we've had good abstractions for the CPU support since the late 90's, with the exception of a borderline between the ARMv5 and ARMv6 architectures.)
Whether the Atmel code does that or not, I don't know, but it _should_ do it.
Over the last few years, we've been moving mainline towards even tighter integration, where it's possible to build completely dissimilar SoCs together, so ultimately we end up with: legacy kernels, one multi-platform ARMv5 and earlier kernel, and one multi-platform ARMv6 and later kernel.
Quoted 3 lines
It seems it would be simpler to just link in all required drivers for both chips and discard the ones that aren't needed after kernel initialization.
Even better is to abstract the differences and have the same driver code deal with the different variants internally - the selection of which variant being controlled via the device tree "compatible" property, or another appropriate method.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up according to speedtest.net.
On 04/08/2014 22:17, Russell King - ARM Linux :
Quoted 26 lines · Grant Edwards
Quoted 10 lines
I'm told that it should be possible to build a kernel that will run on two different SoC chips. They're closely related (same ARM9 core, many identical internal peripherals -- AT91SAM9G20 and 'G25), and would likely have identical external hardware.
In order to handle the internal periphals that differ, it was recommended that I use loadable modules to keep the kernel size small. However, my root filesystem is in RAM, so I don't see how loadable modules helps unless I remove all of the .ko files from the root filesystem after the kernel has booted.
I think whoever made that recommendation probably isn't aware of the direction that mainline kernels are heading.
Where we're going with mainline kernels is to have a set of drivers which work irrespective of the hardware you have.
We've actually had this policy for about the last decade - we've supported building the same family of SoCs into one single kernel (identified by their mach-* directory) and expecting that their drivers will cope with the differences between the SoCs at runtime. (Note that the CPU itself has never really come into it; we've had good abstractions for the CPU support since the late 90's, with the exception of a borderline between the ARMv5 and ARMv6 architectures.)
Quoted 2 lines
Whether the Atmel code does that or not, I don't know, but it _should_ do it.
Absolutely, we do follow this policy for quite some time. So anything that prevents what Russell describes above should be considered as a bug ;-)
Quoted 5 lines
Over the last few years, we've been moving mainline towards even tighter integration, where it's possible to build completely dissimilar SoCs together, so ultimately we end up with: legacy kernels, one multi-platform ARMv5 and earlier kernel, and one multi-platform ARMv6 and later kernel.
We are almost at the point where we can have a multi-platform ARMv6/7 for sama5 SoCs and ARMv5 for our ARM9s.
Quoted 8 lines
Quoted 3 lines
It seems it would be simpler to just link in all required drivers for both chips and discard the ones that aren't needed after kernel initialization.
Even better is to abstract the differences and have the same driver code deal with the different variants internally - the selection of which variant being controlled via the device tree "compatible" property, or another appropriate method.
Sure. Everything in at91 is converted to device tree those days.
Best regards,
Signature · 1 line
Nicolas Ferre
Quoted 1 line · Nicolas Ferre
On 04/08/2014 22:17, Russell King - ARM Linux :
[...]
Quoted 6 lines
Quoted 4 lines
Even better is to abstract the differences and have the same driver code deal with the different variants internally - the selection of which variant being controlled via the device tree "compatible" property, or another appropriate method.
Sure. Everything in at91 is converted to device tree those days.
That's good to hear, thanks.
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
Signature · 3 lines
Grant Edwards grant.b.edwards Yow! I smell a RANCID
at CORN DOG!
gmail.com Quoted 3 lines
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
http://cateee.net/lkddb/web-lkddb/ARM_APPENDED_DTB.html
Regards,
Signature · 2 lines
Robert Nelson http://www.rcn-ee.com/
Quoted 5 lines · Robert Nelson
Quoted 3 lines
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
Interesting. That would still require modifying U-Boot so that at run-time it detects the SoC type and appends the proper DTB to the kernel image, but it that may be less work than "real" DTB support in U-Boot.
Signature · 3 lines
Grant Edwards grant.b.edwards Yow! Now KEN and BARBIE
at are PERMANENTLY ADDICTED to
gmail.com MIND-ALTERING DRUGS ...Quoted 11 lines · Grant Edwards
Quoted 5 lines · Robert Nelson
Quoted 3 lines
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
Interesting. That would still require modifying U-Boot so that at run-time it detects the SoC type and appends the proper DTB to the kernel image, but it that may be less work than "real" DTB support in U-Boot.
The idea of that feature is:
- You take the kernel zImage
- You take the appropriate dtb file
- You concatenate the dtb file into the zImage
- You run mkimage on the resulting combined image to create the special uboot format file for uboot to load
- You use it with uboot as you have done in the past with non-DT kernels.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up according to speedtest.net.
Quoted 13 lines · Russell King - ARM Linux
Quoted 11 lines · Grant Edwards
Quoted 5 lines · Robert Nelson
Quoted 3 lines
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
Interesting. That would still require modifying U-Boot so that at run-time it detects the SoC type and appends the proper DTB to the kernel image, but it that may be less work than "real" DTB support in U-Boot.
Quoted 7 lines
The idea of that feature is:
- You take the kernel zImage
- You take the appropriate dtb file
- You concatenate the dtb file into the zImage
- You run mkimage on the resulting combined image to create the special uboot format file for uboot to load
The problem is now you've got a kernel image that won't run on both the '9g20 and the '9g25. The requirement is to have a kernel image that will run on either.
Quoted 2 lines
- You use it with uboot as you have done in the past with non-DT kernels.
Logistically, there's little difference between that and compiling the kernel twice. It's more elegant than compiling the kernel twice, but in the end it requires the maintenance of two separate kernel images and some way for customers to figure out which one they should download (and no matter what you do, when given a choice between two files, they will download and attempt to install the wrong one more than half of the time).
Signature · 3 lines
Grant Edwards grant.b.edwards Yow! As President I have
at to go vacuum my coin
gmail.com collection!Quoted 22 lines · Grant Edwards
Quoted 13 lines · Russell King - ARM Linux
Quoted 11 lines · Grant Edwards
Quoted 5 lines · Robert Nelson
Quoted 3 lines
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
Interesting. That would still require modifying U-Boot so that at run-time it detects the SoC type and appends the proper DTB to the kernel image, but it that may be less work than "real" DTB support in U-Boot.
Quoted 7 lines
The idea of that feature is:
- You take the kernel zImage
- You take the appropriate dtb file
- You concatenate the dtb file into the zImage
- You run mkimage on the resulting combined image to create the special uboot format file for uboot to load
Quoted 3 lines
The problem is now you've got a kernel image that won't run on both the '9g20 and the '9g25. The requirement is to have a kernel image that will run on either.
Then, upgrade your u-boot to mainline, use the dtb, etc. You have a lot of excuses. ;)
Regards,
Signature · 2 lines
Robert Nelson http://www.rcn-ee.com/
Quoted 24 lines · Robert Nelson
Quoted 22 lines · Grant Edwards
Quoted 20 lines · Russell King - ARM Linux
Quoted 11 lines · Grant Edwards
Quoted 5 lines · Robert Nelson
Quoted 3 lines
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
Interesting. That would still require modifying U-Boot so that at run-time it detects the SoC type and appends the proper DTB to the kernel image, but it that may be less work than "real" DTB support in U-Boot.
The idea of that feature is:
- You take the kernel zImage
- You take the appropriate dtb file
- You concatenate the dtb file into the zImage
- You run mkimage on the resulting combined image to create the special uboot format file for uboot to load
Quoted 6 lines
Quoted 3 lines
The problem is now you've got a kernel image that won't run on both the '9g20 and the '9g25. The requirement is to have a kernel image that will run on either.
Then, upgrade your u-boot to mainline, use the dtb, etc. You have a lot of excuses. ;)
Yep. Unfortunately, excuses aren't the problem. Cost (mostly opportunity cost) is the problem...
Signature · 4 lines
Grant Edwards grant.b.edwards Yow! Is it NOUVELLE
at CUISINE when 3 olives are
gmail.com struggling with a scallop
in a plate of SAUCE MORNAY?Quoted 22 lines · Grant Edwards
Quoted 13 lines · Russell King - ARM Linux
Quoted 11 lines · Grant Edwards
Quoted 5 lines · Robert Nelson
Quoted 3 lines
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
Interesting. That would still require modifying U-Boot so that at run-time it detects the SoC type and appends the proper DTB to the kernel image, but it that may be less work than "real" DTB support in U-Boot.
Quoted 7 lines
The idea of that feature is:
- You take the kernel zImage
- You take the appropriate dtb file
- You concatenate the dtb file into the zImage
- You run mkimage on the resulting combined image to create the special uboot format file for uboot to load
Quoted 3 lines
The problem is now you've got a kernel image that won't run on both the '9g20 and the '9g25. The requirement is to have a kernel image that will run on either.
It depends what you call a kernel image.
As far as I'm concerned (and as I've been concerned from day one of uboot coming into ARM), the kernel image is the zImage, not the crap that uboot decides to dictate that you must provide for it to use.
I've been pretty clear over the years that I utterly despise uboot's custom format - and you're starting to find out why. Welcome to the inflexibility has caused. :)
Quoted 10 lines
Quoted 2 lines
- You use it with uboot as you have done in the past with non-DT kernels.
Logistically, there's little difference between that and compiling the kernel twice. It's more elegant than compiling the kernel twice, but in the end it requires the maintenance of two separate kernel images and some way for customers to figure out which one they should download (and no matter what you do, when given a choice between two files, they will download and attempt to install the wrong one more than half of the time).
While you have a point there, that's a choice of how you do your kernel upgrades.
If you supply a zImage, all the dtbs, a script which does the programming of the kernel onto the target, and a copy of mkimage, then you can do all the steps I've highlighted above on the target - without the customer even having to know what platform they're on, because your script can work it out.
If you don't have a shell on the target, then write a C program to do it instead.
There's plenty of workarounds possible for the old uboot dilemma...
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up according to speedtest.net.
Quoted 7 lines · Russell King - ARM Linux
Quoted 4 lines
The problem is now you've got a kernel image that won't run on both the '9g20 and the '9g25. The requirement is to have a kernel image that will run on either.
It depends what you call a kernel image.
Quoted 7 lines
As far as I'm concerned (and as I've been concerned from day one of uboot coming into ARM), the kernel image is the zImage, not the crap that uboot decides to dictate that you must provide for it to use.
I've been pretty clear over the years that I utterly despise uboot's custom format - and you're starting to find out why. Welcome to the inflexibility has caused. :)
Yea, I've got my own issues with U-Boot, but that's a whole 'nother thread. In the end, it was a lot less painful to put up with U-Boot's issues than it was to write/port something else.
Quoted 8 lines
While you have a point there, that's a choice of how you do your kernel upgrades.
If you supply a zImage, all the dtbs, a script which does the programming of the kernel onto the target, and a copy of mkimage, then you can do all the steps I've highlighted above on the target - without the customer even having to know what platform they're on, because your script can work it out.
Good point.
Quoted 1 line
There's plenty of workarounds possible for the old uboot dilemma...
Definitely. It all comes to do trying to figure out when the work-arounds add up to more work than doing it the "right" way and upgrading everything.
Signature · 3 lines
Grant Edwards grant.b.edwards Yow! All of life is a blur
at of Republicans and meat!
gmail.com Quoted 29 lines · Russell King - ARM Linux
Quoted 22 lines · Grant Edwards
Quoted 13 lines · Russell King - ARM Linux
Quoted 11 lines · Grant Edwards
Quoted 5 lines · Robert Nelson
Quoted 3 lines
Now it's up to somebody else to decide if the price difference between a G20 and G25 is worth the engineering time to upgrade U-Boot and Linux kernel to versions that know about device trees...
Interesting. That would still require modifying U-Boot so that at run-time it detects the SoC type and appends the proper DTB to the kernel image, but it that may be less work than "real" DTB support in U-Boot.
Quoted 7 lines
The idea of that feature is:
- You take the kernel zImage
- You take the appropriate dtb file
- You concatenate the dtb file into the zImage
- You run mkimage on the resulting combined image to create the special uboot format file for uboot to loadQuoted 3 lines
The problem is now you've got a kernel image that won't run on both the '9g20 and the '9g25. The requirement is to have a kernel image that will run on either.
It depends what you call a kernel image.
Quoted 7 lines
As far as I'm concerned (and as I've been concerned from day one of uboot coming into ARM), the kernel image is the zImage, not the crap that uboot decides to dictate that you must provide for it to use.
I've been pretty clear over the years that I utterly despise uboot's custom format - and you're starting to find out why. Welcome to the inflexibility has caused. :)
Note that u-boot grew a "bootz" command in recent year(s). It'll boot just a raw zImage instead of the mkimage-wrapped version.
Of course, not all u-boots have it due to age of the vendor fork. I also have a board that tries to boot a zImage with the 'bootm' command instead. Yes, you heard that right. Sigh.
-Olof
Quoted 29 lines · Grant Edwards
Quoted 7 lines · Russell King - ARM Linux
Quoted 4 lines
The problem is now you've got a kernel image that won't run on both the '9g20 and the '9g25. The requirement is to have a kernel image that will run on either.
It depends what you call a kernel image.
Quoted 7 lines
As far as I'm concerned (and as I've been concerned from day one of uboot coming into ARM), the kernel image is the zImage, not the crap that uboot decides to dictate that you must provide for it to use.
I've been pretty clear over the years that I utterly despise uboot's custom format - and you're starting to find out why. Welcome to the inflexibility has caused. :)
Yea, I've got my own issues with U-Boot, but that's a whole 'nother thread. In the end, it was a lot less painful to put up with U-Boot's issues than it was to write/port something else.
Quoted 8 lines
While you have a point there, that's a choice of how you do your kernel upgrades.
If you supply a zImage, all the dtbs, a script which does the programming of the kernel onto the target, and a copy of mkimage, then you can do all the steps I've highlighted above on the target - without the customer even having to know what platform they're on, because your script can work it out.
Quoted 8 lines
Good point.
Quoted 1 line
There's plenty of workarounds possible for the old uboot dilemma...
Definitely. It all comes to do trying to figure out when the work-arounds add up to more work than doing it the "right" way and upgrading everything.
Is this maybe what you're looking for?
https://github.com/zonque/pxa-impedance-matcher
Best regards,
Tomasz