Epsilon 23 et Upsilon bootloader
Posted: 26 Aug 2024, 12:41
Quelqu'un a-t-il testé si Epsilon 23 stable est compatible avec le bootloader d'Upsilon sur les N0110?
Merci!
Merci!
News, programmes, tutoriaux, forum sur les calculatrices TI !
https://tiplanet.org/forum/
dd if=/dev/zero of=sample.txt bs=8M count=1
qui peut être flashé avec le WebDFU)./* begin section (c) B. Parisse, write exam mode in *all* firmwares */
// write exam mode mode to flash at offset pos/8
void write_exammode(unsigned char * ptr,int pos,int mode,int modulo){
int curmode=pos%modulo;
if (curmode == mode)
return;
int delta=(mode+modulo-curmode)%modulo; // 0<delta<modulo, number of bits that we will set to 0
unsigned char * target = ptr + pos/8;
int pos8=pos % 8; // number of bits already set to 0 at target
pos8 += delta; // 0<pos8<modulo+7
unsigned char postab[]={0b11111111,0b1111111,0b111111,0b11111,0b1111,0b111,0b11,0b1,0}; // postab[i] is a byte with i bits set to 0
unsigned char tab[2];
bool writenext=pos8>8;
tab[0]=postab[writenext?8:pos8];
tab[1]=postab[writenext?pos8-8:0];
#if 1 // KHICAS
Ion::Device::Flash::WriteMemory(target, tab, writenext?2:1);
#else
target[0]=tab[0];
if (writenext) target[1]=tab[1];
#endif
}
// check that region is split in two parts: bits set to 0 followed by bits set to 1, returns position of the first 1 bit or -1
int pos_01(unsigned * start,int l){
unsigned *ptr=start,* end=start+l/sizeof(unsigned);
for (;ptr<end;++ptr){
if (*ptr)
break;
}
if (ptr==end)
return -1;
int pos=(ptr-start)*32;
unsigned char * ptr8=(unsigned char *) ptr;
if (*ptr8==0){
pos+=8; ++ptr8;
}
if (*ptr8==0){
pos+=8; ++ptr8;
}
if (*ptr8==0){
pos+=8; ++ptr8;
}
switch (*ptr8){
case 0b1: pos+=7; break; // 7 bits are already set to 0
case 0b11: pos+=6; break;
case 0b111: pos+=5; break;
case 0b1111: pos+=4; break;
case 0b11111: pos+=3; break;
case 0b111111: pos+=2; break;
case 0b1111111: pos+=1; break;
case 0b11111111: break;
default: return -1;
}
++ptr;
for (;ptr<end;++ptr){
if (*ptr!=0xffffffff)
return -1;
}
return pos;
}
void ck_exammode(int mode,int modulo){
// scan external flash every dflash bytes
unsigned * flashptr=(unsigned *) 0x90000000;
unsigned dflash=0x10000,ntests=8*1024*1024/dflash/sizeof(unsigned);
if (mode==-1){
for (unsigned i=0;i<ntests;++i){
unsigned * ptr=flashptr+i*dflash;
// kernel header?
if (*ptr!=0xffffffff || *(ptr+1)!=0xffffffff || *(ptr+2)!= 0xdec00df0 /* f0 0d c0 de*/)
continue;
ptr += 0x1000/sizeof(unsigned); // exam mode buffer?
int pos=pos_01(ptr,0x1000);
if (pos==-1)
continue;
if (mode==-1 && (pos %modulo)){
mode=pos%modulo;
break;
}
}
if (mode==-1)
return;
}
if (mode){
if (mode==1)
Ion::LED::setColor(KDColorRed);
if (mode==2)
Ion::LED::setColor(KDColorBlue);
if (mode==3)
Ion::LED::setColor(KDColorGreen);
Ion::LED::setBlinking(1000, 0.1f);
}
else {
Ion::LED::setColor(KDColorBlack);
}
// check that this exam mode is reflected in other slots
for (unsigned i=0;i<ntests;++i){
unsigned * ptr=flashptr+i*dflash;
// kernel header?
if (*ptr!=0xffffffff || *(ptr+1)!=0xffffffff || *(ptr+2)!= 0xdec00df0 /* f0 0d c0 de*/)
continue;
ptr += 0x1000/sizeof(unsigned); // exam mode buffer?
int pos=pos_01(ptr,0x1000);
if (pos==-1)
continue;
if (mode==pos%modulo)
continue;
if (pos>=0x1000-8){
Ion::Device::Flash::EraseSector(Ion::Device::Flash::SectorAtAddress((uint32_t)ptr));
pos=0;
}
write_exammode((unsigned char *)ptr,pos,mode,modulo);
}
}
/* end section (c) B. Parisse, */