Ejemplo n.º 1
0
void spl_ymodem_load_image(void)
{
	int size = 0;
	int err;
	int res;
	int ret;
	connection_info_t info;
	char buf[BUF_SIZE];
	ulong store_addr = ~0;
	ulong addr = 0;

	info.mode = xyzModem_ymodem;
	ret = xyzModem_stream_open(&info, &err);

	if (!ret) {
		while ((res =
			xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0) {
			if (addr == 0)
				spl_parse_image_header((struct image_header *)buf);
			store_addr = addr + spl_image.load_addr;
			size += res;
			addr += res;
			memcpy((char *)(store_addr), buf, res);
            WATCHDOG_RESET(); //add by QWB
		}
	} else {
		printf("spl: ymodem err - %s\n", xyzModem_error(err));
		hang();
	}

	xyzModem_stream_close(&err);
	xyzModem_stream_terminate(false, &getcymodem);

	printf("Loaded %d bytes\n", size);
}
Ejemplo n.º 2
0
int
do_download (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	//printf ("\ndownload by kdh\n");

    int size;
		int offset = 0x32000000;
    char buf[32];
    int err;
    int res;
    connection_info_t info;
    char ymodemBuf[1024];
    ulong store_addr = ~0;
    ulong addr = 0;

    size = 0;
    info.mode = xyzModem_ymodem;
    res = xyzModem_stream_open (&info, &err);
    if (!res) {

        while ((res =
            xyzModem_stream_read (ymodemBuf, 1024, &err)) > 0) {
            store_addr = addr + offset;
            size += res;
            addr += res;
						memcpy ((char *) (store_addr), ymodemBuf, res);
        }
    } else {
        printf ("%s\n", xyzModem_error (err));
    }

    xyzModem_stream_close (&err);
    xyzModem_stream_terminate (false, &getcxmodem);


    //flush_cache (offset, size);

    printf ("## Total Size      = 0x%08x = %d Bytes\n", size, size);
    sprintf (buf, "%X", size);

		const unsigned char *p = (unsigned char *)offset;
		for ( int nIndex = 0; nIndex < size; nIndex++)
		{
			printf("%x ", p[nIndex]);
		}
    //setenv ("filesize", buf);

    return offset;
}