View Single Post
  #1322 (permalink)  
Old 02-24-2012, 12:59 AM
muziling's Avatar
muziling
PPCGeeks Regular
Offline
 
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