Anduril 2 feature change suggestions

thanks for the handholding… I pasted this into terminal:

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

terminal replied:
==> Checking for sudo access (which may request your password)…
Password:
Sorry, try again.

it asked for a password, and I tried admin, Admin, and Jonathan… they all failed…

what password do I need?

It’s your local user’s password, the same one you login with, necessary to install some of the dependencies (to verify it’s you, the owner/admin of the computer). sudo is a program that’s used to grant admin (root) access to a command to do things like install software or update configs.

ok, password worked
terminal did some stuff and ended with:

==> Downloading and installing Homebrew…
Checking out files: 100% (3044/3044), done.
HEAD is now at 512d7c961 Merge pull request #15311 from dduugg/prune-activesupport
fatal: Couldn’t find remote ref refs/heads/master
Error: Fetching /usr/local/Homebrew/Library/Taps/osx-cross/homebrew-avr failed!
Updated 1 tap (homebrew/core).
Failed during: /usr/local/bin/brew update --force --quiet

what next?

That looks like a problem with the actual repository (failed to download the dependencies). I’m not a macos expert (more of a Linux person), but it might just be a transient error, could try rerunning brew install avrdude - if not, try brew tap osx-cross/avr first (source here)

I did that earlier, took about an hour and the result was:

Last 15 lines from /Users/jonathan/Library/Logs/Homebrew/confuse/02.make:

TOTAL: 24

PASS: 22

SKIP: 0

XFAIL: 0

FAIL: 2

XPASS: 0

ERROR: 0

============================================================================
See tests/test-suite.log
Please report to Issues · libconfuse/libconfuse · GitHub

make[3]: *** [test-suite.log] Error 1
make[2]: *** [check-TESTS] Error 2
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1

Do not report this issue to Homebrew/brew or Homebrew/homebrew-core!

Error: You are using macOS 10.12.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew’s GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew’s discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

I then tested the command avrdude and got this:

-bash: avrdude: command not found

so afaict, avrdude is not an option on my computer…

fwiw, I do have pymcuprog working…
and I have downloaded the tarball to the gchart repository

what next?

Ok, I’m definitely going to have to defer to someone who knows macOS then. zflasher might be the easier option if you have an android phone available. If I find some time I might try and get avrdude working in Docker, but I have no idea how to handle USB devices there on mac.

I only have iPhone 8

fwiw, I already have the ability to reflash firmware from a Hex file

what I want to learn is how to modify a Hex file with the features Im suggesting…

so far I have relied on other people to build the custom Hex files for me… which works fine, except I have to ask every time I think of a new feature change

I dont understand how to edit the Hex files I have…

but thanks for all your time trying to help…

in any case, this is purely an academic exercise… it confirms what Ive been claiming, that my iMac is not compatible with the tutorial that TK linked me to… no biggie… I already have Hex files with the features Ive mentioned above, in post #3

In terms of editing the hex file, you’re essentially editing raw machine code. It’s possible (in the same way it’s possible to dig a tunnel with a toothpick), but needlessly complicated and way above my skillset, as well as having a much higher chance of introducing bugs or breaking something, as compilers do weird tricks sometimes to save space by packing the code as optimally as possible. You’ll want to be editing the actual source code instead, that compiles into the hex file.

You can browse the source and view files here: https://bazaar.launchpad.net/~toykeeper/flashlight-firmware/anduril2/files/head:/ToyKeeper/spaghetti-monster

If you want to make a local copy, you can run bzr branch lp:~toykeeper/flashlight-firmware/anduril2 to browse it locally, personally I hate launchpad’s web UI and find it a lot easier to look through locally with my editor of choice. The code is fairly well documented and self-explanatory, you probably won’t need to change any of the FSM code for most things (ToyKeeper/spaghetti-monster/), look at ToyKeeper/spaghetti-monster/anduril for most of the relevant states and functions. There is some developer-oriented documentation about how it all works at a low level in spaghetti-monster/spaghetti-monster.txt.

Building firmware doesn’t have a simple guide AFAIK, but in general, if you have the toolchain for it installed (beyond my ability to offer support for mac) you’d run build-all.sh with your build target, e.g. ToyKeeper/spaghetti-monster/anduril/build-all.sh wurkkos-ts10 (running it with none specified will build for all models), or if you can use Docker, you can use a docker image that already has all the dependencies installed and should run on any Windows/Linux/Mac (Intel or M1, no PowerPC support :joy:) system with Docker (e.g. docker run --rm -t -v $(pwd -P):/src siterelenby/anduril-builder:latest wurkkos-ts10).

Also, here’s my anduril fork if you were looking for some ideas for different hacks etc. or just to get an idea of example changes: GitHub - SiteRelEnby/anduril2: modded anduril2

1 Thank

thanks for all the info…

I do not know how to go about editing source code… that is actually why I asked for help… TK linked me to a tutorial, above, but that is just a cluster of confusion and failures to install avrdude, which does not work on my computer

at this point I have a Tarball from the gchart repository, and I also have hex files from there, for example for TS10, that work fine when I use Terminal to install them on the light, using pymcuprog instead of avrdude

What I dont understand is how to build a Hex that has the modifications mentioned in post #3

regarding the tutorial that TK linked, skipping past all the other avr installs, the instructions say:

“Once extracted, open the ~toykeeper/flashlight-firmware/ folder. I then like to move the
fsm folder to my user profile, to make it something like /Users/oweban/fsm/”

when I look inside the folder I got from the gchart repository, called ~gabe, I do not see an fsm folder

what next?

