Giter Site home page Giter Site logo

jkreucher / blackpillfromscratch Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 229 KB

Black Pill STM32F411 drivers from scratch. Without HAL or CMSIS.

License: GNU General Public License v3.0

Makefile 3.92% C 42.85% Assembly 53.24%
blackpill stm32f411 cortex-m4 st-link black-pill from-scratch

blackpillfromscratch's Introduction

Black Pill from Scratch

Copyright 2022 Jannik Kreucher

Table Of Contents

Project

The goal of this project is to write all hardware drivers for the Blackpill from scratch without using HAL or even CMSIS libraries. I started this project to get to know the STM32F411. I uploaded my project files for everyone to use. Maybe this helps you in any shape or form. I am by no means a professional programmer so take any code in this project with a grain of salt.

Setting Up the Development Environment

Install ST-Link tools

sudo apt install stlink-tools

Download arm-gcc from their website. Then extract the archieve

sudo tar xjf gcc-arm-none-eabi-<version>-x86_64-linux.tar.bz2 -C /usr/share/

Link the executables

sudo ln -s /usr/share/gcc-arm-none-eabi-<version>-x86_64-linux/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc
sudo ln -s /usr/share/gcc-arm-none-eabi-<version>-x86_64-linux/bin/arm-none-eabi-g++ /usr/bin/arm-none-eabi-g++
sudo ln -s /usr/share/gcc-arm-none-eabi-<version>-x86_64-linux/bin/arm-none-eabi-gdb /usr/bin/arm-none-eabi-gdb
sudo ln -s /usr/share/gcc-arm-none-eabi-<version>-x86_64-linux/bin/arm-none-eabi-size /usr/bin/arm-none-eabi-size
sudo ln -s /usr/share/gcc-arm-none-eabi-<version>-x86_64-linux/bin/arm-none-eabi-objcopy /usr/bin/arm-none-eabi-objcopy

When running arm-none-eabi-gdb you might encounter problems with missing libraries. This can be fixed by linking to a newer version

sudo apt install libncurses-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
sudo ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5

Install OpenOCD

git clone https://github.com/openocd-org/openocd.git
./bootstrap
./configure
make
sudo make install

Erase Flash Memory

Now try to erase the flash memory of your Black Pill. The board might boot into the protected bootloader.

st-flash erase

When you encounter an error hold down both the NRST and the BOOT0 button. Then release the NRST button while the other one is still pressed. Finally release the BOOT0 button as well and try to erase the flash memory again.

Setting Up VS Code

Install the plugin Cortex-Debug by marus25. Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.

ext install marus25.cortex-debug

Now open a project folder with VS Code and try debugging on your Blackpill.

cd 0-led/
code .

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.