#include <hidef.h>#include <start08.h>#include <checksum.h>#include "derivative.h"_CHECKSUM_STARTUP_ENTRY......void main(void){ __RESET_WATCHDOG(); while(__CHECKSUM_IS_OK != 1) __RESET_WATCHDOG(); ... ... }
_CHECKSUM_STARTUP_ENTRY has to be added in (a copy of) start08.h, not in main.c.
#include <hidef.h> /* for EnableInterrupts macro */#include <string.h>#include "checksum.h"#include "Start08.h"#include "derivative.h"
#define __NO_FLAGS_OFFSET /* we do not need the flags field in the startup data descriptor */#define __NO_MAIN_OFFSET /* we do not need the main field in the startup data descriptor */#include "Start08.h"
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */ Z_RAM = READ_WRITE 0x0060 TO 0x00FF; // 160 byte RAM = READ_WRITE 0x0100 TO 0x085F; // 1888 byte NO_INIT_RAM_SEG = NO_INIT 0x0860 TO 0x0C5F; // 1024 byte MY_STK = NO_INIT 0x0C60 TO 0x105F; // 1024 byte NV_SAVE_SEG = READ_ONLY 0x1060 TO 0x13FF FILL 0x8D; // reserve 928 (512) byte for NV ROM1 = READ_ONLY 0x1400 TO 0x17FF FILL 0x8D; ROM = READ_ONLY 0x1870 TO 0xFEAF FILL 0x8D; FLASH_ROUTINE_SEG = READ_ONLY 0xFEB0 TO 0xFFAF FILL 0x8D; ROM2 = READ_ONLY 0xFFC0 TO 0xFFD1 FILL 0x8D; INTVECT = READ_ONLY 0xFFD2 TO 0xFFFF FILL 0x8D;// Reserved for Int. Vectors*/ENDPLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */ _DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM; DEFAULT_RAM INTO RAM; NO_INIT_RAM INTO NO_INIT_RAM_SEG; SSTACK INTO MY_STK; NV_SAVE_AREA INTO NV_SAVE_SEG; FLASH_ROUTINE_AREA INTO FLASH_ROUTINE_SEG; _PRESTART, STARTUP, DEFAULT_ROM, ROM_VAR, STRINGS, COPY, .checksum INTO ROM, ROM1; /* ROM1,ROM2 In case you want to use ROM1,ROM2 as well, be sure the option -OnB=b is passed to the compiler. */END
*********************************************************************************************SECTION-ALLOCATION SECTIONSection Name Size Type From To Segment---------------------------------------------------------------------------------------------FLASH_ROUTINE_AREA 210 R 0xFEB0 0xFF81 FLASH_ROUTINE_SEG.init 132 R 0x1870 0x18F3 ROM.startData 18 R 0x18F4 0x1905 ROM.text 54720 R 0x1906 0xEEC5 ROM.rodata 1221 R 0xEEC6 0xF38A ROM.rodata1 930 R 0xF38B 0xF72C ROM.copy 35 R 0xF72D 0xF74F ROM.checksum 36 R 0xF750 0xF773 ROM.abs_section_ffbd 1 R 0xFFBD 0xFFBD .absSeg128.abs_section_ffbf 1 R 0xFFBF 0xFFBF .absSeg129.abs_section_ffd6 2 R 0xFFD6 0xFFD7 .absSeg130.abs_section_ffd8 2 R 0xFFD8 0xFFD9 .absSeg131.abs_section_ffda 2 R 0xFFDA 0xFFDB .absSeg132.abs_section_ffdc 2 R 0xFFDC 0xFFDD .absSeg133.abs_section_ffe8 2 R 0xFFE8 0xFFE9 .absSeg134.abs_section_ffe6 2 R 0xFFE6 0xFFE7 .absSeg135.abs_section_ffec 2 R 0xFFEC 0xFFED .absSeg136.abs_section_ffee 2 R 0xFFEE 0xFFEF .absSeg137.abs_section_fff2 2 R 0xFFF2 0xFFF3 .absSeg138.abs_section_fff4 2 R 0xFFF4 0xFFF5 .absSeg139.abs_section_fff8 2 R 0xFFF8 0xFFF9 .absSeg140.abs_section_fffa 2 R 0xFFFA 0xFFFB .absSeg141.abs_section_fffc 2 R 0xFFFC 0xFFFD .absSeg142.abs_section_ffd2 2 R 0xFFD2 0xFFD3 .absSeg143.abs_section_fff6 2 R 0xFFF6 0xFFF7 .absSeg144.abs_section_ffd4 2 R 0xFFD4 0xFFD5 .absSeg145.abs_section_fff0 2 R 0xFFF0 0xFFF1 .absSeg146.abs_section_ffea 2 R 0xFFEA 0xFFEB .absSeg147.abs_section_ffe2 2 R 0xFFE2 0xFFE3 .absSeg148.abs_section_ffe0 2 R 0xFFE0 0xFFE1 .absSeg149.abs_section_ffe4 2 R 0xFFE4 0xFFE5 .absSeg150.abs_section_ffde 2 R 0xFFDE 0xFFDF .absSeg151INTVECT_vect 46 R 0xFFD2 0xFFFF INTVECTNV_SAVE_SEG_152 928 R 0x1060 0x13FF NV_SAVE_SEGROM1_153 1024 R 0x1400 0x17FF ROM1ROM_154 1852 R 0xF774 0xFEAF ROMFLASH_ROUTINE_SEG_155 46 R 0xFF82 0xFFAF FLASH_ROUTINE_SEGSummary of section sizes per section type:READ_ONLY (R): EF3C (dec: 61244)
INTVECT_vect 46 R 0xFFD2 0xFFFF INTVECT.abs_section_ffd2 2 R 0xFFD2 0xFFD3 .absSeg143
/* Block Protection Disabled */const unsigned char NVPROT_INIT @0x0000FFBD = 0b11111111;/* NVOPT: KEYEN=0,FNORED=1,??=1,??=1,??=1,??=1,SEC01=0,SEC00=1 *//* Backdoor Key disabled, no vector redirection, MCU is unsecure */const unsigned char NVOPT_INIT @0x0000FFBF = 0b01000010; // CyclonePro makes it secure after programming!