NishanthMenon changed the topic of #openocd to: this is the place to discuss all things OpenOCD | Logs: https://libera.irclog.whitequark.org/openocd/
Steffanx- has quit [Ping timeout: 244 seconds]
mithro has quit [Ping timeout: 244 seconds]
dreamcat4 has quit [Ping timeout: 260 seconds]
key2 has quit [Read error: Connection reset by peer]
borneoa_ has quit [Read error: Connection reset by peer]
devanagram has quit [Read error: Connection reset by peer]
NishanthMenon has quit [Write error: Connection reset by peer]
nohit has quit [Ping timeout: 268 seconds]
abg has quit [Ping timeout: 250 seconds]
key2 has joined #openocd
borneoa_ has joined #openocd
devanagram has joined #openocd
dreamcat4 has joined #openocd
borneoa_ has quit [Ping timeout: 268 seconds]
devanagram has quit [Ping timeout: 264 seconds]
dreamcat4 has quit [Ping timeout: 256 seconds]
key2 has quit [Ping timeout: 264 seconds]
devanagram has joined #openocd
key2 has joined #openocd
borneoa_ has joined #openocd
nohit has joined #openocd
dreamcat4 has joined #openocd
Steffanx- has joined #openocd
mithro has joined #openocd
abg has joined #openocd
NishanthMenon has joined #openocd
tsal has quit [Ping timeout: 240 seconds]
tsal has joined #openocd
Hawk777 has joined #openocd
cluelessperson has quit [Ping timeout: 256 seconds]
cluelessperson has joined #openocd
nerozero has joined #openocd
key2 has quit [Ping timeout: 256 seconds]
devanagram has quit [Ping timeout: 256 seconds]
key2 has joined #openocd
devanagram has joined #openocd
Haohmaru has joined #openocd
tomtastic has quit [Ping timeout: 240 seconds]
tomtastic has joined #openocd
Haohmaru has quit []
Hawk777 has quit [Quit: Leaving.]
Haohmaru has joined #openocd
xantoz has joined #openocd
devanagram has quit [Read error: Connection reset by peer]
key2 has quit [Read error: No route to host]
dreamcat4 has quit [Ping timeout: 264 seconds]
mithro has quit [Ping timeout: 268 seconds]
NishanthMenon has quit [Ping timeout: 260 seconds]
Steffanx- has quit [Ping timeout: 256 seconds]
abg has quit [Ping timeout: 260 seconds]
Steffanx- has joined #openocd
nohit_ has joined #openocd
key2 has joined #openocd
devanagram has joined #openocd
nohit has quit [Ping timeout: 268 seconds]
borneoa_ has quit [Ping timeout: 268 seconds]
nohit_ is now known as nohit
dreamcat4 has joined #openocd
mithro has joined #openocd
NishanthMenon has joined #openocd
abg has joined #openocd
borneoa_ has joined #openocd
JakeSays has quit [Ping timeout: 260 seconds]
JakeSays has joined #openocd
key2 has quit [Ping timeout: 256 seconds]
nohit has quit [Ping timeout: 260 seconds]
devanagram has quit [Ping timeout: 250 seconds]
borneoa_ has quit [Ping timeout: 240 seconds]
dreamcat4 has quit [Ping timeout: 250 seconds]
Steffanx- has quit [Ping timeout: 264 seconds]
NishanthMenon has quit [Ping timeout: 240 seconds]
abg has quit [Ping timeout: 250 seconds]
mithro has quit [Ping timeout: 264 seconds]
mithro has joined #openocd
Steffanx- has joined #openocd
NishanthMenon has joined #openocd
abg has joined #openocd
borneoa_ has joined #openocd
dreamcat4 has joined #openocd
key2 has joined #openocd
nohit has joined #openocd
devanagram has joined #openocd
emeb has joined #openocd
Hawk777 has joined #openocd
Haohmaru has quit []
capin has joined #openocd
capin is now known as ipatch
BorgCuba has joined #openocd
<BorgCuba> Hi ppl, how can I teach openocd to erase/write/read flash for my device?
<BorgCuba> I know the procedure and registers from the datasheet
<Hawk777> If it’s a chip type that is supported, you would need to just write a config file for the board. If it’s not, you would need to write C code. If it’s very similar to a device that is already supported, you might be able to add it to an existing flash driver; otherwise, you would need to write a fresh Flash driver. Assuming it’s something like an ordinary on-board microcontroller Flash, look in src/flash/nor for examples.
<PaulFertser> BorgCuba: what's the target core?
<BorgCuba> The MCU is an HK32F030M cortex-M
<BorgCuba> somebody else already left some notes on the EN internet: http://nerdralph.blogspot.com/2020/12/trying-to-test-ten-cent-tiny-arm-m0-mcu.html
<PaulFertser> BorgCuba: is it probably a clone of an stm32?
<BorgCuba> and has this pyocd script for erasing: https://github.com/nerdralph/HK32F030M/blob/master/hk32erase.pyocd
<BorgCuba> PaulFertser, very similar but not really compatible I think
<PaulFertser> BorgCuba: yeah, cool, so drivers for devices like that are in src/flash/nor , do you have any specific questions about it?
<BorgCuba> PaulFertser, so I have to write C code and build openocd from source? Initially I thought maybe I can just define a .cfg.
<BorgCuba> Where can I get the source?
<PaulFertser> BorgCuba: yes, flash drivers in OpenOCD are in C.
<PaulFertser> BorgCuba: if there's any issue with the official website please report.
<BorgCuba> I am cloning from the sf.net repo
<PaulFertser> BorgCuba: good. Is OpenOCD able to talk to the core already? The blog post suggests there's some problem with it.
<BorgCuba> PaulFertser, yes a little bit
<PaulFertser> BorgCuba: so what's the trick?
<BorgCuba> what is the paste bin you use here?
<PaulFertser> Ah, part2 I should read.
<PaulFertser> BorgCuba: I personally prefer paste.debian.net or you can cat to nc termbin.com 9999 or probably any other you prefer.
<BorgCuba> PaulFertser, this is my config and the console output: http://paste.debian.net/1219158/
<BorgCuba> I can read with mdw and so on but it is not showing any flash banks
<PaulFertser> BorgCuba: yeah, all looks perfect.
<Hawk777> Sounds like it’s a Cortex-M but with an unsupported Flash bank, so you’d just have to write a Flash driver for it?
<PaulFertser> Right
<BorgCuba> Hawk777, I think you are right. I will have a look at ./src/flash/nor/stm32f1x.c and the datasheet
<PaulFertser> It might be even compatible to that, yes, if you add the device id and appropriate page sizes.
<BorgCuba> the register addresses look good so far
<PaulFertser> BorgCuba: is that chip still available, no shortage?
<BorgCuba> PaulFertser, available but the price went up significantly
<PaulFertser> BorgCuba: how much is it now?
<BorgCuba> I think I bought 30pcs for around 30ct/pc and now its 1.15$
<PaulFertser> BorgCuba: I think I understand most of the flash driver code so feel free to ask if anything is unclear.
<BorgCuba> Okay, thanks
<BorgCuba> PaulFertser, I tried using the stm32f1x config but it complains about the ID value: http://paste.debian.net/1219162/
<PaulFertser> BorgCuba: where's device id register at according to the vendor doc?
<BorgCuba> should be the same address: 0x40015800
<BorgCuba> Ahh, F0
<PaulFertser> BorgCuba: it's M0 too so 0x40015800 should be used in your case. You can run openocd with -d2 and you'll see what addresses really get accessed when.
nerozero has quit [Ping timeout: 250 seconds]
<karlp> is it actually m0 and not m0+?
<karlp> ah no, that particular stm32 line is from unkonwn devid.
<BorgCuba> PaulFertser, mdw 0x40015800 gives 0
<karlp> you're options for permanent are to figure out a way of identifying it, but I can't se anything obvious in that chinese datasheet
<karlp> or, as a hack, just change the default case to fill in the params you want for your part, instead of rejecting as unknown...
<PaulFertser> BorgCuba: probably the datasheet isn't too accurate then.
<karlp> there's also a line on determining flash size, which may not be implemented on that target either.
<karlp> the stm32f1 impl doesn't really have any hooks for "just pretend it's an f1 with these params..." the way pyocd does.
<BorgCuba> PaulFertser, section 5.23.1 says that the address of DBGMCU_IDCODE is 0x40015800 and the value should read 0x20000440
<karlp> which document have you guys got?
<PaulFertser> BorgCuba: looks like they really tried to mimic stm32f05x then :)
<karlp> you said it's not reading 0x440 though anyway?
<karlp> the datasheet on nerdralph doesn't have any section 5 beyond "TBD"
<BorgCuba> let me see if I can find it
<karlp> and you say that's reading zero though? at 0x40015800?
<BorgCuba> yes, but maybe mdw does not work for that address?
<BorgCuba> how would you read the idcode?
<BorgCuba> Btw, could you open that URL?
<karlp> yeah, that doc looks way better.
<PaulFertser> BorgCuba: mdw it is
<karlp> I was just trying to see if it needs anything insyscfg turned on to access ram or anything weird.
<karlp> but nothing obvious.
<karlp> it seems to try _really_ hard to mimic the f050, with the right part id and all, unlike the APM32 someone was trying here the other day.
<karlp> even has the flash size register documented.
<karlp> run it again with -d3 and see all the addresses it access, and what really returns, but it definitelys appears to be not following the datasheet....
<karlp> (are you sure it's that hk32 and not another type of clone?)
<bencoh> so now they clone chips, not just boards? funny
<bencoh> (complex~ish chips I mean)
<PaulFertser> bencoh: since long!
<PaulFertser> bencoh: https://zeptobars.com/en/read/FTDI-FT232RL-real-vs-fake-supereal already quite complex
<BorgCuba> karlp, this is with -d3: http://paste.debian.net/1219164/
<BorgCuba> karlp, the part number on the chip suggests its a HK32F030MF4P6 and I bought it from lcsc.com
<BorgCuba> can mdb display data like hexdump does with -C?
<PaulFertser> BorgCuba: no. Use dump_image and then hexdump
<BorgCuba> PaulFertser, good idea
<BorgCuba> seems it actually is preprogrammed with some code
<PaulFertser> BorgCuba: you can try debugging it :) "reset halt" and then "step" "step" "step" :)
<PaulFertser> Probably used for production testing
<BorgCuba> PaulFertser, here are 64k data starting at 0800.0000: https://termbin.com/lp0v
<BorgCuba> whats the objdump target -m arm ... thumb ??
<bencoh> trying to disass it?
<BorgCuba> yes
<PaulFertser> BorgCuba: the beginning looks strange, it should have stack pointer address and then reset handler address with thumb (lowest) bit set.
<bencoh> you could even try do "decompile" it if you're really into it (retdec for instance)
<BorgCuba> just for fun, to see if it makes any sense
<BorgCuba> but I think I have an old IDA version somewhere
<BorgCuba> makes kind of sense: https://termbin.com/e01t
<BorgCuba> btw, it is -D -b binary -m arm -Mforce-thumb for objdump
<PaulFertser> BorgCuba: probably the first page was overwritten later by some other tests
<BorgCuba> PaulFertser, could be
<BorgCuba> still I did not manage to read the idcode
<PaulFertser> BorgCuba: ignore it, try to treat it as if it's an stm32f0 device with 128 bytes page size
<BorgCuba> PaulFertser, do stm32 targets initialize clocks at startup?
<BorgCuba> there are RCC bits for the DBGMCU but enabling the DBMCU and resetting it does not yield an IDCODE != 0
<PaulFertser> BorgCuba: not by default, but debug clock is generic and should be enabled by OpenOCD.
<BorgCuba> yeah, and the flash is also readable
<BorgCuba> so some clocks should be running
<BorgCuba> PaulFertser, without idcode and flash-size this device would not fit in with stm32-flash drivers I fear or what do you think?
<PaulFertser> BorgCuba: wouldn't fit upstream but you should first see if it works at all as a quick hack.
<BorgCuba> PaulFertser, so you suggest I should remove the idcode check and hardcode flash size, build openocd and then try to flash the hk32 with the stm32 driver?
<BorgCuba> general question: will risc-v bury arm?
<BorgCuba> Btw, does openocd read erased flash as all 0 or 1?
<PaulFertser> BorgCuba: different MCUs have different erase flash bits.
<PaulFertser> BorgCuba: OpenOCD reads what's really there.
<BorgCuba> In this case it seems to be all 0s
<PaulFertser> That's possible.
<PaulFertser> BorgCuba: arm, pic, avr, stm8 etc didn't bury 8051 and mips.
<BorgCuba> good point
<BorgCuba> I just entered the erase sequence manually. But after reading it back its mostly 0 but some bits are set, i.e. occasionally you can see a 1 2 4 8.
<BorgCuba> Maybe its due to my very cheap setup: 2 pull up resistors(clk,io), 3 caps, µusb, ch551g (as cmsis-dap usb adapter) and hk32f030
<bencoh> are you certain the erase really "worked" though?
<BorgCuba> bencoh, how can I be sure?
<BorgCuba> What I could verify is that the memory looks more 0ish now
<bencoh> that's a good start I guess
<BorgCuba> because I dumped 0x8000000 before and after the erase
<BorgCuba> good night boys
BorgCuba has quit [Quit: Leaving]
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #openocd
emeb has quit [Ping timeout: 256 seconds]
nathanhi has quit [Quit: bye]
nathanhi has joined #openocd