Skip to content

Instantly share code, notes, and snippets.

@brandonros
brandonros / stm32f407g-disc1-dfu-mode.md
Last active January 9, 2024 10:35
STM32F407G-DISC1/STM32F4DISCOVERY DFU mode
  1. Take every jumper off except JP1. Take both jumpers off CN3. Take the jumpers JP2 and JP3 off from the bottom of the board.
  2. Put a jumper between BOOT0 and VDD.
  3. Connect with a wire PA9 to 5V.
  4. Connect the device using the micro USB port, not the mini-USB port.
  5. sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D build/Example_Project.bin
  6. Unplug the device.
  7. Disconnect the BOOT0 jumper.
  8. Plug the device in.
  • PB5 - CAN2_RX
  • PB6 - CAN2_TX
@brandonros
brandonros / dockcross-kernel.sh
Created June 1, 2020 03:59
Compile Linux kernel with dockcross
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.15.tar.xz
tar -xf linux-5.6.15.tar.xz
cd linux-5.6.15
docker run --rm dockcross/linux-x64 > ./dockcross
chmod +x dockcross
./dockcross make defconfig
./dockcross make -j 4

Compiling kernel

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.7.tar.xz
tar -xf linux-5.7.tar.xz
cd linux-5.7
docker run --rm dockcross/linux-x64 > ./dockcross
chmod +x ./dockcross
./dockcross make defconfig
./dockcross make -j $(sysctl -n hw.ncpu)
@brandonros
brandonros / parse-tricore-instructions.js
Created June 17, 2020 02:25
Parse TriCore instructions from hex in node.js
const parseInstructions = (input) => {
const instructions = []
let i = 0
while (i < input.length) {
const instructionLow = input.readUInt16LE(i)
const is16Bit = (instructionLow & 0x01) === 0x00
if (is16Bit) {
instructions.push(instructionLow)
i += 2
} else {
use crate::{masks};
pub enum Format {
// 16 bit formats
SB,
SBC,
SBR,
SBRN,
SC,
SLR,

./configure --target-list=tricore-softmmu &amp;&amp; make -j 4 &amp;&amp; ./tricore-softmmu/qemu-system-tricore --machine tricore_testboard -nographic -D /tmp/qemu.log -d in_asm,out_asm,op,cpu,exec,mmu -singlestep

Brandons-MacBook-Pro-2:can-utils-rs brandonros$ cargo build
Compiling can-utils-rs v0.0.1 (/Users/brandonros/Desktop/can-utils-rs)
error[E0382]: use of moved value: `frame`
--> src/main.rs:57:65
|
55 | let mut handler = move |frame: Vec<u8>| {
| ----- move occurs because `frame` has type `std::vec::Vec<u8>`, which does not implement the `Copy` trait
56 | for websocket in websockets.lock().unwrap().iter() {
57 | let binary_frame = tungstenite::Message::Binary(frame);
| ^^^^^ value moved here, in previous iteration of loop
@brandonros
brandonros / windows-server-2019.md
Last active July 24, 2020 15:54
Set up a new Windows Server 2019 install from scratch for node.js native module compiling

1. Enable SSH

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType "Automatic"
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force

2. Install Choco package manager

@brandonros
brandonros / gist:9086f20135233b1fcf10212cc0830d31
Created July 31, 2020 03:53
OBD-II data/parameter identifier groups to log for ECU tuning
1. general (rpm, speed, gear, time)
2. engine load (actual + target)
3. torque (actual + target)
4. accelerator pedal angle
5. throttle body angle
6. boost (actual + target)
7. wastegate duty cycle
8. fuel trims (short term)
9. fuel pressure (low + high)
10. ignition timing (all cylinders + average)