[U-Boot] [PATCH] at91: board specific lowlevel_init.S

This patch allows to have an at91 board specific lowlevel_init.S
Signed-off-by: Ilko Iliev iliev@ronetix.at
index ec6ad5d..7882e89 100644 --- a/cpu/arm926ejs/at91/lowlevel_init.S +++ b/cpu/arm926ejs/at91/lowlevel_init.S @@ -27,7 +27,7 @@ #include <config.h> #include <version.h>
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT +#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && !defined(CONFIG_USER_LOWLEVEL_INIT)
.globl lowlevel_init lowlevel_init: @@ -39,5 +39,5 @@ lowlevel_init: mov pc, lr
.ltorg - -#endif /* CONFIG_SKIP_LOWLEVEL_INIT */ + +#endif /* !CONFIG_SKIP_LOWLEVEL_INIT && !CONFIG_USER_LOWLEVEL_INIT */

Dear Ilko Iliev,
In message 48FDDC1C.2080808@ronetix.at you wrote:
This patch allows to have an at91 board specific lowlevel_init.S
Signed-off-by: Ilko Iliev iliev@ronetix.at
index ec6ad5d..7882e89 100644 --- a/cpu/arm926ejs/at91/lowlevel_init.S +++ b/cpu/arm926ejs/at91/lowlevel_init.S @@ -27,7 +27,7 @@ #include <config.h> #include <version.h>
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT +#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && !defined(CONFIG_USER_LOWLEVEL_INIT)
.globl lowlevel_init lowlevel_init: @@ -39,5 +39,5 @@ lowlevel_init: mov pc, lr
.ltorg
-#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
+#endif /* !CONFIG_SKIP_LOWLEVEL_INIT && !CONFIG_USER_LOWLEVEL_INIT */
Maybe instead of adding mor #ifdef'ery here, we can turn lowlevel_init() into a "weak" function that can be redefined by board specific code?
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
Dear Ilko Iliev,
In message 48FDDC1C.2080808@ronetix.at you wrote:
This patch allows to have an at91 board specific lowlevel_init.S
Signed-off-by: Ilko Iliev iliev@ronetix.at
index ec6ad5d..7882e89 100644 --- a/cpu/arm926ejs/at91/lowlevel_init.S +++ b/cpu/arm926ejs/at91/lowlevel_init.S @@ -27,7 +27,7 @@ #include <config.h> #include <version.h>
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT +#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && !defined(CONFIG_USER_LOWLEVEL_INIT)
.globl lowlevel_init lowlevel_init: @@ -39,5 +39,5 @@ lowlevel_init: mov pc, lr
.ltorg
-#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
+#endif /* !CONFIG_SKIP_LOWLEVEL_INIT && !CONFIG_USER_LOWLEVEL_INIT */
Maybe instead of adding mor #ifdef'ery here, we can turn lowlevel_init() into a "weak" function that can be redefined by board specific code?
The lowlevel_init() is an assembler function called from another assembler function and the attribute .weak doesn't work. There are no assembler file in the U-BOOT tree which use weak functions. Do you know how can I make an assembler function weak?
best regards, Ilko Iilev

On 18:00 Tue 21 Oct , Ilko Iliev wrote:
Wolfgang Denk wrote:
Dear Ilko Iliev,
In message 48FDDC1C.2080808@ronetix.at you wrote:
This patch allows to have an at91 board specific lowlevel_init.S
Signed-off-by: Ilko Iliev iliev@ronetix.at
index ec6ad5d..7882e89 100644 --- a/cpu/arm926ejs/at91/lowlevel_init.S +++ b/cpu/arm926ejs/at91/lowlevel_init.S @@ -27,7 +27,7 @@ #include <config.h> #include <version.h>
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT +#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && !defined(CONFIG_USER_LOWLEVEL_INIT)
.globl lowlevel_init lowlevel_init: @@ -39,5 +39,5 @@ lowlevel_init: mov pc, lr
.ltorg
-#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
+#endif /* !CONFIG_SKIP_LOWLEVEL_INIT && !CONFIG_USER_LOWLEVEL_INIT */
Maybe instead of adding mor #ifdef'ery here, we can turn lowlevel_init() into a "weak" function that can be redefined by board specific code?
The lowlevel_init() is an assembler function called from another assembler function and the attribute .weak doesn't work. There are no assembler file in the U-BOOT tree which use weak functions. Do you know how can I make an assembler function weak?
IIRC .weak fct1 = fct2 should work
.weakref not
Best Regards, J.

