Skip to content
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

Introduce Bouffalo Lab SoC's #78795

Closed
wants to merge 21 commits into from

Conversation

nandojve
Copy link
Member

@nandojve nandojve commented Sep 21, 2024

This PR is intent to continue the work started at #37686. It rewrite the original work to be compatible with Zephyr 3.7. It extends the original work to complete remove the Bouffalo Lab SDK. This means that a re-write was made to use direct register access. This proves to drop ~8k Flash content.

  • Introduces Bouffalo Lab BL-60x SoC.
  • Add following drivers:
    • Pinctrl
    • Serial
    • GPIO
  • Add following boards:
  • bl604e_iot_dvk (from Bouffalo Lab) - can only be obtained directly with Bouffalo Lab
  • dt_bl10_devkit (from DOIT) - easy to find and start will come in a future PR as requested
  • Add bflb_mcu_tool runner to easy flash

This work is Co-Authored by Camille BAUD [email protected]

In the first wave we will introduce BL 60x/70x series, with uses E24 SiFive's core. On a second moment we will add the newer XuanTie-902/6/7 (LP/M/D) from T-Head BL61x/80x.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Sep 21, 2024

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_bouffalolab 🆕 N/A (Added) nandojve/hal_bouffalolab@main N/A

DNM label due to: 1 added project

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_bouffalolab DNM This PR should not be merged (Do Not Merge) labels Sep 21, 2024
@nandojve nandojve force-pushed the bflb/bflb_upstream branch 3 times, most recently from 36aa581 to 7b2500b Compare September 21, 2024 16:16
@nandojve nandojve added this to the v4.0.0 milestone Sep 21, 2024
@nandojve nandojve force-pushed the bflb/bflb_upstream branch 3 times, most recently from f026bea to 3ee0c70 Compare September 23, 2024 12:12
@nandojve nandojve marked this pull request as ready for review September 23, 2024 19:02
@zephyrbot zephyrbot added area: GPIO area: Pinctrl area: Interrupt Controller area: Timer Timer area: West West utility platform: nRF Nordic nRFx area: Process area: RISCV RISCV Architecture (32-bit & 64-bit) area: UART Universal Asynchronous Receiver-Transmitter labels Sep 23, 2024
nandojve and others added 16 commits January 5, 2025 22:13
Switch to use the riscv-privileged mode.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Add Bouffalo Lab pinctrl driver.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Add Bouffalo Lab serial driver. The driver uses pinctrl to configure
pins and have power management capabilities.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Enable interrupt support in the driver.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Add Bouffalo Lab ISP console flash runner.  This tool enable bootloader
to flash devices using serial port.

The blflash Rust tool can be found at
  https://github.com/spacemeowx2/blflash

Signed-off-by: Gerson Fernando Budke <[email protected]>
Add initial version.

Signed-off-by: Gerson Fernando Budke <[email protected]>
This replace the SDK 1.4.2 by a direct register access aproach. This
means that future operations on hal_bouffalolab do not require any
dependency of a SDK from Bouffalo Lab anymore.

The code was inspired by the newer SDK 2.0.

Signed-off-by: Camille BAUD <[email protected]>
Signed-off-by: Gerson Fernando Budke <[email protected]>
Make all changes on the SoC to remove SDK dependency.

Signed-off-by: Camille BAUD <[email protected]>
Signed-off-by: Gerson Fernando Budke <[email protected]>
Update the BL60x cpu devicetree definitions.

Signed-off-by: Camille BAUD <[email protected]>
Signed-off-by: Gerson Fernando Budke <[email protected]>
Update pinctrl driver to be SDK independent.

Signed-off-by: Camille BAUD <[email protected]>
Signed-off-by: Gerson Fernando Budke <[email protected]>
Add Bouffalo Lab gpio driver.

Signed-off-by: Camille BAUD <[email protected]>
Signed-off-by: Gerson Fernando Budke <[email protected]>
Update serial driver to be SDK independent.

Signed-off-by: Camille BAUD <[email protected]>
Signed-off-by: Gerson Fernando Budke <[email protected]>
Add Bouffalo Lab ISP console flash runner.  This tool enable bootloader
to flash devices using serial port.

The blflash Rust tool can be found at
    https://pypi.org/project/bflb-mcu-tool

Signed-off-by: Camille BAUD <[email protected]>
Signed-off-by: Gerson Fernando Budke <[email protected]>
Move the board to the new SoC directory.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Use official flash tool by default.

Signed-off-by: Gerson Fernando Budke <[email protected]>
Introduce Bouffalo Lab platform.

Signed-off-by: Gerson Fernando Budke <[email protected]>
@nandojve nandojve force-pushed the bflb/bflb_upstream branch from 2f8e682 to 6cfc420 Compare January 5, 2025 21:14
@ycsin ycsin removed their request for review January 7, 2025 14:49
@VynDragon VynDragon mentioned this pull request Jan 7, 2025
76 tasks
modules/hal_bouffalolab/CMakeLists.txt Show resolved Hide resolved
modules/hal_bouffalolab/CMakeLists.txt Outdated Show resolved Hide resolved
modules/hal_bouffalolab/CMakeLists.txt Show resolved Hide resolved
Comment on lines 44 to 54
};
dtcm: dtcm@42014000 {
compatible = "zephyr,memory-region", "sifive,dtim0";
reg = <0x42014000 DT_SIZE_K(48)>;
zephyr,memory-region = "DTCM";
};

sram0: memory@42020000 {
compatible = "mmio-sram";
};
sram1: memory@42030000 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not resolved

