Rustic Engineering

My Mind working on…

ARM Development on Mac (with CrossWorks and STM32L-DISCOVERY)

with 5 comments

Move to 32 bits ARM core

Recently I moved my projects to 32 bits ARM way. After some time thinking about various platforms, I’ve decide to abandon any Windows based tool, and trying to work only with Mac, without Parallels Desktop. For small 8 or 16 bits PIC projects, I still use MPLABX. For ARM core I’ve decide to use STM32 series.

As development tool I’ve chosen Rowley CrossWorks. They have a reasonably price for non-commercial use ($150) and the most important, a Mac Os Lion version. I’ve also bought some STM32 boards, and in that post I’ll show my steps with one of them: STM32L-DISCOVERY. The other boards I also have are STM32F4-DISCOVERY and WaveShare Port103R (great board! post more later).

STM32L-DISCOVERY Development Board

The STM32L-DISCOVERY helps you to discover the STM32L ultra low power features and to develop and share your applications.

It is based on an STM32L152RBT6 and includes an ST-Link/V2 embedded debugging tool interface, a LCD (24 segments, 4 commons), LEDs, push buttons, a linear touch sensor or touch keys.

Recent version of Rowley CrossWorks for ARM added support for ST-Link/V2 programmers, so you can connect STM32L-DISCOVERY board directly to your Mac and start ARM developing.

Environment preparation steps

To work with STM32L-DISCOVERY board in CrossWorks, we’ll need to do some preparations:

  1. Install CrossWorks “STMicroelectronics STM32 CPU Support Package”:
    • Choose “Tools” menu, then “Package Manager…
    • In search box, write “STM32 CPU Support”
    • Double click to change action to “Install”
    • Next
    • Next
    • Finish
  2. Install the “STM32L-DISCOVERY firmware package” (version 1.0.2):
    • You’ll need to download it from the ST website;
    • Unfortunately, ST doesn’t have a Mac friendly package. You will see that it’s a Windows “.exe” that install it under Program Files/STMicroelectronics directory.
    • But you’re lucky. I’ve already unpack it and share over my dropbox account. Click here and unpack it on your CrossWorks projects directory.

CrossWorks project creation steps

  1. Creating  a new STM32 project:
    • Select menu “File“, then “New Project” menu item.
    • Select the “STMicroelectronics” from the Categories list.
    • Select the executable for STMicroelectronics STM32 from the Templates list.
    • Enter the name of your project: AN3413-Current_consumption_touch_sensing
    • Enter the location of your project. Create a new folder under “STM32L_Discovery_Firmware_Pack_V1.0.2/Projects/AN3413-Current_consumption_touch_sensing/CrossWorks/
    • Next
    • Select the Target Processor as STM32L152RB. You can finish it from here.
    • Next. Uncheck “main.c” (you don’t need that auto-generated file)
    • Finish
  2. Include Preprocessor Definitions
    • Select menu “Project“, then “Properties…” menu item. The Project Manager window appears.
    • Select View: Properties, Properties: All, Grouping: Categorize, Configuration: Common
    • Navigating on “Settings:” and find “Preprocessor Options
    • In “Preprocessor Definitions“, include the following:
      • USE_STDPERIPH_DRIVER
      • STARTUP_FROM_RESET
      • STM32L15XXB_128
    • Don’t close Project Manager window, yet.
  3. The “User Include Directories” uses project directory in path reference. Now we are going to include the various library include paths (.h):
    • In “User Include Directories”, include the following:
      • ../inc
      • $(TargetsDir)/STM32/include
      • $(TargetsDir)/CMSIS_3/CMSIS/Include (necessary after after STM32 Support Package 2.14, see release notes)
      • ../../../Libraries/STM32L1xx_StdPeriph_Driver/inc
      • ../../../Libraries/STM32_TouchSensing_Driver/inc
      • ../../../Utilities/STM32L-DISCOVERY
  4. Go to Project Explorer to add the project source files (.c):
    • Expand the Project
    • Tap with two fingers in “Source Files”, chose “Add Existing file…”
    • Add the files:
      • main.c
      • discover_functions.c
      • icc_measure_Ram.c
      • icc_measure.c
      • stm32l1xx_it.c
      • system_stm32l1xx.c
    • Create a “Utilities” folder under Project ‘AN3413-Current_consumption_touch_sensing’ (Tap with two fingers and “New folder…”)
    • Make it a Dynamic folder (Tap with two fingers on “Utilities” folder, then “Dynamic folder…”)
    • In Directory, use “../../../Utilities/STM32L-DISCOVERY” (or navigate and find it on you STM32L_Discovery_Firmware_Pack_V1.0.2 folder)
    • Ok
    • Create a “STM32L1xx_StdPeriph_Driver” folder, make it Dynamic, point it to “../../../Libraries/STM32L1xx_StdPeriph_Driver/src/
    • Create a “STM32_TouchSensing_Driver” folder, make it Dynamic, point it to “../../../Libraries/STM32_TouchSensing_Driver/src/
    • Your project Items need to look like this (“System Files” folder is automatically added):

