Skip to content

Instantly share code, notes, and snippets.

@milesfrain
milesfrain / probe-rs.md
Created December 4, 2023 06:04
probe-rs evaluation

We have a few options for debug. One is to use a combo of openocd and gdb. The other is to use probe-rs's cargo embed.

These examples use this project template for reference: https://github.com/rp-rs/rp2040-project-template

Debugging works best with opt-level = 0 for [profile.dev] in Cargo.toml, otherwise we're limited in where we can set breakpoints, and there is some other unexpected behavior.

openocd and gdb

This requires a debug probe. There are many options, but a simple one is to just flash probe fw onto another rp2040. Note that the fw link there is not the latest release.

@milesfrain
milesfrain / sigrok-logic-analyzer-instructions.md
Last active October 15, 2024 03:30
Logic Analyzer Instructions

Hardware:

Cheapo $5

Search “USB Logic Analyzer 24MHz 8 Channel” on aliexpress.com

Expensive $150

Turns out std::span has some deduction limitations. There's a pending paper proposing a fix which might be applied in C++26. In the meantime, we can use a helper factory function (e.g. as_span below) to enable this missing deduction capability. We could alternatively apply the fix directly to pw::span, but upstreaming will be controversial.

// as_span implementation snipped - view in godbolt link below

template<typename T>
void foo(std::span<const T>);

void test() {
 // Can never deduce foo()
@milesfrain
milesfrain / db.purs
Last active October 17, 2020 23:05 — forked from MrFincher/db.purs
Now compiles (although some additional debug still required), see https://try.ps.ai/?gist=540b36954ee840f8c32a95bfa4324d1f
data Column v = Column String
data Table columnRow = Table {name :: String, columns :: Record columnRow}
data Select tableColumns selectedColumns = Select
(Record tableColumns -> Record selectedColumns)
(Table tableColumns)
data ToStr = ToStr
@milesfrain
milesfrain / uint_assembly.log
Created October 7, 2019 20:58
Int vs UInt Performance
julia> @code_llvm debuginfo=:none runbench_expand(UInt)
define i64 @julia_runbench_expand_17321(%jl_value_t addrspace(10)*) {
top:
br label %L2
L2: ; preds = %L30, %top
%value_phi = phi i64 [ 0, %top ], [ %value_phi6, %L30 ]
%value_phi1 = phi i64 [ 1, %top ], [ %3, %L30 ]
br label %pass
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
[?25l[?25hPkgBenchmark: Running benchmarks...
Activating new environment at `/tmp/jl_80elOh/Project.toml`
Resolving package versions...
Updating `/tmp/jl_80elOh/Project.toml`
[864edb3b] + DataStructures v0.17.0 [`~/temp/DataStructures.jl`]
Updating `/tmp/jl_80elOh/Manifest.toml`
[864edb3b] + DataStructures v0.17.0 [`~/temp/DataStructures.jl`]
[bac558e1] + OrderedCollections v1.1.0
<!-- This configuration file specifies the required security policies
for Bluetooth core daemon to work. -->
<!-- Debian-compatible additions to https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/bluetooth.conf?h=5.49 -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- ../system.conf have denied everything, so we just punch some holes -->
@milesfrain
milesfrain / google_sheet_macro_steps.md
Last active September 25, 2018 17:48
How to create a

Instructions on creating a macro to move a row down by one in google sheets. Or in other words, swap the contents of the row containing the current active cell with the contents of the row below the current active cell.

This macro also supports moving multiple rows of any selected range.

There's a potential glitch if repeating the macro quickly multiple times before the previous iteration completes. It seems that google allows the next iteration to start before the first completes, which can cause an unexpected row to be shifted.

The macro takes about 1 second to execute, which is not ideal. I'm not sure if there are any ways to speed this up.

Tools > Script Editor
@milesfrain
milesfrain / bolt_build_issues.md
Last active May 21, 2018 00:37
bolt build issues

I'm trying to build bolt with the following commands:

meson build
ninja -C build

I'm seeing this error:

ninja: Entering directory `build'