Archive for the ‘Projects’ Category

Miosix 2.0 code size

May 4, 2014

If you’ve tried the new Miosix 2.0 recently, you may have noticed that compiling an hello world without tweaking the build options results in a code size of around 90KB for the kernel plus the hello world program. This appears to be a big step up with respect to Miosix 1.6, but is due to the fact that more features are enabled by default, as well as due to the completley rewritten filesystem subsystem with support for advanced features such as multiple mountpoints, unicode in file names DevFs etc.

However, the kernel is very modular and the code size is only limited by the features you need. This quick guide shows how it is possible to bring the size of Miosix 2.0 down to around 6KB by disabling features you may not need. This is the same size of a minimal configuration of Miosix 1.6.

Miosix 2.0beta1 released

April 13, 2014

If you’re watching Miosix’s git repository, you probably noticed that in the last year most commit were done in the testing branch, but until now no official information was available on how to use the testing branch.

Today Miosix 2.0beta1 has been officially released, together with changes to the Miosix website, including a wiki.

A short list of changes introduced in Miosix 2.0:

  • Upgraded GCC compiler to 4.7.3
  • Support for hardware floating point operations in Cortex M4 (thanks to the new GCC and to an updated context switch code)
  • Improved atomic operations, which speeds up mutex locking
  • Improved memory profiling to return more detailed heap statistics
  • Completely rewritten the filesystem code, with better POSIX compliance, support for multiple mountpoints, Unicode in file names, and in-memory filesystems including DevFs like on Unix machines
  • Experimental multiprocess environment with memory protection and supporting loading code at runtime (work in progress)
  • Improved serial port drivers with DMA support for reading and writing
  • More board support

Check out the Miosix wiki.

tea-time turns your smartwatch back into a watch… and a 3D rendering engine

August 24, 2013

A while ago this post caught my attention on Hackaday. Sony relased some hardware specifications of its smart watch, and invited people to hack it and write custom firmwares. It wasn’t the first time I’ve heard about that smart watch, as I had alreay found (thanks Daniel) a teardown of it.

The author of the teardown actually was disappointed by finding a microcontroller instead of a Linux capable processor in the watch, but being used to microcontrollers, this was no problem. Also, Sony didn’t put into the watch a tiny 8bit microcontroller, but instead chose an ARM running at 120MHz, with 128KB of RAM and 1MB of FLASH. That’s a lot to work with.

However, before Sony’s move towards openness, I wasn’t that much interested in the watch, as it takes too much time compared to the one I have available to reverse engineer a firmware to understand how to write drivers for the display, touchscreen etc. After reading that news on Hackaday, and looking at the documentation, though, I ordered the watch straight away.

This turned out to be, at least partially, a bad move. This is because if looked on the surface the documentation on Sony’s site seemed sufficient to write a custom firmware, as it says on which GPIO pins devices are connected, there’s the part number for the display controller, and some source code for driving the touchscreen. When looking deeper, though, many parts were missing. For example, searching the display controller datasheet on a search engine resulted only in links to the site of the company who produce it – and no datasheet. Also, certain parts of the watch’s hardware were missing entirely from the documentation. For example, it was later found out that the watch has a power management unit that controls battery charging and turns the watch off under software control, but this is entirely missing from the documentation.

Shortly after, however, always on Hackaday, a post showed an Arduino-like toolchain to write sketches for the smart watch. Personally, I am not very fond of the Arduino. Probably since I’m used to programming microcontrollers using an RTOS (Miosix), having to fit all my code logic in the loop() function seems unnatural to me. Also, one of the few things I like about the Arduino: openness here was missing, as no hardware schematics of the watch have ever been released by Sony.

At least the availability of the Arduino toolchain gave me a code base to look at to understand how the watch works, it’s way better than reversing the binary of the original firmware! Quickly, I understood that the Arduino firmware was written by someone who had much more documentation than the one which is publicly available. For example, the file system.c mentions in the comments “SONY’S NAME” for each GPIO pin. Clearly they had access to the original source code of the watch. It’s by reading that code that I came to know about the existence of the power management unit.

The Arduino code, and in particular its comments, filled the gap left open by the lack of documentation and helped a lot in the process of porting the Miosix kernel and the Mxgui library to the watch, which was my end goal.

Enough talk, let’s start with a demo. Here is a simple but functional firmware, called tea-time, that turns the smart watch into… a watch. To test the hardware’s performance I ported a simple 3D rendering engine for Mxgui to the watch, it draws in real time the famous utah teapot, resulting in quite an original watch face.

solidwireframe

There’s also a video showing the smoothness of the rendering.

