Libraries & Config files on SD

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
PatrickFolci
User
Posts: 14
Joined: Mon 2018-03-19 11:02

Libraries & Config files on SD

Post by PatrickFolci » Mon 2018-03-19 12:43

Hi All,

I'm trying to boot the kernel from external flash and read the config file and the libraries from the SD.
I think the properly way to do that is mount the SD on StartOS3 methods in vsos_vs1005g.c file.

Something like this:

Code: Select all

#ifdef USE_SD
	static DEVICE devSdSd;

	SysReport("Internal Flash");
	
	DevSdSdCreate((DEVICE *)(&sdCard), NULL, 0); /* Always succeeds */

	sd_sysdevice = 'D'-'A';
	SysReport("%c: SD card in SD mode", 'A'+sd_sysdevice);
	original_device_pointer = vo_pdevices[sd_sysdevice];
	vo_pdevices[sd_sysdevice] = (DEVICE *)(&sdCard);
#endif
I've copied this code from the SDSD library, but it gives me some error.

Could you help me?

Thanks
Patrick

User avatar
Panu
VLSI Staff. Currently on holiday.
Posts: 2733
Joined: Tue 2010-06-22 13:43

Re: Libraries & Config files on SD

Post by Panu » Thu 2018-03-22 10:18

Hi!

The last version to use SD card as system disk was 2.50 I think. Since then I've just made one experimental kernel for another engineer Hannu, that uses the SD card as the system disk, and that used the old SPI mode SD driver. The code to activate the SD card is in a "#if 0 ... #endif" block in vsos_vs1005g.c, but the SD card driver source .c files are not included in the solution.

The best solution would be to take the SDSDMONO driver and include its source code files into the kernel. The normal SDSD driver actually loads the initialization parts of it from the file system - which is impossible to do if you don't have an S: file system. But the SDSDMONO driver is monolithic, e.g. it contains all the code in itself, including the initialization code. So there is a rather large memory usage penalty to include it all in the kernel.

But if you like to do that, you can include the c files in the kernel, and then adjust the memory description file (in the "Other" files in the solution browser) to allow the kernel to use more memory, and finally adjust the APP_I_START etc macros in the kernel to remove that memory from application use.

I'll ask Hannu if he can find that experimental kernel and post it here, in case it's useful. But due to the high memory cost of having the whole SD driver always in memory, I hope that you can consider to use the "normal" way things work, e.g. loading drivers from flash and media files from SD card.

Do you have a specific reason to load all drivers from the SD card? Maybe I can help you to make a work-around..? Note that you can load drivers and run programs from any disk, but you need to use the full file name, such as "D:SYS/INTTRACE.DL3" instead of just "INTTRACE" which automatically expands to "S:SYS/INTTRACE.DL3"

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Hannu
Senior User
Posts: 79
Joined: Mon 2016-05-30 11:54

Re: Libraries & Config files on SD

Post by Hannu » Thu 2018-03-22 11:03

Hello!

Here is experimental VSOS system on SD card. It is used on VS1005 developer test setup and I have only booted it through vs3emu. So testing has been it compiles, boots and runs some set of programs.

How I use it:
On SD card I have CONFIG.TXT file and SYS directory which has all the needed drivers and programs to create working developer board.
Config and drivers aren't in package, but they are same as normal kernel would like to have.


What to do next with it:
  1. Study the source and compare the differences compared to a normal 3.42 kernel.
  2. Port the changes to your kernel of choice.
  3. Try to flash it.
  4. Report bugs
As Panu said, the normal system on external flash has much more benefits.
Attachments
VSOS342sd.zip
Expiremental VSOS3.42 system on SD card kernel
(269.87 KiB) Downloaded 56 times

PatrickFolci
User
Posts: 14
Joined: Mon 2018-03-19 11:02

Re: Libraries & Config files on SD

Post by PatrickFolci » Fri 2018-03-23 11:00

Hi Guys,

