⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 write_idblock.c

📁 用于Rabbit写Flash设备ID的程序
💻 C
📖 第 1 页 / 共 4 页
字号:
/********************************************************************
	write_idblock.c


	Writes product System ID Block(s) to top of flash and verifies.
	This version is intended for Dynamic C 7.04P2 and later.

	This program is intended to write a System ID Block on boards
	that don't have a System ID block, or to replace a version 1 or 2
	System ID Block.  If your board has a version 3 or 4 System ID
	Block then you should use the idblock_recovery.c utility program
	for proper recovery of your data from the userblock data area.

	This program, when compiled using Dynamic C version 7.25 or prior
	and an existing version 3 or 4 System ID Block is detected, will
	prompt for confirmation before overwriting the System ID Block.

	Version 2.06

 ********************************************************************


 Instructions:


 1. Uncomment the MYBOARD macro below for the board you are writing
    to, or add your own MYBOARD macro for a custom board.


 2. Enter the MAC address of the board you are writing to if it is
    Ethernet capable.  For Z-World products, the first three hex
    digits are always 0x00, 0x90, 0xC2.  The last three digits should
    be on a sticker on your product.  NOTE that OP6700 and Rabbit
    TCP/IP Development Kit boards already have MAC addresses in an
    onboard EEPROM and versions 1.1 or later of this program will not
    write a MAC address to the ID block even if supplied.


3.  Define the NUMUSER4KBLOCKS macro to 0 for no User Block, or to
    the number of 4K blocks in the desired User Block size.
    EG:  Define NUMUSER4KBLOCKS to 2 for an 8K User Block size.


4.  (Optional.)
    Uncomment and set the IDBLOCK_VERSION macro to a number from 1
    through 4, inclusive.  0 is not allowed; 1 is an ID Block with no
    User Block; 2 is an unmirrored ID plus User Block; 3 and 4 are
    mirrored ID plus User Blocks; 5 and greater are not allowed.


5.  (Only required if the target is an RCM3200 or derivative that
     does not already have a correct ID Block containing an RCM3200
     or derivative product ID code.)
    Add "_BOARD_TYPE_=RCM3200" (or as appropriate for the derivative
    board type, without the quotes, and noting that there are no
    spaces within the quotes) to the Compiler Options' Defines box.


6.  Run the program.  The contents of the ID block will be printed
    (or any errors reported) to stdio.


7.  (Only required if the target is an RCM3200 or derivative that did
     not already have a correct ID Block containing an RCM3200 or
     derivative product ID code.)
    Ignore the warning about the redefined _BOARD_TYPE_ macro, and
    remove the "_BOARD_TYPE_=RCM3200" (or derivative product ID code)
    from the Compiler Options' Defines box.


 ********************************************************************


	History:
			2.06
				- Corrected BL26xx series' board information.
            - Removed (reserved product ID) RCM3350A board information.
			2.05
				- Added boards:  BL2600A, BL2600B, BL2600C, BL2600D, RCM3310A.
			2.04
				- Added boards:  RCM3300A, RCM3350A, RCM3600H, RCM3610H,
				  RCM3700H, RCM3710H.
				- Corrected RCM3410A product ID.
			2.03
				- Corrected RCM3610A, RCM3710A descriptions to 128 KB SRAM.
			2.02
				- Added boards:  RCM3600A, RCM3610A, RCM3700A, RCM3710A.
			2.01
				- Updated instructions in the comments above.
				- Reorganized information presentation, eased future flash
				  writeMode additions.
				- If available, use the compiler's dc_timestamp compile end-
				  time to set the ID Block's time stamp information.
				- Loop forever at the end of main to prevent repetitive
				  flash writes in case this program is started in run mode.
				- Added AMD AM29F040B, STMicroelectronics M29W010B flashes.
				- Added board:  BL2000B.
			2.00
				- Added option to retain existing MAC address for targets
				  with a System ID Block already installed.
			1.85
				- Added boards:  EM1500A, RCM3210A, RCM3220A.
				- Added checks for undefined board types:  BL1800, BL1805,
				  BL1810, BL1820, RCM2000, RCM2010, RCM2020, RCM2300.
			1.84
				- Fixed a conditionally missing return value in GetFlashID.
				- Replaced mainline SysIDBlock info output code with a new
				  function, and added other new functions for detailed
				  product and flash info output.
				- Uses *_PROGRAM_NAME macros in some STDIO output.
				- Enabled writing a version 1 ID Block and updated the
				  instructions to reflect this.
			1.83
				- Updated comments with instructions on writing ID Block(s)
				  to an RCM3200 that does not already have an RCM3200 ID.
         	- Added board:  RCM3300A.
				- For Dynamic C 8, allows 0K, 4K, ..., 64K User Block size.
				- Added support for load-to-flash-run-in-fast-RAM and
				  run-in-RAM operation.
				- Made separate I&D space compatible.
			1.82
         	- Added board:  EG2110A (3V RabbitLink).
         	- Corrected BL2550A name to BL2500C.
				- Added IDBLOCK_VERSION macro to facilitate setting a
				  specific SysIDBlock.tableVersion value.  (See step 4.)
			1.81
				- For ID Block version > 2, initially invalidate "B" copy.
				- Added boards:  BL25xx.
			1.8
				- Added error messages when compiling as primary (DLM)
				  or secondary (DLP) type program, and when compiling
				  with separate I&D space enabled.
				- Automatically mirror tableVersion 3 and up ID blocks
				  as required.
				- Replaced HASUSERBLOCK macro with NUMUSER4KBLOCKS macro
				  to facilitate installing a custom User Block size.
				- Removed RCM2130 from the HAS2FLASHES macro list.
				- Added boards:  BL2010B, OP6805, OP72xx, RCM21xx,
				  RCM2210, RCM34xx, SR9160.
				- Reorganized and renamed Has2Flash(), HasEEPROM(), and
				  HasEthernet() macros to HAS2FLASHES, HASEEPROM, and
				  HASETHERNET macro lists respectively, to make
				  maintenance easier when adding new board types.
				- Standardized board descriptions.
			1.7
				- Made "unconditional" use of div19200ptr.
			1.6
				- Added board:  LP3510.
				- Added RCM3200 to HasEthernet() macro.
				- Forces version 2 ID Block for Dynamic C 7.25 and earlier.
				- Added detection of system ID blocks of version 3 or
				  higher to prompt the user to use the idblock_recovery
				  program.
			1.5
				- Separated ifndef board type groups into individual board
				  ID macros.
				- Conditionally defined GCPU, GREV register addresses.
			1.4
				- Added more boards:  BL21xx, LP3500, and OP72xx.
				- Bug with reading divider19200 fixed in Dynamic C 7.30;
				  needed to modify routine to do it the right way.
				- Made ID block version dependent on Dynamic C version
				  program is compiled with:
						7.06 or earlier will write a type 2 ID block
						7.20 or later will write type 4
			1.3
				- Added Rabbit 3000 cores (RCM3xxx series).
			1.2
				- Updated for version 4 ID block (new fields).
				- Improved support for older Dynamic C versions.


			1.1
				- Fixed a small bug in getFlashID().
				- Added RCM3000 core modules.
				- Fixed problem with writing MAC address in ID block to
				  OP6700 and RTDKs, which would override the MAC address
				  in the on-board EEPROM.
			1.0
				- Corresponds to initwrid.c version 3.14.


 ********************************************************************/

