Skip to content

Commit

Permalink
support for RPi5
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Sep 18, 2024
1 parent 9c78f90 commit b02dfa7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
29 changes: 25 additions & 4 deletions rosbot_utils/rosbot_utils/flash-firmware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3

# Copyright 2024 Husarion sp. z o.o.
#
Expand All @@ -25,6 +25,20 @@
import gpiod
import sh

def get_raspberry_pi_model():
try:
with open("/proc/cpuinfo", "r") as f:
for line in f:
if "Model" in line:
model_info = line.split(":")[1].strip()
if "Raspberry Pi 4" in model_info:
return "Raspberry Pi 4"
elif "Raspberry Pi 5" in model_info:
return "Raspberry Pi 5"
else:
return "Unknown Raspberry Pi Model"
except FileNotFoundError:
return "Not a Raspberry Pi"

class FirmwareFlasher:
def __init__(self, sys_arch, binary_file):
Expand Down Expand Up @@ -53,12 +67,19 @@ def __init__(self, sys_arch, binary_file):

elif self.sys_arch == "aarch64":
# Setups RPi pins
print("Device: RPi\n")
model = get_raspberry_pi_model()
print(f"Device: {model}\n")
self.serial_port = "/dev/ttyAMA0"
gpio_chip = "/dev/gpiochip0"

if model == "Raspberry Pi 4":
gpio_chip = "/dev/gpiochip0"
elif model == "Raspberry Pi 5":
gpio_chip = "/dev/gpiochip4"
else:
gpio_chip = "/dev/gpiochip0" # Default or error handling

boot0_pin_no = 17
reset_pin_no = 18

else:
print("Unknown device...")

Expand Down
13 changes: 7 additions & 6 deletions rosbot_utils/rosbot_utils/flash_firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import subprocess
import os
import sys
import argparse
import signal
import glob
import requests
import os
import signal
import subprocess
import sys

import ament_index_python.packages
import requests

# Global variable to hold the subprocess reference
subproc = None
Expand Down Expand Up @@ -115,4 +116,4 @@ def main(args=None):


if __name__ == "__main__":
main()
main()

0 comments on commit b02dfa7

Please sign in to comment.