diff --git a/bsp/renesas/ebf_qi_min_6m5/SConstruct b/bsp/renesas/ebf_qi_min_6m5/SConstruct index 67511e3048..57d44892c4 100644 --- a/bsp/renesas/ebf_qi_min_6m5/SConstruct +++ b/bsp/renesas/ebf_qi_min_6m5/SConstruct @@ -45,6 +45,10 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ebf_qi_min_6m5/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c b/bsp/renesas/ebf_qi_min_6m5/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c index d135ed0762..54124cbcf3 100644 --- a/bsp/renesas/ebf_qi_min_6m5/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c +++ b/bsp/renesas/ebf_qi_min_6m5/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c @@ -64,7 +64,12 @@ void Reset_Handler (void) SystemInit(); /* Call user application. */ +#ifdef __ARMCC_VERSION main(); +#elif defined(__GNUC__) + extern int entry(void); + entry(); +#endif while (1) { diff --git a/bsp/renesas/ebf_qi_min_6m5/startup_check.py b/bsp/renesas/ebf_qi_min_6m5/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ebf_qi_min_6m5/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check() diff --git a/bsp/renesas/ra2l1-cpk/SConstruct b/bsp/renesas/ra2l1-cpk/SConstruct index 67511e3048..91489ff888 100644 --- a/bsp/renesas/ra2l1-cpk/SConstruct +++ b/bsp/renesas/ra2l1-cpk/SConstruct @@ -45,6 +45,12 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + +RegisterPreBuildingAction(startup_check) + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ra2l1-cpk/startup_check.py b/bsp/renesas/ra2l1-cpk/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ra2l1-cpk/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check() diff --git a/bsp/renesas/ra4m2-eco/SConstruct b/bsp/renesas/ra4m2-eco/SConstruct index 67511e3048..57d44892c4 100644 --- a/bsp/renesas/ra4m2-eco/SConstruct +++ b/bsp/renesas/ra4m2-eco/SConstruct @@ -45,6 +45,10 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ra4m2-eco/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c b/bsp/renesas/ra4m2-eco/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c index 7fc7f0a514..a031aae886 100644 --- a/bsp/renesas/ra4m2-eco/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c +++ b/bsp/renesas/ra4m2-eco/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c @@ -64,7 +64,12 @@ void Reset_Handler (void) SystemInit(); /* Call user application. */ +#ifdef __ARMCC_VERSION main(); +#elif defined(__GNUC__) + extern int entry(void); + entry(); +#endif while (1) { diff --git a/bsp/renesas/ra4m2-eco/startup_check.py b/bsp/renesas/ra4m2-eco/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ra4m2-eco/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check() diff --git a/bsp/renesas/ra6m3-ek/SConstruct b/bsp/renesas/ra6m3-ek/SConstruct index 67511e3048..91489ff888 100644 --- a/bsp/renesas/ra6m3-ek/SConstruct +++ b/bsp/renesas/ra6m3-ek/SConstruct @@ -45,6 +45,12 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + +RegisterPreBuildingAction(startup_check) + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ra6m3-ek/startup_check.py b/bsp/renesas/ra6m3-ek/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ra6m3-ek/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check() diff --git a/bsp/renesas/ra6m3-hmi-board/SConstruct b/bsp/renesas/ra6m3-hmi-board/SConstruct index 67511e3048..91489ff888 100644 --- a/bsp/renesas/ra6m3-hmi-board/SConstruct +++ b/bsp/renesas/ra6m3-hmi-board/SConstruct @@ -45,6 +45,12 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + +RegisterPreBuildingAction(startup_check) + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ra6m3-hmi-board/startup_check.py b/bsp/renesas/ra6m3-hmi-board/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ra6m3-hmi-board/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check() diff --git a/bsp/renesas/ra6m4-cpk/SConstruct b/bsp/renesas/ra6m4-cpk/SConstruct index 67511e3048..91489ff888 100644 --- a/bsp/renesas/ra6m4-cpk/SConstruct +++ b/bsp/renesas/ra6m4-cpk/SConstruct @@ -45,6 +45,12 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + +RegisterPreBuildingAction(startup_check) + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ra6m4-cpk/startup_check.py b/bsp/renesas/ra6m4-cpk/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ra6m4-cpk/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check() diff --git a/bsp/renesas/ra6m4-iot/SConstruct b/bsp/renesas/ra6m4-iot/SConstruct index 67511e3048..91489ff888 100644 --- a/bsp/renesas/ra6m4-iot/SConstruct +++ b/bsp/renesas/ra6m4-iot/SConstruct @@ -45,6 +45,12 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + +RegisterPreBuildingAction(startup_check) + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ra6m4-iot/startup_check.py b/bsp/renesas/ra6m4-iot/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ra6m4-iot/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check() diff --git a/bsp/renesas/ra8d1-ek/SConstruct b/bsp/renesas/ra8d1-ek/SConstruct index 67511e3048..91489ff888 100644 --- a/bsp/renesas/ra8d1-ek/SConstruct +++ b/bsp/renesas/ra8d1-ek/SConstruct @@ -45,6 +45,12 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + +RegisterPreBuildingAction(startup_check) + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ra8d1-ek/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c b/bsp/renesas/ra8d1-ek/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c index d135ed0762..54124cbcf3 100644 --- a/bsp/renesas/ra8d1-ek/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c +++ b/bsp/renesas/ra8d1-ek/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c @@ -64,7 +64,12 @@ void Reset_Handler (void) SystemInit(); /* Call user application. */ +#ifdef __ARMCC_VERSION main(); +#elif defined(__GNUC__) + extern int entry(void); + entry(); +#endif while (1) { diff --git a/bsp/renesas/ra8d1-ek/rtconfig.py b/bsp/renesas/ra8d1-ek/rtconfig.py index 51a4958c83..a87ae8d064 100644 --- a/bsp/renesas/ra8d1-ek/rtconfig.py +++ b/bsp/renesas/ra8d1-ek/rtconfig.py @@ -4,7 +4,7 @@ import sys # toolchains options ARCH='arm' CPU='cortex-m85' -CROSS_TOOL='keil' +CROSS_TOOL='gcc' if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') diff --git a/bsp/renesas/ra8d1-ek/startup_check.py b/bsp/renesas/ra8d1-ek/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ra8d1-ek/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check() diff --git a/bsp/renesas/ra8m1-ek/SConstruct b/bsp/renesas/ra8m1-ek/SConstruct index 67511e3048..91489ff888 100644 --- a/bsp/renesas/ra8m1-ek/SConstruct +++ b/bsp/renesas/ra8m1-ek/SConstruct @@ -45,6 +45,12 @@ Export('SDK_LIB') rtconfig.BSP_LIBRARY_TYPE = None +def startup_check(): + import startup_check + startup_check.startup_check() + +RegisterPreBuildingAction(startup_check) + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) diff --git a/bsp/renesas/ra8m1-ek/rtconfig.py b/bsp/renesas/ra8m1-ek/rtconfig.py index 51a4958c83..a87ae8d064 100644 --- a/bsp/renesas/ra8m1-ek/rtconfig.py +++ b/bsp/renesas/ra8m1-ek/rtconfig.py @@ -4,7 +4,7 @@ import sys # toolchains options ARCH='arm' CPU='cortex-m85' -CROSS_TOOL='keil' +CROSS_TOOL='gcc' if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') diff --git a/bsp/renesas/ra8m1-ek/startup_check.py b/bsp/renesas/ra8m1-ek/startup_check.py new file mode 100644 index 0000000000..6eeae016f5 --- /dev/null +++ b/bsp/renesas/ra8m1-ek/startup_check.py @@ -0,0 +1,62 @@ +import subprocess +import sys + +def check_git_exists(): + try: + # Check if Git is installed + subprocess.call(["git", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except OSError: + return False + return True + +def install_git(): + if sys.version_info[0] == 2: + version_cmd = subprocess.call + else: + version_cmd = subprocess.run + + # Install Git based on the operating system type + system = sys.platform.lower() + if "linux" in system: + version_cmd(["sudo", "apt-get", "install", "git"]) + elif "darwin" in system: + version_cmd(["brew", "install", "git"]) + elif "win" in system: + print("Please manually install Git and ensure it is added to the system PATH.") + sys.exit(1) + +def check_file_changes(filepath): + # Use Git to check the file status + result = subprocess.Popen(["git", "status", "--porcelain", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, _ = result.communicate() + + # Return True if the file has changes + return bool(out.decode('utf-8')) + +def revert_to_original(filepath): + # Use Git to revert the file to its original state + subprocess.call(["git", "checkout", filepath]) + +def startup_check(): + file_path = "ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c" + python_executable = 'python' if sys.version_info[0] == 2 else 'python3' + + # Check if Git is installed, if not, try to install it + if not check_git_exists(): + print("Git not detected, attempting to install...") + install_git() + + # Check if Git is installed after the installation attempt + if not check_git_exists(): + print("Git installation failed. Please manually install Git and add it to the system PATH.") + sys.exit(1) + + # Check if the file has changes + if check_file_changes(file_path): + # If changes are detected, revert the file to its original state + revert_to_original(file_path) + # else: + # print "File {file_path} is unchanged." + +if __name__ == "__main__": + startup_check()