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

Make signals_to_port_fields patch work for newer PORT registerblocks #10

Merged
merged 6 commits into from
Nov 18, 2020

Conversation

explicite
Copy link
Contributor

Not sure if it's correct way. For visibility. Will be good if anyone from #6 can advice.

src/atdf/patch.rs Outdated Show resolved Hide resolved
src/atdf/patch.rs Outdated Show resolved Hide resolved
src/atdf/patch.rs Outdated Show resolved Hide resolved
src/atdf/patch.rs Outdated Show resolved Hide resolved
@Rahix Rahix changed the title Draft Make signals_to_port_fields patch work for newer PORT registerblocks Nov 14, 2020
@Rahix Rahix added the enhancement New feature or request label Nov 14, 2020
explicite and others added 2 commits November 14, 2020 15:39
Co-authored-by: Rahix <rahix@rahix.de>
- aho-carasick bump
@explicite explicite marked this pull request as ready for review November 14, 2020 14:50
@explicite
Copy link
Contributor Author

After this change still getting warnings. Description probably can be fixed with info. from caption attr.

Warning: Unhandled register node: "<register-group offset=\"0\" name=\"SINGLE\" union-tag-value=\"0\" name-in-module=\"TCA_SINGLE\" ...>"
Warning: Unhandled register node: "<register-group name-in-module=\"TCA_SPLIT\" name=\"SPLIT\" offset=\"0\" union-tag-value=\"1\" ...>"
Warning: Could not apply 'signals_to_port_fields' patch!
Warning: Description missing for peripheral "AC0"
Warning: Description missing for peripheral "ADC0"
Warning: Description missing for peripheral "BOD"
Warning: Description missing for peripheral "CCL"
Warning: Description missing for peripheral "CLKCTRL"
Warning: Description missing for peripheral "CPU"
Warning: Description missing for peripheral "CPUINT"
Warning: Description missing for peripheral "CRCSCAN"
Warning: Description missing for peripheral "EVSYS"
Warning: Description missing for peripheral "FUSE"
Warning: Description missing for peripheral "GPIO"
Warning: Description missing for peripheral "LOCKBIT"
Warning: Description missing for peripheral "NVMCTRL"
Warning: Description missing for peripheral "PORTA"
Warning: Description missing for peripheral "PORTB"
Warning: Description missing for peripheral "PORTC"
Warning: Description missing for peripheral "PORTD"
Warning: Description missing for peripheral "PORTE"
Warning: Description missing for peripheral "PORTF"
Warning: Description missing for peripheral "PORTMUX"
Warning: Description missing for peripheral "RSTCTRL"
Warning: Description missing for peripheral "RTC"
Warning: Description missing for peripheral "SIGROW"
Warning: Description missing for peripheral "SLPCTRL"
Warning: Description missing for peripheral "SPI0"
Warning: Description missing for peripheral "SYSCFG"
Warning: No registers found for peripheral "TCA0"
Warning: Description missing for peripheral "TCB0"
Warning: Description missing for peripheral "TCB1"
Warning: Description missing for peripheral "TCB2"
Warning: Description missing for peripheral "TCB3"
Warning: Description missing for peripheral "TWI0"
Warning: Description missing for peripheral "USART0"
Warning: Description missing for peripheral "USART1"
Warning: Description missing for peripheral "USART2"
Warning: Description missing for peripheral "USART3"
Warning: Description missing for peripheral "USERROW"
Warning: Description missing for peripheral "VPORTA"
Warning: Description missing for peripheral "VPORTB"
Warning: Description missing for peripheral "VPORTC"
Warning: Description missing for peripheral "VPORTD"
Warning: Description missing for peripheral "VPORTE"
Warning: Description missing for peripheral "VPORTF"
Warning: Description missing for peripheral "VREF"
Warning: Description missing for peripheral "WDT"
Warning: Description missing for field "NMI"
Warning: Description missing for field "VLM"
Warning: Description missing for field "CNT"
Warning: Description missing for field "PIT"
Warning: Description missing for field "CCL"
Warning: Description missing for field "LUNF"
Warning: Description missing for field "OVF"
Warning: Description missing for field "HUNF"
Warning: Description missing for field "CMP0"
Warning: Description missing for field "LCMP0"
Warning: Description missing for field "CMP1"
Warning: Description missing for field "LCMP1"
Warning: Description missing for field "CMP2"
Warning: Description missing for field "LCMP2"
Warning: Description missing for field "TWIS"
Warning: Description missing for field "TWIM"
Warning: Description missing for field "AC"
Warning: Description missing for field "RESRDY"
Warning: Description missing for field "WCOMP"
Warning: Description missing for field "EE"
Warning: Description missing for field "PORT"
Warning: Description missing for field "INT"
Warning: Description missing for field "RXC"
Warning: Description missing for field "DRE"
Warning: Description missing for field "TXC"

