Software in two separate programs

Writing software that controls the system and peripherals such as displays, SD cards, Buttons, LEDs, Serial Ports etc.
Post Reply
Posts: 1
Joined: Fri 2010-11-19 19:59

Software in two separate programs

Post by ThomasG2010 » Wed 2010-12-22 20:01

Hello Panu,
I work with the V1000b on an own 4-Layer-PCB. The programs are in flash.
Everthing runs ok: play .ogg-Fils; work with display; work with Key-Events; USB-Connection
But i have many code. For code space reasons the software is in two separate programs.
Fallowing you can see a small seperation from the complete software.
i have a problem with the functions that copy a new seperate program from flash to the DSP-CODE-RAM
and started it. That doesn't work.
Description: The 1.program only copy the second program in RAM and start it. I can see, that the code is complete in the RAM, but it runs not correctly. If i start the 2.program direct (without 1.program) it works good.

Fallowing you can see the two programs and the batch-file to build it:
1.Programm "FW1_Menue.c":

Code: Select all

extern struct FsNandPhys fsNandPhys;
extern struct FsPhysical *ph;
void main(void)
  while (1) 
	  ((struct FsNandPhys *)ph)->waitns += 40;
	  ph->Read(ph, 512/512, 8192/512, mallocAreaX, NULL/*minifatBuffer*/);[/i]
	  ((struct FsNandPhys *)ph)->waitns -= 40;
	  ((struct FsNandPhys *)ph)->waitns += 20;
2.Programm "FW_Player.c":

Code: Select all

void main(void)
      InitMC();  // Initialisierung der IOs  

%VSBIN%vcc -P130 -O -fsmall-code -I include -o fw1_menue.o FW1_Menue.c

%VSBIN%vcc -P130 -O -fsmall-code -I include -o fw2_player.o FW2_Player.c
# REM ###### FW1_Menue Link ----------------------------------------------
# echo Linking for Nand Flash loading... (combining with libraries)
%VSBIN%vslink -k -m mem_user -L lib -lc -o fw1_menue.bin lib/c-nand.o lib/rom1000.o fw1_menue.o

# REM ###### FW2_Player Link ----------------------------------------------
# echo Linking for Nand Flash loading... (combining with libraries)
%VSBIN%vslink -k -m mem_user -L lib -lc -o fw2_player.bin lib/c-nand.o lib/rom1000.o fw2_player.o

# PLAYER.IMG: fw2_player.bin
%VSBIN%coff2nandboot -x 0x50 -n fw2_player.bin FW2_PLAYER.IMG

# MENUE.IMG: fw1_menue.bin
%VSBIN%coff2nandboot -t 3 -b 8 -s 19 -x 0x50 menue.bin FW1_MENUE.IMG

%VSBIN%combineimg -o Output_256M.IMG -m 65536 +0 FW1_MENUE.IMG +512 FW2_PLAYER.IMG

in the Attachment are the complete files

Thank you for your help
(10.85 KiB) Downloaded 456 times

User avatar
VLSI Staff
Posts: 2782
Joined: Tue 2010-06-22 13:43

Re: Software in two separate programs

Post by Panu » Thu 2010-12-23 22:31

I need a lot more time to take a good look at your e-mail, but here are some quick remarks...

My favorite way to extend a program is to use overlays. Have you seen the post about overlays for VS1053? I now have working overlays also for VS1000 + SPI flash, but it's not published yet. Would you like to try it?

The most simple way to extend a program with VS1000 is to use Exec(). See our legacy example "ExecDemo"... seems your code is somewhat similar. Maybe the Exec could be useful as an example. The ExecDemo uses the FAT file system to load and run programs.

If you use the SPI flash, there is a really easy way to completely reload the running program... a ROM function called SpiLoad(startingAdderss, boolUse24bitAddress) reloads the image from a given address on the SPI flash. It's really easy, but not that convenient because you cannot return to the first program. That's why I developed the overlays... The overlays are modules (like standard programs), which have "Entry" functions that are of type int Function(int). Whenever you call such a function, the system loads the overlay module, runs the function, and loads back the overlay(if any) from which the call was made. Elegant and simple. All my new projects use overlays. But I haven't made a loader for nand flash yet. Though that would be very easy...

just some thoughts...

Merry Christmas!


P.S. By the way... since I don't want to take false credit... I did not invent overlays... the theory of overlaying was already complete in the 1970's... I just implemented them for VSDSP... :)
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

User avatar
VLSI Staff
Posts: 1750
Joined: Thu 2010-07-15 16:04

Re: Software in two separate programs

Post by pasi » Fri 2010-12-24 10:22

ThomasG2010 wrote: i have a problem with the functions that copy a new seperate program from flash to the DSP-CODE-RAM and started it. That doesn't work.
Does the second program work if started from FLASH directly, or are you only loading it from the emulator?

The OLED display startup is not the most reliable on the vs1000 developer board. In some code we have added some delays to wait for it to come up from power-on-reset before initializing it.

I have used multiple programs in several projects, including the mlcplayer example. There I use the error correction code to make sure the code is loaded correctly (the flasher needs to write with ECC).

If you switch programs more than once, you should use c-restart.o or c-spi.o, otherwise each switch consumes a bit of stack and eventually crashes during playing.
Visit VLSI Solution on Facebook

Post Reply