What is Micropython?
Why on Arduino Due?
Arduino Due is the first 32-bit microcontroller introduced in 2013. It has the powerful SAM3X8E chip which runs at 84 Mhz, 96KB of RAM, 512KB of flash memory and tons of extra I/O peripherals like CAN bus and dedicated DACs. This makes Due perfect for running Micropython.
[NOTE: The Micropython port on Arduino Due is still in BETA, so not all peripherals are currently supported. Go to Github repo for the current status of the project]
This is a step-by-step guide on how to flash & run Micropython on Arduino Due.
Step 1: Downloading necessary programs and libraries
- You'll need ARM GCC Toolchain to compile source code. Go to this link to download & install Toolchain for your windows version.
- You'll also need 'make' utility. You can also install it from MinGW project which is a collection of GNU utils for windows.
Alternatives: I highly recommend using cygwin because it's easy to setup, all your files stay in a single folder and you can use this script as CLI package manager.
- You'll also need Arduino IDE installed on your PC.
- PuTTY is required for serial communication.
- A clone of my Git-repo.
Step 2: Installing drivers and setting up tools
- Plug Due's 'Prorgramming port' to the PC.
- Hold the Erase button for a second and release.
- Windows should automatically install drivers and recognize device as 'Arduino Programming port'.
- Now we need to setup Bossac tool. You'll need to add the full path in Windows environment variable list. The executable is in micropython/atmel-sam3x/tools folder.
Step 3: Compiling micropython
- Open command
cdinto your micropython/atmel-sam3x folder.
- Then type:
It will compile the source code and create a bin file in /build folder.
Step 3: Flashing Micropython on the Arduino Due
- Plug USB to PC and to Arduino Due's 'Programming port'
- Once detected, go to control panel > Hardware and sound > device manager > ports and note the COM port number. In my case, it is COM8.
- In the same folder (atmel-sam3x) type:
make upload port
=(your COM Port)
Flashing takes about 20-30 seconds to complete. After successful flashing the board will reboot itself.
Step 4: More driver installation
- Now disconnect the board and plug it again but with 'Native port'.
- Automatic driver installation will eventually fail.
- In the device manager under ports section, you'll see:
- Right click on CDC Virtual Com > Update driver software > browse computer > select the micropython/atmel-sam3x/drivers folder. After installation you'll see the following but with different COM port.
Step 5: Profit
- Open PuTTY and click on Serial button and type your COM port enter speed 115200 and hit open.
- You'll see a blank screen, just hit Ctrl + D and Voila!
help()to see what features board currently supports.
Type the following LED blink program in REPL:
>>>from machine import LED, time >>>while True: >>> LED.toggle() >>> time.sleep_ms(500)