Well, you’ll need to learn at least basic C (the language) to make modifications past just changing default settings within the flags that exist, then you modify the source code and use a compiler to turn it into the hex file that contains specific instructions the light’s MCU understands (which operates at a much lower level than a language like C, with C you write in human-readable form, then the compiler turns it into machine code that operates on levels like "compare these two values, and swap them around if this one is larger). I haven’t fully read it yet (working/trading) but this looks like a good overview I found from a quick search: AVR Assembler 101 - CodeProject

IMO C is a very easy/logical language, perhaps not the best to learn as a first general purpose language compared to something like Python or Go (although it was my first, heh) as there are various gotchas around stuff like memory management, but in the case of anduril, FSM (the underlying framework) handles all that for you.

I’ll probably make a post when I get something generally-usable for making custom builds, but not sure when that will be at the moment.

Will double check specifically when I’m not afk, but the fsm code is under spaghetti-monster/ or ToyKeeper/spaghetti-monster/ depending on the version.

thanks for all your efforts to educate me…

I remain grateful to the people that know how to build Hex files, and have been generous in providing the ones Ive shared in post #3 above.

No problem. Made a quick edit to my previous comment about assembler that hopefully makes it a bit clearer why we usually don’t directly edit hex files.

Taken from assembly.html, here’s an example: In C, you would write:

int f (int n) {
  if (n < 2) return n;
  return f (n - 1) * n;
}

Which should be understandable even to a non-programmer with a little thought (main non-obvious thing might be that n is an expected input that will always be an integer, and the program outputs another integer when complete), but in assembler, it would be this (non-relevant parts omitted):

.text
        .align 4
.globl A
        .type    A,@function
A:
        pushl   %ebp
        movl    %esp, %ebp
        movl    $1, X
        movl    $1, %eax
        .p2align 2
.L5:
        testl   %eax, %eax
        jne     .L5
        popl    %ebp
        ret
.Lfe1:
        .size    A,.Lfe1-A
        .comm   X,4,4
        .ident  "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-81)"

Which is a lot less intuitive to read/edit. People do do it, especially with code where performance is critical, as assembler by hand can be more efficient than using a compiler, but it’s also difficult and messy to write, then even harder to work out what someone else was doing, or what you were trying to do 18 months ago :wink:

If you want to go a little deeper, found https://www.cs.cmu.edu/~guna/15-123S11/Lectures/Lecture27.pdf which seems reasonable at a quick glance.

I believe you… :wink:
I dont know what application I need to read and edit the precompiled code that ends up in the Hex file

and I dont know what file Im supposed to edit… yet

nor do I know how to compile the edited file into a finished hex…

is there a tutorial for this stage of my education? :wink:
Im sorry to impose on so much of your time, as clearly Im clueless… I do not have a programming background…

A hex editor. Some popular text editors can also handle hex, while some examples of dedicated ones are HxD and ImHex.

That’s what build.sh in the anduril repo is for - it handles running a compiler called gcc (the de facto standard C compiler, a lot of common software uses it behind the scenes) on the code which produces the hex file as output. You don’t need to go a deep dive into compilers to make a build as TK already built some good tooling around it than handles running gcc and converting the program output into the hex file that the MCU can understand (which is the assembler code, in a compressed format that flashing utilities can understand). If you’re interested for curiosity’s sake, I can probably find some resources but it’s the kind of thing I learned so long ago that overall I have no idea how to introduce to a beginner :laughing: - I’d suggest a general tutorial on learning to program in C as that will introduce compilers as a concept in a gradual and understandable way. Learning to program for the first time with C is like learning to weld with a stick welder instead of going straight to a TIG, or learning to drive an unsynchronised manual before going to an automatic - there are easier ways, but learning the basics first will give you a much better understanding of good practice and improve overall results later with something easier.

If you’re just looking to change some defaults, you can edit the header file that contains configuration for a specific light, e.g. here’s the header file for the dual channel D4S: https://bazaar.launchpad.net/~toykeeper/flashlight-firmware/anduril2/view/head:/ToyKeeper/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h - you can change stuff like default settings there, but if you wanted to do something that the code doesn’t already allow, you need to edit the C code itself - e.g. to disable factory reset while simple UI is active, you’d want to edit the C code here: ~toykeeper/flashlight-firmware/anduril2 : contents of ToyKeeper/spaghetti-monster/anduril/off-mode.c at revision 659

If you’re just looking to do header file changes, I’ve compiled a list of useful settings for custom builds here: GitHub - SiteRelEnby/anduril2: modded anduril2

Here’s an example of a heavily customised build for one of my lights, using custom features: https://github.com/SiteRelEnby/anduril2/blob/main/spaghetti-monster/anduril/cfg-siterelenby-emisar-d4sv2-tintramp-fet.h

3 Thanks

thanks! now were getting down to the stuff TK keeps posting about…

really appreciate the roadmap… will take a moment to digest all the new info

That’s just for my fork, stuff I plan to work on in the future; it’s not relevant to base anduril. If you’re looking for what’s coming from TK, the LT1S Pro thread is a good place.

when I open that I see a very complicated window of info I dont understand

I dont see an app download button… would be clueless how to open and use that hex editor…

this whole hex file thing is quite a deep and multi branching worm hole… for me… I want to give up on learning to build my own hex files

Im ever grateful to the people that have built the hex files I have learned to install (that was a loooong process too)… poor me… lol

my hardware is so old, it takes 5 minutes to reflash my TS10… I dont mind, but Im told it takes 3 seconds on an Android phone… youza!

thanks for all the help, expanding my horizons

There’s really no need to concern yourself with the hex file itself as it’s a lot easier to change the code that’s used to generate it - if you want to make changes to anduril, look at the header files I gave as examples and the list of variables you can change in them. If you want to implement new functionality, that’s when you need to learn at least some C (simple changes can probably be done just by reading what’s there and applying the same pattern).

yes, I did look

that is what led me to ask what to use as an editor, and how to find which file I need to open

atm Im lost and overwhelmed by trying to choose a hex editor… this may seem infantile from your perspective… and if you need a break from bottlefeeding me… Im ready to give up… this whole process just seems overwhelming to me…

No problem. For editing the header or source files (.c and .h), any text editor will do, e.g. TextEdit on mac, although if you’re looking to actually do significant code changes, you’ll probably want an editor with syntax highlighting and similar features, but that’s completely beyond my knowledge what exists/is any good for mac as I just use vim everywhere, which is very powerful but not in any way user-friendly ;).