; *************************************************************************** ; copyright : (C) 2025 by Martin Preuss ; email : martin@libchipcard.de ; ; *************************************************************************** ; * This file is part of the project "AqHome". * ; * Please see toplevel file COPYING of that project for license details. * ; *************************************************************************** ; *************************************************************************** ; data .dseg flashDataBegin: flashUid: .byte 4 flashSendBuffer: .byte 32 flashRecvBuffer: .byte FLASH_RECVBUFFER_MAXLEN flashDataEnd: ; *************************************************************************** ; code .cseg FLASH_PROTO_BEGIN: bootLoader: ; rcall watchdogOff ; turn off watchdog timer (sometimes it stays on after reboot) sbi LED_DDR, LED_PINNUM ; out cbi LED_PORT, LED_PINNUM ; on ldi r16, 30 rcall flashWaitForMulti100ms rcall flashReadUidIntoSdram ; R16, X, Y rcall checkFlash ; (r16, r17, r18, r19, r20, r22, x, y, z) brcc bootLoader_startFirmware ; no flash process, try to start installed firmware rcall flashProcess ; received a FLASH START msg, handle flashing brcc bootLoader_waitAndRestartBootLoader ; try to start firmware bootLoader_startFirmware: cbi LED_PORT, LED_PINNUM ; on rjmp firmwareStart bootLoader_waitAndRestartBootLoader: sbi LED_PORT, LED_PINNUM ; off ldi r16, 20 rcall flashWaitForMulti100ms rjmp bootLoader bootClcRet: clc bootRet: ret bootSecRet: sec ret FLASH_PROTO_END: .equ MODULE_SIZE_FLASH_PROTO = FLASH_PROTO_END-FLASH_PROTO_BEGIN