NishanthMenon changed the topic of #openocd to: this is the place to discuss all things OpenOCD | Logs: https://libera.irclog.whitequark.org/openocd/
<russ> I see a lot of code in openocd for translating from virtual address to physical address
<russ> but what's supposed to happen when a read request is made for a virtual address that is paged out?
ianstcdns has quit [Quit: Client closed]
wingsorc has quit [Ping timeout: 252 seconds]
Hawk777 has joined #openocd
MCorgano has joined #openocd
<MCorgano> Hi
<MCorgano> rying to get adafruit bootloader and circuit python onto a bare NRF52840 module, same module and chip on the Adafruit feather series of boards, using a raspberry pi zero as a host for OpenOCD, and having issues falshing the bootloader. Can anyone help me?
<MCorgano> > targets
<MCorgano>     TargetName Type Endian TapName State
<MCorgano> -- ------------------ ---------- ------ ------------------ ------------
<MCorgano>  0* nrf52840.cpu cortex_m little nrf52840.cpu halted
<MCorgano> That looks fine
<MCorgano> But when I try to erase
<MCorgano> > nrf51 mass_erase
<MCorgano> SWD DPIDR 0x2ba01477
<MCorgano> Failed to read memory at 0x4001e404
<MCorgano> Error waiting NVMC_READY: generic flash write/erase error (check protection etc...)
<MCorgano> SWD DPIDR 0x2ba01477
<MCorgano> Failed to read memory at 0x00000000
<MCorgano> Error waiting NVMC_READY: generic flash write/erase error (check protection etc...)
<MCorgano> Read only enable did not complete
<MCorgano> Failed to erase reg: 0x4001e50c val: 0x00000001
<MCorgano> Failed to erase the chip
<MCorgano> [nrf52840.cpu] clearing lockup after double fault
<MCorgano> [nrf52840.cpu] external reset detected
<MCorgano> [nrf52840.cpu] halted due to debug-request, current mode: Handler HardFault
<MCorgano> xPSR: 0x01000003 pc: 0xfffffffe msp: 0xffffffd8
<PaulFertser> Hi
<PaulFertser> MCorgano: please use some pastebin the next time.
<PaulFertser> MCorgano: the problem is likely nrf-specific, have you already read the corresponding section in the user manual?
nerozero has joined #openocd
nerozero has quit [Ping timeout: 255 seconds]
nerozero has joined #openocd
<MCorgano> PaulFertser honestly I'm still super new to nordic stuff, as well as programming microcontrollers directly. I've done a bit of stuff on arduino, but I'm trying to doa  project that demanded a very small bluetooth module
<PaulFertser> MCorgano: that's not a problem at all if you're willing to learn :) However, that doesn't answer my question specificallyy.
<PaulFertser> MCorgano: also, it looks like you're using an old OpenOCD version?
<borneoa__> russ: the read will fail and I expect it will throw an exception to the CPU that made the read on behalf of OpenOCD. I think that openocd clears the exception in the code of the read, so it will not be taken by the CPU when OpenOCD resumes it.
<russ> so if you wanted to disassemble a function that was paged out, you'd be out of luck
<borneoa__> russ: yes. But if you have the elf file you are debugging, gdb can give you the disassembly without accessing the target's memory
<russ> similar issue then when trying to view data that is paged out
<borneoa__> russ: yep
Hawk777 has quit [Quit: Leaving.]
<MCorgano> How do you quickly reply to an individual?
<MCorgano> PaulFertser OH ok so I was following this guide
<MCorgano> and installed openOCD that way. IT SHOULD be recent IFAIK
<MCorgano> in fact, when I start it it tells me that some of the settings are depreciated, and I should use a different name for them, but it still seems to otherwise work. implying the OpenOCD is newer than the configs used
<MCorgano> I'm controlling the pi over ssh, is there like, a simple way to copy the config file off the pi to my laptop?
<Mis012[m]> scp
erhankur has joined #openocd
<erhankur> I see jimtcl new release (0.82) is already tagged. Do we plan to update it?
erhankur has quit [Remote host closed the connection]
<PaulFertser> MCorgano: so what version are you running exactly?
erhankur has joined #openocd
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
<MCorgano> How do I tell OoenOCD version?
<MCorgano> I have a bit of an issue where if I go to the screen where I started it, and hit ctrl C to close it, OpenOCD closes but doesn't like, release the ports - causing it to crash next time i go to start it, and need to re start the pi over again
<MCorgano> config file
<MCorgano> Open On-Chip Debugger 0.12.0+dev-00075-g79caea874 (2023-02-23-15:18)
erhankur_ has joined #openocd
erhankur has quit [Ping timeout: 268 seconds]
<MCorgano> OH! Partial success?
<MCorgano> I have a bad habbit of randomly pushing buttons until I let the smoke out
<MCorgano> but through a random halt, attempt to flash, it looks like it worked?
<MCorgano> but verify failed.
<MCorgano> OH! So I need to halt it before running the vrify
<MCorgano> so halt, flash, halt, verify seemed to work?
<PaulFertser> MCorgano: I think if you're using "write_image" manually you should also specify "erase" option to it.
<MCorgano> the tutorials say to do this
<MCorgano> nrf5 mass_erase
<MCorgano> flash write_image /home/pi/pca10059_bootloader-0.7.0_s140_6.1.1.hex
<MCorgano> verify_image /home/pi/pca10059_bootloader-0.7.0_s140_6.1.1.hex
<PaulFertser> MCorgano: if it's after mass_erase, yes, you can just write_image.
<MCorgano> ok im trying to re-do it so I can get to something that works consistantly
<MCorgano> my current state is Halted
<MCorgano> so I run the nrf5 mass_erase, but it gives me tonnes of errors
<MCorgano> > halt
<MCorgano> > nrf5 mass_erase
<MCorgano> SWD DPIDR 0x2ba01477
<MCorgano> Failed to read memory at 0x4001e404
<MCorgano> Error waiting NVMC_READY: generic flash write/erase error (check protection etc...)
<MCorgano> SWD DPIDR 0x2ba01477
<MCorgano> Failed to read memory at 0x00000000
<PaulFertser> Does "reset halt" not work?
<MCorgano> Checking nrf52840.dap apreg 1 0x0c gives me 0x000000001, which means not protected. Alledgedly
<MCorgano> I'm kind of a noob. What is the difference between halt and reset halt?
<PaulFertser> reset halt resets the target to halt it before even the first instruction is executed.
<MCorgano> Oh
<MCorgano> where as halt just stops it.... wherever it is....
<PaulFertser> Yeah, so if firmware has watchdog enabled or something like that, or probably an interrupt source etc etc, it can affect flash operations.
<MCorgano> OH want to note, This chip is a module that I got a la china, doesn't have a bootloader or anything on it when shipped
<MCorgano> not sure if that changes things
<MCorgano> SO
<MCorgano> Reset halt -> nrf5 mass_erase, seems to work
<MCorgano> then I run flash write_image /home/pi/pca10059_bootloader-0.7.0_s140_6.1.1.hex
<MCorgano> and get a lot of errors
<PaulFertser> What if you do another "reset halt" before writing image?
<MCorgano> do I need to like, run these all as one command? Or halt between commands? I feel like I'm missing something obvious and fundimental
<MCorgano> Did reset halt -> nrf5 mass_erase -> error
<PaulFertser> I'm not sure, probably nrf52 is glitchy in some way.
<PaulFertser> Or probably it has hardware watchdog enabled.
<MCorgano> Any way I can like, slow down the debugger to make it more reliable?
<PaulFertser> Or probably your communication channel to it isn't solid. Do you have series resistors on data lines between the raspberrypi and the MCU?
<MCorgano> or is that more for like, writing chunks of flash
<MCorgano> uuuuuuuuummmm
<PaulFertser> You can't make edges less sharp by using slower frequency, no.
<MCorgano> Let's say no.
<MCorgano> what value should I use?
<PaulFertser> Do you have an oscilloscope? Then you can check for ringing.
<PaulFertser> Typically 47--100 Ohm are good enough.
<MCorgano> I do not
<MCorgano> I have whatever can be made out of like 12 pi zero's and a pi 4 b 8gb
<MCorgano> so like, 75 ohm would work?
<PaulFertser> It might help or might not, depending on whether ringing is really a problem in your case.
<PaulFertser> Another thing to try is to run with -c "set WORKAREASIZE 0" before sourcing target config. Then flashing will work slower but probably more reliable as it wouldn't involve running helper code on target CPU.
<MCorgano> OH I saw somewhere else mention that, but it flew straight over my head
<MCorgano> usually I cd => folder with config in it, and then sudo openocd
<MCorgano> so then, sudo openocd -c "set WORKAREASIZE 0" instead?
<PaulFertser> MCorgano: you're not reading user manual are you?
<MCorgano> I read some parts of it, to kind of mull my way through
<MCorgano> but understanding is an entirely different question
<MCorgano> wait waht? Those go to the same link?
<MCorgano> Apparently I don't know how to use imgur
<MCorgano> Resistors are in
<MCorgano> looping through reset halt and doing the mass erase over and over, I found the results were very inconsistant. I'm thinking maybe there was some kind of connection issue
<MCorgano> I also know that most people are using like, pi 2's or 3's. I'm using a pi zero W. I am not sure if the values I used are 100% correct. I set it to be the same as the pi 1 as apparently they use the same chip. In my configs it is
<MCorgano> bcm2835gpio speed_coeffs 113714 28
<MCorgano> but if im having inconsistant connection issues, maybe that's the problem
<MCorgano> I'm actually curious, if I port forwarded the 4444 port to go to my pi, could you telnet into my openOCD instance?
<PaulFertser> MCorgano: if the issues are the same with different "adapter speed" settings then coefficients are good enough.
erhankur_ has quit [Ping timeout: 268 seconds]
<MCorgano> not saying you would WANT to, but wondering if it would work.
<PaulFertser> It would, but I have no experience with nrf52, unfortunately.
<MCorgano> ok restarted openocd with sudo openocd -c "set WORKAREASIZE 0" -f /home/pi/openocd-config/openocd.cfg
<MCorgano> targets shows there's something connected, it's halted
<MCorgano> Ok, SOMETIMES when I do nrf5 mass_erase it just gives me an error, sometimes when I run it it says wrong parity detected, then gives an error
<MCorgano> what does Wrong parity detected mean?
<MCorgano> OH HEY
<MCorgano> So here, it mentioned a nrf52_recover command, that basicly sets the APPPROTECT register to unlock it, and erases it
<MCorgano> then did a write
<MCorgano> then did a verify
<MCorgano> and it completed successfully
<MCorgano> cool!
<MCorgano> ok now presuming it works and now I have a bootloader on it, I should be able to just reset, and then plug in usb?
<PaulFertser> MCorgano: oh, cool
<PaulFertser> MCorgano: btw, it's all in nrf52.cfg file, the recover command is visible inside. But it should be added to the user manual too...
<MCorgano> Ok. At risk of sounding like an idiot, what nre52.cfg file?
<MCorgano> I saw ONE guide that mentioned it, from like 2017, and when I tried to CD there to see it, I couldn't find it
<PaulFertser> The target config you're sourciing.
<MCorgano> There is a definite disconnect between what I'm doing and understanding what I'm doing.
<PaulFertser> MCorgano: you're sourcing the target config from /home/pi/openocd-config/openocd.cfg
<PaulFertser> It's likely located in /usr/share/openocd-scripts/target/
<MCorgano> OH
<MCorgano> Ok The config I was running with said this
<MCorgano> And there are no functions in there
<MCorgano> I know it was loading SOMETHING with nrf52-specific commands in it, but honestly had no idea where that file actually lived in the file system
<MCorgano> set CHIPNAME nrf52840
<MCorgano> source [find target/nrf52.cfg]
<MCorgano> OH so that's what that line did
<MCorgano> so SOMEWHERE there's the nrf52.cfg, no idea where though
<MCorgano> I 3d printed the jig im using to program the chip. Wanna see?
<PaulFertser> MCorgano: sure :)
<PaulFertser> MCorgano: probably in /usr/local/share/openocd*/ if you installed OpenOCD from source.
<PaulFertser> If you run it with openocd -d2 you'll see the path.
<MCorgano> Fun fact
<MCorgano> the holes for the pins are actually too small to print with my 3d printer
<MCorgano> so instead, I printed the area AROUND the holes, as a series of noodle shapes
<MCorgano> and drilled the holes out a little with a pcb drill bit by hand, to make them circular enough to use
<MCorgano> Modeling this took for flipping ever because you're basically creating a shape that the slicer can only possibly slice in one way, to ensure it prints correctly.
<PaulFertser> Haha, nice.
<MCorgano> I have a little top hat with a brim i screw in from the top to hold the pins in, and a single bolt that releases the lever on the bottom, that holds the module
<MCorgano> my thinking was, if I wanted to do a small run I could use a jig to program them and pi to automate it
<MCorgano> that and I needed to solder these modules to a bare pcb, so I can't like, temp solder things onto them to test with
<PaulFertser> Cool trick. But why didn't you just solder to the board? How is mounting wires for flashing affects it?
<MCorgano> I don't have the PCB yet
<PaulFertser> Ah, small run makes sense then indeed.
<PaulFertser> I mean solder directly to those castellated vias on the target module.
<MCorgano> I'm working on a project, and I wanted to make sure I can get the fundimental idea working first, THEN start ordering parts
<PaulFertser> Yes, so for testing it would feel to be much faster and more reliable if you just soldered to module without inventing the jig first.
wingsorc has joined #openocd
<MCorgano> I mean, yes
<MCorgano> but now that I have a jig
<MCorgano> I THINK I have the adafruit bootloader as well
<MCorgano> how do I put it into usb mode.... lol
wingsorc has quit [Quit: Leaving]
wingsorc has joined #openocd
<MCorgano> welp nothing
<MCorgano> ill have to try tomowwo
MCorgano has quit [Quit: Client closed]
Hawk777 has joined #openocd
IoTMaker has joined #openocd
erhankur has joined #openocd
IoTMaker has quit [Quit: Client closed]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
Guest3098 has joined #openocd
Guest3098 has quit [Quit: Client closed]
Hawk777 has quit [Quit: Leaving.]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
nerozero has quit [Ping timeout: 255 seconds]
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
erhankur has quit [Remote host closed the connection]
erhankur has joined #openocd
JakeSays_ is now known as JakeSays