]> cloudbase.mooo.com Git - z180-stamp.git/blame - avr/command_tbl.c
command printenv: new option -s: Print env variables in setenv commands.
[z180-stamp.git] / avr / command_tbl.c
CommitLineData
35edb766 1/*
04b3ea0e 2 * (C) Copyright 2014-2016 Leo C. <erbl259-lmu@yahoo.de>
35edb766 3 *
b51d2360 4 * SPDX-License-Identifier: GPL-2.0
35edb766 5 */
d684c216
L
6
7#include "common.h"
d684c216 8#include "command.h"
72f58822 9#include "cmd_mem.h"
d684c216 10
d0581f88
L
11extern command_ret_t do_help(cmd_tbl_t *, int, int, char * const []);
12extern command_ret_t do_echo(cmd_tbl_t *, int, int, char * const []);
8a7decea 13extern command_ret_t do_sleep(cmd_tbl_t *, int, int, char * const []);
d0581f88 14extern command_ret_t do_env_print(cmd_tbl_t *, int, int, char * const []);
7e24905c 15extern command_ret_t do_env_default(cmd_tbl_t *, int, int, char * const []);
d0581f88
L
16extern command_ret_t do_env_set(cmd_tbl_t *, int, int, char * const []);
17extern command_ret_t do_env_save(cmd_tbl_t *, int, int, char * const []);
18extern command_ret_t do_loadf(cmd_tbl_t *, int, int, char * const []);
a2907f2e 19extern command_ret_t do_bootcf(cmd_tbl_t *, int, int, char * const []);
c0abd68b 20extern command_ret_t do_loadcpm3(cmd_tbl_t *, int, int, char * const []);
179bc609 21extern command_ret_t do_loadihex(cmd_tbl_t *, int, int, char * const []);
393b1897
L
22#if defined(CONFIG_CMD_LOADB)
23extern command_ret_t do_load_serial_bin(cmd_tbl_t *, int, int, char * const []);
24#endif
d0581f88
L
25extern command_ret_t do_go(cmd_tbl_t *, int, int, char * const []);
26extern command_ret_t do_restart(cmd_tbl_t *, int, int, char * const []);
89adce76 27extern command_ret_t do_console(cmd_tbl_t *, int, int, char * const []);
d0581f88 28extern command_ret_t do_dump_mem(cmd_tbl_t *, int, int, char * const []);
ad9bc17c
L
29extern command_ret_t do_mem_mm_avr(cmd_tbl_t *, int, int, char * const []);
30extern command_ret_t do_mem_nm_avr(cmd_tbl_t *, int, int, char * const []);
d0581f88
L
31extern command_ret_t do_eep_cp(cmd_tbl_t *, int, int, char * const []);
32extern command_ret_t do_busreq_pulse(cmd_tbl_t *, int, int, char * const []);
61b0cfe9 33extern command_ret_t do_date(cmd_tbl_t *, int, int, char * const []);
05994bd9
L
34extern command_ret_t do_gpio(cmd_tbl_t *, int, int, char * const []);
35extern command_ret_t do_sd(cmd_tbl_t *, int, int, char * const []);
2f53dd65
L
36extern command_ret_t do_fat_stat(cmd_tbl_t *, int, int, char * const []);
37extern command_ret_t do_fat_ls(cmd_tbl_t *, int, int, char * const []);
4565be9a 38extern command_ret_t do_fat_rw(cmd_tbl_t *, int, int, char * const []);
131e0d5a
L
39extern command_ret_t do_run(cmd_tbl_t *, int, int, char * const []);
40extern command_ret_t do_source(cmd_tbl_t *, int, int, char * const []);
41extern command_ret_t do_attach(cmd_tbl_t *, int, int, char * const []);
05994bd9
L
42
43#ifdef CONFIG_SYS_LONGHELP
44const FLASH char sd_help_text[] =
45 "bla \t- do bla\n"
46 ;
47#endif /* CONFIG_SYS_LONGHELP */
d684c216
L
48
49
50cmd_tbl_t cmd_tbl[] = {
51
61b0cfe9
L
52CMD_TBL_ITEM(
53 date, 2, 1, do_date,
a036b05f 54 "get/set date & time",
85046f8c 55 "[MMDDhhmm[[CC]YY][.ss]]\n"
61b0cfe9
L
56 " - without arguments: print date & time\n"
57 " - with numeric argument: set the system date & time\n"
61b0cfe9
L
58),
59
323398b1 60#ifdef DEBUG
4565be9a 61
323398b1 62CMD_TBL_ITEM(
f338df2a
L
63 !mdr, 3, 1, do_dump_mem,
64 "RAM dump",
65 "address [count]"
66),
67CMD_TBL_ITEM(
68 !mde, 3, 1, do_dump_mem,
323398b1
L
69 "EEPROM dump",
70 "address [count]"
71),
c748023e
L
72CMD_TBL_ITEM(
73 !mdf, 3, 1, do_dump_mem,
74 "FLASH dump",
75 "address [count]"
76),
323398b1 77CMD_TBL_ITEM(
f338df2a 78 !cpe, 4, 0, do_eep_cp,
323398b1
L
79 "EEPROM copy",
80 "source target count"
81),
ad9bc17c
L
82CMD_TBL_ITEM(
83 !mm, 2, 1, do_mem_mm_avr,
84 "avr memory modify (auto-incrementing address)",
85 "address"
86),
87CMD_TBL_ITEM(
88 !nm, 2, 1, do_mem_nm_avr,
89 "avr memory modify (constant address)",
90 "address"
91),
323398b1 92#endif
f338df2a
L
93CMD_TBL_ITEM(
94 mstep, 2, 1, do_busreq_pulse,
95 "execute one M cycle",
96 "[count]\n"
97 " - repeat count times"
98),
d684c216
L
99CMD_TBL_ITEM(
100 echo, CONFIG_SYS_MAXARGS, 1, do_echo,
bbd45c46
L
101 "display a line of text",
102 "[-n] [argument ...]\n"
32154e5a
L
103 "- echo the argument(s) to console.\n"
104 " -n do not output the trailing newline"
d684c216 105),
8a7decea
L
106CMD_TBL_ITEM(
107 sleep , 2, 1, do_sleep,
108 "delay execution for some time",
109 "N[m][s]\n"
110 " - delay execution for decimal N (milli) seconds"
111),
d684c216
L
112CMD_TBL_ITEM_COMPLETE(
113 run, CONFIG_SYS_MAXARGS, 1, do_run,
114 "run commands in an environment variable",
115 "var [...]\n"
116 " - run the commands in the environment variable(s) 'var'",
117 var_complete
118),
04b3ea0e
L
119CMD_TBL_ITEM_COMPLETE(
120 source, CONFIG_SYS_MAXARGS, 1, do_source,
121 "run commands from a file",
122 "filename\n"
123 " - run the commands in the script file 'filename'",
124 var_complete
125),
d684c216
L
126CMD_TBL_ITEM_COMPLETE(
127 printenv, CONFIG_SYS_MAXARGS, 1, do_env_print,
128 "print environment variables",
8eb73d17
L
129 "[-s] [name ...]\n"
130 " Print value of environment variable(s) 'name'\n"
131 " If no names are given, print values of all environment variables\n"
132 " -s Print in setenv form",
d684c216
L
133 var_complete
134),
135CMD_TBL_ITEM_COMPLETE(
136 setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
137 "set environment variables",
72f58822
L
138 "name value ...\n"
139 " - set environment variable 'name' to 'value ...'\n"
140 "setenv name\n"
141 " - delete environment variable 'name'",
d684c216
L
142 var_complete
143),
323398b1
L
144CMD_TBL_ITEM(
145 saveenv, 1, 0, do_env_save,
146 "save environment variables to persistent storage",
147 ""
148),
7e24905c
L
149CMD_TBL_ITEM(
150 defaultenv, 1, 0, do_env_default,
151 "set all environment variables to their default values",
152 ""
153),
72f58822 154
534e1dfc 155CMD_TBL_ITEM(
323398b1 156 loadf, 1, 0, do_loadf,
534e1dfc
L
157 "load srec_cat prepared image from controller flash",
158 ""
159),
a2907f2e
L
160CMD_TBL_ITEM(
161 bootcf, CONFIG_SYS_MAXARGS, 0, do_bootcf,
162 "boot from cf card",
163 "[options]\n"
164 " Load a number of sectors from the first CP/M partition and jump to\n"
165 " the load address.\n"
166 " -a ADDRESS\n"
167 " Load and start address (default 100 hex)\n"
168 " -s NUM\n"
169 " First sector of partition to load (0..255, default 0)\n"
170 " -c NUM\n"
171 " Number of sectors to load (1..127, default 7)\n"
172 " -i NUM\n"
173 " Partition type to look for (default 52 hex)\n"
174 " -n\n"
175 " Load only, do not execute\n"
176 " -t NUM\n"
177 " Timeout for IDE commands (1..65535, default 10000)\n"
178 " -v verbose\n"
179 " TODO: be verbose"
180),
c0abd68b
L
181CMD_TBL_ITEM(
182 loadcpm3, 3, 0, do_loadcpm3,
183 "load CPM3.SYS file",
98aac4d0 184 "[filename [common-base [banked-base]]] \n"
fa84c3ba
L
185 " - Load CP/M 3 system file from FAT filesystem. This command makes\n"
186 " CPMLDR superfluous. Uses the following environment variables if set:\n"
b51d2360
L
187 " '"ENV_CPM3_SYSFILE"' File to load. Default is '"CONFIG_CPM3_SYSFILE"'.\n"
188 " '"ENV_CPM3_BANKED_BASE"' Default is '"CONFIG_CPM3_BANKED_BASE_STR"'.\n"
189 " Sets the following environment variables after loading:\n"
190 " '"ENV_CPM3_COMMON_BASE"'\n"
191 " '"ENV_STARTADDRESS"'"
c0abd68b 192),
179bc609
L
193CMD_TBL_ITEM(
194 loadi, 2, 0, do_loadihex,
bf587043
L
195 "load intel hex file over serial line",
196 "[[-]offset]\n"
197 " - load Intel-Hex-Record file over serial line with offset 'offset'"
179bc609 198),
393b1897
L
199
200#if defined(CONFIG_CMD_LOADB)
201CMD_TBL_ITEM(
202 loadb, 1, 0, do_load_serial_bin,
203 "load binary file over serial line (kermit mode)",
204 " - load binary file over serial line"
205),
206
207CMD_TBL_ITEM(
208 loadx, 1, 0, do_load_serial_bin,
209 "load binary file over serial line (xmodem mode)",
210 " - load binary file over serial line"
211),
212
213CMD_TBL_ITEM(
214 loady, 1, 0, do_load_serial_bin,
215 "load binary file over serial line (ymodem mode)",
216 " - load binary file over serial line"
217),
218#endif /* CONFIG_CMD_LOADB */
219
534e1dfc 220CMD_TBL_ITEM(
323398b1 221 go, 2, 0, do_go,
534e1dfc
L
222 "start application at address 'addr'",
223 "addr\n"
224 " - start application at address 'addr'"
225// "\n"
226// " passing 'arg' as arguments"
227),
228CMD_TBL_ITEM(
323398b1 229 reset, 1, 0, do_reset,
534e1dfc
L
230 "Keep CPU in RESET state",
231 ""
232),
233CMD_TBL_ITEM(
89adce76 234 restart, 1, 1, do_restart,
534e1dfc
L
235 "Perform RESET of the CPU",
236 ""
237),
89adce76 238CMD_TBL_ITEM(
2fe44122 239 connect, 1, 0, do_console,
89adce76 240 "Connect to CPU console i/o",
98aac4d0
L
241 "\n"
242 " - type the escape character followed by Q to close the connection, \n"
243 " or followed by ? to see other options. The default escape character \n"
244 " is Ctrl-^ (0x1E). It can be changed by setting env var '"ENV_ESC_CHAR"'."
245
89adce76 246),
41d36f28 247
41d36f28 248CMD_TBL_ITEM(
05994bd9 249 pin, CONFIG_SYS_MAXARGS, 1, do_gpio,
cd5ee544
L
250 "Set or query pin state",
251 "[-s] [<pins>]\n"
41d36f28
L
252 " - print cofiguration and state or frequency of pins\n"
253 " print all pins, if argument is omitted\n"
cd5ee544 254 "pin <pins> h[igh]|l[ow]\n"
41d36f28 255 " - config pins as output and set to level high or low\n"
cd5ee544 256 "pin <pins> ts|i[n]|p[ullup]\n"
41d36f28 257 " - config pins as input/tristate or input with pullup\n"
cd5ee544 258 "pin <pins> value[K|M][Hz]\n"
41d36f28
L
259 " - output a clock on pins\n"
260 " value is system clock divider or frequency, if 'Hz' is appended\n"
261 " divider is rounded down to next possible value (depends on pin)\n"
262 "\n"
cd5ee544 263 "<pins> is a comma separated list of numbers or ranges, i.e. \"0,9,3-6\"\n"
6035a17b 264),
534e1dfc 265
72f58822
L
266CMD_TBL_ITEM(
267 md, 3, 1, do_mem_md,
268 "memory display",
269 "address [# of objects]"
270),
271CMD_TBL_ITEM(
272 mm, 2, 1, do_mem_mm,
273 "memory modify (auto-incrementing address)",
274 "address"
275),
276CMD_TBL_ITEM(
277 nm, 2, 1, do_mem_nm,
278 "memory modify (constant address)",
279 "address"
280),
281CMD_TBL_ITEM(
32154e5a 282 mw, CONFIG_SYS_MAXARGS, 1, do_mem_mw,
72f58822 283 "memory write (fill)",
32154e5a
L
284 "[-bwl] address value [count]\n"
285 " -b write value as byte (8 bit, default)\n"
286 " -w write value as word (16 bit)\n"
fcd2239e 287 " -l write value as long (32 bit)"
72f58822
L
288),
289CMD_TBL_ITEM(
290 cp, 4, 1, do_mem_cp,
291 "memory copy",
292 "source target count"
293),
294CMD_TBL_ITEM(
295 cmp, 4, 1, do_mem_cmp,
296 "memory compare",
297 "addr1 addr2 count"
298),
299CMD_TBL_ITEM(
c79c80b4 300 base, 2, 0, do_mem_base,
72f58822
L
301 "print or set address offset",
302 "\n"
303 " - print address offset for memory commands\n"
304 "base offset\n"
305 " - set address offset for memory commands to 'offset'"
306),
307CMD_TBL_ITEM(
5480dc65 308 mloop, 3, 1, do_mem_loop,
72f58822
L
309 "infinite loop on address range",
310 "address number_of_bytes"
311),
72f58822 312CMD_TBL_ITEM(
5480dc65 313 mloopw, 4, 1, do_mem_loopw,
72f58822
L
314 "infinite write loop on address range",
315 "address number_of_bytes data_to_write"
316),
72f58822
L
317
318#ifdef CONFIG_CMD_MEMTEST
319CMD_TBL_ITEM(
5480dc65 320 mtest, 4, 1, do_mem_mtest,
72f58822 321 "simple RAM read/write test",
5480dc65 322 "[start [end [iterations]]]"
72f58822
L
323),
324#endif /* CONFIG_CMD_MEMTEST */
325
326#ifdef CONFIG_MX_CYCLIC
327CMD_TBL_ITEM(
328 mdc, 4, 1, do_mem_mdc,
329 "memory display cyclic",
330 "address count delay(ms)"
331),
332CMD_TBL_ITEM(
fcd2239e 333 mwc, CONFIG_SYS_MAXARGS, 1, do_mem_mdc,
72f58822 334 "memory write cyclic",
fcd2239e
L
335 "[-bwl] address value delay(ms)\n"
336 " -b write value as byte (8 bit, default)\n"
337 " -w write value as word (16 bit)\n"
338 " -l write value as long (32 bit)"
72f58822
L
339),
340#endif /* CONFIG_MX_CYCLIC */
341
7f552300
L
342CMD_TBL_ITEM(
343 sd, CONFIG_SYS_MAXARGS, 1, do_sd,
344 "SD/MMC card handling commands",
345 "<subcommand> args ...\n"
346 "sd help\n"
347 " - print help on subcommands"
348),
72f58822 349
2f53dd65
L
350CMD_TBL_ITEM(
351 fatstat, 2, 1, do_fat_stat,
352 "Show logical drive status",
353 "dev"
354),
355CMD_TBL_ITEM(
356 fatls, 2, 1, do_fat_ls,
357 "Directory listing",
358 "path"
359),
360CMD_TBL_ITEM(
4565be9a 361 fatload, 5, 0, do_fat_rw,
2f53dd65
L
362 "load binary file from a dos filesystem",
363 "<d:/path/filename> <addr> [bytes [pos]]\n"
364 " - Load binary file 'path/filename' on logical drive 'd'\n"
365 " to address 'addr' from dos filesystem.\n"
366 " 'pos' gives the file position to start loading from.\n"
367 " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
368 " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
369 " the load stops on end of file."
370),
371CMD_TBL_ITEM(
4565be9a 372 fatwrite, 4, 0, do_fat_rw,
2f53dd65
L
373 "write file into a dos filesystem",
374 "<d:/path/filename> <addr> <bytes>\n"
4565be9a 375 " - Write file to 'path/filename' on logical drive 'd' from RAM\n"
79082813 376 " starting at address 'addr'.\n"
2f53dd65 377),
cb4fb1ed
L
378CMD_TBL_ITEM(
379 attach, CONFIG_SYS_MAXARGS, 1, do_attach,
380 "attach filesystem image file to CP/M drive",
96798b2c
L
381 "[-rw] [-o options] dsk<n> diskfile\n"
382 " Attach diskfile to dsk<n>, where n in 0..7\n"
383 " -r File is read only (write protected)\n"
384 " -w File is read/write (default)\n"
385 " -o options\n"
386 " Options is a comma-separated list of\n"
387 " ro, rw, debug, nodebug\n"
388 "\n"
389 "attach [-rw] -o reattach[,other options] dsk<n>\n"
390 " Change options for dsk<n>.\n"
391 " Options as above.\n"
392 "\n"
393 "attach -d -a|dsk<n>\n"
394 "detach -a|dsk<n>\n"
395 " Detach diskfile from dsk<n>.\n"
396 " -a Detach all.\n"
397 "\n"
cb4fb1ed 398 "attach\n"
96798b2c 399 " Without arguments, list current assignments\n"
cb4fb1ed
L
400),
401CMD_TBL_ITEM(
402 detach, 2, 1, do_attach,
403 "detach file from CP/M drive",
404 "dsk<n>]\n"
a2907f2e 405 " - alias for 'attach -d dsk<n>'"
cb4fb1ed 406),
2f53dd65 407
d684c216
L
408CMD_TBL_ITEM(
409 help, CONFIG_SYS_MAXARGS, 1, do_help,
410 "print command description/usage",
411 "\n"
412 " - print brief description of all commands\n"
413 "help command ...\n"
414 " - print detailed usage of 'command'"
415),
416
72f58822 417/* This does not use the CMD_TBL_ITEM macro as ? can't be used in symbol names */
d684c216
L
418 {FSTR("?"), CONFIG_SYS_MAXARGS, 1, do_help,
419 FSTR("alias for 'help'"),
420#ifdef CONFIG_SYS_LONGHELP
421 FSTR(""),
422#endif /* CONFIG_SYS_LONGHELP */
423#ifdef CONFIG_AUTO_COMPLETE
424 0,
425#endif
426},
427/* Mark end of table */
428{ 0 },
429};