New ML support - bootloader support and update proces test
This commit is contained in:
parent
0ddb31d4eb
commit
4746c77195
5 changed files with 104 additions and 1 deletions
|
@ -970,6 +970,35 @@ void erase_eeprom_section(uint16_t offset, uint16_t bytes)
|
|||
for (int i = offset; i < (offset+bytes); i++) eeprom_write_byte((uint8_t*)i, 0xFF);
|
||||
}
|
||||
|
||||
#include "bootapp.h"
|
||||
|
||||
void __test()
|
||||
{
|
||||
cli();
|
||||
boot_app_magic = 0x55aa55aa;
|
||||
boot_app_flags = BOOT_APP_FLG_USER0;
|
||||
boot_reserved = 0x00;
|
||||
wdt_enable(WDTO_15MS);
|
||||
while(1);
|
||||
}
|
||||
|
||||
void upgrade_sec_lang_from_external_flash()
|
||||
{
|
||||
if ((boot_app_magic == 0x55aa55aa) && (boot_app_flags & BOOT_APP_FLG_USER0))
|
||||
{
|
||||
fprintf_P(lcdout, PSTR(ESC_2J ESC_H(1,1) "TEST %d"), boot_reserved);
|
||||
boot_reserved++;
|
||||
if (boot_reserved < 4)
|
||||
{
|
||||
_delay_ms(1000);
|
||||
cli();
|
||||
wdt_enable(WDTO_15MS);
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
boot_app_flags &= ~BOOT_APP_FLG_USER0;
|
||||
}
|
||||
|
||||
// "Setup" function is called by the Arduino framework on startup.
|
||||
// Before startup, the Timers-functions (PWM)/Analog RW and HardwareSerial provided by the Arduino-code
|
||||
// are initialized by the main() routine provided by the Arduino framework.
|
||||
|
@ -977,6 +1006,9 @@ void setup()
|
|||
{
|
||||
lcd_init();
|
||||
fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream
|
||||
|
||||
// upgrade_sec_lang_from_external_flash();
|
||||
|
||||
lcd_splash();
|
||||
setup_killpin();
|
||||
setup_powerhold();
|
||||
|
|
32
Firmware/bootapp.c
Normal file
32
Firmware/bootapp.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
//bootapp.c
|
||||
#include "bootapp.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
|
||||
/*
|
||||
void bootapp_print_vars()
|
||||
{
|
||||
printf_P(_n("boot_src_addr =0x%08lx\n"), boot_src_addr);
|
||||
printf_P(_n("boot_dst_addr =0x%08lx\n"), boot_dst_addr);
|
||||
printf_P(_n("boot_copy_size =0x%04x\n"), boot_copy_size);
|
||||
printf_P(_n("boot_reserved =0x%02x\n"), boot_reserved);
|
||||
printf_P(_n("boot_app_flags =0x%02x\n"), boot_app_flags);
|
||||
printf_P(_n("boot_app_magic =0x%08lx\n"), boot_app_magic);
|
||||
}
|
||||
*/
|
||||
|
||||
void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
|
||||
{
|
||||
cli();
|
||||
// uint16_t ui; for (ui = 0; ui < size; ui++)
|
||||
// ram_array[ui+rptr] = 0xff;
|
||||
boot_app_magic = 0x55aa55aa;
|
||||
boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY;
|
||||
boot_copy_size = (uint16_t)size;
|
||||
boot_src_addr = (uint32_t)rptr;
|
||||
boot_dst_addr = (uint32_t)fptr;
|
||||
wdt_enable(WDTO_15MS);
|
||||
while(1);
|
||||
}
|
36
Firmware/bootapp.h
Normal file
36
Firmware/bootapp.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
//language.h
|
||||
#ifndef BOOTAPP_H
|
||||
#define BOOTAPP_H
|
||||
|
||||
#include "config.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
#define RAMSIZE 0x2000
|
||||
#define ram_array ((uint8_t*)(0))
|
||||
#define boot_src_addr (*((uint32_t*)(RAMSIZE - 16)))
|
||||
#define boot_dst_addr (*((uint32_t*)(RAMSIZE - 12)))
|
||||
#define boot_copy_size (*((uint16_t*)(RAMSIZE - 8)))
|
||||
#define boot_reserved (*((uint8_t*)(RAMSIZE - 6)))
|
||||
#define boot_app_flags (*((uint8_t*)(RAMSIZE - 5)))
|
||||
#define boot_app_magic (*((uint32_t*)(RAMSIZE - 4)))
|
||||
#define BOOT_APP_FLG_ERASE 0x01
|
||||
#define BOOT_APP_FLG_COPY 0x02
|
||||
#define BOOT_APP_FLG_FLASH 0x04
|
||||
|
||||
#define BOOT_APP_FLG_USER0 0x80
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif //defined(__cplusplus)
|
||||
|
||||
|
||||
extern void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif //defined(__cplusplus)
|
||||
|
||||
#endif //BOOTAPP_H
|
|
@ -2,6 +2,7 @@
|
|||
#include "language.h"
|
||||
#include <inttypes.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "bootapp.h"
|
||||
|
||||
|
||||
// Currectly active language selection.
|
||||
|
@ -93,3 +94,4 @@ const char* lang_get_name(unsigned char lang)
|
|||
}
|
||||
|
||||
const char MSG_LANGUAGE_NAME[] PROGMEM_I1 = ISTR("English"); ////c=0 r=0
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ extern const char* lang_select(unsigned char lang);
|
|||
extern unsigned char lang_get_count();
|
||||
extern const char* lang_get_name(unsigned char lang);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif //defined(__cplusplus)
|
||||
|
@ -88,5 +89,5 @@ extern const char MSG_LANGUAGE_NAME[];
|
|||
#include "messages.h"
|
||||
|
||||
|
||||
#endif //__LANGUAGE_H
|
||||
#endif //LANGUAGE_H
|
||||
|
||||
|
|
Loading…
Reference in a new issue