Exemplo n.º 1
0
BOOL CMonitorService::CheckMemory()
{
	UINT	nTotal, nUse, nFree, nCache, nBuffer;
	UINT	nFlashTotal=0, nFlashUse, nFlashFree;
	double	fSize, fFlashSize;
    BOOL    bReturn = TRUE;

	GetMemoryInfo(&nTotal, &nUse, &nFree, &nCache, &nBuffer);
	
#if defined(__TI_AM335X__)
    /** TI Multi boot 를 위해 두가지 검사를 한다.
      * SPI boot일 경우 /dev/root 를 검사하고
      * NAND boot일 경우에는 ubi1:rootfs 를 검사해야 한다
      */
	GetFlashInfo("/dev/root", &nFlashTotal, &nFlashUse, &nFlashFree);
    if(nFlashTotal <= 0)
    {
	    GetFlashInfo("ubi1:rootfs", &nFlashTotal, &nFlashUse, &nFlashFree);
    }    
    
#endif
	fSize = (double)nFree / (double)(1024*1024);
	fFlashSize = (double)nFlashFree / (double)(1024*1024);

	if (nFlashFree < (100*1024)) bReturn = FALSE;
	if (nFree < (5000*1024)) bReturn = FALSE;

    if(!bReturn) {
	    printf("Memory [Share] Total=%d, Use=%d, Free=%d(%.2fM)\r\n", nTotal, nUse, nFree, fSize);
	    printf("        [root] Total=%d, Use=%d, Free=%d(%.2fM)\r\n", nFlashTotal, nFlashUse, nFlashFree, fFlashSize);
    }

	return bReturn;
}
Exemplo n.º 2
0
int main(void)
{

	// open the device
	AFP_Error = ADIM29W64DEntryPoint.adi_pdd_Open(	NULL,		// DevMgr handle
							0,				// pdd entry point
							NULL,			// device instance
							NULL,			// client handle callback identifier
				  			ADI_DEV_DIRECTION_BIDIRECTIONAL,// data direction for this device
							NULL,			// DevMgr handle for this device
							NULL,			// handle to DmaMgr for this device
							NULL,			// handle to deferred callback service
							NULL );			// client's callback function

	// setup the device so the DSP can access it
	if (SetupForFlash() != NO_ERR)
		return FALSE;

	// allocate AFP_Buffer
	if (( AFP_Error = AllocateAFPBuffer()) != NO_ERR)
		return FALSE;

	// get sector map
	if (( AFP_Error = GetSectorMap())!= NO_ERR)
		return FALSE;

	// get flash manufacturer & device codes, title & desc
	if (( AFP_Error = GetFlashInfo()) != NO_ERR)
		return FALSE;

	// command processing loop
	while ( !bExit )
	{
		// the plug-in will set a breakpoint at "AFP_BreakReady" so it knows
		// when we are ready for a new command because the DSP will halt
		//
		// the jump is used so that the label will be part of the debug
		// information in the driver image otherwise it may be left out
 		// since the label is not referenced anywhere
		asm("AFP_BreakReady:");
       		asm("nop;");
			if ( FALSE )
				asm("jump AFP_BreakReady;");

		// Make a call to the ProcessCommand
		   AFP_Error = ProcessCommand();
	}

	//Clear the AFP_Buffer
	FreeAFPBuffer();

	//Close the Device
	AFP_Error = ADIM29W64DEntryPoint.adi_pdd_Close(NULL);

	return TRUE;
}
Exemplo n.º 3
0
BOOL CMonitorService::CheckFlash()
{
	UINT	nTotal, nUse, nFree;
	double	fSize;
    BOOL    bReturn;

	#if defined(__TI_AM335X__)
	GetFlashInfo("ubi0:filestore", &nTotal, &nUse, &nFree);
#endif
	fSize = (double)nFree / (double)(1024*1024);
	bReturn = (nFree < (200*1024)) ? FALSE : TRUE;

    if(!bReturn) {
	    printf("Flash : Total=%d, Use=%d, Free=%d(%.2fM)\r\n", nTotal, nUse, nFree, fSize);
    }
    return bReturn;
}
int main(void)
{

    SECTORLOCATION *pSectorInfo;
    ERROR_CODE Result;							// result

    /* open flash driver */
    AFP_Error = m25p16_Open();

    // setup the device so the DSP can access it
    if (SetupForFlash() != NO_ERR)
        return FALSE;

    // get flash manufacturer & device codes, title & desc
    if( AFP_Error == NO_ERR )
    {
        AFP_Error = GetFlashInfo();
    }

    // get the number of sectors for this device
    if( AFP_Error == NO_ERR )
    {
        AFP_Error = GetNumSectors();
    }

    if( AFP_Error == NO_ERR )
    {
        // malloc enough space to hold our start and end offsets
        pSectorInfo = (SECTORLOCATION *)malloc(AFP_NumSectors * sizeof(SECTORLOCATION));
    }

    // allocate AFP_Buffer
    if( AFP_Error == NO_ERR )
    {
        AFP_Error = AllocateAFPBuffer();
    }

    // get sector map
    if( AFP_Error == NO_ERR )
    {
        AFP_Error = GetSectorMap(pSectorInfo);
    }

    // point AFP_SectorInfo to our sector info structure
    if( AFP_Error == NO_ERR )
    {
        AFP_SectorInfo = (int*)pSectorInfo;
    }

    // command processing loop
    while ( !bExit )
    {
        // the plug-in will set a breakpoint at "AFP_BreakReady" so it knows
        // when we are ready for a new command because the DSP will halt
        //
        // the jump is used so that the label will be part of the debug
        // information in the driver image otherwise it may be left out
        // since the label is not referenced anywhere
        asm("AFP_BreakReady:");
        asm("nop;");
        if ( FALSE )
            asm("jump AFP_BreakReady;");

        // Make a call to the ProcessCommand
        AFP_Error = ProcessCommand();
    }

    // Clear the AFP_Buffer
    FreeAFPBuffer();

    if( pSectorInfo )
    {
        free(pSectorInfo);
        pSectorInfo = NULL;
    }

    // Close the Device
    AFP_Error = m25p16_Close();

    if (AFP_Error != NO_ERR)
        return FALSE;

    return TRUE;
}
Exemplo n.º 5
0
/* Player version */
static void DoUserDialog(char* filename)
{
    tImageHeader ImageHeader;
    tFlashInfo FlashInfo;
    static char buf[MAX_PATH];
    int button;
    int rc; /* generic return code */
    UINT32 space, aligned_size, true_size;
    UINT8* pos;
    size_t memleft;
    unsigned bl_version;

    /* 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, "Batt. 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 */
    }

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

    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_puts_scroll(0, 0, "Hint: You're not using the latest bootloader. A full reflash is recommended, but not required.");
        rb->lcd_puts_scroll(0, 1, "Press [Menu] to ignore");
        rb->lcd_update();

        if (WaitForButton() != BUTTON_MENU)
        {
            return;
        }
        rb->lcd_clear_display();
    }

    rb->lcd_puts(0, 0, "Checking...");
    rb->lcd_update();

    space = FlashInfo.size - (pos-FB + sizeof(ImageHeader));
    /* size minus start */
    
    rc = CheckImageFile(filename, space, &ImageHeader, pos);
    rb->lcd_puts(0, 0, "Checked:");
    switch (rc) {
        case eOK:
            rb->lcd_puts(0, 1, "File OK.");
            rb->sleep(HZ*1);
            break;
    case eNotUCL:
            rb->lcd_puts_scroll(0, 1, "File not UCL compressed.");
            break;
    case eWrongAlgorithm:
            rb->lcd_puts_scroll(0, 1, "Wrong compression algorithm.");
            break;
    case eFileNotFound:
            rb->lcd_puts_scroll(0, 1, "File not found.");
            break;
    case eTooBig:
            rb->lcd_puts_scroll(0, 1, "File too big.");
            break;
    case eTooSmall:
            rb->lcd_puts_scroll(0, 1, "File too small. Incomplete?");
            break;
    case eReadErr:
            rb->lcd_puts_scroll(0, 1, "File read error.");
            break;
    case eMultiBlocks:
            rb->lcd_puts_scroll(0, 1, "File invalid. Blocksize too small?");
            break;
    case eBadRomLink:
            rb->lcd_puts_scroll(0, 1, "RomBox mismatch.");
            break;
    default:
            rb->lcd_puts_scroll(0, 1, "Check failed.");
            break;
    }
    rb->lcd_update();

    if (rc == eOK)
    {    /* was OK */
        rb->lcd_clear_display();
        rb->lcd_puts_scroll(0, 0, "[ON] to program,");
        rb->lcd_puts_scroll(0, 1, "other key to exit.");
    }
    else
    { /* error occured */
        WaitForButton();
        rb->lcd_clear_display();
        rb->lcd_puts_scroll(0, 0, "Flash failed.");
        rb->lcd_puts_scroll(0, 1, "Any key to exit.");
    }
    rb->lcd_update();

    button = WaitForButton();
    if (rc != eOK || button != BUTTON_ON)
    {
        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->snprintf(buf, sizeof(buf), "%d errors", rc);
        rb->lcd_puts_scroll(0, 0, "Programming failed!");
        rb->lcd_puts_scroll(0, 1, buf);
        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.");
        rb->lcd_update();
    }
    else
    {
        rb->snprintf(buf, sizeof(buf), "Verify fail! %d errors", rc);
        rb->lcd_puts_scroll(0, 0, buf);
        rb->lcd_puts_scroll(0, 1, "Use safe image if booting hangs: [-] during power-on");
        rb->lcd_update();
        button = WaitForButton();
    }
}
Exemplo n.º 6
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();
}
Exemplo n.º 7
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();
}