Changeset 10243


Ignore:
Timestamp:
2008-01-25T09:19:31+01:00 (10 years ago)
Author:
juhosg
Message:

[tools] firmware-utils/mkzynfw: add preliminary support for OEM boards

Location:
trunk/tools/firmware-utils/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/firmware-utils/src/mkzynfw.c

    r10218 r10243  
    99 *  http://www.ixo.de/info/zyxel_uclinux 
    1010 * 
    11  *  This program is free software; you can redistribute it and/or 
    12  *  modify it under the terms of the GNU General Public License 
    13  *  as published by the Free Software Foundation; either version 2 
    14  *  of the License, or (at your option) any later version. 
     11 *  This program is free software; you can redistribute it and/or modify it 
     12 *  under the terms of the GNU General Public License version 2 as published 
     13 *  by the Free Software Foundation. 
    1514 * 
    16  *  This program is distributed in the hope that it will be useful, 
    17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    19  *  GNU General Public License for more details. 
    20  * 
    21  *  You should have received a copy of the GNU General Public License 
    22  *  along with this program; if not, write to the 
    23  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    24  *  Boston, MA  02110-1301, USA. 
    2515 */ 
    2616 
     
    2919#include <stdint.h> 
    3020#include <string.h> 
    31 #include <unistd.h>     /* for unlink() */ 
     21#include <unistd.h>     /* for unlink() */ 
    3222#include <libgen.h> 
    33 #include <getopt.h>     /* for getopt() */ 
     23#include <getopt.h>     /* for getopt() */ 
    3424#include <stdarg.h> 
    3525#include <errno.h> 
    3626#include <sys/stat.h> 
    37 #include <endian.h>     /* for __BYTE_ORDER */ 
     27#include <endian.h>     /* for __BYTE_ORDER */ 
    3828#if defined(__CYGWIN__) 
    3929#  include <byteswap.h> 
     
    10191        char *name;             /* model name */ 
    10292        char *desc;             /* description */ 
     93        uint16_t vendor;        /* vendor id */ 
    10394        uint16_t model;         /* model id */ 
    10495        uint32_t flash_base;    /* flash base address */ 
     
    128119#define AR7_CODE_START          0x94008000 
    129120 
    130 #define BOARD(n, d, m, fb, fs, cs, fo) { \ 
    131         .name = (n), .desc=(d), .model = (m), \ 
     121#define BOARD(n, d, v, m, fb, fs, cs, fo) { \ 
     122        .name = (n), .desc=(d), \ 
     123        .vendor = (v), .model = (m), \ 
    132124        .flash_base = (fb), .flash_size = (fs)<<20, \ 
    133125        .code_start = (cs), .fw_offs = (fo) \ 
    134126        } 
    135127 
    136 #define ADMBOARD1(n, d, m, fs) BOARD(n, d, m, \ 
     128#define ADMBOARD1(n, d, m, fs) BOARD(n, d, ZYNOS_VENDOR_ID_ZYXEL, m, \ 
    137129        ADM5120_FLASH_BASE, fs, ADM5120_CODE_START, 0x8000) 
    138130 
    139 #define ADMBOARD2(n, d, m, fs) BOARD(n, d, m, \ 
     131#define ADMBOARD2(n, d, m, fs) BOARD(n, d, ZYNOS_VENDOR_ID_ZYXEL, m, \ 
    140132        ADM5120_FLASH_BASE, fs, ADM5120_CODE_START, 0x10000) 
    141133 
    142 #define AR7BOARD1(n, d, m, fs) BOARD(n, d, m, \ 
     134#define AR7BOARD1(n, d, m, fs) BOARD(n, d, ZYNOS_VENDOR_ID_ZYXEL, m, \ 
    143135        AR7_FLASH_BASE, fs, AR7_CODE_START, 0x8000) 
    144136 
     
    166158        ADMBOARD1("P-335U",     "ZyXEL Prestige 335U", ZYNOS_MODEL_P_335U, 4), 
    167159        ADMBOARD1("P-335WT",    "ZyXEL Prestige 335WT", ZYNOS_MODEL_P_335WT, 4), 
     160 
    168161#if 0 
    169162        /* 
     
    187180        AR7BOARD1("P-660R-D3",  "ZyXEL P-660R-D3", ZYNOS_MODEL_P_660R_D3, 2), 
    188181#endif 
     182        { 
     183                .name           = "O2SURF", 
     184                .desc           = "O2 DSL Surf & Phone", 
     185                .vendor         = ZYNOS_VENDOR_ID_O2, 
     186                .model          = ZYNOS_MODEL_O2SURF, 
     187                .flash_base     = AR7_FLASH_BASE, 
     188                .flash_size     = 8*1024*1024, 
     189                .code_start     = 0x94014000, 
     190                .fw_offs        = 0x40000, 
     191        }, 
     192 
    189193        {.name = NULL} 
    190194}; 
     
    195199#define ERR(fmt, ...) do { \ 
    196200        fflush(0); \ 
    197         fprintf(stderr, "[%s] *** error: " fmt "\n", progname, ## __VA_ARGS__ ); \ 
     201        fprintf(stderr, "[%s] *** error: " fmt "\n", \ 
     202                        progname, ## __VA_ARGS__ ); \ 
    198203} while (0) 
    199204 
     
    201206        int save = errno; \ 
    202207        fflush(0); \ 
    203         fprintf(stderr, "[%s] *** error: " fmt ", %s\n", progname, ## __VA_ARGS__ \ 
    204                 , strerror(save)); \ 
     208        fprintf(stderr, "[%s] *** error: " fmt ", %s\n", \ 
     209                        progname, ## __VA_ARGS__, strerror(save)); \ 
    205210} while (0) 
    206211 
    207212#define WARN(fmt, ...) do { \ 
    208         fprintf(stderr, "[%s] *** warning: " fmt "\n", progname, ## __VA_ARGS__ ); \ 
     213        fprintf(stderr, "[%s] *** warning: " fmt "\n", \ 
     214                        progname, ## __VA_ARGS__ ); \ 
    209215} while (0) 
    210216 
     
    522528 
    523529        /* setup temporary header fields */ 
    524         memset(&t,0, sizeof(t)); 
     530        memset(&t, 0, sizeof(t)); 
    525531        t.addr = HOST_TO_BE32(hdr->addr); 
    526532        memcpy(&t.sig, ROMBIN_SIGNATURE, ROMBIN_SIG_LEN); 
     
    546552        int res; 
    547553 
    548         memset(buf,0,sizeof(buf)); 
     554        memset(buf, 0, sizeof(buf)); 
    549555 
    550556        mh = (struct zyn_mmt_hdr *)buf; 
     
    555561        /* Build user data section */ 
    556562        data = buf+sizeof(*mh); 
    557         data += sprintf(data,"Model 1 %d", BE16_TO_HOST(board->model)); 
     563        data += sprintf(data, "Vendor 1 %d", board->vendor); 
     564        *data++ = '\0'; 
     565        data += sprintf(data, "Model 1 %d", BE16_TO_HOST(board->model)); 
    558566        *data++ = '\0'; 
    559567        /* TODO: make hardware version configurable? */ 
    560         data += sprintf(data,"HwVerRange 2 %d %d", 0, 0); 
     568        data += sprintf(data, "HwVerRange 2 %d %d", 0, 0); 
    561569        *data++ = '\0'; 
    562570 
     
    667675 
    668676        /* setup header fields */ 
     677        memset(&hdr, 0, sizeof(hdr)); 
    669678        hdr.addr = board->code_start; 
    670679        hdr.type = OBJECT_TYPE_BOOTEXT; 
  • trunk/tools/firmware-utils/src/zynos.h

    r9493 r10243  
    99 *  http://www.ixo.de/info/zyxel_uclinux 
    1010 * 
    11  *  This program is free software; you can redistribute it and/or 
    12  *  modify it under the terms of the GNU General Public License 
    13  *  as published by the Free Software Foundation; either version 2 
    14  *  of the License, or (at your option) any later version. 
    15  * 
    16  *  This program is distributed in the hope that it will be useful, 
    17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    19  *  GNU General Public License for more details. 
    20  * 
    21  *  You should have received a copy of the GNU General Public License 
    22  *  along with this program; if not, write to the 
    23  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    24  *  Boston, MA  02110-1301, USA. 
     11 *  This program is free software; you can redistribute it and/or modify it 
     12 *  under the terms of the GNU General Public License version 2 as published 
     13 *  by the Free Software Foundation. 
     14 * 
    2515 */ 
    2616 
    2717#ifndef _ZYNOS_H 
    2818#define _ZYNOS_H 
    29  
    3019 
    3120#define BOOTBASE_NAME_LEN       32 
     
    3726        char            model[BOOTBASE_NAME_LEN]; /* Model name */ 
    3827        uint32_t        bootext_addr;   /* absolute address of the Boot Extension */ 
    39         uint16_t        res0;           /* reserved */ 
     28        uint16_t        res0;           /* reserved/unknown */ 
    4029        uint8_t         sys_type;       /* system type */ 
    41         uint8_t         res1;           /* reserved */ 
     30        uint8_t         res1;           /* reserved/unknown */ 
    4231        uint16_t        model_id;       /* model id */ 
    4332        uint8_t         feat_other[BOOTBASE_FEAT_LEN]; /* other feature bits */ 
    4433        uint8_t         feat_main;      /* main feature bits */ 
    45         uint8_t         res2;           /* reserved */ 
     34        uint8_t         res2;           /* reserved/unknown */ 
    4635        uint8_t         mac[BOOTBASE_MAC_LEN]; /* mac address */ 
    4736        uint8_t         country;        /* default country code */ 
     
    117106 
    118107/* 
    119  * Board IDs (in big-endian format) 
     108 * Vendor IDs 
     109 */ 
     110#define ZYNOS_VENDOR_ID_ZYXEL   0 
     111#define ZYNOS_VENDOR_ID_NETGEAR 1 
     112#define ZYNOS_VENDOR_ID_DLINK   2 
     113#define ZYNOS_VENDOR_ID_03      3 
     114#define ZYNOS_VENDOR_ID_LUCENT  4 
     115#define ZYNOS_VENDOR_ID_O2      10 
     116 
     117/* 
     118 * Model IDs (in big-endian format) 
    120119 */ 
    121120#define MID(x)  (((x) & 0xFF) << 8) | (((x) & 0xFF00) >> 8) 
     
    161160#define ZYNOS_MODEL_P_2602HWL_D1A       MID( 6301) 
    162161#define ZYNOS_MODEL_P_2602HWL_D3A       MID( 7581) 
     162#define ZYNOS_MODEL_P_2602HWN_D7A       MID(30464) 
    163163#define ZYNOS_MODEL_P_2602HWNLI_D7A     MID( 6813) 
    164164 
     
    213213#define ZYNOS_MODEL_P_662HW_D3          MID(12954) 
    214214 
     215/* OEM boards */ 
     216#define ZYNOS_MODEL_O2SURF              ZYNOS_MODEL_P_2602HWN_D7A 
     217 
    215218#endif /* _ZYNOS_H */ 
Note: See TracChangeset for help on using the changeset viewer.