Dear Ilko Iliev,
In message 48FDFCA0.4090608@ronetix.at you wrote:
Maybe instead of adding mor #ifdef'ery here, we can turn lowlevel_init() into a "weak" function that can be redefined by board specific code?
The lowlevel_init() is an assembler function called from another assembler function and the attribute .weak doesn't work.
What do you mean by "attribute .weak doesn't work" ?
There are no assembler file in the U-BOOT tree which use weak functions. Do you know how can I make an assembler function weak?
Well, if you don't know, then don't ask me, ask your compiler - he knows how to do this.
For example, common/cmd_boot.c has this code snippet right at the beginning:
30 31 /* Allow ports to override the default behavior */ 32 __attribute__((weak)) 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) 34 { 35 return entry (argc, argv); 36 }
Compile this with -S option, and you get this:
12 .Ltext0: 13 .align 2 14 .weak do_go_exec 15 .type do_go_exec, @function 16 do_go_exec: 17 .LFB87: 18 .file 1 "cmd_boot.c" 19 .loc 1 34 0 20 .LVL0: 21 mflr 0 22 .LCFI0: 23 stwu 1,-16(1) ...
So to me it seems as if the attribute .weak is supposed to work just fine.
What exactly is not working for you?
Best regards,
Wolfgang Denk

Dear Mr. Denk,
Dear Ilko Iliev,
In message 48FDFCA0.4090608@ronetix.at you wrote:
Maybe instead of adding mor #ifdef'ery here, we can turn lowlevel_init() into a "weak" function that can be redefined by board specific code?
The lowlevel_init() is an assembler function called from another assembler function and the attribute .weak doesn't work.
What do you mean by "attribute .weak doesn't work" ?
There are no assembler file in the U-BOOT tree which use weak functions. Do you know how can I make an assembler function weak?
Well, if you don't know, then don't ask me, ask your compiler - he knows how to do this.
For example, common/cmd_boot.c has this code snippet right at the beginning:
30 31 /* Allow ports to override the default behavior */ 32 __attribute__((weak)) 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) 34 { 35 return entry (argc, argv); 36 }
Compile this with -S option, and you get this:
12 .Ltext0: 13 .align 2 14 .weak do_go_exec 15 .type do_go_exec, @function 16 do_go_exec: 17 .LFB87: 18 .file 1 "cmd_boot.c" 19 .loc 1 34 0 20 .LVL0: 21 mflr 0 22 .LCFI0: 23 stwu 1,-16(1) ...
So to me it seems as if the attribute .weak is supposed to work just fine.
What exactly is not working for you?
With ".weak lowlevel_init" the function is marked as weak (I can see this in the ELF file) but it is not overwritten from the another lowlevel_init().

On 13:12 Wed 22 Oct , Ilko Iliev wrote:
Dear Mr. Denk,
Dear Ilko Iliev,
In message 48FDFCA0.4090608@ronetix.at you wrote:
Maybe instead of adding mor #ifdef'ery here, we can turn lowlevel_init() into a "weak" function that can be redefined by board specific code?
The lowlevel_init() is an assembler function called from another assembler function and the attribute .weak doesn't work.
What do you mean by "attribute .weak doesn't work" ?
There are no assembler file in the U-BOOT tree which use weak functions. Do you know how can I make an assembler function weak?
Well, if you don't know, then don't ask me, ask your compiler - he knows how to do this.
For example, common/cmd_boot.c has this code snippet right at the beginning:
30 31 /* Allow ports to override the default behavior */ 32 __attribute__((weak)) 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) 34 { 35 return entry (argc, argv); 36 }
Compile this with -S option, and you get this:
12 .Ltext0: 13 .align 2 14 .weak do_go_exec 15 .type do_go_exec, @function 16 do_go_exec: 17 .LFB87: 18 .file 1 "cmd_boot.c" 19 .loc 1 34 0 20 .LVL0: 21 mflr 0 22 .LCFI0: 23 stwu 1,-16(1) ...
So to me it seems as if the attribute .weak is supposed to work just fine.
What exactly is not working for you?
With ".weak lowlevel_init" the function is marked as weak (I can see this in the ELF file) but it is not overwritten from the another lowlevel_init().
try .weak __default_lowlevel_init = lowlevel_init
IIRC
Best Regards, J.

Jean-Christophe PLAGNIOL-VILLARD wrote:
On 13:12 Wed 22 Oct , Ilko Iliev wrote:
Dear Mr. Denk,
Dear Ilko Iliev,
In message 48FDFCA0.4090608@ronetix.at you wrote:
Maybe instead of adding mor #ifdef'ery here, we can turn lowlevel_init() into a "weak" function that can be redefined by board specific code?
The lowlevel_init() is an assembler function called from another assembler function and the attribute .weak doesn't work.
What do you mean by "attribute .weak doesn't work" ?
There are no assembler file in the U-BOOT tree which use weak functions. Do you know how can I make an assembler function weak?
Well, if you don't know, then don't ask me, ask your compiler - he knows how to do this.
For example, common/cmd_boot.c has this code snippet right at the beginning:
30 31 /* Allow ports to override the default behavior */ 32 __attribute__((weak)) 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) 34 { 35 return entry (argc, argv); 36 }
Compile this with -S option, and you get this:
12 .Ltext0: 13 .align 2 14 .weak do_go_exec 15 .type do_go_exec, @function 16 do_go_exec: 17 .LFB87: 18 .file 1 "cmd_boot.c" 19 .loc 1 34 0 20 .LVL0: 21 mflr 0 22 .LCFI0: 23 stwu 1,-16(1) ...
So to me it seems as if the attribute .weak is supposed to work just fine.
What exactly is not working for you?
With ".weak lowlevel_init" the function is marked as weak (I can see this in the ELF file) but it is not overwritten from the another lowlevel_init().
try .weak __default_lowlevel_init = lowlevel_init
I tried and the result is: lowlevel_init.S:32: Error: junk at end of line, first unrecognized character is `='
I' using arm-elf-gcc 4.1.1

On 15:07 Wed 22 Oct , Ilko Iliev wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 13:12 Wed 22 Oct , Ilko Iliev wrote:
Dear Mr. Denk,
Dear Ilko Iliev,
In message 48FDFCA0.4090608@ronetix.at you wrote:
Maybe instead of adding mor #ifdef'ery here, we can turn lowlevel_init() into a "weak" function that can be redefined by board specific code?
The lowlevel_init() is an assembler function called from another assembler function and the attribute .weak doesn't work.
What do you mean by "attribute .weak doesn't work" ?
There are no assembler file in the U-BOOT tree which use weak functions. Do you know how can I make an assembler function weak?
Well, if you don't know, then don't ask me, ask your compiler - he knows how to do this.
For example, common/cmd_boot.c has this code snippet right at the beginning:
30 31 /* Allow ports to override the default behavior */ 32 __attribute__((weak)) 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) 34 { 35 return entry (argc, argv); 36 }
Compile this with -S option, and you get this:
12 .Ltext0: 13 .align 2 14 .weak do_go_exec 15 .type do_go_exec, @function 16 do_go_exec: 17 .LFB87: 18 .file 1 "cmd_boot.c" 19 .loc 1 34 0 20 .LVL0: 21 mflr 0 22 .LCFI0: 23 stwu 1,-16(1) ...
So to me it seems as if the attribute .weak is supposed to work just fine.
What exactly is not working for you?
With ".weak lowlevel_init" the function is marked as weak (I can see this in the ELF file) but it is not overwritten from the another lowlevel_init().
try
I tried and the result is: lowlevel_init.S:32: Error: junk at end of line, first unrecognized character is `='
sorry try this
.global __default_lowlevel_init ..... .weak lowlevel_init .set lowlevel_init,__default_lowlevel_init
after in the other asm .global lowlevel_init .......
Best Regards, J.

Jean-Christophe PLAGNIOL-VILLARD wrote:
On 15:07 Wed 22 Oct , Ilko Iliev wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 13:12 Wed 22 Oct , Ilko Iliev wrote:
Dear Mr. Denk,
Dear Ilko Iliev,
In message 48FDFCA0.4090608@ronetix.at you wrote:
> Maybe instead of adding mor #ifdef'ery here, we can turn > lowlevel_init() into a "weak" function that can be redefined by board > specific code? > > The lowlevel_init() is an assembler function called from another assembler function and the attribute .weak doesn't work.
What do you mean by "attribute .weak doesn't work" ?
There are no assembler file in the U-BOOT tree which use weak functions. Do you know how can I make an assembler function weak?
Well, if you don't know, then don't ask me, ask your compiler - he knows how to do this.
For example, common/cmd_boot.c has this code snippet right at the beginning:
30 31 /* Allow ports to override the default behavior */ 32 __attribute__((weak)) 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) 34 { 35 return entry (argc, argv); 36 }
Compile this with -S option, and you get this:
12 .Ltext0: 13 .align 2 14 .weak do_go_exec 15 .type do_go_exec, @function 16 do_go_exec: 17 .LFB87: 18 .file 1 "cmd_boot.c" 19 .loc 1 34 0 20 .LVL0: 21 mflr 0 22 .LCFI0: 23 stwu 1,-16(1) ...
So to me it seems as if the attribute .weak is supposed to work just fine.
What exactly is not working for you?
With ".weak lowlevel_init" the function is marked as weak (I can see this in the ELF file) but it is not overwritten from the another lowlevel_init().
try
I tried and the result is: lowlevel_init.S:32: Error: junk at end of line, first unrecognized character is `='
sorry try this
.global __default_lowlevel_init ..... .weak lowlevel_init .set lowlevel_init,__default_lowlevel_init
after in the other asm .global lowlevel_init .......
Best Regards, J.
Still doesn't work - the lowlevel_init is weak, but not overwritten.
It works only if the second (strong) function is in the same archive. Maybe this is a bug of the linker.

On 16:01 Wed 22 Oct , Ilko Iliev wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 15:07 Wed 22 Oct , Ilko Iliev wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 13:12 Wed 22 Oct , Ilko Iliev wrote:
Dear Mr. Denk,
Dear Ilko Iliev,
In message 48FDFCA0.4090608@ronetix.at you wrote:
>> Maybe instead of adding mor #ifdef'ery here, we can turn >> lowlevel_init() into a "weak" function that can be redefined by board >> specific code? >> >> > The lowlevel_init() is an assembler function called from another > assembler function and the attribute .weak doesn't work. > > What do you mean by "attribute .weak doesn't work" ?
> There are no assembler file in the U-BOOT tree which use weak functions. > Do you know how can I make an assembler function weak? > > Well, if you don't know, then don't ask me, ask your compiler - he knows how to do this.
For example, common/cmd_boot.c has this code snippet right at the beginning:
30 31 /* Allow ports to override the default behavior */ 32 __attribute__((weak)) 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) 34 { 35 return entry (argc, argv); 36 }
Compile this with -S option, and you get this:
12 .Ltext0: 13 .align 2 14 .weak do_go_exec 15 .type do_go_exec, @function 16 do_go_exec: 17 .LFB87: 18 .file 1 "cmd_boot.c" 19 .loc 1 34 0 20 .LVL0: 21 mflr 0 22 .LCFI0: 23 stwu 1,-16(1) ...
So to me it seems as if the attribute .weak is supposed to work just fine.
What exactly is not working for you?
With ".weak lowlevel_init" the function is marked as weak (I can see this in the ELF file) but it is not overwritten from the another lowlevel_init().
try
I tried and the result is: lowlevel_init.S:32: Error: junk at end of line, first unrecognized character is `='
sorry try this
.global __default_lowlevel_init ..... .weak lowlevel_init .set lowlevel_init,__default_lowlevel_init
after in the other asm .global lowlevel_init .......
Best Regards, J.
Still doesn't work - the lowlevel_init is weak, but not overwritten.
It works only if the second (strong) function is in the same archive. Maybe this is a bug of the linker.
Do you specify that the 2 is type "func"
Best Regards, J.