Needless to say, the firmware is entirely free software/open source, and can be found in the examples directory of the mxgui library. For trying it out without the need to compile it, the compiled firmware is here.Although it’s just a preliminary version, and there’s still work to do, it already provides a battery status indicator and dynamic display brightness adaptation based on ambient light, as well as a 30s timeout after which the display turns off to save power.

For developers

The code is written in C++ as a multithreaded application for Miosix, using the POSIX threading API. There’s also a simulator for the GUI to help design the user interface without the need to flash the watch every time to see how a modification looks like.

sim1sim2

In the future I’ll probably add a tutorial on how to set up the miosix/mxgui environment, how the optimized video driver for the smart watch works and how the rendering engine works. There are a lot of tricks in there…

Update 25/08/2013

The link to the firmware now points to a new version. The previous one had a bug in the power saving code, causing the battery to last only one day. This one should be better.

Update 1/9/2013

The new firmware did actually fix the battery issue. It now lasts 6 days.

Better code completion for Miosix

April 6, 2012

For those who are using Miosix with the Netbeans IDE, there is an interesting new feature: support for configurations. Netbeans is the IDE I’m using to develop Miosix, and the kernel comes with a folder containing a Netbeans project to manage its sources. While code completion in Netbeans is good, the IDE often got confused by the existence of multiple supported architectures, so code completion would not work for resolving symbols in the board support packages, at least until now.

Now a new configuration has been added for each supported board, with the predefined macros reflecting those in Makefile.inc, so that code completion now works also for board specific files.

To select the board you’re currently using, right click on the project, and select your board among those listed under “Set Configuration”. Note that this does not eliminate the need to edit the Makefile.inc to build the kernel for a specific board.

Image

Miosix 1.60 is out

February 12, 2012

Latest changes include preliminary support for the STM32F4 microcontrollers, and the stm32f4discovery board.

Mxgui

September 22, 2011

Ok, here’s the new library for Miosix: Mxgui. As the name suggests, it’a a GUI library for microcontrollers, designed to work with the Miosix kernel.

Source code is here, while documentation here.

What can it be used for? 3D rendering on a microcontroller, for example.

Mxgui examples from fede.tft on Vimeo.

Miosix 1.54 released

October 3, 2010

After a lot of time spent coding, here’s the new release of Miosix, my OS kernel for microcontrollers.

New features include:

  • Porting for ST’s Cortex M3 microcontrollers
  • Preliminary implementation of the POSIX thread API (pthreads)
  • Improved statistics on memory usage and debugging messages
  • Bug fixes and other enhancements

If you’re interested, download the new release here: http://www.webalice.it/fede.tft/miosix/index.html

Digital voltmeter for power supply

October 2, 2010

This summer I finally found some time to fix my power supply.

It’s a rather old but relieable unit, and I have no intention of replacing it. Basically, it still works except for the voltage meter on the front panel. Over time, the pointer developed an offset of around 1V, which is visible in this image where the power supply is turned off. Instead of indicating exactly zero volt, the pointer is below the beginning of the scale.

This, together with the fact that today’s microcontroller require 3.3V to operate (while the voltmeter only has an 1V resolution), forced me to always use a multimeter when using it, to be able to precisely set the output voltage.

The solution I found was to simply replace the analog voltmeter with a digital one. Instead of using a voltmeter chip like the ICL7107 that usually require the measurement ground to be separated from the supply ground, these days it is easier to build a voltmeter using a microcontroller.

That’s because even the cheap and simple micros now have at least a 10 bit ADC which is more than enough for a voltage meter in the rage 3..15V (which is the range of my power supply). Since the task is easy there was no need to use an ARM microcontroller as I usually do, but instead an ATtiny26 proved more than enough, despite only having 2KBytes of FLASH and 128Bytes of RAM.

This is the result:

The circiut is simple, a 78L05 is used to reduce the 20V found in the power supply to 5V to power the microcontroller. A voltage divider made with 1% precision resistors is connected from the power supply input to an ADC capable GPIO on the microcontroller, and three LED displays show the voltage with 0.1V resolution.

The LED displays are ofcourse multiplexed so that the ATtiny, despite its low number of GPIOs, can drive the display with no other glue logic except for current limiting resistors.

Around 100 lines of C++ code keep the whole thing working.

Glue stick torch

June 5, 2010

Ever thought that you can make a torch using a glue stick?
Ever thought that you can hack an inductor into a transformer?

Here is the final result of a rather old project I’ve done in 2005, but never published until now.

Read the full article on my website.

Sound controlled lamp

October 20, 2009

That’s a project I’ve done long time ago, but never talked about it in my website.

Here is the link.


Follow

Get every new post delivered to your Inbox.

Join 30 other followers