Ejemplo n.º 1
0
BOOL CFlashInfoDlg::Create(CWnd* pParentWnd, CPoint ptWnd)
{
	if (!CDialog::Create(IDD, pParentWnd)) return FALSE;
	CRect	rectTemp;
	// Move window
	GetWindowRect(&rectTemp);
	rectTemp.MoveToXY(ptWnd);
	MoveWindow(&rectTemp);
	// Init controls
	ShowFlashInfo(NULL);
	// Show window
	ShowWindow(SW_SHOW);
	return TRUE;
}
Ejemplo n.º 2
0
bool show_info(void)
{
    struct flash_info fi;
    
    rb->lcd_clear_display();
    cfi_get_flash_info(&fi);
    ShowFlashInfo(&fi);
    if (fi.size == 0) /* no valid chip */
    {
        rb->splash(HZ*3, "Sorry!");
        return false; /* exit */
    }
    
    return true;
}
Ejemplo n.º 3
0
/* recorder version */
static void DoUserDialog(char* filename)
{
    tImageHeader ImageHeader;
    tFlashInfo FlashInfo;
    int button;
    int rc; /* generic return code */
    UINT32 space, aligned_size, true_size;
    UINT8* pos;
    size_t memleft;
    unsigned bl_version;
    bool show_greet = false;
    
    /* this can only work if Rockbox runs in DRAM, not flash ROM */
    if ((UINT8*)rb >= FB && (UINT8*)rb < FB + 4096*1024) /* 4 MB max */
    {   /* we're running from flash */
        rb->splash(HZ*3, "Not from ROM");
        return; /* exit */
    }

    /* refuse to work if the power may fail meanwhile */
    if (!rb->battery_level_safe())
    {
        rb->splash(HZ*3, "Battery too low!");
        return; /* exit */
    }
    
    /* "allocate" memory */
    sector = rb->plugin_get_buffer(&memleft);
    if (memleft < SECTORSIZE) /* need buffer for a flash sector */
    {
        rb->splash(HZ*3, "Out of memory");
        return; /* exit */
    }

    rb->lcd_setfont(FONT_SYSFIXED);

    pos = (void*)GetSecondImage();
    rc = GetFlashInfo(&FlashInfo);

    ShowFlashInfo(&FlashInfo, (void*)pos);
    rb->lcd_update();

    if (FlashInfo.size == 0) /* no valid chip */
    {
        rb->splash(HZ*3, "Not flashable");
        return; /* exit */
    }
    else if (pos == 0)
    {
        rb->splash(HZ*3, "No image");
        return; /* exit */
    }

    bl_version = BootloaderVersion();
    if (bl_version < LATEST_BOOTLOADER_VERSION)
    {
        rb->lcd_putsf(0, 0, "Bootloader V%d", bl_version);
        rb->lcd_puts(0, 1, "Hint: You're not  ");
        rb->lcd_puts(0, 2, "using the latest  ");
        rb->lcd_puts(0, 3, "bootloader.       ");
        rb->lcd_puts(0, 4, "A full reflash is ");
        rb->lcd_puts(0, 5, "recommended, but  ");
        rb->lcd_puts(0, 6, "not required.     ");
        rb->lcd_puts(0, 7, "Press " KEYNAME1 " to ignore");
        rb->lcd_update();

        if (WaitForButton() != KEY1)
        {
            return;
        }
        rb->lcd_clear_display();
    }
    
    rb->lcd_puts(0, show_greet ? 0 : 3, "Checking...");
    rb->lcd_update();

    space = FlashInfo.size - (pos-FB + sizeof(ImageHeader));
    /* size minus start */
    
    rc = CheckImageFile(filename, space, &ImageHeader, pos);
    if (rc != eOK)
    {
        rb->lcd_clear_display(); /* make room for error message */
        show_greet = true; /* verbose */
    }

    rb->lcd_puts(0, show_greet ? 0 : 3, "Checked:");
    switch (rc) {
        case eOK:
            rb->lcd_puts(0, show_greet ? 0 : 4, "File OK.");
            break;
    case eNotUCL:
            rb->lcd_puts(0, 1, "File not UCL ");
            rb->lcd_puts(0, 2, "compressed.");
            rb->lcd_puts(0, 3, "Use uclpack --2e");
            rb->lcd_puts(0, 4, " --10 rockbox.bin");
            break;
    case eWrongAlgorithm:
            rb->lcd_puts(0, 1, "Wrong algorithm");
            rb->lcd_puts(0, 2, "for compression.");
            rb->lcd_puts(0, 3, "Use uclpack --2e");
            rb->lcd_puts(0, 4, " --10 rockbox.bin");
            break;
    case eFileNotFound:
            rb->lcd_puts(0, 1, "File not found:");
            rb->lcd_puts_scroll(0, 2, filename);
            break;
    case eTooBig:
            rb->lcd_puts(0, 1, "File too big,");
            rb->lcd_puts(0, 2, "won't fit in chip.");
            break;
    case eTooSmall:
            rb->lcd_puts(0, 1, "File too small.");
            rb->lcd_puts(0, 2, "Incomplete?");
            break;
    case eReadErr:
            rb->lcd_puts(0, 1, "File read error.");
            break;
    case eMultiBlocks:
            rb->lcd_puts(0, 1, "File invalid.");
            rb->lcd_puts(0, 2, "Blocksize");
            rb->lcd_puts(0, 3, " too small?");
            break;
    case eBadRomLink:
            rb->lcd_puts(0, 1, "RomBox mismatch.");
            rb->lcd_puts(0, 2, "Wrong ROM position");
            break;
    default:
            rb->lcd_puts(0, 1, "Check failed.");
            break;
    }

    if (rc == eOK)
    {    /* was OK */
        rb->lcd_puts(0, 6, "[" KEYNAME2 "] to program");
        rb->lcd_puts(0, 7, "other key to exit");
    }
    else
    { /* error occured */
        rb->lcd_puts(0, 6, "Any key to exit");
    }
    rb->lcd_update();

    button = WaitForButton();
    if (rc != eOK || button != KEY2)
    {
        return;
    }
    
    true_size = ImageHeader.size;
    aligned_size = ((sizeof(tImageHeader) + true_size + SECTORSIZE-1) &
                    ~(SECTORSIZE-1)) - sizeof(tImageHeader); /* round up to
                                                                next flash
                                                                sector */
    ImageHeader.size = aligned_size; /* increase image size such that we reach
                                        the next sector */
    
    rb->lcd_clear_display();
    rb->lcd_puts_scroll(0, 0, "Programming...");
    rb->lcd_update();

    rc = ProgramImageFile(filename, pos, &ImageHeader, UCL_HEADER, true_size);
    if (rc)
    {   /* errors */
        rb->lcd_clear_display();
        rb->lcd_puts(0, 0, "Error:");
        rb->lcd_puts(0, 1, "Programming fail!");
        rb->lcd_putsf(0, 2, "%d errors", rc);
        rb->lcd_update();
        button = WaitForButton();
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts_scroll(0, 0, "Verifying...");
    rb->lcd_update();

    rc = VerifyImageFile(filename, pos, &ImageHeader, UCL_HEADER, true_size);

    rb->lcd_clear_display();
    if (rc == 0)
    {
        rb->lcd_puts(0, 0, "Verify OK.");
    }
    else
    {
        rb->lcd_puts(0, 0, "Error:");
        rb->lcd_puts(0, 1, "Verify fail!");
        rb->lcd_putsf(0, 2, "%d errors", rc);
        rb->lcd_puts(0, 3, "Use safe image");
        rb->lcd_puts(0, 4, "if booting hangs:");
        rb->lcd_puts(0, 5, "F1 during power-on");
    }
    rb->lcd_puts(0, 7, "Any key to exit");
    rb->lcd_update();
    WaitForButton();
}
Ejemplo n.º 4
0
void DoUserDialog(char* filename)
{
    tFlashInfo FlashInfo;
    char buf[32];
    char default_filename[32];
    int button;
    int rc; /* generic return code */
    size_t memleft;
    tCheckROM result;
    bool is_romless;

    /* this can only work if Rockbox runs in DRAM, not flash ROM */
    if ((UINT8*)rb >= FB && (UINT8*)rb < FB + 4096*1024) /* 4 MB max */
    {   /* we're running from flash */
        rb->splash(HZ*3, "Not from ROM");
        return; /* exit */
    }

    /* test if the user is running the correct plugin for this box */
    if (!CheckPlatform(PLATFORM_ID, *(UINT16*)(FB + VERSION_ADR)))
    {
        rb->splash(HZ*3, "Wrong version");
        return; /* exit */
    }

    /* refuse to work if the power may fail meanwhile */
    if (!rb->battery_level_safe())
    {
        rb->splash(HZ*3, "Batt. too low!");
        return; /* exit */
    }
    
    /* check boot ROM */
    result = CheckBootROM();
    if (result == eUnknown)
    {   /* no support for any other yet */
        rb->splash(HZ*3, "Wrong boot ROM");
        return; /* exit */
    }
    is_romless = (result == eROMless);

    /* compose filename if none given */
    if (filename == NULL)
    {
        rb->snprintf(
            default_filename, 
            sizeof(default_filename),
            "/firmware_%s%s.bin",
            FILE_TYPE,
            is_romless ? "_norom" : "");
        filename = default_filename;
    }

    /* "allocate" memory */
    sector = rb->plugin_get_buffer(&memleft);
    if (memleft < SEC_SIZE) /* need buffer for a flash sector */
    {
        rb->splash(HZ*3, "Out of memory");
        return; /* exit */
    }

    rc = GetFlashInfo(&FlashInfo);
    ShowFlashInfo(&FlashInfo);
    
    if (FlashInfo.size == 0) /* no valid chip */
    {
        return; /* exit */
    }
    
    rb->lcd_puts_scroll(0, 0, filename);
    rb->lcd_puts_scroll(0, 1, "[Menu] to check");
    rb->lcd_update();

    button = WaitForButton();
    if (button != BUTTON_MENU)
    {
        return;
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts(0, 0, "Checking...");
    rb->lcd_update();

    rc = CheckFirmwareFile(filename, FlashInfo.size, is_romless);
    rb->lcd_puts(0, 0, "Checked:");
    switch (rc)
    {
    case eOK:
        rb->lcd_puts(0, 1, "File OK.");
        break;
    case eFileNotFound:
        rb->lcd_puts_scroll(0, 0, "File not found:");
        rb->lcd_puts_scroll(0, 1, filename);
        break;
    case eTooBig:
        rb->lcd_puts_scroll(0, 0, "File too big,");
        rb->lcd_puts_scroll(0, 1, "larger than chip.");
        break;
    case eTooSmall:
        rb->lcd_puts_scroll(0, 0, "File too small.");
        rb->lcd_puts_scroll(0, 1, "Incomplete?");
        break;
    case eReadErr:
        rb->lcd_puts_scroll(0, 0, "Read error.");
        break;
    case eBadContent:
        rb->lcd_puts_scroll(0, 0, "File invalid.");
        rb->lcd_puts_scroll(0, 1, "Sanity check failed.");
        break;
    case eCrcErr:
        rb->lcd_puts_scroll(0, 0, "File invalid.");
        rb->lcd_puts_scroll(0, 1, "CRC check failed.");
        break;
    case eBadPlatform:
        rb->lcd_puts_scroll(0, 0, "Wrong file for");
        rb->lcd_puts_scroll(0, 1, "this hardware.");
        break;
    default:
        rb->lcd_puts_scroll(0, 0, "Check failed.");
        break;
    }
    rb->lcd_update();

    rb->sleep(HZ*3);

    if (rc == eOK)
    {
        rb->lcd_puts_scroll(0, 0, "[On] to program,");
        rb->lcd_puts_scroll(0, 1, "other key to exit.");
        rb->lcd_update();
    }
    else
    {   /* error occured */
        return;
    }
    
    button = WaitForButton();

    if (button != BUTTON_ON)
    {
        return;
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts_scroll(0, 0, "Are you sure?");
    rb->lcd_puts_scroll(0, 1, "[+] to proceed.");
    rb->lcd_update();

    button = WaitForButton();
    
    if (button != BUTTON_RIGHT)
    {
        return;
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts_scroll(0, 0, "Programming...");
    rb->lcd_update();

    rc = ProgramFirmwareFile(filename, FlashInfo.size);
    
    if (rc)
    {   /* errors */
        rb->lcd_clear_display();
        rb->lcd_puts_scroll(0, 0, "Programming failed!");
        rb->snprintf(buf, sizeof(buf), "%d errors", rc);
        rb->lcd_puts_scroll(0, 1, buf);
        rb->lcd_update();
        WaitForButton();
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts_scroll(0, 0, "Verifying...");
    rb->lcd_update();

    rc = VerifyFirmwareFile(filename);
    
    rb->lcd_clear_display();
    
    if (rc == 0)
    {
        rb->lcd_puts_scroll(0, 0, "Verify OK.");
    }
    else
    {
        rb->snprintf(buf, sizeof(buf), "Verify failed! %d errors", rc);
        rb->lcd_puts_scroll(0, 0, buf);
    }

    rb->lcd_puts_scroll(0, 1, "Press any key to exit.");
    rb->lcd_update();
    WaitForButton();
}