Has anybody tried to simulate ATmega running amforth with simavr?

34 views
Skip to first unread message

wzab

unread,
Sep 10, 2010, 5:12:57 PM9/10/10
to simavr
Hi,
I've tried to simulate the ATmega running amforth ( http://amforth.sf.net
) with simavr, but without success.
I've started with simulation of arduino (duemilanove).
I've modified a little simduino.c to read the contents of
duemilanove.hex and duemilanove.eep.hex:

// reload bootloader anyway
free(avr->flash);
avr->flash = mm;
{
int i = 0;
uint32_t base, size;
sprintf(path, "%s/%s", pwd, "duemilanove.eep.hex");
uint8_t * eeprom = read_ihex_file(path, &size, &base);
if (!eeprom) {
fprintf(stderr, "%s: Unable to load %s\n", argv[0], path);
exit(1);
}
{
avr_eeprom_desc_t d = { .ee = eeprom, .offset = base, .size =
size };
avr_ioctl(avr, AVR_IOCTL_EEPROM_SET, &d);
}
}
uint32_t base, size;
sprintf(path, "%s/%s", pwd, "duemilanove.x.hex");
uint8_t * boot = read_ihex_file(path, &size, &base);
if (!boot) {
fprintf(stderr, "%s: Unable to load %s\n", argv[0], path);
exit(1);
}
printf("Booloader %04x: %d\n", base, size);
memcpy(mm + base, boot, size);
free(boot);

I also had to modify the hex file with code to get it correctly read
by simavr:

srec_cat duemilanove.hex -Intel -Output duemilanove.y.hex -Intel -
MULTiple -Line_length=40 -address-length=2
avr-objcopy duemilanove.y.hex duemilanove.x.hex --gap-fill 255

Finally i have slightly modified the uart_udp.c to connect reliably to
the netcat program working as terminal:
if ((p->s = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
fprintf(stderr, "%s: Can't create socket: %s",
__FUNCTION__, strerror(errno));
return ;
}
struct sockaddr_in address = { 127, 0 , 0 , 1 };
address.sin_family = AF_INET;
address.sin_port = htons (4321);

if (connect(p->s, (struct sockaddr *) &address,
sizeof(address))) {
fprintf(stderr, "%s: Can not bind socket: %s",
__FUNCTION__, strerror(errno));
return ;
}

I have also uncommented debug messages in uart_udp.c

The simulated ATmega starts, and prints the welcome message and
prompt, however it does not receive data
sent from netcat (even though the debug message in uart_udp.c says,
that data arrive through the socket.)
I've checked both polling and interrupt driven communication routines
in amforth.

Has anybody else tried to simulate the amforth with simavr?
Has anyone succeeded with it?
--
TIA, WZab
Reply all
Reply to author
Forward
0 new messages