Skip to content

Instantly share code, notes, and snippets.

@9names
9names / build_release_commit.sh
Last active October 1, 2023 02:16
bflb-mcu-tool git rebuild
#!/bin/bash
export GIT_AUTHOR_NAME="""bouffalolab"""
export GIT_AUTHOR_EMAIL="""[email protected]"""
export GIT_AUTHOR_DATE="$2"
export GIT_COMMITTER_NAME="""bouffalolab"""
export GIT_COMMITTER_EMAIL="""[email protected]"""
export GIT_COMMITTER_DATE="$2"
rm "*" -rf
tar -xvf ../bflb-mcu-tool-$1.tar.gz --strip-components=1
@9names
9names / pico_display_pack_testing.rs
Last active September 12, 2022 10:25
A quick test of the pico display pack with the mipidsi crate
//! # Pimoroni Display Pack Example
#![no_std]
#![no_main]
use embedded_hal::digital::v2::InputPin;
// The macro for our start-up function
use rp_pico::entry;
// Time handling traits
@9names
9names / do_not_run.sh
Created July 3, 2022 12:26
Set up Rust and try to build probe-rs under qemu
sudo qemu-debootstrap --arch=mipsel --keyring /usr/share/keyrings/debian-archive-keyring.gpg \
--variant=buildd --exclude=debfoster unstable debian-mipsel http://ftp.debian.org/debian
sudo apt install qemu binfmt-support qemu-user-static
sudo cp /usr/bin/qemu-mipsel-static debian-mipsel/usr/bin/
cd debian-mipsel
for f in dev dev/pts sys proc run ; do sudo mount --bind /$f ./$f ; done
sudo chroot .
apt update
apt install dialog locales
@9names
9names / hsprobe_swd_decode
Last active April 6, 2022 11:52
comparing SWD output from hsprobe and dappermime with probe-rs
swd-1: LINERESET
swd-1: JTAG->SWD
swd-1: LINERESET
swd-1: IDCODE
swd-1: OK
swd-1: 0x2ba01477
swd-1: W ABORT
swd-1: OK
swd-1: 0x0000001e
swd-1: W SELECT
@9names
9names / pico_usb_serial_logger.rs
Last active April 4, 2022 12:34
Pico USB serial abstraction
//! # Pico USB Serial - with format, panics.
//! Should move into it's own crate.
//!
//! heavily inspired by https://github.com/eterevsky/rp2040-blink/blob/main/src/main.rs and https://github.com/mvirkkunen/rtt-target
#![no_std]
#![no_main]
use core::cell::RefCell;
use core::fmt::Write;
{
"arch": "riscv32",
"cpu": "generic-rv32",
"data-layout": "e-m:e-p:32:32-i64:64-n32-S128",
"eh-frame-header": false,
"emit-debug-gdb-scripts": false,
"executables": true,
"features": "+m,+a",
"linker": "rust-lld",
"linker-flavor": "ld.lld",
@9names
9names / segger_rtt_pipe.rs
Created February 24, 2022 12:01
Just a toy program to pipe segger-rtt output to stdout for using with defmt-print
use std::net::{TcpStream};
use std::io::{Read, Write};
use memchr::memmem;
// Update this to match what your tool says.
const END_OF_SEGGER_RTT_HEADER: &[u8; 28] = b"Process: JLinkGDBServerCLExe";
fn main() {
match TcpStream::connect("localhost:19021") {
Ok(mut stream) => {
@9names
9names / uart.rs
Created January 5, 2022 00:33
rp2040 uart0 + uart 1
//! # UART Example
//!
//! This application demonstrates how to use the UART Driver to talk to a serial
//! connection.
//!
//! It may need to be adapted to your particular board layout and/or pin
//! assignment.
//!
//! See the `Cargo.toml` file for Copyright and licence details.
uart1_pins_split-join_flow-control.rs: configuring pins as TX/RX/CTS/RTS, split and join functions, UART HW flow control
uart0_split_flow-control.rs: test UART HW flow control on UART0 but uses split TX/RX for all operations
flow_control_debugging.rs: attempting to work out if we could unblock UART after errors (unsuccessfully)
I also tested without the CTS/RTS pins enabled, and that worked fine (HW flow control is currently always enabled)
@9names
9names / spi.rs
Created December 18, 2021 12:12
RP2040 DMA: SPI tx on one peripheral, rx on the second
//! Serial Peripheral Interface (SPI)
//!
//! See [Chapter 4 Section 4](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details
//!
//! ## Usage
//!
//! ```no_run
//! use embedded_hal::spi::MODE_0;
//! use embedded_time::rate::*;
//! use rp2040_hal::{spi::Spi, gpio::{Pins, FunctionSpi}, pac, sio::Sio};