svd2zig icon indicating copy to clipboard operation
svd2zig copied to clipboard

nrf51.svd device_description quotes and also %s unevaluated

Open markfirmware opened this issue 5 years ago • 10 comments

  1. device_description needs quotes?

  2. there are unevaluated %s expressions

Can you advise on next steps?

Thanks, Mark

pub const device_name = nrf51;
pub const device_revision = 522;
pub const device_description = nRF51 reference description for radio MCU with ARM 32-bit Cortex-M0 Microcontroller at 16MHz CPU clock;

...

/// Device address base segment.
pub const RADIO_DAB[%s]_Address = 0x40001000 + 0x600;
pub const RADIO_DAB[%s]_Reset_Value = 0x0;
pub inline fn RADIO_DAB[%s]_Read() u32 {
    const mmio_ptr = @intToPtr(*volatile u32, RADIO_DAB[%s]_Address);
    return mmio_ptr.*;
}

...

markfirmware avatar Feb 29 '20 03:02 markfirmware

Hey Mark, the missing quotes is obviously wrong and will be a quick fix so I'll look at that today.

The %s thing must be a missing syntax that is not being translated currently and would be a larger fix so I won't be able to get to it quickly due to obligations in my normal life.

I wrote this repo to translate the file I needed and also just to get some Zig code under my belt. In the posborne repo they have some python that parses every svd file they claim. Adding to those to print out the zig you want will probably be a faster route for your project. Thank you for the bug reports and I will be improving this over time but it will be at a slow pace most likely.

justinbalexander avatar Feb 29 '20 13:02 justinbalexander

Hey Mark, the missing quotes is obviously wrong and will be a quick fix so I'll look at that today.

The %s thing must be a missing syntax that is not being translated currently and would be a larger fix so I won't be able to get to it quickly due to obligations in my normal life.

I wrote this repo to translate the file I needed and also just to get some Zig code under my belt. In the posborne repo they have some python that parses every svd file they claim. Adding to those to print out the zig you want will probably be a faster route for your project. Thank you for the bug reports and I will be improving this over time but it will be at a slow pace most likely.

justinbalexander avatar Feb 29 '20 13:02 justinbalexander

Your update fixed the device_description - thanks.

I see that the %s comes from data such as

<name>CONFIG[%s]</name>

and I can look at that myself next week.

markfirmware avatar Mar 01 '20 03:03 markfirmware

I think it might be more efficient to write a python script that takes advantage of the posborne svd file parser. I haven't confirmed how correct it is, but it will be a lot of work to get the Zig one fully up to speed. Of course, once it's up to speed, it will be cool to incorporate it into the package manager.

justinbalexander avatar Mar 02 '20 19:03 justinbalexander

I think it might be more efficient to write a python script that takes advantage of the posborne svd file parser. I haven't confirmed how correct it is, but it will be a lot of work to get the Zig one fully up to speed. Of course, once it's up to speed, it will be cool to incorporate it into the package manager.

Noted.

markfirmware avatar Mar 03 '20 00:03 markfirmware

May I ask what reference manual you are using for your design? I am using https://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.1.pdf for the microbit.

markfirmware avatar Mar 10 '20 01:03 markfirmware

My burnedhead project is using an STM32F767ZG so there are a lot of documents on the STM website. There's a reference manual, programming manual (for the CPU), etc. I'm also directly pulling from the armv7m architecture reference manual.

I'd love your help on my cmsis-like repo where I'm remaking much of the CMSIS functionality in zig. Look for zig-cortex in my repos. I'm working on the cortex-m7 part since that is the part I'm using first.

justinbalexander avatar Mar 10 '20 01:03 justinbalexander

I read some of cm7.zig. Have you defined all the cm7 registers already?

markfirmware avatar Mar 10 '20 22:03 markfirmware

I wasn't planning on defining them all at this point. It seems to me like the main use for CMSIS is the functions. I'm not planning on doing an exact reproduction of CMSIS, but rather to make useful common functionality to cortex processors available in idiomatic Zig. CMSIS is an inspiration but it will be divergent.

justinbalexander avatar Mar 11 '20 21:03 justinbalexander

Ok, I have an atsame70-xpld and I think I’ll see what it takes to blink its led.

markfirmware avatar Mar 12 '20 01:03 markfirmware