Skip to content

Instantly share code, notes, and snippets.

View tstellanova's full-sized avatar
💭
growing excited

Todd Stellanova tstellanova

💭
growing excited
  • N6FFF
  • Berkeley, CA
View GitHub Profile
@tstellanova
tstellanova / itm_en.rs
Created March 13, 2020 21:30 — forked from richardeoin/itm_en.rs
Enable ITM output over the SWO pin for STM32H7 parts. The output is manchester coded and can be received by a debugger - eg. blackmagic probe
/// Enables ITM
///
/// If swo_enable is true, then the SWO output pin will be enabled
fn low_level_itm(dbgmcu: &stm32::DBGMCU, swo_enable: bool) {
// ARMv7-M DEMCR: Set TRCENA. Enables DWT and ITM units
unsafe { *(0xE000_EDFC as *mut u32) |= 1 << 24 };
// Ensure debug blocks are clocked before interacting with them
dbgmcu.cr.modify(|_, w| {
w.d1dbgcken()
@tstellanova
tstellanova / erase_stm32_cmd.md
Created February 14, 2020 16:57
Erase all flash on stm32 chips using STCubeProgrammer command line

This command can be used when the stm32 chip has become nonresponsive. This typically presents when the stlink programmer is responding to commands but can't connect to the MCU under test in order to program it.

Warning: This will wipe EVERYTHING from the MCU.

~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin$ ./STM32_Programmer.sh -c port=swd INDEX=0 mode=UR -e ALL
@tstellanova
tstellanova / itm_swo_enable.rs
Last active February 7, 2020 16:30
Force enabling arm cortex ITM / SWO from Rust
use core::ptr;
fn swo_init(cp: &mut Peripherals) {
const SYSCLOCK_FREQ_HZ: u32 = 64000000;
//TODO use locks.sysclk().0 instead ?
const SWO_FREQ_HZ: u32 = 2000000; // 2_000_000; // let swo_freq = 2_000_000;
unsafe {
// enable TPIU and ITM
@tstellanova
tstellanova / enable_swo_stm32h7x.md
Created February 7, 2020 02:28
Enable SWO for stm32h7 eval board
@tstellanova
tstellanova / STM32H7_SWO_Output_Solution.py
Created February 7, 2020 00:27 — forked from mofosyne/STM32H7_SWO_Output_Solution.py
This generates codes that enables SWO output for STM32H7 and was tested on NUCLEO-H743ZI2. This is required because stm32h7 changed the registers that OpenOCD expects for SWO output.
#!/usr/bin/env python3
"""
# STM32H7 SWO Output Solution
Author: Brian Khuu 2020
Main Copy: https://gist.github.com/mofosyne/178ad947fdff0f357eb0e03a42bcef5c
This generates codes that enables SWO output for STM32H7 and was tested on NUCLEO-H743ZI2.
This is required because stm32h7 changed the registers that OpenOCD expects for SWO output.
Best to use 400Mhz, tried lower... but had issue with getting stable uart output
@tstellanova
tstellanova / p52_ubuntu_18_setup.md
Created October 8, 2019 02:50
setup lenovo thinkpad p52 with ubuntu 18

For UEFI boot, press e when it says “Start Linux/Ubuntu”. Find the line that says quiet splash Right after that, add nomodeset and then press F10 to boot (or whatever key it instructs you to press). It should boot Linux now with no graphics drivers, which appears to be the problem.

@tstellanova
tstellanova / ubuntu_px4_dev_setup.sh
Last active October 1, 2019 17:48
Script for setting up ubuntu development environment for PX4
#!/bin/bash
# allow ssh to this box
sudo apt-get install openssh-server
# Gazebo simulator
sudo apt-get install protobuf-compiler libeigen3-dev libopencv-dev -y
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
## Setup keys
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
@tstellanova
tstellanova / mac_px4_homebrew_notes.txt
Created September 29, 2019 23:55
notes from Mac px4 homebrew installation
Warning: osrf/simulation/gazebo9 dependency gcc was built with a different C++ standard
library (libstdc++ from clang). This may cause problems at runtime.
🍺 /usr/local/Cellar/gazebo9/9.11.0: 1,260 files, 126.5MB
==> Installing px4/px4/px4-sim
==> Downloading https://raw.githubusercontent.com/PX4/Firmware/master/Tools/px4.py
Already downloaded: /Users/todd/Library/Caches/Homebrew/downloads/7be7daca52fab83c40ed326bdcf732c0060cdc0b9d97e0d94f1e71856982d00b--px4.py
==> PX4 Simulation Installed
🍺 /usr/local/Cellar/px4-sim/1.6.5.0: 3 files, 10.1KB, built in 5 seconds
==> Caveats
@tstellanova
tstellanova / lrzsz_install_mac.md
Created September 3, 2019 13:41
Install command line tools `sz` and `rz` on Mac OSX
brew install lrzsz
@tstellanova
tstellanova / install_zeroconf_debian.sh
Created August 30, 2019 19:03
Install zeroconf on debian
apt-get install avahi-daemon avahi-discover libnss-mdns