| 1 | #ifndef _UPGRADE_H_ |
| 2 | #define _UPGRADE_H_ |
| 3 | |
| 4 | #define FLASH_END_ADDR 0xffffffff |
| 5 | #define FLASH_ADDR_BASE 0xff800000 |
| 6 | #define BOOT_ADDR_BASE 0xfffc0000 |
| 7 | #define BOOT_ADDR_BASE_OFF 0x7c0000 |
| 8 | #define FLASH_SIZE 0x800000 |
| 9 | #define BOOT_SIZE 0x40000 |
| 10 | //NVRAM in boot area |
| 11 | //#define NVRAM_ADDR_BASE 0xfff90000 |
| 12 | //#define NVRAM_ADDR_BASE_OFF 0x790000 |
| 13 | //#define NVRAM_SIZE 0x10000 |
| 14 | |
| 15 | #define PID_OFFSET (BOOT_SIZE- 0x46) |
| 16 | #define NODE_ADDRESS (BOOT_SIZE-0x60) |
| 17 | #define NODE_BASE_OFF (FLASH_SIZE-0x60) |
| 18 | #define PIN_ADDRESS (BOOT_SIZE-0x70)//WPS PIN,8bytes |
| 19 | #define PIN_OFF (FLASH_SIZE-0x70) |
| 20 | #define KERNEL_CODE_OFFSET 0 |
| 21 | #define SN_ADDRESS (BOOT_SIZE-0x80) //12bytes |
| 22 | #define SN_OFF (FLASH_SIZE-0x80) |
| 23 | |
| 24 | |
| 25 | #define UPGRADE_START_OFFSET 0 |
| 26 | #define UPGRADE_END_OFFSET 0x7A0000 |
| 27 | #define PRODUCT_ID_OFFSET 0x75ffe0//(UPGRADE_END_OFFSET - 0x10) |
| 28 | #define PROTOCOL_ID_OFFSET (PRODUCT_ID_OFFSET + 0x02) |
| 29 | #define FW_VERSION_OFFSET (PRODUCT_ID_OFFSET + 0x04) |
| 30 | #define SIGN_OFFSET (PRODUCT_ID_OFFSET + 0x08) /* eRcOmM */ |
| 31 | |
| 32 | //#define LANG_UPGRADE |
| 33 | #ifdef LANG_UPGRADE |
| 34 | #define LANGBUF_BEGIN 0x1300000 |
| 35 | #define LANGBUF_END 0x1f00000 |
| 36 | #define LANGBUF_LENTH (LANGBUF_END - LANGBUF_BEGIN) |
| 37 | #endif |
| 38 | #ifndef ERROR |
| 39 | #define ERROR -1 |
| 40 | #endif |
| 41 | |
| 42 | #ifndef OK |
| 43 | #define OK 0 |
| 44 | #endif |
| 45 | |
| 46 | #ifndef NULL |
| 47 | #define NULL 0 |
| 48 | #endif |
| 49 | |
| 50 | |
| 51 | void do_boot(void); |
| 52 | void Download(void); |
| 53 | void Assign(void); |
| 54 | |
| 55 | void gpio_init(void); |
| 56 | void Led_Power(int value); |
| 57 | void Led_security(int value); |
| 58 | int PushButton(void); |
| 59 | |
| 60 | static unsigned short xchg ( unsigned short dwData); |
| 61 | int FlashDriver(unsigned long dlAddress,unsigned char *dbData,unsigned long dlLength,unsigned long dlFlag); |
| 62 | int ProgramChip(unsigned long dlAddress,unsigned char * dbData,unsigned long dlLength); |
| 63 | int dl_Initialize(void); |
| 64 | void dl_GetAddr(unsigned char *node); |
| 65 | int dl_Receive(void); |
| 66 | int dl_Transmit(char *buf,int len); |
| 67 | void reset(void); |
| 68 | void AssignHWAddress(unsigned char *psBuffer); |
| 69 | int ResetChip(unsigned long ulRomDstAddr); |
| 70 | int GetFlashType(void); |
| 71 | |
| 72 | #ifdef LANG_UPGRADE |
| 73 | int save_lang_buf(unsigned long flash_addr, char *mem_addr,unsigned long length); |
| 74 | int LangDriver(unsigned long flash_addr, char *mem_addr,unsigned long length, unsigned long dlFlag); |
| 75 | #endif |
| 76 | #endif |
| 77 | |
| 78 | |