Browse Source

New lang, arduino 1.8.5 - boot_app debug output
+ variable _uartout linkage fix
+ DEBUG_DCODE5

Robert Pelnar 5 years ago
parent
commit
ac18eb67c0
5 changed files with 41 additions and 25 deletions
  1. 15 13
      Firmware/Dcodes.cpp
  2. 3 0
      Firmware/Marlin.h
  3. 8 3
      Firmware/Marlin_main.cpp
  4. 14 9
      Firmware/bootapp.c
  5. 1 0
      Firmware/bootapp.h

+ 15 - 13
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 <avr/wdt.h>
+#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()
 {

+ 3 - 0
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))

+ 8 - 3
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

+ 14 - 9
Firmware/bootapp.c

@@ -5,17 +5,20 @@
 #include <avr/interrupt.h>
 
 
-/*
-void bootapp_print_vars()
+#include <stdio.h>
+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);
 }

+ 1 - 0
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);