3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * \email daniel.otte@rub.de
24 * \license GPLv3 or later
33 #include <avr/pgmspace.h>
35 #include "string-extras.h"
40 void dump_chars(uint8_t* buffer){
43 for(i=0; i<DUMP_WIDTH; ++i){
44 if(isprint(buffer[i])){
58 uint8_t i,buffer[DUMP_WIDTH];
61 if(*s=='r' || *s=='R' || *s=='m' || *s=='M')
69 addr = strtoul(s, &eptr, 0);
71 size = strtoul(eptr, NULL, 0);
75 cli_putstr_P(PSTR("\r\ndumping "));
76 ultoa(size, tstr, 10);
78 cli_putstr_P(PSTR(" bytes of "));
79 cli_putstr_P(flash?PSTR("flash"):PSTR("ram"));
80 cli_putstr_P(PSTR(", beginning at 0x"));
81 ultoa(addr, tstr, 16);
83 cli_putstr_P(PSTR(":\r\n"));
84 while(size>=DUMP_WIDTH){
86 for(i=0; i<DUMP_WIDTH; ++i){
87 #ifdef pgm_read_byte_far
88 buffer[i]=pgm_read_byte_far(addr+i);
90 buffer[i]=pgm_read_byte(addr+i);
94 memcpy(buffer, (void*)((uint16_t)addr), DUMP_WIDTH);
96 ultoa(addr, tstr, 16);
97 sprintf(tstr,"%6lX", addr);
99 cli_putstr_P(PSTR(": "));
100 cli_hexdump2(buffer, DUMP_WIDTH);
105 cli_putstr_P(PSTR("\r\n"));
109 for(i=0; i<size; ++i){
110 #ifdef pgm_read_byte_far
111 buffer[i]=pgm_read_byte_far(addr+i);
113 buffer[i]=pgm_read_byte(addr+i);
117 memcpy(buffer, (void*)((uint16_t)addr), size);
119 ultoa(addr, tstr, 16);
120 sprintf(tstr,"%6lX", addr);
122 cli_putstr_P(PSTR(": "));
123 cli_hexdump2(buffer, size);
124 cli_putstr_P(PSTR("\r\n"));