Skip to content

Instantly share code, notes, and snippets.

@JamesHagerman
JamesHagerman / CMakeLists.txt
Created October 4, 2016 07:43 — forked from eugene-babichenko/CMakeLists.txt
CMakeLists.txt and toolchain file for building STM32 HAL-based projects generated with STM32CubeMX with arm-none-eabi-gcc. STM32CubeMX settings. Toolchain: SW4STM32. ☑ Generate under root.
set(PRJ_NAME CLion_STM_LED)
set(MCU_FAMILY STM32F1xx)
set(MCU_LINE STM32F103xB)
set(MCU_LINKER_SCRIPT STM32F103RBTx_FLASH.ld)
cmake_minimum_required(VERSION 3.6)
project(${PRJ_NAME} C ASM)
add_definitions(-D${MCU_LINE})

How to get firmware onto mutable modules

I had the best luck with the Black Magic Probe and gdb.

Install compiler

First install the arm compiler:

sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
@JamesHagerman
JamesHagerman / setTermColors.sh
Last active November 22, 2016 09:18
Just the script I use to set colors on the gnome-terminal
#!/bin/bash
#gconftool-2 --set /apps/gnome-terminal/profiles/Default/use_theme_background --type bool false
#gconftool-2 --set /apps/gnome-terminal/profiles/Default/use_theme_colors --type bool false
#gconftool-2 -s -t string /apps/gnome-terminal/profiles/Default/background_color '#41414d4d3d3d'
#gconftool-2 -s -t string /apps/gnome-terminal/profiles/Default/foreground_color '#d3d3cfcfcdcd'
#echo 'setting funk colors'
#gconftool-2 -s -t string /apps/gnome-terminal/profiles/Default/palette '#3c3c2d2d2626:#f7f700007c7c:#7c7cf7f70000:#f7f77c7c0000:#00007c7cf7f7:#7c7c0000f7f7:#0000f7f77c7c:#b6b6a7a79f9f:#7c7c6d6d6565:#ffff5454a9a9:#a9a9ffff5454:#ffffa9a95454:#5454a9a9ffff:#a9a95454ffff:#5454ffffa9a9:#f4f4e5e5dddd'
# Oops! We have moved on to dconf:
@JamesHagerman
JamesHagerman / skull.zsh-theme
Created December 6, 2016 19:45
A slight modification of the cloud theme
if [[ -z $ZSH_THEME_CLOUD_PREFIX ]]; then
ZSH_THEME_CLOUD_PREFIX='☠'
fi
PROMPT='%{$fg_bold[yellow]%}$ZSH_THEME_CLOUD_PREFIX %{$fg_bold[green]%}%p %{$fg[green]%}%c %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}] %{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}]"
@JamesHagerman
JamesHagerman / .bashrc-modifications
Created December 6, 2016 19:46
LDAP/AD oh-my-zsh init and colors setup
# My edits:
alias ip='ip -c'
# Set some colors up:
# Oops! We have moved on to dconf:
echo "setting FUNK colors"
# This should be "Default"
profile_id=b1dcc9dd-5262-4d8d-a863-c897e6d979b9
#profile_id=$(gsettings get org.gnome.Terminal.ProfilesList default)
dconf write /org/gnome/terminal/legacy/profiles:/:$profile_id/bold-color-same-as-fg "true"
@JamesHagerman
JamesHagerman / conversion notes.md
Last active May 17, 2017 23:04
Convert Github style Markdown to PDF in one line (using docker and pandoc)
@JamesHagerman
JamesHagerman / LayerOne2017BadgeNotes.md
Last active June 11, 2017 02:00
LayerOne 2017 Badge Linux walkthrough

LayerOne 2017 Badge Notes

The badge for LayerOne 2017 runs on an STM32 ARM embedded microprocessor. Most of the notes about this board can be dug out of CharlieX's page on Hackaday.io: https://hackaday.io/project/13262-layerone-2017

Known bugs

Yes, there are a few. Word on the street is that when the original code is compiled under Linux, the USB doesn't enumerate! There is a fix for this... but then the SD card doesn't work correctly

PLEASE let me know if you figure out what could be causing this!

@JamesHagerman
JamesHagerman / start-forwarding.sh
Created June 4, 2017 21:48
Simple script to enable ip forwarding for basic routing
#!/bin/bash
logger "Telling kernel to turn on ipv4 ip_forwarding"
echo 1 > /proc/sys/net/ipv4/ip_forward
logger "Done. Setting up iptables rules to allow FORWARDING"
DOWNSTREAM=wlan0 # wlan0 is client network (running hostapd)
UPSTREAM=eth0 # eth0 is upstream network (internet)
# Allow IP Masquerading (NAT) of packets from clients (downstream) to upstream network (internet)
@JamesHagerman
JamesHagerman / HowToHostapd.md
Last active April 7, 2024 12:50
Just some notes on getting wlan0->eth0 configured with hostapd and dnsmasq to turn a box into a router.

How to setup hostapd based router

Install some tools you'll need with: apt-get install -y hostapd dnsmasq wireless-tools iw wvdial

Note that some wifi cards just plain don't work with hostapd. Sorry.

Setup your network interfaces correctly

This is done in /etc/network/interfaces:

@JamesHagerman
JamesHagerman / DisassembleARMBinaryInR2.md
Last active March 30, 2023 06:43
Some quick notes on disassembling 16bit ARM (STM32F4) code using radare2

Disassembling 1bitsy examples using radare2

Note that because radare2 uses Capstone to disassemble ARM code, there are issues with the disassembly. arm-none-eabi-objdump -d compiledbinary.elf actually does a better job in some cases. For example, msr isn't decompiled correctly...

First, you have to either strip the default ELF binaries the default Makefiles build when you run make OR you need to just compile .bin files using something like:

make binaryname.bin