by Sascha77 » Mon Aug 13, 2007 3:08 pm
by Sascha77
Mon Aug 13, 2007 3:08 pm
I've tried using minicom on Mac OS X to download c-programs as described above. Whereas it is no problem to activate and use the bootloader, I have not managed to transfer the binaries correctly. I hope, someone can help me with this problem (should be the same problem using Linux):
I've used minicom -s to setup the serial port as described by the user guide and Marmakoide above: 57600 Baud, 8N1, no hardware flow control, no software flow control.
The problems occured when I tried to download the
binary program (e.g. example.bin): using the ascii protocol the minicom reported only 1.1 KB of the 3.3 KB to be transfered. I've tried several settings of ascii-xfr (use minicom -s to change settings of "file transfer protocols"): with or without line-end translation (option -n) and with control-d or control-z as end-of-file character (option -e / -d). Nothing worked correctly. When I use ascii-xfr to pipe the original binary into another file (ascii-xfr -sv[dne] example.bin > copy.bin) I noticed that the files actually are different.
I then tried my own "transfer protocol". I added the following short program to minicom's transfer protocols:
- Code: Select all
#include <stdio>
int main(int argc, char *argv[]) {
FILE* in;
in = fopen(argv[1], "r");
fprintf(stderr, "Start transfering %s. ", argv[1]);
char c;
int count = 1;
while (fread(&c, sizeof(char), 1, in)) {
printf("%c",c);
usleep(2000);
if (count++%1024==0) fprintf(stderr, "."); // print a dot every kb
}
fclose(in);
fprintf(stderr,"Done.");
return 1;
}
I've verified "bcat example.bin > copy.bin" to produce an exact copy of the original file. When I use this program to load the example.bin into the CM-5 with the minicom, the bootlader just hangs after the transmission. Pressing any keys does not help. After disconnecting and reconnecting to the Bioloid and entering the bootloader again (#+red button), I had a look at the contents of the flash memory. Actually, the program was partially uploaded (actually the file-end is there, but in the wrong place)but not in the correct order. The download seems to start correctly, but always something wents wrong later on: either the CM-5 misses some big parts between the correct file start and the correct file ending or already transfered content gets overwritten with the end of the program.
I've played around a little bit with the usleep after each character: the delay makes a difference. With some settings the first 400 or so bytes are correct and than there is a discontinuity (several hundred bytes missing), with other settings there are only 3 bytes in the correct order. Repeating with the same delay always produces the same memory content in the CM-5. But longer delays do not result in a later disconitinuity.
Does someone have a clue, how to resolve this problem or where to look at next? For me, it would be really great to understand what's going wrong here exactly and to have minicom working.
But for the time being I have a workaround:
1. Use minicom to enter the boot loader and start the file transfer by entering "load"
2. Without quitting minicom simply cat the binary file directly to the device using another console. For me this is "cat example.bin > /dev/tty.KeySerial1 (using a Keyspan USA-19QW).
In the minicom the CM-5 reports the correct file size and the example.bin works as expected. Simple!
I've tried using minicom on Mac OS X to download c-programs as described above. Whereas it is no problem to activate and use the bootloader, I have not managed to transfer the binaries correctly. I hope, someone can help me with this problem (should be the same problem using Linux):
I've used minicom -s to setup the serial port as described by the user guide and Marmakoide above: 57600 Baud, 8N1, no hardware flow control, no software flow control.
The problems occured when I tried to download the
binary program (e.g. example.bin): using the ascii protocol the minicom reported only 1.1 KB of the 3.3 KB to be transfered. I've tried several settings of ascii-xfr (use minicom -s to change settings of "file transfer protocols"): with or without line-end translation (option -n) and with control-d or control-z as end-of-file character (option -e / -d). Nothing worked correctly. When I use ascii-xfr to pipe the original binary into another file (ascii-xfr -sv[dne] example.bin > copy.bin) I noticed that the files actually are different.
I then tried my own "transfer protocol". I added the following short program to minicom's transfer protocols:
- Code: Select all
#include <stdio>
int main(int argc, char *argv[]) {
FILE* in;
in = fopen(argv[1], "r");
fprintf(stderr, "Start transfering %s. ", argv[1]);
char c;
int count = 1;
while (fread(&c, sizeof(char), 1, in)) {
printf("%c",c);
usleep(2000);
if (count++%1024==0) fprintf(stderr, "."); // print a dot every kb
}
fclose(in);
fprintf(stderr,"Done.");
return 1;
}
I've verified "bcat example.bin > copy.bin" to produce an exact copy of the original file. When I use this program to load the example.bin into the CM-5 with the minicom, the bootlader just hangs after the transmission. Pressing any keys does not help. After disconnecting and reconnecting to the Bioloid and entering the bootloader again (#+red button), I had a look at the contents of the flash memory. Actually, the program was partially uploaded (actually the file-end is there, but in the wrong place)but not in the correct order. The download seems to start correctly, but always something wents wrong later on: either the CM-5 misses some big parts between the correct file start and the correct file ending or already transfered content gets overwritten with the end of the program.
I've played around a little bit with the usleep after each character: the delay makes a difference. With some settings the first 400 or so bytes are correct and than there is a discontinuity (several hundred bytes missing), with other settings there are only 3 bytes in the correct order. Repeating with the same delay always produces the same memory content in the CM-5. But longer delays do not result in a later disconitinuity.
Does someone have a clue, how to resolve this problem or where to look at next? For me, it would be really great to understand what's going wrong here exactly and to have minicom working.
But for the time being I have a workaround:
1. Use minicom to enter the boot loader and start the file transfer by entering "load"
2. Without quitting minicom simply cat the binary file directly to the device using another console. For me this is "cat example.bin > /dev/tty.KeySerial1 (using a Keyspan USA-19QW).
In the minicom the CM-5 reports the correct file size and the example.bin works as expected. Simple!