Giter VIP home page Giter VIP logo

stm32-bootloader-1's Introduction

stm32-bootloader

UART bootloader for STM32 microcontroller.

Table of content

Introduction

A bootloader for STM32F100 (STM32VLDISCOVERY board) [1] with UART and Xmodem protocol [2][3]. The software is created with Atollic trueSTUDIO and the drivers are generated with CubeMX.

Main features:

  • UART & Xmodem protocol
  • CRC16 checksum
  • Supports 128 and 1024 bytes data length

How it works

Overall

The bootloader was developed for STM32VLDISCOVERY board, the only extra thing needed is an USB-UART module on PA10 (RX) and PA9 (TX) pins.


Figure 1. Pinout of the system.

After start-up, the system sends a welcome message through UART and checks if the user button is pressed. If it is pressed, then it stays in booatloader mode, turns on the green (PC9) LED and waits for a new binary file. If the button isn't pressed, then it jumps to the user application.


Figure 2. Brief overview of the workflow of the system.

The Xmodem protocol is clearly explained in the references.

Memory map

The bootloader starts from 0x08000000 and the user application starts from 0x08008000.


Figure 3. The organization of the memory.

Code

Every important code is inside the Src and Inc folders. main.c holds the button check, xmodem.c and .h hold the communication portocol, uart.c and .h are a layer between Xmodem and the generated HAL code, flash.c and .h have the writing/erasing/jumping related functions. Everything else is provided by ST. The code is fully commented, so it should be easy to understand.

How to use it

Embedded

To use the bootloader, just get the softwares mentioned in the Introduction and flash it.

I included an example binary file called "blinky_test.bin" in the root folder. It blinks the blue (PC8) LED on the board. To make your own binary, you have to modify the memory location in the linker script (STM32F100RB_FLASH.ld):

FLASH (rx)      : ORIGIN = 0x8008000,

And the vector table offset in system_stm32f1xx.c

#define VECT_TAB_OFFSET  0x00008000U

Last step is you have to generate a *.bin file:

arm-atollic-eabi-objcopy -O binary "input.elf" "output.bin"

PC

To update the firmware, you need a terminal software, that supports Xmodem. I recommend PuTTY [4] or Tera Term [5].

Configure them in the following way:

  • Baud rate: 115200
  • Data bits: 8
  • Parity: none
  • Stop bits: 1

In PuTTY: select Files Transfer >> Xmodem (or Xmodem 1K) >> Send and then open the binary file.


Figure 4. PuTTY.

In Tera Term: select File >> Transfer >> Xmodem >> Send and then open the binary file.
Figure 5. Tera Term.

In case everything was fine, then the output should be the same:

================================
UART Bootloader
https://github.com/ferenc-nemeth
================================

Please send a new binary file with Xmodem protocol to update the firmware.
CCCCCCC
Firmware updated!
Jumping to user application...

Porting

I included the *.ioc file, so the drivers can be regenerated for any ST microntroller (if it has similar memory structure). If you have a non-ST microntroller, then the xmodem protocol can be reused, but nothing else.

References

[1] ST - Discovery kit with STM32F100RB MCU
[2] Xmodem protocol with CRC
[3] Chuck Forsberg - XMODEM/YMODEM PROTOCOL REFERENCE
[4] PuTTY
[5] Tera Term

stm32-bootloader-1's People

Contributors

ferenc-nemeth avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.