<roland>
hi, I'm trying to flash a NXP lpc55s36 board using openocd, but it looks like the board is not supported. the closest I can find is https://review.openocd.org/c/openocd/+/6800?tab=comments , but that's not compatible w/ lpc55s36.
<roland>
Error: timed out while waiting for target halted
<roland>
** Unable to reset target **
<roland>
shutdown command invoked
Hawk777 has joined #openocd
dliviu has quit [Ping timeout: 252 seconds]
dliviu has joined #openocd
SoFarAway has joined #openocd
SoFarAway has left #openocd [Leaving]
roland has quit [Quit: Client closed]
roland has joined #openocd
roland has quit [Quit: Client closed]
roland has joined #openocd
nerozero has joined #openocd
roland has quit [Ping timeout: 250 seconds]
Hawk777 has left #openocd [#openocd]
<zapb_>
roland, the main problem is probably that there is no driver for the flash of this microcontroller in OpenOCD
roland has joined #openocd
<roland>
can anyone see my messages?
<PaulFertser>
roland: hi
<PaulFertser>
roland: yes, and in the future please use sme pastebin to show anything more than 2-3 lines.
<PaulFertser>
roland: to flash you need a flash driver for this target. The debug is working apparently as you get "Cortex-M33 r0p4 processor detected".
<roland>
ah, sorry. I'll do that. thanks for the suggestion
<roland>
I'm using the nxp lpc55s36 dev board, so that has a driver to do it. or are you referring to something else?
Haohmaru has joined #openocd
<roland>
I can flash the MCU via MCUExpresso IDE, so that works. but it does not work via openocd, and I'm kind of lost as to what's going on. I have more logs, I'll paste here via pastebin
<PaulFertser>
roland93: I mean OpenOCD needs support for flash peripheral controller of the particular MCU.
<PaulFertser>
If you want to modify flash by regular OpenOCD means.
<PaulFertser>
The last log says even debug adapter wasn't found, but your earlier logs were showing communication with the debug adapter was fine.
<PaulFertser>
So that's different state.
<roland93>
I see. that means it cannot be done just by config? and it would require some impl. to be done?
<roland93>
on the logs, yeah, I was trying different config to see if I can get something running ... I'm not that familiar with the stack, so I'm pretty much shooting in the dark there
renrelkha has quit [Quit: bye]
renrelkha has joined #openocd
<PaulFertser>
roland93: you can probably upload some bootloader to RAM and control it over serial to ask it to flash.
<PaulFertser>
roland93: or you can write a driver or change an existing flash driver if there's a similar thing already.
<PaulFertser>
roland93: it's not too complicated usually when there're docs for MCU available.
<PaulFertser>
roland93: if you have any specific question I'll try to answer
<roland93>
in an idea world, the setup should be simple: arm32 machine w/ a debian based distro -> pins to the MCU -> MCU and flash the MCU from the arm32 machine using openocd. we've been doing that with a different chip family that's currently supported (kinetis). so we were trying to do the same, but the NXP LPC55S36 chip instead, which is not supported by
<PaulFertser>
roland93: hm is it really NAND flash? Probably it's a bit easier to run some ready-made code like e.g. U-boot and use that for the flashing?
<roland93>
do you have some example or blog showing how I would do that? load the bootloader (uboot) to RAM and then flash the fw hex onto ROM/flash mem?
<roland93>
also, would you be open to consulting services? as in, help me/us get something working/implemented?
roland93 has quit [Quit: Client closed]
<karlp1>
no, ignore the nand distraction
<karlp1>
it's just an M33, you want to look at nor/lpc288x.c, nor/lpc2800.c nor/lpc2900 and nor/kinetis.c and see which one is closest.
<karlp1>
(it's _probably closest to LPC heritage than kinetis heritage given the part naming....)
<PaulFertser>
It wasn't me mentioning NAND :)
<PaulFertser>
(first)
<PaulFertser>
But roland already left
<karlp1>
whatever then.
<karlp1>
yeah, i think roland just saw flash nand and recognised the word.
roland has joined #openocd
rolf has quit [Remote host closed the connection]
rolf has joined #openocd
rolf has quit [Remote host closed the connection]
rolf has joined #openocd
<karlp1>
lpc288x is used in no config files...
<PaulFertser>
roland: you come and go and miss messages
<roland>
PaulFertser sorry, I was commuting. I probably missed some messages
<PaulFertser>
roland: re using a bootloader, the idea is to use something your familiar with, just upload it to SRAM with "load_image" and let it run to do whatever job you need to be done.
<olerem>
replace barebox to what ever you can use instead
<karlp1>
yeah, it's just an m33, they're not goin gto find barebox or uboot for it...
<karlp1>
it might be a "big" one, but thats still just way more work.
<roland>
PaulFertser so based on the https://paste.debian.net/1305141/ , I'd need to copy one of those impl. and make the changes required for LPC55S36, then rebuild openocd to include that driver
<karlp1>
copy would be the fast and dirty method, yes. you probably want to add to the lpc2000 drive,r it sseems to be the most extensible one, with support for the most parts, including some lpc4 and lpc5 parts.
<karlp1>
can you pastebin a link ot your config you got up earlier?
<karlp1>
nvm, it's all in the scrollback
<karlp1>
I'd just try adding `flash bank $_CHIPNAME.flash lpc2000 <flash address> <flash size> 0 0 $_CHIPNAME.<cpu?> lpc4300....." stuff
<karlp1>
(have a look at tcl/target/lpc4357.cfg for inspiration)
<karlp1>
and see what the lpc2000 autoprobe driver detects...
<karlp1>
I don't know. I'd _guess_ that 55s16 is closer to 55ss32 :)
<karlp1>
those cfg files are fine, you still need the flash bank at the bottom though to actually write to flash, not just debug
<roland>
ah, ok
<karlp1>
I just added a comment on #6800 too, the work area size definition is far too big, which would come and bite you later :)
<roland>
so I've got https://pastebin.com/0qrHTMcn and a script https://pastebin.com/zuArpNP3 that runs openocd. gonna run again and paste the output . I'll then try to find the flash bank stuff I need to fill in and re-run to see what happens
<karlp1>
(same for you, setting work area size more than 32k/64k does nothing, and if that 112k isn't contiguous, or available all the time, with things like core coupled memory and so on, it's not even actually available)
<karlp1>
so, read what that one says, and continue...
<roland>
"Error: 67 15 tcl.c:1298 handle_flash_bank_command(): 'lpc2000' driver rejected flash bank at 0x00000000; usage: (null)" which would suggest I'm using the cmd the wrong way ...
<karlp1>
correct ...
<karlp1>
it's harder to see with that -d3,
<karlp1>
but it's giving you the command help
<roland>
"User : 69 15 command.c:741 command_help_show_indent(): User : 70 15 command.c:757 command_help_show_wrap(): flash bank bank_id driver_name base_address size_bytes chip_width_bytes"
<karlp1>
you can't just go "000000"
<karlp1>
but you're on the right track now I think :)
<roland>
does that mean I can add "flash list" which would list the banks available? I will also look through the data sheet to try to find this info
<roland>
ah: "Retrieves a list of associative arrays for each device that was declared using flash bank, numbered from zero. This returned list can be manipulated easily from within scripts." which probably means it'll just list the stuff I declared as flash bank ...
<karlp1>
try flash bank $_FLASHNAME lpc2000 0 <flash length> 0 0 $_TARGETNAME auto <clkspeed? try 0 or 200000 or something...> calc_checksum"
<karlp1>
(from the doc page I linked...)
<roland>
so "flash bank $_FLASHNAME lpc2000 0 200000 0 0 $_TARGETNAME calc_checksum" or is the auto and clkspeed something I need to add as well?
<karlp1>
yes, read the doc page (html) that I linked, it talks abotu teh requried and optional parameters...
<karlp1>
you need to specify "variant" and "clock speed"
<karlp1>
that 20000 is meant ot be the size of the flash?
<karlp1>
you _may_ be able to put 0 there and have it be detected, I don't know, or you should put the right value there.
<karlp1>
basically at the very top of that Flash-Commands.html page it has the help for "flash bank"
<karlp1>
you need to get the first parameters right, then also scroll down and read the lpc2000 for the "[driver_options]"
<roland>
yeah, but the driver opts are not there, or I cannot find the it seems
<karlp1>
they are down in the lpc2000 section.
<karlp1>
scroll down
<roland>
ok
<roland>
ok, used the following:
<roland>
flash bank $_FLASHNAME lpc2000 0 0 0 0 $_TARGETNAME auto 100000 calc_checksum
<PaulFertser>
roland: do not use program. Just start openocd, connect with telnet and try different commands.
<PaulFertser>
roland: if reset halt can't halt it, try just "halt".
<PaulFertser>
roland: and if you manage to halt it, then do "flash info 0" to trigger probing.
<PaulFertser>
roland: and since OpenOCD is a tool for embedded developers it should be reasonably easy to dig src/flash/nor/lpc2000.c to see what's happening.
<roland>
just getting into this, so I'm by no means an embedded dev. but I appreciate all the help and patience
<roland>
"start openocd, connect with telnet and try different commands." not familiar with it, but I'll do a quick search try to figure that out
<PaulFertser>
I mean embedded dev as in someone who uses C language to write firmware for MCUs and bare metal SoCs.
<Haohmaru>
C x_x
<Haohmaru>
openocd needs some more dumb-friendly examples IMO, i can't easily figure it out, so i should probably write a page on my website with some simple example invokations
<Haohmaru>
i mean, they surely exist on the internet, just not in the documentation itself
<PaulFertser>
Examples of what?
<Haohmaru>
not just examples (of invoking openocd) but also some very basic introduction
<PaulFertser>
I do not understand what you mean, what exactly is lacking in the User Manual? It explains it all like a textbook from the basics.
<Haohmaru>
all i'm saying is that the documentation is too high level for.... some people ;P~
<Haohmaru>
that's not openocd's fault
<PaulFertser>
Documentation is maintained as part of the software, we can improve it.
<PaulFertser>
If you're reading it from the beginning, where exactly is the too complicated part starts?
<Haohmaru>
i can't even tell, i already learned some of those things so i have them in my head, for the other things - i just write the whole command somewhere with explanation what it does
<Haohmaru>
don't take this as criticism, it's more my problem, i have the same thing with "git"
<Haohmaru>
thousands of people don't have a problem with git... i do
<roland>
ok, so started openocd:
<roland>
Info : 214 485 gdb_server.c:3791 gdb_target_start(): starting gdb server for lpc55s36.m4 on 3333
<roland>
Info : 215 485 server.c:297 add_service(): Listening on port 3333 for gdb connections
<roland>
Info : 216 486 gdb_server.c:3791 gdb_target_start(): starting gdb server for lpc55s36.cpu on 3334
<roland>
Info : 217 486 server.c:297 add_service(): Listening on port 3334 for gdb connections
<roland>
Info : 218 77117 server.c:90 add_connection(): accepting 'gdb' connection on tcp/3333
<roland>
but when trying to telnet, it just exists:
<roland>
Info : 218 77117 server.c:90 add_connection(): accepting 'gdb' connection on tcp/3333
<roland>
Debug: 219 77117 breakpoints.c:362 breakpoint_clear_target_internal(): Delete all breakpoints for target: lpc55s36.m4
<roland>
Debug: 220 77117 breakpoints.c:542 watchpoint_clear_target(): Delete all watchpoints for target: lpc55s36.m4
<roland>
Debug: 222 78119 log.c:412 gdb_timeout_warning(): keep_alive() was not invoked in the 1000 ms timelimit (1438 ms). This may cause trouble with GDB connections.
<roland>
Info : 223 91743 server.c:90 add_connection(): accepting 'gdb' connection on tcp/3334
<roland>
Debug: 224 91743 breakpoints.c:362 breakpoint_clear_target_internal(): Delete all breakpoints for target: lpc55s36.cpu
<roland>
Debug: 225 91743 breakpoints.c:542 watchpoint_clear_target(): Delete all watchpoints for target: lpc55s36.cpu
<roland>
Debug: 227 92745 log.c:412 gdb_timeout_warning(): keep_alive() was not invoked in the 1000 ms timelimit (1090 ms). This may cause trouble with GDB connections.
<roland>
telnet 127.0.0.1 3334
<roland>
Trying 127.0.0.1...
<roland>
Connected to 127.0.0.1.
<roland>
ah, it was on 4444
<roland>
ok, so sending halt results in:
<roland>
> halt
<roland>
[lpc55s36.cpu] halted due to debug-request, current mode: Thread
<roland>
Debug: 240 237218 cortex_m.c:858 cortex_m_debug_entry(): [lpc55s36.cpu] entered debug state in core mode: Thread at PC 0x8c8, cpu in Non-Secure state, target->state: halted
<roland>
I run openocd as "sudo openocd -d -f interface/cmsis-dap.cfg -f ./config/lpc55s36.cfg.cp", so I'd imagine it loads that work area config specified in the config
<karlp1>
you make the target twice
<roland>
karlp1 "so autoprobe fails, you're going to want to start there" what does that entail?
<karlp1>
it probably gets junked and re-added?
<karlp1>
or do the configure after the second one?
<roland>
timed out while waiting for target halted
<roland>
BUG: unknown Part ID encountered: 0xffff
<roland>
Connection closed by foreign host.
<roland>
the auto probe failing is probably because it cannot find a match for the chip i use in the lpc2000 driver
<karlp1>
yes....
<karlp1>
that's not at all surprising.
<karlp1>
the idea of the lpc2000 driver was to point to you where you might want to start adding in your part...
<karlp1>
though personally, I suspect that 0xffff means it's reading the wrong place entirely for your part...
<karlp1>
that doesn't seem like an "unknown" id, more like a "not an id at all"
karlp1 is now known as karlp
<roland>
so if I provide the bank base and size (and replace the auto w/ something else), would that work? ... or this is the point where I need to modify that lpc2000.c file to get things going?
<roland>
it's looking like I may need to path that file ... just gonna have to figure out some of that info there (hopefully datasheet has it all)
<roland>
*patch
pedro_pt has quit [Quit: Client closed]
<PaulFertser>
roland: please do not spam the channel
roland has quit [Quit: Client closed]
roland has joined #openocd
<karlp>
feck, nxp flash config bytes fail I think.