Thanks for you answer, I was finally be able to set SD as S:.
What I've done is implement SDSD and SDSDX library directly inside the kernel.
Effectively this give me some memory error, I've solved it by removing SPI flash management from the kernel.

I agree with you about the possibility to store all the system information in the flash, but looks complicated.
The kernel attached works properly and I'll be able to start the INIT.ap3 from SD and give S:SYS in SD file system.

If you can provide me an idea how proceed to store library and config inside the flash this will be appreciated.

Thanks.
Patrick
Attachments
KernelSD.zip
(778.95 KiB) Downloaded 52 times

PatrickFolci
User
Posts: 14
Joined: Mon 2018-03-19 11:02

Re: Libraries & Config files on SD

Post by PatrickFolci » Mon 2018-03-26 12:25

Hi Panu,

I'm trying to follow your suggestion and put config files inside the an external SPI flash.
Anyway I'm not able to propose my SPI flash on USB connector, could do you help me on that?

Thanks
Patrick

PatrickFolci
User
Posts: 14
Joined: Mon 2018-03-19 11:02

Re: Libraries & Config files on SD

Post by PatrickFolci » Mon 2018-03-26 13:55

Hi Panu,

Finally using the kernel attached by Hannu and porting it on 3.50 I have a stable kernel using SD as S:.
Now I'm facing another problem: when I run INIT.ap3 it gives me an error.

Code: Select all

App exit, result: -1.
E'Too old APP'
I've read the topic related this, but not make sense for me because I'm using last 3.50 kernel and I've made a new Main Menu Application as it is.
I've tried also with a Universal project leaving it as it is but same result.

Maybe I'm doing something wrong ... Could you give me a feedback to understand how proceed?

Thanks
Patrick

P.S. I'm using VSIDE v2.43.
P.P.S I've tried the root files found in "VSOS_352_RootAndLibrariesSourceCode.zip" file and gives me same error.

PatrickFolci
User
Posts: 14
Joined: Mon 2018-03-19 11:02

Re: Libraries & Config files on SD

Post by PatrickFolci » Tue 2018-03-27 15:04

Hi Guys,

Some good news:
1) I can confirm that, starting from kernel posted by Hannu (btw thanks), I've a fully working and stable kernel working as S: on SD based on 3.55
2) I have solved the problem related to "E'Too old APP'"; it was my fault: I've format the SD as FAT instead of FAT32 so the system was able to "found" the file, but not read it properly.

Now I'm trying to play loop a file, that looks tricky; maybe I'm doing something wrong, but I'm not able to loopback it. If you have any suggestion will be appreciated.

Another open point is if is convenient to keep SD as S: or found a way to store the information inside an external flash.

Thanks
Patrick
Last edited by PatrickFolci on Tue 2018-03-27 15:38, edited 1 time in total.

PatrickFolci
User
Posts: 14
Joined: Mon 2018-03-19 11:02

Re: Libraries & Config files on SD

Post by PatrickFolci » Tue 2018-03-27 15:38

Hi all,

Small update, I'm now able to loop back the file, but it is not "continuous" there is small empty window (very small I was not able to trigger it with the scope) audible.

Thanks
Patrick

PatrickFolci
User
Posts: 14
Joined: Mon 2018-03-19 11:02

Re: Libraries & Config files on SD

Post by PatrickFolci » Tue 2018-03-27 16:15

Hi,

I've tried as suggested by Hernik in this post viewtopic.php?f=13&t=1974&p=9993&hilit=file+loop#p9995, but looks not working for MP3 files.

This is my code for decoding:

Code: Select all

