[U-Boot] strange thing: u-boot's vsprintf overrun on DM355

yaojin liu lanmanck at gmail.com
Thu Jul 29 02:49:25 CEST 2010


hi,all:
I encounter strange thing again. :(

it seems the vsprintf will overrun. have someone met before?

To debug it ,I define a function writing character directly to the register:
"u_sendstring()"

Here is the code for debugging printf:

 void printf(const char *fmt, ...)

{

va_list args;

uint i;

char printbuffer[CONFIG_SYS_PBSIZE];

va_start(args, fmt);

/* For this to work, printbuffer must be larger than

* anything we ever want to print.

*/

u_sendstring("printf2\n");

i = vsprintf(printbuffer, fmt, args);

u_sendstring("printf3\n");

va_end(args);

puts(printbuffer);

}

and here is the output:

DM3xx=>>:    DONEprintf2

DM3xx=>>: printf3

DM3xx=>>: U-Boot 2009.03 ( 2010 - 23:14:17)

DM3xx=>>: I2C:   ready

DM3xx=>>: DRAM:  printf2

DM3xx=>>: printf3

DM3xx=>>: 128printf2

DM3xx=>>: printf3

DM3xx=>>:  MB

DM3xx=>>: NAND:  board_nand_init end

DM3xx=>>: nand_scan1

DM3xx=>>: nand_scan_ident1

DM3xx=>>: nand_scan_ident2

DM3xx=>>: nand_get_flash_type1

DM3xx=>>: nand_get_flash_type2

DM3xx=>>: nand_get_flash_type4

DM3xx=>>: printf2n BOOTME

DM3xx=>>:  BOOTME

DM3xx=>>:  BOOTME

DM3xx=>>:  BOOTME


/////////////////////// weill, you can see that the first string will output
correctly,such as "128" "MB", but when it ran to nand_get_flash_type(), the
chip reboot.

static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
struct nand_chip *chip, int busw, int *maf_id)

{

struct nand_flash_dev *type = NULL;

int i, dev_id, maf_idx;

int tmp_id, tmp_manf;

/* Select the device */

chip->select_chip(mtd, 0);

u_sendstring("nand_get_flash_type1\n");

.....

u_sendstring("nand_get_flash_type4\n");

printk("NAND device: Manufacturer ID:"

         " 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id, dev_id,

         nand_manuf_ids[maf_idx].name, type->name);

u_sendstring("nand_get_flash_type5\n");

return type;

}

printk is just printf. So as i describe above, the code ran to vsprintf and
no respond anymore.
How could this happen? Is it another hardware bug?


More information about the U-Boot mailing list