Bootstrap and definition library for programming STM32L100RC in ARM assembler. This was a class project to learn ARM assembly
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.2 KiB

# Bootstrap project and an asm library for STM32L100
9 years ago
[Česká verze](README.cz.md)
9 years ago
## Project description
9 years ago
The project consists of a definition library for the STM32L100 ARM microcontroller.
9 years ago
The library is in a large part converted from the device-specific CMSIS header files, other
files are based on the datasheets.
9 years ago
The project also includes a simple "Hello World" program which demonstrates usage of the library
by blinking the LEDs on your STM32L100 Discovery board.
9 years ago
A startup script (startup_stm32l100xc.s) comes from the Keil device packages, and can also be
found in the CMSIS.
9 years ago
## Target hardware
9 years ago
The project targets the STM32L100RC on the STM32L100C-DISCO Discovery development board. The kit
is attached to the computer using a USB cable.
9 years ago
## Library structure
9 years ago
The assembler library is located in a `lib/` folder, and consists of multiple modules.
9 years ago
To use any of the modules, first include `INI_BASE.s`, then the required modules (in any order).
9 years ago
Example of the library usage:
9 years ago
```asm
; Base file
GET lib/INI_BASE.s
9 years ago
; Registers and bit presets for the peripherals
9 years ago
GET lib/INI_BITS_GPIO.s
GET lib/INI_BITS_RCC.s
GET lib/INI_BITS_FLASH.s
```
## Code style
All comments are in English. Files are formatted with spaces, or tabs 4 spaces wide.
All files should use Windows line endings for compatibility with Keil.
## Development environment
The library will work with any tool that supports the ARM assembler.
### Keil MDK-ARM (Windows)
Included are project files for **µVision MDK-ARM v.5** (Keil).
You can obtain a trial copy of Keil MDK for free from their website (after filling in some fake
contact info to "register"). There is a code size limitaiton (32 kB), but that's usually not a
problem.
If you're working on Windows, this is probably the best tool you can get.
### Developing on Linux
9 years ago
On Linux, you can run Keil in Wine (without hardware support), and also in Virtualbox
(but with ST-Link v2 only).
9 years ago
If you choose to use a more native "IDE" (read: vim, Sublime Text...), you can use the
provided Makefile for compilation and flashing.
9 years ago
First, though, you have to setup the compiler:
9 years ago
1. Install Keil in `wine` (into `~/.wine`) - we'll be using the trial version of
the otherwise paid compiler, and for that we need the Keil license files.
9 years ago
If you are adventurous, you can try to use the Keil license files with the native Linux
version of the compiler.
9 years ago
2. Check that the Makefile variable `WINEPREFIX` points to the folder with the Keil
compiler binaries. If you are using the linux versions of those, adjust your Makefile
accordingly.
9 years ago
3. For a disassembler support, install `arm-none-eabi-binutils`. This is optional.
9 years ago
4. Install the `stlink` package - drivers for communication with the development board.
This step is optional, if you don't need flashing.
9 years ago
*Tip:* ArchLinuxu users can find both `stlink` and `arm-none-eabi-binutils` in the Community
repository.
9 years ago
### Using the ARM DS-5
9 years ago
The "official" ARM IDE, DS-5, is really expensive, but there's a free "Community Edition".
9 years ago
The IDE is a customized Eclipse, so if you have some Eclipse experience, you're right at home.
**The catch** is that this variant **can't compile anything** - not even assembler.
The editor and the context-help manual viewer work perfectly, though.
There is some Makefile support, but I've found it rather pathetic. If you, however, install
a terminal plugin into the IDE, you can conveniently run the Makefile tasks to compile and
flash your program.
9 years ago
## Credits
9 years ago
This project is developed for educational purposes at the [Department of Measurement][measure] of the CTU in Prague. The project may be used in the [NVS][nvs] and [MMP][mmp] courses.
9 years ago
- The example program is based on an old code by Michal Tomáš © 2010.
- Base of the library extracted from CMSIS by Petr Douša © 2015.
- Further library improvements, organisation and the Makefile © Ondřej Hruška, 2015.
9 years ago
The library code is free to use in any educational and non-commercial projects, provided you retain the copyright notice and the file header files.
9 years ago
[measure]: http://measure.feld.cvut.cz/
9 years ago
[nvs]: http://measure.feld.cvut.cz/vyuka/predmety/A4B38NVS
[mmp]: http://measure.feld.cvut.cz/vyuka/predmety/A3B38MMP