Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

[RISCV - Xuantie] Custom SVD - register error #17

Open
kassane opened this issue Apr 24, 2022 · 10 comments
Open

[RISCV - Xuantie] Custom SVD - register error #17

kassane opened this issue Apr 24, 2022 · 10 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@kassane
Copy link

kassane commented Apr 24, 2022

Recently, have started some tests with regz using some SVD's such as gd32v (which does not yet have cluster support), esp32-c3 and now allwinner D1 (unofficial svd). However an error occurs when trying to generate the file conversion. I just succeeded in doing the conversion using svd2rust according to shell script found in the above mentioned repository. svd2rust --target riscv -i ../svd/d1_unofficial.svd --const_generic

Output:

$> regz -s svd ../aw-pac/svd/d1_unofficial.svd -o allwinner_d1.zig 
warning: ignoring field 'CLK_SRC_GATING' (31-32) because it overlaps with 'CLK_GATING' (31-32) in register 'EMAC_25M_CLK'
error: MissingDimension
/home/kassane/regz/src/Database.zig:0:21: 0x262f91 in Database.genZigSingleRegister (regz)
/home/kassane/regz/src/Database.zig:0:0: 0x2631ec in Database.genZigSingleRegister (regz)
/home/kassane/regz/src/Database.zig:0:0: 0x25fcb8 in Database.genZigRegister (regz)
/home/kassane/.local/lib/zig/std/mem/Allocator.zig:0:28: 0x23547f in Database.toZig (regz)
/home/kassane/.local/lib/zig/std/heap/arena_allocator.zig:0:16: 0x22f85c in mainImpl (regz)
/home/kassane/regz/src/main.zig:25:17: 0x23033d in std.start.main (regz)
        else => return err,
@kassane
Copy link
Author

kassane commented Apr 25, 2022

Surprising, I found this project that haven't tried yet that extracts the list of board registers from the manual.
https://github.com/daym/allwinner-register-interface-extractor

Edit: I have found an issue/1 when trying to get data from the D1-H manual.

@mattnite mattnite moved this to Todo in Embedded Zig Apr 26, 2022
@mattnite mattnite added bug Something isn't working good first issue Good for newcomers labels Apr 26, 2022
@kassane
Copy link
Author

kassane commented May 2, 2022

Edit: I have found an issue/1 when trying to get data from the D1-H manual.

I don't know if you followed the situation mentioned above, but a new svd was generated from the official manual.
After this, I again try to use regz with the generated SVDs (manual 0.1 and 1.0) and another error occurred:

warning: clusters with dimIndex set are not implemented yet: _N_%s
error: InvalidClusterSize
/home/kassane/regz/src/Database.zig:888:21: 0x233df2 in Database.toZig (regz)
                    return error.InvalidClusterSize;
                    ^
/home/kassane/regz/src/Database.zig:0:0: 0x2361d1 in Database.toZig (regz)
/home/kassane/.local/lib/zig/std/heap/arena_allocator.zig:0:16: 0x22f85c in mainImpl (regz)
/home/kassane/regz/src/main.zig:25:17: 0x23033d in std.start.main (regz)
        else => return err,

generated SVDs

@kassane
Copy link
Author

kassane commented May 3, 2022

New SVD - D1s
allwinner_d1s.svd

Same error

@mattnite
Copy link
Contributor

mattnite commented May 5, 2022

