greatscottgadgets / apollo

microcontroller-based FPGA / JTAG programmer
BSD 3-Clause "New" or "Revised" License
61 stars 29 forks source link

modules: switch to tinyusb 0.14.0 #13

Closed cyber-murmel closed 1 year ago

cyber-murmel commented 1 year ago

Switch to TinyUSB 0.14.0

updates lib/tinyusb submodule to 0.14.0 and adapts board source files accordingly firmware for daisho couldn't be build to to missing bsp in TinyUSB

current TinyUSB submodule makes building for ESP32-S2 quite hard

cyber-murmel commented 1 year ago

I have only built for other targets to check that the build process didn't break, since I don't have any Cynthion device. The PR is a back port of another branch where I added other devices.

What is the correct APOLLO_BOARD for Cynthion? I'd guess luna_d11.


This is the current output size for me

   text    data     bss     dec     hex filename
  12244      72    3240   15556    3cc4 _build/luna_d11/firmware.elf
$ ls -l firmware/_build/luna_d11/firmware.bin 
-rwxr-xr-x 1 marble users 12316 Apr  1 23:03 firmware/_build/luna_d11/firmware.bin

Apparently the compiler already optimizes for least space, since -Os doesn't change anything and all other optimization options make the linker fail to fit it in rom. Also removing -g didn't make a difference... Does it fail for you every time regardless of optimization and debug flags?


May I ask what gcc vesion you use? Mine is

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (Arm GNU Toolchain 11.3.Rel1) 11.3.1 20220712
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Gutting the heartbeat_task reduces the binary size by 260 bytes. I don't know if that is enough reduction to fit in the flash with the boot loader. If yes, maybe it could be optimized, but I also don't see how, since it's already quite minimal. But that's the only non-vital part of the code base I could identify and the rest of the code is nice and slick t.b.h. - so not much to remove there.

cyber-murmel commented 1 year ago

If you want a reproducible build environment, this is my current shell.nix

{ pkgs ? import
    (builtins.fetchGit {
      name = "nixos-22.11-2023_04_01";
      url = "https://github.com/nixos/nixpkgs/";
      ref = "refs/heads/nixos-22.11";
      rev = "a575c243c23e2851b78c00e9fa245232926ec32f";
    })
    { }
}:

with pkgs;

mkShell {
  buildInputs = [
    gcc
    gcc-arm-embedded
    gnumake
    dfu-util
    udisks
    python3Packages.pyserial
  ];
}
mossmann commented 1 year ago

@cyber-murmel Thank you so much for looking into this further! We've managed to make size improvements in #17 and by reducing the size of Saturn-V from 4 KiB to 2 KiB (https://github.com/greatscottgadgets/saturn-v/pull/3), so we plan to merge your tinyusb update (or its equivalent) and probably proceed further to tinyusb 0.15.0.