Skip to content

Conversation

kaspar030
Copy link
Contributor

@kaspar030 kaspar030 commented Oct 23, 2019

Contribution description

I just got the PineTime devkit. It was a breeze to port, from opening the device to hello world took <15minutes. Thanks @aabadie @haukepetersen et al for the nice abstractions there!

For more information about the board, please look here:
https://wiki.pine64.org/index.php/PineTime

edit
This currently only adds the basic board configuration and flashing etc. No drivers are used, yet.

Testing procedure

AFAIK they just started shipping the devkits, so I'm probably the only maintainer who has one.
I'll provide output and test results.

For now, maybe concentrate on the integration.

Issues/PRs references

@kaspar030 kaspar030 added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: boards Area: Board ports labels Oct 23, 2019
@kaspar030
Copy link
Contributor Author

examples/hello-world output:

[kaspar@ng riot/examples/hello-world (add_pinetime_support)]$ BOARD=pinetime make term
/home/kaspar/src/riot/dist/tools/jlink/jlink.sh term_rtt
### Starting RTT terminal ###
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2019-10-23 13:52:20,988 # Host name for TCP connection is missing, defaulting to "localhost"
2019-10-23 13:52:20,988 # Connect to localhost:19021
Welcome to pyterm!
Type '/exit' to exit.
2019-10-23 13:52:21,993 # SEGGER J-Link V6.44e - Real time terminal output
2019-10-23 13:52:21,993 # SEGGER J-Link EDU V10.1, SN=260107551
2019-10-23 13:52:21,994 # Process: JLinkExe
2019-10-23 13:52:21,994 # main(): This is RIOT! (Version: 2020.01-devel-284-gdb33e-add_pinetime_support)
2019-10-23 13:52:21,994 # Hello World!
2019-10-23 13:52:21,995 # You are running RIOT on a(n) pinetime board.
2019-10-23 13:52:21,995 # This board features a(n) nrf52 MCU.

Other than that, I tested xtimer_msg, which works fine.

@@ -38,7 +38,7 @@ ${CODESPELL_CMD} --version &> /dev/null || {
CODESPELL_OPTS="-q 2" # Disable "WARNING: Binary file"
CODESPELL_OPTS+=" --check-hidden"
# Disable false positives "nd => and, 2nd", "WAN => WANT", "od => of"
CODESPELL_OPTS+=" --ignore-words-list=ND,nd,WAN,od"
CODESPELL_OPTS+=" --ignore-words-list ND,nd,wan,od,dout"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? Was this supposed to end up in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, sorry, thanks!

@kaspar030 kaspar030 force-pushed the add_pinetime_support branch from db33e00 to e702726 Compare October 23, 2019 12:16
@kaspar030
Copy link
Contributor Author

  • force-pushed removal of the unrelated commit

@bergzand
Copy link
Member

Awesome!

Skimming through the display controller datasheet, it looks like it is compatible with the display driver from #9948

@kaspar030
Copy link
Contributor Author

Skimming through the display controller datasheet, it looks like it is compatible with the display driver from #9948

Yeah! I've already configured the settings. 1 hour of RIOT hello-world drained the battery, need to recharge before I can try...

@bergzand
Copy link
Member

Yeah! I've already configured the settings. 1 hour of RIOT hello-world drained the battery, need to recharge before I can try...

Can we have some proof when you have the display working? 😄

@kaspar030
Copy link
Contributor Author

Can we have some proof when you have the display working? smile

Sure! 😄 It's all black at the moment, though.

@patchedsoul
Copy link

patchedsoul commented Dec 27, 2019

@kaspar030 @bergzand Will this be landing in the January release by chance?

@kaspar030
Copy link
Contributor Author

@kaspar030 @bergzand Will this be landing in the January release by chance?

I'll put this to high-priority. With the ili9341 merged, this should be possible. ping @fjmolinas, this would be awesome to have!

@bergzand
Copy link
Member

bergzand commented Jan 9, 2020

I'll put this to high-priority. With the ili9341 merged, this should be possible. ping @fjmolinas, this would be awesome to have!

I should receive my PineTime in the next few days, I can test this PR as soon as I have it.

@kaspar030
Copy link
Contributor Author

I've got some more code here: https://github.com/kaspar030/pinetime-riot

The branch includes a simple module for stdio on the display. It is based on a pre-merged ili9341, though.

Copy link
Member

@bergzand bergzand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review, nothing tested so far

# for this board, we are using Segger's RTT as default terminal interface
USEMODULE += stdio_rtt
TERMPROG = $(RIOTTOOLS)/jlink/jlink.sh
TERMFLAGS = term_rtt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TERMFLAGS = term_rtt
TERMFLAGS = term-rtt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coppied, others use term_rtt:

[kaspar@ng riot (add_pinetime_support)]$ gg -i term.rtt
Makefile.include:# TERMFLAGS must be exported for `jlink.sh term_rtt`.
boards/hamilton/Makefile.include:TERMFLAGS = term_rtt
boards/pinetime/Makefile.include:TERMFLAGS = term_rtt
boards/ruuvitag/Makefile.include:TERMFLAGS = term_rtt
boards/thingy52/Makefile.include:TERMFLAGS = term_rtt
dist/tools/jlink/jlink.sh:  term_rtt)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it was modified in #12733 to term-rtt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. fixed

