/*
* (C) Copyright 2015 Leo C. <erbl259-lmu@yahoo.de>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0
*/
-#include "common.h"
-#include <stdlib.h>
+#include "cmd_loadihex.h"
#include <ctype.h>
-#include <stdbool.h>
-#include "command.h"
#include "con-utils.h"
#include "z80-if.h"
#include "debug.h"
uint8_t sum;
rec->status = IHX_BROKEN;
+ rec->len = 0;
+ rec->type = 0xff;
-
- while ((c = my_getchar(0)) != ':')
+ while ((c = my_getchar(0)) != ':') {
if (c == 0x03)
- return -1;
+ return -1; /* Control-C */
+ if (c == 0x04) {
+ rec->status = IHX_OK;
+ return 0; /*Control-D, EOF */
+ }
+ }
if ((c = get_hexbyte()) < 0) /* Start code */
return -1;
}
-command_ret_t do_loadihex(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_loadihex(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
{
long offset = 0;
uint32_t base_address = 0;
uint32_t address_low = address_max;
command_ret_t rcode = CMD_RET_FAILURE;
ihex_t rec;
+ bool firstrec = true;
(void) cmdtp; (void) flag;
if (argc > 1)
offset = strtol(argv[1], NULL, 16);
+ printf_P(PSTR("Waiting for Intel Hex Records...\n"));
+
while (ihex_get_record(&rec) > 0 &&
rec.status == IHX_OK &&
rec.type != 1 ) {
switch (rec.type) {
case 0: /* Data record */
+ if (firstrec) {
+ printf_P(PSTR("Loading: 0x....."));
+ firstrec = false;
+ }
if (rec.len) {
uint32_t addr = base_address + rec.address + offset;
if (addr < address_low)
// debug("low: 0x%.5lX, high: 0x%.5lX, max: 0x%.5lX, addr: 0x%.5lX, len: %d\n",
// address_low, address_high, address_max, addr, rec.len);
-
+ printf_P(PSTR("\b\b\b\b\b%.5lX"), addr);
if (addr < address_max) {
uint32_t tmplen = address_max - addr;
if (rec.len > tmplen)
break;
}
- printf_P(PSTR("Data loaded: "));
+
+ for (uint_fast8_t i=0; i<100; ++i) {
+ /* flush input buffer */
+ while (my_getchar(0) > 0)
+ ;
+ udelay(1000);
+ }
+
+
+ printf_P(PSTR("\nData loaded: "));
if (address_low >= MIN(address_high, address_max))
printf_P(PSTR("None.\n"));
else