@Rahix
Copy link
Owner

Rahix commented Nov 14, 2020

Warnings are normal, the ATDF files are riddled with these minor issues ... What stands out to me is the

Warning: Could not apply 'signals_to_port_fields' patch!

We need to investigate where that comes from.

Edit: This change should give you more information about what is happening:

diff --git a/src/atdf/mod.rs b/src/atdf/mod.rs
index 85b959255cef..f8fb797f387d 100644
--- a/src/atdf/mod.rs
+++ b/src/atdf/mod.rs
@@ -13,7 +13,7 @@ pub fn parse<R: std::io::Read>(r: R) -> crate::Result<crate::chip::Chip> {
     let mut chip = chip::parse(&tree)?;
 
     patch::signals_to_port_fields(&mut chip, &tree)
-        .unwrap_or_else(|_| log::warn!("Could not apply 'signals_to_port_fields' patch!"));
+        .unwrap_or_else(|e| crate::cli::exit_with_error(e));
     patch::remove_unsafe_cpu_regs(&mut chip, &tree)?;
 
     Ok(chip)

Cargo.lock Outdated Show resolved Hide resolved
src/atdf/patch.rs Outdated Show resolved Hide resolved
explicite and others added 2 commits November 14, 2020 21:20
Co-authored-by: Rahix <rahix@rahix.de>
- dead code removal
@explicite
Copy link
Contributor Author

Looks like this lines are problematic

      <register-group caption="16-bit Timer/Counter Type A" class="union" name="TCA" size="0x40" union-tag="TCA.SINGLE.CTRLD.SPLITM">
        <register-group name="SINGLE" name-in-module="TCA_SINGLE" offset="0" union-tag-value="0"/>
        <register-group name="SPLIT" name-in-module="TCA_SPLIT" offset="0" union-tag-value="1"/>
      </register-group>

4098

Then we have definition per selected mode eg.

 <value-group caption="Clock Selection select" name="TCA_SINGLE_CLKSEL">
        <value caption="System Clock" name="DIV1" value="0x00"/>
        <value caption="System Clock / 2" name="DIV2" value="0x01"/>
        <value caption="System Clock / 4" name="DIV4" value="0x02"/>
        <value caption="System Clock / 8" name="DIV8" value="0x03"/>
        <value caption="System Clock / 16" name="DIV16" value="0x04"/>
        <value caption="System Clock / 64" name="DIV64" value="0x05"/>
        <value caption="System Clock / 256" name="DIV256" value="0x06"/>
        <value caption="System Clock / 1024" name="DIV1024" value="0x07"/>
</value-group>

@Rahix
Copy link
Owner

Rahix commented Nov 14, 2020

What document is this picture from?

AFAIK, we currently do not support nested register groups (#4). But this should not hinder the remaining peripherals from working at least ...

Copy link
Owner

@Rahix Rahix left a comment

Choose a reason for hiding this comment

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

The changes look good, but we still need to find what causes the patch to fail to apply. Can you try the patch I posted above and check what output you get?

@explicite
Copy link
Contributor Author

Ok, got it.

Error:

Error: Missing child "<instance name=\'PORTMUX\'>" in
   <module name="PORT" id="I2103" ...>

I can see only PORTMUX for I2600

<module id="I2600" name="PORTMUX">
          <instance name="PORTMUX">
            <register-group address-space="data" name="PORTMUX" name-in-module="PORTMUX" offset="0x05E0"/>
          </instance>
</module>
<module caption="Port Multiplexer" id="I2600" name="PORTMUX">
      <register-group caption="Port Multiplexer" name="PORTMUX" size="0x10">
        <register caption="Port Multiplexer CCL" initval="0x00" name="CCLROUTEA" offset="0x1" rw="RW" size="1">
          <bitfield caption="CCL LUT0" mask="0x1" name="LUT0" rw="RW"/>
          <bitfield caption="CCL LUT1" mask="0x2" name="LUT1" rw="RW"/>
          <bitfield caption="CCL LUT2" mask="0x4" name="LUT2" rw="RW"/>
          <bitfield caption="CCL LUT3" mask="0x8" name="LUT3" rw="RW"/>
        </register>
        <register caption="Port Multiplexer EVSYS" initval="0x00" name="EVSYSROUTEA" offset="0x0" rw="RW" size="1">
          <bitfield caption="Event Output 0" mask="0x1" name="EVOUT0" rw="RW"/>
          <bitfield caption="Event Output 1" mask="0x2" name="EVOUT1" rw="RW"/>
          <bitfield caption="Event Output 2" mask="0x4" name="EVOUT2" rw="RW"/>
          <bitfield caption="Event Output 3" mask="0x8" name="EVOUT3" rw="RW"/>
          <bitfield caption="Event Output 4" mask="0x10" name="EVOUT4" rw="RW"/>
          <bitfield caption="Event Output 5" mask="0x20" name="EVOUT5" rw="RW"/>
        </register>
        <register caption="Port Multiplexer TCA" initval="0x00" name="TCAROUTEA" offset="0x4" rw="RW" size="1">
          <bitfield caption="Port Multiplexer TCA0" mask="0x7" name="TCA0" rw="RW" values="PORTMUX_TCA0"/>
        </register>
        <register caption="Port Multiplexer TCB" initval="0x00" name="TCBROUTEA" offset="0x5" rw="RW" size="1">
          <bitfield caption="Port Multiplexer TCB0" mask="0x1" name="TCB0" rw="RW"/>
          <bitfield caption="Port Multiplexer TCB1" mask="0x2" name="TCB1" rw="RW"/>
          <bitfield caption="Port Multiplexer TCB2" mask="0x4" name="TCB2" rw="RW"/>
          <bitfield caption="Port Multiplexer TCB3" mask="0x8" name="TCB3" rw="RW"/>
        </register>
        <register caption="Port Multiplexer TWI and SPI" initval="0x00" name="TWISPIROUTEA" offset="0x3" rw="RW" size="1">
          <bitfield caption="Port Multiplexer SPI0" mask="0x3" name="SPI0" rw="RW" values="PORTMUX_SPI0"/>
          <bitfield caption="Port Multiplexer TWI0" mask="0x30" name="TWI0" rw="RW" values="PORTMUX_TWI0"/>
        </register>
        <register caption="Port Multiplexer USART register A" initval="0x00" name="USARTROUTEA" offset="0x2" rw="RW" size="1">
          <bitfield caption="Port Multiplexer USART0" mask="0x3" name="USART0" rw="RW" values="PORTMUX_USART0"/>
          <bitfield caption="Port Multiplexer USART1" mask="0xc" name="USART1" rw="RW" values="PORTMUX_USART1"/>
          <bitfield caption="Port Multiplexer USART2" mask="0x30" name="USART2" rw="RW" values="PORTMUX_USART2"/>
          <bitfield caption="Port Multiplexer USART3" mask="0xc0" name="USART3" rw="RW" values="PORTMUX_USART3"/>
        </register>
      </register-group>
      <value-group caption="Port Multiplexer TCA0 select" name="PORTMUX_TCA0">
        <value caption="TCA0 pins on PA[5:0]" name="PORTA" value="0x0"/>
        <value caption="TCA0 pins on PB[5:0]" name="PORTB" value="0x1"/>
        <value caption="TCA0 pins on PC[5:0]" name="PORTC" value="0x2"/>
        <value caption="TCA0 pins on PD[5:0]" name="PORTD" value="0x3"/>
        <value caption="TCA0 pins on PE[5:0]" name="PORTE" value="0x4"/>
        <value caption="TCA0 pins on PF[5:0]" name="PORTF" value="0x5"/>
      </value-group>
      <value-group caption="Port Multiplexer SPI0 select" name="PORTMUX_SPI0">
        <value caption="SPI0 on PA[7:4]" name="DEFAULT" value="0x0"/>
        <value caption="SPI0 on PC[3:0]" name="ALT1" value="0x1"/>
        <value caption="SPI0 on PE[3:0]" name="ALT2" value="0x2"/>
        <value caption="Not connected to any pins" name="NONE" value="0x3"/>
      </value-group>
      <value-group caption="Port Multiplexer TWI0 select" name="PORTMUX_TWI0">
        <value caption="SCL/SDA on PA[3:2], Slave mode on PC[3:2] in dual TWI mode" name="DEFAULT" value="0x0"/>
        <value caption="SCL/SDA on PA[3:2], Slave mode on PF[3:2] in dual TWI mode" name="ALT1" value="0x1"/>
        <value caption="SCL/SDA on PC[3:2], Slave mode on PF[3:2] in dual TWI mode" name="ALT2" value="0x2"/>
        <value caption="Not connected to any pins" name="NONE" value="0x3"/>
      </value-group>
      <value-group caption="Port Multiplexer USART0 select" name="PORTMUX_USART0">
        <value caption="USART0 on PA[3:0]" name="DEFAULT" value="0x0"/>
        <value caption="USART0 on PA[7:4]" name="ALT1" value="0x1"/>
        <value caption="Not connected to any pins" name="NONE" value="0x3"/>
      </value-group>
      <value-group caption="Port Multiplexer USART1 select" name="PORTMUX_USART1">
        <value caption="USART1 on PC[3:0]" name="DEFAULT" value="0x0"/>
        <value caption="USART1 on PC[7:4]" name="ALT1" value="0x1"/>
        <value caption="Not connected to any pins" name="NONE" value="0x3"/>
      </value-group>
      <value-group caption="Port Multiplexer USART2 select" name="PORTMUX_USART2">
        <value caption="USART2 on PF[3:0]" name="DEFAULT" value="0x0"/>
        <value caption="USART2 on PF[6:4]" name="ALT1" value="0x1"/>
        <value caption="Not connected to any pins" name="NONE" value="0x3"/>
      </value-group>
      <value-group caption="Port Multiplexer USART3 select" name="PORTMUX_USART3">
        <value caption="USART3 on PB[3:0]" name="DEFAULT" value="0x0"/>
        <value caption="USART3 on PB[5:4]" name="ALT1" value="0x1"/>
        <value caption="Not connected to any pins" name="NONE" value="0x3"/>
      </value-group>
    </module>
    <module caption="Reset controller" id="I2111" name="RSTCTRL">
      <register-group caption="Reset controller" name="RSTCTRL" size="0x4">
        <register caption="Reset Flags" initval="0x00" name="RSTFR" offset="0x0" rw="RW" size="1">
          <bitfield caption="Brown out detector Reset flag" mask="0x2" name="BORF" rw="RW"/>
          <bitfield caption="External Reset flag" mask="0x4" name="EXTRF" rw="RW"/>
          <bitfield caption="Power on Reset flag" mask="0x1" name="PORF" rw="RW"/>
          <bitfield caption="Software Reset flag" mask="0x10" name="SWRF" rw="RW"/>
          <bitfield caption="UPDI Reset flag" mask="0x20" name="UPDIRF" rw="RW"/>
          <bitfield caption="Watch dog Reset flag" mask="0x8" name="WDRF" rw="RW"/>
        </register>
        <register caption="Software Reset" initval="0x00" name="SWRR" offset="0x1" rw="RW" size="1">
          <bitfield caption="Software reset enable" mask="0x1" name="SWRE" rw="RW"/>
        </register>
      </register-group>
    </module>

@Rahix
Copy link
Owner

Rahix commented Nov 15, 2020

Okay, I think I got it: This line:

.filter(|p| p.name.starts_with("PORT"))

also matches PORTMUX while we're only looking for PORTA, PORTB, PORTC, etc...

So it needs to be changed to something like e.g.

 .filter(|p| p.name.starts_with("PORT") && p.name.len() == 5) 

This is a bit dirty but I think it'll do the trick for now ...

@explicite
Copy link
Contributor Author

Maybe we can do same as prev. : list names explicite?
No errors but still lot of warning

arning: Unhandled register node: "<register-group union-tag-value=\"0\" name=\"SINGLE\" name-in-module=\"TCA_SINGLE\" offset=\"0\" ...>"
Warning: Unhandled register node: "<register-group offset=\"0\" union-tag-value=\"1\" name-in-module=\"TCA_SPLIT\" name=\"SPLIT\" ...>"
Warning: Description missing for peripheral "AC0"
Warning: Description missing for peripheral "ADC0"
Warning: Description missing for peripheral "BOD"
Warning: Description missing for peripheral "CCL"
Warning: Description missing for peripheral "CLKCTRL"
Warning: Description missing for peripheral "CPU"
Warning: Description missing for peripheral "CPUINT"
Warning: Description missing for peripheral "CRCSCAN"
Warning: Description missing for peripheral "EVSYS"
Warning: Description missing for peripheral "FUSE"
Warning: Description missing for peripheral "GPIO"
Warning: Description missing for peripheral "LOCKBIT"
Warning: Description missing for peripheral "NVMCTRL"
Warning: Description missing for peripheral "PORTA"
Warning: Description missing for peripheral "PORTB"
Warning: Description missing for peripheral "PORTC"
Warning: Description missing for peripheral "PORTD"
Warning: Description missing for peripheral "PORTE"
Warning: Description missing for peripheral "PORTF"
Warning: Description missing for peripheral "PORTMUX"
Warning: Description missing for peripheral "RSTCTRL"
Warning: Description missing for peripheral "RTC"
Warning: Description missing for peripheral "SIGROW"
Warning: Description missing for peripheral "SLPCTRL"
Warning: Description missing for peripheral "SPI0"
Warning: Description missing for peripheral "SYSCFG"
Warning: No registers found for peripheral "TCA0"
Warning: Description missing for peripheral "TCB0"
Warning: Description missing for peripheral "TCB1"
Warning: Description missing for peripheral "TCB2"
Warning: Description missing for peripheral "TCB3"
Warning: Description missing for peripheral "TWI0"
Warning: Description missing for peripheral "USART0"
Warning: Description missing for peripheral "USART1"
Warning: Description missing for peripheral "USART2"
Warning: Description missing for peripheral "USART3"
Warning: Description missing for peripheral "USERROW"
Warning: Description missing for peripheral "VPORTA"
Warning: Description missing for peripheral "VPORTB"
Warning: Description missing for peripheral "VPORTC"
Warning: Description missing for peripheral "VPORTD"
Warning: Description missing for peripheral "VPORTE"
Warning: Description missing for peripheral "VPORTF"
Warning: Description missing for peripheral "VREF"
Warning: Description missing for peripheral "WDT"
Warning: Description missing for field "NMI"
Warning: Description missing for field "VLM"
Warning: Description missing for field "CNT"
Warning: Description missing for field "PIT"
Warning: Description missing for field "CCL"
Warning: Description missing for field "LUNF"
Warning: Description missing for field "OVF"
Warning: Description missing for field "HUNF"
Warning: Description missing for field "CMP0"
Warning: Description missing for field "LCMP0"
Warning: Description missing for field "CMP1"
Warning: Description missing for field "LCMP1"
Warning: Description missing for field "CMP2"
Warning: Description missing for field "LCMP2"
Warning: Description missing for field "TWIS"
Warning: Description missing for field "TWIM"
Warning: Description missing for field "AC"
Warning: Description missing for field "RESRDY"
Warning: Description missing for field "WCOMP"
Warning: Description missing for field "EE"
Warning: Description missing for field "PORT"
Warning: Description missing for field "INT"
Warning: Description missing for field "RXC"

@Rahix Rahix self-requested a review November 17, 2020 09:28
Copy link
Owner

@Rahix Rahix left a comment

Choose a reason for hiding this comment

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

Looks all good now, thanks a lot!

@Rahix Rahix linked an issue Nov 17, 2020 that may be closed by this pull request
@explicite
Copy link
Contributor Author

@Rahix are we going to merge this? I want to progress on #11

@Rahix
Copy link
Owner

Rahix commented Nov 18, 2020

Sorry for the delay, wanted to do some regression tests before merging. All done now, though :)

@Rahix Rahix merged commit 5320186 into Rahix:master Nov 18, 2020
@explicite explicite deleted the topic-6 branch November 18, 2020 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make signals_to_port_fields patch work with newer devices
2 participants