extern "C" {
#endif

/* move on, nothing to see here */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the GPIO button available on the PineTime here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, done

extern "C" {
#endif

/* move on, nothing to see here */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess this should be extended with the vibrator GPIO as soon as SAUL supports vibrators. This can of course wait for a follow up :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, its there. the vibrator is just a GPIO. On my devkit it worked only when on the cradle, though.
Anyhow, the define should be there now.

#include "cfg_rtt_default.h"
#include "cfg_spi_default.h"
#include "cfg_timer_default.h"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the battery ADC line be included here?

Copy link
Contributor Author

@kaspar030 kaspar030 Jan 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

folo :) done


# Put defined MCU peripherals here (in alphabetical order)
#FEATURES_PROVIDED += periph_i2c
#FEATURES_PROVIDED += periph_uart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UART is not available on the board right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a debug pin or two that could be repurposed? but yeah, not really.

@@ -0,0 +1,4 @@
MODULE = board
DIRS = $(RIOTBOARD)/common/nrf52xxxdk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this pointed to the nrf52xxxdk and not nrf52? Is there some refactoring required in those directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was re-using the board.c. Anyhow, fixed.

TERMFLAGS = term_rtt

# use shared Makefile.include
include $(RIOTBOARD)/common/nrf52xxxdk/Makefile.include
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, including nrf52xxxdk-files while this is not part of the DK development kits is a bit confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


"The PINE64 SmartWatch, dubbed "PineTime", is a product of a community effort for an open source smartwatch in collaboration with wearable RTOS and Linux app developers & communities."

See https://wiki.pine64.org/index.php/PineTime#PineTime_DevKit_SWD_Probe for more information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why link a specific section of that page here? Isn't it more safe to link to the top of the page (without #PineTime_DevKit_SWD_Probe in the url)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, that was an accident.

@bergzand
Copy link
Member

bergzand commented Jan 9, 2020

I've got some more code here: https://github.com/kaspar030/pinetime-riot

If I remember correctly that's the branch I based my firmware application on 😆

@kaspar030
Copy link
Contributor Author

If I remember correctly that's the branch I based my firmware application on laughing

Wow, that's quite advanced! Looking forward to try!

extern "C" {
#endif

/* move on, nothing to see here */
Copy link
Member

@bergzand bergzand Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the backlight GPIO pins also be included here? As an alternative, maybe it is possible to use PWM on them to have more granular brightness control.

Copy link
Contributor Author

@kaspar030 kaspar030 Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I got all those in my pinetime pinetime_display branch, but not very clean. will update soon!

@kaspar030 kaspar030 force-pushed the add_pinetime_support branch from 497c267 to 104d0bd Compare January 9, 2020 22:38
gpio_init(VIBRATOR, GPIO_OUT);
gpio_init(LCD_BACKLIGHT_LOW, GPIO_OUT);
gpio_init(LCD_BACKLIGHT_MID, GPIO_OUT);
gpio_init(LCD_BACKLIGHT_HIGH, GPIO_OUT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be a good neighbor and disable the vibrator, and both LCD_BACKLIGHT_HIGH and LCD_BACKLIGHT_MID with gpio_set(VIBRATOR) (those pins are active low), preferably before initializing them as output if that is possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@bergzand bergzand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 more comments, feel free to ignore if you think these should wait for a follow up.

@bergzand
Copy link
Member

If I have time this evening I can see if I can also give you a snippet to add config for the SPI flash.

CPU_MODEL = nrf52832xxaa

# Put defined MCU peripherals here (in alphabetical order)
#FEATURES_PROVIDED += periph_i2c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't have to be commented out anymore now that the I2C config is included.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@kaspar030
Copy link
Contributor Author

  • addressed all comments

The PR is now able to directly use the ili9341 if the backlight is enabled. E.g., tests/drivers_ili9341 displays something with adding this line: https://gist.github.com/kaspar030/8e252913801e8bb26978093b85dff7f9/raw. I (conditionally) added this to that driver's main.c.
I'd also like to not use the test synchronization for the ili test, if compiling for the pinetime. If used, the pinetime waits on stdio_rtt for 's' indefinitely.

@bergzand
Copy link
Member

The PR is now able to directly use the ili9341 if the backlight is enabled. E.g., tests/drivers_ili9341 displays something with adding this line: https://gist.github.com/kaspar030/8e252913801e8bb26978093b85dff7f9/raw. I (conditionally) added this to that driver's main.c.
I'd also like to not use the test synchronization for the ili test, if compiling for the pinetime. If used, the pinetime waits on stdio_rtt for 's' indefinitely.

Mind giving #13105 a spin on your PineTime with CFLAGS += -DILI9341_PARAM_INVERTED=1 -DILI9341_PARAM_RGB=1? 😁

@kaspar030
Copy link
Contributor Author

Mind giving #13105 a spin on your PineTime with CFLAGS += -DILI9341_PARAM_INVERTED=1 -DILI9341_PARAM_RGB=1? grin

will do. the poor thing is going through a compile_and_test run ATM...

@kaspar030
Copy link
Contributor Author

@bergzand this should be good to go?

@@ -0,0 +1,7 @@
# for this board, we are using Segger's RTT as default terminal interface
USEMODULE += stdio_rtt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at #12724. That would help make things a little cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary if there's no periph_uart feature, which stdio_uart and ethos depend on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.

This board is in the same case as the hamilton, so things related to stdio_rtt could be replaced with just:

# use JLink Segger RTT by default
RIOT_TERMINAL ?= jlink
include $(RIOTMAKE)/tools/serial.inc.mk

And add the following in pinetime/Makefile.dep:

# Use Segger's RTT by default for stdio on this board
DEFAULT_MODULE += stdio_rtt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks weird: include $(RIOTMAKE)/tools/serial.inc.mk.
The board doesn't have uarts exposed...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now that I tried I realized that in master, this doesn't work. ;(

@kaspar030 kaspar030 force-pushed the add_pinetime_support branch from 69f9b63 to e7d34b5 Compare January 13, 2020 21:56
@emmanuelsearch
Copy link
Member

Tested examples/nimble_gatt and tests/driver_ili9341. Both work like a charm!

@kaspar030
Copy link
Contributor Author

kaspar030 commented Jan 14, 2020

I've done a full compile_and_test run. Many tests seem to run fine, but stdio_rtt output is pretty broken. Those that fail because of lost output actually succeeded (edit unless blacklisted).

I've managed to get unittests to pass using this patch (adding an early xtimer_init call and increasing stdio_rtt output buffer size).

$ BOARD=pinetime make term
/home/kaspar/src/riot/dist/tools/jlink/jlink.sh term-rtt
### Starting RTT terminal ###
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2020-01-14 15:38:54,102 # Host name for TCP connection is missing, defaulting to "localhost"
2020-01-14 15:38:54,102 # Connect to localhost:19021
Welcome to pyterm!
Type '/exit' to exit.
2020-01-14 15:38:55,108 # SEGGER J-Link V6.56b - Real time terminal output
2020-01-14 15:38:55,108 # SEGGER J-Link EDU V10.1, SN=260107551
2020-01-14 15:38:55,109 # Process: JLinkExe
2020-01-14 15:38:55,109 # main(): This is RIOT! (Version: 2020.01-devel-1724-ge7d34-add_pinetime_support)
2020-01-14 15:38:55,109 # Help: Press s to start test, r to print it is ready
s
2020-01-14 15:38:55,811 # START
2020-01-14 15:39:05,404 # ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
2020-01-14 15:39:05,404 # OK (959 tests)

Otherwise the tests look fine. The stdio_rtt issues are unrelated to this board.

ping @bergzand, do you see more issues?

@aabadie, regarding the rtt configuration, IMO #12724 is independent of this PR, right?

@fjmolinas please keep an eye on this PR, would be awesome to have the support before fosdem!

@bergzand
Copy link
Member

I've managed to get unittests to pass using this patch (adding an early xtimer_init call and increasing stdio_rtt output buffer size).

Have you tried compiling stdio_rtt with STDIO_RTT_ENABLE_BLOCKING_STDOUT enabled? Or is that unrelated here?

ping @bergzand, do you see more issues?

I think you've covered everything from my side. Feel free to squash if the others agree.

@kaspar030
Copy link
Contributor Author

Have you tried compiling stdio_rtt with STDIO_RTT_ENABLE_BLOCKING_STDOUT enabled? Or is that unrelated here?

Yes... It didn't seem to help, there were still some output issues. I think we need to take a close look at stdio_rtt at some point.

@aabadie
Copy link
Contributor

aabadie commented Jan 14, 2020

If you base your work on #12724 and disable the stdio_rtt module when auto_init is disabled, it will provide a simple workaround to the failing tests.
I managed to do a similar thing in #12304: https://github.com/RIOT-OS/RIOT/pull/12304/files#diff-cc423206e4b071a735d298217a657675R1029

@kaspar030
Copy link
Contributor Author

If you base your work on #12724 and disable the stdio_rtt module when auto_init is disabled, it will provide a simple workaround to the failing tests.

Talked offline, @aabadie is ok with not applying his suggestion.
IMO, the stdio_rtt issues are unrelated to the pinetime (there are boards in master that suffer the same issues, e.g., the ruuvitag). Also, #12724 can be seen as bugfix to the testing situation, so it is not bound by the feature freeze tomorrow. 😉 So I'll squash this now.

@kaspar030 kaspar030 force-pushed the add_pinetime_support branch from e7d34b5 to 2b658c1 Compare January 14, 2020 16:12
@bergzand
Copy link
Member

@kaspar030 Murdock has some issues with missing docs for the ILI9341 defines. Feel free to amend directly.

@kaspar030 kaspar030 force-pushed the add_pinetime_support branch from 2b658c1 to 4c0f4da Compare January 14, 2020 20:06
@kaspar030
Copy link
Contributor Author

@kaspar030 Murdock has some issues with missing docs for the ILI9341 defines. Feel free to amend directly.

Yup, done. Murdock is happy, this needs an ACK!

@emmanuelsearch emmanuelsearch self-requested a review January 15, 2020 08:12
Copy link
Member

@bergzand bergzand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack!

@bergzand
Copy link
Member

Al green, Go!

@bergzand bergzand merged commit fcec592 into RIOT-OS:master Jan 15, 2020
@emmanuelsearch
Copy link
Member

Nice!

@kaspar030 kaspar030 deleted the add_pinetime_support branch January 15, 2020 10:31
@kaspar030
Copy link
Contributor Author

Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants