-
-
I tried to get a better understanding of flash memory on Espruino board.
First check was done to find safe memory using isPageSafe from http://www.espruino.com/STM32F1Flash.
Bad success on whatever adress I used (process.memory().flash_binary_end+2047)&~2047 and 0x0803E000
Next tried to figure out size of binary using
process.memory().flash_binary_end - 0x08002800
This returns 162052 bytes. Last binary size(1v67, 1r3.bin) in download is 172516.
Even this is much smaller than 1v66, is it reduced from 215K to 168K ?
BTW, as far as I understand, there is a typo in notes where 0x080002800 to process.memory().flash_binary_end should be 0x08002800 to ...
To avoid destroying something, could somebody give me some help ? -
Let me try with other words.
The assembler module is designed to support handling of multiple binaries from everywhere (module or main code). We don't have too much experience with binaries, anyway my expection is that they are stored in memory in most cases. To be useful, the modul should be small.
The decision of storing in Flash is project specific. If somebody wants to copy binaries to flash, it would be helpful to have a function in the module for Flash handling. Some other functions like copy arrays to Flash may also be helpful.
In my project, this is not the case (yet?). Therefore I'm not asking for it. And I will not extend ASM module.
-
-
Module could be like this
/* Copyright (c) 2014 Juergen Marsch, Pur3 Ltd. See the file LICENSE for copying permission. */ /*! **/ var ASMList,ASMBase; ASMBase = process.memory().stackEndAddress; ASMList = []; exports.connect = function(){ function ASM(){ this.loadArray = function(varName,format,arr){ var a = {name:varName,format:format,start:ASMBase + 1}; for(var i = 0; i < arr.length; i++){ poke16(ASMBase,arr[i]); ASMBase += 2; } ASMList.push(a); eval('var ' + a.name + ' = E.nativeCall(' + a.start + ',"' + a.format + '");'); }; this.loadSD = function(varName,format,fileName){ var arr,fs = require("fs"); arr = new Uint16Array(E.toArrayBuffer(fs.readFile(fileName))); return(this.loadArray(varName,format,arr)); }; this.list = function(){ return ASMList; } } return new ASM(); }
It could be used like this
var x = require("ASM").connect(); x.loadArray("tst1","int(int,int)",[0x1840,0x4770]); require("ASM").connect().loadArray("tst2","int(int)",[0x4770]); require("ASM").connect().loadSD("tst3","int(int,int)","node_binaries/adder.BIN"); console.log(require("ASM").connect().list()); console.log(tst1(2,6) + " should be 8"); console.log(tst2(3) + " should be 3"); console.log(tst3(4,5) + " should be 9");
I can't follow the comment about STM32F1Flash. That module already exists in your collection. Which kind of data would you write from ASM to Flash ?
I would like to keep ASM module as small as possible, so it doesn't add load which is used in special cases only. -
I was searching for a way to handle assembler code.
Web Editor supports this in a nice way, but how should assembler be treated in modules.
So a small object was born, which supports loading from array and/or from local sdCard.
Location for storage are calculated inside the object, so multiple binarys are easy to handle.
There is also a list of loaded binarys.function ASM(){ this.ASMBase = process.memory().stackEndAddress; this.ASMList = []; } ASM.prototype.loadArray = function(varName,format,arr){ var a = {name:varName,format:format,start:this.ASMBase + 1}; for(var i = 0; i < arr.length; i++){ poke16(this.ASMBase,arr[i]); this.ASMBase += 2; } this.ASMList.push(a); eval('var ' + a.name + ' = E.nativeCall(' + a.start + ',"' + a.format + '");'); }; ASM.prototype.loadSD = function(varName,format,fileName){ var arr,fs = require("fs"); arr = new Uint16Array(E.toArrayBuffer(fs.readFile(fileName))); return(this.loadArray(varName,format,arr)); }; //convert to a module by uncomment next line //exports.connect = function(){ return new ASM(); } ASMMod = new ASM(); //load binarys by name, format of variables and array or filename on SD ASMMod.loadArray("tst1","int(int,int)",[0x1840,0x4770]);//add r0,r0,r1 ... bx lr ASMMod.loadArray("tst2","int(int)",[0x4770]);// bx lr ASMMod.loadSD("tst3","int(int,int)","node_binaries/adder.BIN");//same as tst1 loaded as binary file from sdCard console.log(ASMMod.ASMList); console.log(tst1(2,6) + " should be 8"); console.log(tst2(3) + " should be 3"); console.log(tst3(4,5) + " should be 9");
-
-
-
-
-
Take a look to this node.js module. Its a simple solution.
https://github.com/philmod/node-pid-controller -
hello Benjamin,
sorry, but I missed your response.
For categories I could imagine to search on both levels, global and Espruino.
Major categories could be predefined- device :[Sensor,Actor,Display,Board,...]
- connection :[SPI,I2C,UART,CAN,...]
For each subcategory could be a freetext field which could be used to create additional filter - Sensor:[DS18B20,DH11,...]
- Display:[ILI9341, ....]
- device :[Sensor,Actor,Display,Board,...]
-
-
-
Good point,
I added cs off / cs on during reading from sdCard
With a constant color this works now, but ...- if color is red, it works fine
if color is green I get "Error: Invalid Pin!"
var c = 0x07e0; //Error: Invalid Pin! var c = 0xf800; // works fine for(var i = 0; i < img.height; i++){ ce.write(1); bmp = E.toArrayBuffer(file.read(img.width + img.width)); ce.write(0); for(var j = 0; j < 32; j++){spi.send(c>>8,c);} }
- if color is red, it works fine
-
I'm working on a function to draw bmp-files to ILI9341 display.
Idea is to read bmp file from local drive and send to display.for(var i = 0; i < img.height; i++){ bmp = E.toArrayBuffer(file.read(img.width + img.width)); spi.send(bmp.buffer); }
Data sent to SPI is somehow corrupted.
Checked sending color red and its corrupted.
Uncommented file.read and its working fine.Is there a problem using sdCard and SPI2 at the same time ?
-
-
-
Just tried actual IDE from GitHub.
Problems changed to other behaviour, thats it.
Same source, I sent succesful with previous version now chrashes.
Does not respond to anything now, even Ctrl-c is ignored.
I have to disconnect, reconnect to get connected.
Sometimes I get an errormessage which seems to show code is missing.
Looks like start of a function and next something from middle of another function.
Tested with and without throttle mode.
BTW, still have the starting problem where board recognition sometimes does not work. -
I'm more and more running into strange problems sending code to Espruino.
Main part of my app is a module for TFT Display and Charting.
Problems I found are strange errormesssages or even stop/crashes.
2 easy to follow examples are, problems seem to appear in large sources(900 block used) only.in a module 2 similiar command crash the execution
x = Math.round(x); //works fine
x = Math.round(x); //crashes with strange errormessage y = Math.round(y); // replacing this by a 2nd x =Math.round(x) also crashed
2nd problem is a simple definition of an object which stops everything if writing in 2 lines
wnds = [{left:50,top:100,right:150,bottom:200},{left:0,top:200,right:239,bottom:319}]; //this works
wnds = [{left:50,top:100,right:150,bottom:200}, {left:0,top:200,right:239,bottom:319}]; // this one stops without any message
Other strange behaviour could not be located (yet), I got errors on commented code to give an example. Uncommenting these lines moved the error message to another line, etc. etc.
I've been out of business due to a surgery for some weeks now, so I cannot give more information for when problems started.
-
Great job,
main topics for me are file support and bigram.
I'm working on a kind of datalogger with customized display.
Based on better filesupport I will be able to load some nice gimmicks from file to display. Working on a simple charting Module with lines, bars, points (and pie?)
Bigram will (hopefully)give me more freedom for extended functions.
One question around filehandling.- Is it possible to read from and write to specified location in a file ?
- Is it possible to read from and write to specified location in a file ?
-
-
It's very interesting, to see, what experts like Gordon can do with Javascript on this small board.
I learned a lot. But still the function is very slow. Reading a block of 20*20 pixel takes 0.6 seconds.
Therefore I gave the new assembler interface a chance and created a short function with flat assembler.thumb; lsr r0,#3 lsr r1,#2 lsr r2,#3 lsl r0,#11 lsl r1,#5 add r0,r1 add r0,r2 mov r1,r0 lsl r0,#8 lsr r1,#8 add r0,r1 mov r1,#65535 and r0,r1 return: bx lr
Next changed reading function in displaydriver to:
var zzz = new Uint8Array([0,0,0]); sData = sData.map(function() { var d = spi.send(zzz); return ILIcalc(d[0],d[1],d[2]); //ILIcalc is the name of new assembler based function });
Now it takes 0.34 seconds, 44% faster.
This is still not as fast as I would like, but it shows how helpful assembler can be. -
Just installed bigram and it works fine.
For a large application I was close to "out of memory" and now I have 1000 blocks free.
Thanks a lot !!!