[U-Boot] sandbox: Crash on startup

Matthias Weisser weisserm at arcor.de
Tue Nov 1 10:50:16 CET 2011


Dear Simon

I just wanted to play around with the sandbox "arch" of u-boot maybe
adding tun/tap support. Current head compiled successfully but crashed
immediately after startup in board_init_f:

	gd = malloc(sizeof(gd_t));
	assert(gd);

	memset((void *)gd, 0, sizeof(gd_t));

The simple reason was that malloc refers to u-boots internal malloc
which is not initialized at this point. I added the following snippet

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 685793e..c98ca61 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -21,8 +21,12 @@

 #include <common.h>

+static uint8_t malloc_area[1024*1024*256];
+
 int main(int argc, char *argv[])
 {
+    mem_malloc_init(malloc_area, sizeof(malloc_area));
+
        /*

and got the console working. Can you tell me what I am doing wrong when
building u-boot from current head? Wouldn't it be a better approach to
use the internal malloc of u-boot and acquire some memory from the
system using mmap?

Regards
Matthias


More information about the U-Boot mailing list