Git Product home page Git Product logo

stm32's Introduction

STM32 Sandbox

This is a sandbox full of stuff/garbage for the STM32, specifically the STM32F4 series.

This repository is currently using:

  • CMSIS v3.01
  • STM32F4xx_StdPeriph_driver v1.0.1

Things to keep in mind if adapting to STM32F1, F2, or F3:

  • You'll need to locate the proper device-specific files (stored in libraries/ST folder).
  • Much of libcpp has been tested with F1 series. Notably, the gpio.h will not work with F2 or F3 processors right now.

Setup of development environment (22.04)

I'm using the 2020-q4-major revision from the official GCC ARM launchpad repository: https://launchpad.net/gcc-arm-embedded

sudo apt-get install gcc-multilib libncurses5:i386

cd ~/bin
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
tar xvfj gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
rm gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
echo 'export PATH=$PATH:~/bin/gcc-arm-none-eabi-10-2020-q4-major/bin:$PATH' >> ~/.bashrc

Installing OpenOCD

sudo apt-get install openocd

Build DSP_Lib (optional)

In the CMSIS directory, you can build the DSP_Lib by running Make. You may need to change the target processor as it is currently M4lf (Cortex M4, little-endians, with floating point).

Connecting to a Target

So far I haven't sorted out why openocd hates me, but the following command works around issues with jimtcl paths:

openocd  -f interface/ftdi/flyswatter2.cfg -f target/stm32f4x.cfg
openocd  -f interface/stlink.cfg -f target/stm32f4x.cfg

Sudo may or may not be neccessary depending on your group configurations. Note: the board/stm32f4discovery.cfg file works well for ST-Link V2 and SWD.

I tend to use gdb to upload code and interact with the JTAG/STM32. The example makefile has a ".gdbinit" target which exports a .gdbinit file that allows you to run arm-none-eabi-gdb from within the project directory, and exposes a "flash" command to upload firmware, and a "reset" command that works around some quirks in either OpenOCD/Flyswatter/Lack-Of-Moon-Alignment:

cd <project>
arm-none-eabi-gdb
> flash

Common Problems

Undefined reference to '__aeabi_f2d', '__aeabi_d2iz', etc

The FPU is only single precision, using doubles cause lots of problems -- if you see an error like this, make sure you are appending 'f' to floats:

// 0.0 doesn't work, 0.0f does.
float val = 0.0f;

stm32's People

Contributors

mikeferguson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stm32's Issues

Build a tablebot

Components

  • Etherbotix, with MD-03 motor driver, Mini-IMU v5
  • 3 Cliff sensors (GP2Y0D805Z0F) on height adjustable bracket
  • Differential drive - QTY2 12v 30:1 200RPM motors
  • LD-06 Lidar
  • AX-12 servo to tilt lidar (mounted on left side to avoid interfering with the lidar cable)
  • 12V, 3Ah battery

Roadmap

  • Verify that laser works at high angle of incidence (just use ROS drivers)
  • Get laser driver working on Etherbotix, just fill in 360 degree polar map, send over ethernet, visualize on desktop
  • Design, 3d print and assemble physical chassis
  • Tune PID for motors, make sure we can travel a set distance
  • Tune odometry, make sure 90 degree turns are good
  • Tune cliff sensors
  • Phase 1A - drive straight until cliff sensors trigger, back up, turn 180, repeat
  • Add debugging data over ethernet: odometry pose estimate
  • Add visualization of debugging data
  • Get debugging data over wifi
  • Selection of phases using IMU
  • Get servo running
  • Phase 1B - put control loop around Y error to keep us more centered on the table
  • Phase 1C - Use laser to detect cliff ahead of time (so we can go faster)
  • Phase 1D - Use laser to detect the width of table and keep robot centered
  • Phase 2A - sweep laser and assemble scan
  • Phase 2B - find block in laser scan
  • Phase 2C - approach block and push off table
  • Phase 3A - find box using level laser
  • Phase 3B - change block target pose so that we can push block to goal even if it is off to side of table
  • Phase 3C - push block into box (behavior is present, but only works well if block is fairly closet to middle of table)
  • Physically rotate laser 180 degrees so that we can segment scans for block detection while moving (currently, discontinuity is in the front center, this would put it in the back). Also requires update to transform code in robot and viewer.

Open Issues

  • Bootloader won't boot after upload - requires a power cycle? Has gone away after fixing LD06 driver.
  • Need to add CRC to LD06 driver
  • Odometry is off - Y axis is inverted (we're fixing this by inverting Y in the struct unpack)
  • TIM12/PWM seems very off - is this actually up-down counting? That would explain the prescalar issue and also why the "40%" PWM drives laser so slow (check on scope if it is actually 40% or 20%) - nope, it checks out at 40% - no idea why we need to output 70% to get the proper rotation speed
  • Won't run without the ethernet cable plugged in

Known Issues

  • Can't receive packets bigger than MTU. They show up in Wireshark (which doesn't process checksums) but doesn't show up in python socket.recv() - still exists but packets are now broken up to be smaller than MTU

IMU values are occasionally corrupted

Moved from mikeferguson/robomagellan#2:

It appears the high byte is updated, then table is read out, then low byte is updated. Need to prevent this. This is particularly bad when crossing 0 as the high byte changes from 00 -> ff and vice versa

Example sequence as seen on computer side:

-26, 249, 29

Actual sequence that should be seen:

-26, -7, 29

Plot:

screenshot from 2014-02-25 00 15 47

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.