-
Notifications
You must be signed in to change notification settings - Fork 13
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
Zephyr: examples: add hello #129
Conversation
szczys
commented
Jul 19, 2023
•
edited
Loading
edited
- add samples common support for hardcoded credentials
- add samples common support for default configuration
- select common symbols by default when building with zephyr port
- add symbols to select between PSK and certificate auth
- add the hello sample
Visit the preview URL for this PR (updated for commit 9f9c43c): https://golioth-firmware-sdk-doxygen-dev--pr129-szczys-zephyr-x726rk3c.web.app (expires Fri, 04 Aug 2023 16:29:44 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: a9993e61697a3983f3479e468bcb0b616f9a0578 |
cac7bca
to
1ba6838
Compare
1ba6838
to
d10685c
Compare
09c668c
to
60168c2
Compare
select MBEDTLS | ||
select MBEDTLS_DTLS if MBEDTLS_BUILTIN | ||
select NET_SOCKETS | ||
select NET_UDP | ||
select ZCBOR | ||
imply DNS_RESOLVER if NET_NATIVE | ||
imply NET_SOCKETS_SOCKOPT_TLS | ||
imply NET_SOCKETS_ENABLE_DTLS | ||
help | ||
Enable library for communication with Golioth cloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's remove those symbols from examples/zephyr/golioth_basics
and actually see how much this simplifies prj.conf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done so by adding this commit:
b9048cb
I was trying to keep golioth_basics as a more verbose example. Combining the default symbols from this commit with the common/Kconfig.defconfig committed later in this PR makes for nearly-empty prj.conf files in the more simplified samples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be really just a single way how to configure examples. Otherwise such inconsistency is confusing to people wanting to compare those samples (e.g. "what does it take to configure more services at once, just like in golioth_basics sample").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it would be better to leave this commit out and move this set of symbol selection to the common/Kconfig.defconfig
file for samples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed with @sam-golioth and have left these symbols as is for now.
60168c2
to
2939c17
Compare
27ab152
to
750d9d6
Compare
Use absolute path when sourcing other Kconfig files. Signed-off-by: Mike Szczys <[email protected]>
* Add GOLIOTH_SAMPLE_COMMON * Add the `hardcoded_credentials` samples common helper from the Golioth Zephyr SDK. * add `hardcoded_credentials_get()` to return a `golioth_client_config_t` used to create a Golioth client * PSK or PKI (certificate auth) are returned automatically based on the `CONFIG_GOLIOTH_AUTH_METHOD_CERT` symbol * PKI is not yet implemented in the port. Placeholder code must be updated/replace when support is available Signed-off-by: Mike Szczys <[email protected]>
Use the GOLIOTH_SAMPLE_CONFIG symbol to conditionally include the common library files in the build. Signed-off-by: Mike Szczys <[email protected]>
automatically select necessary symbols when Golioth is enabled in a build: * MBEDTLS * MBEDTLS_DTLS * NET_SOCKETS * NET_UDP * ZCBOR * DNS_RESOLVER * NET_SOCKETS_SOCKOPT_TLS * NET_SOCKETS_ENABLE_DTLS Signed-off-by: Mike Szczys <[email protected]>
* port/zephyr/Kconfig: add symbols to select either certificate or PSK auth * port/zephyr/Kconfig: add symbols to configure mbedtls based on auth type * examples/zephyr/common/Kconfig: add symbols to define PSK/PSK-ID and certificate symbols Signed-off-by: Mike Szczys <[email protected]>
750d9d6
to
fdc33ca
Compare
rsource '../../src/Kconfig' | ||
rsource '${ZEPHYR_GOLIOTH_FIRMWARE_SDK_MODULE_DIR}/src/Kconfig' | ||
|
||
config GOLIOTH_CIPHERSUITES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think is being used anywhere, let's remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might need this. When I remove it I get this:
warning: the int symbol GOLIOTH_ZEPHYR_THREAD_STACK_SIZE (defined at /home/mike/golioth-compile/golioth-firmware-sdk/modules/lib/golioth-firmware-sdk/port/zephyr/Kconfig:121) has a non-int default GOLIOTH_COAP_THREAD_STACK_SIZE (undefined)
And I see that's in src/Kconfig:
➜ grep GOLIOTH_COAP_THREAD_STACK_SIZE ../../../src/Kconfig -A4
config GOLIOTH_COAP_THREAD_STACK_SIZE
int "Golioth CoAP thread stack size"
default 6144
help
Thread stack size of the Golioth CoAP thread, in bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it doesn't seem like removing GOLIOTH_CIPHERSUITES
should cause that particular error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sam-golioth I was confused by what you were commenting on. I thought you were asking to remove the rsource
line.
Sorry that I merged before reading this comment. I can make a new PR to remove this block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries! We're an agile team 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, looking into this I remember why I added it. It's a value used in the twister testing:
golioth-firmware-sdk/examples/zephyr/hello/sample.yaml
Lines 40 to 48 in 8a0825b
sample.golioth.hello.psk.fast.ccm_8: | |
platform_allow: > | |
nrf52840dk_nrf52840 | |
qemu_x86 | |
extra_configs: | |
- CONFIG_MBEDTLS_CIPHER_GCM_ENABLED=n | |
- CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y | |
- CONFIG_MBEDTLS_CIPHER_MODE_CBC_ENABLED=n | |
- CONFIG_GOLIOTH_CIPHERSUITES="TLS_PSK_WITH_AES_128_CCM_8" |
Do want me to remove the GOLIOTH_CIPHERSUITES along with that test?
default 2048 if MINIMAL_LIBC | ||
|
||
config LOG_PROCESS_THREAD_STACK_SIZE | ||
default 2048 if LOG_BACKEND_GOLIOTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no Golioth log backend yet, so we don't need this. Are there other settings in this file that go beyond what we need for these samples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point. I've removed everything form defconfig that wasn't directly used in the current state of golioth_basics.
CONFIG_FLASH=y | ||
CONFIG_FLASH_MAP=y | ||
CONFIG_STREAM_FLASH=y | ||
CONFIG_IMG_MANAGER=y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these flash and image symbols for a "hello" sample?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the DFU portions of the SDK are built automatically and I don't see a way to turn them off (the Zephyr SDK has a CONFIG_GOLIOTH_FW symbol for this).
In file included from /home/mike/golioth-compile/golioth-firmware-sdk/modules/lib/golioth-firmware-sdk/port/zephyr/golioth_fw_zephyr.c:1:
/home/mike/golioth-compile/golioth-firmware-sdk/zephyr/include/zephyr/dfu/flash_img.h:33:21: error: 'CONFIG_IMG_BLOCK_BUF_SIZE' undeclared here (not in a function); did you mean 'CONFIG_ISR_STACK_SIZE'?
33 | uint8_t buf[CONFIG_IMG_BLOCK_BUF_SIZE];
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| CONFIG_ISR_STACK_SIZE
These symbols are necessary to complete the build. But I don't think they should be part of the default config. I've left them here to be removed later when building DFU components is configurable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me! Can you file a ticket to make DFU configurable?
CONFIG_DNS_RESOLVER=y | ||
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y | ||
CONFIG_NET_SOCKETS_ENABLE_DTLS=y | ||
|
||
# TLS configuration | ||
CONFIG_MBEDTLS_ENABLE_HEAP=y | ||
CONFIG_MBEDTLS_HEAP_SIZE=10240 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these TLS options are enabled by GOLIOTH_AUTH_PSK_MBEDTLS_DEPS
in port/zephyr/Kconfig
so we don't need to set them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pared this prj.conf down to only the necessary symbols.
add symbols needed by all samples as the default when the common library is enabled. Signed-off-by: Mike Szczys <[email protected]>
Source the examples/zephyr/common/Kconfig from the main Zephyr port Kconfig file. All symbols in the common Kconfig are guarded and will only be built when `GOLIOTH_SAMPLE_COMMON` is selected. Signed-off-by: Mike Szczys <[email protected]>
Add the ciphersuites Kconfig options. These are used during Twister testing. Signed-off-by: Mike Szczys <[email protected]>
Remove the symbols that are now selected by default. This commit also changes the name of the symbol used for PSK/PSK-ID from CONFIG_GOLIOTH_* to CONFIG_GOLIOTH_SAMPLE_*. Signed-off-by: Mike Szczys <[email protected]>
Add a sample that sends "hello world" style message to Golioth. Includes support for qemu_x86 and nrf52840dk_nrf52840. Signed-off-by: Mike Szczys <[email protected]>
ignore hidden .cache directories created by vim Signed-off-by: Mike Szczys <[email protected]>
fdc33ca
to
9f9c43c
Compare