Procházet zdrojové kódy

EEPROM dump (code D3)

Robert Pelnar před 5 roky
rodič
revize
691e7a24ed

+ 113 - 85
Firmware/Dcodes.cpp

@@ -1,33 +1,12 @@
 #include "Dcodes.h"
-#include "Marlin.h"
-
-#ifdef DEBUG_DCODES
-
-#include "ConfigurationStore.h"
+//#include "Marlin.h"
+#include "language.h"
 #include "cmdqueue.h"
-#include "pat9125.h"
-#include "adc.h"
-#include "temperature.h"
-#include <avr/wdt.h>
+#include <stdio.h>
+#include <avr/pgmspace.h>
 
 
-#define FLASHSIZE     0x40000
-
-#define RAMSIZE        0x2000
-#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
-
-extern uint8_t fsensor_log;
-extern float current_temperature_pinda;
-extern float axis_steps_per_unit[NUM_AXIS];
-
+#define DBG(args...) printf_P(args)
 
 inline void print_hex_nibble(uint8_t val)
 {
@@ -46,26 +25,18 @@ void print_hex_word(uint16_t val)
 	print_hex_byte(val & 255);
 }
 
-void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperline = 16)
+void print_eeprom(uint16_t address, uint16_t count, uint8_t countperline = 16)
 {
 	while (count)
 	{
-		if (type == 2)
-			print_hex_nibble(address >> 16);
 		print_hex_word(address);
 		putchar(' ');
 		uint8_t count_line = countperline;
 		while (count && count_line)
 		{
 			uint8_t data = 0;
-			switch (type)
-			{
-			case 0: data = *((uint8_t*)address++); break;
-			case 1: data = eeprom_read_byte((uint8_t*)address++); break;
-			case 2: data = pgm_read_byte_far((uint8_t*)address++); break;
-			}
 			putchar(' ');
-			print_hex_byte(data);
+			print_hex_byte(eeprom_read_byte((uint8_t*)address++));
 			count_line--;
 			count--;
 		}
@@ -73,9 +44,6 @@ void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperl
 	}
 }
 
-//#define LOG(args...) printf(args)
-#define LOG(args...)
-
 int parse_hex(char* hex, uint8_t* data, int count)
 {
 	int parsed = 0;
@@ -99,6 +67,112 @@ int parse_hex(char* hex, uint8_t* data, int count)
 	return parsed;
 }
 
+
+void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperline = 16)
+{
+	while (count)
+	{
+		if (type == 2)
+			print_hex_nibble(address >> 16);
+		print_hex_word(address);
+		putchar(' ');
+		uint8_t count_line = countperline;
+		while (count && count_line)
+		{
+			uint8_t data = 0;
+			switch (type)
+			{
+			case 0: data = *((uint8_t*)address++); break;
+			case 1: data = eeprom_read_byte((uint8_t*)address++); break;
+			case 2: data = pgm_read_byte_far((uint8_t*)address++); break;
+			}
+			putchar(' ');
+			print_hex_byte(data);
+			count_line--;
+			count--;
+		}
+		putchar('\n');
+	}
+}
+
+#ifdef DEBUG_DCODE3
+#define EEPROM_SIZE 0x1000
+void dcode_3()
+{
+	DBG(_N("D3 - Read/Write EEPROM\n"));
+	uint16_t address = 0x0000; //default 0x0000
+	uint16_t count = EEPROM_SIZE; //default 0x1000 (entire eeprom)
+	if (code_seen('A')) // Address (0x0000-0x0fff)
+		address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
+	if (code_seen('C')) // Count (0x0001-0x1000)
+		count = (int)code_value();
+	address &= 0x1fff;
+	if (count > EEPROM_SIZE) count = EEPROM_SIZE;
+	if ((address + count) > EEPROM_SIZE) count = EEPROM_SIZE - address;
+	if (code_seen('X')) // Data
+	{
+		uint8_t data[16];
+		count = parse_hex(strchr_pointer + 1, data, 16);
+		if (count > 0)
+		{
+			for (int i = 0; i < count; i++)
+				eeprom_write_byte((uint8_t*)(address + i), data[i]);
+			printf_P(_N("%d bytes written to EEPROM at address 0x%04x"), count, address);
+			putchar('\n');
+		}
+		else
+			count = 0;
+	}
+	print_mem(address, count, 1);
+/*	while (count)
+	{
+		print_hex_word(address);
+		putchar(' ');
+		uint8_t countperline = 16;
+		while (count && countperline)
+		{
+			uint8_t data = eeprom_read_byte((uint8_t*)address++);
+			putchar(' ');
+			print_hex_byte(data);
+			countperline--;
+			count--;
+		}
+		putchar('\n');
+	}*/
+}
+#endif //DEBUG_DCODE3
+
+#ifdef DEBUG_DCODES
+
+#include "ConfigurationStore.h"
+#include "cmdqueue.h"
+#include "pat9125.h"
+#include "adc.h"
+#include "temperature.h"
+#include <avr/wdt.h>
+
+
+#define FLASHSIZE     0x40000
+
+#define RAMSIZE        0x2000
+#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
+
+extern uint8_t fsensor_log;
+extern float current_temperature_pinda;
+extern float axis_steps_per_unit[NUM_AXIS];
+
+
+//#define LOG(args...) printf(args)
+#define LOG(args...)
+
 void dcode__1()
 {
 	printf("D-1 - Endless loop\n");
@@ -177,52 +251,6 @@ void dcode_2()
 	}*/
 }
 
