All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Van Baren <gvb.uboot@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Help Request - Command parsing, find_cmd (), possible linker script problem
Date: Sat, 20 Sep 2008 09:57:17 -0400	[thread overview]
Message-ID: <48D5013D.10906@gmail.com> (raw)
In-Reply-To: <48D49E9E.6000405@gmail.com>

Graeme Russ wrote:
> Hi All,
> 
> So far I have my sc520 board booting into main_loop (), DRAM configured
> and serial ports working. Now I seem to be stuck on getting commands
> to execute (even help). Using printf() I have traced my problem into
> find_cmd (). I added the following into find_cmd() just before the for
> loop:
>
> printf ("Searching for Command '%s'\n", cmd);
> printf ("Command Table Start : %08lx\n", (ulong)&__u_boot_cmd_start);
> printf ("Command Table End   : %08lx\n", (ulong)&__u_boot_cmd_end);
> printf ("sizeof(int)         : %x\n", sizeof(int));
> printf ("sizeof(cmd_tbl_t)   : %x\n", sizeof(cmd_tbl_t));

Aaargh, you printed %x, not 0x%x.  That really threw me on the printout 
of sizeof(cmd_tbl_t).

[snip]

> The output is (there are a few other printf()'s leadinf up to
> find_cmd () as well):
> 
> boot > help
> 
> [RUN_COMMAND] cmd[00400ccc]="help"
> [PROCESS_SEPARATORS] help
> token: "help"
> 
> Processing Macros...
> [PROCESS_MACROS] INPUT len 4: "help"
> [PROCESS_MACROS] OUTPUT len 4: "help"
> Extracting Arguments...
> parse_line: "help"
> 
> parse_line: nargs=1
> Looking up Command...
> Searching for Command 'help'
> Command Table Start : 0000053e
> Command Table End   : 00000870

0x870 - 0x53e = 0x332 = 818.  818 / 24 = 34 with a remainder of 2.  I 
believe this is your problem.  I bet you need to word-align the start of 
your table... the end label is getting word aligned which is padding out 
your end so your loop doesn't end.

I suspect this is the problem with not recognizing the commands as well? 
  Perhaps the processor/compiler doesn't like having the table poorly 
aligned so one of the pointers is getting messed up?

> sizeof(int)         : 4
> sizeof(cmd_tbl_t)   : 18

0x18 == 24

> Checking : 0000053e
> Checking : 00000556

0x56 - 0x3e == 0x18 == 24 (check)

> Checking : 0000056e
> .
> .
> .
> Checking : 00000856
> Checking : 0000086e

0x86e is the proper table end given 34 commands and 24 bytes per table 
entry.

> Checking : 00000886
> Checking : 0000089e
> Checking : 000008b6
> 
> There are a few weird things going on...
> 
> a) sizeof(cmd_tbl_t) is 18, but the loop is incrementing by 24 (I would
> have thought a 4 byte alignment would push it to 20 maybe)

Nope, just radix issues (see above).

> 
> b) The loop never completes since cmdtp never actually equals
> &__u_boot_cmd_end

Alignment padding problems are preventing it (see above).

[snip]

> Can anyone point me an a rough direction to look? Any help at all
> would be greatly appreciated

I think you need a 4 byte alignment before the command table in the 
linker control file (below)

> Regards,
> 
> Graeme
> 
> u-boot.lds:

[snip]

> 	/* 16bit BIOS emulation code (just enough to boot Linux) */
> 	.bios 0 : AT ( LOADADDR(.realmode) + SIZEOF(.realmode) ) { *(.bios) }
> 
> 	_i386boot_bios = LOADADDR(.bios);
> 	_i386boot_bios_size = SIZEOF(.bios);
> 
> 
>   . = .;


I think you need to add
. = ALIGN(2);
here

(ALIGN(4)? IIRC, the ALIGN is 2^n so ALIGN(2) is 4-byte alignment)

>   __u_boot_cmd_start = .;
>   .u_boot_cmd : { *(.u_boot_cmd) }
>   __u_boot_cmd_end = .;

[snip]

HTH,
gvb

  reply	other threads:[~2008-09-20 13:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-20  6:56 [U-Boot] Help Request - Command parsing, find_cmd (), possible linker script problem Graeme Russ
2008-09-20 13:57 ` Jerry Van Baren [this message]
2008-09-20 23:27   ` Graeme Russ
2008-09-21  2:22     ` Graeme Russ

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=48D5013D.10906@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.