Jean-Christophe PLAGNIOL-VILLARD wrote:
On 16:01 Wed 22 Oct , Ilko Iliev wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 15:07 Wed 22 Oct , Ilko Iliev wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 13:12 Wed 22 Oct , Ilko Iliev wrote:
Dear Mr. Denk,
> Dear Ilko Iliev, > > In message 48FDFCA0.4090608@ronetix.at you wrote: > > > >>> Maybe instead of adding mor #ifdef'ery here, we can turn >>> lowlevel_init() into a "weak" function that can be redefined by board >>> specific code? >>> >>> >>> >> The lowlevel_init() is an assembler function called from another >> assembler function and the attribute .weak doesn't work. >> >> >> > What do you mean by "attribute .weak doesn't work" ? > > > > >> There are no assembler file in the U-BOOT tree which use weak functions. >> Do you know how can I make an assembler function weak? >> >> >> > Well, if you don't know, then don't ask me, ask your compiler - he > knows how to do this. > > For example, common/cmd_boot.c has this code snippet right at the > beginning: > > 30 > 31 /* Allow ports to override the default behavior */ > 32 __attribute__((weak)) > 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) > 34 { > 35 return entry (argc, argv); > 36 } > > Compile this with -S option, and you get this: > > 12 .Ltext0: > 13 .align 2 > 14 .weak do_go_exec > 15 .type do_go_exec, @function > 16 do_go_exec: > 17 .LFB87: > 18 .file 1 "cmd_boot.c" > 19 .loc 1 34 0 > 20 .LVL0: > 21 mflr 0 > 22 .LCFI0: > 23 stwu 1,-16(1) > ... > > > So to me it seems as if the attribute .weak is supposed to work just fine. > > What exactly is not working for you? > > > > With ".weak lowlevel_init" the function is marked as weak (I can see this in the ELF file) but it is not overwritten from the another lowlevel_init().
try
I tried and the result is: lowlevel_init.S:32: Error: junk at end of line, first unrecognized character is `='
sorry try this
.global __default_lowlevel_init ..... .weak lowlevel_init .set lowlevel_init,__default_lowlevel_init
after in the other asm .global lowlevel_init .......
Best Regards, J.
Still doesn't work - the lowlevel_init is weak, but not overwritten.
It works only if the second (strong) function is in the same archive. Maybe this is a bug of the linker.
Do you specify that the 2 is type "func"
The following variants don't work:
Variant A: .globl lowlevel_init .weak lowlevel_init .type lowlevel_init,function lowlevel_init: .......
Variant B: .globl __default_lowlevel_init .weak lowlevel_init .set lowlevel_init,__default_lowlevel_init .type __default_lowlevel_init,function lowlevel_init: .......

Dear Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 16:01 Wed 22 Oct , Ilko Iliev wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 15:07 Wed 22 Oct , Ilko Iliev wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 13:12 Wed 22 Oct , Ilko Iliev wrote:
Dear Mr. Denk,
> Dear Ilko Iliev, > > In message 48FDFCA0.4090608@ronetix.at you wrote: > > > >>> Maybe instead of adding mor #ifdef'ery here, we can turn >>> lowlevel_init() into a "weak" function that can be redefined by board >>> specific code? >>> >>> >>> >> The lowlevel_init() is an assembler function called from another >> assembler function and the attribute .weak doesn't work. >> >> >> > What do you mean by "attribute .weak doesn't work" ? > > > > >> There are no assembler file in the U-BOOT tree which use weak functions. >> Do you know how can I make an assembler function weak? >> >> >> > Well, if you don't know, then don't ask me, ask your compiler - he > knows how to do this. > > For example, common/cmd_boot.c has this code snippet right at the > beginning: > > 30 > 31 /* Allow ports to override the default behavior */ > 32 __attribute__((weak)) > 33 unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) > 34 { > 35 return entry (argc, argv); > 36 } > > Compile this with -S option, and you get this: > > 12 .Ltext0: > 13 .align 2 > 14 .weak do_go_exec > 15 .type do_go_exec, @function > 16 do_go_exec: > 17 .LFB87: > 18 .file 1 "cmd_boot.c" > 19 .loc 1 34 0 > 20 .LVL0: > 21 mflr 0 > 22 .LCFI0: > 23 stwu 1,-16(1) > ... > > > So to me it seems as if the attribute .weak is supposed to work just fine. > > What exactly is not working for you? > > > > With ".weak lowlevel_init" the function is marked as weak (I can see this in the ELF file) but it is not overwritten from the another lowlevel_init().
try
I tried and the result is: lowlevel_init.S:32: Error: junk at end of line, first unrecognized character is `='
sorry try this
.global __default_lowlevel_init ..... .weak lowlevel_init .set lowlevel_init,__default_lowlevel_init
after in the other asm .global lowlevel_init .......
Best Regards, J.
Still doesn't work - the lowlevel_init is weak, but not overwritten.
It works only if the second (strong) function is in the same archive. Maybe this is a bug of the linker.
Do you specify that the 2 is type "func"
Best Regards, J.
I tried several variants to make the function lowlevel_init() weak but without success. If there is no other solution for the problem could you commit my patch. Without this patch I can't post the patch for our PM9261 and PM9263 boards.

Hi Ilko,
Ilko Iliev wrote: <snip>
I tried several variants to make the function lowlevel_init() weak but without success. If there is no other solution for the problem could you commit my patch. Without this patch I can't post the patch for our PM9261 and PM9263 boards.
I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
cheers, Ben

On 09:27 Mon 27 Oct , Ben Warren wrote:
Hi Ilko,
Ilko Iliev wrote:
<snip> > I tried several variants to make the function lowlevel_init() weak but > without success. > If there is no other solution for the problem could you commit my patch. > Without this patch I can't post the patch for our PM9261 and PM9263 boards. > > I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
I've found a solution but it's need to update the all u-boot linking method.
Move from AR to LD.
Which need some work to fit on all boards.
Best Regards, J.

Dear Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 09:27 Mon 27 Oct , Ben Warren wrote:
Hi Ilko,
Ilko Iliev wrote:
<snip>
I tried several variants to make the function lowlevel_init() weak but without success. If there is no other solution for the problem could you commit my patch. Without this patch I can't post the patch for our PM9261 and PM9263 boards.
I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
I've found a solution but it's need to update the all u-boot linking method.
Move from AR to LD.
Which need some work to fit on all boards.
Best Regards, J.
Could be possible to commit my patch (I need it for the PM9261/PM9263 patches) because the moving from AR to LD will take a lot of time. When the moving from AR to LD is done, I will correct my board's patches.
Otherwise I must wait a lot of time and must change my patches every time when there is an correction in the at91 platform.

Dear Ilko,
In message 4905FE17.4040001@ronetix.at you wrote:
On 09:27 Mon 27 Oct , Ben Warren wrote:
...
I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
...
Could be possible to commit my patch (I need it for the PM9261/PM9263
I don't think this makes sense. If Ben is right (and I don't doubt that), than all that needs to be done is to link your own, board-specific lowlevel_init.o file separately, i. e. not as part of the lib$(BOARD).a archive.
This seems to be easy to do.
patches) because the moving from AR to LD will take a lot of time. When the moving from AR to LD is done, I will correct my board's patches.
Argh. May we please try and get the terms right. I know that you didn't phrase the words "moving from AR to LD", but repeating these makes no sense either. We've been using the linker ("ld") all the time and will continue to use it, no matter if we're liking libraries or object files. And note that we already now use a mix of both.
Otherwise I must wait a lot of time and must change my patches every time when there is an correction in the at91 platform.
Right. So let's do it right now. Please use the weak approach as described.
Best regards,
Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081027164336.GA1778@game.jcrosoft.org you wrote:
I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
I've found a solution but it's need to update the all u-boot linking method.
Move from AR to LD.
Well, that is exactly what Ben just described.
Which need some work to fit on all boards.
Well, actually only the file lowlevel_init.o needs to be treated that way, so the needed hcanges look not too complicated to me.
Best regards,
Wolfgang Denk

