build firmware image for the MZK-W300NH board

SVN-Revision: 16342
This commit is contained in:
Gabor Juhos 2009-06-04 19:14:46 +00:00
parent f3c3e2772f
commit c8bf295481
2 changed files with 68 additions and 6 deletions

View File

@ -114,7 +114,9 @@ define Image/Build/Planex
dd if=$(KDIR)/vmlinux-$(2).uImage bs=1408k conv=sync; \ dd if=$(KDIR)/vmlinux-$(2).uImage bs=1408k conv=sync; \
dd if=$(KDIR)/root.$(1) bs=6208k conv=sync; \ dd if=$(KDIR)/root.$(1) bs=6208k conv=sync; \
) > $(call imgname,$(1),$(2)).bin; \ ) > $(call imgname,$(1),$(2)).bin; \
$(STAGING_DIR_HOST)/bin/mkplanexfw -v 2.00.00 \ $(STAGING_DIR_HOST)/bin/mkplanexfw \
-B $(2) \
-v 2.00.00 \
-i $(call imgname,$(1),$(2)).bin \ -i $(call imgname,$(1),$(2)).bin \
-o $(call imgname,$(1),$(2)).webui; \ -o $(call imgname,$(1),$(2)).webui; \
fi; fi fi; fi
@ -221,6 +223,10 @@ define Image/Build/Profile/MZKW04NU
$(call Image/Build/Template/Planex/$(1),mzk-w04nu,board=MZK-W04NU) $(call Image/Build/Template/Planex/$(1),mzk-w04nu,board=MZK-W04NU)
endef endef
define Image/Build/Profile/MZKW300NH
$(call Image/Build/Template/Planex/$(1),mzk-w300nh,board=MZK-W300NH)
endef
define Image/Build/Profile/TLWR841NDV3 define Image/Build/Profile/TLWR841NDV3
$(call Image/Build/Template/TPLINK/$(1),tl-wr841ndv3,board=TL-WR941ND,TL-WR841NDv3) $(call Image/Build/Template/TPLINK/$(1),tl-wr841ndv3,board=TL-WR941ND,TL-WR841NDv3)
endef endef
@ -237,6 +243,7 @@ define Image/Build/Profile/Default
$(call Image/Build/Profile/A02RBW300N,$(1)) $(call Image/Build/Profile/A02RBW300N,$(1))
$(call Image/Build/Profile/DIR615C1,$(1)) $(call Image/Build/Profile/DIR615C1,$(1))
$(call Image/Build/Profile/MZKW04NU,$(1)) $(call Image/Build/Profile/MZKW04NU,$(1))
$(call Image/Build/Profile/MZKW300NH,$(1))
$(call Image/Build/Profile/TEW632BRP,$(1)) $(call Image/Build/Profile/TEW632BRP,$(1))
$(call Image/Build/Profile/TEW652BRP,$(1)) $(call Image/Build/Profile/TEW652BRP,$(1))
$(call Image/Build/Profile/TLWR841NDV3,$(1)) $(call Image/Build/Profile/TLWR841NDV3,$(1))

View File

@ -36,6 +36,12 @@ struct planex_hdr {
uint32_t datalen; uint32_t datalen;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct board_info {
char *id;
uint32_t seed;
uint8_t unk[2];
};
/* /*
* Globals * Globals
*/ */
@ -44,6 +50,23 @@ static char *progname;
static char *ofname; static char *ofname;
static char *version = "1.00.00"; static char *version = "1.00.00";
static char *board_id;
static struct board_info *board;
static struct board_info boards[] = {
{
.id = "MZK-W04NU",
.seed = 2,
.unk = {0x04, 0x08},
}, {
.id = "MZK-W300NH",
.seed = 4,
.unk = {0x00, 0x00},
}, {
/* terminating entry */
}
};
/* /*
* Message macros * Message macros
*/ */
@ -60,6 +83,22 @@ static char *version = "1.00.00";
progname, ## __VA_ARGS__, strerror(save)); \ progname, ## __VA_ARGS__, strerror(save)); \
} while (0) } while (0)
static struct board_info *find_board(char *id)
{
struct board_info *ret;
struct board_info *board;
ret = NULL;
for (board = boards; board->id != NULL; board++){
if (strcasecmp(id, board->id) == 0) {
ret = board;
break;
}
};
return ret;
}
void usage(int status) void usage(int status)
{ {
FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
@ -69,6 +108,7 @@ void usage(int status)
fprintf(stream, fprintf(stream,
"\n" "\n"
"Options:\n" "Options:\n"
" -B <board> create image for the board specified with <board>\n"
" -i <file> read input from the file <file>\n" " -i <file> read input from the file <file>\n"
" -o <file> write output to the file <file>\n" " -o <file> write output to the file <file>\n"
" -v <version> set image version to <version>\n" " -v <version> set image version to <version>\n"
@ -87,7 +127,7 @@ int main(int argc, char *argv[])
char *buf; char *buf;
struct planex_hdr *hdr; struct planex_hdr *hdr;
sha1_context ctx; sha1_context ctx;
uint32_t t = HOST_TO_BE32(2); uint32_t seed;
FILE *outfile, *infile; FILE *outfile, *infile;
@ -96,11 +136,14 @@ int main(int argc, char *argv[])
while ( 1 ) { while ( 1 ) {
int c; int c;
c = getopt(argc, argv, "i:o:v:h"); c = getopt(argc, argv, "B:i:o:v:h");
if (c == -1) if (c == -1)
break; break;
switch (c) { switch (c) {
case 'B':
board_id = optarg;
break;
case 'i': case 'i':
ifname = optarg; ifname = optarg;
break; break;
@ -119,6 +162,17 @@ int main(int argc, char *argv[])
} }
} }
if (board_id == NULL) {
ERR("no board specified");
goto err;
}
board = find_board(board_id);
if (board == NULL) {
ERR("unknown board '%s'", board_id);
goto err;
};
if (ifname == NULL) { if (ifname == NULL) {
ERR("no input file specified"); ERR("no input file specified");
goto err; goto err;
@ -148,8 +202,8 @@ int main(int argc, char *argv[])
hdr = (struct planex_hdr *)buf; hdr = (struct planex_hdr *)buf;
hdr->datalen = HOST_TO_BE32(buflen - sizeof(*hdr)); hdr->datalen = HOST_TO_BE32(buflen - sizeof(*hdr));
hdr->unk1[0] = 0x04; hdr->unk1[0] = board->unk[0];
hdr->unk1[1] = 0x08; hdr->unk1[1] = board->unk[1];
snprintf(hdr->version, sizeof(hdr->version), "%s", version); snprintf(hdr->version, sizeof(hdr->version), "%s", version);
@ -166,8 +220,9 @@ int main(int argc, char *argv[])
goto err_close_in; goto err_close_in;
} }
seed = HOST_TO_BE32(board->seed);
sha1_starts(&ctx); sha1_starts(&ctx);
sha1_update(&ctx, (uchar *) &t, sizeof(t)); sha1_update(&ctx, (uchar *) &seed, sizeof(seed));
sha1_update(&ctx, buf + sizeof(*hdr), buflen - sizeof(*hdr)); sha1_update(&ctx, buf + sizeof(*hdr), buflen - sizeof(*hdr));
sha1_finish(&ctx, hdr->sha1sum); sha1_finish(&ctx, hdr->sha1sum);