PPCGeeks Forums HTC Arrive HTC HD2 HTC Thunderbolt HTC Touch Pro 2 HTC Evo 4G HTC Evo 3D Samsung Galaxy S II Motorola Droid X Apple iPhone Blackberry
Go Back   PPCGeeks > Windows Mobile > WM HTC Devices > HTC Touch Pro 2 > Android On TP2 > Android On TP2 Development
Register Community Search

Notices


 
 
LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9 (permalink)  
Old 02-24-2012, 12:59 AM
muziling's Avatar
PPCGeeks Regular
Offline
Pocket PC: HTC Touch Pro 2(RHOD400)
Carrier: CDMA
 
Join Date: Nov 2010
Posts: 175
Reputation: 55
muziling is becoming a great contributor
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: [TESTING] - NAND OMGB (1.2.3)

Finally, easy to prevent erase or overwrite protected partition

platform/msm_shared/nand.c
Code:
int flash_erase(struct ptentry *ptn)
{
    unsigned block = ptn->start;
    unsigned count = ptn->length;

    if (ptn->perm == PERM_NON_WRITEABLE) {
        dprintf(INFO, "%s partition is protected, can't be erased.\n", ptn->name);
        return -1;
    }

    set_nand_configuration(ptn->type);
    while(count-- > 0) {
        if(flash_erase_block(flash_cmdlist, flash_ptrlist, block * 64)) {
            dprintf(INFO, "cannot erase @ %d (bad block?)\n", block);
        }
        block++;
    }
    return 0;
}

int flash_write(struct ptentry *ptn, unsigned extra_per_page, const void *data,
        unsigned bytes)
{
    unsigned page = ptn->start * 64;
    unsigned lastpage = (ptn->start + ptn->length) * 64;
    unsigned *spare = (unsigned*) flash_spare;
    const unsigned char *image = data;
    unsigned wsize = flash_pagesize + extra_per_page;
    unsigned n;
    int r;

    if (ptn->type == TYPE_MODEM_PARTITION)
    {
        dprintf(CRITICAL, "flash_write_image: model partition not supported\n");
        return -1;
    }

    if (ptn->perm == PERM_NON_WRITEABLE) {
        dprintf(INFO, "%s partition is protected, can't be overwrited.\n", ptn->name);
        return -1;
    }
Tested pass:
Quote:
E:\adb-tool>Fastboot flash TPCAL x:\cal.raw
sending 'TPCAL' (128 KB)... OKAY [ 0.110s]
writing 'TPCAL'... FAILED (remote: flash write failure)
finished. total time: 0.345s

E:\adb-tool>Fastboot erase TPCAL
erasing 'TPCAL'... FAILED (remote: failed to erase partition)
finished. total time: 0.692s

Last edited by muziling; 02-24-2012 at 01:41 AM.
Reply With Quote
 

  PPCGeeks > Windows Mobile > WM HTC Devices > HTC Touch Pro 2 > Android On TP2 > Android On TP2 Development


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 03:41 PM.


Powered by vBulletin® ©2000 - 2026, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0
©2012 - PPCGeeks.com