$(call prepare_generic_squashfs,$(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin)
endef
+define Image/Build/CFEAGPF
+ # Generate the tagged image
+ $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
+ -o $(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin \
+ -b $(2) -c $(3) -e $(LOADADDR) -l $(LOADADDR) \
+ -v 8 -m IMAGE -k 131072
+ $(call prepare_generic_squashfs,$(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin)
+endef
+
define Image/Build/RedBoot
cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(1)-vmlinux.elf
gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
$(call Image/Build/CFE,$(1),F@ST2404,6348)
# Inventel Livebox
$(call Image/Build/RedBoot,livebox)
+ # Pirelli Alice Gate VoIP 2 Plus Wi-Fi AGPF-S0
+ $(call Image/Build/CFEAGPF,$(1),AGPF-S0,6358)
endef
$(eval $(call BuildImage))
#define IMAGETAG_CRC_START 0xFFFFFFFF
#define DEFAULT_FW_OFFSET 0x10000
#define DEFAULT_FLASH_START 0xBFC00000
-#define FLASH_BS (64 * 1024) /* TODO: Make this a command line option */
+#define DEFAULT_FLASH_BS (64 * 1024)
/* Kernel header */
struct kernelhdr {
int tagfile(const char *kernel, const char *rootfs, const char *bin,
const char *boardid, const char *chipid, const uint32_t fwaddr,
- const uint32_t loadaddr, const uint32_t entry)
+ const uint32_t loadaddr, const uint32_t entry,
+ const char *ver, const char *magic2, const uint32_t flash_bs)
{
struct imagetag tag;
struct kernelhdr khdr;
/* Build the rootfs address and length (start and end do need to be aligned on flash erase block boundaries */
rootfsoff = kerneloff + kernellen;
- rootfsoff = (rootfsoff % FLASH_BS) > 0 ? (((rootfsoff / FLASH_BS) + 1) * FLASH_BS) : rootfsoff;
+ rootfsoff = (rootfsoff % flash_bs) > 0 ? (((rootfsoff / flash_bs) + 1) * flash_bs) : rootfsoff;
rootfslen = getlen(rootfsfile);
- rootfslen = (rootfslen % FLASH_BS) > 0 ? (((rootfslen / FLASH_BS) + 1) * FLASH_BS) : rootfslen;
+ rootfslen = (rootfslen % flash_bs) > 0 ? (((rootfslen / flash_bs) + 1) * flash_bs) : rootfslen;
/* Seek to the start of the kernel */
fseek(binfile, kerneloff - fwaddr, SEEK_SET);
fclose(rootfsfile);
/* Build the tag */
- strcpy(tag.tagver, IMAGETAG_VER);
+ strcpy(tag.tagver, ver);
strncpy(tag.sig1, IMAGETAG_MAGIC1, sizeof(tag.sig1) - 1);
- strncpy(tag.sig2, IMAGETAG_MAGIC2, sizeof(tag.sig2) - 1);
+ strncpy(tag.sig2, magic2, sizeof(tag.sig2) - 1);
strcpy(tag.chipid, chipid);
strcpy(tag.boardid, boardid);
strcpy(tag.bigendian, "1");
int main(int argc, char **argv)
{
int c;
- char *kernel, *rootfs, *bin, *boardid, *chipid;
+ char *kernel, *rootfs, *bin, *boardid, *chipid, *magic2, *ver;
uint32_t flashstart, fwoffset, loadaddr, entry;
- uint32_t fwaddr;
+ uint32_t fwaddr, flash_bs;
kernel = rootfs = bin = boardid = chipid = NULL;
entry = 0;
flashstart = DEFAULT_FLASH_START;
fwoffset = DEFAULT_FW_OFFSET;
loadaddr = IMAGETAG_DEFAULT_LOADADDR;
+ flash_bs = DEFAULT_FLASH_BS;
- printf("Broadcom image tagger - v0.1.0\n");
+ printf("Broadcom image tagger - v0.1.1\n");
printf("Copyright (C) 2008 Axel Gembe\n");
- while ((c = getopt(argc, argv, "i:f:o:b:c:s:n:l:e:h")) != -1) {
+ while ((c = getopt(argc, argv, "i:f:o:b:c:s:n:v:m:k:l:e:h")) != -1) {
switch (c) {
case 'i':
kernel = optarg;
case 'n':
fwoffset = strtoul(optarg, NULL, 16);
break;
+ case 'v':
+ ver = optarg;
+ break;
+ case 'm':
+ magic2 = optarg;
+ break;
+ case 'k':
+ flash_bs = strtoul(optarg, NULL, 16);
+ break;
case 'l':
loadaddr = strtoul(optarg, NULL, 16);
break;
fprintf(stderr, "-o <bin> - The output file\n");
fprintf(stderr, "-b <boardid> - The board id to set in the image (i.e. \"96345GW2\")\n");
fprintf(stderr, "-c <chipid> - The chip id to set in the image (i.e. \"6345\")\n");
- fprintf(stderr, "-s <flashstart> - \n");
+ fprintf(stderr, "-s <flashstart> - Flash start address (i.e. \"0xBFC00000\"\n");
fprintf(stderr, "-n <fwoffset> - \n");
+ fprintf(stderr, "-v <version> - \n");
+ fprintf(stderr, "-m <magic2> - \n");
+ fprintf(stderr, "-k <flash_bs> - \n");
fprintf(stderr, "-l <loadaddr> - Address where the kernel expects to be loaded (defaults to 0x80010000)\n");
fprintf(stderr, "-e <entry> - Address where the kernel entry point will end up\n");
fprintf(stderr, "-h - Displays this text\n");
return 1;
}
+ /* Fallback to defaults */
+
fwaddr = flashstart + fwoffset;
+
+ if (!magic2) {
+ magic2 = malloc(sizeof(char) * 14);
+ if (!magic2) {
+ perror("malloc");
+ return 1;
+ }
+ strcpy(magic2, IMAGETAG_MAGIC2);
+ }
+
+ if (!ver) {
+ ver = malloc(sizeof(char) * 4);
+ if (!ver) {
+ perror("malloc");
+ return 1;
+ }
+ strcpy(ver, IMAGETAG_VER);
+ }
- return tagfile(kernel, rootfs, bin, boardid, chipid, fwaddr, loadaddr, entry);
+ return tagfile(kernel, rootfs, bin, boardid, chipid, fwaddr, loadaddr, entry, ver, magic2, flash_bs);
}