// search for specified dsp file and load it u8 files_load_dsp_name(const char* name) { void* fp; u32 size = 0; u8 ret; // ModuleVersion modVers; delay_ms(10); app_pause(); fp = list_open_file_name(&dspList, name, "r", &size); if( fp != NULL) { print_dbg("\r\n found file, loading dsp: "); print_dbg(name); fake_fread(bfinLdrData, size, fp); fl_fclose(fp); bfinLdrSize = size; if(bfinLdrSize > 0) { print_dbg("\r\n loading bfin from buf"); // reboot the dsp with new firmware in RAM bfin_load_buf(); print_dbg("\r\n finished load"); // write module name in global scene data ///////////////// /// FIXME: filename and reported modulename should be decoupled /// bees should search for aleph-module-x.y.z.ldr /// but try aleph-module*.ldr on failure //// /// query name and version to the scene data // scene_query_module(); /// now set it to the actual filename because we are dumb scene_set_module_name(name); /////////////////////////// print_dbg("\r\n sceneData->moduleName : "); print_dbg(name); ret = 1; } else { print_dbg("\r\n bfin ldr size was <=0, aborting"); ret = 0; } } else { print_dbg("\r\n error: fp was null in files_load_dsp_name \r\n"); ret = 0; } app_resume(); return ret; }
// search for specified dsp file and load it u8 files_load_dsp_name(const char* name) { // don't need .ldr, but we do need .dsc... char descname[128]; u8 nbuf[4]; // buffer for binary blob of single descriptor u8 dbuf[PARAM_DESC_PICKLE_BYTES]; // unpacked descriptor ParamDesc desc; u32 nparams; u8 ret = 0; FILE* fp; int i; strcpy(descname, workingDir); strcat(descname, name); strip_ext(descname); strcat(descname, ".dsc"); fp = fopen(descname, "r"); if(fp == NULL) { printf("\r\n module descriptor not found; path: %s", descname); ret = 1; return ret; } // get count of params fread(nbuf, 1, 4, fp); unpickle_32(nbuf, (u32*)&nparams); /// loop over params if(nparams > 0) { printf("\r\n loading param descriptor; count: %d", nparams); net_clear_params(); for(i=0; i<nparams; i++) { // read into desc buffer fread(dbuf, 1, PARAM_DESC_PICKLE_BYTES, fp); // unpickle directly into network descriptor memory pdesc_unpickle( &desc, dbuf ); // copy descriptor to network and increment count net_add_param(i, (const ParamDesc*)(&desc)); } } else { ret = 1; } fclose(fp); scene_set_module_name(name); return ret; }