This summer I started learning about embedded systems, focusing on the TM4C123 Development Board. I started out using the Keil IDE on my windows desktop and decided to look for Linux alternatives that were not so cumbersome. Feeling unsatisfied with alternatives I decided to start learning about CMake for cross-compilation. I then stumbled across the lm4tools flasher software and some sample code on GitHub by Vitor Matos. I can now use Vim and one command, "make flash" to program and upload code onto my TM4C123.
Prerequisite SoftwareTo get up and running you will need some software that is easily obtainable and open source.
- From Linux Repositories
These packages should be available on most distros (Using Arch as an example).
pacman -S make cmake arm-none-eabi-gcc arm-none-eabi-newlib gcc-c++ libusb unzip
- Installing lm4flash
Manually from Github:
mkdir ~/tiva-projects; cd ~/tiva-projects
git clone https://github.com/utzig/lm4tools.git
cd lm4tools/lm4flash
make
We now need to add lm4flash to our PATH and get the udev rules for the usb device
sudo echo "export PATH=$PATH:$HOME/tiva-projects/lm4tools/lm4flash" &>> ~/.profile
echo 'ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00fd", GROUP="users", MODE="0660"' | \
sudo tee /etc/udev/rules.d/99-stellaris-launchpad.rules
- Getting TivaWare software
Go to http://software-dl.ti.com/tiva-c/SW-TM4C/latest/index_FDS.html and download the Full Release .exe file (need to make a free account) then go to or create your own projects folder, example below.
cd ~/tiva-projects
mkdir tivaware; cd tivaware
mv ~/Downloads/SW-TM4C-2.1.3.178.exe .
unzip SW-TM4C-2.1.3.178.exe
make
Setting up the project directoryWe now have all the software we need and can get a blinky project going to test if it works!
cd ~/tiva-projects
git clone https://github.com/yusef-karim/cmake-tm4c-blinky.git
cd cmake-tm4c-blinky
#This is how our project directory looks
cmake-tm4c-blinky/
├── CMakeLists.txt
├── inc
│ └── tm4c123gh6pm.h
├── src
│ ├── blinky.c
│ └── startup.c
├── tiva.specs
├── tm4c123g.cmake
└── tm4c123g.ld
Almost there!
Building and uploading our codeWe can now use our CMake files to create a Make file that can compile and upload the code directly to our board. Make sure your board is plugged in and switched on for these steps.
mkdir build
cd build
cmake ..
make
sudo make flash
NOTE: If the last command does not work try below command instead and go to the link below for more information on how to fix.
sudo env PATH=$PATH make flash
https://stackoverflow.com/questions/257616/sudo-changes-path-why
Done!Huzzah! If you followed the steps above the code should now be on your board. The blinky.c example program blinks the blue on-board LED every 500ms when the on-board switch SW1 is held down and keeps the red on-board LED on if SW2 is pressed and held.
ThanksHey, thanks for reading through this. I am brand new to embedded systems, hackster.io and programming in general. If you see any errors, improvements or recommendations for further development please let me know!
Comments
Please log in or sign up to comment.