-void dcode_3()
-{
-	LOG("D3 - Read/Write EEPROM\n");
-	uint16_t address = 0x0000; //default 0x0000
-	uint16_t count = 0x2000; //default 0x2000 (entire eeprom)
-	if (code_seen('A')) // Address (0x0000-0x1fff)
-		address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
-	if (code_seen('C')) // Count (0x0001-0x2000)
-		count = (int)code_value();
-	address &= 0x1fff;
-	if (count > 0x2000) count = 0x2000;
-	if ((address + count) > 0x2000) count = 0x2000 - address;
-	if (code_seen('X')) // Data
-	{
-		uint8_t data[16];
-		count = parse_hex(strchr_pointer + 1, data, 16);
-		if (count > 0)
-		{
-			for (int i = 0; i < count; i++)
-				eeprom_write_byte((uint8_t*)(address + i), data[i]);
-			LOG(count, DEC);
-			LOG(" bytes written to EEPROM at address ");
-			print_hex_word(address);
-			putchar('\n');
-		}
-		else
-			count = 0;
-	}
-	print_mem(address, count, 1);
-/*	while (count)
-	{
-		print_hex_word(address);
-		putchar(' ');
-		uint8_t countperline = 16;
-		while (count && countperline)
-		{
-			uint8_t data = eeprom_read_byte((uint8_t*)address++);
-			putchar(' ');
-			print_hex_byte(data);
-			countperline--;
-			count--;
-		}
-		putchar('\n');
-	}*/
-}
-
 void dcode_4()
 {
 	LOG("D4 - Read/Write PIN\n");

+ 6 - 2
Firmware/Marlin_main.cpp

@@ -7125,11 +7125,11 @@ while (!lcd_clicked() && (counterBeep < 50)) {
 	  }
   } // end if(code_seen('T')) (end of T codes)
 
-#ifdef DEBUG_DCODES
   else if (code_seen('D')) // D codes (debug)
   {
     switch((int)code_value())
     {
+#ifdef DEBUG_DCODES
 	case -1: // D-1 - Endless loop
 		dcode__1(); break;
 	case 0: // D0 - Reset
@@ -7138,8 +7138,12 @@ while (!lcd_clicked() && (counterBeep < 50)) {
 		dcode_1(); break;
 	case 2: // D2 - Read/Write RAM
 		dcode_2(); break;
+#endif //DEBUG_DCODES
+#ifdef DEBUG_DCODE3
 	case 3: // D3 - Read/Write EEPROM
 		dcode_3(); break;
+#endif //DEBUG_DCODE3
+#ifdef DEBUG_DCODES
 	case 4: // D4 - Read/Write PIN
 		dcode_4(); break;
 	case 5: // D5 - Read/Write FLASH
@@ -7168,9 +7172,9 @@ while (!lcd_clicked() && (counterBeep < 50)) {
 		dcode_9125(); break;
 #endif //FILAMENT_SENSOR
 
+#endif //DEBUG_DCODES
 	}
   }
-#endif //DEBUG_DCODES
 
   else
   {

+ 1 - 0
Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h

@@ -113,6 +113,7 @@
 #define PAT9125
 #define FILAMENT_SENSOR
 
+#define DEBUG_DCODE3
 
 //#define DEBUG_BUILD
 #ifdef DEBUG_BUILD

+ 1 - 0
Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h

@@ -114,6 +114,7 @@
 #define PAT9125
 #define FILAMENT_SENSOR
 
+#define DEBUG_DCODE3
 
 //#define DEBUG_BUILD
 #ifdef DEBUG_BUILD

+ 2 - 0
Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h

@@ -147,6 +147,8 @@
 #define MINTEMP_MINAMBIENT      25
 #define MINTEMP_MINAMBIENT_RAW  978
 
+#define DEBUG_DCODE3
+
 //#define DEBUG_BUILD
 //#define DEBUG_SEC_LANG   //secondary language debug output at startup
 //#define DEBUG_W25X20CL   //debug external spi flash