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

board: add hamilton board support #9013

Merged
merged 1 commit into from
Apr 4, 2019

Conversation

Hyungsin
Copy link

@Hyungsin Hyungsin commented Apr 24, 2018

This PR provides an initial driver for the Hamilton board [1,2]. @immesys.

image

Hamilton has samr21e18a SoC (Cortex M0+ CPU and AT86RF233 radio), HDC1080 (temperature and humidity sensors), FXOS8700 (3-axis accelerator and magnetometer), TMP006 (object temperature), APDS9007 (light sensor), Button, LED, and EKMB (PIR motiron sensor). It provides JTAG as the programming/debugging interface. Its idle current is ~6 uA when a 32 kHZ RTC is running.

Some sensors have not been merged yet: APDS9007 (#8989), EKMB (#7823), FXOS8700 (#8978).
Low power clock configuration has not been merged yet: #7826.

Therefore, this PR, as an initial support, provides a test application which tests operation of HDC1080, TMP006, Button, and LED without low idle current.

References

[1] https://bets.cs.berkeley.edu/publications/2017buildsys_hamiltondemo.pdf
[2] https://bets.cs.berkeley.edu/publications/2018sensys_hamilton.pdf

@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch 7 times, most recently from 1982809 to c080d91 Compare April 24, 2018 19:28
@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch from c080d91 to 5f2ccce Compare June 15, 2018 19:49
@Hyungsin
Copy link
Author

Any review here?

@MichelRottleuthner
Copy link
Contributor

Where to get one of these boards, is it publicly available somewhere?

@Hyungsin
Copy link
Author

Hyungsin commented Jun 18, 2018

@MichelRottleuthner, Yes. You can get one from https://hamiltoniot.com/. I sent 5 hamiltons to @emmanuelsearch too.

@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch 2 times, most recently from 276c439 to ff4defe Compare June 18, 2018 23:30
@Hyungsin
Copy link
Author

Since #8978 was merged, now this PR includes FXOS8700.

@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch from ff4defe to 73a0f78 Compare June 18, 2018 23:43
Copy link
Contributor

@MichelRottleuthner MichelRottleuthner left a comment

Choose a reason for hiding this comment

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

Thank you for this PR! Looks quite clean to me. I only found some minor things, see below. One thing I'm not sure about is the board-specific test application. I think gnerally it's nice to have a test app that makes use of all the boards features but I'm not convinced it actually adds additional value here. Most (if not all) of the things that are done in tests/board_hamilton should already be covered by the saul test, while being easier and more generic (less code; no need for adaption when adding additional sensors).

@@ -0,0 +1,15 @@
ifneq (,$(filter gnrc_netdev_default netdev_default,$(USEMODULE)))
USEMODULE += at86rf233
USEMODULE += auto_init_gnrc_netif
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 the board itself shouldn't depend on auto_init_gnrc_netif - what if some application wants to use the radio (gnrc_netdev_default) but without auto-init?

Copy link
Author

Choose a reason for hiding this comment

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

What is a counter example? As saul_default includes "auto_init_saul" for sensor initialization, I think it is very convenient to include "auto_init_gnrc_netif" for radio initialization.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it is convenient, but it should be upon the application to decide whether to use auto_init or not. Counter example: run grep -r --include "Makefile*" "USEMODULE += auto_init_gnrc_netif" from RIOT root dir and you will see that hamilton is the only board that adds this dependency, all other occurrences are from tests or examples (i.e. applications).

Copy link
Author

@Hyungsin Hyungsin Jun 20, 2018

Choose a reason for hiding this comment

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

I changed the code, for consistency. But it is still not clear why "saul_default" includes auto_init in "RIOT-OS/Makefile.dep" but "netdev_default" does not. What is the reason?

FEATURES_PROVIDED += periph_rtt
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_pm
Copy link
Contributor

Choose a reason for hiding this comment

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

alphabetical order

Copy link
Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,18 @@
#!/bin/sh

# This script resets a CC2538SF53 target using JLink called
Copy link
Contributor

Choose a reason for hiding this comment

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

CC2538SF53?

Copy link
Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,151 @@
/*
* Copyright (C) 2018 UC Berkeley
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency please stick to same format here and above. Also the previous remark stated 2016, are both correct?

Copy link
Author

Choose a reason for hiding this comment

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

done 2016 is more correct

*
* @file
* @brief Board specific definitions for the Hamilton
* board
Copy link
Contributor

Choose a reason for hiding this comment

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

can go to the line above

Copy link
Author

Choose a reason for hiding this comment

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

done

#define PWM_MAX_CHANNELS 2
/* for compatibility with test application */
#define PWM_0_CHANNELS PWM_MAX_CHANNELS
#define PWM_1_CHANNELS PWM_MAX_CHANNELS
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really needed? looks like some old compatibility code to me(?)

Copy link
Author

Choose a reason for hiding this comment

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

It is true, but no harm to have this just in case, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

no harm, but we shouldn't add unnecessary code ;) I think you are safe to remove it here. The use of this define was removed some time ago.

Copy link
Author

Choose a reason for hiding this comment

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

OK. I resolved the issue. But FYI, samr21-xpro driver also has this part.

@@ -24,6 +24,7 @@
#include <string.h>

#include "periph/cpuid.h"
#include "board.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated?

Copy link
Author

Choose a reason for hiding this comment

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

It is related because fb_eui64 is defined in board.h.

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, I actually meant the same line in tmp006.h

Copy link
Author

Choose a reason for hiding this comment

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

Alright :)

