From: Jerry Van Baren <gvb.uboot@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Can not access global variable in uboot command function?
Date: Sun, 11 Oct 2009 21:28:24 -0400 [thread overview]
Message-ID: <4AD28638.4060903@gmail.com> (raw)
In-Reply-To: <e997b7420910102010s49de3c15q85091c7b86f9ee3@mail.gmail.com>
Hi Wilbur,
wilbur.chan wrote:
> mips64 , xlr732
>
> I've added a test command in uboot, say,
> U_BOOT_CMD(test_globa,...do_test_global) ,which is in cmd_command.c
>
> And in cmd_command.c, there is also a global string array ,say ,char*
> p = "test";
>
> In do_test_global, I used pointer to access elements of array p like this:
>
> char c = *(char*)p;
>
> it seemd that , the code above caused uboot dead and print nothing ,I
> guess that,maybe there was a memory access violation.
>
> Any suggestions on how could this happended? Thank you in advance
Just a guess, but I suspect your are getting bitten by the manual
pointer relocation issue.
Your char *p is pointing into flash, but you are dereferencing the
pointer after relocation to RAM, running out of RAM with a different
memory map than power-on-reset (initialization has completed). I
suspect your flash image is no longer where it was on release of reset
and thus dereferencing *p now tries to read an invalid memory location,
causing your "hang."
If you really need the pointers, you need to manually relocate them.
See ./include/asm-mips/global_data.h and the function
void board_init_r (gd_t *id, ulong dest_addr)
in lib_mips/board.c.
The bottom line is that you probably need to add gd->reloc_off to your
compiled-in pointers:
*(p + gd->reloc_off)
[snip]
gvb
prev parent reply other threads:[~2009-10-12 1:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-11 3:10 [U-Boot] Can not access global variable in uboot command function? wilbur.chan
2009-10-12 1:28 ` Jerry Van Baren [this message]
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=4AD28638.4060903@gmail.com \
--to=gvb.uboot@gmail.com \
--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 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.