Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
run: |
python3 -m pip install --upgrade pip
pip3 install flake8
# Install other dependencies from setup.py
pip3 install .
- name: Lint with flake8
run: |
echo "Linting current directory"
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --max-complexity=12 --max-line-length=120 --statistics
echo "Linting rcar_flash directory"
flake8 ./rcar_flash --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 ./rcar_flash --count --max-complexity=12 --max-line-length=120 --statistics
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,24 @@ commands into MiniMonitor again and again, this tool is for you.
### Initial setup

You need to perform a number of steps to make `rcar_flash` work on
your machine. Basically, you need to clone the repository somewhere on
your PC:
your machine.

Option 1 (preferred installation method):
Install the `rcar_flash` tool as a package using `pipx`:

```
pipx install git+https://github.com/xen-troops/rcar_flash.git
```

This will allow you to run the `rcar_flash` tool directly from the command line.
For example:

```
rcar_flash -h
```

Option 2.
You can to clone the repository somewhere on your PC:

```
# git clone https://github.com/xen-troops/rcar_flash.git
Expand Down
1 change: 1 addition & 0 deletions rcar_flash/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file intentionally left blank
19 changes: 12 additions & 7 deletions rcar_flash.py → rcar_flash/rcar_flash.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import traceback
import time
from string import printable
from importlib.resources import files

logging.basicConfig(level=logging.INFO, format="[%(levelname)s] %(message)s")
log = logging.getLogger(__name__)
Expand All @@ -23,7 +24,7 @@ def main():
'--conf',
help='Name of config file. Default is "rcar_flash.yaml"',
type=argparse.FileType('r'),
default='rcar_flash.yaml')
default=str(files("rcar_flash").joinpath("rcar_flash.yaml")))

subparsers = parser.add_subparsers(required=True, dest="action")

Expand Down Expand Up @@ -87,6 +88,7 @@ def main():
help='List of loaders to flash or "all" to flash all')

args = parser.parse_args()
log.info(f"Using configuration file: {args.conf.name}")

actions = {
"list-loaders": do_list_loaders,
Expand Down Expand Up @@ -222,13 +224,16 @@ def do_flash(conf, args): # noqa: C901
if not args.cpld:
log.info("Please ensure that board is in the serial download mode")
if args.flash_writer == "DEFAULT":
fname = board["flash_writer"]
flash_writer_file_name = board["flash_writer"]
flash_writer_file_path = files("rcar_flash").joinpath(flash_writer_file_name)
if not os.path.exists(flash_writer_file_path):
raise Exception(f"Flash writer file {flash_writer_file_path} does not exist in package resources.")
else:
fname = args.flash_writer
if not os.path.exists(fname):
raise Exception(f"Flash write file {fname} does not exists!")
log.info(f"Sending flash writer file {fname}...")
send_flashwriter(board, fname, conn)
flash_writer_file_path = args.flash_writer
if not os.path.exists(flash_writer_file_path):
raise Exception(f"Flash writer file not found at specified path: {args.flash_writer}")
log.info(f"Sending flash writer file {flash_writer_file_path}...")
send_flashwriter(board, flash_writer_file_path, conn)
if "sup_baud" in board:
# Increase comm speed if SUP command is available
conn_send(conn, "sup\r")
Expand Down
File renamed without changes.
29 changes: 29 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from setuptools import setup, find_packages

setup(
name="rcar_flash",
version="0.1.0",
description="Tool for flashing R-Car boards",
url='https://github.com/xen-troops/rcar_flash',
author='Volodymyr Babchuk',
author_email='volodymyr_babchuk@epam.com',
packages=find_packages(),
package_data={
'rcar_flash': [
'rcar_flash.yaml',
'mot/*',
],
},

install_requires=[
'pyserial',
'PyYAML',
'pyftdi',
],
entry_points={
'console_scripts': [
'rcar_flash=rcar_flash.rcar_flash:main',
],
},
python_requires='>=3.9',
)