From 6c126cbd196c0d0878eb01323e46ee6543749648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20L=C3=A1ska?= Date: Thu, 7 Apr 2022 16:05:17 +0200 Subject: [PATCH 1/2] Implemented load of osccal value (draft) --- optiboot/bootloaders/optiboot/optiboot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/optiboot/bootloaders/optiboot/optiboot.c b/optiboot/bootloaders/optiboot/optiboot.c index dec9c45ed..ee2a5e360 100644 --- a/optiboot/bootloaders/optiboot/optiboot.c +++ b/optiboot/bootloaders/optiboot/optiboot.c @@ -694,13 +694,17 @@ void pre_main(void) { // entry to this function will always be here, independent of // compilation, features etc asm volatile ( - " rjmp 1f\n" + " rjmp start_main\n" #if APP_NOSPM " ret\n" // if do_spm isn't include, return without doing anything #else " rjmp do_spm\n" #endif - "1:\n" + "set_osccal:\n" // start_main must difer only by extra 1s, so they can be overwritten to 0s after calibration is done. Here is rjmp is set default to 0x05 and would overwrite to 0x01. + " nop\n" + " ldi r24, 0xFF\n" + " sts 0x0066, r24\n" + "start_main:\n" ); } From 1b609bb3c6397bbafa2e3fbf18626ddf344a748b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20L=C3=A1ska?= Date: Tue, 12 Apr 2022 14:25:37 +0200 Subject: [PATCH 2/2] Updated calibration procedure to use OSCCAL from defines to correct support different platforms. --- optiboot/bootloaders/optiboot/optiboot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/optiboot/bootloaders/optiboot/optiboot.c b/optiboot/bootloaders/optiboot/optiboot.c index ee2a5e360..c5d5e9232 100644 --- a/optiboot/bootloaders/optiboot/optiboot.c +++ b/optiboot/bootloaders/optiboot/optiboot.c @@ -703,8 +703,9 @@ void pre_main(void) { "set_osccal:\n" // start_main must difer only by extra 1s, so they can be overwritten to 0s after calibration is done. Here is rjmp is set default to 0x05 and would overwrite to 0x01. " nop\n" " ldi r24, 0xFF\n" - " sts 0x0066, r24\n" + " sts %[osccal_reg], r24\n" "start_main:\n" + : : [osccal_reg] "M" (_SFR_MEM_ADDR(OSCCAL)) : "r24" ); }