#define VERSION "2.06"
#define MY_PROGRAM_NAME "write_idblock.c"
#define RECOVERY_PROGRAM_NAME "idblock_recovery.c"

/********************************************************************/
/**  STEP ONE:  uncomment the macro for the board you are using.   **/
/********************************************************************/


//*** RabbitCore Modules ***//

//#define	MYBOARD RCM2000	// 25MHz R2000, 256K flash, 512k SRAM
//#define	MYBOARD RCM2010	// 25MHz R2000, 256K flash, 128k SRAM
//#define	MYBOARD RCM2020	// 18MHz R2000, 256K flash, 128K SRAM

//#define	MYBOARD RCM2100	// 22MHz R2000, 2x256K flash, 512K SRAM, ethernet
//#define	MYBOARD RCM2110	// 22MHz R2000, 256K flash, 128K SRAM, ethernet
//#define	MYBOARD RCM2115	// 22MHz R2000, 256K flash, 128K SRAM, ethernet (no RJ45)
//#define	MYBOARD RCM2120	// 22MHz R2000, 2x256K flash, 512K SRAM
//#define	MYBOARD RCM2130	// 22MHz R2000, 256K flash, 128K SRAM

//#define	MYBOARD RCM2200	// 22MHz R2000, 256K flash, 128K SRAM, ethernet
//#define	MYBOARD RCM2210	// 22MHz R2000, 256K flash, 128K SRAM, ethernet (no RJ45)
//#define	MYBOARD RCM2250	// 22MHz R2000, 2x256K flash, 512K SRAM, ethernet

