Re: Error in Multibank Load
Xavier IZARD <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <[email protected]> |
Abhijit Gadgil a écrit :
> Dear Xavier,
>
> Thanks for your help.
>
> I would really appreciate if you could send me the C file for breaking the
> programs into parts. Regarding Macro's in Javakit, I am not too sure. Can
> you point me to right documentation for the same? (This would save a lot
> of time for me.)
>
> Thanks again.
>
> -abhijit
>
>
> On Fri, 16 Apr 2004, Xavier IZARD wrote:
>
>
>>Abhijit Gadgil a écrit :
>>
>>>Dear All,
>>>
>>>We are facing a strange problem while loading a hex file as tbin on the
>>>TINI when the size of the file is > 64K. This problem is occuring both
>>>with the FLASH as well as RAM. This is a custom board designed by us.
>>>Further, we are not having any problems while loading hex files < 64k.
>>>
>>>When the debug and verbose mode is enabled, it is observed that the CRC
>>>check after the first of the (target bank) is loaded fails.
>>>
>>>Can anyone please throw some light on this?
>>>
>>>Regards,
>>>
>>>-abhijit
>>>
>>
>>Hello,
>>
>>I got the same problem with a custom board too (even with DTR connected
>>to reset). However, I don't know if the cause of my problem is the same
>>as for you because I load the program as hex file.
>>
>>My solution is to split the hex file into smaller ones with max size of
>>64k. Then, different parts are easy to load with a macro for javakit. I
>>wrote a C program to split the hex file, I can send it to you if you want.
>>
>>Regards,
>
>
Ok, you will find the C program attached. It is in french, but very
simple to use : ./split_bank <name_of_the_file.hex> and it generates
files named partie_1.hex, partie_2.hex, ...
I use gcc to compile it (Linux or cygwin on windows), but it should work
with any C compiler. Licence of the program is GPL. If you can't compile
it, I will send you the exe file + required dll, but off-list.
I also send you the macro for javakit. Be sure to use -macro option for
javakit. Note that you can also load files manualy, this is just longuer.
Regards,
Xavier
*** The Macro
<JavaKit RESET>
<JavaKit LOAD>partie_1.hex
<JavaKit RESET>
<JavaKit LOAD>partie_2.hex
*** The C program
#include <stdio.h>
#include <stdlib.h>
#define TAILLE_FLASH 1048576
#define PREFIXE_FICHIER_SORTIE "partie_"
int main(int argc,char *argv[])
{
FILE *fichier;
int compteur_fichier_sortie=1;
char *chaine;
char *nom_fichier_sortie;
char *index_debut;
char *index_fin;
if(argc<2)
{
printf("\033[32;1mDecoupe un fichier .hex en banques de 64ko
maximum\033[0m\nUsage: split_bank <nom_fichier.hex>\n");
exit(1);
}
fichier=fopen(argv[1],"r");
if(fichier==NULL)
{
printf("Impossible d'ouvrir le fichier %s\n",argv[1]);
return EXIT_FAILURE;
}
chaine=(char *)malloc((TAILLE_FLASH*3+15*17+1)*sizeof(char));
//ATTENTION, changer la taille !!!
nom_fichier_sortie=(char
*)malloc((strlen(PREFIXE_FICHIER_SORTIE)+8)*sizeof(char));
fread(chaine,sizeof(char),TAILLE_FLASH*3+15*17,fichier);
if(fgetc(fichier)!=EOF) printf("\033[31;1mAttention: Le fichier depasse
la taille de la flash, il n'a pas ete lu en entier\033[0m\n");
fclose(fichier);
index_debut=strstr(chaine,":02000004"); //recherche de la premiere banque
if(index_debut==NULL)
{
printf("\033[31;1mAttention: fichier HEX non conforme, impossible de
trouver les adresses de poids fort. Aucune operation effectuee\033[0m\n");
free(chaine);
free(nom_fichier_sortie);
exit(1);
}
index_fin=strstr(chaine+1,":02000004");
while(index_debut!=NULL)
{
sprintf(nom_fichier_sortie,"%s%d.hex",PREFIXE_FICHIER_SORTIE,compteur_fichier_sortie);
fichier=fopen(nom_fichier_sortie,"w");
if(fichier==NULL)
{
printf("Impossible d'ecrire le fichier %s\n",nom_fichier_sortie);
free(chaine);
free(nom_fichier_sortie);
return EXIT_FAILURE;
}
if(index_fin!=NULL)
{
fwrite(index_debut,sizeof(char),index_fin-index_debut,fichier);
fwrite(":00000001FF",sizeof(char),strlen(":00000001FF"),fichier);
}
else
{
fwrite(index_debut,sizeof(char),strlen(index_debut),fichier);
}
fclose(fichier);
if(index_fin!=NULL)
{
index_debut=index_fin;
index_fin=strstr(index_fin+1,":02000004");
}
else break;
compteur_fichier_sortie++;
}
free(chaine);
free(nom_fichier_sortie);
return EXIT_SUCCESS;
}
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini