MEAM.Design - M4 - Getting Started in Linux (Ubuntu)
Install ARM GCC Compiler binaries
1. Download the GCC-ARM-Embedded binaries for Ubuntu from here
2. Rename the downloaded file to "gcc-arm-none-eabi.tar.bz2"
2. Move it to "/usr/local/bin"
mv gcc-arm-none-eabi.tar.bz2 /usr/local/bin/
3. Extract the files
tar xf gcc-arm-none-eabi.tar.bz2
4. Add the path of the binaries to the PATH variable
echo export PATH=$PATH:/usr/local/bin/gcc-arm-none-eabi/bin >> ~/.bashrc source ~/.bashrc
Install libusb driver and dfu-util
1. Install libusb
tar xf libusb-1.0.9.tar.bz2 cd libusb-1.0.9 ./configure make sudo make install
2. Install dfu-util
cd ~/Downloads git clone git://gitorious.org/dfu-util/dfu-util.git cd dfu-util ./autogen.sh ./configure sudo make install
Compile Source Code
1. Download the template code which contains all the libraries. (Note if you have Green M4 edit the Makefile and change -DM4_WHITE to -DM4_GREEN)
2. Place your source files (*.c) in "m4Template/src" folder OR "m4Template" folder
3. Place your header files (*.h) in "m4Template/inc" folder OR "m4Template" folder
4. Navigate terminal to m4Template folder and execute:
make
5. Last line should look something like
[>--BinaryGenerated--<]
Upload your code
1. Connect the microcontroller to the computer, hold the onboard button until the Orange LED is on (about two seconds), then release it.
2. Execute the flollowing in terminal
make flash
3. You should see a number of messages that indicate that this works. If it does not work, check the connection, and check to make sure the switch is in load and press the reset button.
Running your code
1. Tap the onboard button for less than two seconds, the orange LED should turn off, and your code should run.
Note:
You can also call make with following arguments
make clean
-- cleans all the object files of user source filesmake cleanlib
-- cleans all object files for the library and user source filesmake flash
-- upload code using USB DFU Bootloadermake disassemble
-- generates .dis and .dmp file for debug purposes
Running without root:
To avoid needing to run anything as root when programming the M4:
- Create a new file in /etc/udev/rules.d, called something like '90-m4.rules'
- In that file, add the following lines:
SUBSYSTEMS=="usb", ATTRS{idProduct}=="df11", ATTRS{idVendor}=="0483", MODE="0666", SYMLINK+="m4"
SUBSYSTEMS=="usb", ATTRS{idProduct}=="5740", ATTRS{idVendor}=="0483", MODE="0666", SYMLINK+="ttyM4"
- Reload the udev rules:
sudo udevadm control --reload-rules
- When you reconnect your micro, it should show up as
/dev/m4
, and you shouldn't need to use sudo when runningdfu-util
ormake flash
anymore
\\