Changeset 12376

Show
Ignore:
Timestamp:
06/25/2009 02:32:50 PM (5 months ago)
Author:
BrainSlayer
Message:

merge partition code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade.c

    r12368 r12376  
    6060 
    6161extern void fis_init(int argc, char *argv[], int force); 
     62 
     63void addPartition(char *name, unsigned int flashbase, unsigned int memaddr, 
     64                  unsigned int entryaddr, unsigned int partsize, 
     65                  unsigned int datasize) 
     66{ 
     67        int index; 
     68        struct fis_image_desc *img = (struct fis_image_desc *)fis_work_block; 
     69        for (index = 0; index < fisdir_size / sizeof(*img); index++, img++) { 
     70                if (img->name[0] == (unsigned char)0xFF) { 
     71                        break; 
     72                } 
     73        } 
     74        strcpy(img->name, name); 
     75        img->flash_base = flashbase; 
     76        img->mem_base = memaddr; 
     77        img->entry_point = entryaddr;   // Hope it's been set 
     78        img->size = partsize; 
     79        img->data_length = datasize; 
     80} 
    6281 
    6382int fw_check_image_ddwrt(unsigned char *addr, unsigned long maxlen, 
     
    125144                        return -1; 
    126145                } 
    127                 img = fis_lookup("linux", &i); 
    128                 if (!img) { 
    129                         img = (struct fis_image_desc *)fis_work_block; 
    130                         for (i = 0; i < fisdir_size / sizeof(*img); i++, img++) { 
    131                                 if (img->name[0] == (unsigned char)0xFF) { 
    132                                         break; 
    133                                 } 
    134                         } 
    135                         memset(img, 0, sizeof(*img)); 
    136                         strcpy(img->name, "linux"); 
    137                 } 
    138                 img->flash_base = flash_addr; 
    139                 img->mem_base = 0x80041000; 
    140                 img->entry_point = 0x80041000;  // Hope it's been set 
    141                 img->size = trx.len; 
    142                 img->data_length = trx.len; 
     146                addPartition("linux", flash_addr, 0x80041000, 0x80041000, 
     147                             trx.len, trx.len); 
    143148                fis_update_directory(); 
    144149                diag_printf("DD-WRT_FW: flashing done\n"); 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade.h

    r12370 r12376  
    1111                               int do_flash); 
    1212extern int fw_check_image_senao(unsigned char *addr, unsigned long maxlen, 
    13                                int do_flash); 
     13                               int do_flash); 
    1414 
    1515#define MAX_IMAGE_SIZE          0x7E0000        /* 4mb - 64k */ 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_senao.c

    r12372 r12376  
    2424#define TRACE 
    2525 
     26extern void addPartition(char *name, unsigned int flashbase, 
     27                         unsigned int memaddr, unsigned int entryaddr, 
     28                         unsigned int partsize, unsigned int datasize); 
    2629 
    2730extern void fis_init(int argc, char *argv[], int force); 
     
    3033                         int do_flash) 
    3134{ 
    32         unsigned char *base = (unsigned char *)addr+10; 
    33         if (strncmp(addr,"AP51-3660",9)) { 
     35        unsigned char *base = (unsigned char *)addr + 10; 
     36        if (strncmp(addr, "AP51-3660", 9)) { 
    3437                diag_printf("SENAO_FW: bad header\n"); 
    3538                return -1; 
     
    3740 
    3841        if (do_flash) { 
    39                 maxlen-=10; 
     42                maxlen -= 10; 
    4043                char *arg[] = { "fis", "init" }; 
    4144                fis_init(2, arg, 1); 
     
    6972                } 
    7073                img = (struct fis_image_desc *)fis_work_block; 
    71                         for (i = 0; i < fisdir_size / sizeof(*img); i++, img++) { 
    72                                 if (img->name[0] == (unsigned char)0xFF) { 
    73                                         break; 
    74                                 } 
     74                for (i = 0; i < fisdir_size / sizeof(*img); i++, img++) { 
     75                        if (img->name[0] == (unsigned char)0xFF) { 
     76                                break; 
    7577                        } 
    76                          
     78                } 
     79 
    7780                unsigned int filesyssize = 0x3f0000; 
    7881                unsigned int linuxsize = 0xa0000; 
    7982                unsigned int cfgsize = 0x20000; 
    8083                unsigned int exec = 0x80041798; 
    81                 if (maxlen==(3670026-10)) // detect 4M images (EAP3660 etc.) 
    82                     { 
    83                     filesyssize = 0x2f0000; 
    84                     exec = 0x80170040; //weired entrypoint 
    85                     } 
    86                 strcpy(img->name, "rootfs"); 
    87                 img->flash_base = flash_addr; 
    88                 img->mem_base = 0x80041000; 
    89                 img->entry_point = 0; 
    90                 img->size = filesyssize; 
    91                 img->data_length = filesyssize; 
    92                 img++; 
    93                 strcpy(img->name, "vmlinux.bin.l7"); 
    94                 img->flash_base = flash_addr+filesyssize; 
    95                 img->mem_base = 0x80041000; 
    96                 img->entry_point = exec; 
    97                 img->size = linuxsize; 
    98                 img->data_length = linuxsize; 
    99                 img++; 
    100                 strcpy(img->name, "cfg"); 
    101                 img->flash_base = flash_addr+filesyssize+linuxsize; 
    102                 img->mem_base = 0x80041000; 
    103                 img->entry_point = 0; 
    104                 img->size = cfgsize; 
    105                 img->data_length = cfgsize; 
    106                  
     84                if (maxlen == (3670026 - 10))   // detect 4M images (EAP3660 etc.) 
     85                { 
     86                        filesyssize = 0x2f0000; 
     87                        exec = 0x80170040;      //weired entrypoint 
     88                } 
     89                addPartition("rootfs", flash_addr, 0x80041000, 0, filesyssize, 
     90                             filesyssize); 
     91                addPartition("vmlinux.bin.l7", flash_addr + filesyssize, 
     92                             0x80041000, exec, linuxsize, linuxsize); 
     93                addPartition("cfg", flash_addr + filesyssize + linuxsize, 
     94                             0x80041000, 0, cfgsize, cfgsize); 
    10795                fis_update_directory(); 
    10896                diag_printf("SENAO_FW: flashing done\n"); 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_ubnt.c

    r12368 r12376  
    4242        int part_count; 
    4343} fw_t; 
     44 
     45extern void addPartition(char *name, unsigned int flashbase, 
     46                         unsigned int memaddr, unsigned int entryaddr, 
     47                         unsigned int partsize, unsigned int datasize); 
    4448 
    4549#define crc32 cyg_ether_crc32_accumulate 
     
    175179                                return -1; 
    176180                        } 
    177                         int index; 
    178                         img = (struct fis_image_desc *)fis_work_block; 
    179                         for (index = 0; 
    180                              index < fisdir_size / sizeof(*img); 
    181                              index++, img++) { 
    182                                 if (img->name[0] == (unsigned char)0xFF) { 
    183                                         break; 
    184                                 } 
    185                         } 
    186                         strcpy(img->name, fwp->header->name); 
    187                         img->flash_base = base; 
    188                         img->mem_base = ntohl(fwp->header->memaddr); 
    189                         img->entry_point = ntohl(fwp->header->entryaddr);       // Hope it's been set 
    190                         img->size = ntohl(fwp->header->part_size); 
    191                         img->data_length = ntohl(fwp->header->data_size); 
     181                        addPartition(fwp->header->name, base, 
     182                                     ntohl(fwp->header->memaddr), 
     183                                     ntohl(fwp->header->entryaddr), 
     184                                     ntohl(fwp->header->part_size), 
     185                                     ntohl(fwp->header->data_size)); 
     186                } 
     187                addPartition("cfg", (flash_end + 1) - (flash_block_size * 3), 0, 
     188                             0, 0x10000, 0x10000); 
    192189 
    193                 } 
    194190                fis_update_directory(); 
    195191                diag_printf("UBNT_FW: flashing done\n"); 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_client.c

    r12368 r12376  
    223223                                if (ntohs(hdr->th_opcode) == DATA) { 
    224224                                        if (ntohs(hdr->th_block) == 
    225                                             (cyg_uint16) ((tftp_stream.last_good_block + 1) & 0xFFFF)) { 
     225                                            (cyg_uint16) ((tftp_stream. 
     226                                                           last_good_block + 
     227                                                           1) & 0xFFFF)) { 
    226228                                                // Consume this data 
    227229                                                data_len -= 4;  /* Sizeof TFTP header */ 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_server.c

    r12370 r12376  
    286286                                issenao = 
    287287                                    fw_check_image_senao((char *)BASE_ADDR, 
    288                                                         ptr - BASE_ADDR, 
    289                                                         0) == 0; 
     288                                                        ptr - BASE_ADDR, 
     289                                                        0) == 0; 
    290290 
    291291                        if (isddwrt || isubnt || iswili || issenao)     /* third parameter 0 - do not write to flash */ 
     
    317317                        } 
    318318                        if (issenao) { 
    319                                 diag_printf 
    320                                     ("SENAO firmware format detected\n"); 
     319                                diag_printf("SENAO firmware format detected\n"); 
    321320                                do_flash_update_senao(BASE_ADDR, 
    322                                                      ptr - BASE_ADDR); 
     321                                                      ptr - BASE_ADDR); 
    323322                        } 
    324323#else