@kassane looks like the issue is the SVD, in cluster _n[%s] (is that really what it's meant to be called?). This is meant to be a cluster array, the dimIncrement is 4, but has three 32-bit registers in the cluster. A dimIncrement is defined as the following:

Specify the address increment, in Bytes, between two neighboring clusters of the cluster array.

So the issue is that the SVD says that each cluster is 4 bytes, but then says there are 12 bytes of registers.

@kassane
Copy link
Author

kassane commented May 5, 2022

looks like the issue is the SVD, in cluster _n[%s] (is that really what it's meant to be called?). This is meant to be a cluster array, the dimIncrement is 4, but has three 32-bit registers in the cluster.

I will need to check it more carefully, as there were some errors in the information in the manual device and the generated svd also brought redundant information to extract from the manual.

@kassane
Copy link
Author

kassane commented May 8, 2022

Hi @mattnite

I am manually reviewing the generated file issue and have seen some inconsistencies in the official documentation itself (may take some time to fully review).

But to test the regz tolerance in svd(d1-h) some clustered lines were commented:

LoC:

  • 25015 - 25151
  • 74295 - 74345
  • 80637 - 80708

Result:

@kassane
Copy link
Author

kassane commented May 21, 2022

Recently, have started some tests with regz using allwinner D1 (unofficial svd).
Output:

$> regz -s svd ../aw-pac/svd/d1_unofficial.svd -o allwinner_d1.zig 
warning: ignoring field 'CLK_SRC_GATING' (31-32) because it overlaps with 'CLK_GATING' (31-32) in register 'EMAC_25M_CLK'
error: MissingDimension
/home/kassane/regz/src/Database.zig:0:21: 0x262f91 in Database.genZigSingleRegister (regz)
/home/kassane/regz/src/Database.zig:0:0: 0x2631ec in Database.genZigSingleRegister (regz)
/home/kassane/regz/src/Database.zig:0:0: 0x25fcb8 in Database.genZigRegister (regz)
/home/kassane/.local/lib/zig/std/mem/Allocator.zig:0:28: 0x23547f in Database.toZig (regz)
/home/kassane/.local/lib/zig/std/heap/arena_allocator.zig:0:16: 0x22f85c in mainImpl (regz)
/home/kassane/regz/src/main.zig:25:17: 0x23033d in std.start.main (regz)
        else => return err,

I quickly resumed some tests on this manual version of SVD and modified the regz by removing these parameters:

regz/src/Database.zig

Lines 1165 to 1166 in eb42e56

if (std.mem.indexOf(u8, field.name, "%s") != null)
return error.MissingDimension;

regz/src/Database.zig

Lines 1243 to 1244 in eb42e56

if (dimension_opt == null and std.mem.indexOf(u8, register.name, "%s") != null)
return error.MissingDimension;

This way it generated a clearer error reporting the real problem:

warning: ignoring field 'CLK_SRC_GATING' (31-32) because it overlaps with 'CLK_GATING' (31-32) in register 'EMAC_25M_CLK'
warning: dimensioned peripherals not supported yet: SMHC[%s]
warning: dimensioned peripherals not supported yet: I2S_PCM[%s]
warning: dimensioned peripherals not supported yet: TWI[%s]
warning: dimensioned peripherals not supported yet: UART[%s]
error: found overlapping fields in register:
error:   LEDC_EN: 0+1
error:   LEDC_SOFT_RESET: 1+1
error:   LED_MSB_%s: 2+1
error:   LED_RGB_MODE: 6+3
error:   RESET_LED_EN: 10+1
error:   TOTAL_DATA_LENGTH: 16+13

The same occurs in another project (Chinese RISC-V): W806-pac

warning: ignoring field 'cpu' (8-16) because it overlaps with 'wlan' (8-16) in register 'clock_divide'
error: found overlapping fields in register:
error:   i2c: 0+1
error:   uart%s: 1+1
error:   dma: 8+1
error:   timer: 10+1
error:   gpio: 11+1
error:   adc: 12+1
error:   pwm: 13+1
error:   i2s: 15+1
error:   rsa: 16+1
error:   sdio: 18+1
error:   touch: 21+1

Unfortunately, I don't have the understanding of how SVD works yet to release patch but I study about it!

@kassane kassane changed the title [RISCV] Allwinner D1 - register error [RISCV - Xuantie] Custom SVD - register error May 22, 2022
@kassane
Copy link
Author

kassane commented Oct 12, 2022

New device SVD (same processor) BL808:

regz -s svd bl808.svd -o bl808.zig
warning: dimensioned peripherals not supported yet: DMA%s
warning: dimensioned peripherals not supported yet: I2C[%s]
warning: dimensioned peripherals not supported yet: SPI[%s]
warning: dimensioned peripherals not supported yet: UART[%s]
thread 12432 panic: reached unreachable code
[1]    12432 IOT instruction (core dumped)  regz -s svd bl808.svd -o bl808.zig

@kassane
Copy link
Author

kassane commented Jan 6, 2023

My new tests with refactored regz:

BL808 SVD:

$> regz -s svd bl808.svd -o bl808.zig 
warning(svd): TODO clusters. name: capability
warning(svd): TODO clusters. name: operation
warning(svd): TODO clusters. name: group[%s]
warning(svd): failed to load cluster: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(gen): failed to generate peripheral 'EMAC': error.MissingEnumFields
warning(gen): failed to generate peripheral 'LZ4D': error.MissingEnumFields
warning(gen): failed to generate peripheral 'I2S': error.MissingEnumFields
warning(gen): failed to generate peripheral 'I2C[%s]': error.MissingEnumFields
warning(gen): failed to generate peripheral 'UART[%s]': error.MissingEnumFields

D1 SVD (unofficial) has generated

$> regz -s svd d1_unofficial.svd -o d1.zig
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): TODO clusters. name: msgbox%s
warning(svd): failed to load cluster: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.TodoDimElements
warning(svd): TODO clusters. name: csic_ccu
warning(svd): TODO clusters. name: csic_top
warning(svd): TODO clusters. name: csic_parser0
warning(svd): TODO clusters. name: csic_dma%s
warning(svd): failed to load cluster: error.TodoDimElements
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): TODO clusters. name: ehci_capability
warning(svd): TODO clusters. name: ehci_operational
warning(svd): TODO clusters. name: ohci_control_status_partition
warning(svd): TODO clusters. name: ohci_memory_pointer_partition
warning(svd): TODO clusters. name: ohci_frame_counter_partition
warning(svd): TODO clusters. name: ohci_root_hub_partition
warning(svd): TODO clusters. name: hci_controller_phy_interface
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElementsExtended
warning(svd): failed to load register: error.DimIncrementSizeMismatch
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): failed to load register: error.TodoDimElements
warning(svd): TODO: implement derivation for Database.EntityType.peripheral

@kassane
Copy link
Author

kassane commented Jan 6, 2023

RISC-V32 (GigaDevice) - gd32vf103:

new output:

$> regz -s svd GD32VF103.svd -o gd32vf103.zig          
warning(svd): TODO clusters. name: CLICINTS[%s]
warning(svd): failed to load cluster: error.TodoDimElements
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(svd): TODO: implement derivation for Database.EntityType.peripheral
warning(gen.arm): TODO: implement interrupt table for arch: Database.Arch.cortex_m3
warning(gen): failed to write vector table: error.Todo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Todo
Development

No branches or pull requests

2 participants