||| v7: (12.08.2019) AVRco 5.10.01 Optimizer 3.6.5.0 ||| Changed bootloaderId and version ||| Deleted FlashCheck_A, because it overwrites the app's checksum in hex file ||| Changed BOD level to 2.8V program boot; Device = xmega128A4U, VCC = 3.3; {$BootApplication} Define_Fuses Override_Fuses; // update ispe file //COMport = USB; //ProgMode = PDI; //LockBits0 = [BLBB0, BLBB1, LB0, LB1]; // protect boot and app against read back FuseBits0 = []; FuseBits1 = [WDPER0, WDPER2]; // watchdog = 8s FuseBits2 = [BOOTRST]; // mandatory for bootloader FuseBits4 = [WDLOCK]; FuseBits5 = [BODACT0, BODLEVEL1, BODLEVEL2]; // BOD = 2.8V progFuses = true; progEEPROM = true; AddApp = '..\app\udac'; // use batch file if addApp does not work // addApp fails without a message Import FlashWrite, FAT_BootX, SerPortE0; From System Import LongWord, Traps; Define OSCtype = int32MHz; // default StackSize = $100, iData; FrameSize = $200, iData; SerPortE0 = 115200, Stop1; // debug connection FAT_BootPort = SPI_D, PortD.4; FAT_BootMode = plain; // plain or AES FAT_BootFile = 'UDAC'; uses uFAT_BootX; Implementation {$EEPROM} structconst EE_bootMe[eepromEnd] : byte = $00; // jump to app after programming the pac file to // prevent downgrade if an old udac.dld exist on card // after flashing pac file {$IDATA} const BootLoaderVersion : word = 7; BootLoaderID : word = 8323; // must be equal to Application's ID {--------------------------------------------------------------} {$VALIDATE $} // no optimise function trap_getBootLoaderID : word; Trap; begin return (BootLoaderID); end; {$VALIDATE $} // no optimise function trap_getBootVersion : word; Trap; begin return (BootLoaderVersion); end; {--------------------------------------------------------------} { Main Program } begin Writeln(SeroutE0, 'Boot loader v' + IntToStr(BootLoaderVersion) + ' ID = ' + IntToStr(BootLoaderID)); if EEprom[EEpromEnd] <> $FF then Writeln(SeroutE0, 'Jump to main'); mDelay(1); // for writeln Application_Startup; endif; mDelay(250); // ensure power stabilisation { // card detection DIRCLRD := $10; // CS to input mDelay(1); if (PIND and $10) = 0 then Writeln(SeroutE0, 'SD ejected'); Application_Startup; endif; DIRSETD := $10; // CS to output mDelay(250); } if not FATInit then Writeln(SeroutE0, 'FAT failed'); Application_Startup(); endif; // This reads the UpdateFile and flashes it into the application area. // If selected then also EEprom and UserRow are reprogrammed. // The filename can have upto 8 chars, the extension must be ".dld"! // The extension must not be included and is always ".dld" Writeln(SeroutE0, 'Start Update'); UpdateFirmware(BootLoaderID); // in case of error Writeln(SeroutE0, 'Update failed, Err = ' + ByteToStr(BootErr)); Application_Startup; // EEpromEnd is cleared by App after flash verification loop endloop; end boot.