Beispiel #1
0
int main(uint32_t startloc) {
	cpu_clock_init();
	ssp_clock_init();
	systickInit();

//	cpu_clock_set(204);

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);
	SETUPgout(MIC_AMP_DIS);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);
	inputInit();
	flashInit();

	lcdInit();
	fsInit();
	lcdFill(0xff); /* Display BL Image here */

	sli=startloc;

	if (startloc != (uintptr_t)&_app_start){ /* not booted via DFU, do autoboot */ 
        char filename[FLEN];
        switch(getInputRaw()){
            case BTN_LEFT:
                getInputWaitRelease();
                doRealExec(1);
                break;
            case BTN_UP:
                doMSC();
            default:
            case BTN_NONE:
                readTextFile(BOOTCFG, filename, FLEN);
                lcdPrintln("Booting:");
                lcdPrintln(filename);
                bootFile(filename);
                break;
		};
	};
	static const struct MENU main={ "Bootloader", {
		{ "Exec Firmware", &doExec},
		{ "MSC", &doMSC},
		{ "Flash Boot Ldr", &doFlash},
		{ "Info", &doInfo},
		{NULL,NULL}
	}};
	do {
		handleMenu(&main);
	}while(1);
}
Beispiel #2
0
void doExec(){
	char filename[FLEN];
	FATFS FatFs;

	FRESULT res;
	if(selectFile(filename,"BIN")){
		lcdPrintln("Select ERROR");
		lcdDisplay();
		getInputWait();
		return;
	};
	lcdPrintln("Loading:");
	lcdPrintln(filename);
	lcdDisplay();
	bootFile(filename,1);

};
Beispiel #3
0
int main(uint32_t startloc) {
	cpu_clock_init();
	ssp_clock_init();
	systick_set_reload(208000);
	systick_set_clocksource(0);
	systick_interrupt_enable();
	systick_counter_enable();

//	cpu_clock_pll1_max_speed();

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);
	inputInit();
	flashInit();

    lcdInit();
	fsInit();
    lcdFill(0xff); /* Display BL Image here */

	sli=startloc;

	if (startloc != (uintptr_t)&_app_start){ /* not booted via DFU, do autoboot */ 
		if (getInputRaw()!=BTN_LEFT){
			char filename[FLEN];
			readTextFile(BOOTCFG, filename, FLEN);
			lcdPrintln("Fname");
			lcdPrintln(filename);
			bootFile(filename,0);
		};
	};
	static const struct MENU main={ "Bootloader", {
		{ "Info", &doInfo},
		{ "Exec", &doExec},
		{ "Flash", &doFlash},
		{NULL,NULL}
	}};
	handleMenu(&main);
	return 0;
}
Beispiel #4
0
void doRealExec(int silent){
	char filename[FLEN];
	FATFS FatFs;
	FRESULT res;
	int sres;

	sres=selectFile(filename,"B1N");
	if(sres<0){
	    if(!silent){
		lcdPrintln("Select ERROR");
		lcdDisplay();
		getInputWait();
	    };
	    return;
	};
	if(sres==0){
	    lcdPrintln("set as default:");
	    res=writeFile(BOOTCFG, filename, strlen(filename)+1);
        if(res<0){
            lcdPrint("write Error:");
            lcdPrintln(IntToStr(-res,3,0));
            lcdPrintln(f_get_rc_string(res));
            lcdDisplay();
            getInputWait();
        }else{
		lcdPrint("wrote ");
		lcdPrint(IntToStr(res,3,0));
		lcdPrintln(" bytes.");
		lcdDisplay();
	    };
	};
	lcdPrintln("Loading:");
	lcdPrintln(filename);
	lcdDisplay();
	bootFile(filename);
};
Beispiel #5
0
void EnumerateBoots(wstring dir, int& count)
{
    // check for skip-path
    if (wcsicmp(dir.c_str(),_bootserv_config._random_skip.c_str())==0)
    {
        LOG1S(L"skipping {%s}: boots from this folder can ONLY BE ASSIGNED MANUALLY (using map.txt)", dir.c_str());
        return;
    }

	WIN32_FIND_DATA fData;
    wstring pattern(dir);
    pattern += L"*";

	HANDLE hff = FindFirstFile(pattern.c_str(), &fData);
	if (hff == INVALID_HANDLE_VALUE) 
	{
		// none found.
		return;
	}
	while(true)
	{
        // bounds check
        if (count >= MAX_BOOTS)
        {
            LOG1N(L"ERROR in bootserver: Too many boots (MAX supported = %d). Random boot enumeration stopped.", MAX_BOOTS);
            break;
        }

        // check if this is a directory
        if (fData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
                && wcscmp(fData.cFileName,L".")!=0 
                && wcscmp(fData.cFileName,L"..")!=0)
        {
            wstring nestedDir(dir);
            nestedDir += fData.cFileName;
            nestedDir += L"\\";
            EnumerateBoots(nestedDir, count);
        }
        else if ((fData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
        {
            // check for ".bin" extension. This way we have
            // a little bit of protection against other types
            // of files in boots folder.
            int flen = wcslen(fData.cFileName);
            if (wcsicmp(fData.cFileName+flen-4, L".bin")==0)
            {
                int idx = FIRST_RANDOM_BOOT_SLOT + count;

                wstring bootFile(dir);
                bootFile += L"\\";
                bootFile += fData.cFileName;
                if (k_bootserv.debug)
                    LOG1N1S(L"random boot: %d <-- {%s}", idx, bootFile.c_str());

                _fast_bin_table[idx - FIRST_EXTRA_BOOT_SLOT] =
                    new wstring(bootFile);
                count++;
            }
		}

		// proceed to next file
		if (!FindNextFile(hff, &fData)) break;
	}
	FindClose(hff);
}