[U-Boot] [RFC] himport_r() with the first call malloc() (with bin relocation) problem in NDS32 architecture
馬克泡
macpaul at gmail.com
Thu Aug 25 13:04:25 CEST 2011
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
More information about the U-Boot
mailing list