embassy-rs / stm32-data

69 stars 101 forks source link

HSEM peripheral missing in cube xml files for several chip families #444

Closed taunusflieger closed 5 months ago

taunusflieger commented 5 months ago

I'm in the process to add support for HSEM.

It looks like that the cube XML files are missing the HSEM entry except for the STM32WLE family. parse_groups() relays on the xml data to identify the IP available on the chip. If HSEM is not defined in the XML the further process does not process the HSEM data. Therefore the data generation process is only successful for the STM32WEL family. For all other chips which have a HSEM peripheral the data generation process is not successful.

I've done some quick hack to prove that the missing HSEM entry in the cube XML is causing the issue:

fn process_group(
    mut group: ChipGroup,
    peri_matcher: &mut PeriMatcher,
    headers: &header::Headers,
    af: &gpio_af::Af,
    chip_interrupts: &interrupts::ChipInterrupts,
    peripheral_to_clock: &rcc::ParsedRccs,
    dma_channels: &dma::DmaChannels,
    chips: &HashMap<String, Chip>,
    memories: &memory::Memories,
    docs: &docs::Docs,
) -> Result<(), anyhow::Error> {
    let chip_name = group.chip_names[0].clone();
    group.family = Some(group.xml.family.clone());
    group.line = Some(group.xml.line.clone());
    group.die = Some(group.xml.die.clone());
    let rcc_kind = group.ips.values().find(|x| x.name == "RCC").unwrap().version.clone();
    let rcc_block = peri_matcher
        .match_peri(&format!("{chip_name}:RCC:{rcc_kind}"))
        .unwrap_or_else(|| panic!("could not get rcc for {}", &chip_name));
    let h = headers
        .get_for_chip(&chip_name)
        .unwrap_or_else(|| panic!("could not get header for {}", &chip_name));
    let chip_af = &group.ips.values().find(|x| x.name == "GPIO").unwrap().version;
    let chip_af = chip_af.strip_suffix("_gpio_v1_0").unwrap();
    let chip_af = af.0.get(chip_af);

    // Quick hack to add the missing HSEM IP
    if chip_name.starts_with("STM32H747") || chip_name.starts_with("STM32H757") {
        info!("Patching HSEM in IPS for {}", chip_name);
        group.ips.insert(
            "HSEM".to_string(),
            xml::Ip {
                name: "HSEM".to_string(),
                version: "hsem1_v1_0_Cube".to_string(),
                instance_name: "HSEM".to_string(),
            },
        );
    }

What is the right approach to get this fixed?