)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"48b2c5387a9b0df1b59c572e35b45e20d3d8dd39","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":2,"id":"2c5f206b_00138d1a","updated":"2023-08-31 11:52:57.000000000","message":"Minor cosmetic fixed","commit_id":"f7ecf11e28e0815d9c2ead308b4678ca5e246e4f"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"6cd35af750fe9bb158662f0939fea006e489ce8d","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":6,"id":"936956b3_7cd6c7f6","updated":"2023-08-31 16:53:32.000000000","message":"Benjamin,\nyou based your work on Nuvoton NPCX flash driver.\nI have no idea why you selected NPCX but I\u0027m sorry, it was very unfortunate choice. NPCX is in fact a SPI flash specific driver, but does not use OpenOCD\nspi.[ch] infrastructure. The \u0027command interpreter\u0027 target algorithm is a total overkill and the way the driver controls target algo starting/stopping is at least suboptimal. IMO NPCX flash driver should have not been merged in such messy state.\n\nYou folded the SPI flash driver back to handle an internal flash - including such funny thinks like generating a fake flash ID and running the target algo to get it. Sorry, we cannot accept such code. Although the driver may work it would make the longterm OpenOCD maintenance difficult or impossible.\n\nIf you want to start over and rewrite the flash driver, I have some tips:\n- sector erase is usually fast enough without target algo, directly\ncontrolled from OpenOCD code\n- avoid running target algo at probe time\n- programming usually needs a target algo - the simpler the better.\nThe best for programming speed is async algo. For flash sizes \u003c\u003d 64k writing\nin chunks may be sufficiently fast.\nSee e.g. src/flash/nor/stm32l4x.c for proper work area and algo control flow and contrib/loaders/flash/stm32/stm32l4x.c to see how to write a loader in C without requiring fixed load address.\n\nBTW Read \nhttps://openocd.org/doc/doxygen/html/patchguide.html#stepbystep\nhow to format the commit message.","commit_id":"51ace439604d771a374406d0cbdc3b7ecc487708"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"6c85fb67b254cabbec409234fa926243c967daaa","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":6,"id":"596f3052_c5136f09","in_reply_to":"05c5c765_b6076b36","updated":"2023-09-04 11:35:09.000000000","message":"Done","commit_id":"51ace439604d771a374406d0cbdc3b7ecc487708"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"b19c7b101c891c92a20c813f13a2c0785ddb2e17","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":6,"id":"b1594708_9d90e52b","in_reply_to":"936956b3_7cd6c7f6","updated":"2023-09-01 06:20:09.000000000","message":"Hi Tomas,\n\nThanks for your fast feedback.\n\nI\u0027m confused as I do not really understand your point towards this flash driver for cx32l003 series.\n\nEven if I was inspired by the NPCX code (as it was the best I have found all other I have checked are overcomplicated for such simple MCU flash) to do my code you can check my final code is clean and very fast for example (with a STM32F429I-DISCO converted as JLink Probe):\nErasing all 128 sectors (64KB) take less than 10 milliseconds especially for such MCU CX32L003 which have maximum 64KB flash, Programming is also very fast.\n\nAbout \"including such funny thinks like generating a fake flash ID\":\nI have added that as maybe one day we could find a way to find the flash size from the MCU to be not static so it is a good things to keep it like that, it allow also to validate the MCU work fine before to continue on Erase / Flash algorithm.\n\nAbout your point to rewrite all without target algorithm I\u0027m not agree as it will requires to spend lot of time (rewriting/testing again all that stuff) without any gain and to have something slower at end and potentially less reliable than like actual solution which execute firmware code in SRAM for Flash Erase \u0026 Flash Programming.\n\nNote: I have checked src/flash/nor/stm32l4x.c and it is clearly \"overcomplicated\" to be used as template for simple MCU like CX32L003.\n\nCould you reconsider that contribution to be accepted (with minor modifications if your want) as I doubt anyone except me will do any change for that MCU ?\n\nBest Regards,\nBenjamin VERNOUX","commit_id":"51ace439604d771a374406d0cbdc3b7ecc487708"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"4a5f60b8d1f9bdaaef8ba384f06122174639e575","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":6,"id":"e80055a7_ff9e0489","in_reply_to":"b1594708_9d90e52b","updated":"2023-09-01 09:07:43.000000000","message":"\u003e About \"including such funny thinks like generating a fake flash ID\":\n\u003e I have added that as maybe one day we could find a way to find the flash size from the MCU\n\nThe device should be identified in probe() code without running an algo on the target. probe() is called during gdb attach and should not interfere with a target app.\n\n\u003e Note: I have checked src/flash/nor/stm32l4x.c and it is clearly \"overcomplicated\" to be used as template for simple MCU like CX32L003.\n\nI admit the stm32l4x.c code is COMPLICATED (but not overcomplicated), because it handles lot of slightly different devices, controls complicated write and read out protection schemes, have some additional commands and workarounds of silicon errata.\n\nIf you want to see a really simplistic flash driver, look at src/flash/nor/swm050.c\nThe driver has 197 lines of code (in comparison to more than 1200 lines of your contribution). I admit swm050 has no target loader (it does not need it).\n\nUnfortunately we don\u0027t have a template code for a new flash driver.\nMost of frequently used and well tuned flash drivers got rather complicated over\nyears as they support lot of devices.\n\n\u003e Could you reconsider that contribution to be accepted (with minor modifications if your want) as I doubt anyone except me will do any change for that MCU ?\n\nMy experience from OpenOCD project warn me: the bad code is often copied and used to support a new device. I regret the npcx code slipped around me.\nI have to say stop here.\n\nI know you spent considerable time working on the driver and I appreciate it.\nBut I\u0027m asking for further work... maybe it would be easier than it looks now. Please reduce your code to lets say 400-500 lines and fix conceptually wrong parts.\n\nOr alternatively wait for OpenOCD support of Open-CMSIS-Pack flash programming (though I\u0027m not aware of anybody working on this) and then write CMSIS-Pack compatible device support.\n\nThanks for understanding.","commit_id":"51ace439604d771a374406d0cbdc3b7ecc487708"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"3a33ddf93734a65c98b2902c1b7f5b7b76cdb62e","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":6,"id":"05c5c765_b6076b36","in_reply_to":"e80055a7_ff9e0489","updated":"2023-09-02 19:44:57.000000000","message":"I have done a new version using swm050.c as template which is quite clean and using only some target_write_u32() / target_read_u32() rewriting erase/program, the main issue is when it works it\u0027s so slow and it is not reliable as after erasing \u0026 programming an application(with success) next time I reset and I want to program a new application the sector erase just fail with an error target_read_u32() fail.\n\nSee https://hydrabus.com/openocd_cx32l003/openocd_cx32l003_noalgo_02Sep2023_src.7z\n\nSee an example of the performances with this new version without algorithm executed in MCU (all done with openocd API target_write_u32() / target_read_u32()):\n\u003e program uart_print.elf verify\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x41000003 pc: 0x20000022 msp: 0x20000bf8\n** Programming Started **\nAdding extra erase range, 0x00002f64 .. 0x00002fff\ncx32l003_erase bank\u003d00000194c3fd4ed0 first\u003d0 last\u003d23\ncx32l003_erase retval\u003d0 elapsed_ms\u003d225\ncx32l003_write bank\u003d00000194c3fd4ed0 buffer\u003d00000194c4038f40 offset\u003d0x00000000 count\u003d12132\ncx32l003_write retval\u003d0 elapsed_ms\u003d21154\n** Programming Finished **\n** Verify Started **\n** Verified OK **\n\nLike you can see for a program with only 12132 bytes it take more than 21s especially the programming is very long.\n\nThe main blocker with that version is not only it is ultra slow but we cannot erase sector again after poweroff/poweron even with reset;halt ... with target_read_u32() fail all the time ...\nSee log extract:\n\u003e reset;halt\nDisabling watchdog...\n[cx32l003.cpu] clearing lockup after double fault\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x21000003 pc: 0xfffffffe msp: 0x20000b70\nPolling target cx32l003.cpu failed, trying to reexamine\n[cx32l003.cpu] Cortex-M0+ r0p1 processor detected\n[cx32l003.cpu] target has 4 breakpoints, 2 watchpoints\nDisabling watchdog..\n\n\u003e program uart_print.elf verify\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x21000003 pc: 0xfffffffe msp: 0x20000b70\n** Programming Started **\nAdding extra erase range, 0x00002f64 .. 0x00002fff\ncx32l003_erase first\u003d0 last\u003d23\nSWD DPIDR 0x0bc11477\nFailed to read memory and, additionally, failed to find out where\ncx32l003_flash_erase_sector: target_read_u32() fail\nSWD DPIDR 0x0bc11477\nfailed erasing sectors 0 to 23\nembedded:startup.tcl:1524: Error: ** Programming Failed **\nin procedure \u0027program\u0027\nin procedure \u0027program_error\u0027 called at file \"embedded:startup.tcl\", line 1589\nat file \"embedded:startup.tcl\", line 1524\n\nWith actual version in this PR (I have added some code to measure performances) using algorithm for erase/programming I obtain following logs:\nSee https://hydrabus.com/openocd_cx32l003/openocd_cx32l003_algo_02Sep2023_src.7z\n\n\u003e reset;halt\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x41000000 pc: 0x20000478 msp: 0x20000800\n\n\u003e program uart_print.elf verify\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x41000000 pc: 0x20000478 msp: 0x20000800\n** Programming Started **\nAdding extra erase range, 0x00002f64 .. 0x00002fff\ncx32l003_erase first\u003d0 last\u003d23\ncx32l003_erase retval\u003d0 elapsed_ms\u003d84\ncx32l003_write buffer\u003d000001beca98cc70 offset\u003d0x00000000 count\u003d12132\ncx32l003_write retval\u003d0 elapsed_ms\u003d391\n** Programming Finished **\n** Verify Started **\n** Verified OK **\nTo erase and program 12132 bytes it take less than 0.5s vs 21s \u003d\u003e So 42 times faster\n\nof course I can erase/program it again after poweroff/poweron even with worst case scenario with full flash loaded 65536 bytes (which take about 2s when it will take more than 60s with the no algo version if it will work)\n\u003etelnet 127.0.0.1 4444\nTrying 127.0.0.1...\nConnected to 127.0.0.1.\nEscape character is \u0027^]\u0027.\nOpen On-Chip Debugger\n\u003e reset;halt\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x81000000 pc: 0x00000554 msp: 0x20000fe8\n\n\u003e program xxx.bin verify\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x81000000 pc: 0x00000554 msp: 0x20000fe8\n** Programming Started **\ncx32l003_mass_erase\ncx32l003_mass_erase retval\u003d0 elapsed_ms\u003d345\ncx32l003 mass erase complete\ncx32l003_write buffer\u003d000001c1bf058d10 offset\u003d0x00000000 count\u003d65536\ncx32l003_write retval\u003d0 elapsed_ms\u003d1999\n** Programming Finished **\n** Verify Started **\n** Verified OK **","commit_id":"51ace439604d771a374406d0cbdc3b7ecc487708"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"3a33ddf93734a65c98b2902c1b7f5b7b76cdb62e","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":9,"id":"488ecf57_0896d293","updated":"2023-09-02 19:44:57.000000000","message":"I have done a new version using swm050.c as template which is quite clean and using only some target_write_u32() / target_read_u32() rewriting erase/program, the main issue is when it works it\u0027s so slow and it is not reliable as after erasing \u0026 programming an application(with success) next time I reset and I want to program a new application the sector erase just fail with an error target_read_u32() fail.\n\nSee https://hydrabus.com/openocd_cx32l003/openocd_cx32l003_noalgo_02Sep2023_src.7z\n\nSee an example of the performances with this new version without algorithm executed in MCU (all done with openocd API target_write_u32() / target_read_u32()):\n\u003e program uart_print.elf verify\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x41000003 pc: 0x20000022 msp: 0x20000bf8\n** Programming Started **\nAdding extra erase range, 0x00002f64 .. 0x00002fff\ncx32l003_erase bank\u003d00000194c3fd4ed0 first\u003d0 last\u003d23\ncx32l003_erase retval\u003d0 elapsed_ms\u003d225\ncx32l003_write bank\u003d00000194c3fd4ed0 buffer\u003d00000194c4038f40 offset\u003d0x00000000 count\u003d12132\ncx32l003_write retval\u003d0 elapsed_ms\u003d21154\n** Programming Finished **\n** Verify Started **\n** Verified OK **\n\nLike you can see for a program with only 12132 bytes it take more than 21s especially the programming is very long.\n\nThe main blocker with that version is not only it is ultra slow but we cannot erase sector again after poweroff/poweron even with reset;halt ... with target_read_u32() fail all the time ...\nSee log extract:\n\u003e reset;halt\nDisabling watchdog...\n[cx32l003.cpu] clearing lockup after double fault\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x21000003 pc: 0xfffffffe msp: 0x20000b70\nPolling target cx32l003.cpu failed, trying to reexamine\n[cx32l003.cpu] Cortex-M0+ r0p1 processor detected\n[cx32l003.cpu] target has 4 breakpoints, 2 watchpoints\nDisabling watchdog..\n\n\u003e program uart_print.elf verify\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x21000003 pc: 0xfffffffe msp: 0x20000b70\n** Programming Started **\nAdding extra erase range, 0x00002f64 .. 0x00002fff\ncx32l003_erase first\u003d0 last\u003d23\nSWD DPIDR 0x0bc11477\nFailed to read memory and, additionally, failed to find out where\ncx32l003_flash_erase_sector: target_read_u32() fail\nSWD DPIDR 0x0bc11477\nfailed erasing sectors 0 to 23\nembedded:startup.tcl:1524: Error: ** Programming Failed **\nin procedure \u0027program\u0027\nin procedure \u0027program_error\u0027 called at file \"embedded:startup.tcl\", line 1589\nat file \"embedded:startup.tcl\", line 1524\n\nWith actual version in this PR (I have added some code to measure performances) using algorithm for erase/programming I obtain following logs:\nSee https://hydrabus.com/openocd_cx32l003/openocd_cx32l003_algo_02Sep2023_src.7z\n\n\u003e reset;halt\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x41000000 pc: 0x20000478 msp: 0x20000800\n\n\u003e program uart_print.elf verify\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x41000000 pc: 0x20000478 msp: 0x20000800\n** Programming Started **\nAdding extra erase range, 0x00002f64 .. 0x00002fff\ncx32l003_erase first\u003d0 last\u003d23\ncx32l003_erase retval\u003d0 elapsed_ms\u003d84\ncx32l003_write buffer\u003d000001beca98cc70 offset\u003d0x00000000 count\u003d12132\ncx32l003_write retval\u003d0 elapsed_ms\u003d391\n** Programming Finished **\n** Verify Started **\n** Verified OK **\nTo erase and program 12132 bytes it take less than 0.5s vs 21s \u003d\u003e So 42 times faster\n\nof course I can erase/program it again after poweroff/poweron even with worst case scenario with full flash loaded 65536 bytes (which take about 2s when it will take more than 60s with the no algo version if it will work)\n\u003etelnet 127.0.0.1 4444\nTrying 127.0.0.1...\nConnected to 127.0.0.1.\nEscape character is \u0027^]\u0027.\nOpen On-Chip Debugger\n\u003e reset;halt\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x81000000 pc: 0x00000554 msp: 0x20000fe8\n\n\u003e program xxx.bin verify\nDisabling watchdog...\n[cx32l003.cpu] halted due to debug-request, current mode: Thread\nxPSR: 0x81000000 pc: 0x00000554 msp: 0x20000fe8\n** Programming Started **\ncx32l003_mass_erase\ncx32l003_mass_erase retval\u003d0 elapsed_ms\u003d345\ncx32l003 mass erase complete\ncx32l003_write buffer\u003d000001c1bf058d10 offset\u003d0x00000000 count\u003d65536\ncx32l003_write retval\u003d0 elapsed_ms\u003d1999\n** Programming Finished **\n** Verify Started **\n** Verified OK **","commit_id":"b0782b0e51d885d01a6e2d9d5c3404255a146ab3"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"bf8097eb82ebbe05373f1bbafcc2ec3c9b548dd1","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":9,"id":"fb78e569_33cbcb80","updated":"2023-08-31 18:07:11.000000000","message":"Please use tools/checkpatch.sh to reduce jenkins build failures.","commit_id":"b0782b0e51d885d01a6e2d9d5c3404255a146ab3"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"e3b533f7a88db1c9de1b62ff7b4a23c5894b7c28","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":9,"id":"e5d9f422_b29dfd94","in_reply_to":"488ecf57_0896d293","updated":"2023-09-04 07:58:18.000000000","message":"\u003e I have done a new version using swm050.c as template which is quite clean and using only some target_write_u32() / target_read_u32() rewriting erase/program, the main issue is when it works it\u0027s so slow...\n\nNo wonder. Remember I wrote\n\n\u003e programming usually needs a target algo\n\n\u003e See https://hydrabus.com/openocd_cx32l003/openocd_cx32l003_noalgo_02Sep2023_src.7z\n\nNormally I don\u0027t have time to download, unpack and inspect code from scattered places. I did it this time just for curiosity - but I cannot send comments.\nSubmit a change to gerrit\n\n\n\u003e cx32l003_erase first\u003d0 last\u003d23\n\u003e SWD DPIDR 0x0bc11477\n\u003e Failed to read memory and, additionally, failed to find out where\n\u003e cx32l003_flash_erase_sector: target_read_u32() fail\n\u003e SWD DPIDR 0x0bc11477\n\u003e failed erasing sectors 0 to 23\n\u003e embedded:startup.tcl:1524: Error: ** Programming Failed **\n\u003e in procedure \u0027program\u0027\n\u003e in procedure \u0027program_error\u0027 called at file \"embedded:startup.tcl\", line 1589\n\u003e at file \"embedded:startup.tcl\", line 1524\n\nIt looks like the previous\n\u003e target_write_u32(target, flash_addr_dst, DUMMY_DATA);\n\nkeeps the bus staled until the flash erase is finished. That\u0027s why the next polling read fails. Your code should react properly, not just completely fail the operation. This differs from the target code behaviour because the target CPU is held in wait state, it does not see any time-out.","commit_id":"b0782b0e51d885d01a6e2d9d5c3404255a146ab3"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"6c85fb67b254cabbec409234fa926243c967daaa","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":9,"id":"09b20af5_2f640844","in_reply_to":"e5d9f422_b29dfd94","updated":"2023-09-04 11:35:09.000000000","message":"Thanks for the hint but so far even if we fix that version it will be too slow, so I prefer to continue on the version with embedded algorithm for erase/program","commit_id":"b0782b0e51d885d01a6e2d9d5c3404255a146ab3"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":13,"id":"78d28402_b473ec67","updated":"2023-09-05 09:51:47.000000000","message":"Please take me seriously: I really want you to remove all npcx based rubbish.\nPutting -2 score until you submit a code based on your no algo version - the target algo (for faster write only) could be added later.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"2b0a7149266f50b07296980e5c1c995eca41b7a9","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":13,"id":"9d559c7d_2c087085","in_reply_to":"16ac68ac_96d13c37","updated":"2023-09-05 16:15:14.000000000","message":"For information the latest no-algo version is available here https://hydrabus.com/openocd_cx32l003/openocd_cx32l003_noalgo_04Sep2023_src.7z with \"crappy\" fix with alive_sleep() with test results to show you how it is slow (the J-Link probe used works at 2MHz\n- dump_image dump_64KB.bin 0 65536\n- dumped 65536 bytes in 0.845358s (75.708 KiB/s)\n\nI doubt we can improve that with a faster SWD probe as anyway the CX32L003F8 will probably do not work with SWD frequency \u003e2MHz ...","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"cabfc76e041ecef767932b7d07376c34670b5423","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":13,"id":"16ac68ac_96d13c37","in_reply_to":"78d28402_b473ec67","updated":"2023-09-05 16:00:28.000000000","message":"I understand your point but actual \"no-algo\" version even if it is cleaner is too slow and have lot of border effects during erase/program algorithm done step by step with target_read_u32()/target_write_u32() especially after erase or programming command when we want to poll the status of the flash there is some SWD fatal errors which requires to add some arbitrary wait delay (alive_sleep()) which are very bad as it can break on different MCU depending on flash aging... and that slow down even more the whole process which take more than 1minute when algorithm version take less than 2s...","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"2a5b442947e1eb3868b40be371841ce72b62a234","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":13,"id":"cd1c5211_6573ae21","in_reply_to":"9d559c7d_2c087085","updated":"2023-09-05 21:53:49.000000000","message":"Done","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"}],"contrib/loaders/flash/cx32l003/cx32l003_flash.c":[{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"e3b533f7a88db1c9de1b62ff7b4a23c5894b7c28","unresolved":true,"context_lines":[{"line_number":91,"context_line":"\t\tIWDG-\u003eUNLOCK \u003d 0x55aa6698;"},{"line_number":92,"context_line":"\t}"},{"line_number":93,"context_line":""},{"line_number":94,"context_line":"\tif (page_addr \u003c 0x8000) {"},{"line_number":95,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":96,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":97,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK0;"},{"line_number":98,"context_line":"\t\tFLASH-\u003eSLOCK0 \u003d val | 1 \u003c\u003c (page_addr \u003e\u003e 10 \u0026 0xff);"},{"line_number":99,"context_line":"\t} else if (page_addr \u003c 0x10000) {"},{"line_number":100,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":101,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":102,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":103,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":104,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":105,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":106,"context_line":"\t}"},{"line_number":107,"context_line":"\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":108,"context_line":"\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":109,"context_line":"\tFLASH-\u003eCR \u003d 2;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"95c6998d_3d0a9d65","line":106,"range":{"start_line":94,"start_character":1,"end_line":106,"end_character":2},"updated":"2023-09-04 07:58:18.000000000","message":"I comment it here but the same part is in .._cx32l003_noalgo_02Sep2023_..\n\nWhy is the sector unprotected just before erase operation and protected back after erase is finished?\n\nThis is at least very uncommon and looks like you copied a vendor provided example without understanding what it does.\n\nI searched for a cx32l003 reference manual but no luck - I found the data sheet only, which is not detailed enough. Do you have a reference or flash programming manual?\n\nAre the registers SLOCK0 and SLOCK1 volatile or not?\n\nNormally, write protection is controlled by OpenOCD flash driver protect()\nmethod and not touched in erase/mass erase/write. There is a good reason not to change the write lock too frequently - if the lock is non-volatile, it is implemented as a flash cell with limited endurance. And the second reason is the programming speed.","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":91,"context_line":"\t\tIWDG-\u003eUNLOCK \u003d 0x55aa6698;"},{"line_number":92,"context_line":"\t}"},{"line_number":93,"context_line":""},{"line_number":94,"context_line":"\tif (page_addr \u003c 0x8000) {"},{"line_number":95,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":96,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":97,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK0;"},{"line_number":98,"context_line":"\t\tFLASH-\u003eSLOCK0 \u003d val | 1 \u003c\u003c (page_addr \u003e\u003e 10 \u0026 0xff);"},{"line_number":99,"context_line":"\t} else if (page_addr \u003c 0x10000) {"},{"line_number":100,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":101,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":102,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":103,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":104,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":105,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":106,"context_line":"\t}"},{"line_number":107,"context_line":"\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":108,"context_line":"\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":109,"context_line":"\tFLASH-\u003eCR \u003d 2;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"f9a6b7d4_a969dd22","line":106,"range":{"start_line":94,"start_character":1,"end_line":106,"end_character":2},"in_reply_to":"28f3f469_c3c1e900","updated":"2023-09-05 09:51:47.000000000","message":"Thanks for sharing the translated user manual. The translation is surprisingly clear. Unfortunately pictures/diagrams are not translated and the description is sometimes rather insufficient.\n\nYou\u0027re right SLOCK0,1 are just plain registers. It would be sufficient to set all bits in a common init (OpenOCD normally uses Tcl event handler \u0027reset-init\u0027 for initialization before flash ops start) and rely on MCU reset which resets SLOCK0,1 to zero after flash programming. No problem if set at flash op start and reset at flash op end - in this case it must be done consistently, not leaving SLOCK unlocked in case of any error (e.g. timeout)","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"6c85fb67b254cabbec409234fa926243c967daaa","unresolved":false,"context_lines":[{"line_number":91,"context_line":"\t\tIWDG-\u003eUNLOCK \u003d 0x55aa6698;"},{"line_number":92,"context_line":"\t}"},{"line_number":93,"context_line":""},{"line_number":94,"context_line":"\tif (page_addr \u003c 0x8000) {"},{"line_number":95,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":96,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":97,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK0;"},{"line_number":98,"context_line":"\t\tFLASH-\u003eSLOCK0 \u003d val | 1 \u003c\u003c (page_addr \u003e\u003e 10 \u0026 0xff);"},{"line_number":99,"context_line":"\t} else if (page_addr \u003c 0x10000) {"},{"line_number":100,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":101,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":102,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":103,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":104,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":105,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":106,"context_line":"\t}"},{"line_number":107,"context_line":"\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":108,"context_line":"\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":109,"context_line":"\tFLASH-\u003eCR \u003d 2;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"28f3f469_c3c1e900","line":106,"range":{"start_line":94,"start_character":1,"end_line":106,"end_character":2},"in_reply_to":"95c6998d_3d0a9d65","updated":"2023-09-04 11:35:09.000000000","message":"The SLOCK0 \u0026 SLOCK1 are just standard registers to protect/unprotect the Flash before Erase or Program Flash\nThey are not in flash so it is not critical how many time we set/clear them.\nI think it is safer to Unlock the write/erase access only during the time we erase/program flash then to lock all for safety purpose, it is how work actual algorithm.\n\nFor information CX32L003 series official documents with the full User Manual with details on all peripherals/registers (in chinese only) is available on \nhttp://www.zbitsemi.com/display.php?id\u003d139\nScroll down to Datasheet / User Manual... and click on Download\nInteresting point is \"CX32L003 SDK\" available with Download where there is all peripherals and it is what I have used\nEspecially following files:\n* Drivers/CMSIS/Device/XMC/CX32L003/Include/cx32l003.h\n* Drivers/CX32L003_HAL_Driver/Inc/cx32l003_hal_flash.h\n* Drivers/CX32L003_HAL_Driver/Src/cx32l003_hal_flash.c\n\nI have translated that big document with Google Translate from Chinese to English it is available on \nhttps://hydrabus.com/openocd_cx32l003/CX32L003_UserManual_1.0.2_EN.pdf","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"cabfc76e041ecef767932b7d07376c34670b5423","unresolved":false,"context_lines":[{"line_number":91,"context_line":"\t\tIWDG-\u003eUNLOCK \u003d 0x55aa6698;"},{"line_number":92,"context_line":"\t}"},{"line_number":93,"context_line":""},{"line_number":94,"context_line":"\tif (page_addr \u003c 0x8000) {"},{"line_number":95,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":96,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":97,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK0;"},{"line_number":98,"context_line":"\t\tFLASH-\u003eSLOCK0 \u003d val | 1 \u003c\u003c (page_addr \u003e\u003e 10 \u0026 0xff);"},{"line_number":99,"context_line":"\t} else if (page_addr \u003c 0x10000) {"},{"line_number":100,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":101,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":102,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":103,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":104,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":105,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":106,"context_line":"\t}"},{"line_number":107,"context_line":"\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":108,"context_line":"\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":109,"context_line":"\tFLASH-\u003eCR \u003d 2;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"afe77ba5_27a7a50b","line":106,"range":{"start_line":94,"start_character":1,"end_line":106,"end_character":2},"in_reply_to":"f9a6b7d4_a969dd22","updated":"2023-09-05 16:00:28.000000000","message":"See a version a bit better with extract of Flash Details with picture/diagrams also translated\nhttps://hydrabus.com/openocd_cx32l003/CX32L003_UserManual_1.0.2_FlashDetails_EN_BVE_04Sep2023.pdf\n\nActual algorithm take care to protect flash (Flash_SLOCK0 \u0026 Flash_SLOCK1) at end each time and in case of infinite loop due to error in flash (and status stuck) the MCU will be rebooted by IWDT(after about 27s with max value loaded).\nTell me if you see anything to improve","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"e3b533f7a88db1c9de1b62ff7b4a23c5894b7c28","unresolved":true,"context_lines":[{"line_number":104,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":105,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":106,"context_line":"\t}"},{"line_number":107,"context_line":"\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":108,"context_line":"\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":109,"context_line":"\tFLASH-\u003eCR \u003d 2;"},{"line_number":110,"context_line":"\t/* Erase flash sector */"},{"line_number":111,"context_line":"\t*(uint32_t *)page_addr \u003d 0;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"1d2ee7b6_1a3dadcf","line":108,"range":{"start_line":107,"start_character":1,"end_line":108,"end_character":24},"updated":"2023-09-04 07:58:18.000000000","message":"Just for curiosity, what\u0027s the BYPASS register for?","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"6c85fb67b254cabbec409234fa926243c967daaa","unresolved":false,"context_lines":[{"line_number":104,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":105,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":106,"context_line":"\t}"},{"line_number":107,"context_line":"\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":108,"context_line":"\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":109,"context_line":"\tFLASH-\u003eCR \u003d 2;"},{"line_number":110,"context_line":"\t/* Erase flash sector */"},{"line_number":111,"context_line":"\t*(uint32_t *)page_addr \u003d 0;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"656468b7_a9bb20fc","line":108,"range":{"start_line":107,"start_character":1,"end_line":108,"end_character":24},"in_reply_to":"1d2ee7b6_1a3dadcf","updated":"2023-09-04 11:35:09.000000000","message":"Like defined in the User Manual it is very special sequence.\nI have done full traduction(with some fixes) from Chinese to English of the whole Flash chapter 10 \"Flash controller (Flash)\"\nSee https://hydrabus.com/openocd_cx32l003/CX32L003_UserManual_1.0.2_FlashDetails_EN_BVE_04Sep2023.odt\nSee https://hydrabus.com/openocd_cx32l003/CX32L003_UserManual_1.0.2_FlashDetails_EN_BVE_04Sep2023.pdf\n\nI will push new optimized code for the erase \u0026 program algorithm","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"e3b533f7a88db1c9de1b62ff7b4a23c5894b7c28","unresolved":true,"context_lines":[{"line_number":146,"context_line":"\t\tIWDG-\u003eUNLOCK \u003d 0x55aa6698;"},{"line_number":147,"context_line":"\t}"},{"line_number":148,"context_line":"\tfor (; size !\u003d 0; size \u003d size - 4) {"},{"line_number":149,"context_line":"\t\tif (flash_addr_dst \u003c (uint32_t *)0x8000) {"},{"line_number":150,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":151,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":152,"context_line":"\t\t\tval \u003d FLASH-\u003eSLOCK0;"},{"line_number":153,"context_line":"\t\t\tFLASH-\u003eSLOCK0 \u003d val | 1 \u003c\u003c ((uint32_t)flash_addr_dst \u003e\u003e 10 \u0026 0xff);"},{"line_number":154,"context_line":"\t\t} else if (flash_addr_dst \u003c (uint32_t *)0x10000) {"},{"line_number":155,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":156,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":157,"context_line":"\t\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":158,"context_line":"\t\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((uint32_t)(flash_addr_dst - 0x2000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":159,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":160,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":161,"context_line":"\t\t}"},{"line_number":162,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":163,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":164,"context_line":"\t\tval \u003d FLASH-\u003eCR;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"e5551b61_826d1088","line":161,"range":{"start_line":149,"start_character":2,"end_line":161,"end_character":3},"updated":"2023-09-04 07:58:18.000000000","message":"Unlock and lock on word by word basis... sorry it looks like a total nonsense","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"5aec12b86b4c5d3daa4ecf3258f109f92c163e0f","unresolved":false,"context_lines":[{"line_number":146,"context_line":"\t\tIWDG-\u003eUNLOCK \u003d 0x55aa6698;"},{"line_number":147,"context_line":"\t}"},{"line_number":148,"context_line":"\tfor (; size !\u003d 0; size \u003d size - 4) {"},{"line_number":149,"context_line":"\t\tif (flash_addr_dst \u003c (uint32_t *)0x8000) {"},{"line_number":150,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":151,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":152,"context_line":"\t\t\tval \u003d FLASH-\u003eSLOCK0;"},{"line_number":153,"context_line":"\t\t\tFLASH-\u003eSLOCK0 \u003d val | 1 \u003c\u003c ((uint32_t)flash_addr_dst \u003e\u003e 10 \u0026 0xff);"},{"line_number":154,"context_line":"\t\t} else if (flash_addr_dst \u003c (uint32_t *)0x10000) {"},{"line_number":155,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":156,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":157,"context_line":"\t\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":158,"context_line":"\t\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((uint32_t)(flash_addr_dst - 0x2000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":159,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":160,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":161,"context_line":"\t\t}"},{"line_number":162,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":163,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":164,"context_line":"\t\tval \u003d FLASH-\u003eCR;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"3677a347_d18ca69d","line":161,"range":{"start_line":149,"start_character":2,"end_line":161,"end_character":3},"in_reply_to":"9dd0366b_856d03f7","updated":"2023-09-04 12:18:36.000000000","message":"Done","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"6c85fb67b254cabbec409234fa926243c967daaa","unresolved":true,"context_lines":[{"line_number":146,"context_line":"\t\tIWDG-\u003eUNLOCK \u003d 0x55aa6698;"},{"line_number":147,"context_line":"\t}"},{"line_number":148,"context_line":"\tfor (; size !\u003d 0; size \u003d size - 4) {"},{"line_number":149,"context_line":"\t\tif (flash_addr_dst \u003c (uint32_t *)0x8000) {"},{"line_number":150,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":151,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":152,"context_line":"\t\t\tval \u003d FLASH-\u003eSLOCK0;"},{"line_number":153,"context_line":"\t\t\tFLASH-\u003eSLOCK0 \u003d val | 1 \u003c\u003c ((uint32_t)flash_addr_dst \u003e\u003e 10 \u0026 0xff);"},{"line_number":154,"context_line":"\t\t} else if (flash_addr_dst \u003c (uint32_t *)0x10000) {"},{"line_number":155,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":156,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":157,"context_line":"\t\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":158,"context_line":"\t\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((uint32_t)(flash_addr_dst - 0x2000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":159,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":160,"context_line":"\t\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":161,"context_line":"\t\t}"},{"line_number":162,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":163,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":164,"context_line":"\t\tval \u003d FLASH-\u003eCR;"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"9dd0366b_856d03f7","line":161,"range":{"start_line":149,"start_character":2,"end_line":161,"end_character":3},"in_reply_to":"e5551b61_826d1088","updated":"2023-09-04 11:35:09.000000000","message":"I will push new optimized code for the program algorithm to avoid that mess and simplify things\nmainly unlock all sectors before program and do minimal code to program each word then at end lock all sectors for safety.","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"e3b533f7a88db1c9de1b62ff7b4a23c5894b7c28","unresolved":true,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"55dd9c2f_4c3178f0","line":172,"updated":"2023-09-04 07:58:18.000000000","message":"I didn\u0027t see a reference manual so it is just a speculation:\nThe write loop could be reduced to\n- write a word\n- wait for idle state\n\nAll other could persist...","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"b84a9cf64de56dea92ffbbed15c08ed5d5aadd22","unresolved":false,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"312b8f6e_94332e6a","line":172,"in_reply_to":"16a9f181_fca7b964","updated":"2023-09-06 12:24:12.000000000","message":"I have tested following flash program to check the theory of FLASH-\u003eBYPASS to be used only one time or for each word programmed\n```c\nvoid cx32l003_flash_program(uint32_t *flash_addr_dst, int size, uint32_t *ram_data_src)\n{\n\tuint32_t val;\n\n\t/* If IWDG is running, reload it to max value about 27s */\n\tcx32l003_reload_iwdg();\n\n\t/* Unlock all Flash pages for erase or program  */\n\tcx32l003_flash_unlock_all();\n\n\tFLASH-\u003eBYPASS \u003d 0x5A5A;\n\tFLASH-\u003eBYPASS \u003d 0xA5A5;\n\tFLASH-\u003eCR \u003d 1; /* Write operation */\n\n\tfor (; size !\u003d 0; size \u003d size - 4) {\n\n\n\t\t/* Program flash */\n\t\t*flash_addr_dst \u003d *ram_data_src;\n\n\t\t/* Wait end of program \"idle state\" */\n\t\tdo {\n\t\t\tval \u003d FLASH-\u003eCR;\n\t\t} while ((val \u0026 4) \u003d\u003d 4);\n/*\n\t\tFLASH-\u003eBYPASS \u003d 0x5A5A;\n\t\tFLASH-\u003eBYPASS \u003d 0;\n*/\n\t\tflash_addr_dst \u003d flash_addr_dst + 1;\n\t\tram_data_src \u003d ram_data_src + 1;\n\t}\n\n\t/* Lock all Flash pages for erase or program */\n\tcx32l003_flash_lock_all();\n}\n```\n\nI obtain an error  during binary compare / verify so the FLASH-\u003eBYPASS steps are mandatory between each word.\n```\n\u003e reset;halt;program inc16bits_64KB.bin verify\n[cx32l003.cpu] halted due to breakpoint, current mode: Handler HardFault\nxPSR: 0x61000003 pc: 0x2000002e msp: 0x030000e0\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x61000003 pc: 0x2000002e msp: 0x030000e0\n** Programming Started **\ncx32l003_erase mass erase complete\ncx32l003_write buffer\u003d0000017814cb7d90 offset\u003d0x00000000 count\u003d65536\n** Programming Finished **\n** Verify Started **\nchecksum mismatch - attempting binary compare\nembedded:startup.tcl:1524: Error: ** Verify Failed **\n```\nI confirm with a dump that this algorithm only write the first word in flash\n```\n00 01 00 03 FF FF FF FF FF FF FF FF FF FF FF FF\nFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\nFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\nFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\nFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\nFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\nFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\nFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\n```","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"2c7a1d167988c572d96dbbb8bb670df5df5ee4e1","unresolved":true,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"16a9f181_fca7b964","line":172,"in_reply_to":"30f96734_4b9c4a8c","updated":"2023-09-06 11:52:33.000000000","message":"Unfortunately we are testing things not documented here and I will prefer to keep safe code like done by the official SDK HAL Flash driver and similar algorithm is also present in \"CX32L003_Keil_Pack_1.0.7\" which work perfectly to flash erase/program.","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"bb3a9574cc2624e73132882a2b0852b2701188cc","unresolved":false,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"4a8c67ed_db1274cd","line":172,"in_reply_to":"312b8f6e_94332e6a","updated":"2023-10-05 06:29:52.000000000","message":"Thanks for testing it. Such a bad design of the flash controller is almost unbelievable for me. The documentation is very poor as well (e.g. undocumented need of explicit locking of BYPASS register). I think OpenOCD should better stay away from that crap.","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"e099323af44d359f23394777ba055350d755dc41","unresolved":false,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"ce0188ea_7636f583","line":172,"in_reply_to":"4a8c67ed_db1274cd","updated":"2023-10-05 06:51:50.000000000","message":"I have tested it extensively on different E220-900T22D (Zbit CX32L003F8 MCU) with tons of write/erase/verify (also checking the program run correctly with worst case full 64KB erase/write/verify and program test) with different code/data size without any issue.\nSee the files in https://hydrabus.com/openocd_cx32l003/tests_results_05Sep2023/ it contains tests_results_05Sep2023_21h39.odt report and files used.\nI have done development (Linky TeleInfo FW/LLCC68 ping pong FW ...) with it since that time and I can tell you debug/programming work fine and I have never seen any issue.","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"6c85fb67b254cabbec409234fa926243c967daaa","unresolved":true,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"dd767af4_d8e7f71b","line":172,"in_reply_to":"55dd9c2f_4c3178f0","updated":"2023-09-04 11:35:09.000000000","message":"I will push new optimized code for the program algorithm to avoid that mess and simplify things\nmainly unlock all sectors before program and do minimal code to program each word then at end lock all sectors for safety.\nSee https://hydrabus.com/openocd_cx32l003/CX32L003_UserManual_1.0.2_FlashDetails_EN_BVE_04Sep2023.odt\nSee https://hydrabus.com/openocd_cx32l003/CX32L003_UserManual_1.0.2_FlashDetails_EN_BVE_04Sep2023.pdf","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"9e362321f2fd0074316510471c85c802d8e7f291","unresolved":true,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"30f96734_4b9c4a8c","line":172,"in_reply_to":"5ff46aee_b955eb33","updated":"2023-09-06 09:35:34.000000000","message":"\u003e ... if you need to modify the register again, you must enter the correct BYPASS sequence\n\nBut we don\u0027t need to modify FLASH CR, we want just to continue writing data to flash keeping previously set flash operation mode (CR OP bits). Maybe I\u0027m wrong but most of Chinese MCUs have the flash controller more or less based on STM32F1 (some are completely compatible, this one looks rather \u0027extended\u0027). That\u0027s why I suppose writing to CR need not to be repeated before each data write, just set the CR OP once and write all data (a page or whole flash) - with waiting between word writes until CR BUSY is zero.\n\nPlease test.","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"5ff46aee_b955eb33","line":172,"in_reply_to":"6557f850_b4594585","updated":"2023-09-05 21:34:25.000000000","message":"The User Manual (translated from CN to EN) §10.5.3 Flash_BYPASS (BYPASS sequence register) clearly specify\n- Before modifying the registers of this module, you must write to the BYPASSSEQ[15:0] register\n- Enter 0x5A5A, 0xA5A5 sequence. Only one write is allowed after a correct write sequence\n- Secondary register, if you need to modify the register again, you must enter the correct BYPASS sequence","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"6557f850_b4594585","line":172,"in_reply_to":"cb075643_5801de1a","updated":"2023-09-05 09:51:47.000000000","message":"The translated part of documentation doesn\u0027t make clear if a single write to FLASH CR (preceded by twiddling of BYPASS) is sufficient for multiple data writes (I bet on this) or twiddling of BYPASS and write to CR must precede each single data write as your code does. \n\nCan you please test it?\nYou may interactively issue OpenOCD commands \u0027mww\u0027 and \u0027mdw\u0027 over a telnet connection.","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"8fd6a118d728d5d841f119ff09c7d98c01d79e6b","unresolved":false,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"d1dcc5d1_851a4b0b","line":172,"in_reply_to":"ce0188ea_7636f583","updated":"2024-01-22 22:20:00.000000000","message":"What do I need to change to have this Patch merged as I do not have any feedback since 05 Oct 2023 ?","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"5aec12b86b4c5d3daa4ecf3258f109f92c163e0f","unresolved":false,"context_lines":[{"line_number":169,"context_line":"\t\tFLASH-\u003eCR \u003d val | 1;"},{"line_number":170,"context_line":""},{"line_number":171,"context_line":"\t\t/* Program flash */"},{"line_number":172,"context_line":"\t\t*flash_addr_dst \u003d *ram_data_src;"},{"line_number":173,"context_line":""},{"line_number":174,"context_line":"\t\t/* Wait end of program \"idle state\" */"},{"line_number":175,"context_line":"\t\tdo {"}],"source_content_type":"text/x-csrc","patch_set":11,"id":"cb075643_5801de1a","line":172,"in_reply_to":"dd767af4_d8e7f71b","updated":"2023-09-04 12:18:36.000000000","message":"Done","commit_id":"1eea4f875d30301f87f243faadf3a496c28c30b7"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":101,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":102,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":103,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":104,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":105,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":106,"context_line":"\t}"},{"line_number":107,"context_line":"\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":108,"context_line":"\tFLASH-\u003eBYPASS \u003d 0xa5a5;"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"115fab9e_a3c4c335","line":105,"range":{"start_line":104,"start_character":2,"end_line":105,"end_character":20},"updated":"2023-09-05 09:51:47.000000000","message":"What is this for?","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"cabfc76e041ecef767932b7d07376c34670b5423","unresolved":false,"context_lines":[{"line_number":101,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":102,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":103,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val | 1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff);"},{"line_number":104,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":105,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":106,"context_line":"\t}"},{"line_number":107,"context_line":"\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":108,"context_line":"\tFLASH-\u003eBYPASS \u003d 0xa5a5;"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"45f8cce2_1a587063","line":105,"range":{"start_line":104,"start_character":2,"end_line":105,"end_character":20},"in_reply_to":"115fab9e_a3c4c335","updated":"2023-09-05 16:00:28.000000000","message":"For reference this part of code is taken from official Zbit CX32L003 SDK link http://www.zbitsemi.com/display.php?id\u003d139 (see it also on https://hydrabus.com/openocd_cx32l003/CX32L003_SDK_1.4.2.rar)\n- CX32L003_SDK_V1.4.2-20220725/CX32L003_HAL_Driver/Src/cx32l003_hal_flash.c\n- CX32L003_SDK_V1.4.2-20220725/CX32L003_HAL_Driver/Inc/cx32l003_hal_flash.h\n\nMaybe it can be removed to be tested without that (it is not clear if it is here to fix an errata ...)\n\nExtract of macro they use to program or erase sector(called page too):\n``` c\n#define __HAL_FLASH_REGISTER_UNLOCK \\\ndo {\\\n\tFLASH-\u003eBYPASS \u003d FLASH_REGUNLOCK_KEY1; \\\n\tFLASH-\u003eBYPASS \u003d FLASH_REGUNLOCK_KEY2; \\\n} while(0U) \n\n#define __HAL_FLASH_REGISTER_LOCK \\\ndo {\\\nFLASH-\u003eBYPASS \u003d FLASH_REGUNLOCK_KEY1; \\\nFLASH-\u003eBYPASS \u003d 0x00000000; \\\n} while(0U) \n\nstatic void FLASH_Program_Word(uint32_t Address, uint32_t Data)\n{\n\t/* Clean the error context */\n\tpFlash.ErrorCode \u003d HAL_FLASH_ERROR_NONE;\n\t__disable_irq();\n\t/* Proceed to program the new data */\n\t__HAL_FLASH_REGISTER_UNLOCK;\n\tMODIFY_REG(FLASH-\u003eCR, FLASH_CR_OP, FLASH_OP_PROGRAM);\n\n\t/* Write data in the address */\n\t*(__IO uint32_t*)Address \u003d Data;\n\n\t__HAL_FLASH_REGISTER_LOCK;\n\t__enable_irq();\n}\n\nstatic void FLASH_PageErase(uint32_t PageAddress)\n{\n\t/* Clean the error context */\n\tpFlash.ErrorCode \u003d HAL_FLASH_ERROR_NONE;\n\t__disable_irq();\n\t/* one page will be erased*/\n\t__HAL_FLASH_REGISTER_UNLOCK;\n\tMODIFY_REG(FLASH-\u003eCR, FLASH_CR_OP, FLASH_OP_SECTORERASE);\n\t/* Proceed to erase the page */\n\t*(__IO uint32_t*)PageAddress \u003d DUMMY_DATA;\n\t__HAL_FLASH_REGISTER_LOCK;\n\t__enable_irq();\n}\n```\nI have removed that code in different parts and all work fine (I suspect it was a mistake in the SDK code probably they where testing something or for old chipset with errata not documented...)","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":128,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":129,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":130,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val \u0026 ~(1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff));"},{"line_number":131,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":132,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":133,"context_line":"\t}"},{"line_number":134,"context_line":"}"},{"line_number":135,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"316ff153_750b6bb5","line":132,"range":{"start_line":131,"start_character":1,"end_line":132,"end_character":20},"updated":"2023-09-05 09:51:47.000000000","message":"And this?","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"9e362321f2fd0074316510471c85c802d8e7f291","unresolved":true,"context_lines":[{"line_number":128,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":129,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":130,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val \u0026 ~(1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff));"},{"line_number":131,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":132,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":133,"context_line":"\t}"},{"line_number":134,"context_line":"}"},{"line_number":135,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"276a8631_3eeefaa7","line":132,"range":{"start_line":131,"start_character":1,"end_line":132,"end_character":20},"in_reply_to":"10fc6e36_c4832f7d","updated":"2023-09-06 09:35:34.000000000","message":"Strange. Is the log from algo or no-algo version?\nAnd could you paste -d3 log instead? debug_level 2 is not detailed enough.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"2c7a1d167988c572d96dbbb8bb670df5df5ee4e1","unresolved":true,"context_lines":[{"line_number":128,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":129,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":130,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val \u0026 ~(1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff));"},{"line_number":131,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":132,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":133,"context_line":"\t}"},{"line_number":134,"context_line":"}"},{"line_number":135,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"be147068_0d568032","line":132,"range":{"start_line":131,"start_character":1,"end_line":132,"end_character":20},"in_reply_to":"276a8631_3eeefaa7","updated":"2023-09-06 11:52:33.000000000","message":"This bug is really not fun as it appears only with debug_level \u003c 3 (and when the code FLASH-\u003eBYPASS \u003d 0x5A5A then FLASH-\u003eBYPASS \u003d 0 is removed so it could be a tricky issue or an errata on too fast access where FLASH-\u003eBYPASS does not work correctly or other strange things ...\nI think it will be safer to keep that \"non documented\" (except it is done in official SDK HAL Flash driver) FLASH-\u003eBYPASS \u003d 0x5A5A then FLASH-\u003eBYPASS \u003d 0 for flash program and erase too(to avoid potential errors) as there is no any issue with that and that do not really slow down flash program/flash erase\n\nSo with debug_level 2 I obtain only those logs:\n```\n\u003e reset;halt;program inc16bits_64KB.bin verify\n[cx32l003.cpu] clearing lockup after double fault\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x60000003 pc: 0xfffffffe msp: 0x030000e0\nPolling target cx32l003.cpu failed, trying to reexamine\n[cx32l003.cpu] Cortex-M0+ r0p1 processor detected\n[cx32l003.cpu] target has 4 breakpoints, 2 watchpoints\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x60000003 pc: 0xfffffffe msp: 0x030000e0\n** Programming Started **\ncx32l003_erase mass erase complete\ncx32l003_write buffer\u003d0000026de49c8c10 offset\u003d0x00000000 count\u003d65536\ncx32l003: Flash operation failed, status\u003d0xff000000\nerror writing to flash at address 0x00000000 at offset 0x00000000\nembedded:startup.tcl:1524: Error: ** Programming Failed **\nin procedure \u0027program\u0027\nin procedure \u0027program_error\u0027 called at file \"embedded:startup.tcl\", line 1589\nat file \"embedded:startup.tcl\", line 1524\nshutdown command invoked\n\u003e reset;halt;program inc16bits_64KB.bin verifyConnection closed by foreign host.\n```\nWith debug_level 3 all is fine\n```\n\u003e reset;halt;program inc16bits_64KB.bin verify\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x41000003 pc: 0x20000404 msp: 0x20000714\n[cx32l003.cpu] halted due to debug-request, current mode: Handler HardFault\nxPSR: 0x41000003 pc: 0x20000404 msp: 0x20000714\n** Programming Started **\ncx32l003_erase mass erase complete\ncx32l003_write buffer\u003d000001e8f3647d90 offset\u003d0x00000000 count\u003d65536\n** Programming Finished **\n** Verify Started **\n** Verified OK **\nshutdown command invoked\n```","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"cabfc76e041ecef767932b7d07376c34670b5423","unresolved":false,"context_lines":[{"line_number":128,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":129,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":130,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val \u0026 ~(1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff));"},{"line_number":131,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":132,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":133,"context_line":"\t}"},{"line_number":134,"context_line":"}"},{"line_number":135,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"643695ec_222399f2","line":132,"range":{"start_line":131,"start_character":1,"end_line":132,"end_character":20},"in_reply_to":"316ff153_750b6bb5","updated":"2023-09-05 16:00:28.000000000","message":"Initially I have added that like it is done in official SDK flash driver (see my previous comment details)\nAfter removing that code all work fine (I have done several flash tests with full 64KB filled with pattern then load of elf with 2 sections all work perfectly like before)","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":128,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":129,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":130,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val \u0026 ~(1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff));"},{"line_number":131,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":132,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":133,"context_line":"\t}"},{"line_number":134,"context_line":"}"},{"line_number":135,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"10fc6e36_c4832f7d","line":132,"range":{"start_line":131,"start_character":1,"end_line":132,"end_character":20},"in_reply_to":"643695ec_222399f2","updated":"2023-09-05 21:34:25.000000000","message":"In cx32l003_flash_program() after the loop to wait for \"idle state\" the code with special FLASH-\u003eBYPASS \u003d 0x5A5A then FLASH-\u003eBYPASS \u003d 0 is mandatory else the flash program fail.\nExtract of error if we remove the special FLASH-\u003eBYPASS \u003d 0x5A5A then FLASH-\u003eBYPASS \u003d 0\n```c\ncx32l003_write buffer\u003d000001cf8e898ce0 offset\u003d0x00000000 count\u003d65536\ncx32l003: Flash operation failed, status\u003d0xffffff00\nerror writing to flash at address 0x00000000 at offset 0x00000000\nembedded:startup.tcl:1524: Error: ** Programming Failed **\n```","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"79396cdcd2ca4bc49fc5b1ee88ee1edcd87c8c20","unresolved":false,"context_lines":[{"line_number":128,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0xa5a5;"},{"line_number":129,"context_line":"\t\tval \u003d FLASH-\u003eSLOCK1;"},{"line_number":130,"context_line":"\t\tFLASH-\u003eSLOCK1 \u003d val \u0026 ~(1 \u003c\u003c ((page_addr - 0x8000) \u003e\u003e 10 \u0026 0xff));"},{"line_number":131,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0x5a5a;"},{"line_number":132,"context_line":"\t\tFLASH-\u003eBYPASS \u003d 0;"},{"line_number":133,"context_line":"\t}"},{"line_number":134,"context_line":"}"},{"line_number":135,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"9e51e7f7_98197b11","line":132,"range":{"start_line":131,"start_character":1,"end_line":132,"end_character":20},"in_reply_to":"be147068_0d568032","updated":"2023-09-06 12:44:56.000000000","message":"I have refactored a bit the code but I keep this flash BYPASS 2 steps (lock \u0026 also unlock after) like in Official SDK and I confirm there is no any issue to program or erase the flash without debug too","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":262,"context_line":"\t\t\t\tbreak;"},{"line_number":263,"context_line":"\t\t\tcase CX32L003_FLASH_CMD_ERASE_ALL:"},{"line_number":264,"context_line":"\t\t\t\taddress \u003d 0x0;"},{"line_number":265,"context_line":"\t\t\t\tsize \u003d CX32L003_FLASH_PAGES * CX32L003_FLASH_PAGE_SIZE; /* 64KB */"},{"line_number":266,"context_line":"\t\t\t\tfor (; size \u003e 0; size -\u003d CX32L003_FLASH_PAGE_SIZE,"},{"line_number":267,"context_line":"\t\t\t\t\taddress +\u003d CX32L003_FLASH_PAGE_SIZE) {"},{"line_number":268,"context_line":"\t\t\t\t\tcx32l003_flash_erase_sector(address);"},{"line_number":269,"context_line":"\t\t\t\t}"},{"line_number":270,"context_line":"\t\t\t\tstatus \u003d CX32L003_FLASH_STATUS_OK;"},{"line_number":271,"context_line":"\t\t\t\tbreak;"},{"line_number":272,"context_line":"\t\t\tcase CX32L003_FLASH_CMD_PROGRAM:"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"7f7c0caf_3dddd18e","line":269,"range":{"start_line":265,"start_character":1,"end_line":269,"end_character":5},"updated":"2023-09-05 09:51:47.000000000","message":"Erase all is handled exactly same way as erase sectors of all sectors. Just an useless branch.\nMoreover hardcoded flash size would fail on 32 kB devices.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":262,"context_line":"\t\t\t\tbreak;"},{"line_number":263,"context_line":"\t\t\tcase CX32L003_FLASH_CMD_ERASE_ALL:"},{"line_number":264,"context_line":"\t\t\t\taddress \u003d 0x0;"},{"line_number":265,"context_line":"\t\t\t\tsize \u003d CX32L003_FLASH_PAGES * CX32L003_FLASH_PAGE_SIZE; /* 64KB */"},{"line_number":266,"context_line":"\t\t\t\tfor (; size \u003e 0; size -\u003d CX32L003_FLASH_PAGE_SIZE,"},{"line_number":267,"context_line":"\t\t\t\t\taddress +\u003d CX32L003_FLASH_PAGE_SIZE) {"},{"line_number":268,"context_line":"\t\t\t\t\tcx32l003_flash_erase_sector(address);"},{"line_number":269,"context_line":"\t\t\t\t}"},{"line_number":270,"context_line":"\t\t\t\tstatus \u003d CX32L003_FLASH_STATUS_OK;"},{"line_number":271,"context_line":"\t\t\t\tbreak;"},{"line_number":272,"context_line":"\t\t\tcase CX32L003_FLASH_CMD_PROGRAM:"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"b1a61c78_6f3d0c86","line":269,"range":{"start_line":265,"start_character":1,"end_line":269,"end_character":5},"in_reply_to":"1e5f3280_cbf5dd40","updated":"2023-09-05 21:34:25.000000000","message":"Resolved by removing all those dependencies to CX32L003_FLASH_PAGES and modifying CX32L003_FLASH_CMD_ERASE_ALL to use the mass erase command","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"cabfc76e041ecef767932b7d07376c34670b5423","unresolved":true,"context_lines":[{"line_number":262,"context_line":"\t\t\t\tbreak;"},{"line_number":263,"context_line":"\t\t\tcase CX32L003_FLASH_CMD_ERASE_ALL:"},{"line_number":264,"context_line":"\t\t\t\taddress \u003d 0x0;"},{"line_number":265,"context_line":"\t\t\t\tsize \u003d CX32L003_FLASH_PAGES * CX32L003_FLASH_PAGE_SIZE; /* 64KB */"},{"line_number":266,"context_line":"\t\t\t\tfor (; size \u003e 0; size -\u003d CX32L003_FLASH_PAGE_SIZE,"},{"line_number":267,"context_line":"\t\t\t\t\taddress +\u003d CX32L003_FLASH_PAGE_SIZE) {"},{"line_number":268,"context_line":"\t\t\t\t\tcx32l003_flash_erase_sector(address);"},{"line_number":269,"context_line":"\t\t\t\t}"},{"line_number":270,"context_line":"\t\t\t\tstatus \u003d CX32L003_FLASH_STATUS_OK;"},{"line_number":271,"context_line":"\t\t\t\tbreak;"},{"line_number":272,"context_line":"\t\t\tcase CX32L003_FLASH_CMD_PROGRAM:"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"1e5f3280_cbf5dd40","line":269,"range":{"start_line":265,"start_character":1,"end_line":269,"end_character":5},"in_reply_to":"7f7c0caf_3dddd18e","updated":"2023-09-05 16:00:28.000000000","message":"Hardcoded flash size shall be definitely removed and taken from tcl script (as there is no way to detect that in the MCU), if you can point me to an example doing something similar to retrieve parameter from flash driver ... (then I can pass it to the flash algorithm)","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"}],"contrib/loaders/flash/cx32l003/cx32l003_flash_config.h":[{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":13,"context_line":"/* CX32L003 chip information */"},{"line_number":14,"context_line":"#define CX32L003_FLASH_BASE_ADDR\t0x00000000"},{"line_number":15,"context_line":"#define CX32L003_FLASH_PAGE_SIZE\t512"},{"line_number":16,"context_line":"#define CX32L003_FLASH_PAGES\t\t128"},{"line_number":17,"context_line":""},{"line_number":18,"context_line":"/* CX32L003 flash loader information */"},{"line_number":19,"context_line":"#define CX32L003_FLASH_LOADER_WORKING_ADDR 0x20000000"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"bc83c79a_940806e5","line":16,"updated":"2023-09-05 09:51:47.000000000","message":"The xx_flash_config.h file is total crap. Even the file name is misleading:\nMost of definitions are relevant to flash loader, not the flash itself.\n\nEverything fixed e.g. FLASH_PAGES should differ for 32kB flash?!","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":13,"context_line":"/* CX32L003 chip information */"},{"line_number":14,"context_line":"#define CX32L003_FLASH_BASE_ADDR\t0x00000000"},{"line_number":15,"context_line":"#define CX32L003_FLASH_PAGE_SIZE\t512"},{"line_number":16,"context_line":"#define CX32L003_FLASH_PAGES\t\t128"},{"line_number":17,"context_line":""},{"line_number":18,"context_line":"/* CX32L003 flash loader information */"},{"line_number":19,"context_line":"#define CX32L003_FLASH_LOADER_WORKING_ADDR 0x20000000"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"4e03c092_262d44da","line":16,"in_reply_to":"10cdd562_01e0a67f","updated":"2023-09-05 21:34:25.000000000","message":"File renamed to cx32l003_flash_loader.h and containing only information related to flash loader","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"cabfc76e041ecef767932b7d07376c34670b5423","unresolved":true,"context_lines":[{"line_number":13,"context_line":"/* CX32L003 chip information */"},{"line_number":14,"context_line":"#define CX32L003_FLASH_BASE_ADDR\t0x00000000"},{"line_number":15,"context_line":"#define CX32L003_FLASH_PAGE_SIZE\t512"},{"line_number":16,"context_line":"#define CX32L003_FLASH_PAGES\t\t128"},{"line_number":17,"context_line":""},{"line_number":18,"context_line":"/* CX32L003 flash loader information */"},{"line_number":19,"context_line":"#define CX32L003_FLASH_LOADER_WORKING_ADDR 0x20000000"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"10cdd562_01e0a67f","line":16,"in_reply_to":"bc83c79a_940806e5","updated":"2023-09-05 16:00:28.000000000","message":"What is your proposal for the name of that file ?\nYes CX32L003_FLASH_PAGES 128 is for 64KB flash CX32L003F8 (the only one I have as I cannot test on the 32KB version CX32L003F6)\nSo for CX32L003F6 it shall be CX32L003_FLASH_PAGES 64, to be configured from tcl script if you have an example I\u0027m interested to check it (to take into account external parameter from tcl in flash driver)","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":23,"context_line":"#define CX32L003_FLASH_LOADER_BUFFER_SIZE CX32L003_FLASH_PAGE_SIZE"},{"line_number":24,"context_line":"#define CX32L003_FLASH_LOADER_PROGRAM_ADDR (CX32L003_FLASH_LOADER_BUFFER_ADDR + CX32L003_FLASH_LOADER_BUFFER_SIZE)"},{"line_number":25,"context_line":"#define CX32L003_FLASH_LOADER_PROGRAM_SIZE 3568"},{"line_number":26,"context_line":""},{"line_number":27,"context_line":"/* Stack size in byte. 4 byte size alignment */"},{"line_number":28,"context_line":"#define CX32L003_FLASH_LOADER_STACK_SIZE 512"},{"line_number":29,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"10cd2927_25d11f61","line":26,"updated":"2023-09-05 09:51:47.000000000","message":"The loader memory map but very difficult to read...\n\nxx_FLASH_LOADER_PROGRAM_SIZE - misleading, includes also loader data, bss and stack!!!","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"cabfc76e041ecef767932b7d07376c34670b5423","unresolved":true,"context_lines":[{"line_number":23,"context_line":"#define CX32L003_FLASH_LOADER_BUFFER_SIZE CX32L003_FLASH_PAGE_SIZE"},{"line_number":24,"context_line":"#define CX32L003_FLASH_LOADER_PROGRAM_ADDR (CX32L003_FLASH_LOADER_BUFFER_ADDR + CX32L003_FLASH_LOADER_BUFFER_SIZE)"},{"line_number":25,"context_line":"#define CX32L003_FLASH_LOADER_PROGRAM_SIZE 3568"},{"line_number":26,"context_line":""},{"line_number":27,"context_line":"/* Stack size in byte. 4 byte size alignment */"},{"line_number":28,"context_line":"#define CX32L003_FLASH_LOADER_STACK_SIZE 512"},{"line_number":29,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"38ef03a7_f2f44801","line":26,"in_reply_to":"10cd2927_25d11f61","updated":"2023-09-05 16:00:28.000000000","message":"The idea is to have loader buffer size equal to flash page size so 512bytes for any CX32L003 series MCU (there is only 2 available today CX32L003F8 64KB Flash and CX32L003F6 32KB flash they have both 4KB SRAM)\nAny idea to clarify that is welcome (I can add some explanation comment ...)","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":23,"context_line":"#define CX32L003_FLASH_LOADER_BUFFER_SIZE CX32L003_FLASH_PAGE_SIZE"},{"line_number":24,"context_line":"#define CX32L003_FLASH_LOADER_PROGRAM_ADDR (CX32L003_FLASH_LOADER_BUFFER_ADDR + CX32L003_FLASH_LOADER_BUFFER_SIZE)"},{"line_number":25,"context_line":"#define CX32L003_FLASH_LOADER_PROGRAM_SIZE 3568"},{"line_number":26,"context_line":""},{"line_number":27,"context_line":"/* Stack size in byte. 4 byte size alignment */"},{"line_number":28,"context_line":"#define CX32L003_FLASH_LOADER_STACK_SIZE 512"},{"line_number":29,"context_line":""}],"source_content_type":"text/x-csrc","patch_set":13,"id":"97302161_f82a1ca9","line":26,"in_reply_to":"38ef03a7_f2f44801","updated":"2023-09-05 21:34:25.000000000","message":"Done","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"}],"src/flash/nor/cx32l003.c":[{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":190,"context_line":"\tfree(bank-\u003esectors);"},{"line_number":191,"context_line":"\tbank-\u003ewrite_start_alignment \u003d 4;"},{"line_number":192,"context_line":"\tbank-\u003ewrite_end_alignment \u003d 4;"},{"line_number":193,"context_line":"\tbank-\u003esize \u003d CX32L003_FLASH_PAGE_SIZE * CX32L003_FLASH_PAGES;"},{"line_number":194,"context_line":""},{"line_number":195,"context_line":"\tbank-\u003enum_sectors \u003d CX32L003_FLASH_PAGES;"},{"line_number":196,"context_line":"\tbank-\u003esectors \u003d alloc_block_array(0, CX32L003_FLASH_PAGE_SIZE, CX32L003_FLASH_PAGES);"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"63e3f104_f38379d5","line":193,"range":{"start_line":193,"start_character":1,"end_line":193,"end_character":62},"updated":"2023-09-05 09:51:47.000000000","message":"If you don\u0027t know how to probe flash size, don\u0027t hardcode it.\nbank-\u003esize is normally read from a positional parameter of \u0027flash bank\u0027 command.\nSee tcl/target/stm32f1x.cfg how to manually set flash size.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":190,"context_line":"\tfree(bank-\u003esectors);"},{"line_number":191,"context_line":"\tbank-\u003ewrite_start_alignment \u003d 4;"},{"line_number":192,"context_line":"\tbank-\u003ewrite_end_alignment \u003d 4;"},{"line_number":193,"context_line":"\tbank-\u003esize \u003d CX32L003_FLASH_PAGE_SIZE * CX32L003_FLASH_PAGES;"},{"line_number":194,"context_line":""},{"line_number":195,"context_line":"\tbank-\u003enum_sectors \u003d CX32L003_FLASH_PAGES;"},{"line_number":196,"context_line":"\tbank-\u003esectors \u003d alloc_block_array(0, CX32L003_FLASH_PAGE_SIZE, CX32L003_FLASH_PAGES);"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"945f7102_515386b5","line":193,"range":{"start_line":193,"start_character":1,"end_line":193,"end_character":62},"in_reply_to":"63e3f104_f38379d5","updated":"2023-09-05 21:34:25.000000000","message":"Modified to take into account flash bank from user tcl(like tcl/target/stm32f1x.cfg...) else use default max value","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":192,"context_line":"\tbank-\u003ewrite_end_alignment \u003d 4;"},{"line_number":193,"context_line":"\tbank-\u003esize \u003d CX32L003_FLASH_PAGE_SIZE * CX32L003_FLASH_PAGES;"},{"line_number":194,"context_line":""},{"line_number":195,"context_line":"\tbank-\u003enum_sectors \u003d CX32L003_FLASH_PAGES;"},{"line_number":196,"context_line":"\tbank-\u003esectors \u003d alloc_block_array(0, CX32L003_FLASH_PAGE_SIZE, CX32L003_FLASH_PAGES);"},{"line_number":197,"context_line":"\tif (!bank-\u003esectors)"},{"line_number":198,"context_line":"\t\treturn ERROR_FAIL;"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"25cdf544_e280e17e","line":195,"range":{"start_line":195,"start_character":7,"end_line":195,"end_character":18},"updated":"2023-09-05 09:51:47.000000000","message":"num_sectors must be computed from flash size if you make the size configurable","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":192,"context_line":"\tbank-\u003ewrite_end_alignment \u003d 4;"},{"line_number":193,"context_line":"\tbank-\u003esize \u003d CX32L003_FLASH_PAGE_SIZE * CX32L003_FLASH_PAGES;"},{"line_number":194,"context_line":""},{"line_number":195,"context_line":"\tbank-\u003enum_sectors \u003d CX32L003_FLASH_PAGES;"},{"line_number":196,"context_line":"\tbank-\u003esectors \u003d alloc_block_array(0, CX32L003_FLASH_PAGE_SIZE, CX32L003_FLASH_PAGES);"},{"line_number":197,"context_line":"\tif (!bank-\u003esectors)"},{"line_number":198,"context_line":"\t\treturn ERROR_FAIL;"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"605cf57c_6d3622fb","line":195,"range":{"start_line":195,"start_character":7,"end_line":195,"end_character":18},"in_reply_to":"25cdf544_e280e17e","updated":"2023-09-05 21:34:25.000000000","message":"Done","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":262,"context_line":"\t\treturn ERROR_TARGET_NOT_HALTED;"},{"line_number":263,"context_line":"\t}"},{"line_number":264,"context_line":""},{"line_number":265,"context_line":"\tif (first \u003d\u003d 0 \u0026\u0026 (last \u003d\u003d (bank-\u003enum_sectors - 1))) {"},{"line_number":266,"context_line":"\t\t/* Request chip erase */"},{"line_number":267,"context_line":"\t\tLOG_INFO(\"%s mass_erase\", __func__);"},{"line_number":268,"context_line":"\t\tstart_ms \u003d timeval_ms();"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"4689599d_18431098","line":265,"updated":"2023-09-05 09:51:47.000000000","message":"Erase all is handled exactly same way as erase sectors of all sectors. Just useless branch and cx32l003_chip_erase() procedure is useless too.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":262,"context_line":"\t\treturn ERROR_TARGET_NOT_HALTED;"},{"line_number":263,"context_line":"\t}"},{"line_number":264,"context_line":""},{"line_number":265,"context_line":"\tif (first \u003d\u003d 0 \u0026\u0026 (last \u003d\u003d (bank-\u003enum_sectors - 1))) {"},{"line_number":266,"context_line":"\t\t/* Request chip erase */"},{"line_number":267,"context_line":"\t\tLOG_INFO(\"%s mass_erase\", __func__);"},{"line_number":268,"context_line":"\t\tstart_ms \u003d timeval_ms();"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"5f289d04_449d6ebc","line":265,"in_reply_to":"4689599d_18431098","updated":"2023-09-05 21:34:25.000000000","message":"I have implemented mass erase command in the flash loader so it is not useless anymore","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":280,"context_line":"\tuint32_t address \u003d first * cx32l003_bank-\u003esector_length;"},{"line_number":281,"context_line":"\tuint32_t length \u003d (last - first + 1) * cx32l003_bank-\u003esector_length;"},{"line_number":282,"context_line":""},{"line_number":283,"context_line":"\tLOG_INFO(\"%s first\u003d%d last\u003d%d\", __func__, first, last);"},{"line_number":284,"context_line":"\tstart_ms \u003d timeval_ms();"},{"line_number":285,"context_line":""},{"line_number":286,"context_line":"\tretval \u003d cx32l003_init(bank);"},{"line_number":287,"context_line":"\tif (retval !\u003d ERROR_OK)"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"8cc17357_cb92cf94","line":284,"range":{"start_line":283,"start_character":1,"end_line":284,"end_character":25},"updated":"2023-09-05 09:51:47.000000000","message":"Don\u0027t duplicate - infrastructure already measures and shows elapsed time and (also bit/sec speed for write). Just use \u0027flash erase_sector\u0027 and \u0027flash write_image\u0027 commands instead of \u0027program\u0027 script to see full text output.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":280,"context_line":"\tuint32_t address \u003d first * cx32l003_bank-\u003esector_length;"},{"line_number":281,"context_line":"\tuint32_t length \u003d (last - first + 1) * cx32l003_bank-\u003esector_length;"},{"line_number":282,"context_line":""},{"line_number":283,"context_line":"\tLOG_INFO(\"%s first\u003d%d last\u003d%d\", __func__, first, last);"},{"line_number":284,"context_line":"\tstart_ms \u003d timeval_ms();"},{"line_number":285,"context_line":""},{"line_number":286,"context_line":"\tretval \u003d cx32l003_init(bank);"},{"line_number":287,"context_line":"\tif (retval !\u003d ERROR_OK)"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"311e0c3c_87f016ed","line":284,"range":{"start_line":283,"start_character":1,"end_line":284,"end_character":25},"in_reply_to":"8cc17357_cb92cf94","updated":"2023-09-05 21:34:25.000000000","message":"Done","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":302,"context_line":"\t}"},{"line_number":303,"context_line":""},{"line_number":304,"context_line":"\t/* Issue flash helper algorithm parameters for erase */"},{"line_number":305,"context_line":"\ttarget_buffer_set_u32(target, (uint8_t *)\u0026algo_params.sync, CX32L003_FLASH_LOADER_EXECUTE);"},{"line_number":306,"context_line":"\tretval \u003d target_write_buffer(target, cx32l003_bank-\u003eparams_addr,"},{"line_number":307,"context_line":"\t\t\t\tsizeof(algo_params), (uint8_t *)\u0026algo_params);"},{"line_number":308,"context_line":""},{"line_number":309,"context_line":"\t/* If no error, wait for erase to finish */"},{"line_number":310,"context_line":"\tif (retval \u003d\u003d ERROR_OK)"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"9371b1e3_85e8cb70","line":307,"range":{"start_line":305,"start_character":1,"end_line":307,"end_character":50},"updated":"2023-09-05 09:51:47.000000000","message":"Four words are transferred but only one was changed - not big issue in terms of performance but readability sucks.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"2a5b442947e1eb3868b40be371841ce72b62a234","unresolved":false,"context_lines":[{"line_number":302,"context_line":"\t}"},{"line_number":303,"context_line":""},{"line_number":304,"context_line":"\t/* Issue flash helper algorithm parameters for erase */"},{"line_number":305,"context_line":"\ttarget_buffer_set_u32(target, (uint8_t *)\u0026algo_params.sync, CX32L003_FLASH_LOADER_EXECUTE);"},{"line_number":306,"context_line":"\tretval \u003d target_write_buffer(target, cx32l003_bank-\u003eparams_addr,"},{"line_number":307,"context_line":"\t\t\t\tsizeof(algo_params), (uint8_t *)\u0026algo_params);"},{"line_number":308,"context_line":""},{"line_number":309,"context_line":"\t/* If no error, wait for erase to finish */"},{"line_number":310,"context_line":"\tif (retval \u003d\u003d ERROR_OK)"}],"source_content_type":"text/x-csrc","patch_set":13,"id":"f0a73a1d_7793b8c5","line":307,"range":{"start_line":305,"start_character":1,"end_line":307,"end_character":50},"in_reply_to":"9371b1e3_85e8cb70","updated":"2023-09-05 21:53:49.000000000","message":"Ack","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":395,"context_line":"\treturn retval;"},{"line_number":396,"context_line":"}"},{"line_number":397,"context_line":""},{"line_number":398,"context_line":"static int cx32l003_info(struct flash_bank *bank, struct command_invocation *cmd)"},{"line_number":399,"context_line":"{"},{"line_number":400,"context_line":"\tcommand_print_sameline(cmd, \"cx32l003 flash: 64KB\\n\");"},{"line_number":401,"context_line":""},{"line_number":402,"context_line":"\treturn ERROR_OK;"},{"line_number":403,"context_line":"}"},{"line_number":404,"context_line":""},{"line_number":405,"context_line":"const struct flash_driver cx32l003_flash \u003d {"},{"line_number":406,"context_line":"\t.name \u003d \"cx32l003\","}],"source_content_type":"text/x-csrc","patch_set":13,"id":"7581272a_44e972d8","line":403,"range":{"start_line":398,"start_character":0,"end_line":403,"end_character":1},"updated":"2023-09-05 09:51:47.000000000","message":"Not quite useful, the size may lie.\nYou can remove whole func. The infrastructure prints driver name and flash size.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":395,"context_line":"\treturn retval;"},{"line_number":396,"context_line":"}"},{"line_number":397,"context_line":""},{"line_number":398,"context_line":"static int cx32l003_info(struct flash_bank *bank, struct command_invocation *cmd)"},{"line_number":399,"context_line":"{"},{"line_number":400,"context_line":"\tcommand_print_sameline(cmd, \"cx32l003 flash: 64KB\\n\");"},{"line_number":401,"context_line":""},{"line_number":402,"context_line":"\treturn ERROR_OK;"},{"line_number":403,"context_line":"}"},{"line_number":404,"context_line":""},{"line_number":405,"context_line":"const struct flash_driver cx32l003_flash \u003d {"},{"line_number":406,"context_line":"\t.name \u003d \"cx32l003\","}],"source_content_type":"text/x-csrc","patch_set":13,"id":"0f781c38_8150cf77","line":403,"range":{"start_line":398,"start_character":0,"end_line":403,"end_character":1},"in_reply_to":"7581272a_44e972d8","updated":"2023-09-05 21:34:25.000000000","message":"Done","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"}],"tcl/target/cx32l003.cfg":[{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":56,"context_line":"# reasonable default"},{"line_number":57,"context_line":"adapter speed 2000"},{"line_number":58,"context_line":""},{"line_number":59,"context_line":"adapter srst delay 100"},{"line_number":60,"context_line":"if {[using_jtag]} {"},{"line_number":61,"context_line":"\tjtag_ntrst_delay 100"},{"line_number":62,"context_line":"}"},{"line_number":63,"context_line":""},{"line_number":64,"context_line":"#reset_config srst_nogate"},{"line_number":65,"context_line":"reset_config trst_and_srst"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"c05de0be_f47445b5","line":62,"range":{"start_line":59,"start_character":0,"end_line":62,"end_character":1},"updated":"2023-09-05 09:51:47.000000000","message":"Useless. Remove","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":56,"context_line":"# reasonable default"},{"line_number":57,"context_line":"adapter speed 2000"},{"line_number":58,"context_line":""},{"line_number":59,"context_line":"adapter srst delay 100"},{"line_number":60,"context_line":"if {[using_jtag]} {"},{"line_number":61,"context_line":"\tjtag_ntrst_delay 100"},{"line_number":62,"context_line":"}"},{"line_number":63,"context_line":""},{"line_number":64,"context_line":"#reset_config srst_nogate"},{"line_number":65,"context_line":"reset_config trst_and_srst"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"21552457_82d821e4","line":62,"range":{"start_line":59,"start_character":0,"end_line":62,"end_character":1},"in_reply_to":"c05de0be_f47445b5","updated":"2023-09-05 21:34:25.000000000","message":"Done","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":62,"context_line":"}"},{"line_number":63,"context_line":""},{"line_number":64,"context_line":"#reset_config srst_nogate"},{"line_number":65,"context_line":"reset_config trst_and_srst"},{"line_number":66,"context_line":""},{"line_number":67,"context_line":"if {![using_hla]} {"},{"line_number":68,"context_line":"\t# if srst is not fitted use SYSRESETREQ to"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"a02a4f7e_19458b7d","line":65,"range":{"start_line":65,"start_character":13,"end_line":65,"end_character":26},"updated":"2023-09-05 09:51:47.000000000","message":"SWD transport only and TRST used?!!\nMoreover this should be configured in a board config, not here! Read the doc!","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"9e362321f2fd0074316510471c85c802d8e7f291","unresolved":true,"context_lines":[{"line_number":62,"context_line":"}"},{"line_number":63,"context_line":""},{"line_number":64,"context_line":"#reset_config srst_nogate"},{"line_number":65,"context_line":"reset_config trst_and_srst"},{"line_number":66,"context_line":""},{"line_number":67,"context_line":"if {![using_hla]} {"},{"line_number":68,"context_line":"\t# if srst is not fitted use SYSRESETREQ to"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"e3cec898_1519bcd3","line":65,"range":{"start_line":65,"start_character":13,"end_line":65,"end_character":26},"in_reply_to":"8e7241e0_dff23a7c","updated":"2023-09-06 09:35:34.000000000","message":"Did you try\nhttps://www.google.com/search?q\u003dtrst_and_srst\n\nI get the relevant chapter of OpenOCD documentation as the first result from Google\nhttps://openocd.org/doc/html/Reset-Configuration.html","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":true,"context_lines":[{"line_number":62,"context_line":"}"},{"line_number":63,"context_line":""},{"line_number":64,"context_line":"#reset_config srst_nogate"},{"line_number":65,"context_line":"reset_config trst_and_srst"},{"line_number":66,"context_line":""},{"line_number":67,"context_line":"if {![using_hla]} {"},{"line_number":68,"context_line":"\t# if srst is not fitted use SYSRESETREQ to"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"8e7241e0_dff23a7c","line":65,"range":{"start_line":65,"start_character":13,"end_line":65,"end_character":26},"in_reply_to":"a02a4f7e_19458b7d","updated":"2023-09-05 21:34:25.000000000","message":"It is not very clear for me how \"reset_config trst_and_srst\" work exactly could you point to a documentation link ?","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"79396cdcd2ca4bc49fc5b1ee88ee1edcd87c8c20","unresolved":false,"context_lines":[{"line_number":62,"context_line":"}"},{"line_number":63,"context_line":""},{"line_number":64,"context_line":"#reset_config srst_nogate"},{"line_number":65,"context_line":"reset_config trst_and_srst"},{"line_number":66,"context_line":""},{"line_number":67,"context_line":"if {![using_hla]} {"},{"line_number":68,"context_line":"\t# if srst is not fitted use SYSRESETREQ to"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"e946633b_c9cce6ef","line":65,"range":{"start_line":65,"start_character":13,"end_line":65,"end_character":26},"in_reply_to":"e3cec898_1519bcd3","updated":"2023-09-06 12:44:56.000000000","message":"Thanks for the details, I have removed it and all work fine (if required it will be added in user script)","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":68,"context_line":"\t# if srst is not fitted use SYSRESETREQ to"},{"line_number":69,"context_line":"\t# perform a soft reset"},{"line_number":70,"context_line":"\tcortex_m reset_config sysresetreq"},{"line_number":71,"context_line":"\techo \"sysresetreq ...\""},{"line_number":72,"context_line":"}"},{"line_number":73,"context_line":""},{"line_number":74,"context_line":"$_TARGETNAME configure -event examine-end {"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"ecd63c67_9e17cc0c","line":71,"range":{"start_line":71,"start_character":1,"end_line":71,"end_character":22},"updated":"2023-09-05 09:51:47.000000000","message":"Remove.","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":68,"context_line":"\t# if srst is not fitted use SYSRESETREQ to"},{"line_number":69,"context_line":"\t# perform a soft reset"},{"line_number":70,"context_line":"\tcortex_m reset_config sysresetreq"},{"line_number":71,"context_line":"\techo \"sysresetreq ...\""},{"line_number":72,"context_line":"}"},{"line_number":73,"context_line":""},{"line_number":74,"context_line":"$_TARGETNAME configure -event examine-end {"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"454d659b_692e235b","line":71,"range":{"start_line":71,"start_character":1,"end_line":71,"end_character":22},"in_reply_to":"ecd63c67_9e17cc0c","updated":"2023-09-05 21:34:25.000000000","message":"Done","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"f6c2a5fb27631d055b262c0687eda1da882926e9","unresolved":true,"context_lines":[{"line_number":85,"context_line":"\t# Stop watchdog counters during halt"},{"line_number":86,"context_line":"\t# DBG_APBFZ |\u003d KEY(0x5A690000) | WWDGDBGSTOP(bit10) | IWDGDBGSTOP(bit9)"},{"line_number":87,"context_line":"\tmmw 0x40004C00 0x5A690600 0"},{"line_number":88,"context_line":"\techo \"Disabling watchdog...\""},{"line_number":89,"context_line":"}"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"9841daac_086bc97b","line":88,"range":{"start_line":88,"start_character":1,"end_line":88,"end_character":29},"updated":"2023-09-05 09:51:47.000000000","message":"Misleading. Remove","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"},{"author":{"_account_id":1002184,"name":"Benjamin Vernoux","display_name":"Benjamin Vernoux","email":"bvernoux@gmail.com","username":"bvernoux"},"change_message_id":"293029bea86514a8bfc89ed38d2bb9b97621d482","unresolved":false,"context_lines":[{"line_number":85,"context_line":"\t# Stop watchdog counters during halt"},{"line_number":86,"context_line":"\t# DBG_APBFZ |\u003d KEY(0x5A690000) | WWDGDBGSTOP(bit10) | IWDGDBGSTOP(bit9)"},{"line_number":87,"context_line":"\tmmw 0x40004C00 0x5A690600 0"},{"line_number":88,"context_line":"\techo \"Disabling watchdog...\""},{"line_number":89,"context_line":"}"}],"source_content_type":"text/x-ttcn-cfg","patch_set":13,"id":"52753409_837bdd2c","line":88,"range":{"start_line":88,"start_character":1,"end_line":88,"end_character":29},"in_reply_to":"9841daac_086bc97b","updated":"2023-09-05 21:34:25.000000000","message":"Done","commit_id":"5d211c946aa61596cf909bf91781d558b7b8f3dc"}]}
