Raspberry Pi Zero

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
User avatar
pythoncoder
Posts: 3403
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Raspberry Pi Zero

Post by pythoncoder » Tue Dec 01, 2015 10:14 am

I think it's worth restating the things the Pyboard can do which the Pi (in any variant) cannot. Firstly, as I mentioned above, it's a realtime device. Python code running on a Pi will experience random delays as other processes are executed. I've been advised by a Linux guru that these can be as long as 25mS. For some applications this doesn't matter, for others it's a complete deal breaker. The Pyboard is over three orders of magnitude faster. Faster still if you use inline assembler. Secondly the Pyboard beats Pi's. Arduinos and many other boards on the low-power front. For long term operation from batteries there is no contest. Thirdly, as others have pointed out, it has more I/O.

Reviewing the numerous things I've built in recent years, if I were starting now I'd use a Pyboard in almost all of them. Arduinos would score zero. The Pi would score two or three - non-realtime projects requiring an underlying OS: I have one behind the TV doing a fine job of playing movies stored on my NAS box - a task entirely unsuited to the Pyboard. Another candidate I've used is the range of devices from Phidgets. Flexible and easy to use but expensive and definitely not realtime. They score one with a Pi as a possible substitute. A WiPy could do have been a contender had it had float support, math support, and more RAM: in other words, forget it.

To sum up I think the Pyboard is an awesome piece of kit, and great value for money, for most of the things I'd want to build.

As for the politics of the situation, I think a port of MicroPython to the Pi Zero would be awesome even without display support. Extending MicroPython to a potentially huge userbase would surely be in the interests of the language. Whether it would cannibalise sales of the Pyboard is another matter. Lack of I/O might limit this. I've no idea whether the Broadcom chip is capable of low power operation but I doubt the board was designed for it given its intended use with Linux. If anyone started a credible Kickstarter project to do a bare metal port I'd chip in, unless the prevailing view was that it would adversely affect the Pyboard.
Peter Hinch

torwag
Posts: 207
Joined: Fri Dec 13, 2013 9:25 am

Re: Raspberry Pi Zero

Post by torwag » Tue Dec 01, 2015 2:58 pm

I guess discussions about usefulness are useless. Most of the time people start porting a program or a programming language because they like to use it on another platform since they got used to it so much already. If the only language you know is a hammer, you will port "banging with a hammer" on the Pi Zero ;)

However, I agree with pfalcon that it is a waste of resources to start a port just for showing "it works" and drop it afterwards. Also interesting approach to add the software dev costs to the unit costs. Absolutely right, but I guess most projects never thought about it ;)

I would like to see a $5 pyboard myself simply to create my own home-automation modules (which means I need a couple of dozens of them). I love to use the wipy for it but that would put me in an financial debate with my wife (and you can only lose those discussions). I was hoping for the ESP8266. There was the Node.It project on kickstarter which said they would like to support micropython, but it got a bit quite around it.

Maybe I should simply go with the wipy and just start slowly to add piece by piece over the years

SpotlightKid
Posts: 380
Joined: Wed Apr 08, 2015 5:19 am

Re: Raspberry Pi Zero

Post by SpotlightKid » Tue Dec 01, 2015 10:30 pm

I think the expectations for a $5 board for micropython expressed repeatedly here are a bit unrealistic.

Firstly, there are already boards for around $15, which can run micropython, namely the stm32f4discovery and the nucleo-f401, which are readily available.

Secondly, the esp8266 boards are often quoted as being < $5, but in practice, especially the newer, more capable models, you can only get them at that price, if you buy them directly from hongkong sellers. Comparing this to a board produced in Britain and sold under EU regulations, is comparing apples and oranges.

willie
Posts: 14
Joined: Mon Dec 14, 2015 12:05 am

Re: Raspberry Pi Zero

Post by willie » Mon Dec 14, 2015 12:48 am

I don't understand the desire to port micropython to the Pi0 instead of using CPython or PyPy. Can someone enlighten me? I thought the idea of micropython was to run a pretty good subset of python on a low-resource board. With a bigger board like the rPi, you can run the full blown version with all the libraries. Note the much higher power consumption, no integrated wifi, etc. http://onion.io might be an interesting alternative, a smaller, lower powered Linux board with wifi, costing $19. So it's about halfway between the Pi0 and the WiPy in power (both computing power and energy consumption) and also intermediate in cost. Note that both the Onion board and the Pi0 lack an RTC, which is trouble for some applications.

