Skip to content

Commit

Permalink
reset MCU only in ROSbot 2R and 2 PRO
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Aug 28, 2023
1 parent dc8e07e commit c8f6680
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
48 changes: 48 additions & 0 deletions robots/_rosbot_2_reset_mcu/reset-mcu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/python3
import sh
import time
from periphery import GPIO

def exit_bootloader_mode(boot0_pin_number, reset_pin_number):
boot0_pin = GPIO(boot0_pin_number, "out")
reset_pin = GPIO(reset_pin_number, "out")
boot0_pin.write(False)
reset_pin.write(True)
time.sleep(0.2)
reset_pin.write(False)
time.sleep(0.2)


def main():
sys_arch = sh.uname('-m')
print(f"System architecture: {sys_arch}")

boot0_pin_number = None
reset_pin_number = None

if sys_arch.stdout == b'armv7l\n':
# Setups ThinkerBoard pins
print("Device: ThinkerBoard\n")
boot0_pin_number = 164
reset_pin_number = 184

elif sys_arch.stdout == b'x86_64\n':
# Setups UpBoard pins
print("Device: UpBoard\n")
boot0_pin_number = 17
reset_pin_number = 18

elif sys_arch.stdout == b'aarch64\n':
# Setups RPi pins
print("Device: RPi\n")
boot0_pin_number = 17
reset_pin_number = 18

else:
raise Exception("Unknown device...")

exit_bootloader_mode(boot0_pin_number, reset_pin_number)


if __name__ == "__main__":
main()
10 changes: 10 additions & 0 deletions robots/_rosbot_2_reset_mcu/reset-mcu.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Reset MCU in ROSbot 2R / 2 PRO on startup

[Service]
Type=simple
ExecStart=/usr/local/sbin/reset-mcu.py
RemainAfterExit=no

[Install]
WantedBy=multi-user.target
8 changes: 7 additions & 1 deletion robots/rosbot_2_pro/custom_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

# If a particular robot requires any extra custom configuration steps, they should be included in this file.

echo "no additional custom configuration for ROSbot 2R"
echo "enable reset MCU service"

cp ../_rosbot_2_reset_mcu/reset-mcu.py /usr/local/sbin/reset-mcu.py
cp ../_rosbot_2_reset_mcu/reset-mcu.service /etc/systemd/system/reset-mcu.service

systemctl enable reset-mcu.service
systemctl start reset-mcu.service
8 changes: 7 additions & 1 deletion robots/rosbot_2r/custom_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

# If a particular robot requires any extra custom configuration steps, they should be included in this file.

echo "no additional custom configuration for ROSbot 2R"
echo "enable reset MCU service"

cp ../_rosbot_2_reset_mcu/reset-mcu.py /usr/local/sbin/reset-mcu.py
cp ../_rosbot_2_reset_mcu/reset-mcu.service /etc/systemd/system/reset-mcu.service

systemctl enable reset-mcu.service
systemctl start reset-mcu.service

0 comments on commit c8f6680

Please sign in to comment.