Hi,
I am trying to get even a basic ARM GCC example set up using the provided toolchain code, and am having a rough go at it.
First, what is the most recent, working, full example of how to set up ARM GCC to compile and deploy to a nRF51 DK? I have no 'difficult' goals - I am running without a softdevice, with only GPIO, no standard library, not trying to implement OTA firmware or anything. I can figure out Eclipse later, I just need to be able to deploy to a target for now.
My procedure was this -
- Changed the $sdk/components/toolchain/gcc/Makefile.posix to point to /usr/local, where the ARM GCC is linked
- CD to the blinky armgcc directory, make, make flash
- The .hex is around 3kB, which is what we would expect for a gpio-only hex file
- Worth pointing out at this point that "make flash" is broken, it calls --program when my nrfjprog uses --flash for some reason. Even then, as written, it calls flash on _build/.hex, which is obviously wrong. So, I do it manually, with JLinkExe commands r, loadfile _build/nrf51422_xxac.hex, r, g in a script file.
- In any case, it says that it flashes successfully, but the expected pins are not toggling.
- If I use JLinkExe and halt it just says that PC is at 00000. After stepping, CycleCnt doesn't change, PC doesn't change, etc. IPSR says HardFault - maybe a problem with the startup code?
- Speaking of which, I read that some people saw blinky start at _start, which is a stdlib function, and suggested that blinky would work with the CFLAG -nostdlib. This didn't change anything.
When I halt, I see the following output -
PC = FFFFFFFE, CycleCnt = 00000000
R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = FFFFFFFF
R4 = FFFFFFFF, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
R12= FFFFFFFF
SP(R13)= FFFFFFD8, MSP= FFFFFFD8, PSP= FFFFFFFC, R14(LR) = FFFFFFF9
XPSR = 81000003: APSR = Nzcvq, EPSR = 01000000, IPSR = 003 (HardFault)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
The obvious questions,
-
What am I missing to make this work?
-
Is there a way to step through the code, on the command line? I will look up GDB in the meantime.
-
From an organizational perspective, are there Makefile examples that are self-contained? The current system looks like it would work best if you duplicated the example projects in-place. There doesn't seem to be a way for me to just "point to" a nRF SDK installation and have it use the files there, without modifying the Makefile. I did that, and got the same result, so it's not hard, but I am interested to know why this method of organization was selected. It seems a little awkward to have to actually drop your code into the nRF SDK examples folder to use the provided stationary.
Version notes -
OSX Yosemite, 10.10.2
ARM GCC version 4.7.4 20140401 (release) [ARM/embedded-4_7-branch revision 209195]
SDK 8.0.0
Thanks,
-Alex