Skip to content

scripts: runners: Introduce bflb_mcu_tool runner #89035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2025

Conversation

VynDragon
Copy link
Collaborator

Introduces one of the official flash tools for bouffalolab platforms

Caveat: It does not like a python version above 3.11

@pdgendt
Copy link
Collaborator

pdgendt commented Apr 24, 2025

Is there a HAL that this runner can be moved to?

@VynDragon
Copy link
Collaborator Author

Is there a HAL that this runner can be moved to?

Why would this be in the HAL?

@pdgendt
Copy link
Collaborator

pdgendt commented Apr 24, 2025

Is there a HAL that this runner can be moved to?

Why would this be in the HAL?

If the runner is useless without sources originating from a HAL, it would limit the scope of the runner to that HAL, and reduce the maintenance for Zephyr itself.

@VynDragon
Copy link
Collaborator Author

VynDragon commented Apr 24, 2025

It is not useless without sources originating from the HAL, the runner is installable via pypi and comparable to minichlink or esptool.py.

@VynDragon
Copy link
Collaborator Author

Someone is going to have to explain to me how i content ruff here, it hasn't accepted any of the possible orders.

@pdgendt
Copy link
Collaborator

pdgendt commented Apr 24, 2025

Someone is going to have to explain to me how i content ruff here, it hasn't accepted any of the possible orders.

$ ruff check --fix scripts/west_commands/runners/bflb_mcu_tool.py
$ ruff format scripts/west_commands/runners/bflb_mcu_tool.py

@VynDragon
Copy link
Collaborator Author

VynDragon commented Apr 24, 2025

ruff check --fix scripts/west_commands/runners/bflb_mcu_tool.py

Thank you, that was a incredibly useless error message for what the issue was.

I also disagree with the assessment that there should not be 2 line jumps between imports and the start of the code.

@VynDragon VynDragon force-pushed the bflb_flasher branch 3 times, most recently from 589608c to ec6f36f Compare April 24, 2025 13:48
@pdgendt
Copy link
Collaborator

pdgendt commented Apr 24, 2025

Caveat: It does not like a python version above 3.11

Besides that, if you install the pypi package, it downloads an entire JLink executable + libraries. I doubt this desired/allowed.

$ ls -la .venv/lib/python3.12/site-packages/bflb_mcu_tool/utils/jlink
.rwxr-xr-x 316k pdgendt 24 Apr 16:21 JLink.exe
.rw-r--r--  19M pdgendt 24 Apr 16:21 JLink_x64.dll
.rw-r--r--  18M pdgendt 24 Apr 16:21 JLinkARM.dll
.rw-r--r--  16M pdgendt 24 Apr 16:21 libjlinkarm.dylib

Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting a tentative -1 for now.

@VynDragon
Copy link
Collaborator Author

VynDragon commented Apr 24, 2025

That is neither in the scope of this PR, a problem in this PR, or addressable in this PR.
Best I can do is bring it up to pypi and the vendor.

@carlescufi
Copy link
Member

What pip package exactly is causing the trouble here? I don't see anything added to requirements?

@pdgendt
Copy link
Collaborator

pdgendt commented Apr 25, 2025

What pip package exactly is causing the trouble here? I don't see anything added to requirements?

The package bflb-mic-tool needs to be installed for this runner to work, it's printed as an error if missing,

@carlescufi
Copy link
Member

What pip package exactly is causing the trouble here? I don't see anything added to requirements?

The package bflb-mic-tool needs to be installed for this runner to work, it's printed as an error if missing,

But we have that for all tools. In fact we should use self.require() instead, shouldn't we? in no case should we be installing this package for the user in my opinion.

@carlescufi
Copy link
Member

That is neither in the scope of this PR, a problem in this PR, or addressable in this PR. Best I can do is bring it up to pypi and the vendor.

Please do that. Also there's additional info here: bouffalolab/bouffalo_sdk#93. Perhaps you can open an issue in that repo?

After another look, I agree that bundling the JLink binaries may not be acceptable.

@VynDragon
Copy link
Collaborator Author

What pip package exactly is causing the trouble here? I don't see anything added to requirements?

The package bflb-mic-tool needs to be installed for this runner to work, it's printed as an error if missing,

But we have that for all tools. In fact we should use self.require() instead, shouldn't we? in no case should we be installing this package for the user in my opinion.

I didnt know about that feature, ill looking making it a requirement style thing.

Please do that. Also there's additional info here: bouffalolab/bouffalo_sdk#93. Perhaps you can open an issue in that repo?

After another look, I agree that bundling the JLink binaries may not be acceptable.

I dont disagree that it is a issue (and likely should not even be on pypi either), I have already contacted the vendor through a privileged channel and it might get fixed quickly.

@VynDragon
Copy link
Collaborator Author

Rebased on main.

@VynDragon VynDragon force-pushed the bflb_flasher branch 3 times, most recently from e5aa1ce to fcd572c Compare April 29, 2025 17:01
@nandojve
Copy link
Member

nandojve commented Apr 29, 2025

I could flash the device but when install I got this error:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pyocd 0.36.0 requires pylink-square<2.0,>=1.0, but you have pylink-square 0.5.0 which is incompatible.

Linux
python3.11 and python3.13

@VynDragon
Copy link
Collaborator Author

That's normal and not related to this, you can ignore it.

@nandojve
Copy link
Member

Hi @VynDragon ,

That's normal and not related to this, you can ignore it.

It not seems to be the case, see below:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
bflb-mcu-tool-uart 1.10.0 requires pylink-square==0.5.0, but you have pylink-square 1.6.0 which is incompatible.

That the dependency is too old and need to be updated, see setup.py.
This possible will broke easy on future again. So, need to ask to Bouffalo Lab to make dependency >= instead ==.
I would recommend to then to update to latest versions, if possible.

    install_requires=[
        "toml==0.10.0",
        "configobj==5.0.9",
        "cryptography==37.0.4",
        "pycklink>=0.1.1",
        "pyserial==3.5",
-        "pylink-square==0.5.0",
+        "pylink-square>=1.6.0",
        "portalocker==2.0.0",
        "telnetlib-313-and-up; python_version > '3.12'"
    ],
    python_requires=">=3.6",
    zip_safe=False,

@VynDragon
Copy link
Collaborator Author

Right, ill mail them and ask.

@VynDragon
Copy link
Collaborator Author

It should be good now, please check

@VynDragon VynDragon requested a review from pdgendt May 22, 2025 17:45
pdgendt
pdgendt previously approved these changes May 22, 2025
VynDragon and others added 3 commits May 25, 2025 12:02
Introduces one of the official flash tools for bouffalolab platforms.

Co-authored-by: Gerson Fernando Budke <[email protected]>
Signed-off-by: Camille BAUD <[email protected]>
Sets bflb_mcu_tool to be the tool used by default for flashing

Signed-off-by: Camille BAUD <[email protected]>
Adds bflb_mcu_tool to import test

Signed-off-by: Camille BAUD <[email protected]>
Sets bflb_mcu_tool to be the tool used by default for flashing

Signed-off-by: Camille BAUD <[email protected]>
Copy link

@kartben kartben merged commit f06f6be into zephyrproject-rtos:main May 26, 2025
44 checks passed
@VynDragon VynDragon deleted the bflb_flasher branch May 26, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants