Better HN
topnewbestaskshowjobs
Log inSign up

drozd

48 karma · joined Jan 16, 2016 (10y ago) · 24 submissions

Submissions

comment 3y ago · link · parent

The linker script specifies that .data section starts where 192k RAM region starts - in other words, addresses of all variables, etc, are in the RAM memory range.

But the firmware image (that resides on flash), which has .text and .data concatenated, has that .data section in Flash region, obviously. So we have .data section residing in Flash region, but all its addresses in the RAM memory range. That's why it is necessary to copy it over manually.

Hope this is clear... Let me know if not!

2.

A bare metal programming guide(github.com ↗)

26 points · by drozd · 3y ago · 7 comments

3.

Control Arduino Uno via AWS Device Shadow(youtube.com ↗)

3 points · by drozd · 7y ago · discuss

comment 9y ago · link · parent

Fast prototyping is the answer. If you or some others are skilled in C/C++, you don't need JS.

For others, having a simple way to prototype fast on the target hardware is a big benefit.

comment 9y ago · link · parent

mJS allows you to use C/C++ SDK functions directly without writing a glue code - basically, you can prototype things quite fast with the libraries/drivers that do not have any scripting support yet.

comment 9y ago · link · parent

That's right, cause Linux cannot run on the large class of microcontrollers - particularly, those with less than 4M of RAM. Mongoose OS is targeting that category.

comment 9y ago · link · parent

JS is for prototyping.

comment 9y ago · link · parent

Sure, try to run those on e.g. TI CC3200 microcontroller.

comment 9y ago · link · parent

I think Mongoose was called mongoose before mongo db plugin existed.

https://github.com/cesanta/mongoose - that's the project from which Mongoose OS stems.

comment 9y ago · link · parent

Ah, thanks, wrong about flash footprint. Neil has done a great job adopting Duktape on ESP32.

comment 9y ago · link · parent

Hi Gordon! Nice to meet you :) I am the author of the article, and I am quite fond of Espruino, it's a great project. Wasn't aware that Espruino has FFI API!

comment 9y ago · link · parent

Yes. Closures add quite a bit of complexity and footprint. Anticipated use case was a short script that orchestrates the device logic, calling existing SDK functions.

comment 9y ago · link · parent

Nice! I wasn't aware of lua ffi api, thank you!

comment 9y ago · link · parent

Nope. It's similar though, cause some of the concepts, and the code, were reused. mJS does not need an embedding API, really. The intent is that FFI is used.

comment 9y ago · link · parent

Embedded environment in this context means hardware low on resources, e.g. microcontrollers. Your perception of that word is "embedded into the C/C++ program". These are two different things. I agree that Lua (like some other languages) were designed to be embedded into C/C++ apps.

comment 9y ago · link · parent

Duktape is nice, and I've mentioned it in the article. However it's quite fat, and can't be used on some boards like ESP8266. It's flash footprint is Megabytes, whereas mJS flash footprint is ~25k.

comment 9y ago · link · parent

I recall that very much the same opinions were expressed about the JS and backend programming, until node.js appeared. Now the reality is different.

To be honest, we do not think that JS is a good language for embedded. Like any other existing popular scripting language. Perhaps scripted Go would be a better choice.

The point is that in many, many cases scripting brings a lot of benefits to the embedded environment. It all depends on a specific tasks - for some tasks, scripting will never be appropriate.

comment 9y ago · link · parent

There is no yacc code in either V7 or mJS.

V7 uses hand-written recursive-descent parser. Initially, it was using ordinary C functions, and that created a problem on systems with low stack size. E.g. each '(' starts statement parsing from the top, so 1 + (2 + (3 + (4 + 5))) consumed stack, and sometimes resulted in stack overflow in e.g. interrupt handlers or network callbacks.

Therefore we have rewritten recursive descent using C coroutines, and that is extremely sophisticated piece of work. See https://raw.githubusercontent.com/cesanta/v7/master/v7.c , search for #line 1 "v7/src/parser.c"

mJS on the other hand uses lemon parser generator - the one from sqlite project. It generates a LALR parser which is quite efficient in terms of memory.

comment 9y ago · link · parent

Currently we use mJS in our Mongoose OS firmware framework. There, a symbol resolver is generated automatically from the configuration file which tells which symbols you'd like to use.

https://github.com/cesanta/mongoose-os/blob/master/fw/exampl...

comment 9y ago · link · parent

The ability to script without the need of rebuilding/reflashing the whole firmware is often fairly useful. The most value is not in JS per se, but in the ability to script.

comment 9y ago · link · parent

Currently, mJS FFI is limited to functions only. And, to simple enough functions.

On how to access memory from mJS: write an accessor function!

    // C
    void setmem(uint8_t *ptr, int index, int value) {
      ptr[index] = value;
    }

    // mJS
    let setmem = ffi('void setmem(void *, int, int)');
    let malloc = ffi('void *malloc(int)');
    let mem = malloc(10);
    setmem(mem, 3, 5);

22.

JSON parser/emitter for embedded systems with printf/scanf semantics(github.com ↗)

1 points · by drozd · 10y ago · discuss

23.

V7 – the smallest embeddable JavaScript engine(github.com ↗)

2 points · by drozd · 10y ago · discuss

24.

Implementing “real” Posix Filesystem on TI CC3200(blog.cesanta.com ↗)

7 points · by drozd · 10y ago · discuss