Thymio source code

The contributor centre is in English only.

You can get the source code of Thymio in a zip file: First release, Second release, or from github.

Compiling the git tree

Source code

To compile the firmware from git, you need the following source code:


You need the MPLAB X environment and C compiler:

Creating a project and compilation

Do NOT use the MPLAB v8 project provided in the git tree, it is too old and should not be used.

First, you need to start MPLAB X and create a new project:

  • Microcontroller: PIC24FJ128GB106
  • Compiler: XC16
  • Hardware tool: None (simulator, or whatever).

Use the linker script provided in the aseba-target-thymio2 git tree.

Use the following sources:

  • from aseba-target-thymio2 git tree, almost everything except skel-usb-user.c/h:
    • abo.c, analog.c, behavior.c, button.c, crc.c, entry.s, ground_ir.c, ir_prox.c, leds.c, leds_low.s, log.c, main.c, mma7660.c, mode.c, motor.c, ntc.c, pid_motor.c, playback.c, pmp.c, pwm_motor.c, rc5.c, regulator.c, rf.c, sd/ff.c, sd/mmc.c, sd.c, sensors.c, skel-usb.c, sound.c, test_mode.c, thymio-buffer.c, thymio_natives.c, tone.c, usb_uart.c, wav.c
  • from usb_pic24 folder:
    • usb_descriptors.c, usb_device.c, usb_function_cdc.c
  • from aseba git tree:
    • natives.c, vm-buffer.c, vm.c
  • from molole svn tree:
    • clock/clock.c, error/error.c, flash/flash.c, i2c/i2c.c, i2c/master.c, i2c/master_protocol.c, i2c/slave.c, timer/timer.c

Note that if you want to edit the firmware, you should add the following two files from the aseba-target-thymio2 git tree as "Important files": skel-usb-user.c, skel-usb-user.h. You should not compile them directly, as they are included from skel-usb.c/h. The reason is that skel-usb.c/h is target-independent code, while skel-usb-user.c/h is target-dependent code.

Project setup:

  • Compiler options: -Os -mlarge-code -fomit-frame-pointer -fno-strict-aliasing
    • On, linux add: -fno-peephole2, because of a compiler bug (official workaround from microchip).
  • Add molole, usb_pic24, aseba git tree, and aseba-target-thymio2 as include search path.

Here are screenshots of the detailed options you should set in the project properties:


Then you should be able to compile the firmware. To upload it to the robot, use the Thymio firmware upgrader and not a program such as icd3 or pickit3.

Released versions (old V3)

The zip archives contain 3 folders:

  • thymio2
  • bootloader
  • usb_pic24

The bootloader and main code share the same USB low-level code. This is mandatory as the switching between the bootloader and the main code is done while the USB link is running. Thus you should not modify those files unless you really know what you are doing:

  • everything under bootloader and usb_pic24 folder
  • the following files inside thymio2 folder: entry.s skel-usb.c usb_uart.c

Compiling the released versions

Source code

To compile the firmware you need the following source code:

  • Aseba branch master
  • Molole trunk
  • released zip archive


You need the MPLAB environment and C compiler:


When you open the file thymio2/thymio2.mcp, you will need to locate several missing files which are included in Aseba and Molole. Here is the list:

  • Molole
    • clock.c, error.c, flash.c, i2c.c, master.c, master_protocol.c, timer.c
  • Aseba
    • native.c, usb-buffer.c, vm.c, vm-buffer.c

Moreover, in the project settings, make sure the Include search path points to the correct Molole and Aseba source folders.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License