Skip to content

Commit

Permalink
scons: get_programmer(): refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Mar 5, 2024
1 parent 05ce3f6 commit d7c9263
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 19 deletions.
31 changes: 26 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,41 @@
"cwd": "${workspaceFolder}/test-examples/Alhambra-II/ledon"
},
{
"name": "Apio upload",
"name": "Upload (Alhambra II)",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"args": ["upload"],
"console": "internalConsole",
"justMyCode": true,
//-- Change to the folder with the example to test
//-- Testing the Alhanbra-II board
"cwd": "${workspaceFolder}/test-examples/Alhambra-II/ledon"
},
{
"name": "Upload (TinyFPGA)",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"args": ["upload"],
"console": "internalConsole",
"justMyCode": true,
//-- Change to the folder with the example to test

//-- Testing the TinyFPGA board
"cwd": "${workspaceFolder}/test-examples/TinyFPGA-BX/01-LED-ON"
},
{
"name": "Upload (Blackice)",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"args": ["upload"],
"console": "internalConsole",
"justMyCode": true,
//-- Change to the folder with the example to test
//-- Testing the Blackice
"cwd": "${workspaceFolder}/test-examples/BlackIce/01-LEDs-buttons"

//-- Testing the Alhanbra-II board
//"cwd": "${workspaceFolder}/test-examples/Alhambra-II/ledon"
}
},
]
}
36 changes: 22 additions & 14 deletions apio/managers/scons.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@ def get_programmer(self, board: str, prog: dict) -> str:
# -- is not installed, an exception is raised
self.check_pip_packages(board_data)

# -- Special case for the TinyFPGA on MACOS platforms
# -- TinyFPGA BX board is not detected in MacOS HighSierra
if "tinyprog" in board_data:

# -- Get the platform
platform = util.get_systype()

# -- darwin / darwin_arm64 platforms
if "darwin" in platform or "darwin_arm64" in platform:

# In this case the serial check is ignored
# This is the command line to execute for uploading the
# circuit
return "tinyprog --libusb --program"

# -- Serialize programmer command
# -- Get a string with the command line to execute
# -- BUT! it is a TEMPLATE string, with some parameters
Expand Down Expand Up @@ -305,29 +320,22 @@ def get_programmer(self, board: str, prog: dict) -> str:
# -- If not, an exception is raised
self.check_usb(board, board_data)

# -- TODO: FIXME!
# -- Get the FTDI index of the connected board
ftdi_id = self.get_ftdi_id(board, board_data, prog[FTDI_ID])
programmer = programmer.replace("${FTDI_ID}", ftdi_id)

# TinyFPGA BX board is not detected in MacOS HighSierra
if "tinyprog" in board_data and "darwin" in util.get_systype():
# In this case the serial check is ignored
return "tinyprog --libusb --program"

# TinyFPGA BX board is not detected in MacOS HighSierra
if "tinyprog" in board_data and "darwin_arm64" in util.get_systype():
# In this case the serial check is ignored
return "tinyprog --libusb --program"

# -- DEBUG
print("-------> DEBUG: Traza 2")
# -- Place the value in the command string
programmer = programmer.replace("${FTDI_ID}", ftdi_id)

# Replace Serial port
# -- TODO: Refactor and test this part
if "${SERIAL_PORT}" in programmer:
self.check_usb(board, board_data)
print("-------> DEBUG: Traza 3")
device = self.get_serial_port(board, board_data, prog[SERIAL_PORT])
programmer = programmer.replace("${SERIAL_PORT}", device)

# -- Return the Command to execute for uploading the circuit
# -- to the given board
return programmer

@staticmethod
Expand Down

0 comments on commit d7c9263

Please sign in to comment.