//#define	MYBOARD RCM2300	// 22MHz R2000, 256K flash, 128K SRAM

//#define	MYBOARD RCM3000	// 29MHz R3000, 2x256K flash, 512K SRAM, ethernet
//#define	MYBOARD RCM3010	// 29MHz R3000, 256K flash, 128K SRAM, ethernet

//#define	MYBOARD RCM3100	// 29MHz R3000, 2x256K flash, 512K SRAM
//#define	MYBOARD RCM3110	// 29MHz R3000, 256K flash, 128K SRAM

//#define	MYBOARD RCM3200	// 44MHz R3000, 512K flash, 256K+512K SRAM, ethernet
//#define	MYBOARD RCM3210A	// 29MHz R3000, 256K flash, 128K SRAM, ethernet
//#define	MYBOARD RCM3220A	// 44MHz R3000, 512K flash, 256K+512K SRAM

//#define	MYBOARD RCM3300A	// 44MHz R3000, 512K flash, 512K+512K SRAM, ethernet, 8M serial flash
//#define	MYBOARD RCM3310A	// 44MHz R3000, 512K Flash, 512K+512K SRAM, ethernet, 4M serial flash
//#define	MYBOARD RCM3350A

//#define	MYBOARD RCM3400A	// 29MHz R3000, 512K flash, 512K SRAM, ethernet on PB, analog
//#define	MYBOARD RCM3410A	// 29MHz R3000, 256K flash, 256K SRAM, ethernet on PB, analog

//TinyCore
//#define	MYBOARD RCM3600A	// 22MHz R3000, 512K flash, 512K SRAM
//#define	MYBOARD RCM3610A	// 22MHz R3000, 256K flash, 128K SRAM
//Hobby
//#define	MYBOARD RCM3600H	// 22MHz R3000, 512K flash, 512K SRAM
//#define	MYBOARD RCM3610H	// 22MHz R3000, 256K flash, 128K SRAM

//Ethernet TinyCore
//#define	MYBOARD RCM3700A	// 22MHz R3000, 512K flash, 512K SRAM, ethernet, 1M serial flash
//#define	MYBOARD RCM3710A	// 22MHz R3000, 256K flash, 128K SRAM, ethernet, 1M serial flash
//Hobby Ethernet
//#define	MYBOARD RCM3700H	// 22MHz R3000, 512K flash, 512K SRAM, ethernet, 1M serial flash
//#define	MYBOARD RCM3710H	// 22MHz R3000, 256K flash, 128K SRAM, ethernet, 1M serial flash


//*** Single Board Computers ***//

//Jackrabbit
//#define	MYBOARD BL1800		// 29MHz R2000, 256K flash, 128K SRAM, RS485, battery
//#define	MYBOARD BL1805		// 29MHz R2000, 256K flash, 512K SRAM, RS485, battery
//#define	MYBOARD BL1810		// 14MHz R2000, 128K flash, 128K SRAM, RS485, battery
//#define	MYBOARD BL1820		// 14MHz R2000, 128K flash, 128k SRAM

