[U-Boot] Booting different kernel from U-Boot based on time stamp

I am using U-Boot and two kernel Image(uImage). I want to add some code in U-Boot which will select kernel based of time stamp. I am using MIPS architecture. this two kernels are in different MTD partition.
For example:-
|If kernel-1 is new, U-Boot will boot Kernel-1. and leave kernel-2 as it is. If kernel-2 is new, U-Boot will boot kernel-2. and leave kernel-2 as it is. |
Questions:-
|Is it possible to do so? How can I add such functionality in U-boot? Where to chage the code for the same? |

Dear Hemal Patel,
In message assp.0730d63214.50F9164E.7070301@slscorp.com you wrote:
For example:-
|If kernel-1 is new, U-Boot will boot Kernel-1. and leave kernel-2 as it is. If kernel-2 is new, U-Boot will boot kernel-2. and leave kernel-2 as it is. |
Questions:-
|Is it possible to do so?
This is software,so everything is possible, if you assign sufficient resources to the task ;-)
How can I add such functionality in U-boot?
Yes, this is not difficult.
Where to chage the code for the same?
The clean way would be to add a (board specific) command to either make accessable (so you can use the itest command on them) or to compare (so that you can use plain "if") the time stamps of two images.
Assume your command "is_newer_img" takes the addresses of two legacy image files and returns true (i. e. with a zero return code) if this is the case, then you could just write:
if is_newer_img ${kernel_1_addr} ${kernel_2_addr} then bootm ${kernel_1_addr} else bootm ${kernel_2_addr} fi
Alternatively, for a quick & dirty test or show case, you could of course peek directly at the ih_time entry of the image_header structure. This would not even need any new code, existing features would be sufficient.
Best regards,
Wolfgang Denk

1.What do you mean by board specific ? 2.Which file should I modify? 3.From which file this bootm command is called?And where do I find this file in stack?
Regards, Hemal Patel
On Monday 21 January 2013 06:19 PM, Wolfgang Denk wrote:
Dear Hemal Patel,
In messageassp.0730d63214.50F9164E.7070301@slscorp.com you wrote:
For example:-
|If kernel-1 is new, U-Boot will boot Kernel-1. and leave kernel-2 as it is. If kernel-2 is new, U-Boot will boot kernel-2. and leave kernel-2 as it is. |
Questions:-
|Is it possible to do so?
This is software,so everything is possible, if you assign sufficient resources to the task ;-)
How can I add such functionality in U-boot?
Yes, this is not difficult.
Where to chage the code for the same?
The clean way would be to add a (board specific) command to either make accessable (so you can use the itest command on them) or to compare (so that you can use plain "if") the time stamps of two images.
Assume your command "is_newer_img" takes the addresses of two legacy image files and returns true (i. e. with a zero return code) if this is the case, then you could just write:
if is_newer_img ${kernel_1_addr} ${kernel_2_addr} then bootm ${kernel_1_addr} else bootm ${kernel_2_addr} fi
Alternatively, for a quick& dirty test or show case, you could of course peek directly at the ih_time entry of the image_header structure. This would not even need any new code, existing features would be sufficient.
Best regards,
Wolfgang Denk

Dear Hemal Patel,
please do not top-post / full-quote. If you need help, please see http://www.netmeister.org/news/learn2quote.html
In message assp.07330ae221.50FD468D.1090707@slscorp.com you wrote:
1.What do you mean by board specific ?
A "(board specific) command" is a command implemented in your board specific code.
2.Which file should I modify?
One of those in your board directory - eventually you would add a new one there.
3.From which file this bootm command is called?And where do I find this file in stack?
These commands would be part of your boot command settings, i. e. what you define for "bootcmd".
Best regards,
Wolfgang Denk
participants (2)
-
Hemal Patel
-
Wolfgang Denk