From: wilbur.chan Date: Sun, 11 Oct 2009 11:10:37 +0800 Subject: [U-Boot] Can not access global variable in uboot command function? Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 my code is like this: /* cmd_command.c*/ char* p = "test"; U_BOOT_CMD(test_globa,do_test_global) ; int do_test_global() { char c = *(char*)p; //when called , uboot was dead here... return 0; }