• Stars
    star
    281
  • Rank 147,023 (Top 3 %)
  • Language
    C
  • License
    GNU Lesser Genera...
  • Created almost 8 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

libopencm3 and FreeRTOS projects using the STM32F103C8T6 MCU

Project stm32f103c8t6

This is the source code for the book:

Beginning STM32 : Developing with FreeRTOS, libopencm3 and GCC

ISBN: 978-1-4842-3623-9 Soft cover
      978-1-4842-3624-6 eBook

https://www.apress.com/us/book/9781484236239

This git repo contains libopencm3 and FreeRTOS+libopencm3 projects. This provides a ready development environment for those who want to apply the economical STM32F103 to using libopencm3 alone or in concert with FreeRTOS.

THIS PROJECT ONLY USES OPEN SOURCE TOOLS

No Windows based IDE environments are used or implied! Cygwin, Linux, MacOS and *BSD environments are suitable.

This project exists to bring several components together in a manner that just works for the STM32F103.

PROJECT STRUCTURE:

The top level defines the environment common to libopencm3 mainly, and used by FreeRTOS builds in the ./rtos subdirectory.

At the top level directory, projects like ./miniblink use libopencm3 only (they do NOT use FreeRTOS).

The subdirectory ./rtos contains projects that do use FreeRTOS (and libopencm3).

