najnesnaj / pinetime-zephyr

pinetime smartwatch nrf52 zephyr
Apache License 2.0
106 stars 20 forks source link

Consider using nRF connect SDK as baseline #10

Closed nordic-krch closed 4 years ago

nordic-krch commented 4 years ago

nRF Connect SDK (often referred as NCS) is Nordic Semiconductor SDK based on zephyr. It has additional features that could be useful for pinetime, namely bluetooth modules and bluetooth services. Important to mention that even though, NCS forks zephyr it is kept close to it and it is regularly updated to latest zephyr (typically every 2-3 weeks).

NCS has no impact on build framework and overall user experience. The only downside I can think of is that NCS is based on older version of zephyr (~2 weeks behind).

The main reason why i'm bringing it up is bluetooth shell. Zephyr has very nice shell module with multiple transports (UART, RTT). NCS extends it with bluetooth transport (using Nordic Uart Service) and host tool for using it. There is an application for linux from which you can use shell over bluetooth, get logs, etc.. It is really cool and can be very useful when playing with pinetime where you can get logs or control/tune things with only wireless connection to your PC. Here is a demonstration of bluetooth console used in one of nordic reference kits: https://www.youtube.com/watch?v=3KzTfr6S4pg&t= . It's based on nRF5 SDK (not zephyr) but bluetooth shell (and PC tool) was taken from there.

nordic-krch commented 4 years ago

fyi, I tried to switch to NCS. There are some minor issues now as NCS is one month behind zephyr (display driver is not up to date). I tried using NCS with newest zephyr and after one small patch i was able to run shell over bluetooth with pinetime!

najnesnaj commented 4 years ago

I just have 2 questions regarding nrf connect sdk 1: do you have to use the softdevice? 2: the uart would be really cool (I already did some research on this), but will it run on my setup? I use windows subsystem for linux on W10, which does not handle bluetooth. The pinetime watch is connected to the gpio header of an orange pi single board computer which runs armbian. I plugged a usb 4.0 Bluetooth dongle and can use bluez, eg for FOTA, and all other Bluetooth communication. But will the Nordic software (console) run on my arm-based 32bit linux?

nordic-krch commented 4 years ago

do you have to use the softdevice?

no, it's zephyr based sdk

I use windows subsystem for linux on W10

I'm not sure. There are two options for host side for connecting to bluetooth shell:

BLE Console tool is more user friendly, while bt_nus_shell.py is more a proof of concept.

the uart would be really cool

Do you mean standard UART? I could not find 2 pins to have that, i would also like to have that as RTT has its limitations (debug session needed).

Regarding pins for uart, do you have PCB layout file? I was wondering if P0.30 (HRS3300-TEST) pin and P0.27(STATUS LED not staff) could be used.

najnesnaj commented 4 years ago

I mean uart as in bluetooth ble console. Communication over bluetooth is a really big plus! As is firmware over the air updating. I think it would render the watch more userfriendly as well. (not having to deal with hardwareprogrammers and fysical connections)

I can use the nordic windows software, so no problem. (Have to sit beside my watch though, currently I can access it worldwide thanks to my SBC (orange pi).)

Will have a look at the bt_nus_shell.py, because I think I can use my desay D6 watch for that.

Switching to NCS doesn't have any impact on the "Open Source" nature of this project?

If not, I'm in favour!

for pinout have a look at http://files.pine64.org/doc/PineTime/PineTime%20Port%20Assignment%20rev1.0.pdf

schematic

http://files.pine64.org/doc/PineTime/PineTime%20Schematic-V1.0a-20191103.pdf

nordic-krch commented 4 years ago

Switching to NCS doesn't have any impact on the "Open Source" nature of this project?

no problem. NCS is using BSD-5-Clause-Nordic license (https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/LICENSE)

I've seen pinout and schematic, but wanted to locate P0.27 (not placed LED) as i thought about using that for UART. To locate that i need pcb layout.

najnesnaj commented 4 years ago
nordic-krch commented 4 years ago

@najnesnaj I see that you are using MY_REGISTER1=0xe5; stuff a lot in the code which indicates that you are not using jlink debugger. right? also you wrote:

The pinetime watch is connected to the gpio header of an orange pi single board computer which runs armbian.

I would really recommend getting nrf52 dk board: https://eu.mouser.com/ProductDetail/Nordic-Semiconductor/NRF52-DK?qs=79dOc3%2F91%2FccrafuGv4fOw==&gclid=EAIaIQobChMIppeV__-r5wIVAkQYCh1VNwqJEAAYASAAEgJE-PD_BwE

This will allow you to use RTT for shell and logging which are great tools (once you start using shell you'll love it, guaranteed since with auto-completion it works so smooth that you will start typing there bash commands by accident 😄 ) it is also necessary for bluetooth shell (without pairing).

najnesnaj commented 4 years ago

@nordic-krch Thank you for your tip! (maybe Nordic has some spare ones? ;)) I now use a cheap nrf52832 watch with a serial port, so debugging has become easier.:)

I've created a separate branch for testing, and I will clean out the code (get rid of the debug stuff) I will try to use cleaner commits as well. (I learn by doing)