Skip to content

Conversation

@tnias
Copy link

@tnias tnias commented Jan 10, 2026

Having free test binaries for things like rizinorg/rizin#3747 may be useful.

% readelf -A arm/elf/pico_serprog.elf
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "6S-M"
  Tag_CPU_arch: v6S-M
  Tag_CPU_arch_profile: Microcontroller
  Tag_THUMB_ISA_use: Thumb-1
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: small

To the best of my knowledge the binary is licensed: GPL-3.0-only AND MIT AND BSD-3-Clause

Steps to reproduce the binary (click spoiler)

On a x86_64-linux system with nix write this code in a default.nix.

{
  lib,
  stdenvNoCC,
  fetchFromGitea,
  cmake,
  gcc-arm-embedded,
  picotool,
  python3,
  pico-sdk,
}:

let
  # We need tinyusb and it is one of pico-sdk's submodules.
  pico-sdk-with-submodules = pico-sdk.override { withSubmodules = true; };
in
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "pico-serprog";
  version = "20250212";

  src = fetchFromGitea {
    domain = "codeberg.org";
    owner = "Riku_V";
    repo = "pico-serprog";
    tag = finalAttrs.version;
    hash = "sha256-1Fo4g57vk4u5u1Q+Yrx/co8CE8/NxZDJdwIFQ+51f1Q=";
  };

  nativeBuildInputs = [
    cmake
    gcc-arm-embedded
    picotool
    python3
  ];

  buildInputs = [
    pico-sdk-with-submodules
  ];

  cmakeFlags = [
    "-DPICO_SDK_PATH=${pico-sdk-with-submodules}/lib/pico-sdk"
    "-DPICO_COMPILER=pico_arm_cortex_m0plus_gcc"
    "-DCMAKE_C_COMPILER=${gcc-arm-embedded}/bin/arm-none-eabi-gcc"
    "-DCMAKE_CXX_COMPILER=${gcc-arm-embedded}/bin/arm-none-eabi-g++"
  ];

  dontFixup = true;

  installPhase = ''
    install -m 0444 -D -t $out/etc/udev/rules.d $src/99-serprog.rules
    install -m 0444 -D -t $out/share/pico-serprog pico_serprog.uf2
    install -m 0444 -D -t $out/share/pico-serprog pico_serprog.elf
    install -m 0444 -D -t $out/share/doc/pico-serprog $src/pinout.png
  '';

  meta = {
    description = "Raspberry Pi Pico serprog";
    homepage = "https://codeberg.org/Riku_V/pico-serprog";
    license = with lib.licenses; [
      cc-by-sa-40
      gpl3Only
      mit
    ];
    platforms = lib.platforms.all;
  };
})

Then build it with this command.

nix-build --expr '
with import (builtins.fetchTarball {
  url = "https://github.com/nixos/nixpkgs/archive/5912c1772a44e31bf1c63c0390b90501e5026886.tar.gz";
  sha256 = "1kk6dr0d9hpc0pfsb24dpvn7cnvwnyc9fnj1pbkd55phyzfdsg9j";
}) {};
callPackage ./default.nix {}
'

% readelf -A arm/elf/pico_serprog.elf                                                                                                                                                                                                                       pico_serprog
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "6S-M"
  Tag_CPU_arch: v6S-M
  Tag_CPU_arch_profile: Microcontroller
  Tag_THUMB_ISA_use: Thumb-1
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: small
@Rot127
Copy link
Member

Rot127 commented Jan 11, 2026

For what PR is this?

@tnias
Copy link
Author

tnias commented Jan 11, 2026

A while back I looked at and rebased the patchset of the abandoned PR that attempted to solve rizinorg/rizin#3747. But at the time I have not seen relevant cortex-m elfs in rizin-testbins.

So this is not really for an already existing PR. I just thought it would be useful to have for potential future PRs. :)

Are new binaries only accepted when they are accompanied with a PR on the main repo? Should I close this?

@wargio
Copy link
Member

wargio commented Jan 11, 2026

it would be nice to have this info outputted by iH

@Rot127
Copy link
Member

Rot127 commented Jan 11, 2026

Are new binaries only accepted when they are accompanied with a PR on the main repo?

We have no policy or something about this, but I'd say yes. The repo is already huge. No need to add unused binaries.

As @wargio suggested. You can open a PR and just print the info with iH to see if it sets the correct cpu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants