News for hackers. Stuff that matters.
Re:Zinc – Rust’s safety features applied to embedded develop... by pjmlp on Tuesday July 15, 2014 @04:35AM (#8035368)
This looks nice!

Rust is starting to join Ada, Oberon, Pascal dialects compilers in bare metal support.

Good way to dispel the belief only C compilers can do it.

Specially if like Zinc, there is zero C code there.

Re:Zinc – Rust’s safety features applied to embedded develop... by diydsp on Tuesday July 15, 2014 @09:51AM (#8036386)
I'm very exciting to see Rust move into embedded!

Some minor comments: The page includes example code. I worry that it might be abstracting TOO much away, while at the same time hiding details.

For example, in the main oscillator example, you still would have to consult deep in the manual to understand what m, n and divisor do if you wanted to change the frequency. I think if you're going to use a library, it would be cool to operate at a higher level than this.

Also notice in the timer example, you still have no idea what frequency the timer will run at! Maybe I just want something higher-level built on top of this? Maybe I should implement libopencm3 on top of this?

p.s. Crazed fans of the greatest microcontroller of all time, the stm32f4, check out http://reddit.com/r/stm32f4 and http://diydsp.com/livesite/pages/stm32f4

Re:Zinc – Rust’s safety features applied to embedded develop... by eric_bullington on Tuesday July 15, 2014 @10:07AM (#8036491)
>http://diydsp.com/livesite/pages/stm32f4

Very cool page! Great links to some amazing projects on the stm32f4.

I see you mention Lua and JavaScript on the stm32f4, have you seen micropython running on it?

https://github.com/micropython/micropython/wiki/Board-STM32F...

Re:Zinc – Rust’s safety features applied to embedded develop... by diydsp on Tuesday July 15, 2014 @11:12AM (#8036861)
Wow. I didn't know that was possible! Ima haveta try it. You can easily see I'm obsessed. I'll add it now.

Seriously, a chip like this hasn't been out in a long time. Sure there are more powerful ones like the BeagleBoards and RPis, but they require more support hardware, space, components and power. Hell, the stm32f4 can run with just a few capacitors and no external crystal, and still have 24 analog inputs, two analog outputs and floating point. Plus it has internal cache so it can run at 168+ MHz and DMA, etc.

Re:Zinc – Rust’s safety features applied to embedded develop... by paletoy on Tuesday July 15, 2014 @01:04PM (#8037616)
I read that they will be release a new $1 stm32f4 mcu using a new process soon.

http://www.st.com/web/en/news/n3547

BTW , my mistake , it's stm32f3 , altough it's cortex-m4. a bit weird naming.

Re:Zinc – Rust’s safety features applied to embedded develop... by farcaller on Wednesday July 16, 2014 @02:50AM (#8040875)
At some point I realised that abstracting to the level of "source_frequency" and "out_frequency" is too fragile, That will be going away in some places, will be added in another, where applicable. You are going to specify the exact PLL configuration, but zinc will compute the clocks for e.g. timer or UART based on frequency or baud rate.
Re:Zinc – Rust’s safety features applied to embedded develop... by akiselev on Tuesday July 15, 2014 @04:06PM (#8038665)
> p.s. Crazed fans of the greatest microcontroller of all time, the stm32f4

The greatest until you need to do something complex with both DMA peripherals. Yay for silicon bugs and using tons of third party IP cores without proper testing.

Re:Zinc – Rust’s safety features applied to embedded develop... by eric_bullington on Tuesday July 15, 2014 @06:52AM (#8035720)
A came upon this the other day, and was so impressed that I'm about to drop $60 on an lpc1768, which is the primary MCU they are using at the beta stage (they plan to expand to others once the API is solidified).

They also have used an stm32f4, which I do have at the moment, but support for it seems to have dwindled over the past few months.

But I really like the safe way they are developing the API. Even the hardware configuration is done as a safe DSL. Very impressive.

This project looks like a great foundation for a realtime OS in Rust I've been itching to try my hand at.

Re:Zinc – Rust’s safety features applied to embedded develop... by omgtehlion on Tuesday July 15, 2014 @09:07AM (#8036165)
> I'm about to drop $60 on an lpc1768

I usually buy them at ~$3 a piece...

Re:Zinc – Rust’s safety features applied to embedded develop... by eric_bullington on Tuesday July 15, 2014 @09:35AM (#8036291)
Yeah, I should have specified the eval board, which includes peripherals. This Zinc project already has support for several of the peripherals, including a few TFT drivers, which I want to be able to try out.

I don't always buy eval boards -- if a chip comes in a DIP package, I've just breadboarded it in the past. As a hobbyist, I haven't yet tried to build a breakout board for any SMT-mounted chips, but it's on my todo list.

The one I'm looking at (by RioRand) is not a bad deal, since it actually includes a 2.8 inch TFT on the board as well as Ethernet interface. But I did consider just buying the chip and breadboarding it. I may still do that and buy the LCD separately.

$60 would indeed be expensive for the chip alone.

Re:Zinc – Rust’s safety features applied to embedded develop... by omgtehlion on Tuesday July 15, 2014 @10:00AM (#8036441)
BTW, you cand find cheaper boards or with more peripherals from China, just check out eBay or aliexpress
Re:Zinc – Rust’s safety features applied to embedded develop... by eric_bullington on Tuesday July 15, 2014 @10:10AM (#8036507)
Yeah, I know I can probably get the eval board a bit cheaper -- I've bought chips from China on ebay and frequently look at TFT LCD displays on aliexpress while dreaming of a commercial product I'd love to do some day.

But in this case, I don't want to wait 2-4 weeks for delivery. The RioRand will be here in 2 days since it's on Amazon Prime.

Re:Zinc – Rust’s safety features applied to embedded develop... by bluefinity on Tuesday July 15, 2014 @09:15AM (#8036199)
Re:Zinc – Rust’s safety features applied to embedded develop... by marcosscriven on Tuesday July 15, 2014 @06:21AM (#8035630)
Can someone clarify two things please?

Firstly, bare metal here means this stack can create an img with an executable that will be run with nothing more the uboot? I.e. No OS, no kernel, not even a Rust runtime (hence, presumably, no std in the example)?

Secondly, can anyone recommend a good reference to get a handle on platform trees? I first came across them on my beagle bone. My understanding it was mostly because Linus got fed up of hundreds of patches for each and every ARM board.

Re:Zinc – Rust’s safety features applied to embedded develop... by eric_bullington on Tuesday July 15, 2014 @07:27AM (#8035794)
>Firstly, bare metal here means this stack can create an img with an executable that will be run with nothing more the uboot? I.e. No OS, no kernel, not even a Rust runtime (hence, presumably, no std in the example)?

Yes, that is correct. No OS, no kernel, no runtime. Now, Rust is isolating a core library (called libcore) that can be used without runtime support (and hence in projects like this one).

Re:Zinc – Rust’s safety features applied to embedded develop... by pjmlp on Tuesday July 15, 2014 @09:35AM (#8036287)
To be pedantic, from compiler design point of view, that is also a runtime.
Re:Zinc – Rust’s safety features applied to embedded develop... by eric_bullington on Tuesday July 15, 2014 @09:52AM (#8036392)
Well, it uses the libc runtime [This is actually mostly incorrect, see comment below by dbaupp], which obliges me to invoke the old quote, "the greatest trick C ever played was to convince the world it has no runtime".

I wish I could track down the originator of that quote, but I have no idea. I'm sure someone here will know.

Re:Zinc – Rust’s safety features applied to embedded develop... by dbaupp on Tuesday July 15, 2014 @10:08AM (#8036500)
Libcore doesn't use the (entire) libc runtime; IIRC, it essentially just needs the memcpy and memset symbols to be defined.
Re:Zinc – Rust’s safety features applied to embedded develop... by andrewflnr on Tuesday July 15, 2014 @01:10PM (#8037663)
Why not just implement those in Rust too? It seems like you could break the dependency entirely.
Re:Zinc – Rust’s safety features applied to embedded develop... by dbaupp on Tuesday July 15, 2014 @05:44PM (#8039245)
Yes, you can, and they are even provided in pure Rust for exactly that reason: http://doc.rust-lang.org/master/rlibc/

(Seems there were 2 more mem* symbols required than I remembered.)

Re:Zinc – Rust’s safety features applied to embedded develop... by pcwalton on Tuesday July 15, 2014 @01:46PM (#8037881)
You can implement those in Rust if you want.
Re:Zinc – Rust’s safety features applied to embedded develop... by heinrich5991 on Tuesday July 15, 2014 @10:27AM (#8036591)
Couldn't it use librlibc then?
Re:Zinc – Rust’s safety features applied to embedded develop... by dbaupp on Tuesday July 15, 2014 @05:43PM (#8039237)
Yes, that's exactly what librlibc is for and what is used.
Re:Zinc – Rust’s safety features applied to embedded develop... by pjc50 on Tuesday July 15, 2014 @10:50AM (#8036740)
The runtime really isn't mandatory, though. It's entirely feasible to have an embedded system where the only code that runs is your own.

I'll agree that glibc is a much larger iceberg than people think, though.

Re:Zinc – Rust’s safety features applied to embedded develop... by pjmlp on Tuesday July 15, 2014 @10:28AM (#8036597)
Yes, now we have to make the world understand what a lie it was.
Re:Zinc – Rust’s safety features applied to embedded develop... by farcaller on Wednesday July 16, 2014 @03:05AM (#8040905)
Zinc doesn't really need u-boot too. So far we're targeting smaller MCUs that don't even run "big" OSes like Linux, but there's absolutely no problem in running zinc on e.g. RPi.

Zinc includes it's own preemptive scheduler, so, effectively it's an OS for user-defined tasks, as it does manage the hardware resources.

Platform trees in zinc are not really the same as devices tress in linux. Initially I tried to use linux device tree specification but in progress I realised, that zinc doesn't need some things and needs others. And with all the changes there's no reason to keep similar syntax.

Re:Zinc – Rust’s safety features applied to embedded develop... by bjackman on Tuesday July 15, 2014 @07:20AM (#8035780)
First question: I don't know but I interpreted it the same as you.

Second question: The "platform trees" described in this post are not exactly the same as the "device trees" used by Linux on ARM (and also MIPS I think?). They are essentially the same concept, but device trees have their own DSL amd binary format. They are basically descriptions of the hardware om a system: the CPUs, the RAM, the peripherals. It allows the same kernel image to boot on multiple systems by intwrpreting the devicetree at boot time, rather than having to embed info about the system at compile time. You can get more info about device trees (a.k.a FDTs where F stands for "flattened") on devicetree.org and elinux.org.

Re:Zinc – Rust’s safety features applied to embedded develop... by pjmlp on Tuesday July 15, 2014 @09:34AM (#8036281)
Yes, that is usually what bare metal means.
Re:Zinc – Rust’s safety features applied to embedded develop... by nwh on Tuesday July 15, 2014 @05:53AM (#8035545)
Zinc doesn't rust though.

ED: Read the correction below.

Re:Zinc – Rust’s safety features applied to embedded develop... by unfamiliar on Tuesday July 15, 2014 @06:42AM (#8035691)
That is almost incorrect. Zinc is used as a plating because it corrodes preferentially to steel, and in doing so it removes electrons needed for oxidation and thus prevents the steel from rusting. This is why you can stop a ship hull rusting by simply bolting a block of zinc to it.
Re:Zinc – Rust’s safety features applied to embedded develop... by marcosscriven on Tuesday July 15, 2014 @06:47AM (#8035710)
I read ages ago that the Sydney Opera House uses sea water for air conditioning, and has a sacrificial zinc anode.
Re:Zinc – Rust’s safety features applied to embedded develop... by kps on Tuesday July 15, 2014 @11:38AM (#8037042)
I think it's unfortunate that LLVM has no first-class public targets smaller than ARM to help guard against ‘all the world's a VAX’ pitfalls. There are/were projects for MSP430 and AVR but it's not practical to keep up with LLVM without full-time developers.
Re:Zinc – Rust’s safety features applied to embedded develop... by sanxiyn on Tuesday July 15, 2014 @12:02PM (#8037212)
As I understand, MSP430 is such first-class target. MSP430 is in-tree and maintained.
Re:Zinc – Rust’s safety features applied to embedded develop... by pestaa on Tuesday July 15, 2014 @06:40AM (#8035690)
Great domain name for a project.
Re:Zinc – Rust’s safety features applied to embedded develop... by gchp on Tuesday July 15, 2014 @06:30AM (#8035658)
Is anyone here actually using Rust in a "real-world" situation? My impression is that is gaining traction, yet is not yet stable enough for production use. Anyone have experience to say otherwise?
Re:Zinc – Rust’s safety features applied to embedded develop... by steveklabnik on Tuesday July 15, 2014 @07:34AM (#8035810)
There are three production deployments of Rust: OpenDNS, something I always forget, and Tilde, for Skylight.io.

(I'm starting to think it's only two and my brain made up the mysterious second one)

That said, you have to be a certain kind of person to use a pre-release programming language in production.

Re:Zinc – Rust’s safety features applied to embedded develop... by dbaupp on Tuesday July 15, 2014 @08:46AM (#8036068)
The best kind of person. :)

((Members of) Tilde are writing Rust's awesome new package manager, Cargo: http://crates.io/ )

Re:Zinc – Rust’s safety features applied to embedded develop... by steveklabnik on Tuesday July 15, 2014 @09:17AM (#8036205)
Right, which was great, as "We already use Rust in production" combined with "we built Bundler" is a pretty decent pitch.
Re:Zinc – Rust’s safety features applied to embedded develop... by gchp on Tuesday July 15, 2014 @09:47AM (#8036355)
Sweet, thanks for the reply!

You say pre-release, is there a set release schedule for Rust?

Re:Zinc – Rust’s safety features applied to embedded develop... by dbaupp on Tuesday July 15, 2014 @10:16AM (#8036537)
The aim for 1.0 is for the end of this year; it will offer backwards compatibility at the language level (syntax and semantics of language constructs), and a subset of the standard library. The rest of the library will stabilised progressively.

(The compiler warns/errors when using a nonstable language or library feature, so it will be easy to stick to the stable parts, or at least know what may need to be adjusted when updating. The goal is to a strict semantic versioning plan too.)