void DecoderTask() {
	struct CodecServices *cs;
	char cExit = '\0';
	
	fp_Input = fopen(s_FileName, "rb");
	if(!fp_Input)
		goto Finally;
				
	printf("Playing '%s'\n", fp_Input->Identify(fp_Input, NULL, 0));

	//while(!cExit) {
		RunLibraryFunction("METADATA", ENTRY_2, (int)fp_Input);
	
		pobj_Decoder = CreateAudioDecoder(pui16_AuDecLib, fp_Input, stdaudioout, NULL, auDecFGuess);
		 
		// Initialize loop: write all values first, and as the last thing set cs->loop.
		// Do not modify loop parameters while looping, except for numberOfLoops (to have 
		// infinite looping, set it to 0xFFFFFFFFU, to stop looping, clear it. 
		*cs = pobj_Decoder->cs;
		memset(&codecLoop, 0, sizeof(codecLoop));
		
		codecLoop.startSeconds = 0;
		codecLoop.startSamples = 0;
		codecLoop.endSeconds = 0xffffffffu;
		codecLoop.endSamples = 0;
		
		codecLoop.numberOfLoops = 0xffffffffu;
		
		pobj_Decoder->cs.loop = &codecLoop;
		//printf("\nLoop Configuration\n");
	
		StartTask(TASK_DECODER, PlayerThread); 
		Delay(100);
		
		while(pSysTasks[TASK_DECODER].task.tc_State && pSysTasks[TASK_DECODER].task.tc_State != TS_REMOVED) {
			static u_int32 oldSeconds = -1;
			if(pobj_Decoder->cs.playTimeSeconds != oldSeconds) {
				oldSeconds = pobj_Decoder->cs.playTimeSeconds;
				//printf("\n%[%02ld:%02ld]\n", oldSeconds/60L, oldSeconds%60L);
			} //End if
	
			//ReadToDo();
			//cntDebounce();
			
			//if(uc_Index == 0x00) {
			//	if(pobj_Decoder)
			//		pobj_Decoder->cs.cancel = 1;
			//} //End if
			
			Delay(1);
		} //End while
		
		printf("\nFILE END\n");
		
		if(pobj_Decoder) {
			DeleteAudioDecoder(pui16_AuDecLib, pobj_Decoder);
			pobj_Decoder = NULL;
		}//End if

	//	fseek(fp_Input, 0, SEEK_SET);
	//} // End while

	Finally:
	if(pobj_Decoder) {
		DeleteAudioDecoder(pui16_AuDecLib, pobj_Decoder);
		pobj_Decoder = NULL;
	}//End if
		
	if(fp_Input) {
		fclose(fp_Input);
		fp_Input = NULL;
	}//End if
}//End DecoderTask

void PlayerThread(void) {
	i_Code = DecodeAudio(pui16_AuDecLib, pobj_Decoder, &pc_Str);
} //End PlayerThread
and this how it is called in main:

Code: Select all

	// Decode the file and play on the output
	uc_Index = 0x01;
	sprintf(s_FileName, "S:files/%u.mp3", uc_Index);
	printf("\nRead: %u\n", uc_Index);

	DecoderTask();
Also, the library PlayFileLoop seems not playing file in loop.

I have no idea how proceed, please give me a feedback on that.

Thanks
Patrick

PatrickFolci
User
Posts: 14
Joined: Mon 2018-03-19 11:02

Re: Libraries & Config files on SD

Post by PatrickFolci » Wed 2018-03-28 10:10

Hi,

Ok, I've temporary solved by pushing back file pointer to start of file; it gives me a small empty window, but could be OK for now.

Now I'm passing to manage the operations that chip should do based on GPI configuration.
My idea is to do something similar you are doing for the CONFIG.TXT; so the idea is to remove from the kernel the INIT.ap3 launch and put a while(1) to continuously checking pin status and run/stop properly application.

That should not a problem, but I need to pass something to the application in order to stop it or I can simple drop it? If yes how I can have a shared memory between applications and kernel?

If I generate an interrupt on GPI change and I've an application running, the interrupt will be managed by the kernel or not?

Note: 1 application will be running at time.

Could you give me answer to that please? I know that you are full o work and Easter is arriving, but need a starting point for that.

Thanks
Patrick

Post Reply