NordicSemiconductor / Nordic-Thingy52-FW

Nordic Thingy:52 software development kit. This kit is designed to assist users in developing their own custom firmware for Thingy. Please see http://www.nordicsemi.com/thingy for the latest news and software releases.
Other
210 stars 133 forks source link

can compile and program with GCC on ubuntu 16.04, but the code doesn't run #40

Closed w52191 closed 4 years ago

w52191 commented 4 years ago

Hi, I use GCC to compile the code. And program the board with J-link on linux (ubuntu 16.04). But I didn't see the LED light on. And my phone cannot connect to it.

However, if I flash the precompiled HEX file (thingyv210HW10.hex) into the device, it works.

Here are the tools and commands I used to do it: 1, gcc-arm-none-eabi-8-2019-q3-update. I don't use gcc-arm-none-eabi-4_9-2015-q3, because the ubuntu 16.04 cannot recognize it. 2, nrfjprog --family nRF52 -e, to erase the device. 3, nrfjprog --family nRF52 --program _build/nrf52832_xxaa_s132.hex, to flash the device. 4, nrfjprog --family nRF52 -r, to run the code.

And nrf52832_xxaa_s132.hex is 380 bytes less than the precompiled HEX file (thingyv210HW10.hex).

Do I have to use gcc-arm-none-eabi-4_9-2015-q3 to compile the code? Or it could be some other issues?

koffes commented 4 years ago

Have you tried compiling with the debug flag enabled? Try that and see if you get any output on real time terminal (RTT). For RTT use, please see: https://devzone.nordicsemi.com/f/nordic-q-a/14512/how-to-use-rtt-viewer-or-similar-on-gnu-linux. I would expect your compiler to work fine, however, we have not tested with that version.

jorgenmk commented 4 years ago

The precompiled hex file contains both the BLE stack and the application code. Your compiled app does not contain the BLE stack. To make this work you must first program the s132 v4.0.2 BLE stack.

(Its in the repo here: external/sdk13/components/softdevice/s132/hex/s132_nrf52_4.0.2_softdevice.hex)

Full procedure: nrfjprog -f nrf52 -e nrfjprog -f nrf52 --program s132_nrf52_4.0.2_softdevice.hex nrfjprog -f nrf52 --program _build/nrf52832_xxaa_s132.hex # Your app nrfjprog -f nrf52 -r

Note: You can avoid flashing the stack every time: nrfjprog -f nrf52 --program _build/nrf52832_xxaa_s132.hex --sectorerase

w52191 commented 4 years ago

Thank you guys! Your suggestions work very well for me!

w52191 commented 4 years ago

Have you tried compiling with the debug flag enabled? Try that and see if you get any output on real time terminal (RTT). For RTT use, please see: https://devzone.nordicsemi.com/f/nordic-q-a/14512/how-to-use-rtt-viewer-or-similar-on-gnu-linux. I would expect your compiler to work fine, however, we have not tested with that version.

Hi Koffes, I followed the link you posted. But I didn't get anything. Here are the steps I did: 1, rebuild the code with: make -d 2, type the command in the terminal: JLinkExe -if SWD -speed 4000 -device Cortex-M4 -autoconnect 1 3, open another terminal and type: JLinkRTTClient

By the way, will the code print the information by default? Or should I define the DEBUG macro and turn on NRF_LOG_ENABLE somewhere in the code? Thanks!

koffes commented 4 years ago

Can you check if the DEBUG macro is set and what the NRF_LOG_DEFAULT_LEVEL is when you compile? Try to set the level to 4, this should print all debug messages.