From mboxrd@z Thu Jan 1 00:00:00 1970 From: Graeme Russ Date: Sun, 21 Sep 2008 09:27:46 +1000 Subject: [U-Boot] Help Request - Command parsing, find_cmd (), possible linker script problem In-Reply-To: <48D5013D.10906@gmail.com> References: <48D49E9E.6000405@gmail.com> <48D5013D.10906@gmail.com> Message-ID: <48D586F2.2010505@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Thanks for such a quick response Jerry. Your suggestion fixed one problem, but it still doesn't work Jerry Van Baren wrote: > Graeme Russ wrote: >> Hi All, >> > > Aaargh, you printed %x, not 0x%x. That really threw me on the printout > of sizeof(cmd_tbl_t). > > > 0x18 == 24 How embarrassing - I've changed it to %i >> >> b) The loop never completes since cmdtp never actually equals >> &__u_boot_cmd_end > > Alignment padding problems are preventing it (see above). > Fixed with . = ALIGN(4) (ALIGN(2) made no difference) I've added a few more debugs in the loop (and my startup code) with the following results: U-Boot 2008.10-rc2-00002-gd6aaec1-dirty (Sep 20 2008 - 14:37:52) U-Boot code: 38040000 -> 3805158F data: 00400000 -> 00400A57 BSS: 00400A58 -> 00404463 stack: 00404464 -> 0040C463 DRAM Configuration: Bank #0: 00000000 64 MB Bank #1: 04000000 64 MB Bank #2: 08000000 0 kB Bank #3: 08000000 0 kB *** Warning - bad CRC, using default environment In: serial Out: serial Err: serial Serck Controls eNET autoscript => do_autoscript() @ 0x38040886 bdinfo => do_bdinfo() @ 0x380408e7 imls => do_imls() @ help => do_help() @ 0x38043713 ? => do_help() @ 0x38043713 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 : 0x00000540 Command Table End : 0x00000870 sizeof(int) : 4 sizeof(cmd_tbl_t) : 24 cmdtp = 0x00000540 cmdtp->name = 0xffffffff cmdtp->maxargs = -262145 cmdtp->repeatable = -33562625 cmdtp->cmd = 0xf7ffffff cmdtp->usage = 0xffff5fff cmdtp->help = 0x7bffff7f cmdtp = 0x00000858 cmdtp->name = 0xfeffffff cmdtp->maxargs = -513 cmdtp->repeatable = -1 cmdtp->cmd = 0xffffffff cmdtp->usage = 0xffffffff cmdtp->help = 0xffffffff Searching complete Unknown command 'help' - try 'help' boot > The address dumps of each command are simply achieved by: printf("autoscript => do_autoscript() @ 0x%08lx\n", (ulong)do_autoscript); /* printf("imls => do_imls() @ 0x%08lx\n", (ulong)do_imls); */ printf("imls => do_imls() @ \n"); For some reason do_imls always results in an undefined reference error reported by the linker, even though it ends up in the command list at 0x600 as shown in u-boot.map 0x0000000000000540 . = ALIGN (0x4) 0x0000000000000540 __u_boot_cmd_start = . .u_boot_cmd 0x0000000000000540 0x330 load address 0x000000003805268e *(.u_boot_cmd) .u_boot_cmd 0x0000000000000540 0x18 common/libcommon.a(cmd_autoscript.o) 0x0000000000000540 __u_boot_cmd_autoscr .u_boot_cmd 0x0000000000000558 0x18 common/libcommon.a(cmd_bdinfo.o) 0x0000000000000558 __u_boot_cmd_bdinfo .u_boot_cmd 0x0000000000000570 0x30 common/libcommon.a(cmd_boot.o) 0x0000000000000588 __u_boot_cmd_reset 0x0000000000000570 __u_boot_cmd_go .u_boot_cmd 0x00000000000005a0 0x78 common/libcommon.a(cmd_bootm.o) 0x00000000000005a0 __u_boot_cmd_bootm 0x00000000000005e8 __u_boot_cmd_iminfo 0x00000000000005d0 __u_boot_cmd_bootd 0x00000000000005b8 __u_boot_cmd_boot 0x0000000000000600 __u_boot_cmd_imls .u_boot_cmd 0x0000000000000618 0x18 common/libcommon.a(cmd_console.o) So now it is terminating the loop correctly, but it looks like the command table contains nothing garbage I thought the load address 0x000000003805268e might be a hint, so I did a dump of u-boot.bin: 0x3805268e - 0x3804000 = 0x1268E = 75406 graeme at devel:~/Source/U-Boot/v2008.10-rc2$ xxd -s 75406 -l 160 u-boot.bin 001268e: 90e0 0438 0200 0000 0000 0000 8608 0438 ...8...........8 001269e: 98e0 0438 bae0 0438 a4e1 0438 0100 0000 ...8...8...8.... 00126ae: 0100 0000 e708 0438 abe1 0438 0000 0000 .......8...8.... 00126be: 2be2 0438 1000 0000 0100 0000 c509 0438 +..8...........8 00126ce: 2ee2 0438 5de2 0438 b8e2 0438 0100 0000 ...8]..8...8.... 00126de: 0000 0000 63c9 0438 bee2 0438 0000 0000 ....c..8...8.... 00126ee: 7ee6 0438 1000 0000 0100 0000 5a0c 0438 ~..8........Z..8 00126fe: 84e6 0438 b2e6 0438 c301 0538 0100 0000 ...8...8...8.... 001270e: 0100 0000 3a0c 0438 5ae7 0438 0000 0000 ....:..8Z..8.... 001271e: 87e7 0438 0100 0000 0100 0000 3a0c 0438 ...8........:..8 Doesn't seem to match (maybe I'm barking up the wrong tree) Any ideas? Regards, Graeme