sys/luid/luid.c Outdated
#ifdef HAS_FACTORY_BLOCK
uint8_t *out = (uint8_t *)buf;
memcpy(out, fb_eui64, 8);
#else
#if CPUID_LEN
Copy link
Contributor

Choose a reason for hiding this comment

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

use #else if here

sys/luid/luid.c Outdated
@@ -59,4 +64,5 @@ void luid_base(void *buf, size_t len)
out[i % len] ^= cid[i];
}
#endif
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

when using #else if above, one of the #endif lines can be removed here

Copy link
Author

Choose a reason for hiding this comment

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

done

* CORECLOCK = ((PLL_MUL + 1) * 1MHz) / PLL_DIV
*
* NOTE: The PLL circuit does not run with less than 32MHz while the maximum PLL
* frequency is 96MHz. So PLL_MULL must be between 31 and 95!
Copy link
Contributor

Choose a reason for hiding this comment

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

PLL_MULL

Copy link
Author

Choose a reason for hiding this comment

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

done

@MichelRottleuthner MichelRottleuthner added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: boards Area: Board ports labels Jun 19, 2018
@MichelRottleuthner
Copy link
Contributor

I don't have a board here to actually test. @emmanuelsearch can you or someone at FU test this on real hardware? Or can you spare one of the five boards you have for some time? (I assume @tcschmidt would be willing to ship it from FU to HAW and back)

@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch from 8ce33c8 to 27bf380 Compare June 19, 2018 22:39
@Hyungsin
Copy link
Author

Hyungsin commented Jun 19, 2018

@MichelRottleuthner, I reflected most comments.

Regarding the test application, I do think that providing a complete test application is good for users to experience full features of the board quickly, without tedious trials and errors. This is to mitigate any misunderstanding and hasty frustration.

The hamilton is designed for low-power sensing and wireless reporting, which needs to be shown in this test application. I'm thinking working on this application further to show that hamilton periodically wakes up, senses all information, and broadcasts a packet including the information. The idle current should be ~6uA.

If redundancy is only thing that matters, please allow me to maintain this application :)

@@ -80,6 +80,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "periph/i2c.h"
#include "board.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is used for TMP006_USE_LOW_POWER, right? It looks a bit misplaced to me, that the driver of a temperature sensor needs to know something about the board it is used on, except for it's parameters. Is it really needed to define this in board.h? I mean, the board will work without this setting and so will the driver -> this looks application-specific to me. If there really is a good reason to set TMP006_USE_LOW_POWER and TMP006_USE_RAW_VALUES in board.h then these should be handled like the other TMP006_PARAM* values via tmp006_params.h. But then this change should also be introduced by a seperate PR I think.

#define FXOS8700_PARAM_ADDR (0x1E)
#define FXOS8700_PARAM_ACC_RANGE FXOS8700_REG_XYZ_DATA_CFG_FS__8G
#define FXOS8700_PARAM_RENEW_INTERVAL (1000000ul)
#define FXOS8700_USE_ACC_RAW_VALUES (0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really needed here? FXOS8700_USE_ACC_RAW_VALUES isn't handled by fxos8700_params.h so overwriting this by the application will not be possible. See my other comment regarding tmp006.h

@emmanuelsearch
Copy link
Member

@Hyungsin @MichelRottleuthner the plan was to test this week and integrate in CI in Berlin with @kaspar030
Stay tuned, we target Friday.

@MichelRottleuthner
Copy link
Contributor

MichelRottleuthner commented Jun 20, 2018

Regarding the test application, I do think that providing a complete test application is good for users to experience full features of the board quickly, without tedious trials and errors. This is to mitigate any misunderstanding and hasty frustration.

I agree on that and I like that you kept an eye on usability/simplicity, but at the moment the application doesn't include something specific to this board, does it? Have you tried the saul test appllication? It should do almost the same as this test app with less code.

I'm thinking working on this application further to show that hamilton periodically wakes up, senses all information, and broadcasts a packet including the information. The idle current should be ~6uA.

Then it may be better to issue a PR once the application has this implemented ;)

Edit: maybe the applications repo would be the right place for this specifc app - when placed there you could also add some code to showcase usage of the hamilton cloud service ;)

@emmanuelsearch thanks!

@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch 3 times, most recently from f4b62d4 to e29be55 Compare June 20, 2018 20:01
#endif
#ifndef HDC1000_PARAM_RENEW_INTERVAL
#define HDC1000_PARAM_RENEW_INTERVAL (1000000ul)
#endif
Copy link
Author

Choose a reason for hiding this comment

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

This part is related to #9386.

@Hyungsin
Copy link
Author

@MichelRottleuthner, I agree. So I removed the test application and tmp006.h from this PR.

@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch from e29be55 to d17ff3d Compare June 20, 2018 22:48
@Hyungsin
Copy link
Author

@danpetry, how is it going? Can we include this PR in the upcoming release?

@tcschmidt
Copy link
Member

There is still a change request by @kYc0o - has this been resolved?

@Hyungsin
Copy link
Author

@tcschmidt, yes 👍

@tcschmidt
Copy link
Member

@tcschmidt, yes 👍

@kYc0o can you confirm?
@danpetry can this be merged then?

@danpetry
Copy link
Contributor

This is still not working over this side - we've tested on a number of dev machines to make sure it's not something to do with the setup of mine. @Hyungsin I've got exactly the same OS and Jlink versions as you. Looking into this further.

@cladmi
Copy link
Contributor

cladmi commented Mar 28, 2019

I added a PR that could at least, show when flashing fails with the board instead on returning 0.
#11303

Copy link
Contributor

@kYc0o kYc0o left a comment

Choose a reason for hiding this comment

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

ACK from my side, though I think the testing is not completely done yet.

@danpetry danpetry self-requested a review March 28, 2019 17:05
@cladmi
Copy link
Contributor

cladmi commented Mar 28, 2019

Re the removal of auto_init, initially this was to isolate the test code better. As you point out, now we need it for RTT so should put it back in. It's unlikely to have any adverse effects but let's test on a few other selected boards just in case.

I'm just realizing that this would be fine for tests/shell, but may cause trouble in other tests.

I am thinking about something as I currently have a similar issue that when auto_init is disabled I cannot rely on it to have something started.
The issue is that auto_init cannot be enabled by default as one test may not want one init function to be called.
So more the fact that "auto_init" enables all the available "auto_init" functions by default.

It would be a good solution to just disable the auto inclusion of all init functions but still use the requested ones. It would require some refactoring but I think it would still be beneficial when using xfa so could still make sense to do it now.
By changing the #ifdef MODULE_MODULE_NAME to #ifdef MODULE_AUTO_INIT_MODULE_NAME or #ifdef defined(MODULE_AUTO_INIT_MODULE_NAME) && defined(MODULE_MODULE_NAME) and doing the requested definitions in the dependencies handling, auto_init could be split between init which calls the base function and auto_init that enables everything by default.

@danpetry
Copy link
Contributor

danpetry commented Mar 29, 2019

I've found that the following sequence of operations works reliably, for examples/default, tests/shell, and examples/hello-world.

w1: BOARD=hamilton make flash debug
w2: BOARD=hamilton make term (can get serial output at this point, from w2)
w1: (gdb) c (can give serial input at this point, into w2)

If the second and third steps are swapped, no operation is possible, which is why it wasn't working for me before. I.e. pyterm doesn't seem to connect correctly when the program is actually running. @Hyungsin is this the same on your side?

@cladmi has raised the point that this doesn't allow running automated tests. i.e. make test doesn't work. What's the usual requirement for a new board concerning make test? Is it acceptable to document this and raise an issue? I'm conscious also that this would probably be an extra requirement for @Hyungsin that he wasn't aware of, so I'm happy to help out if we decide it's necessary.

@danpetry danpetry removed the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Mar 29, 2019
@Hyungsin
Copy link
Author

@danpetry, @cladmi, alright. Please figure out where we should go.

@danpetry
Copy link
Contributor

danpetry commented Apr 1, 2019

Here's my assessment of the issues. tl;dr: ACK from me, I'll wait for a day or so before merging in case others want to offer further opinion.

auto_init/xtimer
Stdio_rtt is dependent on xtimer_init() being called, whereas stdio_uart is not, which has caused the issue. tests/shell covers both these modules. Seems to me that enabling auto_init for this test is fine and won't have any adverse effects on the stdio_uart case.

make test
Checking the Ruuvitag and Thingy52, it seems they have the same treatment - i.e. stdio is provided over RTT by default. So, no make test available.

Both of these issues existed before this PR, and the ruuvitag and thingy52 were merged presumably without tests/shell working, and without make test. It's good that this has highlighted some related issues but since they were not caused by the contribution my opinion is that these issues should be discussed and fixed separately. I'll raise the issues.

@danpetry danpetry added the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Apr 2, 2019
@danpetry
Copy link
Contributor

danpetry commented Apr 2, 2019

Comment above updated after some offline discussion with @miri64 . ACK from me and I'll wait before merging for a short while as stated.

@Hyungsin
Copy link
Author

Hyungsin commented Apr 2, 2019

@danpetry, great! Then should I restore DISABLE=auto_init for the shell test?

@danpetry
Copy link
Contributor

danpetry commented Apr 3, 2019

@Hyungsin yes, please restore the shell test makefile back to the way it was, squash and rebase. I don't see any blocking comments above so I'll re-test and merge once you've done this :)

@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch 3 times, most recently from cebf85f to 2f1345c Compare April 3, 2019 21:53
@Hyungsin Hyungsin force-pushed the forupstream_hamilton branch from 2f1345c to d9c17c2 Compare April 3, 2019 22:00
@Hyungsin
Copy link
Author

Hyungsin commented Apr 3, 2019

@danpetry, done!

@danpetry danpetry merged commit 09b48d7 into RIOT-OS:master Apr 4, 2019
@danpetry
Copy link
Contributor

danpetry commented Apr 4, 2019

Re-tested and merged. Thanks for your patience and your contribution! 💯

@danpetry
Copy link
Contributor

danpetry commented Apr 4, 2019

#11341 adds instructions on RTT shell access for all boards that use it

@danpetry
Copy link
Contributor

danpetry commented Apr 4, 2019

#11344 and #11343 describe the RTT-related issues with the shell

@danpetry
Copy link
Contributor

danpetry commented Apr 4, 2019

As described above, these issues were pre-existing and so being raised and dealt with outside the scope of this PR.

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 Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines 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.