modules/hal_bouffalolab/CMakeLists.txt Outdated Show resolved Hide resolved
boards/bouffalolab/bl6/bl604e_iot_dvk/doc/index.rst Outdated Show resolved Hide resolved
boards/bouffalolab/bl6/bl604e_iot_dvk/doc/index.rst Outdated Show resolved Hide resolved
boards/bouffalolab/bl6/bl604e_iot_dvk/doc/index.rst Outdated Show resolved Hide resolved
west.yml Show resolved Hide resolved
modules/hal_bouffalolab/CMakeLists.txt Outdated Show resolved Hide resolved
@marc-hb
Copy link
Collaborator

marc-hb commented Jan 8, 2025

In collaborative projects, it's important to give proper credit for the work done by contributors, especially in open-source communities, like here. This is often seen as an ethical obligation. This means that if you can not distinguish what authors made you violate their right.

There is a middle ground between squashing everything and losing the entire, original git blame, versus fixing typos introduced in the same PR... For instance, current commit a699d4f is only moving files to a different directory?! At the very least this rename commit should go. I bet neither contributor cares about being "credited" for 1) the initial location 2) the better location! Pure symbol renames should also disappear as much as possible for the same reason: no one cares about them being preserved, not even the authors involved.

Bad news: squashing such renames, typo fixes and other noises ONLY while preserving git blame elsewhere requires a fair amount of git expertise and work, sorry about that. But reviewer manpower is generally more scarce and trumps that. The git command line is not ideal, look for a better git client. The good news is: this history cleanup experience is useful in very many open-source projects - especially the ones older than GitHub. This old issue is relevant:

Generally speaking, if you only make an effort to clean the history then I bet you'll be surprised by how well this will be received. You can and probably should keep an archive of the original progression and history in some personal branch somewhere.

Just for fun: https://fossil-scm.org/home/doc/trunk/www/rebaseharm.md (totally wrong)


EDIT: a closer look shows only TWO authors in this entire PR. So it seems that you're blowing this credit/recognition complexity out of proportion. I mean here in this specific PR, not in general.

@@ -23,6 +23,8 @@ manifest:
url-base: https://github.com/zephyrproject-rtos
- name: babblesim
url-base: https://github.com/BabbleSim
- name: nandojve
Copy link
Member

Choose a reason for hiding this comment

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

this should never be in the commit history, I am not sure what exactly are we achieving by leaving something like that in the manifest. Manifest changes must be squashed and always point to a tree hosted by the zephyr project.

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely, but there is no hal_bouffalolab yet. It is possible to use only one manifest version if we delay to introduce the board as one the latest commits. That will prevent bisect errors for this new platform because there won't be a target until the first board.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely, but there is no hal_bouffalolab yet.

Until there is, a PR pointing at your personal repo is a "demo" PR, not ready for merge yet. It should be demoted to a GitHub draft to make sure it cannot be merged and to be excluded from PR scrubbing and stats. The PR name should be adjusted accordingly. There's also a DNM label.

It is possible to use only one manifest version if we delay to introduce the board as one the latest commits.

Yes: bisectability requires that dependencies are always added before dependants. That's true no matter how many commits or PRs there are. It's fine if brand new code or HAL is not immediately tested yet but in the next commits/PRs coming right after.

marc-hb added a commit to marc-hb/zephyr that referenced this pull request Jan 12, 2025
The documentation had for a long time a section that specifically
recommends to submit "smaller PRs" for review:
https://docs.zephyrproject.org/latest/contribute/contributor_expectations.html#defining-smaller-prs

Yet submitters keep submitting large PRs on a regular basis, sometimes
very large ones. See a couple of very recent examples below.

(Reminder: submitting a giant, draft PR for pure _testing_ purposes and
NOT for review is a perfectly fine)

The "natural" explanation is that submitters optimistically and wrongly
believe that dumping a large amount of code at once onto reviewers will
be dealt with faster than in smaller chunks. This is most likely a
contributing factor but most people should quickly learn from bad
experience. Yet we keep seeing large PRs on a regular basis. So there
must be other factors too.

Based on personal but fairly extensive git support experience, another
top reason is likely git usability and some lack of git
knowledge (neither the first nor the last time git usability would have
a significant impact)

To help with this, add to the existing git guide the simple command that
lets split a large submission in several, smaller PRs. This can only
help demystify and promote smaller PRs while barely growing the size of
the documentation.

While at it, also add a couple missing benefits of smaller PRs.

Recent examples of large PRs:

- In the controversial and giant PR
zephyrproject-rtos#77368 (comment)
the exhausted submitter wrote:

> Every time any one person requests a rebase that changes the PR,
> unless there's consensus, there's no mechanism (manual/project process
> or built into GitHub) to know/prevent a different person from rejecting
> the new changes.

That PR had 21 commits (18 in the final version), 82 files changed and
400 (!) comments. The sheer size massively increased the likelihood of
the problem described.  Re-submitting it in smaller chunks would
obviously have mitigated that problem. Yet that PR was never split and
stayed huge...?

- In this second example, a large PR was submitted with different
authors. A disagreement emerged about squashing across different
authors:
zephyrproject-rtos#78795 (comment)
If this PR had been split in smaller chunks, then the squashing
discussion might have been avoided entirely. Whether squashing is good or
bad in this particular case is irrelevant (and already discussed at
great in length in zephyrproject-rtos#83117). What matters here is: the submitter lost
that chance by submitting a larger PR with different authors.

Signed-off-by: Marc Herbert <[email protected]>
@nandojve
Copy link
Member Author

will continue on #84173

@nandojve nandojve closed this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree area: GPIO area: Interrupt Controller area: Pinctrl area: Process area: RISCV RISCV Architecture (32-bit & 64-bit) area: Timer Timer area: UART Universal Asynchronous Receiver-Transmitter area: West West utility DNM This PR should not be merged (Do Not Merge) manifest manifest-hal_bouffalolab
Projects
None yet
Development

Successfully merging this pull request may close these issues.