On 22:20 Mon 27 Oct , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081027164336.GA1778@game.jcrosoft.org you wrote:
I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
I've found a solution but it's need to update the all u-boot linking method.
Move from AR to LD.
Well, that is exactly what Ben just described.
Which need some work to fit on all boards.
Well, actually only the file lowlevel_init.o needs to be treated that way, so the needed hcanges look not too complicated to me.
I'll send a patch to move cpu/at91 to it only and an example to use it with board dir
Best Regards, J.

Dear Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 22:20 Mon 27 Oct , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081027164336.GA1778@game.jcrosoft.org you wrote:
I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
I've found a solution but it's need to update the all u-boot linking method.
Move from AR to LD.
Well, that is exactly what Ben just described.
Which need some work to fit on all boards.
Well, actually only the file lowlevel_init.o needs to be treated that way, so the needed hcanges look not too complicated to me.
I'll send a patch to move cpu/at91 to it only and an example to use it with board dir
Please take a look at the following patch:
diff --git a/Makefile b/Makefile index d6abb4d..b1c07ae 100644 --- a/Makefile +++ b/Makefile @@ -199,6 +199,11 @@ endif ifeq ($(CPU),mpc85xx) OBJS += cpu/$(CPU)/resetvec.o endif +ifeq ($(SOC),at91) +OBJS += cpu/$(CPU)/$(SOC)/lowlevel_init.o $(shell \ + if [ -f board/$(VENDOR)/$(BOARD)/$(BOARD)_lowlevel_init.S ]; then echo \ + "board/$(VENDOR)/$(BOARD)/$(BOARD)_lowlevel_init.o"; fi) +endif
OBJS := $(addprefix $(obj),$(OBJS))
@@ -337,7 +342,8 @@ $(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) -Map u-boot.map -o u-boot
$(OBJS): depend $(obj)include/autoconf.mk - $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@)) + $(MAKE) -C cpu/$(CPU) +# $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
$(LIBS): depend $(obj)include/autoconf.mk $(MAKE) -C $(dir $(subst $(obj),,$@)) diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile index 2d2a888..d0dcf9b 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -28,12 +28,13 @@ LIB = $(obj)lib$(SOC).a COBJS-y += timer.o COBJS-$(CONFIG_HAS_DATAFLASH) +=spi.o COBJS-y += usb.o -SOBJS = lowlevel_init.o +LOWLEVEL_INIT = lowlevel_init.o
-SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c) +SRCS := $(LOWLEVEL_INIT:.o=.S) $(SOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) +LOWLEVEL_INIT := $(addprefix $(obj),$(LOWLEVEL_INIT))
-all: $(obj).depend $(LIB) +all: $(obj).depend $(LIB) $(LOWLEVEL_INIT)
$(LIB): $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) diff --git a/cpu/arm926ejs/at91/lowlevel_init.S b/cpu/arm926ejs/at91/lowlevel_init.S index ec6ad5d..4fea4a6 100644 --- a/cpu/arm926ejs/at91/lowlevel_init.S +++ b/cpu/arm926ejs/at91/lowlevel_init.S @@ -30,6 +30,8 @@ #ifndef CONFIG_SKIP_LOWLEVEL_INIT
.globl lowlevel_init +.weak lowlevel_init +.set lowlevel_init,function lowlevel_init:
/*
I think that this part is not good, but I don't know how to make it better: - $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@)) + $(MAKE) -C cpu/$(CPU) +# $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))

On 12:45 Tue 28 Oct , Ilko Iliev wrote:
Dear Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 22:20 Mon 27 Oct , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081027164336.GA1778@game.jcrosoft.org you wrote:
I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
I've found a solution but it's need to update the all u-boot linking method.
Move from AR to LD.
Well, that is exactly what Ben just described.
Which need some work to fit on all boards.
Well, actually only the file lowlevel_init.o needs to be treated that way, so the needed hcanges look not too complicated to me.
I'll send a patch to move cpu/at91 to it only and an example to use it with board dir
Could you try this
diff --git a/config.mk b/config.mk index 5a9334c..0d81ab3 100644 --- a/config.mk +++ b/config.mk @@ -80,6 +80,9 @@ STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump RANLIB = $(CROSS_COMPILE)RANLIB +cmd_link_o_target = $(if $(strip $(2)),\ + $(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\ + rm -f $@; $(AR) rcs $(1))
#########################################################################
diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile index 2d2a888..662657c 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -36,7 +36,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) all: $(obj).depend $(LIB)
$(LIB): $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $@, $(OBJS))
#########################################################################
and modify your board lib build by - $(AR) $(ARFLAGS) $@ $(OBJS) + $(call cmd_link_o_target, $@, $(OBJS))
Best Regards, J.

Dear Jean,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 12:45 Tue 28 Oct , Ilko Iliev wrote:
Dear Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 22:20 Mon 27 Oct , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081027164336.GA1778@game.jcrosoft.org you wrote:
I've found that weak functions are only overwritten if the overwriting function is in a file (not archive) that has strongly-linked symbols. Admittedly, I've only done this with C code but expect that the assembly equivalent works the same way. The idea of using weak functions seems great, but suffers from some pretty cumbersome weaknesses :)
I've found a solution but it's need to update the all u-boot linking method.
Move from AR to LD.
Well, that is exactly what Ben just described.
Which need some work to fit on all boards.
Well, actually only the file lowlevel_init.o needs to be treated that way, so the needed hcanges look not too complicated to me.
I'll send a patch to move cpu/at91 to it only and an example to use it with board dir
Could you try this
diff --git a/config.mk b/config.mk index 5a9334c..0d81ab3 100644 --- a/config.mk +++ b/config.mk @@ -80,6 +80,9 @@ STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump RANLIB = $(CROSS_COMPILE)RANLIB +cmd_link_o_target = $(if $(strip $(2)),\
$(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
rm -f $@; $(AR) rcs $(1))
#########################################################################
diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile index 2d2a888..662657c 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -36,7 +36,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
- $(call cmd_link_o_target, $@, $(OBJS))
#########################################################################
and modify your board lib build by
- $(AR) $(ARFLAGS) $@ $(OBJS)
- $(call cmd_link_o_target, $@, $(OBJS))
Best Regards, J.
Your patch doesn't resolve the problem - the lowlevel_init.o is still a part of libat91.s: arm-elf-ld -r -o libat91.a lowlevel_init.o timer.o spi.o usb.o make[1]: Leaving directory `/home/develop/u-boot-last/u-boot/u-boot-2008-11-03/u-boot/cpu/arm926ejs/at91'
The attribute ".weak" works only if the file where is the weak function is not in a library. I'm not familiar with the makefile scripting, but I can't see a possibility to link both lowlevel_init.o files into the u-boot.elf without to change the main Makefile.
I think my last patch is a possible solution, but I don't know if the following is a potential problem:
- $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@)) + $(MAKE) -C cpu/$(CPU)
I haven't the possibility to compile U-BOOT for all targets - maybe someone can test all targets with my last patch (email from 28.10.2008).

On 18:29 Wed 05 Nov , Ilko Iliev wrote:
Dear Jean,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 12:45 Tue 28 Oct , Ilko Iliev wrote:
Dear Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 22:20 Mon 27 Oct , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081027164336.GA1778@game.jcrosoft.org you wrote:
> I've found that weak functions are only overwritten if the overwriting > function is in a file (not archive) that has strongly-linked symbols. > Admittedly, I've only done this with C code but expect that the assembly > equivalent works the same way. The idea of using weak functions seems > great, but suffers from some pretty cumbersome weaknesses :) > > I've found a solution but it's need to update the all u-boot linking method.
Move from AR to LD.
Well, that is exactly what Ben just described.
Which need some work to fit on all boards.
Well, actually only the file lowlevel_init.o needs to be treated that way, so the needed hcanges look not too complicated to me.
I'll send a patch to move cpu/at91 to it only and an example to use it with board dir
Could you try this
diff --git a/config.mk b/config.mk index 5a9334c..0d81ab3 100644 --- a/config.mk +++ b/config.mk @@ -80,6 +80,9 @@ STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump RANLIB = $(CROSS_COMPILE)RANLIB +cmd_link_o_target = $(if $(strip $(2)),\
$(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
rm -f $@; $(AR) rcs $(1))
#########################################################################
diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile index 2d2a888..662657c 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -36,7 +36,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
- $(call cmd_link_o_target, $@, $(OBJS))
#########################################################################
and modify your board lib build by
- $(AR) $(ARFLAGS) $@ $(OBJS)
- $(call cmd_link_o_target, $@, $(OBJS))
Best Regards, J.
Your patch doesn't resolve the problem - the lowlevel_init.o is still a part of libat91.s: arm-elf-ld -r -o libat91.a lowlevel_init.o timer.o spi.o usb.o make[1]: Leaving directory `/home/develop/u-boot-last/u-boot/u-boot-2008-11-03/u-boot/cpu/arm926ejs/at91'
The attribute ".weak" works only if the file where is the weak function is not in a library.
This method of build will not generate a library evenif it's still called libat91.a, it will generate a pre-built object.
Best Regards, J.

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081105173728.GB5323@game.jcrosoft.org you wrote:
The attribute ".weak" works only if the file where is the weak function is not in a library.
This method of build will not generate a library evenif it's still called libat91.a, it will generate a pre-built object.
Then we probably should avoid a .a suffix ?
Best regards,
Wolfgang Denk

Dear Jean,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 18:29 Wed 05 Nov , Ilko Iliev wrote:
Dear Jean,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 12:45 Tue 28 Oct , Ilko Iliev wrote:
Dear Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 22:20 Mon 27 Oct , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081027164336.GA1778@game.jcrosoft.org you wrote:
>> I've found that weak functions are only overwritten if the overwriting >> function is in a file (not archive) that has strongly-linked symbols. >> Admittedly, I've only done this with C code but expect that the assembly >> equivalent works the same way. The idea of using weak functions seems >> great, but suffers from some pretty cumbersome weaknesses :) >> >> >> > I've found a solution but it's need to update the all u-boot linking method. > > Move from AR to LD. > > > Well, that is exactly what Ben just described.
> Which need some work to fit on all boards. > > > Well, actually only the file lowlevel_init.o needs to be treated that way, so the needed hcanges look not too complicated to me.
I'll send a patch to move cpu/at91 to it only and an example to use it with board dir
Could you try this
diff --git a/config.mk b/config.mk index 5a9334c..0d81ab3 100644 --- a/config.mk +++ b/config.mk @@ -80,6 +80,9 @@ STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump RANLIB = $(CROSS_COMPILE)RANLIB +cmd_link_o_target = $(if $(strip $(2)),\
$(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
rm -f $@; $(AR) rcs $(1))
#########################################################################
diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile index 2d2a888..662657c 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -36,7 +36,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
- $(call cmd_link_o_target, $@, $(OBJS))
#########################################################################
and modify your board lib build by
- $(AR) $(ARFLAGS) $@ $(OBJS)
- $(call cmd_link_o_target, $@, $(OBJS))
Best Regards, J.
Your patch doesn't resolve the problem - the lowlevel_init.o is still a part of libat91.s: arm-elf-ld -r -o libat91.a lowlevel_init.o timer.o spi.o usb.o make[1]: Leaving directory `/home/develop/u-boot-last/u-boot/u-boot-2008-11-03/u-boot/cpu/arm926ejs/at91'
The attribute ".weak" works only if the file where is the weak function is not in a library.
This method of build will not generate a library evenif it's still called libat91.a, it will generate a pre-built object.
I can confirm that your patch works - thank you! Please commit the patch into the mainline.

Dear Jean,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 18:29 Wed 05 Nov , Ilko Iliev wrote:
Dear Jean,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 12:45 Tue 28 Oct , Ilko Iliev wrote:
Dear Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 22:20 Mon 27 Oct , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20081027164336.GA1778@game.jcrosoft.org you wrote:
>> I've found that weak functions are only overwritten if the overwriting >> function is in a file (not archive) that has strongly-linked symbols. >> Admittedly, I've only done this with C code but expect that the assembly >> equivalent works the same way. The idea of using weak functions seems >> great, but suffers from some pretty cumbersome weaknesses :) >> >> >> > I've found a solution but it's need to update the all u-boot linking method. > > Move from AR to LD. > > > Well, that is exactly what Ben just described.
> Which need some work to fit on all boards. > > > Well, actually only the file lowlevel_init.o needs to be treated that way, so the needed hcanges look not too complicated to me.
I'll send a patch to move cpu/at91 to it only and an example to use it with board dir
Could you try this
diff --git a/config.mk b/config.mk index 5a9334c..0d81ab3 100644 --- a/config.mk +++ b/config.mk @@ -80,6 +80,9 @@ STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump RANLIB = $(CROSS_COMPILE)RANLIB +cmd_link_o_target = $(if $(strip $(2)),\
$(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
rm -f $@; $(AR) rcs $(1))
#########################################################################
diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile index 2d2a888..662657c 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -36,7 +36,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
- $(call cmd_link_o_target, $@, $(OBJS))
#########################################################################
and modify your board lib build by
- $(AR) $(ARFLAGS) $@ $(OBJS)
- $(call cmd_link_o_target, $@, $(OBJS))
Best Regards, J.
Your patch doesn't resolve the problem - the lowlevel_init.o is still a part of libat91.s: arm-elf-ld -r -o libat91.a lowlevel_init.o timer.o spi.o usb.o make[1]: Leaving directory `/home/develop/u-boot-last/u-boot/u-boot-2008-11-03/u-boot/cpu/arm926ejs/at91'
The attribute ".weak" works only if the file where is the weak function is not in a library.
This method of build will not generate a library evenif it's still called libat91.a, it will generate a pre-built object.
I forgot to tell you that it is enough to define the lowlevel_init() in arm926ej/at91/lowlevel_init.S as weak by the following way:
.globl lowlevel_init .weak lowlevel_init lowlevel_init:
/* * Clocks/SDRAM initialization is handled by at91bootstrap, * no need to do it here... */ mov pc, lr
participants (4)
-
Ben Warren
-
Ilko Iliev
-
Jean-Christophe PLAGNIOL-VILLARD
-
Wolfgang Denk