* [U-Boot] [RFC] himport_r() with the first call malloc() (with bin relocation) problem in NDS32 architecture
@ 2011-08-25 11:04 馬克泡
2011-10-31 4:35 ` Vinay
0 siblings, 1 reply; 3+ messages in thread
From: 馬克泡 @ 2011-08-25 11:04 UTC (permalink / raw)
To: u-boot
Hi all,
I'm doing the relocation work for NDS32 architecture.
Currently I've encountered bin relocation problem on malloc().
I've called malloc_bin_reloc() in my lib/board.c however the malloc
for env_relocate still get problem.
Hope someone whom has experience could help me and give me some suggestion.
The relocation parameters are list as below.
1. relocation Offset is: 03fc4000.
2. Three parameters to call relocate_code() and then passed to
board_init_r() is
addr_sp: 03f41f60, id: 03f41f6c, addr: 03fc4000
3. mem_malloc_init related parameters are:
mem_malloc_init: mem_malloc_start: 03F42000, size: 00082000
mem_malloc_init: mem_malloc_start: 03F42000, mem_malloc_end: 03FC4000
4. gd->reloc_off = dest_addr = 0x3fc4000 (The binary of u-boot is
relocated from 0x0 to 0x3fc4000.)
5. All cache is disabled.
6. The first call malloc() will be called is 29 bytes memory
allocation in himport_r().
Hence the procedure will into
"if (is_small_request(nb)) " in malloc() in dlmalloc.c.
The first malloc() will usually fail and execute malloc_extend_top().
However, after malloc_extend_top(), we should be able to get the first
allocated memory.
But I've found a really strange problem when the first malloc() within
himport_r().
That is I will continually get malloc() is fail if the first env
import in himport_r() is fail.
If I do the first memory allocate before the malloc() in himport_r(),
then the hash table and the continue
himport_r() will be success. Is there anything I should do before or
after bin relocation?
If anyone has experience with the same problem,
please give me some advice and suggestions for helping on this issue
The following two debugging log is the default env import process
which the first result is env import fail, and
the second result is env import success while the first malloc() is
called before himport_r() is called.
A. Default env import failed.
himport_r: htab addr: 03feb250, env addr: 03fe2e14, size: 0000001d,
sep: 00000000, flag: 00000000
malloc: mem_malloc_start: 03F42000, mem_malloc_end: 03FC4000
val: victim: 03fea71c, last_remainder->fd: 03fea6f4, last_remaider: 03fea6f4
remainder_size: ffffffd8, top: 03fea6ec, MINSIZE: 00000010
remainder_size: ffffffd8, top: 03f42000, MINSIZE: 00000010
himport_r: can't malloc 29 bytes
ERROR: Environment import failed: errno = 12
at env_common.c:194/set_default_env()
malloc: mem_malloc_start: 03F42000, mem_malloc_end: 03FC4000
val: victim: 03fea734, last_remainder->fd: 03fea6f4, last_remaider: 03fea6f4
victim=top: top: addr: 03fea6f4, val: 03f42000
malloc: mem_malloc_start: 03F42000, mem_malloc_end: 03FC4000
val: victim: 03fea76c, last_remainder->fd: 03fea6f4, last_remaider: 03fea6f4
victim=top: top: addr: 03fea6f4, val: 03f42040
In: serial
Out: serial
Err: serial
malloc: mem_malloc_start: 03F42000, mem_malloc_end: 03FC4000
val: victim: 03fea704, last_remainder->fd: 03fea6f4, last_remaider: 03fea6f4
victim=top: top: addr: 03fea6f4, val: 03f420b8
## Error inserting "stdin" variable, errno=12 (nomem)
B. The default env is imported successfully and we need the first
malloc() been called before
the first call himport_r().
val: victim: 03fea7cc, last_remainder->fd: 03fea7a4, last_remaider: 03fea7a4
remainder_size: ffffffd8, top: 03fea79c, MINSIZE: 00000010
after malloc_extend_top: remainder_size: ffffffd8, top: 03f42000,
MINSIZE: 00000010
board_init_r: test: 00000000
val: victim: 03fea7cc, last_remainder->fd: 03fea7a4, last_remaider: 03fea7a4
victim=top: top: addr: 03fea7a4, val: 03f42000, remainder_size: 00000fd8
chunk2mem(victim): 03f42008
board_init_r: test: 03f42008
env_reloc
*** Warning - bad CRC, using default environment
himport_r: htab addr: 03feb300, env addr: 03fe2e3c, size: 0000001d,
sep: 00000000, flag: 00000000
val: victim: 03fea7cc, last_remainder->fd: 03fea7a4, last_remaider: 03fea7a4
victim=top: top: addr: 03fea7a4, val: 03f42028, remainder_size: 00000fb0
chunk2mem(victim): 03f42030
Destroy Hash Table: 03feb300 table = (null)
Create Hash Table: N=67
val: victim: 03fea9bc, last_remainder->fd: 03fea7a4, last_remaider: 03fea7a4
victim=top: top: addr: 03fea7a4, val: 03f42050, remainder_size: 00000c78
chunk2mem(victim): 03f42058
Thank for your help.
--
Best regards,
Macpaul Lin
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [RFC] himport_r() with the first call malloc() (with bin relocation) problem in NDS32 architecture
2011-08-25 11:04 [U-Boot] [RFC] himport_r() with the first call malloc() (with bin relocation) problem in NDS32 architecture 馬克泡
@ 2011-10-31 4:35 ` Vinay
2011-11-02 14:02 ` 馬克泡
0 siblings, 1 reply; 3+ messages in thread
From: Vinay @ 2011-10-31 4:35 UTC (permalink / raw)
To: u-boot
??? <macpaul <at> gmail.com> writes:
> himport_r: can't malloc 29 bytes
> ERROR: Environment import failed: errno = 12
>
> at env_common.c:194/set_default_env()
>
Hi,
Did you get solution to this malloc failure in himpotr_r issue?
I'm hitting the same issue and looking forward to some help.
Thanks
Vinay
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [RFC] himport_r() with the first call malloc() (with bin relocation) problem in NDS32 architecture
2011-10-31 4:35 ` Vinay
@ 2011-11-02 14:02 ` 馬克泡
0 siblings, 0 replies; 3+ messages in thread
From: 馬克泡 @ 2011-11-02 14:02 UTC (permalink / raw)
To: u-boot
Hi Vinary
2011/10/31 Vinay <vinaymh@gmail.com>:
> Macpaul <macpaul <at> gmail.com> writes:
>
>> himport_r: can't malloc 29 bytes
>
> Hi,
>
> Did you get solution to this malloc failure in himpotr_r issue?
> I'm hitting the same issue and looking forward to some help.
>
> Thanks
> Vinay
>
I do not know which architecture/platform you're using.
Please describe your environment more detail, also the u-boot version
should be told.
Please check your memory layout after relocation back and forth,
be careful on the value of stack pointer and the starting address of
malloc section.
Also the configuration of the size for each section might affect.
I suggest you to check board_init_r() more detail.
Hope this can help you.
--
Best regards,
Macpaul Lin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-02 14:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-25 11:04 [U-Boot] [RFC] himport_r() with the first call malloc() (with bin relocation) problem in NDS32 architecture 馬克泡
2011-10-31 4:35 ` Vinay
2011-11-02 14:02 ` 馬克泡
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.