stm32f103c8t6/
    |- README.md
    |- LICENSE
    |- libopencm3/          git submodule
    |- stm32f103c8t6.ld
    |- Makefile             makes all top-level projects
    |- Makefile.incl        rules for make file builds
    |- miniblink/           simple blink: libopencm3 only
    |   |- *                miniblink files
    |- uart/                UART example (no flow control)
    |   |- *        
    |- uarthwfc/            UART example with hardware flow control
        |- *
    |- rtos/                FreeRTOS projects
        |- FreeRTOSv10.0.0  Unzipped FreeRTOS sources (you create this)
        |- Makefile         Used for creating new rtos projects
        |- Makefile.rtos    Rules for rtos project builds
        |- src/
        |   |- *            Files used for project creation
        |- libwwg
        |   |- Makefile
        |   |- include/*.h
        |   |- src/*.c
        |   |- libwwg.a
        |- blinky           Test FreeRTOS project
        |   |- *            Blinky project related files
        |   |- rtos
        |       |- *        RTOS Support files for blinky
        |- uart3            Another project..
        |   |- *
        |   |- rtos
        |       |- *
        |- usbcdc           USB CDC Demo
            |- etc.

PREREQUISITES:

0a. It will be assumed here that you have your cross compiler
    toolchain installed. In Makefile.incl you'll see references
    to a PREFIX variable. This defaults to arm-none-eabi so that
    gcc for example will be arm-none-eabi-gcc etc. If your 
    prefix differs, edit Makefile.incl at the top level to
    match, or use the shell: export PREFIX=whatever

0b. It is also assumed that you have the st-link command installed
    on your system. You may need to download and install it. 
    Google is your friend.

1.  If you didn't use a --recursive git clone, then you need to make
    sure that libopencm3 is fetched now. From the top level apply
    one of:

        $ git submodule update --init --recursive   # First time

        $ git submodule update --recursive          # Subsequent

2.  Go into ./libopencm3 and type "make". This should build the 
    static libraries that will be needed. Any issues there should
    go to the libopencm3 community.

3.  For FreeRTOS, cd into ./rtos and unzip your FreeRTOS download
    there. It should create a subdirectory FreeRTOSv10.0.0 or 
    similar. If the release differs, you'll need to change the
    variable assignment in rtos/Project.mk FREERTOS ?= ....
    to match, or use the shell: export FREERTOS=whatever

4.  Do NOT compile FreeRTOS, since portions of it will be copied
    to your project subdirectory for further customization. Each
    project is capable of running a different FreeRTOS configuration.

5.  At the top level, do a "make" so that the libwwg and other
    projects get built.  Do a "make clobber" first, if you need
    to rebuild.

All of this is explained in detail in the book.

TEST EXAMPLES:

After the prerequisites have been met:

Going into ./miniblink and:

$ make
$ make flash

should build and flash your example program. Flashing assumes the use of the st-link (v2) command.

Or go into ./rtos/blink:

$ make
$ make flash

will build your FreeRTOS blink example.

If you are encountering make errors, then try forcing the use of Gnu make (it may be installed as "gmake").

CREATING NEW FreeRTOS PROJECTS:

1. cd ./rtos
2. make -f Project.mk PROJECT=name
3. cd ./name
4. Tweak and build

See ./rtos/README.md for more details.

LICENSE:

All files covered by this repo (except those copied from libopencm3 and FreeRTOS, or otherwise marked), are covered by the GNU Lesser General Public License Version 3. See the file named LICENSE.

Bill of Materials for Book:

  1. ST-Link V2 Programmer
  2. Breadboard
  3. Dupont (Jumper) Wires
  4. 0.1 uF Bypass caps (for use on breadboard)
  5. USB TTL serial adapter
  6. Power supply (on eBay MB102 Solderless Breadboard Power Supply Module 3.3 and 5V switchable)
  7. Small assortment of LEDs
  8. 220 ohm or SIP-9 resistor at 220 ohms for several LEDs
  9. Get 3 x STM32 units if you want to do the full CAN project, but you can skimp with two if necessary.
  10. Winbond W25Q32/W25Q64 flash chip (DIP)
  11. PCF8574 GPIO extender (DIP)
  12. OLED using SSD1306 controller (four wire SPI only, eBay)
  13. RC servo(s) and/or scope (to control a servo)
  14. RC servo controller(s) or 555 timer circuit to generate PWM to be read
  15. Optional: Scope for examining clock signals for one chapter

Notes:

  1. When compiling and you get the error message getline.c:5:20: fatal error: memory.h: No such file or directory, at the line where it is coded as "#include <memory.h>", you may have to change that to "#include <string.h>" instead. The compiler folks have sometimes moved the header file.

  2. It has been reported that: Kubuntu 18.04 ships with arm-none-eabi-gcc (15:6.3.1+svn253039-1build1) 6.3.1 20170620, with this compiler the code does not work (creates problems for FreeRTOS). memcpy seems to be the problematic function call in the code, it is called by FreeRTOS when adding an element to the queue. (details in the FreeRTOS discussion on SourceForge)

More Repositories

1

cobcurses

Cobcurses (migrated from SF)
COBOL
16
star
2

teensy3_qemu

Changes to QEMU to accomodate the teensy3.x arm platform (Cortex-m4)
C
15
star
3

raspberry_pi

Book Source Code for "Mastering the Raspberry Pi"
C
13
star
4

raspberry_pi2

Exploring the Raspberry Pi 2 with C++ (ISBN 978-1-4842-1738-2)
C++
12
star
5

ESP8266_TCP_UDP

Embedded ESP8266 C++ Class Library for TCP & UDP Support
C++
11
star
6

miniprintf

Low overhead minimal printf(3) implementation for MCUs like the ARM Cortex-M3
C
9
star
7

FreeRTOS_for_ESP32

FreeRTOS for ESP32-Arduino: ISBN 978-1-907920-93-6
C++
9
star
8

custom_interfaces_pi

Source code for book: Custom Raspberry Pi Interfaces (ISBN 978-1-4842-2405-2)
C++
5
star
9

esp32_freertos

ESP32 FreeRTOS Demonstrations
C++
5
star
10

teensy3_fibers

This is a Teensy-3.x Lightweight Fibers Project, usable by Arduino IDE or a Makefile build
C++
4
star
11

risc-v

RISC-V Assembly Language Programming: Using ESP32-C3 and QEMU
Assembly
4
star
12

pugixml_ada

A thick Ada Binding for the pugi::xml C++ library
C++
3
star
13

teensylc_fibers

Lightweight Threads for Teensy-LC (Cortex-M0)
C++
2
star
14

avr

AVR code
Assembly
2
star
15

ezusbcc

EZ-USB Waveform Compiler
C++
2
star
16

Advanced_Raspberry_Pi

Advanced_Raspberry_Pi
C
2
star
17

PCoroutine

pthreads Coroutine simulation library for MCU application testing
C++
1
star
18

teensy3_lib

Teensy 3.1 development environment, without use of the Arduino IDE
C
1
star
19

isbn-067231990X

Advanced UNIX Programming
C
1
star
20

cppcurses

C++ NCurses Class Library
C++
1
star
21

chartree

C++ Template library for character tree handling
C++
1
star
22

GU128X32-800

A Noritake GU128X32-800 VFD C++ class, using UGUIF for the Raspberry Pi
C
1
star
23

8051_ezusb

EZ-USB Programs
C
1
star
24

isbn-0789722410

Linux Socket Programming by Example
C
1
star
25

plan13cpp

Plan13 Cleaned up for POSIX C++
C++
1
star