2018-05-29 19:03:47 +00:00
|
|
|
//bootapp.c
|
|
|
|
#include "bootapp.h"
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include <avr/wdt.h>
|
|
|
|
#include <avr/interrupt.h>
|
|
|
|
|
|
|
|
|
2018-10-18 14:20:14 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
extern FILE _uartout;
|
|
|
|
#define uartout (&_uartout)
|
|
|
|
|
2020-08-12 09:46:35 +00:00
|
|
|
extern void softReset();
|
|
|
|
|
2018-10-18 14:20:14 +00:00
|
|
|
void bootapp_print_vars(void)
|
2018-05-29 19:03:47 +00:00
|
|
|
{
|
2018-10-18 14:20:14 +00:00
|
|
|
fprintf_P(uartout, PSTR("boot_src_addr =0x%08lx\n"), boot_src_addr);
|
|
|
|
fprintf_P(uartout, PSTR("boot_dst_addr =0x%08lx\n"), boot_dst_addr);
|
|
|
|
fprintf_P(uartout, PSTR("boot_copy_size =0x%04x\n"), boot_copy_size);
|
|
|
|
fprintf_P(uartout, PSTR("boot_reserved =0x%02x\n"), boot_reserved);
|
|
|
|
fprintf_P(uartout, PSTR("boot_app_flags =0x%02x\n"), boot_app_flags);
|
|
|
|
fprintf_P(uartout, PSTR("boot_app_magic =0x%08lx\n"), boot_app_magic);
|
2018-05-29 19:03:47 +00:00
|
|
|
}
|
2018-10-18 14:20:14 +00:00
|
|
|
|
2018-05-29 19:03:47 +00:00
|
|
|
|
|
|
|
void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
|
|
|
|
{
|
|
|
|
cli();
|
2018-06-08 23:23:04 +00:00
|
|
|
boot_app_magic = BOOT_APP_MAGIC;
|
2018-05-30 17:29:52 +00:00
|
|
|
boot_app_flags |= BOOT_APP_FLG_COPY;
|
2018-06-09 15:49:41 +00:00
|
|
|
boot_app_flags |= BOOT_APP_FLG_ERASE;
|
2018-05-29 19:03:47 +00:00
|
|
|
boot_copy_size = (uint16_t)size;
|
|
|
|
boot_src_addr = (uint32_t)rptr;
|
|
|
|
boot_dst_addr = (uint32_t)fptr;
|
2018-10-18 14:20:14 +00:00
|
|
|
bootapp_print_vars();
|
2020-08-12 09:46:35 +00:00
|
|
|
softReset();
|
2018-05-29 19:03:47 +00:00
|
|
|
}
|
2018-06-09 17:16:36 +00:00
|
|
|
|
|
|
|
void bootapp_reboot_user0(uint8_t reserved)
|
|
|
|
{
|
|
|
|
cli();
|
|
|
|
boot_app_magic = BOOT_APP_MAGIC;
|
|
|
|
boot_app_flags = BOOT_APP_FLG_USER0;
|
|
|
|
boot_reserved = reserved;
|
2018-10-18 14:20:14 +00:00
|
|
|
bootapp_print_vars();
|
2020-08-12 09:46:35 +00:00
|
|
|
softReset();
|
2018-06-09 17:16:36 +00:00
|
|
|
}
|