Browse Source

xfdump: reuse standard definitions for SRAM size/offset

Yuri D'Elia 2 years ago
parent
commit
c331c07b16
4 changed files with 8 additions and 10 deletions
  1. 1 1
      Firmware/Dcodes.cpp
  2. 2 1
      Firmware/bootapp.h
  3. 2 3
      Firmware/xflash_dump.cpp
  4. 3 5
      Firmware/xflash_layout.h

+ 1 - 1
Firmware/Dcodes.cpp

@@ -278,7 +278,7 @@ void dcode_1()
     */
 void dcode_2()
 {
-    dcode_core(SRAM_START, SRAM_START + SRAM_SIZE, dcode_mem_t::sram, 2, _N("SRAM"));
+    dcode_core(RAMSTART, RAMEND, dcode_mem_t::sram, 2, _N("SRAM"));
 }
 #endif
 

+ 2 - 1
Firmware/bootapp.h

@@ -3,10 +3,11 @@
 #define BOOTAPP_H
 
 #include "config.h"
+#include <avr/io.h>
 #include <inttypes.h>
 
 
-#define RAMSIZE        0x2000
+#define RAMSIZE        (RAMEND-RAMSTART)
 #define boot_src_addr  (*((uint32_t*)(RAMSIZE - 16)))
 #define boot_dst_addr  (*((uint32_t*)(RAMSIZE - 12)))
 #define boot_copy_size (*((uint16_t*)(RAMSIZE - 8)))

+ 2 - 3
Firmware/xflash_dump.cpp

@@ -83,7 +83,7 @@ void xfdump_dump()
 
     // write sram only
     xfdump_dump_core(buf, DUMP_OFFSET + offsetof(dump_t, data.sram),
-                     (uint8_t*)SRAM_START, SRAM_SIZE);
+                     (uint8_t*)RAMSTART, RAMSIZE);
 }
 
 
@@ -98,8 +98,7 @@ void xfdump_full_dump_and_reset(bool crash)
     cli();
 
     // write all addressable ranges (this will trash bidirectional registers)
-    xfdump_dump_core(buf, DUMP_OFFSET + offsetof(dump_t, data),
-                     0, SRAM_START + SRAM_SIZE);
+    xfdump_dump_core(buf, DUMP_OFFSET + offsetof(dump_t, data), 0, RAMEND);
 
     // force a reset soon
     wdt_enable(0);

+ 3 - 5
Firmware/xflash_layout.h

@@ -1,12 +1,10 @@
 // XFLASH memory layout
 #pragma once
 #include <stdint.h>
+#include "bootapp.h"
 #include "config.h"
 
 #define XFLASH_SIZE 0x40000ul // size of XFLASH
-#define SRAM_SIZE   0x2000u   // size of SRAM
-#define SRAM_START  0x200u    // start of SRAM
-
 #define LANG_OFFSET 0x0       // offset for language data
 
 #ifndef XFLASH_DUMP
@@ -28,8 +26,8 @@ struct dump_header_t
 struct dump_data_t
 {
     // contiguous region containing all addressable ranges
-    uint8_t regs[SRAM_START];
-    uint8_t sram[SRAM_SIZE];
+    uint8_t regs[RAMSTART];
+    uint8_t sram[RAMSIZE];
 };
 
 struct dump_t