Announcement

Collapse
No announcement yet.

Max program size?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Max program size?

    I have noticed that once my program get's to about 12 kilobytes it will no longer mount the SD card, which pretty much renders my program useless. Is there any way to fix this? I have tried separating my program into different files and running from each other but I can't seem to get file_Run or file_Exec to work. Anybody have any ideas on how to fix this?

  • #2


    If you aren't using #MODE RUNFLASH then your program 'executable' will be using RAM as well as the RAM required to actually run the program, so that is probably your problem.

    Add #MODE RUNFLASH near the start of your program and see if that fixes your problem. Note that the program will run slower, this may or may not be an issue for you
    Mark

    Comment


    • #3


      are you running your program with the

      #MODE RUNFLASH

      option in your code?

      If that is missing, your program is actually running from RAM and consuming a possibly hefty chunk or ram. Programs do run faster from RAM, but in most cases
      this will not be an issue and is only realy noticable when using intensive loops. Graphics functions will not suffer any penalty.
      Aything that is time critical can be loaded then discarded later by using the file_LoadFunction function
      Regards,
      Dave

      Comment


      • #4


        What they said... BUT.. maybe a month or so ago I posted a skeleton code for multiple files running from SD card... perhaps do a search for posts by me..

        I have a small boot loader which swaps between 4 main programs each of about 9000 bytes.. One of them is a PC Coms program which when linked to my PC application will auto-update the 4FN files on the uSD card.. so it makes loading new programs onto the devices heaps quicker.

        See if you can find the post, otherwise let me know and I will see if I can find the skeleton code.

        Andy
        MicroLec Industries P/L
        www.intelligym.com.au

        Comment


        • #5


          Here's a base to get started with running multiple files. Most of the thanks must go to the 4D guys for helping me to get this going in the first place..




          I just compiled and tested these programs they work... load boot.4dg into flash, and put the other two programs '.4FN's' on the uSD card.

          Andy
          Attached files boot.4dg (3.4 KB) prog1.4dg (2 KB) prog2.4dg (2 KB)
          MicroLec Industries P/L
          www.intelligym.com.au

          Comment


          • #6


            I'm having some issues with program size myself. I'm using a main program which is running in flash mode and loading sub programs with file_Run(). Firstly, when running one program from flash or ram or when using a main program and file_Run() problems seem to start occurring when the total program size + stack allocation reach around 12kbytes instead of the 15 that are supposed to be available. I thought I saw a post relating to this mentioning a new pmmc that would fix it? Next, when my total program size gets too big, there isn't any kind of warning, things just start acting weird. I try to play a wav file and I hear the driver switch on but the file doesn't play. Or I press a button and the device just resets for no reason. A memory collision causing an invalid instruction to be executed or something maybe? Finally, If my main program is running in flash, and my sub programs are called with file_Run() to run in RAM, shouldn't my main program be able to use the full 15k of flash and my sub program have the full 14k of RAM? Minus any overhead for variables and stack allocation in each of course. Just about all the problems I've been having with this thing are to do with memory allocation or context switching and variable and function addresses. A detailed description of how the memory in this thing operates would go a long way towards helping me and I think a few others here understand how the Picasso actually works.

            Comment


            • #7


              I reckon just make your files smaller, and have more programs.. then you don't have to worry about detail like complex memory management.. 4D have done that for you

              Andy
              MicroLec Industries P/L
              www.intelligym.com.au

              Comment


              • #8


                Hey guys thanks for the ideas. I had been trying to do what Animilector was suggesting before but I missing that #MODE RUNFLASH command so it wasn't working. Got my program split up into a bunch of smaller files now, thanks guys!

                Comment


                • #9


                  Hello:

                  I am having a hard time getting my sub-programs to return without crashing the main. The first problem was that I didn't have enough memory for the main program to run. I fixed that but it is still an issue.
                  The main still crashes when I return, but I have noticed that if I use file_LoadFunction, instead of file_Exec that it works a little better, does Loadfunction work differently or more effectively when returning from a sub-program than file_Exec ?

                  Comment


                  • #10


                    file_exec and calling a loaded function are almost identical, the only difference is the layout of the arguments.

                    Have you reviewed App note 4D-AN-P2005 http://www.4dsystems.com.au/appnotes/ it has an example in it.
                    Mark

                    Comment


                    • #11


                      Thanks for your reply, but yes I did see that appnote and I am still baffled. I launch the sub program like this:

                      else if (n == iWinbutton21)
                      gfx_Cls();
                      mem_Free(hndl);
                      Enable_Buttons();
                      file_Exec("kbImage1.4XE",0);
                      Show_Main();
                      When I do I have over 14K of mem available. When I exit the sub program, I do it like this:

                      else if (n == iWinbutton25)
                      mem_Free(hndl);
                      mem_Free(hFont2);
                      mem_Free(hFont3);
                      file_Close(hstrings) ;

                      return;
                      and I have over 14K of mem available, but instead of returning it blinks and resets. What method do you use to find out what the problem is. I have tried everything I can think of. As always thanks for your help.

                      Mark

                      Comment


                      • #12


                        Not sure that I have everything I need to solve this but I see

                        mem_Free(hndl);

                        Before the file_Exec, but I don't see you opening the handle again after you return
                        Mark

                        Comment


                        • #13


                          OK, that's a question that brings up another question, when the program returns, it was my understanding that the program control begins at the point right after it was transferred to the sub-program.
                          So in the main program:

                          if (n == iWinbutton1)

                          mem_Free(hndl);
                          gfx_Cls();
                          file_Exec(Keyboard,0);
                          gfx_Cls;
                          show_Main();

                          Comment


                          • #14


                            You're right, when a sub program exits it just keeps on going where it left off. Unless you use file_Run() which, as far as I remember, returns back to the beginning of your main program.

                            Sounds like you are looking for something like this to reallocate the memory and the hndl pointer.

                            hndl := file_LoadImageControl("NoName1.dat", "NoName1.gci", 1);

                            That's the function that loads the image handle into ram and sets 'hndl' to point at it. You'll probably want to look at the beginning of your program for the same line so that you can get the correct filenames if they are different. I assume you are using Visi and this line has already been generated for you.

                            You should be able to do this anywhere in your program that you want as long as your careful not to open it unless you're sure it has been freed with mem_Free(). To make sure that never happens you could simply always free 'hndl' before loading it again... like this.

                            mem_Free(hndl);
                            hndl := file_LoadImageControl("NoName1.dat", "NoName1.gci", 1);

                            Anyway, I'm sure that's more advice than you were hoping for... hope it helps!

                            Comment


                            • #15


                              file_Run() also returns to the next statement, the difference is whether your allocate memory is retained or lost.

                              Depending on what your called function did and what you changed in your image control before you freed the handle (image_index for example), all you may need to do is reopen the image control.

                              Or you may need to redisplay your screen, it really depends on your program.
                              Mark

                              Comment

                              Working...
                              X