diff options
| author | okhsunrog <[email protected]> | 2025-05-20 21:31:32 +0300 |
|---|---|---|
| committer | okhsunrog <[email protected]> | 2025-05-20 21:31:32 +0300 |
| commit | e93ae32546b754ee9b54405aca81d936087ea8c7 (patch) | |
| tree | a79a24971eaf0b47dbec151840b6b9c7cdf7ebbb | |
| parent | ab5e0150d46b8b97d5ffe430b3e7a1caaae0438c (diff) | |
adding eeprom constants to _generated.rs
| -rw-r--r-- | embassy-stm32/build.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index b00b6a7ac..b91934af3 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -1923,6 +1923,47 @@ fn main() { | |||
| 1923 | )); | 1923 | )); |
| 1924 | 1924 | ||
| 1925 | // ======== | 1925 | // ======== |
| 1926 | // Generate EEPROM constants | ||
| 1927 | |||
| 1928 | let eeprom_memory_regions: Vec<&MemoryRegion> = | ||
| 1929 | memory.iter().filter(|x| x.kind == MemoryRegionKind::Eeprom).collect(); | ||
| 1930 | |||
| 1931 | if !eeprom_memory_regions.is_empty() { | ||
| 1932 | cfgs.enable("eeprom"); | ||
| 1933 | cfgs.declare("eeprom"); | ||
| 1934 | |||
| 1935 | let mut sorted_eeprom_regions = eeprom_memory_regions.clone(); | ||
| 1936 | sorted_eeprom_regions.sort_by_key(|r| r.address); | ||
| 1937 | |||
| 1938 | let first_eeprom_address = sorted_eeprom_regions[0].address; | ||
| 1939 | let mut total_eeprom_size = 0; | ||
| 1940 | let mut current_expected_address = first_eeprom_address; | ||
| 1941 | |||
| 1942 | for region in sorted_eeprom_regions.iter() { | ||
| 1943 | if region.address != current_expected_address { | ||
| 1944 | // For STM32L0 and STM32L1, EEPROM regions (if multiple) are expected to be contiguous. | ||
| 1945 | // If they are not, this indicates an issue with the chip metadata or an unsupported configuration. | ||
| 1946 | panic!( | ||
| 1947 | "EEPROM regions for chip {} are not contiguous, which is unexpected for L0/L1 series. \ | ||
| 1948 | First region: '{}' at {:#X}. Found next non-contiguous region: '{}' at {:#X}. \ | ||
| 1949 | Please verify chip metadata. Embassy currently assumes contiguous EEPROM for these series.", | ||
| 1950 | chip_name, sorted_eeprom_regions[0].name, first_eeprom_address, region.name, region.address | ||
| 1951 | ); | ||
| 1952 | } | ||
| 1953 | total_eeprom_size += region.size; | ||
| 1954 | current_expected_address += region.size; | ||
| 1955 | } | ||
| 1956 | |||
| 1957 | let eeprom_base_usize = first_eeprom_address as usize; | ||
| 1958 | let total_eeprom_size_usize = total_eeprom_size as usize; | ||
| 1959 | |||
| 1960 | g.extend(quote! { | ||
| 1961 | pub const EEPROM_BASE: usize = #eeprom_base_usize; | ||
| 1962 | pub const EEPROM_SIZE: usize = #total_eeprom_size_usize; | ||
| 1963 | }); | ||
| 1964 | } | ||
| 1965 | |||
| 1966 | // ======== | ||
| 1926 | // Generate macro-tables | 1967 | // Generate macro-tables |
| 1927 | 1968 | ||
| 1928 | for irq in METADATA.interrupts { | 1969 | for irq in METADATA.interrupts { |
