[mbedmicro/pyOCD] WIP: Added STM32L072xZ target (#480)

3 views
Skip to first unread message

Kwinten Schram

unread,
Dec 19, 2018, 11:14:21 AM12/19/18
to mbedmicro/pyOCD, Subscribed

I attempted to add a new target board. I get following error message while attempting to program the board.

pyocd flash -t stm32L072xz modem.bin -v -e chip
0000203:INFO:board:Target type is stm32l072xz
0000218:INFO:dap:DP IDR = 0x0bc11477
0000229:INFO:dap:AP#0 IDR = 0x04770031
0000243:INFO:rom_table:AP#0 ROM table #0 @ 0xf0000000 (designer=020 part=447)
0000257:INFO:rom_table:[0]<e00ff000:ROM class=1 designer=43b part=4c0>
0000257:INFO:rom_table:  AP#0 ROM table #1 @ 0xe00ff000 (designer=43b part=4c0)
0000271:INFO:rom_table:  [0]<e000e000:SCS-M0+ class=14 designer=43b part=008>
0000280:INFO:rom_table:  [1]<e0001000:DWT-M0+ class=14 designer=43b part=00a>
0000290:INFO:rom_table:  [2]<e0002000:BPU class=14 designer=43b part=00b>
0000294:INFO:cortex_m:CPU core is Cortex-M0+ r0p1
0000308:INFO:dwt:2 hardware watchpoints
0000315:INFO:fpb:4 hardware breakpoints, 0 literal comparators
[                    ]   0%0000633:ERROR:flash:program_page(0x8000000) error: 1
[                    ]   2%0000799:ERROR:flash:program_page(0x8000400) error: 1
[                    ]   4%0000967:ERROR:flash:program_page(0x8000800) error: 1
[                    ]   5%0001134:ERROR:flash:program_page(0x8000c00) error: 1
[=                   ]   6%0001303:ERROR:flash:program_page(0x8001000) error: 1
[=                   ]   7%0001470:ERROR:flash:program_page(0x8001400) error: 1
[=                   ]   8%0001638:ERROR:flash:program_page(0x8001800) error: 1
[=                   ]   9%0001805:ERROR:flash:program_page(0x8001c00) error: 1
[==                  ]  10%0001974:ERROR:flash:program_page(0x8002000) error: 1
[==                  ]  11%0002142:ERROR:flash:program_page(0x8002400) error: 1
[==                  ]  12%0002309:ERROR:flash:program_page(0x8002800) error: 1
[==                  ]  14%0002476:ERROR:flash:program_page(0x8002c00) error: 1
[==                  ]  15%0002644:ERROR:flash:program_page(0x8003000) error: 1
[===                 ]  16%0002812:ERROR:flash:program_page(0x8003400) error: 1
[===                 ]  17%0002978:ERROR:flash:program_page(0x8003800) error: 1
[===                 ]  18%0003146:ERROR:flash:program_page(0x8003c00) error: 1
[===                 ]  19%0003313:ERROR:flash:program_page(0x8004000) error: 1
[====                ]  20%0003481:ERROR:flash:program_page(0x8004400) error: 1
[====                ]  21%0003648:ERROR:flash:program_page(0x8004800) error: 1
[====                ]  23%0003815:ERROR:flash:program_page(0x8004c00) error: 1
[====                ]  24%0003986:ERROR:flash:program_page(0x8005000) error: 1
[====                ]  25%0004157:ERROR:flash:program_page(0x8005400) error: 1
[=====               ]  26%0004327:ERROR:flash:program_page(0x8005800) error: 1
[=====               ]  27%0004495:ERROR:flash:program_page(0x8005c00) error: 1
[=====               ]  28%0004665:ERROR:flash:program_page(0x8006000) error: 1
[=====               ]  29%0004832:ERROR:flash:program_page(0x8006400) error: 1
[======              ]  30%0005003:ERROR:flash:program_page(0x8006800) error: 1
[======              ]  32%0005169:ERROR:flash:program_page(0x8006c00) error: 1
[======              ]  33%0005337:ERROR:flash:program_page(0x8007000) error: 1
[======              ]  34%0005504:ERROR:flash:program_page(0x8007400) error: 1
[======              ]  35%0005672:ERROR:flash:program_page(0x8007800) error: 1
[=======             ]  36%0005841:ERROR:flash:program_page(0x8007c00) error: 1
[=======             ]  37%0006007:ERROR:flash:program_page(0x8008000) error: 1
[=======             ]  38%0006175:ERROR:flash:program_page(0x8008400) error: 1
[=======             ]  39%0006341:ERROR:flash:program_page(0x8008800) error: 1
[========            ]  41%0006509:ERROR:flash:program_page(0x8008c00) error: 1
[========            ]  42%0006676:ERROR:flash:program_page(0x8009000) error: 1
[========            ]  43%0006844:ERROR:flash:program_page(0x8009400) error: 1
[========            ]  44%0007012:ERROR:flash:program_page(0x8009800) error: 1
[=========           ]  45%0007179:ERROR:flash:program_page(0x8009c00) error: 1
[=========           ]  46%0007348:ERROR:flash:program_page(0x800a000) error: 1
[=========           ]  47%0007515:ERROR:flash:program_page(0x800a400) error: 1
[=========           ]  48%0007684:ERROR:flash:program_page(0x800a800) error: 1
[=========           ]  50%0007851:ERROR:flash:program_page(0x800ac00) error: 1
[==========          ]  51%0008019:ERROR:flash:program_page(0x800b000) error: 1
[==========          ]  52%0008187:ERROR:flash:program_page(0x800b400) error: 1
[==========          ]  53%0008356:ERROR:flash:program_page(0x800b800) error: 1
[==========          ]  54%0008522:ERROR:flash:program_page(0x800bc00) error: 1
[===========         ]  55%0008690:ERROR:flash:program_page(0x800c000) error: 1
[===========         ]  56%0008860:ERROR:flash:program_page(0x800c400) error: 1
[===========         ]  57%0009024:ERROR:flash:program_page(0x800c800) error: 1
[===========         ]  59%0009190:ERROR:flash:program_page(0x800cc00) error: 1
[===========         ]  60%0009360:ERROR:flash:program_page(0x800d000) error: 1
[============        ]  61%0009528:ERROR:flash:program_page(0x800d400) error: 1
[============        ]  62%0009697:ERROR:flash:program_page(0x800d800) error: 1
[============        ]  63%0009866:ERROR:flash:program_page(0x800dc00) error: 1
[============        ]  64%0010030:ERROR:flash:program_page(0x800e000) error: 1
[=============       ]  65%0010198:ERROR:flash:program_page(0x800e400) error: 1
[=============       ]  66%0010367:ERROR:flash:program_page(0x800e800) error: 1
[=============       ]  68%0010534:ERROR:flash:program_page(0x800ec00) error: 1
[=============       ]  69%0010703:ERROR:flash:program_page(0x800f000) error: 1
[=============       ]  70%0010871:ERROR:flash:program_page(0x800f400) error: 1
[==============      ]  71%0011039:ERROR:flash:program_page(0x800f800) error: 1
[==============      ]  72%0011206:ERROR:flash:program_page(0x800fc00) error: 1
[==============      ]  73%0011374:ERROR:flash:program_page(0x8010000) error: 1
[==============      ]  74%0011541:ERROR:flash:program_page(0x8010400) error: 1
[===============     ]  75%0011712:ERROR:flash:program_page(0x8010800) error: 1
[===============     ]  77%0011883:ERROR:flash:program_page(0x8010c00) error: 1
[===============     ]  78%0012052:ERROR:flash:program_page(0x8011000) error: 1
[===============     ]  79%0012221:ERROR:flash:program_page(0x8011400) error: 1
[===============     ]  80%0012388:ERROR:flash:program_page(0x8011800) error: 1
[================    ]  81%0012555:ERROR:flash:program_page(0x8011c00) error: 1
[================    ]  82%0012723:ERROR:flash:program_page(0x8012000) error: 1
[================    ]  83%0012891:ERROR:flash:program_page(0x8012400) error: 1
[================    ]  84%0013060:ERROR:flash:program_page(0x8012800) error: 1
[=================   ]  86%0013230:ERROR:flash:program_page(0x8012c00) error: 1
[=================   ]  87%0013397:ERROR:flash:program_page(0x8013000) error: 1
[=================   ]  88%0013564:ERROR:flash:program_page(0x8013400) error: 1
[=================   ]  89%0013732:ERROR:flash:program_page(0x8013800) error: 1
[==================  ]  90%0013899:ERROR:flash:program_page(0x8013c00) error: 1
[==================  ]  91%0014065:ERROR:flash:program_page(0x8014000) error: 1
[==================  ]  92%0014233:ERROR:flash:program_page(0x8014400) error: 1
[==================  ]  93%0014401:ERROR:flash:program_page(0x8014800) error: 1
[==================  ]  95%0014565:ERROR:flash:program_page(0x8014c00) error: 1
[=================== ]  96%0014734:ERROR:flash:program_page(0x8015000) error: 1
[=================== ]  97%0014900:ERROR:flash:program_page(0x8015400) error: 1
[=================== ]  98%0015068:ERROR:flash:program_page(0x8015800) error: 1
[=================== ]  99%0015128:ERROR:flash:program_page(0x8015c00) error: 1
[====================] 100%
0015149:INFO:loader:Programmed 89168 bytes (88 pages) at 5.87 kB/s (0 pages unchanged)

Was able to verify that the initial writes in setup_dbgmcu to write did work (was able to read the written values). Erasing the chip does not work.

Any idea what the problem might be?


You can view, comment on, or merge this pull request online at:

  https://github.com/mbedmicro/pyOCD/pull/480

Commit Summary

  • Added STM32L072xZ target

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Chris Reed

unread,
Dec 19, 2018, 1:05:08 PM12/19/18
to mbedmicro/pyOCD, Subscribed

Hi @KwintenSchram! How did you generate the flash algo blob, by using the generate_blobs.py script from the FlashAlgo repo to generate it from an .FLM file in a CMSIS DFP? If so, there is a possibility that pyOCD is currently incompatible with the algo. Basically, some flash algos require that the operation to be performed (i.e. sector erase) be passed into the Init() function. PyOCD currently calls Init() once for all operations, passing 0 for the operation. This works for most algos, but not all. See #349 for details. If this is the problem, I don't have an immediate solution for you, but it will be fixed pretty soon because it is required for CMSIS DFP support (#357).

Btw, you should run the full functional test suite to verify target support. The main script is test/automated_test.py, but you can run individual tests like flash_test.py by themselves. flash_test.py performs much more extensive testing of the flash algo. To enable this:

  • Add an LED blinky test binary to the binaries/ folder. (Please commit the test binary.)
  • (Assuming you are using STLink) Create a test/test_boards.yaml config file that tells pyOCD the target type and test binary name for the probe's unique ID. For example:
    probes:
      066EFF525750877267024521: # probe uid
        target_override: stm32l072xz
        test_binary: nucleo_l072xz.bin # whatever your test binary name is

Kwinten Schram

unread,
Dec 20, 2018, 5:35:12 AM12/20/18
to mbedmicro/pyOCD, Push

@KwintenSchram pushed 1 commit.

  • d23cb50 Added test program for stm32L072xz


You are receiving this because you are subscribed to this thread.

View it on GitHub or mute the thread.

Kwinten Schram

unread,
Dec 20, 2018, 5:51:41 AM12/20/18
to mbedmicro/pyOCD, Subscribed

Thanks for the quick response!

I did indeed use the generate_blobs.py script to generate the flash algo. I used the STM32L0xx_192.FLM file I got from the Keil Pack installer.
I ran the full functional test suite and got following result: test_log.txt

Does this verify the unsupported flash algo theory?

Chris Reed

unread,
Dec 20, 2018, 1:08:17 PM12/20/18
to mbedmicro/pyOCD, Subscribed

It does look like erase operations are successful, and only program operations are failing. This might indicate that theory doesn't apply, but it's not conclusive.

I did notice that the block size and min_program_size are incorrect. I'll add comments on the code.

Chris Reed

unread,
Dec 20, 2018, 1:09:00 PM12/20/18
to mbedmicro/pyOCD, Subscribed

@flit commented on this pull request.


In pyocd/target/target_STM32L072xx.py:

> +    0x6861bdf0, 0x606143a9, 0x43b16861, 0x1c5b6061, 0xd8d8459c, 0xbdf02000, 0x40022000, 0x89abcdef,
+    0x02030405, 0x8c9daebf, 0x13141516, 0x00005555, 0x40003000, 0x00000fff, 0x0000aaaa, 0x00000000
+    ],
+
+    # Relative function addresses
+    'pc_init': 0x20000021,
+    'pc_unInit': 0x2000005d,
+    'pc_program_page': 0x200000b5,
+    'pc_erase_sector': 0x2000007b,
+    'pc_eraseAll': 0x12000001f,
+
+    'static_base' : 0x20000000 + 0x00000020 + 0x0000011c,
+    'begin_stack' : 0x20000400,
+    'begin_data' : 0x20000000 + 0x1000,
+	'page_buffers' : [0x20001000],
+	'min_program_length' : 0x400,

