Skip to content

Preparing the environment

Pham Van Nhi edited this page Jun 13, 2018 · 8 revisions

Hi,

I'm working currently with Ubuntu 16.04 (Linux), due to that's free for all. Below are some tools and the way to creating a compiling environment on Linux.

Flash tool

  • Tools: lm4flash

    This is a command-line flash tool and able to work on all Linux, Windows and Mac OS X.

  • Source: https://github.com/utzig/lm4tools

  • How-to build:

    • Pre-condition: The libusb-1.0 must be install in advance.
    • Clone the repo: git clone https://github.com/utzig/lm4tools.git
    • Change directory: cd lm4tools/lm4flash
    • Build: make release PREFIX=/path/to/install
    • Finish, add the lm4flash tool to $PATH if necessary: export PATH=$PATH:/path/to/install

Compiler on Linux

  • GNU ARM Embedded Toolchain

  • Download: link

  • Extract to somewhere, and add the compiler to the $PATH as follows:

    export PATH=$PATH:$HOME/tools/gcc-arm-none-eabi-7-2017-q4-major/bin

Debugger

  • OpenOCD (Open On-Chip-Debugger) with ICDI support.
  • Clone OpenOCD prj from GIT: git clone git://git.code.sf.net/p/openocd/code openocd
  • Or download: link
  • Need to enable ICDI support (--enable-ti-icdi) when configuring OpenOCD. To build OpenOCD, use the following sequence of commands:
cd openocd
./bootstrap
./configure --prefix=/usr --enable-maintainer-mode --enable-stlink --enable-ti-icdi
make
sudo make install

Using the Visual Studio Code for debugging

  • Download the vscode at the link.

  • Install an extension: Cortex Debug.

    Debugging support for ARM Cortex-M Microcontrollers with the OpenOCD GDB Server.

  • Configuring the Launch for debugging

    • Refer to here for more info.
    • Below are my configuration as an example for Tiva-C Debugging
"configurations": [
        {
            "cwd": "${workspaceRoot}",
            "executable": "./demo/bare_metal_gcc/blinky_prj/blinky.axf",
            "name": "Debug Microcontroller",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            "configFiles": [
                "/usr/share/openocd/scripts/board/ek-tm4c123gxl.cfg"
            ]
        }
]

Create a hello-world program

The source code is implemented in the repo ./wiki/preparing_environment

  • Compiling the hello program:
cd wiki/preparing_environment
make build
  • Flashing the program (binary files) to the Tiva-C board.
sudo lm4flash hello.axf
  • Debugging

    TBD: Add an image for debugging on vscode

Reference

Some repo on github