public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Matthias Weisser <weisserm@arcor.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] sandbox: Crash on startup
Date: Tue, 01 Nov 2011 10:50:16 +0100	[thread overview]
Message-ID: <4EAFC0D8.6030407@arcor.de> (raw)

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

             reply	other threads:[~2011-11-01  9:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-01  9:50 Matthias Weisser [this message]
2011-11-01 14:01 ` [U-Boot] sandbox: Crash on startup Simon Glass
2011-11-01 14:18   ` Matthias Weisser
2011-11-01 18:54   ` Mike Frysinger
2011-11-02 21:01     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EAFC0D8.6030407@arcor.de \
    --to=weisserm@arcor.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox