Monday, November 18, 2013

Setup eCos Development Environment on Ubuntu 12.04 for STM32

Before You Begin

Install Required Tools & Dependencies

  • sudo apt-get install cvs libstdc++5 ia32-libs libglib2.0-dev

Download eCos then Setup

  • wget --passive-ftp
  • sh ecos-install.tcl
    • choose a faster distribution site, like "[16]", which may locate in Japan
    • choose a location to store the downloads, take default /home/<username>/ecos as example in this article
    • select "[1] arm-eabi", which is said in my course assignment instruction; however, I found we don't need this if we have arm-none-eabi (which we've installed already)
  • cd /home/<username>/ecos
  • cvs -z3 -d co -P ecos
  • in file "", modify "ECOS_REPOSITORY=/home/<username>/ecos/ecos-3.0/packages ; export ECOS_REPOSITORY" to "ECOS_REPOSITORY=/home/<username>/ecos/ecos/packages ; export ECOS_REPOSITORY"
  • .
    • this exports the system PATHs for ecos tools

Create HelloWorld Project

  • cd <somewhere you like to place you project>
  • mkdir ecos_project && cd ecos_project
  • ecosconfig new stm32f4discovery
  • configtool
    • change "eCos HAL->Cortex-M Architecture->Cortex-M3/-M4 STM32 Variant->STMicoelectronics STM32F4-Discovery board HAL->Startup Type" to ROM instead of JTAG
    • this starts an GUI interface, open the "ecos.ecc" file which locates in the folder "stm32f4discovery" just created
    • press "Build" -> "Generate Build Tree"
  • create an hello.c file, like:
#include <stdio.h>
int main(){
  printf("hello ecos!\r\n");

  • arm-none-eabi-gcc -o Hello.elf hello.c -Lecos_install/lib -I ecos_install/include -mcpu=cortex-m4 -mthumb -g -O2 -ffunction-sections -fdata-sections -Ttarget.ld -nostdlib
  • arm-none-eabi-objcopy -O binary -R .sram Hello.elf Hello.bin
    • finally, you got Hello.bin here, and burn it into stm32 by following the instruction in last article using QSTLink2 

No comments:

Post a Comment