Compiling steps

At this point we can build that solution. Click on “Build” menu, then “Build AN3413-Current…” . You’ll see a little devil error like that:

Well, one fix at time. Let’s start with the message:

- THUMB Debug/AN3413-Current_consumption_touch_sensing.elf section `.DataFlash’ will not fit in region `UNPLACED_SECTIONS’

– region `UNPLACED_SECTIONS’ overflowed by 2 bytes

There’s nothing about “UNPLACED_SECTIONS” under CrossWorks for ARM Reference manual, so I’ve been opened a trouble ticket for CrossWorks support team. They are very smart and always catch what you need (if you provide them all the details).

According to support, the variable is being placed in a “.DataFlash” section which needs to be allocated into the EEPROM segment. “UNPLACED_SECTIONS” exists to catch errors when sections haven’t been placed. (Thank’s Michael Johnson from Rowley!).

And, if you look at Symbol Browser (“Tools” menu) you’ll find the “.DataFlash” 2 bytes section on the range:

Reading STM32L152RB datasheet, in the memory map section it confirms it’s the EEPROM region, so they are right. But that ugly name “.DataFlash” makes me believe that it’s Flash Memory related. Bad name, bad name…

They told me how to initialize it:

  • Tap two fingers in Project ‘AN3413-Current_consumption_touch_sensing’ and select “Import Section Placement” to get a project local copy of the section placement file “flash_placement.xml“.
  • Tap two fingers on file “flash_placement.xml” and select “Open With” then “Code Editor“.

Add a new segment:

<MemorySegment name="EEPROM" >
 <ProgramSection alignment="4" load="No" name=".DataFlash" />
</MemorySegment>

After that, your file looks like that:

Let’s work on the rest errors:

- THUMB Debug/stm32l15x_tsl_ct_acquisition.o: In function `TSL_IO_Acquisition_P1′: 

– undefined reference to `__TSL_wait_CLWHTA’ 

– undefined reference to `__TSL_wait_CLWLTA’

A double click in that lines let you go to “stm32l15x_tsl_ct_acquisition.c” source file, from STM32_TouchSensing_Driver. Let’s do a search on it, looking for “__TSL_wait_CLWHTA“, and you’ll find the follow piece of code:

So, your problem is here: “__INLINE” isn’t supported by CrossWorks. Remove only the “__INLINE” and repeat it for “__TSL_wait_CLWLTA” function. Now, Clean and Rebuild the entire solution. That’s it! Compile Ok!

Running it on board!

Connect the STM32L-DISCOVERY board to your Mac.

  • Select “Target“, “Connect…“, then select ST/LINK-V2;
  • In Properties Window, select “Target Interface Type: SWD“;
  • Target, Download it to board and see… it’s works!
Here you see my results:

AN3413 Running!

Some comments 

If you want my entire project files, you download it on my downloads page. Unpack it under your CrossWorks project directory. These files contains all my entire folder.

Next post I’ll show how to compiling the other example, AN3964-Temperature_sensor.

Thanks!

About these ads

Written by forrequi

January 23, 2012 at 09:25

5 Responses

Subscribe to comments with RSS.

  1. Love the new design.

    Paul Asselin (@AsselinPaul)

    January 28, 2012 at 09:56

  2. It seems like they used second hand LCDs for my 2 (new) discoveries…is the lcd on yours a bit long in the tooth even new?

    Pro Crastinator

    February 17, 2012 at 02:48

  3. Great tutorial, just started with this board on a Mac, but i didn’t know about Crossworks yet, thanks!

    Levente Balogh

    March 31, 2012 at 03:55


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: