You are reading a single comment by @JumJum and its replies. Click here to read the full conversation.
  • As mentioned in previous post, this post gives more information about loading an assembler based module.

    var asm = require("ASM");
    asm.setup(true);
    asm.loadLibrary({
      varName:"Flash", fileName:"node_binaries/FLASH.BIN",
      functions:[
        {name:"read",format:"int(int)"},
        {name:"unlock",format:"void()"},
        {name:"write",format:"void(int,int)"},
        {name:"erase",format:"void(int)"},
        {name:"copyMem",format:"void(int,int,int)"},
        {name:"pageSafe",format:"int(int)"}
      ]
    });
    
    console.log(asm.listBinaries());
    
    

    A binary file is loaded from fileName and creates an object named by varName.
    This holds functions given by functions array.
    Flash.read(adr) // returns an int-value from adr
    Flash.unlock // unlocks flash memory, so you can change values
    Flash.write(adr,value) // writes value to adr
    Flash.erase(adr) // erases fullpage starting at adr
    Flash.copyMem(source,destination,length) //copys from "length" bytes from source to destination
    Flash.pageSafe(adr) // checks page for safe writing, returns 0 if safe

    The assembly file holds a list of branches on top like this (see attached ASM file)

    thumb;
    ;jump table for functions in this library
            b read          ;Flash.read(adr) adr is word aligned (word size 4 bytes)
            b unlock        ;Flash.unlock()
            b write         ;Flash.write(adr,val) adr is word aligned 
    .....
    
    

    An example, how this can be used is this:

    console.log(asm.listBinaries());
    console.log("pageSafe",Flash.pageSafe(adr));
    console.log("read (0x0803E000):",Flash.read(adr).toString(16));
    Flash.unlock();
    console.log("unlocked");
    Flash.write(adr,0xFFFFFFFE);
    console.log("new value (-2) written");
    console.log("read new value:",Flash.read(adr).toString(16));
    Flash.copyMem(adr,adr+16,4);
    console.log("copyMem done");
    console.log("read target",Flash.read(adr+16).toString(16));
    console.log("pageSafe, (should be <> 0):",Flash.pageSafe(adr).toString(16));
    Flash.erase(adr);
    console.log("erased");
    console.log("pageSafe, should be 0:",Flash.pageSafe(adr).toString(16));
    
    

    BTW, I had some experience with assembler many years ago. This is my first attempt in ARM assembler, any hint is welcome.


    1 Attachment

About

Avatar for JumJum @JumJum started