Return to site

Download Leaflabs Driver

broken image


If you still can't get the IDE installed after reading this page,check the troubleshooting page for help withsome common problems. If all else fails, try our forum, or contactus directly!

Starting from Windows 10, the STSW-STM32102 driver is no more adequate and the usage of the native inbox driver is recommended. Notes, typically a max data transfer mode. This USB driver STSW-LINK009 is for ST-LINK/V2, ST-LINK/V2-1 and STLINK-V3 boards and derivatives STM8/STM32 discovery boards, STM8/STM32 evaluation boards and STM32 Nucleo. Since the library is made to communicate with FTDI/Arduino (which are always 8N1) I don't see the use of changing those settings. Hi Toley, I agree the Arduino is fixed at 8N1 but the FTDI devices are not necessarily fixed & are usually settable, e.g. If you plug a FTDI USB to Serial adapter into your desktop pc & open the relevant comport using something like hyperterminal you are given the.

Programming AVRs was a walk in the park. Just download avrdude + avr-gcc, get a cheap USB programmer, and you were set. Compared to that, developing for ARM is like trying to stroll in the middle of a raging battlefield. First, you need to choose an ARM chip – Cortex-M0, Cortex-M3, etc. Maple was one of the first ARM Cortex-M3 microcontroller boards, all designed and built by LeafLabs. Much loved by users around the world, the STM32-based single board computer surpassed the capabilities of similar products when it was first released in 2009.

The current release of the Maple IDE is version 0.0.9. Choose thecorrect version for your operating system:

PlatformStatusIDE Package
WindowsTested on 32bit Windows XPmaple-ide-0.0.9-windowsxp32.zip (about 75mb)
LinuxTested on Ubuntu 9.10 (64bit) and 10.04 (32bit)

maple-ide-0.0.9-linux32.tgz (about 30mb)

maple-ide-0.0.9-linux64.tgz (about 30mb)

Mac OSXTested on Snow Leopard 10.6 (64bit and 32bit)maple-ide-0.0.9-macosx-10_6.dmg (about 40mb)

The package bundles together a compiler, an upload utility, a softwarelibrary, and a simple GUI text editor. All this software is free andopen; we are grateful to the Arduino, CodeSourcery, GNU, andOpenMoko developers, as well as many others,who allow us to reuse their software.

Looking for something older?Source archives and binaries are availablefor previously-released versions.

First, extract all the files in the ZIP file to a suitable location onyour system (like your Desktop folder). Next, you have to installsome drivers. Sorry!

Note

Note that while these instructions work on Windows XP,changes in Windows 7 mean that you won't be able to install the IDEwithout disabling driver signing on your computer. We're workingon resolving this situation. For now, users on the forum havereported some workarounds.

