I got tired of having to manually cd to path/to/fusee-launcher, manually run fusee-launcher, and type my password everytime I wanted to fire off a payload to my switch. I wanted my computer to just automatically fire the payload as soon as I plugged my RCM switch in via USB, so I put together a dumb little script & udev rule to do this for me. It has been working great for the last few days. I don't know if this would be terribly useful for many people (maybe some of the raspberry pi projects could use this?) but I figured I'd share anyway!
udev rule
The udev rule lives in /ect/udev/rules.d/10-switch.rules and contains the following:
Replace "/PATH/TO" with the absolute path to your .swith_payload script - an example script is below. I just use ~/.switch_payload.
This will only execute the .switch_payload script when the switch is in RCM mode since the manufacturer & product values are different when it isn't in RCM mode.
Once the rule is in place, be sure to reload your udev rules with:
Payload script
I then have a script located at ~/.switch_payload (you can adjust the location of this script by changing the 'RUN' value in the udev rule) with multiple payloads so that I can select which payload gets fired without having to edit the udev rule:
Replace "/PATH/TO" with the path to your fusee-launcher, payloads, and painless-linux directories, set the script to be executable (chmod +x .switch_payload), and you're as good as gold! To switch to a different payload, comment the currently active payload (switchblade IPL in the above example) and uncomment a different payload. If you want to temporarily disable this, just comment all of the payloads.
As a note, fusee-launcher.py used to require you to pass the '--relocator' flag with a path to the 'intermezzo.bin' file when executing it from a different working directory. I submitted a PR to fusee-launcher - which was just recently merged, woo! - to look for 'intermezzo.bin' in the same working directory as fusee-launcher.py if the '--relocator' flag is not passed. That can make our fusee-launcher.py commands much shorter!
udev rule
The udev rule lives in /ect/udev/rules.d/10-switch.rules and contains the following:
Code:
SUBSYSTEMS=="usb", ATTRS{manufacturer}=="NVIDIA Corp.", ATTRS{product}=="APX", RUN+="/PATH/TO/.switch_payload"
Replace "/PATH/TO" with the absolute path to your .swith_payload script - an example script is below. I just use ~/.switch_payload.
This will only execute the .switch_payload script when the switch is in RCM mode since the manufacturer & product values are different when it isn't in RCM mode.
Once the rule is in place, be sure to reload your udev rules with:
Code:
udevadm control --reload-rules
Payload script
I then have a script located at ~/.switch_payload (you can adjust the location of this script by changing the 'RUN' value in the udev rule) with multiple payloads so that I can select which payload gets fired without having to edit the udev rule:
Code:
#!/bin/bash
# switchblade
python3 /PATH/TO/fusee-launcher/fusee-launcher.py /PATH/TO/payloads/switchblade_ipl_2018-05-20.bin
# hekate 4.x
# python3 /PATH/TO/fusee-launcher/fusee-launcher.py /PATH/TO/payloads/hekate_ipl_4.x_2018-05-10.bin
# biskeydump
# python3 /PATH/TO/fusee-launcher/fusee-launcher.py /PATH/TO/payloads/biskeydump.bin
# painless-linux
# /PATH/TO/painless-linux/shofel2/shofel2.py /PATH/TO/painless-linux/payloads/cbfs.bin /PATH/TO/painless-linux/payloads/coreboot.rom
Replace "/PATH/TO" with the path to your fusee-launcher, payloads, and painless-linux directories, set the script to be executable (chmod +x .switch_payload), and you're as good as gold! To switch to a different payload, comment the currently active payload (switchblade IPL in the above example) and uncomment a different payload. If you want to temporarily disable this, just comment all of the payloads.
As a note, fusee-launcher.py used to require you to pass the '--relocator' flag with a path to the 'intermezzo.bin' file when executing it from a different working directory. I submitted a PR to fusee-launcher - which was just recently merged, woo! - to look for 'intermezzo.bin' in the same working directory as fusee-launcher.py if the '--relocator' flag is not passed. That can make our fusee-launcher.py commands much shorter!
Last edited by yesimnathan,
