bosmoment / PineTime-apps

Firmware for the PineTime based on RIOT, NimBLE and LittleVGL
GNU Lesser General Public License v2.1
79 stars 32 forks source link

openocd #3

Closed tgwaste closed 4 years ago

tgwaste commented 4 years ago

Hi, Any way to flash with openocd? Super new to this and I got the stuff working under pinetime-rust-mynewt but dont know how to apply what I learned there to flash this and try it out.

bergzand commented 4 years ago

Hi,

When using RIOT, the build system usually takes care of flashing the microcontroller via the configured programming software and flasher configuration.

The build system currently only has support for using a Jlink (or Jlink-like) programmer for flashing. This means that using make flash in the application directory will execute the flash commands with the assumption that a Jlink is attached to the PineTime. This will use the JlinkExe software to interface with the Jlink programmer. It is also possible to use make flash PROGRAMMER=openocd, but this requires a recent version of OpenOCD.

Now lets say that you're using a different programmer, something like a Raspberry Pi. after building the application (in apps/pinetime) with make all, the elf and bin files are available in apps/pinetime/bin/pinetime. These can be flashed to the PineTime with OpenOCD. As you already tried some things with pinetime-rust-mynewt, maybe you could adapt the openocd flash scripts from there. Let me know if that's an option for you. I can look into how to flash with the Raspberry Pi, but it will take a bit of time.

By the way, as soon as RIOT-OS/RIOT#11311 is merged, it should be trivial to add support for a raspberry pi as flasher to the Pinetime. Then something like make flash PROGRAMMER=openocd FLASHER=raspberry-pi should work.

bergzand commented 4 years ago

BTW if you have an ST-link or CMSIS-dap flasher available you could try flashing the pinetime using pyOCD with make flash PROGRAMMER=pyocd

tgwaste commented 4 years ago

It doesnt even build though. This happens no matter what make command I run.

pinetime/root/PineTime-apps/apps/pinetime# make flash PROGRAMMER=openocd
/root/PineTime-apps/apps/pinetime/../../RIOT/Makefile.include:267: *** The specified board pinetime does not exist..  Stop.

Also git submodule update didnt seem to do anything the RIOT directory was empty. I had to rm -rf RIOT and then do a git clone of RIOT.

bergzand commented 4 years ago

Thanks for the feedback.

Also git submodule update didnt seem to do anything the RIOT directory was empty.

Sorry, it seems the readme is missing the git submodule init step :(

I had to rm -rf RIOT and then do a git clone of RIOT.

At this moment I'm using this fork/branch of RIOT. It includes the pinetime board definitions and the drivers required to build the applications here.

bergzand commented 4 years ago

Sorry, it seems the readme is missing the git submodule init step :(

Added the missing step to the project readme

bergzand commented 4 years ago

I noticed that you succeeded in flashing your PineTime. Could you please post the steps required here for the next person with this issue? Furthermore is it okay to close this issue?

tgwaste commented 4 years ago

Started a repository to throw things into: https://github.com/tgwaste/pinetime

This uses openocd obviously and is for Pi 4

# ./flash-bosmoment.sh /root/PineTime-apps/apps/pinetime/bin/pinetime/PineTime.bin
Open On-Chip Debugger 0.10.0+dev-01000-gdb23c13d (2020-01-13-17:06)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
force hard breakpoints
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Stopping...
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x000016aa psp: 0x2000a6b8

Flashing Application...
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000480 msp: 0x20000200
Enabled ARM Semihosting to show debug output
** Programming Started **
Info : nRF52832-QFAA(build code: E0) 512kB Flash, 64kB RAM
Warn : Adding extra erase range, 0x00036778 .. 0x00036fff
** Programming Finished **
** Verify Started **
** Verified OK **

Restarting...
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000480 msp: 0x20000200, semihosting
Enabled ARM Semihosting to show debug output

**** Done! Press Ctrl-C to exit...
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
ashimokawa commented 4 years ago

@tgwaste Since you deleted https://github.com/tgwaste/pinetime, any hints on how you succeeded?

I am completely new to the PineTime, managed to remove flash protection with the Raspberry Pi SPI method, but I do not know yet what do do next. Bootloader? Flashing RIOT? Flashing PineTime-apps?

I can do my homework but any pointers would be appreciated