Anduril 2 feature change suggestions

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 ;).

Forget about editing hex files, completely.

The simplest way to compile Anduril on a windows or Mac machine is to use SammysHP’s docker image, but Docker isn’t compatible with Mac 10.12, maybe older versions are but somehow I have trouble finding that information.

My advice to you regarding compiling Anduril remains the same since we last chatted, which is to install Ubuntu in a virtual machine, with Virtual Box for example which is free and compatible with Mac OS 10.12, you’ll find many guides on how to do that by searching "install ubuntu virtualbox”

Then it’s simple :

And it’ll build all the models, exept the T1616 ones, there are instructions in the error message but you can ask about it if you have trouble with it when you’re there

2 Thanks

thanks
I thought the lights Im talking about, SC21 pro, SP10 Pro, and TS10, are 1616 models, no?

so I downloaded a tarball from the gchart repository

so… if I follow your instructions… where do I go to change (I use the words edit a hex file, but you call it edit an Anduril Header?) the file that tells my light to use D10 style ramping, and disable 13H in simple mode… for example?

in any case, I thought we already know avrdude wont run on my machine, so I use pymcuprog…

can I compile without avrdude?

Hex files and headers are different. The hex is the output after the source code has been compiled into a form the MCU can understand, while the header file is the base configuration that is used to initialise settings and determine what functionality should be included in the output hex file. For all intents and purposes, consider the hex file uneditable - you want to edit the source code and/or header file to implement your changes, and will get an updated hex file as the output.

Right, then there are instructions in the ReadMe from the error message on how to make it work with T1616, you need to download a file , unzip it and point to it in another file, but worry about it when you get there.

That’s what brz branch lp:~toykeeper/flashlight-firmware/anduril2 does in the quote.

We edit the .h files (headers, which are just text file that you can open with any text editor), specifically the cfg-flashlightmodel.h files in the anduril folder.
That comes after you’ve done all this and successfully compiled Anduril.

It’s the point of using another machine, a virtual machine, specifically Ubuntu, where things work.

I went to this tutorial
How to install Ubuntu on Mac using VirtualBox

after download and install, when I try to run virtualbox, I get this error message:

“VirtualBox cannot be opened because of a problem.
Check with the developer to make sure VirtualBox works with this version of macOS. You may need to reinstall the application. Be sure to install any available updates for the application and macOS”

what next?

I would suggest to use https://mac.getutm.app/ instead of virtual box, especially if you have an Apple Silicon Mac.
They have ready-to-be-used Ubuntu images that you don’t even need to set up, too.
Much easier to use than Virtual Box

thanks
dowloaded, installed, and when I try to open UTM I get this error:

“You can’t use this version of the application “UTM” with this version of macOS.
You have macOS 10.12.6. The application requires macOS 11.3 or later.”

what next?

Hmm. Looks like MacOS 10.12 is from 2016. At this point, with apple’s relatively quick pace at breaking backwards compatibility, you probably just need a newer OS. Also, looks like 10.12 was EOL in 2019, so I’d definitely recommend upgrading as you aren’t getting security patches.

If you can’t upgrade due to hardware limitations, look into getting a raspberry pi or something like that, which you can run Docker on no problem - it won’t be blazing fast, but anduril is so small that it still only takes a few seconds to compile on my rpis.

Im at the highest firmware upgrade step for this computer hardware… thanks for the Raspberry Pi suggestion… I think Im not that motivated… maybe someday when I get a new computer I will revisit how to compile hex files from edited Anduril header files

I appreciate all your time, maybe it will help someone else with newer hardware, learn how to build their own hex files…

1 Thank

Another option would be spinning up a cloud vm in something like linode. This can be extremely cheap (pennies) since you don’t need much power and you don’t need to keep it up constantly.

1 Thank