Skip to content

Instantly share code, notes, and snippets.

@TimMcMahon
Last active February 1, 2023 03:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimMcMahon/22d7a3895988b627187bde3cf344d126 to your computer and use it in GitHub Desktop.
Save TimMcMahon/22d7a3895988b627187bde3cf344d126 to your computer and use it in GitHub Desktop.
anduril_ubuntu_instructions

Ubuntu 18.04

These are personal notes for flashing an Emisar D4V2 Ti with a KR4 nofet driver using E21A emitters.
anduril.noctigon-kr4-nofet.hex will be used.

Caution:

  1. You could brick your D4V2 if the pogo pin adapter from intl-outdoors isn't aligned properly. I bricked my D4V2 Sand.
  2. Don't install the wrong firmware (e.g. anduril.emisar-d4v2.hex on a D4V2 Ti with a KR4 nofet driver) or you may destroy the emitters.
  1. Install avrdude and other required stuff
sudo apt-get install flex byacc bison gcc libusb-dev libc6-dev
sudo apt-get install gcc-avr avr-libc binutils-avr
sudo apt-get install avrdude avrdude-doc
  1. Get the latest firmware
    Go to https://code.launchpad.net/~toykeeper/flashlight-firmware/fsm
    Under Recent Revisions, click the latest version
    Click download tarball

  2. Extract the firmware to ~/fsm

cd Downloads
tar xzvf \~toykeeper_flashlight-firmware_fsm-r490.tgz 
cd \~toykeeper/flashlight-firmware/
mv fsm ~/.
  1. Make hex files
cd ~/fsm/ToyKeeper/spaghetti-monster/anduril
make
  1. Test connection
    Connect usbasp device with pogo pins to pads on the head of the flashlight.
    And then run:
sudo avrdude -c usbasp -p t1634 -n
  1. Flash the firmware
    Connect usbasp device with pogo pins to pads on the head of the flashlight.
    And then run while holding pins for 15-30 seconds:
sudo avrdude -c usbasp -p t1634 -u -Uflash:w:anduril.noctigon-kr4-nofet.hex 
@TimMcMahon
Copy link
Author

TimMcMahon commented Jul 6, 2022

Instructions for building and flashing Anduril 2 on Ubuntu 22.04

1. Install avrdude and other required stuff

Build and install avrdude 7:
https://budgetlightforum.com/comment/1873274#comment-1873274

https://github.com/avrdudes/avrdude/wiki/Building-AVRDUDE-for-Linux

gcc g++ git cmake flex bison libelf libusb libhidapi libftdi1
sudo apt-get install build-essential git cmake flex bison libelf-dev libusb-dev libhidapi-dev libftdi1-dev
git clone https://github.com/avrdudes/avrdude
cd avrdude
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -B build_linux
cmake --build build_linux
sudo cmake --build build_linux --target install

The adapter by gchart works with easily with a Wurkkos TS10, Sofirn SP10 Pro, SC21 Pro, SC31 Pro (newer models).

Pinout:
https://budgetlightforum.com/comment/1867118#comment-1867118
https://budgetlightforum.com/comment/1872395#comment-1872395

Add attiny1616 support for avrdude:

Try this specific version:
http://packs.download.atmel.com/Atmel.ATtiny_DFP.1.10.348.atpack

  - Download the Atmel ATtiny Series Device Support pack:
    http://packs.download.atmel.com/

  - Unzip the pack somewhere on your build computer

  - Set ATTINY_DFP=/path/to/where/you/unzipped/the/pack
    (either in your shell, or in this repo's bin/build.sh script)

    export ATTINY_DFP=$HOME/src/torches/atmel/attiny-dfp

  - Make sure you're using gcc-avr 1:5.4.0+Atmel3.6.2 or newer.
    3.6.1 will not work.  It gives errors like:
    /usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: address 0x80381e of anduril.elf section `.data' is not within region `data'
    This requires debian/bullseye or newer; buster has 3.6.1.

I.e. Add the export to ~/.bashrc and then source ~/.bashrc

2. Get the latest firmware from gabe's branch of Anduril 2

cd ~/projects
sudo apt install bzr
bzr branch lp:~gabe/flashlight-firmware/anduril2 gabe-anduril2

3. Configure Anduril 2 for your particular torch

There are multiple cfg files.
Find one appropriate for your torch and edit it if you want to change the defaults or make changes.

cd ~/projects/gabe-anduril2/ToyKeeper/spaghetti-monster/anduril

4. Generate the hex files by making Anduril 2

cd ~/projects/gabe-anduril2/ToyKeeper/spaghetti-monster/anduril
make

5. Test the connection

Figure out what port the USB adapter is on:

sudo dmesg
usb 1-1.3: cp210x converter now attached to ttyUSB0

The adapter is on /dev/ttyUSB0

Connect the 3 pins from gchart's adapter to a TS10 or SP10 Pro and test the connection:

sudo avrdude -p t1634 -c serialupdi -n -P /dev/ttyUSB0

6. Flash the firmware

Connect USB adapter with pogo pins to pads on the head of the flashlight.
Pay attention to the pad order. It could be R, -, + or +, -, R or something else.
Run one of the following:

Flash the TS10:

sudo avrdude -p attiny1616 -c serialupdi -P /dev/ttyUSB0 -Uflash:w:anduril.wurkkos-ts10.hex

Flash the SP10 Pro:

sudo avrdude -p attiny1616 -c serialupdi -P /dev/ttyUSB0  -Uflash:w:anduril.sofirn-sp10-pro.hex

@TimMcMahon
Copy link
Author

~/projects/gabe-anduril2/ToyKeeper/spaghetti-monster/anduril $ sudo avrdude -p attiny1616 -c serialupdi -P /dev/ttyUSB0 -Uflash:w:anduril.wurkkos-ts10.hex

avrdude: UPDI link initialization OK
avrdude: Device is in SLEEP mode
avrdude: NVM type 0: 16-bit, page oriented write
avrdude: Entering NVM programming mode
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9421 (probably t1616)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file anduril.wurkkos-ts10.hex auto detected as Intel Hex
avrdude: reading input file anduril.wurkkos-ts10.hex for flash
avrdude: writing 9562 bytes flash ...

Writing | ################################################## | 100% 2.56s

avrdude: 9562 bytes of flash written
avrdude: verifying flash memory against anduril.wurkkos-ts10.hex

Reading | ################################################## | 100% 1.35s

avrdude: 9562 bytes of flash verified
avrdude: Leaving NVM programming mode

avrdude done.  Thank you.

~/projects/gabe-anduril2/ToyKeeper/spaghetti-monster/anduril $ sudo avrdude -p attiny1616 -c serialupdi -P /dev/ttyUSB0  -Uflash:w:anduril.sofirn-sp10-pro.hex

avrdude: UPDI link initialization OK
avrdude: Device is in SLEEP mode
avrdude: NVM type 0: 16-bit, page oriented write
avrdude: Entering NVM programming mode
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9421 (probably t1616)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file anduril.sofirn-sp10-pro.hex auto detected as Intel Hex
avrdude: reading input file anduril.sofirn-sp10-pro.hex for flash
avrdude: writing 9278 bytes flash ...

Writing | ################################################## | 100% 2.47s

avrdude: 9278 bytes of flash written
avrdude: verifying flash memory against anduril.sofirn-sp10-pro.hex

Reading | ################################################## | 100% 1.31s

avrdude: 9278 bytes of flash verified
avrdude: Leaving NVM programming mode

avrdude done.  Thank you.

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