Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program option bytes on STM32G4xx
#2
What you have to do:

- Add at the end of the EBlink XML memory map the sector with the option base address and right length
- Give that sector a fake number e.g. 999 (something which is out of range of normal flash) 
- Give that sector a virtual attribute to exclude it from the EBlink caching algorithm (property sectype = virtual)
- In the EBlink erase function filter on sector number 999 to skip normal flash erase function
- In the EBlink flash write function filter on sector number 999 and jump to a new to create function e.g. "option_write"
- Create new "option_write" function with the right algorithm to program option bytes

Check the script code for the stm32h7 which supports option programming. e.g. Memory map H7:
Code:
const mem_template_H7 = @@"
<?xml version=\"1.0\"?> <memory-map>

    <snip...>
 
    <!-- option byte area (virtual sector) -->
    <memory type=\"flash\" start=\"0x1ff20000\" length=\"32\">
        <property name=\"blocksize\">32</property>
        <property name=\"secstart\">999</property>
        <property name=\"sectype\">virtual</property>
    </memory>
</memory-map>"

H7 erase function:
Code:
function flash_erase(sector, address)
{
    local regbase = FLASH_REG_BASE_B0 // first flash bank

    // Skip the virtual option sector
    if(sector == 999)
      return ERROR_OK
   
     <snip...>
}


H7 write function:
Code:
function flash_write(sector, address, buffer)
{
    local regbase = FLASH_REG_BASE_B0 // first flash bank

    // If this is the virtual option sector, go to options write function
    if(sector == 999)
      return option_write(buffer)

    <snip...>
}

H7 option_write:
Code:
function option_write(buffer)
{
   <snip...>
}


Last but not least, if everything works: share it.

P.s. It's not much work but currently I'm a bit busy.


Attached Files
.zip   stm32h7_options.zip (Size: 3.73 KB / Downloads: 70)
Reply


Messages In This Thread
Program option bytes on STM32G4xx - by matsb - 22-11-2022, 12:59 PM
RE: Program option bytes on STM32G4xx - by embitz - 23-11-2022, 09:38 AM
RE: Program option bytes on STM32G4xx - by matsb - 24-11-2022, 09:10 AM
RE: Program option bytes on STM32G4xx - by embitz - 24-11-2022, 10:52 AM
RE: Program option bytes on STM32G4xx - by matsb - 25-11-2022, 03:27 PM
RE: Program option bytes on STM32G4xx - by embitz - 25-11-2022, 07:36 PM
RE: Program option bytes on STM32G4xx - by mri - 25-11-2022, 09:03 PM
RE: Program option bytes on STM32G4xx - by embitz - 25-11-2022, 09:14 PM
RE: Program option bytes on STM32G4xx - by embitz - 25-11-2022, 09:20 PM
RE: Program option bytes on STM32G4xx - by mri - 25-11-2022, 10:38 PM
RE: Program option bytes on STM32G4xx - by embitz - 26-11-2022, 04:11 PM
RE: Program option bytes on STM32G4xx - by matsb - 28-11-2022, 09:48 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)