//Wildcat
//#define	MYBOARD BL2000		// 22MHz R2000, 256K flash, 128K SRAM, ethernet, high-quality analog
//#define	MYBOARD BL2000B	// 22MHz R2000, 512K flash, 512K SRAM, ethernet, high-quality analog
//#define	MYBOARD BL2010		// 22MHz R2000, 256K flash, 128K SRAM, ethernet, analog
//#define	MYBOARD BL2010B	// 22MHz R2000, 256K flash, 512K SRAM, ethernet, analog
//#define	MYBOARD BL2020		// 22MHz R2000, 256K flash, 128K SRAM, high-quality analog
//#define	MYBOARD BL2030		// 22MHz R2000, 256K flash, 128K SRAM, analog
//#define	MYBOARD BL2040		// 22MHz R2000, 256K flash, 128K SRAM

//Smart Cat
//#define	MYBOARD BL2100		// 22MHz RCM2200, 256K flash, 128K SRAM, ethernet, analog
//#define	MYBOARD BL2101		// 22MHz RCM2200, 256K flash, 128K SRAM, ethernet, 10V analog
//#define	MYBOARD BL2105		// 22MHz RCM2250, 2x256K flash, 512K SRAM, ethernet, analog
//#define	MYBOARD BL2110		// 22MHz RCM2200, 256K flash, 128K SRAM, ethernet
//#define	MYBOARD BL2111		// 22MHz RCM2250, 2x256K flash, 512K SRAM, ethernet, 10V analog
//#define	MYBOARD BL2115		// 22MHz RCM2250, 2x256K flash, 512K SRAM, ethernet
//#define	MYBOARD BL2120		// 22MHz RCM2300, 256K flash, 128K SRAM, analog
//#define	MYBOARD BL2121		// 22MHz RCM2300, 256K flash, 128K SRAM, 10V analog
//#define	MYBOARD BL2130		// 22MHz RCM2300, 256K flash, 128K SRAM

//RabbitNet
//#define	MYBOARD BL2500A	// 29MHz RCM3010, 256K flash, 128K SRAM, ethernet
//#define	MYBOARD BL2500B	// 29MHz RCM3000, 2x256K flash, 512K SRAM, ethernet
//#define	MYBOARD BL2500C	// 44MHz RCM3200, 512K flash, 256K+512K SRAM, ethernet
//#define	MYBOARD BL2510A	// 29MHz RCM3110, 256K flash, 128K SRAM
//#define	MYBOARD BL2510B	// 29MHz RCM3100, 2x256K flash, 512K SRAM

//#define	MYBOARD BL2600A	// 44MHz RCM3200, 512K flash, 256K+512K SRAM, ethernet
//#define	MYBOARD BL2600B	// 29MHz RCM3000, 2x256K flash, 512K SRAM, ethernet
//#define	MYBOARD BL2600C	// 29MHz RCM3010, 256K flash, 128K SRAM, ethernet
//#define	MYBOARD BL2610A	// 29MHz RCM3100, 2x256K flash, 512K SRAM
//#define	MYBOARD BL2610B	// 29MHz RCM3110, 256K flash, 128K SRAM

//Fox Low-Power Controller
//#define	MYBOARD LP3500		// 7MHz R3000, 2x256K flash, 512K SRAM, analog, relay
//#define	MYBOARD LP3510		// 7MHz R3000, 256K flash, 128K SRAM


//*** Embedded Control Systems ***//

//SmartStar
//#define	MYBOARD SR9100		// 29MHz R2000, 2x256K flash, 128K SRAM

//MiniStar
//#define	MYBOARD SR9150		// 22MHz R2000, 2x256K flash, 128K SRAM, ethernet
//#define	MYBOARD SR9160		// 22MHz R2000, 2x256K flash, 128K SRAM

//*** Operator Interfaces ***//

//Intellicom
//#define	MYBOARD OP6600		// 18MHz R2000, 256K flash, 128K SRAM
//#define	MYBOARD OP6700		// 18MHz R2000, 2x256K flash, 256K SRAM, ethernet

//Minicom
//#define	MYBOARD OP6800		// 22MHz RCM2200, 256K flash, 128K SRAM, ethernet
//#define	MYBOARD OP6805		// 22MHz RCM2250, 2x256K flash, 512K SRAM, ethernet
//#define	MYBOARD OP6810		// 22MHz RCM2300, 256K flash, 128K SRAM

//eDisplay
//#define	MYBOARD OP7200		// 22MHz RCM2200, 256K flash, 128K SRAM, ethernet, analog, touchscreen
//#define	MYBOARD OP7200B	// 22MHZ RCM2250, 2x256K flash, 512K SRAM, ethernet, analog, touchscreen
//#define	MYBOARD OP7210		// 22MHz RCM2300, 256K flash, 128K SRAM
//#define	MYBOARD OP7210B	// 22MHz RCM2250, 2x256K flash, 512K SRAM, ethernet


//*** Other Products ***//

//Ethernet Modem
//#define	MYBOARD EM1500A	// 44MHz RCM3200, 512K flash, 256K+512K SRAM, ethernet

//RabbitLink
//#define	MYBOARD EG2110A	// 22MHz R2000, 2x256K flash, 128K SRAM, ethernet, 3V
//#define	MYBOARD RABLINK	// 22MHz R2000, 2x256K flash, 128K SRAM, ethernet

//TCP/IP Development Kit
//#define	MYBOARD RTDK		// 18MHz R2000, 2x256K flash, 128K SRAM, ethernet


/********************************************************************/
/**  STEP TWO:  enter the MAC address of the board if it is	       **/
/**		Ethernet-capable.  the first three digits are fixed; the  **/
/**		last three should be on a sticker on the board.           **/
/********************************************************************/


const char MAC[6] = { 0x00, 0x90, 0xC2,
							 0x00, 0x00, 0x00 };


/********************************************************************/
/**  STEP THREE:  set the NUMUSER4KBLOCKS macro to the desired     **/
/**		number of 4K blocks in the User Block.  if 0, only the    **/
/**      ID block will be written, and no User Block will be       **/
/**      installed.  eg:  set to 2 to install an 8K User Block.    **/
/********************************************************************/


#define	NUMUSER4KBLOCKS	4


/********************************************************************/
/**  STEP FOUR:  (optional) uncomment and set the IDBLOCK_VERSION  **/
/**      macro to a number from 1 through 4, inclusive.  0 is not  **/
/**      allowed; 1 is an ID Block with no User Block; 2 is an     **/
/**      unmirrored ID plus User Block; 3 and 4 are mirrored ID    **/
/**      plus User Blocks; 5 and greater are not allowed.          **/
/********************************************************************/


//#define	IDBLOCK_VERSION	2


/********************************************************************/
/**  END OF USER-CUSTOMIZABLE SECTION				                   **/
/********************************************************************/


// check for undefined register macros
//  (R2000C and up has these, prior R2000 versions always return 0s)


#ifndef GCPU
#define GCPU 0x2E
#endif


#ifndef GREV
#define GREV 0x2F
#endif


// check for several potential problems


#ifdef COMPILE_SECONDARY_PROG
#error "This utility is not intended for use as a secondary (DLP) program."
#error "Must remove COMPILE_SECONDARY_PROG macro from Compiler Options Defines box."
#error "Must also type Ctrl-Y to recompile the BIOS."
#endif


#ifdef COMPILE_PRIMARY_PROG
#error "This utility is not intended for use as a primary (DLM) program."
#error "Must remove COMPILE_PRIMARY_PROG macro from Compiler Options' Defines box."
#error "Must also type Ctrl-Y to recompile the BIOS."
#endif


#ifndef MYBOARD
#error "MYBOARD must be set to the proper board type."
#endif


#if (CC_VER < 0x0800)
	#if ((NUMUSER4KBLOCKS < 0) || (NUMUSER4KBLOCKS > 6))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -