Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards/adafruit-clue: add initial support #13276

Merged
merged 5 commits into from
Apr 8, 2020

Conversation

aabadie
Copy link
Contributor

@aabadie aabadie commented Feb 4, 2020

Contribution description

This PR adds an initial support for the Adafruit Clue board. This board has the same form factor as the micro:bit but is running on an nrf52840 MCU, which gives much more possibilities. There are also plenty of sensors and a TFT LCD screen.

Almost all sensors are already supported by RIOT: bmp280, sth31, lis3mdl. Support for the apds9960 is provided by #10420 (I tested it and the basic version works).

What was tested with success:

  • I2C: all configured sensors are working
  • second SPI: it is connected to the screen, which is ILI9341 compliant => tests/driver_ili9341 works

The accelerometer, an LSM6DS33, is not tested/supported yet (maybe it's similar to the LSM6DSL) ?

The board is flashed using nrfutil as it is the tool used by the Arduino IDE: I added a new makefile for managing nrfutil.
The other thing is the management of the bootloader: I reuse the same approach used for the arduino-nano-33-ble board (see #13194) to trigger a reboot in bootloader mode. nrfutil is able to handle the serial "touch" at 1200bauds and to flash afterwards.

Testing procedure

  • Verify sensors/LEDs/buttons are correctly configured:
make BOARD=adafruit-clue -C example/default flash term

Issues/PRs references

This PR is based on #12304 for the bootloader management.

@aabadie aabadie added Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first Area: boards Area: Board ports labels Feb 4, 2020
@aabadie aabadie requested a review from fjmolinas February 4, 2020 07:16
@miri64
Copy link
Member

miri64 commented Feb 4, 2020

The board is flashed using nrfutil as it is the tool used by the Arduino IDE: I added a new makefile for managing nrfutil.

Are you aware of #13146?

@aabadie
Copy link
Contributor Author

aabadie commented Feb 4, 2020

Are you aware of #13146?

Yes, this is where I "took" the zip generation mechanism. But I had to readapt it for this board. Most of this PR is taken from #13194, especially the management of the bootloader. Maybe this can also be useful for #13146 ?

@miri64
Copy link
Member

miri64 commented Feb 4, 2020

Yes, this is where I "took" the zip generation mechanism. But I had to readapt it for this board. Most of this PR is taken from #13194, especially the management of the bootloader. Maybe this can also be useful for #13146 ?

Let's ask @chrysn ;-).

@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from 1c173a8 to 3d31c77 Compare February 4, 2020 07:39
@chrysn
Copy link
Member

chrysn commented Feb 4, 2020

Ad 1200 baud for nrf52840-dongle: I'd prefer to not introduce the 1200 baud rate hack to devices where it's not the manufacturer (or otherwise brand conventional, as in Arduino) endorsed way to enter the bootloader -- at least not unless it's advertised in some way (something like the CDC-ACM subprotocol, maybe, but those can only be allocated with USB-IF registration IIUC). When we have the choice of picking what to do, I'd rather implement a specified DFU reset rather than doing the only thing the particular hardware that happened to be used first with Arduino could do.

But thanks for alerting me to this, I'm still looking through the PR, but it's a tad hard to tell for me what is actually part of the PR itself (it says it's based on #12304 and thus aabadie/pr/boards/arduino-mkr_stdio, but from that I get an even larger delta as from master).

Anyway, I'm probably gonna "steal back" the makefiles/tools/nrfutil.inc.mk , and I think that based on your term-delay, I can come up with something even more precise (by having the programmer report its stat of $TERM to a file, and only blocking term while that is still the stat).

@aabadie
Copy link
Contributor Author

aabadie commented Feb 4, 2020

I hope #12304 will be merged soon, so the diff related to this PR will be more readable.

Otherwise, you can just use git diff b154382311accb3be92680ba8f9fcd77e6a81149...3d31c77641a78ab52e96379959c9d110769cad60 (but the commit hashes might change after some updates of this PR)...

@chrysn
Copy link
Member

chrysn commented Feb 14, 2020

I've tried to incorporate your nrfutil.inc.mk into #13146, but there are a few nontrivial differences both in the fflags. Are we even running the same nrfutil here? (Mine doesn't recognize --baudrate, touch or singlebank, even though I just updated it from pip3 install nrfutil --force).

With that, it might be more prudent to not make this a common nrfutil.inc yet but to have it per board, and later compare them to the point where we can unify.

@aabadie
Copy link
Contributor Author

aabadie commented Feb 14, 2020

there are a few nontrivial differences both in the fflags

As I said, I started from your nrfutil configuration in #13146 and was surprised some options are so different.
So I had a second look, and I think I messed things up between the Nordic nrfutil and the Adafruit nrfutil. It seems both packages are not compatible (installing nrfutil breaks adafruit-nrfutil).
I'll have a look at that later.

@emmanuelsearch
Copy link
Member

@aabadie I also got hold of one of these boards fyi. Could test stuff!

@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from 3d31c77 to 00ff7a1 Compare February 25, 2020 11:34
@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch 2 times, most recently from 9771a07 to 8a192a5 Compare March 11, 2020 07:23
@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from 8a192a5 to e63adf9 Compare March 18, 2020 10:45
@aabadie aabadie removed the State: waiting for other PR State: The PR requires another PR to be merged first label Mar 18, 2020
@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch 2 times, most recently from 99e71ee to b0e2ceb Compare March 18, 2020 10:57
@aabadie aabadie added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 18, 2020
@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from b0e2ceb to bc1f787 Compare March 18, 2020 10:59
@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from b8d4c55 to 35833a5 Compare March 31, 2020 12:35
@aabadie
Copy link
Contributor Author

aabadie commented Mar 31, 2020

@fjmolinas I also applied your suggestions. Let's see what Murdock has to say.

@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from 35833a5 to b4e6bcd Compare April 1, 2020 19:56
@aabadie
Copy link
Contributor Author

aabadie commented Apr 1, 2020

I pushed a fix similar to the one in #13664. Hope this will make Murdock happy this time.

@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from b4e6bcd to 81eaeb9 Compare April 2, 2020 14:25
@aabadie
Copy link
Contributor Author

aabadie commented Apr 2, 2020

No more build issues on Murdock! @fjmolinas, are you ok to squash ?

@fjmolinas
Copy link
Contributor

No more build issues on Murdock! @fjmolinas, are you ok to squash ?

Yes go ahead.

@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from 81eaeb9 to c7b365c Compare April 2, 2020 17:01
@aabadie
Copy link
Contributor Author

aabadie commented Apr 2, 2020

Yes go ahead.

Done!

@emmanuelsearch
Copy link
Member

@aabadie is this targeted at the release?

@aabadie
Copy link
Contributor Author

aabadie commented Apr 6, 2020

is this targeted at the release?

I hope it will be merged tomorrow. So yes :)

Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

In general everything looks good, only some nit-picks. I do not have the BOARD to test, I will trust @aabadie on this one regarding testing, if possible next time give some test results in the PR description.


The board is flashed using the `nrfutil` Python package.

Once `nrfutil` is installed, ase `BOARD=adafruit-clue` with the `make` command.<br/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Once `nrfutil` is installed, ase `BOARD=adafruit-clue` with the `make` command.<br/>
Once `nrfutil` is installed, use `BOARD=adafruit-clue` with the `make` command.<br/>

Copy link
Contributor

Choose a reason for hiding this comment

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

TBH this phrase is weird, I would simply remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line removed


#include "usb_board_reset.h"

#define NRF52_DOUBLE_TAP_MAGIC_NUMBER (0x4e)
Copy link
Contributor

Choose a reason for hiding this comment

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

What this for? Mind adding a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment added.

FLASHFILE = $(HEXFILE)
FLASHDEPS += $(HEXFILE).zip
FLASHER = adafruit-nrfutil
FFLAGS = dfu serial --port=${PORT} --baudrate=115200 --touch=1200 --package=$(HEXFILE).zip --singlebank
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FFLAGS = dfu serial --port=${PORT} --baudrate=115200 --touch=1200 --package=$(HEXFILE).zip --singlebank
FFLAGS = dfu serial --port=${PORT} --baudrate=${BAUD}--touch=1200 --package=$(HEXFILE).zip --singlebank

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


### Flash the board

The board is flashed using the `nrfutil` Python package.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The board is flashed using the `nrfutil` Python package.
The board is flashed using the `nrfutil` Python package:
$ pip install nrfutil --user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed, note that the doc was wrong, the package to install is adafruit-nrfutil.

@fjmolinas fjmolinas self-assigned this Apr 7, 2020
@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from c7b365c to 155d6ec Compare April 7, 2020 16:12
@aabadie
Copy link
Contributor Author

aabadie commented Apr 7, 2020

Also I tested examples/default with the recent changes:

make BOARD=adafruit-clue -C examples/default/ clean flash term
make: Entering directory '/work/riot/RIOT/examples/default'
Building application "default" for "adafruit-clue" with MCU "nrf52".

"make" -C /work/riot/RIOT/boards/adafruit-clue
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/nrf52
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/nrf52/periph
"make" -C /work/riot/RIOT/cpu/nrf52/radio/nrf802154
"make" -C /work/riot/RIOT/cpu/nrf5x_common
"make" -C /work/riot/RIOT/cpu/nrf5x_common/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/apds99xx
"make" -C /work/riot/RIOT/drivers/bmx280
"make" -C /work/riot/RIOT/drivers/lis3mdl
"make" -C /work/riot/RIOT/drivers/netdev_ieee802154
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/drivers/saul
"make" -C /work/riot/RIOT/drivers/saul/init_devs
"make" -C /work/riot/RIOT/drivers/sht3x
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/auto_init/usb
"make" -C /work/riot/RIOT/sys/checksum
"make" -C /work/riot/RIOT/sys/div
"make" -C /work/riot/RIOT/sys/event
"make" -C /work/riot/RIOT/sys/fmt
"make" -C /work/riot/RIOT/sys/isrpipe
"make" -C /work/riot/RIOT/sys/luid
"make" -C /work/riot/RIOT/sys/net/gnrc
"make" -C /work/riot/RIOT/sys/net/gnrc/netapi
"make" -C /work/riot/RIOT/sys/net/gnrc/netif
"make" -C /work/riot/RIOT/sys/net/gnrc/netif/hdr
"make" -C /work/riot/RIOT/sys/net/gnrc/netif/ieee802154
"make" -C /work/riot/RIOT/sys/net/gnrc/netif/init_devs
"make" -C /work/riot/RIOT/sys/net/gnrc/netreg
"make" -C /work/riot/RIOT/sys/net/gnrc/pkt
"make" -C /work/riot/RIOT/sys/net/gnrc/pktbuf
"make" -C /work/riot/RIOT/sys/net/gnrc/pktbuf_static
"make" -C /work/riot/RIOT/sys/net/gnrc/pktdump
"make" -C /work/riot/RIOT/sys/net/link_layer/ieee802154
"make" -C /work/riot/RIOT/sys/net/link_layer/l2util
"make" -C /work/riot/RIOT/sys/net/netif
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/od
"make" -C /work/riot/RIOT/sys/phydat
"make" -C /work/riot/RIOT/sys/ps
"make" -C /work/riot/RIOT/sys/random
"make" -C /work/riot/RIOT/sys/random/tinymt32
"make" -C /work/riot/RIOT/sys/saul_reg
"make" -C /work/riot/RIOT/sys/shell
"make" -C /work/riot/RIOT/sys/shell/commands
"make" -C /work/riot/RIOT/sys/tsrb
"make" -C /work/riot/RIOT/sys/usb/usbus
"make" -C /work/riot/RIOT/sys/usb/usbus/cdc/acm
"make" -C /work/riot/RIOT/sys/usb_board_reset
"make" -C /work/riot/RIOT/sys/xtimer
   text	   data	    bss	    dec	    hex	filename
  46800	    164	   9408	  56372	   dc34	/work/riot/RIOT/examples/default/bin/adafruit-clue/default.elf
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0x00B6 --application /work/riot/RIOT/examples/default/bin/adafruit-clue/default.hex /work/riot/RIOT/examples/default/bin/adafruit-clue/default.hex.zip
Zip created at /work/riot/RIOT/examples/default/bin/adafruit-clue/default.hex.zip
adafruit-nrfutil dfu serial --port=/dev/ttyACM0 --baudrate=115200 --touch=1200 --package=/work/riot/RIOT/examples/default/bin/adafruit-clue/default.hex.zip --singlebank
Upgrading target on /dev/ttyACM0 with DFU package /work/riot/RIOT/examples/default/bin/adafruit-clue/default.hex.zip. Flow control is disabled, Single bank, Touch 1200
########################################
########################################
############
Activating new firmware
Device programmed.
sleep 2
/work/riot/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200" 
2020-04-07 18:11:23,941 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
2020-04-07 18:11:24,947 # main(): This is RIOT! (Version: 2020.04-devel-1985-g155d6-pr/boards/adafruit-clue)
2020-04-07 18:11:24,948 # Welcome to RIOT!
> help
2020-04-07 18:11:26,901 #  help
2020-04-07 18:11:26,902 # Command              Description
2020-04-07 18:11:26,904 # ---------------------------------------
2020-04-07 18:11:26,905 # reboot               Reboot the node
2020-04-07 18:11:26,906 # version              Prints current RIOT_VERSION
2020-04-07 18:11:26,907 # ps                   Prints information about running threads.
2020-04-07 18:11:26,907 # random_init          initializes the PRNG
2020-04-07 18:11:26,907 # random_get           returns 32 bit of pseudo randomness
2020-04-07 18:11:26,907 # ifconfig             Configure network interfaces
2020-04-07 18:11:26,908 # txtsnd               Sends a custom string as is over the link layer
2020-04-07 18:11:26,908 # saul                 interact with sensors and actuators using SAUL
> ifconfig
2020-04-07 18:11:29,255 #  ifconfig
2020-04-07 18:11:29,256 # Iface  5  HWaddr: 8E:1F  Channel: 26  NID: 0x23
2020-04-07 18:11:29,257 # Long HWaddr: 38:92:E5:B1:D1:E8:8E:1F 
2020-04-07 18:11:29,259 #  TX-Power: 0dBm L2-PDU:102 Source address length: 2
2020-04-07 18:11:29,259 # 
> saul
2020-04-07 18:11:32,477 #  saul
2020-04-07 18:11:32,478 # ID	Class		Name
2020-04-07 18:11:32,479 # #0	ACT_SWITCH	LED0 (Red)
2020-04-07 18:11:32,480 # #1	SENSE_BTN	Button A
2020-04-07 18:11:32,481 # #2	SENSE_BTN	Button B
2020-04-07 18:11:32,482 # #3	SENSE_TEMP	NRF_TEMP
2020-04-07 18:11:32,482 # #4	SENSE_PROXIMITY	apds99xx
2020-04-07 18:11:32,483 # #5	SENSE_LIGHT	apds99xx
2020-04-07 18:11:32,483 # #6	SENSE_LIGHT	apds99xx
2020-04-07 18:11:32,483 # #7	SENSE_TEMP	bmp280
2020-04-07 18:11:32,483 # #8	SENSE_PRESS	bmp280
2020-04-07 18:11:32,483 # #9	SENSE_MAG	lis3mdl
2020-04-07 18:11:32,483 # #10	SENSE_TEMP	sht3x1
2020-04-07 18:11:32,484 # #11	SENSE_HUM	sht3x1
> 2020-04-07 18:11:34,171 # Exiting Pyterm

@fjmolinas
Copy link
Contributor

@aabadie please squash!

@aabadie aabadie force-pushed the pr/boards/adafruit-clue branch from 155d6ec to 04f890f Compare April 8, 2020 07:35
Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

ACK.

@aabadie aabadie merged commit 75c6c38 into RIOT-OS:master Apr 8, 2020
@aabadie aabadie deleted the pr/boards/adafruit-clue branch April 8, 2020 07:50
@leandrolanzieri leandrolanzieri added this to the Release 2020.04 milestone Apr 8, 2020
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.

8 participants