Re: submitting contributions to Zephyr
Nicolas Pitre
On Tue, 21 May 2019, Nathaniel Graff wrote:
I for one am definitely excited about a 64-bit RISC-V port of Zephyr!That's coming! But that's the easy part. Making core Zephyr 64-bit clean is the bulk of the work. You might be interested in this tool from GitHub called ‘hub’: https://hub.github.com/ <https://hub.github.com/> It provides a command-line interface to GitHub’s web UI.That's wonderful! Go figure why I didn't find it when looking exactly for such a thing. Thanks! Nicolas
|
|
Re: submitting contributions to Zephyr
Nathaniel Graff
Hi Nicholas!
toggle quoted messageShow quoted text
I for one am definitely excited about a 64-bit RISC-V port of Zephyr! You might be interested in this tool from GitHub called ‘hub’: https://hub.github.com/ It provides a command-line interface to GitHub’s web UI. Nate
|
|
submitting contributions to Zephyr
Nicolas Pitre
Hello,
This is my first post here, however it probably won't be the last. For a while I've been working on making Zephyr to compile for and run on 64-bit targets. That currently works with the native-posix target, and 64-bit RISC-V is my next target. I would like to submit my work for inclusion into the mainline Zephyr repository. The documented submit and review procedures imply Github forks and pull requests which involve going through hoops such as a Javascript-capable web browser and that is not exactly like a walk in the park for me (my background and credentials are available online if you want to know why). That would make my life easier if there could be some alternative way similar to how it is done with the Linux kernel. Please let me know if that is possible. I'm therefore posting my first patch here mainly to initiate a conversation on this issue. Obviously I have many more of them. ----- >8 Subject: [PATCH] fix PTP clock test case The various ptp_clock_driver_api methods receive a struct ptp_context not a struct eth_context, and the later must be obtained from a reference stored in the former. Failing to do so by directly interpreting driver_data as a struct eth_context instance does end up corrupting memory past the actual struct ptp_context storage. The test may still pass as ptp_clock_get() reads from the same out-of-bounds memory as the previous ptp_clock_set() and therefore the content matches, and with luck the corrupted memory is not essential to the completion of the test. But that wasn't my case which allowed me to find this issue. Fix this by properly obtaining a reference to the struct eth_context instance via the actual struct ptp_context, and adding one validation test in my_ptp_clock_set() like the one found in eth_tx() to make sure we got the right memory. Signed-off-by: Nicolas Pitre <npitre@baylibre.com> diff --git a/tests/net/ptp/clock/src/main.c b/tests/net/ptp/clock/src/main.c index 1625f6ec18..5d69164694 100644 --- a/tests/net/ptp/clock/src/main.c +++ b/tests/net/ptp/clock/src/main.c @@ -175,29 +175,40 @@ static u64_t timestamp_to_nsec(struct net_ptp_time *ts) return (ts->second * NSEC_PER_SEC) + ts->nanosecond; } +struct ptp_context { + struct eth_context *eth_context; +}; + static int my_ptp_clock_set(struct device *dev, struct net_ptp_time *tm) { - struct eth_context *ctx = dev->driver_data; + struct ptp_context *ptp_ctx = dev->driver_data; + struct eth_context *eth_ctx = ptp_ctx->eth_context; - memcpy(&ctx->time, tm, sizeof(struct net_ptp_time)); + if (ð_context_1 != eth_ctx && ð_context_2 != eth_ctx) { + zassert_true(false, "Context pointers do not match\n"); + } + + memcpy(ð_ctx->time, tm, sizeof(struct net_ptp_time)); return 0; } static int my_ptp_clock_get(struct device *dev, struct net_ptp_time *tm) { - struct eth_context *ctx = dev->driver_data; + struct ptp_context *ptp_ctx = dev->driver_data; + struct eth_context *eth_ctx = ptp_ctx->eth_context; - memcpy(tm, &ctx->time, sizeof(struct net_ptp_time)); + memcpy(tm, ð_ctx->time, sizeof(struct net_ptp_time)); return 0; } static int my_ptp_clock_adjust(struct device *dev, int increment) { - struct eth_context *ctx = dev->driver_data; + struct ptp_context *ptp_ctx = dev->driver_data; + struct eth_context *eth_ctx = ptp_ctx->eth_context; - ctx->time.nanosecond += increment; + eth_ctx->time.nanosecond += increment; return 0; } @@ -207,10 +218,6 @@ static int my_ptp_clock_rate_adjust(struct device *dev, float ratio) return 0; } -struct ptp_context { - struct eth_context *eth_context; -}; - static struct ptp_context ptp_test_1_context; static struct ptp_context ptp_test_2_context;
|
|
Re: [Zephyr-builds] zephyr build env for external module
Nashif, Anas
Qipeng, You should be posting to the devel@ mailing list instead. To answer your question, this is not supported in zephyr.
Anas
From:
<builds@...> on behalf of "Zha, Qipeng" <qipeng.zha@...>
Hi
In Linux, there will be some driver modules are external, can be put outside in linux kernel tree and build with a simple Makefile. For zephyr, is there similar usage can work as this ? thx.
Best wishes Qipeng
|
|
Upcoming Event: Zephyr Project: APIs - Tue, 05/21/2019 9:00am-10:00am, Please RSVP
#cal-reminder
devel@lists.zephyrproject.org Calendar <devel@...>
Reminder: Zephyr Project: APIs When: Tuesday, 21 May 2019, 9:00am to 10:00am, (GMT-07:00) America/Los Angeles Where:https://zoom.us/j/177647878 An RSVP is requested. Click here to RSVP Organizer: devel@... Description: Join from PC, Mac, Linux, iOS or Android: https://zoom.us/j/177647878 Live meeting minutes: https://docs.google.com/
|
|
Re: Logging with a string via %s
Boie, Andrew P
Why must we support high-speed deferred logging of C strings? Really what is this use-case so compelling that we have to leave sharp edges to developers like this? Is there precedent for this in other operating systems?
toggle quoted messageShow quoted text
Just take out %s support out completely. Format strings for literals, fine. Pointers? This is just going to lead to disasters. We don't need counter-measures, this thing should simply be removed, like gets() Andrew
-----Original Message-----
From: devel@lists.zephyrproject.org [mailto:devel@lists.zephyrproject.org] On Behalf Of Chruscinski, Krzysztof Sent: Monday, May 20, 2019 10:37 PM To: Herbert, Marc <marc.herbert@intel.com>; Dunaj, Pawel <Pawel.Dunaj@nordicsemi.no> Cc: devel@lists.zephyrproject.org Subject: Re: [Zephyr-devel] Logging with a string via %s Hi, Logger was redesigned to work in deferred mode (string processing and transport deferred to idle stage) to be capable of handling multiple backends and to be less intrusive than standard in-place approach. That is because Zephyr is targeting embedded systems where logger may be extensively used from interrupt context. This approach reduces logging time from hundreds of microseconds to just few, making it non-intrusive (compared to in-place logging). Additionally, deferred logging allows using multiple backends, including some which are slow (e.g. flashlog) or more complex (e.g. Bluetooth). In those cases in place logging wouldn't be possible at all. In order to achieve that, only arguments are stored when log message is created. %s is the victim of that but, as already mentioned, there are some countermeasures to take care of that: immediate mode (blocking) and log_strdup for duplicating transient string. For native_posix board immediate mode is the default one, maybe it should be the default for qemu boards as well but making it default for boards with SoC would soon lead to similar complaining email (like "I've enabled logging and my system crashed"). There are countermeasures that could be added that could help with that: - detection of lack of log_strdup during log processing. Based on the string address it could be determined if it's in .rodata or log_strdup buffer pool and if not warning/assert could occur - adding custom format specifiers for address (network, Bluetooth) since in many cases %s was used for locally rendered address. Krzysztof -----Original Message----- From: devel@lists.zephyrproject.org <devel@lists.zephyrproject.org> On Behalf Of Marc Herbert via Lists.Zephyrproject.Org Sent: Monday, May 20, 2019 7:00 PM To: Dunaj, Pawel <Pawel.Dunaj@nordicsemi.no> Cc: devel@lists.zephyrproject.org Subject: Re: [Zephyr-devel] Logging with a string via %s On 20 May 2019, at 00:20, pawel.dunaj@nordicsemi.no wrote: There's a violation of the "Least Astonishment" principle but it's not with the '%s'. The '%s' traditionally refers to the type of the argument only, it says nothing about memory management. I don't think LOG_ASYNC('%s', ...) or LOG(O_NONBLOCK, '%s', ... ) would surprise anyone. Confusing memory semantics with format specifiers would break not just user expectations but also tools like this: https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Common-Function-Attributes.html#index-format-function-attribute (I found an insane number of bugs with this attribute) + other static checkers trying to make C a bit more safe. BTW the current API is neither "asynchronous" nor "non-blocking" in the usual API meanings. It's not asynchronous in the usual sense because there's no callback or any other second step to know when the memory can be freed or re-used. It's not non-blocking because it always succeeds, never asks to retry with EAGAIN/EWOULDBLOCK etc. It's a "globals-only", "UFO" API like nothing else.
|
|
Re: Logging with a string via %s
Chruściński, Krzysztof
Hi,
toggle quoted messageShow quoted text
Logger was redesigned to work in deferred mode (string processing and transport deferred to idle stage) to be capable of handling multiple backends and to be less intrusive than standard in-place approach. That is because Zephyr is targeting embedded systems where logger may be extensively used from interrupt context. This approach reduces logging time from hundreds of microseconds to just few, making it non-intrusive (compared to in-place logging). Additionally, deferred logging allows using multiple backends, including some which are slow (e.g. flashlog) or more complex (e.g. Bluetooth). In those cases in place logging wouldn't be possible at all. In order to achieve that, only arguments are stored when log message is created. %s is the victim of that but, as already mentioned, there are some countermeasures to take care of that: immediate mode (blocking) and log_strdup for duplicating transient string. For native_posix board immediate mode is the default one, maybe it should be the default for qemu boards as well but making it default for boards with SoC would soon lead to similar complaining email (like "I've enabled logging and my system crashed"). There are countermeasures that could be added that could help with that: - detection of lack of log_strdup during log processing. Based on the string address it could be determined if it's in .rodata or log_strdup buffer pool and if not warning/assert could occur - adding custom format specifiers for address (network, Bluetooth) since in many cases %s was used for locally rendered address. Krzysztof
-----Original Message-----
From: devel@lists.zephyrproject.org <devel@lists.zephyrproject.org> On Behalf Of Marc Herbert via Lists.Zephyrproject.Org Sent: Monday, May 20, 2019 7:00 PM To: Dunaj, Pawel <Pawel.Dunaj@nordicsemi.no> Cc: devel@lists.zephyrproject.org Subject: Re: [Zephyr-devel] Logging with a string via %s On 20 May 2019, at 00:20, pawel.dunaj@nordicsemi.no wrote: There's a violation of the "Least Astonishment" principle but it's not with the '%s'. The '%s' traditionally refers to the type of the argument only, it says nothing about memory management. I don't think LOG_ASYNC('%s', ...) or LOG(O_NONBLOCK, '%s', ... ) would surprise anyone. Confusing memory semantics with format specifiers would break not just user expectations but also tools like this: https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Common-Function-Attributes.html#index-format-function-attribute (I found an insane number of bugs with this attribute) + other static checkers trying to make C a bit more safe. BTW the current API is neither "asynchronous" nor "non-blocking" in the usual API meanings. It's not asynchronous in the usual sense because there's no callback or any other second step to know when the memory can be freed or re-used. It's not non-blocking because it always succeeds, never asks to retry with EAGAIN/EWOULDBLOCK etc. It's a "globals-only", "UFO" API like nothing else.
|
|
Re: Logging with a string via %s
Marc Herbert
On 20 May 2019, at 00:20, pawel.dunaj@nordicsemi.no wrote: There's a violation of the "Least Astonishment" principle but it's not with the '%s'. The '%s' traditionally refers to the type of the argument only, it says nothing about memory management. I don't think LOG_ASYNC('%s', ...) or LOG(O_NONBLOCK, '%s', ... ) would surprise anyone. Confusing memory semantics with format specifiers would break not just user expectations but also tools like this: https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Common-Function-Attributes.html#index-format-function-attribute (I found an insane number of bugs with this attribute) + other static checkers trying to make C a bit more safe. BTW the current API is neither "asynchronous" nor "non-blocking" in the usual API meanings. It's not asynchronous in the usual sense because there's no callback or any other second step to know when the memory can be freed or re-used. It's not non-blocking because it always succeeds, never asks to retry with EAGAIN/EWOULDBLOCK etc. It's a "globals-only", "UFO" API like nothing else.
|
|
Re: Logging with a string via %s
pawel.dunaj@...
On Fri, May 17, 2019 at 04:24 PM, Boie, Andrew P wrote:
It has it's pros and cons. Personally I don't mind it as long as it is well understood and can be turned off. Here I totally agree. I think that formatting of strings is such a well known standard that nobody will read the fine print for a logger to see what magic may lie under its hood. I think we should either assert that %s is never used and use some other format instead (i.e. force people to check the doc at least once when they hit an error) or keep %s for in place rendering and add new format for people who want to go faster. Another thing is that assert is disabled by default so many people may never notice the problem (especially for error paths).
|
|
Re: Logging with a string via %s
Paul Sokolovsky
Hello,
On Fri, 17 May 2019 14:38:14 +0000 "lairdjm" <jamie.mccrae@lairdconnect.com> wrote: Hi,Opinions vary on that matter, some people think that the logging was actually "regressed" and not "improved". Literally, it became so advanced, smart, and sophisticated, that it goes against what most people need most of the time. Of course, we'll never know if that's true unless more people provide feedback, so thanks for posting. https://foundries.io/insights/2018/08/14/zephyr-logging-part-2/ whichI personally do conversion in that direction (printf -> LOG_x) only when I'm forced to (like, when submitting code for inclusion to Zephyr). During development, I always use printk/printf which just behave as expected. [] -- Best Regards, Paul Linaro.org | Open source software for ARM SoCs Follow Linaro: http://www.facebook.com/pages/Linaro http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog
|
|
Re: Logging with a string via %s
Paul Sokolovsky
Hello,
On Fri, 17 May 2019 14:24:41 +0000 "Boie, Andrew P" <andrew.p.boie@intel.com> wrote: For an operating system that aims to support various functionalSome people think that asynchronous logging, forced on unsuspecting users, is pretty bad idea and make bets when CONFIG_LOG_IMMEDIATE will become the default behavior again.
-- Best Regards, Paul Linaro.org | Open source software for ARM SoCs Follow Linaro: http://www.facebook.com/pages/Linaro http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog
|
|
Re: Logging with a string via %s
Marc Herbert
On 17 May 2019, at 07:24, Boie, Andrew P <andrew.p.boie@intel.com> wrote: Such a "sharp tool" should at least not look exactly like the slow but safe version used absolutely everywhere else. http://www.catb.org/~esr/writings/taouu/html/ch01s03.html#rule-surprise On the same "least astonishment" principle, I think most developers expect degraded performance when logging.
|
|
Re: Logging with a string via %s
lairdjm
Hi, I think what confused me is that I was reading about the ‘improved logging’ from this guide: https://foundries.io/insights/2018/08/14/zephyr-logging-part-2/ which doesn’t mention anything about it, I was changing old code from printf() to LOG_x() and that’s when the issue arose. Thanks, Jamie
THIS MESSAGE, ANY ATTACHMENT(S), AND THE INFORMATION CONTAINED HEREIN MAY BE PROPRIETARY TO LAIRD CONNECTIVITY, INC. AND/OR ANOTHER PARTY, AND MAY FURTHER BE INTENDED TO BE KEPT CONFIDENTIAL. IF YOU ARE NOT THE INTENDED RECIPIENT, PLEASE DELETE THE EMAIL AND ANY ATTACHMENTS, AND IMMEDIATELY NOTIFY THE SENDER BY RETURN EMAIL. THIS MESSAGE AND ITS CONTENTS ARE THE PROPERTY OF LAIRD CONNECTIVITY, INC. AND MAY NOT BE REPRODUCED OR USED WITHOUT THE EXPRESS WRITTEN CONSENT OF LAIRD CONNECTIVITY, INC.
|
|
Re: Logging with a string via %s
Boie, Andrew P
For an operating system that aims to support various functional safety certifications, asynchronous rendering of %s is a terrible idea.
I think %s capability should be dropped from the logger’s format string processing and a separate API added specifically to log a C string, which makes an immediate copy.
Andrew
From: devel@... [mailto:devel@...]
On Behalf Of pawel.dunaj@...
Sent: Friday, May 17, 2019 1:16 AM To: devel@... Subject: Re: [Zephyr-devel] Logging with a string via %s
Hi,
|
|
Re: Logging with a string via %s
pawel.dunaj@...
Hi,
To optimize time of log processing message construction is deferred. For this reason you cannot use arrays that will not live long enough for logger thread to see them. In other words you can always use static arrays (like you do when calling `LOG_xyz("%s", "testme")`) but you must never pass anything from the stack (like in your example). You can enable `CONFIG_LOG_IMMEDIATE` but this will affect logging performance and does not actually tells you why the problem happened in the first place. If you need to print array declared on stack you must call ` log_strdup()` to duplicate it. Personally I am against this API and I indicated it will cause bugs as people do expect `%s` to simply output a string and they also don't read documentation for something that should just work. But at least it makes logger faster if you look from the bright side. Thanks,
|
|
Re: [NRF52840] GPIO 1 problem
pawel.dunaj@...
Hi,
NRF_GPIO_PIN_MAP will effectively change pin number from 6 to (32+6). This would be ok if you use nrfx but when you use Zephyr GPIO API you should use pin id as is. So you should write to CONFIG_GPIO_P1_DEV_NAME device using pin 6. I.e. do not use NRF_GPIO_PIN_MAP macro. Thanks,
|
|
Upcoming Event: Zephyr Project: Dev Meeting - Thu, 05/16/2019 8:00am-9:00am, Please RSVP
#cal-reminder
devel@lists.zephyrproject.org Calendar <devel@...>
Reminder: Zephyr Project: Dev Meeting When: Thursday, 16 May 2019, 8:00am to 9:00am, (GMT-07:00) America/Los Angeles Where:https://zoom.us/j/993312203 An RSVP is requested. Click here to RSVP Organizer: devel@... Description: Join Zoom Meeting
|
|
[NRF52840] GPIO 1 problem
Felipe Gabardo Gonçalves <felipe@...>
Hi, I'm trying to write a value to a GPIO port 1 on a custom board and to pca_10056 and I'm getting nothing on the output. On GPIO port 0 it works properly. My code has no secrets, I'm using blinky sample code from zephyr tag v1.13.0, and I just modified the folowing: #define LED_PORT CONFIG_GPIO_P1_DEV_NAME
#define LED NRF_GPIO_PIN_MAP(1, 6) Does anyone know where I'm doing something wrong? Thank you in advance,
|
|
Re: Logging with a string via %s
Hi,
toggle quoted messageShow quoted text
There’s also a log_strdup() API to deal with this issue. Johan
On 15 May 2019, at 14.27, Stefan Jaritz <stefan@kokoontech.com> wrote:
|
|
Re: Logging with a string via %s
lairdjm
Hi Stefan, Brilliant, didn’t think of that, all working now, thank you. Thanks, Jamie
From:
devel@... <devel@...> On Behalf Of
Stefan Jaritz via Lists.Zephyrproject.Org
Sent: 15 May 2019 12:27
To: devel@... Cc: devel@... Subject: Re: [Zephyr-devel] Logging with a string via %s
EXTERNAL EMAIL: Be careful with attachments and links. Hey Lairdjm,
Depending on you logging setup, the log of the string is done inside the " LOG_DBG" command or later. Later means, that your main function was already left and your local variables are gone = invalid. Try to add following lines at your proj.conf: This will force the logger "execute" the log function. Good luck! Stefan
On 15/05/2019 11:52, lairdjm wrote:
|
|