From ac18eb67c0a7e4f1d3b45b3689d0b92c1984936e Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Thu, 18 Oct 2018 16:20:14 +0200 Subject: [PATCH] New lang, arduino 1.8.5 - boot_app debug output + variable _uartout linkage fix + DEBUG_DCODE5 --- Firmware/Dcodes.cpp | 28 +++++++++++++++------------- Firmware/Marlin.h | 3 +++ Firmware/Marlin_main.cpp | 11 ++++++++--- Firmware/bootapp.c | 23 ++++++++++++++--------- Firmware/bootapp.h | 1 + 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index d1ddc61e..887d61de 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -142,7 +142,6 @@ void dcode_3() } #endif //DEBUG_DCODE3 -#ifdef DEBUG_DCODES #include "ConfigurationStore.h" #include "cmdqueue.h" @@ -150,8 +149,9 @@ void dcode_3() #include "adc.h" #include "temperature.h" #include +#include "bootapp.h" - +/* #define FLASHSIZE 0x40000 #define RAMSIZE 0x2000 @@ -172,6 +172,8 @@ extern float axis_steps_per_unit[NUM_AXIS]; //#define LOG(args...) printf(args) #define LOG(args...) +*/ +#ifdef DEBUG_DCODES void dcode__1() { @@ -279,10 +281,13 @@ void dcode_4() } } } -/* +#endif //DEBUG_DCODES + +#ifdef DEBUG_DCODE5 + void dcode_5() { - LOG("D5 - Read/Write FLASH\n"); + printf_P(PSTR("D5 - Read/Write FLASH\n")); uint32_t address = 0x0000; //default 0x0000 uint16_t count = 0x0400; //default 0x0400 (1kb block) if (code_seen('A')) // Address (0x00000-0x3ffff) @@ -306,17 +311,11 @@ void dcode_5() { if (bErase) { - LOG(count, DEC); - LOG(" bytes of FLASH at address "); - print_hex_word(address); - putchar(" will be erased\n"); + printf_P(PSTR("%d bytes of FLASH at address %05x will be erased\n"), count, address); } if (bCopy) { - LOG(count, DEC); - LOG(" bytes will be written to FLASH at address "); - print_hex_word(address); - putchar('\n'); + printf_P(PSTR("%d bytes will be written to FLASH at address %05x\n"), count, address); } cli(); boot_app_magic = 0x55aa55aa; @@ -324,6 +323,7 @@ void dcode_5() boot_copy_size = (uint16_t)count; boot_dst_addr = (uint32_t)address; boot_src_addr = (uint32_t)(&data); + bootapp_print_vars(); wdt_enable(WDTO_15MS); while(1); } @@ -344,7 +344,9 @@ void dcode_5() putchar('\n'); } } -*/ +#endif //DEBUG_DCODE5 + +#ifdef DEBUG_DCODES void dcode_6() { diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 13f04557..2b82d7de 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -64,7 +64,10 @@ #include "lcd.h" +extern "C" { extern FILE _uartout; +} + #define uartout (&_uartout) #define SERIAL_PROTOCOL(x) (MYSERIAL.print(x)) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 7d9cc2e4..f2a235e1 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -920,8 +920,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) } - +extern "C" { FILE _uartout = {0}; +} int uart_putchar(char c, FILE *stream) { @@ -1575,7 +1576,7 @@ void setup() uint16_t ui = _SEC_LANG_TABLE; //table pointer printf_P(_n("lang_selected=%d\nlang_table=0x%04x\nSEC_LANG_CODE=0x%04x (%c%c)\n"), lang_selected, ui, sec_lang_code, sec_lang_code >> 8, sec_lang_code & 0xff); -// lang_print_sec_lang(uartout); + lang_print_sec_lang(uartout); #endif //DEBUG_SEC_LANG #endif //(LANG_MODE != 0) @@ -6959,9 +6960,13 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) #ifdef DEBUG_DCODES case 4: // D4 - Read/Write PIN dcode_4(); break; +#endif //DEBUG_DCODES +#ifdef DEBUG_DCODE5 case 5: // D5 - Read/Write FLASH -// dcode_5(); break; + dcode_5(); break; break; +#endif //DEBUG_DCODE5 +#ifdef DEBUG_DCODES case 6: // D6 - Read/Write external FLASH dcode_6(); break; case 7: // D7 - Read/Write Bootloader diff --git a/Firmware/bootapp.c b/Firmware/bootapp.c index 5b5f8dbf..4fd67db2 100644 --- a/Firmware/bootapp.c +++ b/Firmware/bootapp.c @@ -5,17 +5,20 @@ #include -/* -void bootapp_print_vars() +#include +extern FILE _uartout; +#define uartout (&_uartout) + +void bootapp_print_vars(void) { - 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); + 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); } -*/ + void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size) { @@ -35,6 +38,7 @@ void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size) boot_copy_size = (uint16_t)size; boot_src_addr = (uint32_t)rptr; boot_dst_addr = (uint32_t)fptr; + bootapp_print_vars(); wdt_enable(WDTO_15MS); while(1); } @@ -45,6 +49,7 @@ void bootapp_reboot_user0(uint8_t reserved) boot_app_magic = BOOT_APP_MAGIC; boot_app_flags = BOOT_APP_FLG_USER0; boot_reserved = reserved; + bootapp_print_vars(); wdt_enable(WDTO_15MS); while(1); } diff --git a/Firmware/bootapp.h b/Firmware/bootapp.h index cbae89a7..3fb0306a 100644 --- a/Firmware/bootapp.h +++ b/Firmware/bootapp.h @@ -28,6 +28,7 @@ extern "C" { #endif //defined(__cplusplus) +extern void bootapp_print_vars(void); extern void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size);