)]}'
{"src/flash/nor/at91sam4l.c":[{"author":{"_account_id":1000005,"name":"Andreas Fritiofson","email":"andreas.fritiofson@gmail.com","username":"Nattgris"},"change_message_id":"76601688404050289948c28a758851bb5a1e3668","unresolved":false,"context_lines":[{"line_number":309,"context_line":"\t\tLOG_ERROR(\"Target not halted\");"},{"line_number":310,"context_line":""},{"line_number":311,"context_line":"\t\treturn ERROR_TARGET_NOT_HALTED;"},{"line_number":312,"context_line":"\t}"},{"line_number":313,"context_line":""},{"line_number":314,"context_line":"\tres \u003d target_read_u32(bank-\u003etarget, SAM4L_CHIPID + SAM4L_CIDR, \u0026id);"},{"line_number":315,"context_line":"\tif (res !\u003d ERROR_OK) {"}],"source_content_type":"text/x-csrc","patch_set":1,"id":"AAAB2H%2F%2F%2Fc8%3D","line":312,"updated":"2013-09-20 22:46:11.000000000","message":"Can\u0027t the flash be probed while running? Other Cortex-M parts such as the STM32 probes nicely without halting, making the GDB startup issue easier to handle.","commit_id":"519209deef3a1c965e2f07e0b66094f88f1dc68a"},{"author":{"_account_id":1000433,"name":"Andrey Yurovsky","email":"yurovsky@gmail.com","username":"andrey"},"change_message_id":"f73df21e21f7bffff269cad7211a30c8093406e7","unresolved":false,"context_lines":[{"line_number":309,"context_line":"\t\tLOG_ERROR(\"Target not halted\");"},{"line_number":310,"context_line":""},{"line_number":311,"context_line":"\t\treturn ERROR_TARGET_NOT_HALTED;"},{"line_number":312,"context_line":"\t}"},{"line_number":313,"context_line":""},{"line_number":314,"context_line":"\tres \u003d target_read_u32(bank-\u003etarget, SAM4L_CHIPID + SAM4L_CIDR, \u0026id);"},{"line_number":315,"context_line":"\tif (res !\u003d ERROR_OK) {"}],"source_content_type":"text/x-csrc","patch_set":1,"id":"AAAB2H%2F%2F%2Fcs%3D","line":312,"in_reply_to":"AAAB2H%2F%2F%2Fc8%3D","updated":"2013-09-20 22:53:40.000000000","message":"Absolutely, this is a copy paste error.","commit_id":"519209deef3a1c965e2f07e0b66094f88f1dc68a"},{"author":{"_account_id":1000005,"name":"Andreas Fritiofson","email":"andreas.fritiofson@gmail.com","username":"Nattgris"},"change_message_id":"76601688404050289948c28a758851bb5a1e3668","unresolved":false,"context_lines":[{"line_number":606,"context_line":"\t\t\t\tLOG_ERROR(\"%s: %d\", __func__, __LINE__);"},{"line_number":607,"context_line":"\t\t\t\treturn res;"},{"line_number":608,"context_line":"\t\t\t}"},{"line_number":609,"context_line":"\t\t}"},{"line_number":610,"context_line":""},{"line_number":611,"context_line":"\t\t/* Erase the current page */"},{"line_number":612,"context_line":"\t\tres \u003d sam4l_flash_command(bank-\u003etarget, SAM4L_FCMD_EP, -1);"}],"source_content_type":"text/x-csrc","patch_set":1,"id":"AAAB2H%2F%2F%2Fc4%3D","line":609,"updated":"2013-09-20 22:46:11.000000000","message":"Not quite sure why you\u0027re messing with 64-bit numbers in the loop. And as you realized, you should use target_write_memory instead of target_write_u32, because the latter may perform byte order swapping.\n\nI don\u0027t think you need to loop over every word. You should only need to copy the part(s) of the page that should be preserved (if any), from flash to page buffer, using target_read_buffer() followed by target_write_buffer(). Allocate a local buffer for the purpose. Then target_write_buffer() the actual data to the page buffer and trigger the erase/write cycle. Repeat for each page.\n\nUsing target_*_buffer() instead of target_*_memory(), you don\u0027t need to care about alignment issues, as long as the page buffer can be written like regular memory.\n\nAlso, instead of sizeof(uint32_t), just use 4 (we\u0027re dealing with target addresses so host type sizes are not very relevant).","commit_id":"519209deef3a1c965e2f07e0b66094f88f1dc68a"},{"author":{"_account_id":1000433,"name":"Andrey Yurovsky","email":"yurovsky@gmail.com","username":"andrey"},"change_message_id":"f73df21e21f7bffff269cad7211a30c8093406e7","unresolved":false,"context_lines":[{"line_number":606,"context_line":"\t\t\t\tLOG_ERROR(\"%s: %d\", __func__, __LINE__);"},{"line_number":607,"context_line":"\t\t\t\treturn res;"},{"line_number":608,"context_line":"\t\t\t}"},{"line_number":609,"context_line":"\t\t}"},{"line_number":610,"context_line":""},{"line_number":611,"context_line":"\t\t/* Erase the current page */"},{"line_number":612,"context_line":"\t\tres \u003d sam4l_flash_command(bank-\u003etarget, SAM4L_FCMD_EP, -1);"}],"source_content_type":"text/x-csrc","patch_set":1,"id":"AAAB2H%2F%2F%2Fco%3D","line":609,"in_reply_to":"AAAB2H%2F%2F%2Fc4%3D","updated":"2013-09-20 22:53:40.000000000","message":"I\u0027ve rewritten this to use write_memory and will add the rest if the fixes you mentioned.  The page buffer in the part has 64-bit registers so I was trying to be extra careful though indeed a normal write works fine.","commit_id":"519209deef3a1c965e2f07e0b66094f88f1dc68a"},{"author":{"_account_id":1000005,"name":"Andreas Fritiofson","email":"andreas.fritiofson@gmail.com","username":"Nattgris"},"change_message_id":"cc3623b793fb72cac260b2ada0cec99fcd48f202","unresolved":false,"context_lines":[{"line_number":533,"context_line":"\tint res;"},{"line_number":534,"context_line":"\tuint32_t nb \u003d 0;"},{"line_number":535,"context_line":"\tstruct sam4l_info *chip \u003d (struct sam4l_info *)bank-\u003edriver_priv;"},{"line_number":536,"context_line":"\tuint32_t f_addr \u003d offset - (offset % chip-\u003epage_size);"},{"line_number":537,"context_line":""},{"line_number":538,"context_line":"\tif (bank-\u003etarget-\u003estate !\u003d TARGET_HALTED) {"},{"line_number":539,"context_line":"\t\tLOG_ERROR(\"Target not halted\");"}],"source_content_type":"text/x-csrc","patch_set":4,"id":"AAAB2H%2F%2F%2Fbs%3D","line":536,"updated":"2013-09-21 13:04:48.000000000","message":"Offset is relative to the flash start address. You might want to add bank-\u003ebase here, even if it\u0027s zero on current chips.","commit_id":"a1a63acf3d98e0f9ee4beaa5fff2b61df91146b0"},{"author":{"_account_id":1000433,"name":"Andrey Yurovsky","email":"yurovsky@gmail.com","username":"andrey"},"change_message_id":"acb86ff4c18398ed89bee92e2977a2e656655138","unresolved":false,"context_lines":[{"line_number":533,"context_line":"\tint res;"},{"line_number":534,"context_line":"\tuint32_t nb \u003d 0;"},{"line_number":535,"context_line":"\tstruct sam4l_info *chip \u003d (struct sam4l_info *)bank-\u003edriver_priv;"},{"line_number":536,"context_line":"\tuint32_t f_addr \u003d offset - (offset % chip-\u003epage_size);"},{"line_number":537,"context_line":""},{"line_number":538,"context_line":"\tif (bank-\u003etarget-\u003estate !\u003d TARGET_HALTED) {"},{"line_number":539,"context_line":"\t\tLOG_ERROR(\"Target not halted\");"}],"source_content_type":"text/x-csrc","patch_set":4,"id":"AAAB2H%2F%2F%2FbY%3D","line":536,"in_reply_to":"AAAB2H%2F%2F%2Fbs%3D","updated":"2013-09-21 14:42:50.000000000","message":"Ooops, thanks for catching that.","commit_id":"a1a63acf3d98e0f9ee4beaa5fff2b61df91146b0"},{"author":{"_account_id":1000005,"name":"Andreas Fritiofson","email":"andreas.fritiofson@gmail.com","username":"Nattgris"},"change_message_id":"cc3623b793fb72cac260b2ada0cec99fcd48f202","unresolved":false,"context_lines":[{"line_number":552,"context_line":"\t\tnb \u003d chip-\u003epage_size - (offset % chip-\u003epage_size);"},{"line_number":553,"context_line":"\t\tif (nb \u003e count)"},{"line_number":554,"context_line":"\t\t\tnb \u003d count;"},{"line_number":555,"context_line":"\t} else if (count \u003c (uint32_t)chip-\u003epage_size) {"},{"line_number":556,"context_line":"\t\t/* We\u0027re writing an aligned but partial page. */"},{"line_number":557,"context_line":"\t\tnb \u003d count;"},{"line_number":558,"context_line":"\t}"}],"source_content_type":"text/x-csrc","patch_set":4,"id":"AAAB2H%2F%2F%2Fbo%3D","line":555,"updated":"2013-09-21 13:04:48.000000000","message":"page_size would be better suited as an unsigned quantity, instead of having to cast here and there.","commit_id":"a1a63acf3d98e0f9ee4beaa5fff2b61df91146b0"},{"author":{"_account_id":1000433,"name":"Andrey Yurovsky","email":"yurovsky@gmail.com","username":"andrey"},"change_message_id":"acb86ff4c18398ed89bee92e2977a2e656655138","unresolved":false,"context_lines":[{"line_number":552,"context_line":"\t\tnb \u003d chip-\u003epage_size - (offset % chip-\u003epage_size);"},{"line_number":553,"context_line":"\t\tif (nb \u003e count)"},{"line_number":554,"context_line":"\t\t\tnb \u003d count;"},{"line_number":555,"context_line":"\t} else if (count \u003c (uint32_t)chip-\u003epage_size) {"},{"line_number":556,"context_line":"\t\t/* We\u0027re writing an aligned but partial page. */"},{"line_number":557,"context_line":"\t\tnb \u003d count;"},{"line_number":558,"context_line":"\t}"}],"source_content_type":"text/x-csrc","patch_set":4,"id":"AAAB2H%2F%2F%2Fbc%3D","line":555,"in_reply_to":"AAAB2H%2F%2F%2Fbo%3D","updated":"2013-09-21 14:42:50.000000000","message":"Ok, will do.","commit_id":"a1a63acf3d98e0f9ee4beaa5fff2b61df91146b0"},{"author":{"_account_id":1000005,"name":"Andreas Fritiofson","email":"andreas.fritiofson@gmail.com","username":"Nattgris"},"change_message_id":"cc3623b793fb72cac260b2ada0cec99fcd48f202","unresolved":false,"context_lines":[{"line_number":631,"context_line":""},{"line_number":632,"context_line":"\t\tif (res !\u003d ERROR_OK)"},{"line_number":633,"context_line":"\t\t\treturn res;"},{"line_number":634,"context_line":"\t}"},{"line_number":635,"context_line":""},{"line_number":636,"context_line":"\treturn ERROR_OK;"},{"line_number":637,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":4,"id":"AAAB2H%2F%2F%2Fbk%3D","line":634,"updated":"2013-09-21 13:04:48.000000000","message":"As this code above is practically identical to the leading partial page case, I think the flow would be clearer if you replace the preceding four if:s with a loop as long as there is anything left to write (while (count \u003e 0)). And in the loop, if offset is unaligned or count \u003c page_size (partial page, either leading, trailing or both), you do the above, otherwise write directly from buffer.\n\nAlso I think it would be good to keep the number of state-keeping variables down. Now you have offset, buffer, count and f_addr. Four variables but only three degrees-of-freedom means there are some dependency between these variables, making it difficult to make sure they are in sync. In fact, I think you have one or two bugs here, because you update only offset, count and f_addr, still you base the source address calculations on \u0027buffer\u0027 alone. I suggest you drop either f_addr or offset and make sure to update the remaining three in the loop.","commit_id":"a1a63acf3d98e0f9ee4beaa5fff2b61df91146b0"},{"author":{"_account_id":1000433,"name":"Andrey Yurovsky","email":"yurovsky@gmail.com","username":"andrey"},"change_message_id":"acb86ff4c18398ed89bee92e2977a2e656655138","unresolved":false,"context_lines":[{"line_number":631,"context_line":""},{"line_number":632,"context_line":"\t\tif (res !\u003d ERROR_OK)"},{"line_number":633,"context_line":"\t\t\treturn res;"},{"line_number":634,"context_line":"\t}"},{"line_number":635,"context_line":""},{"line_number":636,"context_line":"\treturn ERROR_OK;"},{"line_number":637,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":4,"id":"AAAB2H%2F%2F%2FbU%3D","line":634,"in_reply_to":"AAAB2H%2F%2F%2Fbk%3D","updated":"2013-09-21 14:42:50.000000000","message":"For full pages we just write while for the last page (if it\u0027s less than a page\u0027s worth of data) we need to read-modify-write.  I can roll that into one loop instead of two sets of writes though.  I\u0027ll reduce the state variables by eliminating f_addr;","commit_id":"a1a63acf3d98e0f9ee4beaa5fff2b61df91146b0"}],"tcl/target/at91sam4XXX.cfg":[{"author":{"_account_id":1000005,"name":"Andreas Fritiofson","email":"andreas.fritiofson@gmail.com","username":"Nattgris"},"change_message_id":"76601688404050289948c28a758851bb5a1e3668","unresolved":false,"context_lines":[{"line_number":51,"context_line":" jtag_ntrst_delay 100"},{"line_number":52,"context_line":"}"},{"line_number":53,"context_line":""},{"line_number":54,"context_line":"cortex_m reset_config srst"}],"source_content_type":"text/x-ttcn-cfg","patch_set":1,"id":"AAAB2H%2F%2F%2Fc0%3D","line":54,"updated":"2013-09-20 22:46:11.000000000","message":"Why change this?","commit_id":"519209deef3a1c965e2f07e0b66094f88f1dc68a"},{"author":{"_account_id":1000433,"name":"Andrey Yurovsky","email":"yurovsky@gmail.com","username":"andrey"},"change_message_id":"6a43dea9f05a7f0bb4cf2d5d69cad7f2ca7ca9a8","unresolved":false,"context_lines":[{"line_number":51,"context_line":" jtag_ntrst_delay 100"},{"line_number":52,"context_line":"}"},{"line_number":53,"context_line":""},{"line_number":54,"context_line":"cortex_m reset_config srst"}],"source_content_type":"text/x-ttcn-cfg","patch_set":1,"id":"AAAB2H%2F%2F%2Fcg%3D","line":54,"in_reply_to":"AAAB2H%2F%2F%2Fc0%3D","updated":"2013-09-20 22:55:28.000000000","message":"I\u0027ll take it out if this change but sysreset does not work for me at all.  I\u0027ll follow up with Spencer Oliver to see if its a cmsis dap issue or if I\u0027ve messed something up.","commit_id":"519209deef3a1c965e2f07e0b66094f88f1dc68a"}]}
