# MANUAL EDIT: Prepended four 00 bytes to the start of the 2048 flash algorithm
# instructions and offset all pointers by 4 to match. For some unknown reason
# the instructions cause the final 12 bytes of each 512-byte page to be
# corrupted (with the final 8 bytes being written with the 8 bytes that should
# have been written to the previous sector) whenever the instructions are
# loaded at memory offset 04, or 24, 44, etc. Other (4-byte-aligned) offsets
# are all OK. Since we have a flash algorithm header that's 4 bytes (the two
# BKPT instructions) and start loading at the start of RAM, the normal code
# address is 2040_0004, which triggers the bug. By offsetting the instructions
# with some nulls, we work around the problem.
# Note that this is reproducible in PyOCD if the allocator is changed to place
# the instructions at the start of ram instead of at the end, and the location
# of the page buffers and stack doesn't affect the bug. It seems to be isolated
# to the load address of the algorithm instructions and thus is probably a bug
# in the flash algorithm.
---
name: SAMV71
manufacturer:
  id: 0x1f
  cc: 0x0
variants:
- name: ATSAMV71J19
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x480000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20440000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71J19B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x480000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20440000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71J20
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x500000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71J20B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x500000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71J21
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x600000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71J21B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x600000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71N19
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x480000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20440000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71N19B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x480000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20440000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71N20
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x500000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71N20B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x500000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71N21
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x600000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71N21B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x600000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71Q19
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x480000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20440000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71Q19B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x480000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20440000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71Q20
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x500000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71Q20B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x500000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71Q21
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x600000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
- name: ATSAMV71Q21B
  cores:
  - name: main
    type: armv7em
    core_access_options: !Arm
      ap: !v1 0
  memory_map:
  - !Nvm
    name: IROM1
    range:
      start: 0x400000
      end: 0x600000
    cores:
    - main
    access:
      boot: true
  - !Generic
    name: IROM2
    range:
      start: 0x800000
      end: 0x804000
    cores:
    - main
  - !Ram
    name: IRAM1
    range:
      start: 0x20400000
      end: 0x20460000
    cores:
    - main
  flash_algorithms:
  - atsamv7x_2048
  - atsamv7x_gpnvm
flash_algorithms:
- name: atsamv7x_2048
  description: ATSAMV7x 2048kB Flash
  default: true
  instructions: AAAAAGBJMLVJRAhgYElfSAhgT/RwYF5J5DkIYE/0AEBcSQhgW0mwMQhgXEtaSBhgWkq0OhBoIPADAEAcEGBXSHw4AWgJB/zVEWgh8HABEWABaAkH/NVRTMQ8IWhQTSlDIWABaIkD/NUhaE1NIfBwARg1KUMhYCFoIfCAcUH0XBEhYAFoyQP81RFoIfADAUkcEWABaAkH/NUBIRFgAWgJB/zVPUhAHBhgACAwvQIoFNE3SjxI4DoQYBAdAWjJB/zQM0nYOQloiQcH1DZJ/jERYADgAL8BaMkH+9AtSStIQBwIYAAgcEcvSClJCDjgOQhgCB0A4AC/AWjJB/vQACBwRyFKI0lKROQ5EmiAGkAKIPADAIAcgrIjSAAfQOoCIEhgAOAAv4howAf70B5IgB9A6gIgSGAA4AC/iGjAB/vQiGgQ8A4AANABIHBHD0kwtUlED0vkOwloQRpMClkVIMoJHyDA+9EPSaCyDDlB6gAgWGAA4AC/mGjAB/vQmGgQ8A4AANABIDC9AAAEAAAAAENGReQMDkBUGA5AAENNUOQGDkAIADcADQAAWgAAAAAAAAAA
  pc_init: 0x5
  pc_uninit: 0xad
  pc_program_page: 0x14b
  pc_erase_sector: 0x101
  pc_erase_all: 0xe7
  data_section_offset: 0x1a8
  flash_properties:
    address_range:
      start: 0x400000
      end: 0x600000
    page_size: 0x200
    erased_byte_value: 0xff
    program_page_timeout: 100
    erase_sector_timeout: 1000
    sectors:
    - size: 0x2000
      address: 0x0
  cores:
  - main
- name: atsamv7x_gpnvm
  description: ATSAMV7x GPNVM bits
  instructions: gkkwtUlECGCCSYFICGBP9HBggEnkOQhgT/QAQH5JCGB9SbAxCGB+S3xIGGB8SrQ6EGgg8AMAQBwQYHlIfDgBaAkH/NURaCHwcAERYAFoCQf81XNMxDwhaHJNKUMhYAFoiQP81SFob00h8HABGDUpQyFgIWgh8IBxQfRcESFgAWjJA/zVEWgh8AMBSRwRYAFoCQf81QEhEWABaAkH/NVfSEAcGGAAIDC9WklZSEAcCGAAIHBHACBwRwAgcEdTSlVJSkTkORJogBpACiDwAwCAHIKyVUhA6gIgSGAA4AC/iGjAB/vQUEiAHkDqAiBIYADgAL+IaMAH+9CIaBDwDgAA0AEgcEcwtUhJEGhCSgkd4DoRYBMdGWjJB/zQPknYOQloxAe068F/DNDEBwLQPkykHAHgPUzkHBRgAOAAvxxo5Af70ADwAgQB8AIFrEIL0IQHAdU2TAHgNUxkHBRgAOAAvxxo5Af70ADwgAQB8IAFrEIL0AQGAdUuTAHgLUxkHBRgAOAAvxxo5Af70AD0gHQB9IBxjEIL0MAFAdUmSAHgJUhAHBBgAOAAvxhowAf70AAgML0wtRxLF0wbHRJo4DwjYCMdHGjkB/zQEkvYOxto1Ae068N/BtEC8AIEA/ACBaxCAdBAHDC9AvCABAPwgAWsQgHQwB0wvQL0gHID9IBzmkIB0AgwML0IRDC9AAAEAAAAAENGReQMDkBUGA5AAENNUOQGDkAIADcACQAAWgsBAFoLBwBaCwgAWgAAAAAAAAAA
  pc_init: 0x1
  pc_uninit: 0xa9
  pc_program_page: 0x105
  pc_erase_sector: 0xbd
  pc_erase_all: 0xb9
  data_section_offset: 0x238
  flash_properties:
    address_range:
      start: 0x1ffffff0
      end: 0x20000000
    page_size: 0x10
    erased_byte_value: 0xff
    program_page_timeout: 100
    erase_sector_timeout: 1000
    sectors:
    - size: 0x10
      address: 0x0
  cores:
  - main
