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.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
As mentioned in previous post, this post gives more information about loading an assembler based module.
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)
An example, how this can be used is this:
BTW, I had some experience with assembler many years ago. This is my first attempt in ARM assembler, any hint is welcome.
1 Attachment