min_program_length should be 4 according to the user manual.

Chris Reed

unread,
Dec 20, 2018, 1:15:10 PM12/20/18
to mbedmicro/pyOCD, Subscribed

@flit commented on this pull request.


In pyocd/target/target_STM32L072xx.py:

> +        seq.insert_after('create_cores',
+            ('setup_dbgmcu', self.setup_dbgmcu)
+            )
+
+        return seq
+
+    def setup_dbgmcu(self):
+        self.write32(DBGMCU.CR, DBGMCU.CR_VALUE)
+        self.write32(DBGMCU.APB1FZ, DBGMCU.APB1FZ_VALUE)
+        self.write32(DBGMCU.APB2FZ, DBGMCU.APB2FZ_VALUE)
+
+
+class STM32L072xZ(STM32L072xx):
+
+    memoryMap = MemoryMap(
+        FlashRegion(start=0x08000000, length=0x30000, blocksize=0x400,  is_boot_memory=True, algo=FLASH_ALGO),

The blocksize should be 0x80, equal to the erase page size from the user manual.

You might want to add regions for the boot memory (starting at address 0), EEPROM, system memory, factory options, and user options. If you add a flash algo for the user options, set is_testable to False so the flash test doesn't try to write to those regions.

Chris Reed

unread,
Dec 20, 2018, 1:17:13 PM12/20/18
to mbedmicro/pyOCD, Subscribed

One interesting thing from the test log are the error: integer out of range for 'I' format code exceptions reported during the gdb test. I'm looking into this.

Chris Reed

unread,
Feb 26, 2019, 7:25:20 PM2/26/19
to mbedmicro/pyOCD, Subscribed

You should try the new CMSIS-Pack support.

Kwinten Schram

unread,
Feb 26, 2019, 8:00:48 PM2/26/19
to mbedmicro/pyOCD, Subscribed

I will! Thanks for letting me know. Sorry for the lack of response. Back then the problem still persisted after your suggested corrections.

Chris Reed

unread,
Apr 16, 2019, 5:45:53 PM4/16/19
to mbedmicro/pyOCD, Subscribed

Closed #480.

Chris Reed

unread,
Apr 16, 2019, 5:45:54 PM4/16/19
to mbedmicro/pyOCD, Subscribed

I'm closing this PR for now. If you revive it, please reopen.

Reply all
Reply to author
Forward
0 new messages