Index: /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_server.c =================================================================== --- /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_server.c (revision 12370) +++ /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_server.c (revision 12376) @@ -286,6 +286,6 @@ issenao = fw_check_image_senao((char *)BASE_ADDR, - ptr - BASE_ADDR, - 0) == 0; + ptr - BASE_ADDR, + 0) == 0; if (isddwrt || isubnt || iswili || issenao) /* third parameter 0 - do not write to flash */ @@ -317,8 +317,7 @@ } if (issenao) { - diag_printf - ("SENAO firmware format detected\n"); + diag_printf("SENAO firmware format detected\n"); do_flash_update_senao(BASE_ADDR, - ptr - BASE_ADDR); + ptr - BASE_ADDR); } #else Index: /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_senao.c =================================================================== --- /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_senao.c (revision 12372) +++ /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_senao.c (revision 12376) @@ -24,4 +24,7 @@ #define TRACE +extern void addPartition(char *name, unsigned int flashbase, + unsigned int memaddr, unsigned int entryaddr, + unsigned int partsize, unsigned int datasize); extern void fis_init(int argc, char *argv[], int force); @@ -30,6 +33,6 @@ int do_flash) { - unsigned char *base = (unsigned char *)addr+10; - if (strncmp(addr,"AP51-3660",9)) { + unsigned char *base = (unsigned char *)addr + 10; + if (strncmp(addr, "AP51-3660", 9)) { diag_printf("SENAO_FW: bad header\n"); return -1; @@ -37,5 +40,5 @@ if (do_flash) { - maxlen-=10; + maxlen -= 10; char *arg[] = { "fis", "init" }; fis_init(2, arg, 1); @@ -69,40 +72,25 @@ } img = (struct fis_image_desc *)fis_work_block; - for (i = 0; i < fisdir_size / sizeof(*img); i++, img++) { - if (img->name[0] == (unsigned char)0xFF) { - break; - } + for (i = 0; i < fisdir_size / sizeof(*img); i++, img++) { + if (img->name[0] == (unsigned char)0xFF) { + break; } - + } + unsigned int filesyssize = 0x3f0000; unsigned int linuxsize = 0xa0000; unsigned int cfgsize = 0x20000; unsigned int exec = 0x80041798; - if (maxlen==(3670026-10)) // detect 4M images (EAP3660 etc.) - { - filesyssize = 0x2f0000; - exec = 0x80170040; //weired entrypoint - } - strcpy(img->name, "rootfs"); - img->flash_base = flash_addr; - img->mem_base = 0x80041000; - img->entry_point = 0; - img->size = filesyssize; - img->data_length = filesyssize; - img++; - strcpy(img->name, "vmlinux.bin.l7"); - img->flash_base = flash_addr+filesyssize; - img->mem_base = 0x80041000; - img->entry_point = exec; - img->size = linuxsize; - img->data_length = linuxsize; - img++; - strcpy(img->name, "cfg"); - img->flash_base = flash_addr+filesyssize+linuxsize; - img->mem_base = 0x80041000; - img->entry_point = 0; - img->size = cfgsize; - img->data_length = cfgsize; - + if (maxlen == (3670026 - 10)) // detect 4M images (EAP3660 etc.) + { + filesyssize = 0x2f0000; + exec = 0x80170040; //weired entrypoint + } + addPartition("rootfs", flash_addr, 0x80041000, 0, filesyssize, + filesyssize); + addPartition("vmlinux.bin.l7", flash_addr + filesyssize, + 0x80041000, exec, linuxsize, linuxsize); + addPartition("cfg", flash_addr + filesyssize + linuxsize, + 0x80041000, 0, cfgsize, cfgsize); fis_update_directory(); diag_printf("SENAO_FW: flashing done\n"); Index: /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_client.c =================================================================== --- /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_client.c (revision 12368) +++ /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/tftp_client.c (revision 12376) @@ -223,5 +223,7 @@ if (ntohs(hdr->th_opcode) == DATA) { if (ntohs(hdr->th_block) == - (cyg_uint16) ((tftp_stream.last_good_block + 1) & 0xFFFF)) { + (cyg_uint16) ((tftp_stream. + last_good_block + + 1) & 0xFFFF)) { // Consume this data data_len -= 4; /* Sizeof TFTP header */ Index: /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_ubnt.c =================================================================== --- /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_ubnt.c (revision 12368) +++ /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade_ubnt.c (revision 12376) @@ -42,4 +42,8 @@ int part_count; } fw_t; + +extern void addPartition(char *name, unsigned int flashbase, + unsigned int memaddr, unsigned int entryaddr, + unsigned int partsize, unsigned int datasize); #define crc32 cyg_ether_crc32_accumulate @@ -175,21 +179,13 @@ return -1; } - int index; - img = (struct fis_image_desc *)fis_work_block; - for (index = 0; - index < fisdir_size / sizeof(*img); - index++, img++) { - if (img->name[0] == (unsigned char)0xFF) { - break; - } - } - strcpy(img->name, fwp->header->name); - img->flash_base = base; - img->mem_base = ntohl(fwp->header->memaddr); - img->entry_point = ntohl(fwp->header->entryaddr); // Hope it's been set - img->size = ntohl(fwp->header->part_size); - img->data_length = ntohl(fwp->header->data_size); + addPartition(fwp->header->name, base, + ntohl(fwp->header->memaddr), + ntohl(fwp->header->entryaddr), + ntohl(fwp->header->part_size), + ntohl(fwp->header->data_size)); + } + addPartition("cfg", (flash_end + 1) - (flash_block_size * 3), 0, + 0, 0x10000, 0x10000); - } fis_update_directory(); diag_printf("UBNT_FW: flashing done\n"); Index: /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade.c =================================================================== --- /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade.c (revision 12368) +++ /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade.c (revision 12376) @@ -60,4 +60,23 @@ extern void fis_init(int argc, char *argv[], int force); + +void addPartition(char *name, unsigned int flashbase, unsigned int memaddr, + unsigned int entryaddr, unsigned int partsize, + unsigned int datasize) +{ + int index; + struct fis_image_desc *img = (struct fis_image_desc *)fis_work_block; + for (index = 0; index < fisdir_size / sizeof(*img); index++, img++) { + if (img->name[0] == (unsigned char)0xFF) { + break; + } + } + strcpy(img->name, name); + img->flash_base = flashbase; + img->mem_base = memaddr; + img->entry_point = entryaddr; // Hope it's been set + img->size = partsize; + img->data_length = datasize; +} int fw_check_image_ddwrt(unsigned char *addr, unsigned long maxlen, @@ -125,20 +144,6 @@ return -1; } - img = fis_lookup("linux", &i); - if (!img) { - img = (struct fis_image_desc *)fis_work_block; - for (i = 0; i < fisdir_size / sizeof(*img); i++, img++) { - if (img->name[0] == (unsigned char)0xFF) { - break; - } - } - memset(img, 0, sizeof(*img)); - strcpy(img->name, "linux"); - } - img->flash_base = flash_addr; - img->mem_base = 0x80041000; - img->entry_point = 0x80041000; // Hope it's been set - img->size = trx.len; - img->data_length = trx.len; + addPartition("linux", flash_addr, 0x80041000, 0x80041000, + trx.len, trx.len); fis_update_directory(); diag_printf("DD-WRT_FW: flashing done\n"); Index: /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade.h =================================================================== --- /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade.h (revision 12370) +++ /ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/net/fwupgrade.h (revision 12376) @@ -11,5 +11,5 @@ int do_flash); extern int fw_check_image_senao(unsigned char *addr, unsigned long maxlen, - int do_flash); + int do_flash); #define MAX_IMAGE_SIZE 0x7E0000 /* 4mb - 64k */