I don't see how the WiPy board has deterministic timing either though. Does it have pauseless garbage collection? Or do you mean when running in a tight loop that does no allocation?

I like the idea of a really cheap micropython board built like the Adafruit Trinket, but I think these powerful 32-bit MCU's are still too expensive and the packages are too large. There's the Espruino Pico though, in the same space as the WiPy.

User avatar
pythoncoder
Posts: 3403
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Raspberry Pi Zero

Post by pythoncoder » Mon Dec 14, 2015 9:08 am

See the first para of my post above: many realtime applications can't tolerate 25mS delays occurring at random intervals. On the Pyboard garbage collection takes an order of magnitude less time, and can be triggered at a time of the programmer's choosing. If it's called frequently enough it can take on the order of 1mS.

I believe an allocation scheme offering deterministic timing is an aim of @Damien, hopefully to be realised one day.

Strictly speaking any system involving interrupts is not truly deterministic, but it can be worst-case designed and the overhead of ISR code can be minimised with careful design. With an underlying OS running a pre-emptive scheduler you're at the mercy of events over which you have no control.
Peter Hinch

willie
Posts: 14
Joined: Mon Dec 14, 2015 12:05 am

Re: Raspberry Pi Zero

Post by willie » Sat Dec 19, 2015 3:46 am

Have you tried the Linux realtime scheduler? It's not like a purely single tasking MCU but it gives the realtime process top priority and lets it hold the cpu. 1ms might be doable.

User avatar
pythoncoder
Posts: 3403
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Raspberry Pi Zero

Post by pythoncoder » Sat Dec 19, 2015 6:53 am

I've heard of it but not used it. I think the definition of "real time" is somewhat elastic. There are two prominent issues, firstly the one we've discussed where a running program experiences random pauses resulting from pre-emption. A second is the response time to external events. With MicroPython on bare metal you can respond to an interrupt in tens of microseconds. I'm a Linux user - emphatically not a guru - but I suspect achieving that on a Linux system would require writing a C kernel module.

The bare metal advantages don't stop there. Linux on a Pi Zero takes the best part of a minute to boot. The Pyboard boots in under 200mS http://forum.micropython.org/viewtopic.php?f=6&t=607 which is a big deal in some applications.
Peter Hinch

User avatar
dhylands
Posts: 3174
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Raspberry Pi Zero

Post by dhylands » Sat Dec 19, 2015 7:16 am

Normal linux priorities use a round-robin scheduler. When your time slice is up you get bumped to the end of the queue and the next ready-to-run thread runs.

With real-time priorities, the highest priority thread runs until it blocks or gets preempted by a higher priority thread. The lowest priority real-time priority is higher than the highest non-real-time priority.

In linux, interrupt handlers can also be threaded, which allows you to assign priorities to the interrupts, so it is possible to create a system which has fairly deterministic response.

Since the desktop runs at regular priority, if any real-time priority thread goes into an infinite loop, you lose access to your desktop (been there - done that).

User avatar
JonHylands
Posts: 64
Joined: Sun Dec 29, 2013 1:33 am

Re: Raspberry Pi Zero

Post by JonHylands » Sun Dec 20, 2015 2:38 am

pythoncoder wrote: The bare metal advantages don't stop there. Linux on a Pi Zero takes the best part of a minute to boot. The Pyboard boots in under 200mS http://forum.micropython.org/viewtopic.php?f=6&t=607 which is a big deal in some applications.
Note that Dave and I have been playing with Tiny Core Linux on the Pi. With that running on a Pi 2, power up to login prompt is 12 seconds. Still not approaching pyboard speed, but a whole lot better than one minute+ with the normal version of Linux. Tiny Core Linux uses MicroPython as its scripting language.

User avatar
pythoncoder
Posts: 3403
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Raspberry Pi Zero

Post by pythoncoder » Sun Dec 20, 2015 9:14 am

@dhlyands @JonHylands Interesting. Linux is evidently more capable than I'd realised. I haven't used it for anything requiring speed beyond responding to pushbuttons and suchlike.
Peter Hinch

Post Reply