First, install DFU drivers (for uploading code to your Maple) usingthe following steps.

  1. Plug your Maple into the USB port.
  2. Hit the reset button on your Maple (it's the small button at thebottom left, labeled RESET). Notice that it blinks quickly 6 times,then blinks slowly a few more times.
  3. Hit reset again, and this time push and hold the other buttonduring the 6 fast blinks (the button is on the top right; it islabeled BUT). You can release it once the slow blinks start.
  4. Your Maple is now in perpetual bootloader mode. This should give you achance to install the DFU drivers.
  5. Windows should now prompt you for some drivers. In the top leveldirectory of the Maple IDE, point Windows todrivers/mapleDrv/dfu/.

Next, install serial drivers (for communicating with your Maple usingserial over USB).

  1. Reset your Maple and allow it to exit the bootloader (wait for theslow blinking to stop). The Maple will next start running whateverprogram was uploaded to it last. (New Maples will start running thetest program we upload to them before shipping them to you).
  2. Once Maple is running some user code, Windows should prompt you formore drivers. Point windows to driver/mapleDrv/serial.

You can now run the Maple IDE by double-clicking on themaple-ide program from within the extracted IDE directory.

Note

The IDE is written in Java and requires a compatible runtime (JRE).

If you don't have one, they're usually pretty easy to install. SunJava 1.6 and OpenJDK 1.6 are known to work, and runtimes mostlycompatible with Sun Java 1.5+ should probably get the job done.

To install Java, try using your distribution's software packagingtool and search for 'JRE' or 'java'. On Debian-based systems(including Ubuntu) you can try to install the OpenJDK 1.6 JREwith:

Extract the tarball to an appropriate location (like your homedirectory or desktop).

Make sure you have a Java runtime (JRE) installed; if you can runjava from the shell, you should be fine.

Next, run the script install-udev-rules.sh in the extractedIDE directory. It will ask for root permissions. You now need torestart udev:

This will grant members of the group plugdev read/write access toMaple devices over USB. Make sure that you are in that group. (Formore information on why this is part of the install process, see theUnix toolchain quickstart).

To run the Maple IDE, run maple-ide from the shell, ordouble-click on it if your window system supports it.

Feel free to put the IDE directory wherever you want. As long as youleave its internal structure unchanged, things should be fine.

Double-click on the .dmg file you downloaded to mount the diskimage. From the mounted image, drag and drop the Maple IDE icon intoyour computer's Applications folder.

To run the Maple IDE, double-click the Maple IDEapplication you dragged into your computer's Applicationsfolder.

Update

Please check out my more recent article on STM32 Programming:

Download Leaflabs Driver Download

AVR to ARM

My first introduction to microcontrollers was via the Arduino platform. But I soon started digging a little deeper and got into (8-bit) AVR programming. I was especially fascinated with the tinyAVR line, which I still think of as tiny computers that I can (almost) wrap my head around. I was hearing more and more about 32-bit ARM Cortex-M processors, but was intimidated by the apparent complexity of programming these chips. As I started working with connected devices like Nordic nRF51/52 (BLE) and TI CC3200 (WiFi), I got introduced to the concept of SoC – System On a Chip, where the radio was paired with a processor – often an ARM Cortex-M. Then came the Arduino Zero (and compatible boards like the Neutrino) which adopted the Atmel SAMD21 ARM Cortex-M0+ chip. So I started getting familiar with ARM, but the various layers of libraries and tools I used hid the ARM architecture from me.

In my view, an obvious advantage of ARM compared to (8-bit) AVR was superior capabilities – faster processor speeds, more number of peripherals like ADCs and GPIOs, USB, support for RTOS (Real Time Operating Systems), etc. But another surprising discovery was the cost factor. 32 bit ARM processors were actually cheaper than 8-bit AVRs! So if you were developing a product, the writing was on the wall. It was becoming a necessity to learn about these processors.

Pick an ARM, Code an ARM

Programming AVRs was a walk in the park. Just download avrdude + avr-gcc, get a cheap USB programmer, and you were set. Compared to that, developing for ARM is like trying to stroll in the middle of a raging battlefield. First, you need to choose an ARM chip – Cortex-M0, Cortex-M3, etc. Then, you need to choose a vendor – Atmel, ST, NXP, Microchip, etc., and go through their scary variety of offerings to make your final selection. Next comes the choice of a development board for your chip – either one with an integrated debugger (eg. J-LINK OB, ST-Link), or separate board and generic debugger (eg. J-Link). (The hardware helps you debug your code running in the chip, as well as upload it to the flash memory.) And then comes the most fun – selecting development tools for your chip. 'Professional' tools for ARM program are, for the lack of a more apt adjective, obscenely priced – like a few thousand US dollars.(Vendors also offer free code size limited versions of their expensive Pro tools.) Fortunately, Open Source comes to the rescue again, in the form of ARM GCC, OpenOCD and Eclipse. You can read a rather lengthy discussion on this topic here.

Once you have decided all of the above, you still have to make a choice on how to structure your code – use 'bare metal' (just registers + C), vendor's HAL or middleware, CMSIS, or maybe go 'full me(n)tal' and code in assembly.

My own experience with selecting an ARM Cortex-M3 chip went as follows: I trawled through various internet forums for posts that compared Atmel vs. NXP vs. ST vs. Microchip vs. WhateverARM. After a couple of days, I was convinced of one thing – we humans are an unhappy lot, and can't agree on anything. So I made my choice solely based on economics – ST has the lowest price on ARM chips – especially if I source them from China.

So in the end, I decided to begin my ARM journey with the STM32F103 ARM Cortex-M3 chip from STMicroelectronics.

Getting Started with STM32

When starting with ARM programming, I feel it's best to get the vendor's official development board, rather than muck around with third-party breakout boards, for these reasons:

  • They are usually very economical.
  • You get a well documented, working reference design.
  • Comes with a hardware debugger.
  • Easy to prototype with.

Since it's hard to argue about a $11 (inflated to Rs.1129 in our case) board, I got the STMicroelectronics NUCLEO-F103RB board with the STM32F103RB chip.

In this article, I'll build a small project using this board. Our goals are:

  1. Set up a development environment.
  2. Learn how to debug and upload code.
  3. Make an LED blink.
  4. Learn how to use the USART peripheral.

The first thing to do is to set up a development environment. As I mentioned, I decided to go with GCC, but even with GCC there are several choices, including paid options with support. I chose the ARM GCC toolchain, Eclipse IDE, and OpenOCD for debugging. I found that the simplest way of using these tools was via the Eclipse extensions for ARM GCC developed by Liviu Ionescu.

For installation please follow the excellent documentation by Liviu below:

Make sure you follow the steps in the given order. To quote the author:

'Note for beginners: If performed for the first time, it is recommended to follow the steps by the book and avoid poetic licenses, since they might lead to tricky situations and subtle functional problems.'

Download Leaflabs Driver Printer

Once you have gone through the installation, start an new project in Eclipse by choosing File->New->C Project where you get this dialog:

Choose the appropriate chip, and then you get this dialog:

In content you can just choose empty. At the end the dialog, you will end up with a directory structure similar to the one below:

In the above tree, I removed the _write.c file supplied by the project, and I also have Debug/Release populated above because I have built the executable.

The stm32f1-stdperiph directory above is the Standard Peripheral Library which is a layer of code provided by STMicroelectronics which lets you use the chip peripherals like GPIOs, ADSs, USARTs, etc. without directly setting up the registers. (More on this later.)

One thing to note is that a lot of the unused code is filtered out in the project settings, which can be found here:

Once you start using any of these files (eg. stm32f10x_usart.c) you need remove that from the exclude filter above.

Next, you need to set up OpenOCD for debugging. This is already covered in the installation list. But one thing I found to be missing is using OpenOCD to write the code to the flash memory of the chip. You can easily set that up under
Run->External Tools->External Tools Configuration:

(To clarify, OpenOCD debugging only loads the code onto the RAM of the chip, which is cleared when the chip is reset. The above writes to the Flash memory of the chip, so it's retained on reset.)

Now it's almost time to start coding. But before that, you need to do a bit of reading, and here's your list:

  1. STM32F103x datasheet from STMicroelectronics
  2. STM32F103x reference manual from STMicroelectronics
  3. UM1724 User manual for STM32 Nucleo-64 boards from STMicroelectronics
  4. AN2586 Application note – Getting started with STM32F10xxx hardware development

(1) above gives an overview of the chip whereas (2) goes into details – setting up registers and programming the chip. (3) is a handy reference for the Nucleo board, and (4) is helpful when you are designing your own PCB with the chip.

The above documents are all pretty cryptic, but fortunately there exists a great, free, comprehensible reference to get started on STM32:

Discovering the STM32 Microcontroller by Prof. Geoffrey Brown

You can find the PDF link at the bottom of his list of publications.

I highly recommend that you get the above PDF and spend some time reading it before you do any programming.

Before getting into what our program does, let's briefly look at a few approaches (not comprehensive) to programming STM32:

  1. Use Registers + C code
  2. Use the Standard Peripheral Library
  3. Use CMSIS
  4. Use STM32Cube + HAL
  5. Use some of the above and write your own portable 'middleware'

You can read up on CMSIS and STM32Cube, and maybe read this long discussion on eevblog, but making any decision there is beyond the scope of this article. So let's talk a bit about simpler approaches (1) and (2) below.

Here's some code that sets up pin PA5 as output so we can blink the LED (USR LD2) on the Nucleo board.

Above, we first enable the peripheral clock for GPIOA, and then proceed to set the appropriate registers (see datasheet) to set PA5 as an output.

It could be argued that the above code isn't 'bare metal' enough. Definitions like RCC->APB2ENR come from the stm32f10x.h file. You could certainly skip these headers and code directly with register addresses given in the datasheet – if you are feeling particularly masochistic.

Now let's code the same using the Standard Peripheral Library:

As you can see, the code is much more readable that the first version. Another fact is that this code is very easy to port across other chips from STMicroelectronics. But the downside is that the code, being generic, covers a lot of stuff that may not apply to your specific use. Take a look at GPIO_Init implementation in stm32f10x_gpio.c and compare it with the 'bare metal' code above.

One approach I can suggest is to use the Standard Peripheral Library, but not blindly. Read through the implementation of the functions you are using. When the need arises, write your own optimized functions that use just what you need.

Now let's get on with our program. We start with some initializations:

Download Leaflabs Drivers

In the above code, we set up PA5 (LED on Nucleo board) as output, and PC13 (Blue button on Nucleo board) as input. As before, peripheral clocks are enabled for these ports.

Next, we set up serial communications on USART2.

We're going to use PA2 (TX) and PA3 (RX) for serial communications. This is because they are already connected to the ST-Link hardware which is connected via USB to your computer. (You could use PA9 and PA10 instead, but then you'll need to hook up a separate USB to serial adapter on those lines for testing.) Once you start using Standard Peripheral Library, the initialization scheme is quite uniform, so the code above is pretty much self-explanatory.

Now let's look at the main loop:

The main loop proceeds as follows: We first read the button input on PC13. If the button is pressed, we set a flag val. If the flag is set, we enter an 'input mode' using the blocking call uart_getc(USART2);. We then read user input (expecting ‘1'/'0′) and use that to toggle the LED on PA. The UART methods used are all defined in stm32f10x_usart.c, and the GPIO methods in stm32f10x_gpio.c – all part of Standard Peripheral Library.

We'll talk a bit about the myDelay() function. This is implemented by
hooking into the SysTick_Handler of the chip:

Our SysTick_Handler overrides the default implementation in exception_handlers.c, and we use this to implement a delay function, as shown above. (This implementation is from Brown's book.)

To test the code, upload it the chip, open any serial communications application on your computer (I use CoolTerm.), and connect at 9600 baud and default settings.

The code above is far from robust. If you are using serial communications, you should probably use interrupts, for instance. But that's for another time.

External Programming with NUCLEO-F103RB

As I mentioned, one advantage of getting the official development board is the build-in hardware debugger. This hardware in most cases can be used to program external devices. In the case of the NUCLEO-F103RB, there is an SWD interface which can be used for this purpose.

The above figure is from the Nucleo user manual, and it shows how you can remove CN2 jumpers (move them to grounded CN11, CN12 so you don't lose them) and use the CN4 SWD connector for programming an external target.

I bought a cheap (Rs. 280, $4) STM32F103C8T6 board from ebay to test this out.

It worked great! Pins 1 to 5 on CN4 on the Nucleo board were needed. There's nothing special to be done – once connected, debug and program will automatically go to the external target. I wrote a simple blinky program for testing, and for this board, the LED was on PC13.

Leaflabs

Conclusion

Starting with ARM can be intimidating, especially if you come from the 8-bit AVR world. But there are good learning resources and free Open Source tools available that can help you with this task. Just be ready to do some heavy reading. 🙂

Downloads

You can get the complete source code for this project here:





broken image