No announcement yet.

Run multiple 4dscripts from RAW partition

  • Filter
  • Time
  • Show
Clear All
new posts

  • Run multiple 4dscripts from RAW partition

    [UPDATE: 2013/01/26 -
    I stored my two scripts at 0x1e8000 and 0x2e8000 and I can run multiple scripts. Sadly I would like to set up hundreds of these little helper scripts for special UI purposes, so I'm concerned about what this address actually means and how it pertains to SD card memory layout.

    Apparently the RunScriptRaw only looks at the most significant bytes. I tested this by calling it with 0x1eFFFF and it still called my script supposedly stored at 0x1e8000. Can this insane behaviour be explained please?!



    Our display is running at a custom 500x410 resolution so I can double buffer.

    I have multiple scripts I use to draw the display's background.

    I have opted to use scripts because the fill rate of the picaso is too slow to blit a BMP.

    I am comparing the performance of running a script from FAT vs RAW. There are certainly fewer bytes being transfer with RAW mode so I like that. plus the lack of response code is better. I do beleive this is the right approach.

    I have managed to save my scripts to the RAW partition using either scriptC or directly from Workshop.

    However, When I run my PIC32 program, only the first script is getting executed, even if I pass the second script's address.

    each script is tiny. 1st: 440 bytes, 2nd 439 bytes. I've noticed the RAW partition seems to use 512 byte blocks. I purposely put the two script's starting address 4096 bytes apart to insure they weren't overlapping.

    The top of each script reads thusly:
    #Origin 0x001f8000


    #Origin 0x001f9000

    //kExtendedCmd        = 0x40
    //kRunScriptFromFAT  = 0x70
    //kRunScriptFromRAW  = 0x50
    //  PICASORunScriptRAW(0x00,0x1D,0x80,0x00);  
    //  wait for script to finish running by reading a terminate character/or error
    //  PICASORunScriptRAW(0x00,0x1D,0x90,0x00);
    //  wait for script to finish running by reading a terminate character/or error
    // helper macro
    #define PICASORunScriptRAW(addr1, addr2, addr3, addr4) \
                                            do { \
                                            PutChar(kExtendedCmd); \
                                            PutChar(kRunScriptFromRAW); \
                                            PutChar(addr1); \
                                            PutChar(addr2); \
                                            PutChar(addr3); \
                                            PutChar(addr4); \

    If I purposely store each script in the other's address, then I get the other script appearing instead. So as best as I can tell, I'm only able to address one script. I don't understand.

    (Separate question: is there any way to inspect the bytes stored in the RAW partition from windows? or via the programming cable?)

    (Another separate question: now that I HAVE a RAW partition, I can no longer load scripts from the FAT partition. I can copy files to it in windows, but I get an error if I try to run the script using this helper macro:

    //  PICASORunScript("s50m.4ds");
    //  wait for script to finish running by reading a terminate character/or error
    // helper macro
    #define PICASORunScript(scriptName) \
                                            do { \
                                            char *p; \
                                            PutChar(kExtendedCmd); \
                                            PutChar(kRunScriptFromFAT); \
                                            p = scriptName; \
                                            while(*p) \
                                            { \
                                                PutChar(*p); \
                                                ++p; \
                                            } \
                                            PutChar(0x00); \
    Any help is appreciated.

    [EDIT: update 2013/01/25]
    I merged my two scripts into one larger script (879 bytes). I called my RunScriptRAW macro with the base address of the script and I get the first script's data, then I called the script with the base address + offset to the second script and I inexplicably get the first script only.
    PICASORunScriptRAW(0x00,0x1D,0x80,0x00); // gives me my first script as expected

    then I change the call and ran it again:
    PICASORunScriptRAW(0x00,0x1D,0x81,0xb8); // 0x1b8 == 440 == offset to second script

    and the FIRST script runs. this makes no sense to me at all. Do I have the addresses set up wrong?

  • #2

    The origin is the byte offset into the RAW partition of the uSD card (or from the start of the card if there is no partition and it is not formatted).

    As for the wrong script running all I can guess is that maybe the wrong script has been previously saved at that offset and that the right script needs saving there?