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

Gd32v Support #21

Merged
merged 21 commits into from
Jul 24, 2022
Merged

Gd32v Support #21

merged 21 commits into from
Jul 24, 2022

Conversation

kassane
Copy link
Contributor

@kassane kassane commented Feb 20, 2022

@kassane kassane marked this pull request as draft February 20, 2022 13:12
@kassane
Copy link
Contributor Author

kassane commented Mar 9, 2022

cc: @mattnite @vesim987

Is it possible to automate the translation or read the start.S file in zig build or microzig?
I found the files needed to support the chip in the GD32v firmware libraries ¹, but am having difficulty converting them.
And comparing on the rust solution ² for this I was in doubt of the real support with llvm.

@kassane kassane marked this pull request as ready for review March 10, 2022 19:22
@kassane kassane marked this pull request as draft March 19, 2022 14:07
@kassane
Copy link
Contributor Author

kassane commented Mar 20, 2022

Status

  • Logan Nano board added

By adding some changes you find errors in the api during the build:

Uart error:

./src/core/uart.zig:6:28: error: container '.chip' has no member called 'Uart'
    const SystemUart = chip.Uart(index);
                           ^
./src/modules/boards/logan-nano/logan-nano.zig:60:29: note: called from here
    const uart0 = micro.Uart(0).getOrInit(.{
                            ^
./src/modules/boards/logan-nano/logan-nano.zig:59:44: note: called from here
pub fn debugWrite(string: []const u8) void {

Pin error:

./src/core/pin.zig:22:13: error: container '.chip' has no member called 'parsePin'
        chip.parsePin(@field(board.pin_map, spec))
            ^
./tests/blinky.zig:9:36: note: called from here
        .@"Logan Nano" => micro.Pin("PC13"), // error in 'parsePin'
                                   ^
./tests/blinky.zig:4:17: note: called from here
const led_pin = if (micro.config.has_board)

@widlarizer
Copy link

widlarizer commented Apr 12, 2022

I suggest writing a small HAL for STM32F103 first. It is better documented, the GD32VF is a binary compatible clone. Right now your PR uses F303 HAL which is incompatible, for example, instead of a single GPIO mode register there are two with different fields, so it's not just renaming registers that you have to make it work
By the way, it's Longan, not Logan

@kassane
Copy link
Contributor Author

kassane commented Apr 12, 2022

Hi @ekliptik

Nice tip! I already made some improvements, however didn't have time to validate and send the new commit containing these improvements and including the board name was fixed.

But thanks for the review!

@kassane kassane marked this pull request as ready for review July 16, 2022 14:11
- replace baseline_rv32 to sifive_e21(imac)
- update registers.zig
- parsepin added (WIP)
- more riscv_encoding added
@mattnite
Copy link
Contributor

@kassane looks like some unused parameters are causing the build to fail

@kassane
Copy link
Contributor Author

kassane commented Jul 21, 2022

@kassane looks like some unused parameters are causing the build to fail

fix

build.zig Outdated Show resolved Hide resolved
@kassane kassane requested a review from mattnite July 21, 2022 19:41
@mattnite
Copy link
Contributor

are you able to confirm that this is how interrupts work on the chip, and is it consistent with other risc chips?

@kassane
Copy link
Contributor Author

kassane commented Jul 22, 2022

are you able to confirm that this is how interrupts work on the chip, and is it consistent with other risc chips?

First, you can't confuse gd32 (bluepill clone) with gd32v even though the pinouts are compatible. The main difference is that gd32v has a higher clock speed.

The IRQ mechanism (ECLIC) of this device is unique to the Nuclei manufacturer (core Bumblebee) since RISC-V has no default interrupt mechanism.
So far the interrupt implementation is not finished as it would need to use pieces of code from the official SDK and toolchain (nuclei-gcc fork), even attach an assembly file as it was done in the rust project (see this).

The SVD provided is also not complete, many complain about certain details like undeclared core timer.
And regz did not translate it completely (missing clusters), so it will have to be done manually with the respective time.

Reference

@mattnite
Copy link
Contributor

okay if that's the case then we shouldn't be putting arm interrupt table code in the risc processor code, similar to how we add a skip for the uart example, please add a skip mechanism for the interrupt example.

src/modules/cpus/rv32-imac/riscv32.zig Outdated Show resolved Hide resolved
@kassane kassane requested a review from mattnite July 23, 2022 19:16
build.zig Outdated Show resolved Hide resolved
@kassane kassane requested a review from mattnite July 24, 2022 12:27
build.zig Show resolved Hide resolved
@mattnite mattnite merged commit d57f19c into ZigEmbeddedGroup:main Jul 24, 2022
@mattnite
Copy link
Contributor

🙏 thanks for getting the first riscv patch in!

@kassane
Copy link
Contributor Author

kassane commented Jul 24, 2022

🙏 thanks for getting the first riscv patch in!

Thank you for the patience. 😅

@kassane kassane deleted the gd32v branch August 7, 2022 13:39
ikskuh added a commit that referenced this pull request Feb 16, 2024
* MicroZig Gen 2 interface
* Adds ELF patching to handle the checksum requirement

---------

Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
ikskuh added a commit that referenced this pull request Feb 16, 2024
Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
mattnite added a commit that referenced this pull request Feb 26, 2024
* snapshot

* size from register properties now passes tests

* finish moving to named index types
mattnite added a commit that referenced this pull request Feb 26, 2024
* snapshot

* size from register properties now passes tests

* finish moving to named index types
mattnite added a commit that referenced this pull request Mar 1, 2024
* snapshot

* size from register properties now passes tests

* finish moving to named index types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants