NishanthMenon changed the topic of #openocd to: this is the place to discuss all things OpenOCD | Logs: https://libera.irclog.whitequark.org/openocd/
wingsorc__ has joined #openocd
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
wingsorc has quit [Remote host closed the connection]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
extor has quit [Ping timeout: 255 seconds]
extor has joined #openocd
Bugies has quit [Ping timeout: 248 seconds]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
tsal has quit [Ping timeout: 272 seconds]
tsal has joined #openocd
extor has quit [Remote host closed the connection]
Hawk777 has joined #openocd
akaWolf has quit [Ping timeout: 246 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd
olerem has quit [Quit: WeeChat 2.3]
olerem has joined #openocd
olerem has quit [Client Quit]
olerem has joined #openocd
olerem has quit [Client Quit]
olerem has joined #openocd
olerem has quit [Client Quit]
olerem has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
nerozero has joined #openocd
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 248 seconds]
shoragan is now known as Guest3417
Guest3417 has quit [Killed (silver.libera.chat (Nickname regained by services))]
shoragan_ is now known as shoragan
shoragan_ has joined #openocd
Haohmaru has joined #openocd
olerem has quit [Quit: WeeChat 2.3]
olerem has joined #openocd
olerem has quit [Client Quit]
olerem has joined #openocd
_olerem has joined #openocd
_olerem has quit [Client Quit]
_olerem has joined #openocd
_olerem has quit [Client Quit]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd
Hawk777 has quit [Quit: Leaving.]
JakeSays has quit [Ping timeout: 272 seconds]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
Bugies has joined #openocd
shoragan_ has quit [Quit: quit]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
wingsorc__ has quit [Ping timeout: 252 seconds]
simon_ has joined #openocd
<simon_> Hi. I might have a bug report. I want to flash 8 bytes from a hex file onto stm32f301 using an ST-link. The command looks like this: openocd -f interface/stlink.cfg -c "transport select hla_swd" -f target/stm32f3x.cfg -c "reset_config none separate" -c init -c halt -c "reset init" -c "flash write_image data.hex" -c exit. Also i'm using Ionescu's OpenOCD builds. This command works with OpenOCD version 0.11.0-4 (2022.03.25) but fails with 0.11.0-5 (2022.09.01)
<simon_> The error message is: Error: corrupted fifo read pointer 0x20000044
<simon_> Is this a known issue?
<karlp> sounds like you want to go and check wht ionescu what is the actually difference between those builds :)
<simon_> I also compiled OpenOCD from sources (0.12-rc) 2 days ago and the error was still there.
<simon_> I thought Ionescu does vanilla builds? Anyways my build was from original OOCD source. :) But i cat try it again just to be sure.
<karlp> it just sounds like a very small window, would be easys to see hwat the difference was?
<simon_> Additional note, the flashing works corretly with payloads of 20 bytes.
<karlp> right, ok, might just be that the flashing stub loader is using unitialized memory for the remainder then?
<karlp> and the -4 build just by hcance had different uninit memory.
<simon_> I tried to check the differences, but could not figure out much. I have no idea of internal workings of OpenOCD.
<karlp> you'd have to dig into the code then if that's the case, I'm not sure flashing 8 bytes is a very common use case to have run into it.
<simon_> I have an even older build 0.11.0-1 which also works correct.
<karlp> I wouldn't be surprised if that's just gcc builds of unitialized memory having changed,
<karlp> I would suspect a bug in the flash loader stub for handling small things like this.
<simon_> Flash loader stub is the code that is executed on the target side?
<karlp> yeah.
<karlp> either there or the code that loads the buffer into be flashed. should be a fairly small target area of code though if you have working 20bytes and failing 8 bytes.
<simon_> I tried to debug my build of the OpenOCD a little. And it looks like target_run_flash_async_algorithm is called with buffer_start = 0x20000044 and buffer_size = 8. This function then calculates fifo_start_addr and fifo_end_addr. And the error is raised because those 2 values are equal (rp = fifo_start_addr = fifo_end_addr)
sbach has quit [Read error: Connection reset by peer]
sbach has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
erhankur has quit [Ping timeout: 260 seconds]
wingsorc has joined #openocd
erhankur has joined #openocd
akaWolf has joined #openocd
Battosai42 has joined #openocd
<simon_> So it looks like target_run_flash_async_algorithm requires (and checks) a flash loader buffer of size of data size plus 2 words (8 bytes) for read and write pointers. stm32f1x.c was changed in that it tries to allocate only the bare minimum of RAM. I.e. if data size is 8 bytes then it allocates only 8 bytes for the flash loader buffer.
<simon_> In the stm32f1x.c i changed the line buffer_size = MIN(hwords_count * 2, MAX(buffer_size, 256)); to buffer_size = MIN(hwords_count * 2 + 8, MAX(buffer_size, 256)); and it seems to work now.
<simon_> I believe that flashing any payload of 8 or less bytes on stm32f1 targets will fail with the current code.
<simon_> Commit e3f4ea0b574d952672d57792895a91065aa7a569 has introduced this change. The old code tried to allocate the buffer as big as possible. Then the buffer was always big enough to hold data and read/write pointers.
<simon_> Would be cool if some knowing person looked at it and maybe confirmed.
<karlp> so, fwiw, you could get a zero code workaround for your specific problem by setting the workarea to 0 in your tcl config file
<karlp> it should fall back to word by word programming, but you're only programming 8 bytes anyway, so no big deal perf wise.
<karlp> I don't see how anything less than 20 works, it writes 5 words into the buffer to transfer?
<karlp> oh, but it takes words * 2 for some reason,
<karlp> yeah, looks bogus to me.
<karlp> just make a comment on gerrit on https://review.openocd.org/c/openocd/+/6708 and they'll see it.
<karlp> thomas is pretty responsive,
akaWolf has quit [Ping timeout: 252 seconds]
<simon_> It takes 2 * halfwords, the resulting size does match the size of the data. I get 10 halfwords for 20 byte payload and 4 halfword for 8 bytes.
<simon_> What i completely not understand is the size of the fifo buffer on target. Does it not have to be the size of the data? But then why does the allocation takes the size of the data as input parameter? Why not just always allocate like 256 bytes? Or even 16 bytes for stm since flashing works at most doubleword-wise.
extor has joined #openocd
<PaulFertser> simon_: I can't answer your question specifically but in general it makes sense to allocate plenty of RAM for the ring-buffer from which the target algorithm is taking the data so that it wouldn't be drained if the computer is busy with something else while the flashing process is ongoing.
<PaulFertser> simon_: the process is normally fully async lock-free.
<karlp> yeah, the change linked tries to go for the min of (flashing_data_size, 256) with the expectatoin that it would be 256 ....
<karlp> I don't think it was considered that it would be _less_ than 256, and that it had an actual hard lower limit of it's own.
<PaulFertser> simon_: why do you think reg_params are included in that buffer? It looks like they are allocated separately.
<PaulFertser> simon_: guess you're right, it needs 8 extra bytes first.
<simon_> It's not the reg_params. The target_run_flash_async_algorithm function at lines 1017-1020 sets wp_addr = buffer_start, rp_addr = buffer_start + 4, fifo_start_addr = buffer_start + 8.
<simon_> For me it looks like the function expects at least 8 bytes more in addition to the fifo buffer itself.
<PaulFertser> simon_: so if you can easily reproduce it, can you try a trivial fix: s/hwords_count * 2/hwords_count * 2 + 8/ ?
<simon_> This fix is exactly what i did and it did work for me.
<simon_> buffer_size = MIN(hwords_count * 2, MAX(buffer_size, 256));
<simon_> in stm32f1x.c
<PaulFertser> simon_: so feel free to send a patch to Gerrit. Since it's a fix it'll be fixed before final release.
<simon_> Just to explain the use-case. :) We flash multiple hex files with a single openOCD command. Some of these filea are just configuration values, hence the small size.
<simon_> @PaulFertser, do i need to register there?
akaWolf has joined #openocd
<PaulFertser> simon_: not really, one can use existing bitbucket/github/openid account.
<PaulFertser> Or google account.
<simon_> PaulFertser: haha, if only i had one
<PaulFertser> simon_: how about a launchpad id?
<PaulFertser> simon_: how do you contribute to github projects?
akaWolf has quit [Ping timeout: 248 seconds]
<simon_> PaulFertser: sorry, i try to avoid all kinds of accounts.
<PaulFertser> simon_: if you really have a serious reason not to register on one of those, and you promise to answer mails if there're review comments, I can push the patch to Gerrit on your behalf.
<simon_> PaulFertser: That would be dope. Email i can share.
<PaulFertser> simon_: so please do git format-patch HEAD^, upload it to some pastebin, share the link with me, I'll push your patch.
<simon_> Also i don't really need my name mentioned anywhere
akaWolf has joined #openocd
nerozero has quit [Ping timeout: 260 seconds]
Bugies has quit [Remote host closed the connection]
Bugies has joined #openocd
simon_ has quit [Remote host closed the connection]
simon_ has joined #openocd
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
Haohmaru has quit []
<PaulFertser> Tomas already approved the change, cool!
erhankur has quit [Ping timeout: 260 seconds]
<simon_> That went quick. Thank you guys for your assistance.
<PaulFertser> Thank you for the patch :)
nerozero has joined #openocd
JakeSays has joined #openocd
erhankur has joined #openocd
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
simon_ has quit [Remote host closed the connection]
JakeSays has quit [Ping timeout: 248 seconds]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
erhankur has quit [Read error: Connection reset by peer]
erhankur has joined #openocd
Battosai42 has quit [Quit: Client closed]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
nerozero has quit [Ping timeout: 252 seconds]
wingsorc has quit [Quit: Leaving]
akaWolf has quit [Ping timeout: 248 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 248 seconds]
akaWolf has joined #openocd
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
akaWolf has quit [Ping timeout: 252 seconds]
wingsorc__ has joined #openocd
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 248 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
erhankur has quit [Ping timeout: 252 seconds]
erhankur has joined #openocd
akaWolf has joined #openocd
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #openocd
erhankur has quit [Ping timeout: 246 seconds]
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd
akaWolf has quit [Ping timeout: 260 seconds]
akaWolf has joined #openocd