Changeset 12321


Ignore:
Timestamp:
06/19/09 15:16:14 (4 years ago)
Author:
BrainSlayer
Message:

AR5312/AR2313: nor flash support for erasing nvram on reset button long push (untested)

Location:
ar5315_microredboot/microredboot
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ar5315_microredboot/microredboot/CHANGELOG

    r12320 r12321  
    1119.6.09 
     2    * AR5312/AR2313: nor flash support for erasing nvram on reset button long push (untested) 
    23    * AR5312/AR2313: add support for 32MB ram chips (auto detection) 
    34    * most nor flash chips should be supported, but no guarantee. redboot will display the required ID's for implementation 
  • ar5315_microredboot/microredboot/boot/src/Makefile

    r12319 r12321  
    108108                sed "$(SEDFLAGS)" < ld.script.in > $@ 
    109109 
    110 clean:;         rm -f payload* ld.script *.o lib/*.o 
     110clean:;         rm -f payload* ld.script *.o *.c~ *.h~ lib/*.o 
    111111 
    112112.PHONY: clean 
  • ar5315_microredboot/microredboot/boot/src/misc_lzma.c

    r12320 r12321  
    651651                return; 
    652652        } 
    653         printf("erasing nvram at [0x%08X]\n", flashbase + nvramdetect); 
     653        printf("erasing nvram at [0x%08X]\n", nvramdetect); 
    654654 
    655655        ptr_opcode = &stm_opcodes[SPI_SECTOR_ERASE]; 
     
    698698 
    699699} 
     700#else 
     701 
     702static int flash_erase_nvram(unsigned int flashsize, unsigned int blocksize) 
     703{ 
     704        int i, ticks; 
     705        unsigned short val; 
     706        if (!nvramdetect) { 
     707                puts("nvram can and will not erased, since nvram was not detected on this device (maybe dd-wrt isnt installed)!\n"); 
     708                return; 
     709        } 
     710        printf("erasing nvram at [0x%08X]\n", nvramdetect); 
     711        volatile unsigned short *block = (unsigned short *)nvramdetect; 
     712        volatile unsigned short *p555 = 
     713            (unsigned short *)((unsigned long)flashbase + 0x0aaa); 
     714        volatile unsigned short *p2aa = 
     715            (unsigned short *)((unsigned long)flashbase + 0x0554); 
     716 
     717        *block = 0xf0;          /* Make sure in read state */ 
     718        *p555 = 0xaa; 
     719        *p2aa = 0x55; 
     720        *p555 = 0x80; 
     721        *p555 = 0xaa; 
     722        *p2aa = 0x55; 
     723        *block = 0x30; 
     724        for (ticks = 0, i = 0;; i++) { 
     725                val = *block; 
     726 
     727                /* When Erase operation is completed, DQ7 will produce 1 "1". 
     728                   and  DQ6 stops toggling. */ 
     729                if ((val & 0x80) == 0x80) { 
     730 
     731                        // Check DQ6 toggle 
     732                        unsigned short s_val; 
     733 
     734                        // Read the second time. 
     735                        s_val = *block; 
     736                        if ((s_val & 0x80) && (s_val & 0x40) == (val & 0x40)) { 
     737                                *block = 0xf0;  /* Do reset */ 
     738                                puts("erase successfull!\n"); 
     739                                return 0; 
     740                        } 
     741                } 
     742 
     743                else { 
     744                        if (i >= 1024) { 
     745                                i = 0; 
     746                                if (++ticks > 7 * 100 * 10) { 
     747                                        break; 
     748                                } 
     749                        } 
     750                } 
     751        } 
     752        *block = 0xf0;          /* Do reset */ 
     753        puts("erase failed!\n"); 
     754        return -1; 
     755} 
     756 
    700757#endif 
    701758struct nvram_header { 
     
    795852        if (resetTouched() || (resetbutton && !strcmp(resetbutton, "1"))) { 
    796853                puts("Reset Button triggered\nBooting Recovery RedBoot\n"); 
    797 #ifndef AR5312 
     854 
    798855                int count = 5; 
    799856                while (count--) { 
     
    804861                if (count <= 0) { 
    805862                        puts("reset button 5 seconds pushed, erasing nvram\n"); 
     863 
     864#ifndef AR5312 
    806865                        if (!flashdetect()) 
     866#endif 
    807867                                flash_erase_nvram(flashsize, sectorsize); 
    808868                } 
    809 #endif 
    810869 
    811870                bootoffset = 0x800004bc; 
Note: See TracChangeset for help on using the changeset viewer.