Port of Espruino to Pi Zero - native - no Linux #6755
Replies: 1 comment
-
Posted at 2015-12-01 by DrAzzy I'm not sure how much sense that would make - Espruino can already run on linux, and, assuming the hardware peripherals can be used that way on the Pi zero (I thought they could be used from Espruino on a Pi?), I'm not sure there's much to be gained from making it run natively... And to do it and not even have USB or video? What is the point of a Pi Zero without USB or video? It seems like the wrong tool for the job to me... I think it would make more sense to run Espruino there on top of linux so you can take advantage of all the work that's been done to make the video and USB and all that good stuff work on the Pi Zero, and use the Espruino for the low level stuff where you're interacting over the GPIO pins. Posted at 2015-12-01 by tve Neil, I think this is actually a pretty interesting idea! I think there are a number of options along a spectrum, actually, and I'm not sure which would end up being the most interesting:
Posted at 2015-12-01 by Kolban @drazzy ... I'm still thinking the notion through. The announcement this week of the Pi Zero has changed the landscape. I had been anticipating C.H.I.P. ($8) and Onion Omega ($19) to have been game changers and didn't see a $5 Pi coming. Let us take a step back. Up until now, we had low end processors such as the Arduino and ESP8266 and also the dedicated (but pricier) dedicated Espruino boards. I am now going to take the Arduino out of the story since it doesn't have the ooomh to run Espruino. Now if we take the Pico as the gold standard for a platform for running Espruino ... we end up with a device that runs at 84MHz with 96KByte of RAM. It has no video and no USB output and retails at about $25. If we see value in that device ... what more value would we have in an equivalent device which has 1GHz processor speed, 512MB of RAM and GBytes of SD storage ... for a base price of $5. If we choose to use the Pi Zero as is, then the question becomes one of "What value is Espruino?". My thinking goes as follows ... I want to write applications. When I write applications, I have a choice of programming languages each suited to different purposes. If my purpose leads me to JavaScript ... the question becomes "which" JavaScript run-time environment should I choose? As far as I can see my choices are:
Over the last month, I've been eagerly awaiting my Onion Omega but @tve has been cautioning me that because it runs Linux, I may not be happy with what I find. I have no experience running Linux on small embedded systems so I took his cautions as very worthy of consideration. I have a Pi 2 Model B ... but since that is a quad core monster and also comes in at $35, I put that aside as "not applicable" to our comparisons. Without having had any experience nor read any empirical evidence, my "gut" (and it is only my gut) says that running an existing JavaScript runtime on the Pi Zero will be more than satisfactory for my personal needs. However, if the "cost" of running Linux interferes with what I or others may want to do ... then we eliminate Linux ... and run Espurino on the metal.... and that brings us to this post and the thought experiment. I see a flow chart here ... #1 run JavaScript as-is on Pi Zero on Linux and all is well - stop The question in front of us is one that hobbyists in combined electronics/computing like myself will see revealed over the next 6-12 months.... and that is where do we focus our tinkering? Historically it was Arduino because it was so easy and so cheap. Then came the Pi ... but that was really a computer and for some reason the price north of $20 caused us to pause ... we got all excited again about the ESP8266 ... not necessarily because it just had WiFi ... but because it gave us 80MHz processor and 40K of usable RAM for about $5. Now we have another turn of the crank and we have 1GHz processor with 512MB for $5. GULP!! Orders of magnitude improvement. I can imagine and understand folks saying ... ahhh ... but what about power consumption ... and other dimensions ... and those are all valid ... no question. But in some dimensions ... those that relate to CPU cycles and available RAM and price ... it seems we have just witnessed a dramatic leap forward that will take quite a while to beat. The reason I waffle down this path ... which appears unrelated to our Espruino discussions ... is that if (just IFF) my suppositions hold any merit, then all eyes will transition to Pi Zero ... likely away from Arduino and likely away from ESP8266/ESP32 ... for the hobbyist community (which is where I play). And if eyes transition to Pi Zero ... then maybe (just maybe) a first class ridiculously efficient JavaScript engine running natively on the Pi Zero might have some value ... and again ... that assumes the Node.js with all ITS eco-system doesn't already fill that niche on the Pi Zero on Linux today. Posted at 2015-12-01 by tve Two possibly relevant projects: WiringPi (http://wiringpi.com/) and BoneScript (http://beagleboard.org/Support/BoneScript). Posted at 2015-12-01 by @gfwilliams Espruino currently supports WiringPi so you get fast IO, and when running as The thing it's lacking is a utility timer for accurate From my point of view, trying to run on Pi without Linux is just crazy. There are millions (billions?) of lines of code in Linux, and you're basically reimplementing what others have done before, just worse. You can compile the Linux kernel with a 'realtime' flag so you can get proper accurate timing out of it if needed. IMO, a cut-down Linux disk image that'd run off a ~256MB card, and that booted straight up with Espruino could be really good - and would actually be pretty achievable. You'd get proper USB with WiFi, Ethernet support on the Model B, the dispay, and all that good stuff... and people using it could just jump right into JavaScript without having to worry about Linux. Posted at 2015-12-01 by @gfwilliams ... to add to this, there are a bunch of (probably more exciting) cheap OpenWRT Linux+WiFi modules out there. A firmware image for them that booted right up into Espruino would be really exciting too. Posted at 2015-12-01 by tve
Dumb question: what's the advantage over node.js or BoneScript at that point? Posted at 2015-12-01 by @gfwilliams
It'd just be the Also the way you could just point the Web IDE at the board's IP address, connect, and use all the existing Espruino hardware-centric stuff (in fact you could just serve the Web IDE off of the Pi). Basically it'd be more beginner-friendly than node (IMO) Posted at 2015-12-01 by JumJum Will the $5 PI come to the end user market for this price ? Posted at 2015-12-01 by @gfwilliams Some people (Pimonori?) were selling at the £4/$5 price before they ran out. I wonder if there's any profit margin in there, but I think some companies will be willing to sell almost at cost because people do generally spend extra when they buy something like that. I do wonder about this focus on ultra-cheap boards though. I'm not sure this race to the bottom is really that helpful in the long run... Posted at 2015-12-01 by asez73 Hi, just a few arguments to this discussion: Posted at 2015-12-01 by dgustavus Hi, just some observations from the peanut gallery: I believe a great starting point would be Gordon's suggestion of a Raspian/Debian (hopefully jessie-based) image that booted directly into espruino. If it had a kernel driver for time accuracy, and maybe a template for adding other drivers, it would be a very simple step for the rpi community. Even more important, I, for one, would pay for that (say the cost of a pico) assuming it had been optimized (or maybe cleaned up a bit is a better term) for espruino. BTW, I now run node on my rpi model Bs. I think it would be most attractive if it runs on any of the various berries and could use the espruino modules that already exist. An RT implementation might go a long way towards making it distinctive, but that could perhaps be phased in later if there were enough interest. A full development system (ie using the WebIDE from a browser) would be the rpi philosophy, though I must admit I do not find my rpi model Bs fast enough to use for Arduino development (yes they work; I just need faster turn-around when I am coding). One last comment: I think the rpi has demonstrated that it is not necessary to "hide" linux to make the system attractive. Programming is the primary application of the rpi, so an easy entry point, and lots of examples, help and support from the community for learning clearly works. From my perspective, community is one of the strong points of the rpi and espruino as well. If you are looking for a non-hardware method to support espruino, maybe adding this kind of platform makes sense. At the very least, it will not require the upfront investment that a new hardware board demands. Sorry if this is viewed as "highjacking" the topic since it does not deal specifically with the rpiZ. Under 10 dollar hardware seems to be the trend, but for me it mostly means that hardware costs become an ever smaller factor in the development cost with a new platform. Posted at 2015-12-01 by @gfwilliams Thanks! I don't think it's really highjacking the thread much :) Support for all types of Pi would be a major bonus for the Linux-based release.
I think with Espruino it'd be pretty speedy. After all, all the work gets done in the web browser, which would be running on a proper PC :)
True, but if I'm honest I think the real thing that has 'launched' the Pi is the massive community around it. You can just google what you want to do and then copy/paste the commands :) ... also quite a lot of people use the GUI! :) Carambola existed some time before the Pi (I think?), was cheaper and had Flash, WiFi and Ethernet on board, but I think it failed to become popular mainly because of the way people were thrown headfirst into Linux. Somehow the Pi just got it right... Posted at 2015-12-01 by d0773d Would it be possible with someone who knows how, to couple a RTOS with the Espruino firmware for the raspberry pi? Posted at 2015-12-02 by asez73 Just a link to start this port... Posted at 2015-12-02 by @gfwilliams Yes, potentially you could use FreeRTOS or something similar. Almost immediately you'll have people asking why they can't use USB devices on it though :) Best bet would be to compile a linux kernel with the realtime options set - although if Espruino could use a hardware timer on the Pi, it might be a realtime kernel isn't needed at all. Posted at 2015-12-02 by Kolban @d0773d ... for FreeRTOS, see this existing Github Espruino issue .. espruino/Espruino#699 The ESP32 which ... as we understand it ... will be an ESP8266 with a lot more RAM and CPU power ... will very likely use RTOS as its base. The ESP8266 today has an Espressif RTOS base that ... strangely ... appears that it may already need LESS RAM than the non-OS-SDK today. Not only that, it provides a blocking sockets based TCP/IP API. One of the side effects of that is that the networking portion of the Espruino port to EPS8266 could be replaced with the standard sockets networking code base today. I have a Raspberry Pi 2 at my disposal and I'm going to start an investigation on the state of play of JavaScript programming with electronics integration on a standard Raspbian Linux base. I'll be writing that up for the broad community but as a side effect, we'll maybe get a sense on whether or not Espruino offers something that would warrant any form of port to native hardware. For example, we'll see if SPI, I2C, PWM and all the other items where we need exact timing come across without issue. Ive also got a thought in my mind at the notion of an Espruino "shim" layer for existing JavaScript engines. For example ... if one took Nashorn as a JavaScript engine (for example) and then implemented the Espruino specific JavaScript APIs (relatively simple) ... would one then be able to harvest the large set of component integration libraries already available for Espruino on a non-Espruino JavaScript engine running on Pi Zero linux? Posted at 2015-12-04 by d0773d @Kolban sounds like a plan :-) Posted at 2015-12-14 by @gfwilliams Just to add, not sure if this is recent or not, but there's now a 'lite' Linux image on https://www.raspberrypi.org/downloads/raspbian/ Or just did a quick google and there's this: https://minibianpi.wordpress.com/about/ 200mb download, and will run on a 512mb card - could be very interesting to stick Espruino on there. Posted at 2015-12-14 by conor Another minimal one I spotted this morning is http://dietpi.com/ - UK-based developer. Needs a 1GB card but compares very favourably to standard distro: https://docs.google.com/spreadsheets/d/1mDHGZC-H6tU6_O8kuLTG8d4A8Nt7lV1Q7MXTR_6qw30/edit#gid=0 Posted at 2015-12-14 by tve For espruino, I think this may be the ticket: http://tinycorelinux.net/ Posted at 2015-12-14 by @gfwilliams Wow, yes - although it depends what you're after. There's something to be said for having a proper writable filesystem with There's also a bug open on GitHub with a package for OpenWRT, which I need to submit. It'd be very nice to be able to get into any OpenWRT router/board, install Posted at 2015-12-14 by Sacha The Tessel2 is also OpenWRT based. Running espruino on it would be fun. Posted at 2015-12-15 by @gfwilliams :) Yeah... It wouldn't compare very well to Node.js though! (IMO - I haven't tried!) Posted at 2015-12-18 by the1laz There are a lot of kickstarter boards based on OpenWRT that would probably benefit from Espruino, either because node isn't working on them or because Espruino + IDE are a better fit than node. The one that comes to mind is the Onion Omega, but I know that tiny OpenWRT wifi boards Posted at 2015-12-18 by @gfwilliams Yes, there's this issue at the moment to track doing an OpenWRT package: espruino/Espruino#143 I think the Onion will actually run Node, but Espruino's memory requirements mean you could run it one something with maybe just 16mb RAM (that barely runs Linux). To be honest there's not a lot to do, it just needs submitting. ... while we're on the topic of small things to cram it into, I'm sure it could potentially be stuck into something like Coreboot. It'd be pretty fun to be able to put it into the PC BIOS! Posted at 2015-12-19 by the1laz @gfwilliams last I checked the Onion needed an old version of node with a bit of effort put into getting it compiled. I haven't paid much attention though, espruino kind of stole its place for me. :P Posted at 2016-05-31 by TheAlchemist I was wondering if there was any more work done on this issue. As someone just starting out in the embedded space, I can testify that the Pico has a much better beginner experience than a Raspberry Pi, especially for JavaScript. I can put some work in on this issue... I like the idea of DietPI that boots directly into a Espruino prompt that can be programmed using the Web IDE. Besides the timer issue (BTW, here's the Broadcom datasheet for the Zero), anyone foresee any problems? Posted at 2016-06-01 by @gfwilliams I haven't done any more work on it, but it'd be great if you were willing to take a look at it - it should be pretty easy, especially as @tve has added a Telnet interface to it now. Hopefully it wouldn't be much more difficult than taking a minimal Pi image, adding Espruino and a few scripts. Even as-is, it's still pretty usable - just without the timer you're not going to be able to do totally accurate pulses, but SPI, I2C, etc are still fine. Just some ideas:
And other slightly harder stuff:
Posted at 2016-06-01 by TheAlchemist Thanks for all the nitty-gritty details, @gfwilliams! About the timer: are we sure this isn't doable? I'm not familiar with the terminology, so I'm not sure what to even Google. The Broadcom datasheet implies there's a timer, but I don't know enough to see if it's the "right kind" of timer. Posted at 2016-06-01 by @gfwilliams Well, the timer might be possible. The problem is I'm pretty sure Linux uses at least one timer for the Kernel, so it's whether anything is left over for you to use really - I had a quick google but I can't see any examples of getting an IRQ for a timer while under Linux :( The WiringPi library is used for getting the IRQs when pins change state, but for its soft PWM it actually uses normal threads, which makes me think that using a timer IRQ directly may not be possible: https://github.com/WiringPi/WiringPi/blob/master/wiringPi/softPwm.c Doing something similar to that could be an option. It's not perfect but it would be better than nothing. Posted at 2017-01-19 by CriscoCrusader I agree with @thealchemist, the beginner experience with the Espruino Pico has been much better than pi and Tessel. It seems all these embedded systems vendors are thinking only of robots / IoT, and completely forgetting about wearables. I think the Espruino project has done really well in avoiding that mistake. The pi zero is attractive to me as a platform for an open-source product because users can write in whatever language they like. What's frustrating for me is the long boot time in every distro, since I'm making a wearable product and it shouldn't take 15 seconds to turn on! My end goal is to enable users to work in the language of their choosing, and I plan on supporting more than one MCU (like MicroPython). I was thinking the pi zero would be a good fit, but not if I can't get instantaneous boot. Posted at 2017-01-19 by @gfwilliams Thanks! As far as the Pi goes, if you look at what gets loaded when it boots, it's an insane amount. It'd be well worth fiddling with building your own Linux kernel - it's very configurable and you can really strip it back. To be honest I bet someone's already come up with a super-minimal distribution. You could try OpenWRT as a start. I bet you could get the boot time well under 1 second with fairly little work. Posted at 2017-01-19 by Wilberforce I have spent quite a bit of time getting a pi to fastboot. You can use buildroot or yocto to build a custom kernel. I think I had a buildroot version booting in about 4 secs, and the wifi network would be up in about 10 secs - compared to 30-45 secs on the normal pi Distro. It is a lot of work to do a custom kernel - not for the faint hearted! Posted at 2017-01-19 by @gfwilliams Ahh, thanks! Looks like under 1 second was a bit optimistic. Did a quick google and there's a downloadable image here that does 3 seconds straight into a game emulator: https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=56413 So you've got to ask yourself if it's worth the effort writing your own hardware drivers and networking stack in order to save what's realistically only 2 seconds max. If you come up with a minimal Espruino/micro python image for Pi I'd be really interested though - it could be really neat (especially as the Pi could even serve up the Web IDE). Posted at 2017-01-20 by @allObjects 'boot time': ...kind of a 'hibernate' mode should be available... save to and load/boot from a flash a memory runtime image. (Espruino got this right from very beginning!... amount of memory not really comparable though...). Some initialization is though still required, especially for connections... cached peripheral/sensor states,... Posted at 2017-01-20 by @gfwilliams Yes, I'm kind of surprised about that. I'd have thought you could load a compressed image straight from the SD card into RAM and then run from there (I think that's what OpenWRT does on routers). Posted at 2017-01-20 by Wilberforce Sorry no hibernate or power management on the pi. The sd card is creally the bottle neck. The way pi boots is quite odd, the gpu reads data from thef first fat partition on the disc, loads that into memory, and then hands that over to the arm CPU which then boots and reads the Linux paritition. For a minimized Linux, the kernel boot file is about 200mb. Posted at 2017-01-21 by CriscoCrusader I've seen the game emulator example. The guy who made it doesn't seem to have interest in helping newbies do what he's done. There are people who try to teach others how to do these things, for example, this embedded midi player was built by a guy who created a complete course on OS development. I also found this really awesome guide on building Arduino sketches for the pi. The network access isn't needed immediately upon boot. The device can show a status indicator while the network system is coming up. But a chosen interpreter and associated runtime scripts need to start running immediately, because it will operate the UI, I2C, and be responsible for all device logic. I've read that it's possible to prevent the kernel from waiting for network devices to reach ready state. [edit1] [edit2] [edit3] |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-11-30 by Kolban
With the release of the Pi Zero (https://www.raspberrypi.org/blog/raspberry-pi-zero/) with a retail price of $5 ... I can't help but feel that we are witnessing a significant change.
How about we port Espruino to Pi Zero?
But wait, you are going to say ... the Pi Zero is a Linux system which already has production quality free JavaScript environments ... it has Node.js and Nashorn ... just to name a few. Why port Espruino to Pi Zero?
The answer is a twist ... my suggestion is not to port Espruino onto Pi Zero on top of Linux ... but instead port Espruino to run on Pi Zero natively. Specifically, Pi Zero would have a firmware image that boots from SD card directly into Espruino .... period. No Linux in sight ... just 1 GHz processor, 512MBytes of RAM, SD card FAT32 file system, GPIOs, UART, I2C, SPI, PWM and ADC ... all "just available". WiFi would be handled in the same way that non-WiFi enabled Espruino boards would be handled today. There would be no Video or USB support (in the first release) ....
However, what it would do is appear to provide the most robust environment for only $5 at a performance level that would appear to be unbeatable in the current time frame.
Does anyone see any merit in this? $5 for a 1GHZ, 512MByte, SD card based Espruino environment?
Beta Was this translation helpful? Give feedback.
All reactions