This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Having trouble flashing from Eclipse

I've spent quite a while getting Eclipse on Mac OSX working. I started with the original makefile but have come up with, finally, a working native Eclipse build which does the same thing. It's quite nice having full Eclipse integration. (If anyone is interested in how you do that I'll write it up).

But I'm having issues with debugging. I have Jlink 4.78, Eclipse Kepler and a recent GCC toolchain. I'm running the JLinkGDBServer and have the commands suggested in nan-29.

The sequence goes like this. If the chip is already programmed with anything at all, the flash of the device fails with a block verification error much like this one

Resetting target
Downloading 2456 bytes @ address 0x00000000
Downloading 8 bytes @ address 0x00000998
Downloading 1092 bytes @ address 0x000009A0
ERROR: Programming failed @ address 0x000001F8 (block verification error)

Once that's happened, there appears to be no good way out of it, it'll happen every time until I run a script I have which erases the flash by hand (thank you Mr Mason), then, next time I debug, the flash will be successful ..

however after the flash the device tries to run the code but I end up in the hardfault handler pretty much instantly (and I'm not well-enough versed with this device to work out how I get there).

Finally if I kill the JLinkGDBServer again and run it again .. it will usually work that time.

So to recap, the programming of the flash fails with a block verification error; wiping the device manually makes the next flash work but the code doesn't run, fails with a HardFault, on the third and subsequent times, until I change the code, it mostly works.

Any ideas where these verification errors and HardFaults may be coming from? I feel that the Segger probably isn't waiting long enough before trying things and it's either writing whilst erasing or trying to run before things are ready, but I don't know how to insert things into an Eclipse debug download script to slow it down (if there is such a thing over JLinkGDBServer).

I can turn the download into an external process and made Debug just debug, but that's a bit of a shame, a full Eclipse solution seems quite close at this point and it would be great to finish it.

  • Afraid I can't help you with your flash issue but since you seem to have Eclipse CDT working with the gcc/gdb toolchain on Mac, would you mind explaining how you set up the Toolchain for CDT under project properties -> C/C++ Build -> Tool Chain Editor -> Current toolchain?

    The example project from Nordic has no toolchain here and I suspect this is the cause of a bunch of build errors in the BLE proximity example app (more detail here: stackoverflow.com/.../eclipse-cdt-error-symbol-xxx-could-not-be-resolved).

    Hopefully someone from Nordic can respond about your flash issue.

  • It's not under current Toolchain, that should be set to 'Cross GCC' (if you don't have a Cross GCC option in the dropdown then you probably need to download another piece of the CDT in addition to those suggested by nan-29, I certainly added a few extra bits I thought would be useful).

    Then in the option above that one, Properties -> C/C++ build-> Settings, in the first tab, 'Tool Settings', in the first option, 'Cross Settings' (man Eclipse has a lot of settings) there are boxes for prefix and Path which I have set to

    arm-none-eabi-

    and

    <my homedir + stuff>/gcc/gcc-arm-none-eabi-4_7-2013q3

    I actually didn't have to do a lot of that, I started with a new C project and picked Cross GCC as the toolchain right at the start and it asked me where things were. I didn't build this project around a working makefile, I started from scratch and set Eclipse up to have all the correct paths, includes and flags in it to build the way the makefile does. I'm hoping to turn that into some kind of template and then do another template for a project with softdevice, which I suspect is just going to be another 6 hours of mashing eclipse buttons until it works.

  • Thanks. I probably found the same Eclipse plugin you did:

    http://gnuarmeclipse.livius.net/blog/

    That's got me further along but I still haven't flashed the device using it, so I may hit the same issue you're seeing shortly. The plugin looks promising though - if it works then the Nordic NAN 29 should probably be updated to use it. I certainly never got far with the NAN 29 instructions as they are now.

  • no I just used the normal CDT plugin, the one nan-29 recommends. It's a bit of a bear, especially if you don't know eclipse (I don't .. well I didn't) but it works. I think nan-29 is ok, it got me started at least even making allowances for it being windows and me using OSX.

    That plugin looks quite cute, I'll grab a fresh install of Eclipse and see if, now I've learned how eclipse works, that makes it any easier. If I'm feeling super smart I'll try building a template for nordic .. that won't be this week!

    Sometimes I wish I didn't have a day job ..

  • Have you seen this? I suspect you may be seeing consequences of the same problem.

    Also, are your project using a softdevice or not? If it is not, you should make sure that you don't in any way accidentially flash a softdevice to your chip, as that will most likely cause the kind of verification errors you see.

    Personally, I find myself using command-line gdb more than Eclipse, and I've put my Makefiles and linker scripts on GitHub here. It might be a good idea to check whether things are working from the command line before moving into Eclipse, as I sometimes suspect Eclipse of causing additional problems...

Related