[GitHub] [mynewt-nimble] xumn3348 opened a new issue #633: nimBLE 和手机pair不能正常进行?
xumn3348 opened a new issue #633: nimBLE 和手机pair不能正常进行? URL: https://github.com/apache/mynewt-nimble/issues/633 ble_hs_hci_acl_tx_now, 长度比较大的包调用ble_hs_tx_data包竟然发不到ble_phy_tx这边。怀疑是fragment机制有问题。 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] xumn3348 opened a new issue #632: BLE5.1 AOA_AOD的支持什么时候可以完成?
xumn3348 opened a new issue #632: BLE5.1 AOA_AOD的支持什么时候可以完成? URL: https://github.com/apache/mynewt-nimble/issues/632 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] xumn3348 opened a new issue #631: 修改开发板BLE的服务的UUID,只能重启手机系统后才能重新更新到最新的? 重启开发板和重启APP没用。
xumn3348 opened a new issue #631: 修改开发板BLE的服务的UUID,只能重启手机系统后才能重新更新到最新的? 重启开发板和重启APP没用。 URL: https://github.com/apache/mynewt-nimble/issues/631 手机蓝牙APP连接(或重连) 外围设备后, 发的是 attr req,而不是group type req, 这样如果动态修改了属性的信息,譬如uuid, 在app上是感知不到的, 需要重启手机后,APP才会发group type req请求更新这些信息。 不清楚nordic 的闭源协议栈如何处理这个问题,但nimBLE协议栈的确对这个问题不能健壮处理。 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] wes3 opened a new pull request #630: nimble/host: Use os_mbuf_pack_chains
wes3 opened a new pull request #630: nimble/host: Use os_mbuf_pack_chains URL: https://github.com/apache/mynewt-nimble/pull/630 if BLE_L2CAP_JOIN_RX_FRAGS is set to 1, use the new API to pack mbuf chains instead of previous method. This new API will do more copying (possibly) but will better utilize memory in that it will use the entire data buffer of each mbuf in the chain. NOTE: This PR requires PR #2075 from apache-mynewt-core to be used. That PR has been merged into core but just mentioning it here so folks know to use the proper version of mynewt-core. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[mynewt-core] branch master updated: kernel/os: Add os_mbuf_pack_chains (#2075)
This is an automated email from the ASF dual-hosted git repository. wes3 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git The following commit(s) were added to refs/heads/master by this push: new c5d9068 kernel/os: Add os_mbuf_pack_chains (#2075) c5d9068 is described below commit c5d9068cd472f32f0afd89594038a188d9ddf50d Author: wes3 AuthorDate: Tue Oct 29 17:52:39 2019 -0700 kernel/os: Add os_mbuf_pack_chains (#2075) * kernel/os: Add os_mbuf_pack_chains This commit adds a new API for mbuf handling called os_mbuf_pack_chains. This API, given two mbuf chains, will concatenate them and copy data as needed so that each mbuf fully utilizes the data buffer in each mbuf. Unused mbufs are discarded. This API sacrifices speed for memory and may cause a lot of copying to occur within the mbuf chains. Test code has been written for a number of reasonable cases. * kernel/os: os_mbuf_pack_chains Fix typo in name of os_mbuf_test_pack_chains_rand. --- kernel/os/include/os/os_mbuf.h | 20 ++ kernel/os/selftest/src/mbuf_test.c | 4 +- .../src/testcases/os_mbuf_test_pack_chains.c | 371 + kernel/os/src/os_mbuf.c| 87 + 4 files changed, 481 insertions(+), 1 deletion(-) diff --git a/kernel/os/include/os/os_mbuf.h b/kernel/os/include/os/os_mbuf.h index 40dc16a..53a16c5 100644 --- a/kernel/os/include/os/os_mbuf.h +++ b/kernel/os/include/os/os_mbuf.h @@ -644,6 +644,26 @@ struct os_mbuf *os_mbuf_trim_front(struct os_mbuf *om); */ int os_mbuf_widen(struct os_mbuf *om, uint16_t off, uint16_t len); + +/** + * Creates a single chained mbuf from m1 and m2 utilizing all + * the available buffer space in all mbufs in the resulting + * chain. In other words, ensures there is no leading space in + * any mbuf in the resulting chain and trailing space only in + * the last mbuf in the chain. Mbufs from either chain may be + * freed if not needed. No mbufs are allocated. Note that mbufs + * from m2 are added to the end of m1. If m1 has a packet + * header, it is retained and length updated. If m2 has a packet + * header it is discarded. If m1 is NULL, NULL is returned and + * m2 is left untouched. + * + * @param m1 Pointer to first mbuf chain to pack + * @param m2 Pointer to second mbuf chain to pack + * + * @return struct os_mbuf* Pointer to resulting mbuf chain + */ +struct os_mbuf *os_mbuf_pack_chains(struct os_mbuf *m1, struct os_mbuf *m2); + #ifdef __cplusplus } #endif diff --git a/kernel/os/selftest/src/mbuf_test.c b/kernel/os/selftest/src/mbuf_test.c index 0a39ba4..ad5bfec 100644 --- a/kernel/os/selftest/src/mbuf_test.c +++ b/kernel/os/selftest/src/mbuf_test.c @@ -22,7 +22,7 @@ #include "testutil/testutil.h" #include "os_test_priv.h" -/* +/* * NOTE: currently, the buffer size cannot be changed as some tests are * hard-coded for this size. */ @@ -102,6 +102,7 @@ TEST_CASE_DECL(os_mbuf_test_extend) TEST_CASE_DECL(os_mbuf_test_adj) TEST_CASE_DECL(os_mbuf_test_get_pkthdr) TEST_CASE_DECL(os_mbuf_test_widen) +TEST_CASE_DECL(os_mbuf_test_pack_chains) TEST_SUITE(os_mbuf_test_suite) { @@ -113,4 +114,5 @@ TEST_SUITE(os_mbuf_test_suite) os_mbuf_test_adj(); os_mbuf_test_get_pkthdr(); os_mbuf_test_widen(); +os_mbuf_test_pack_chains(); } diff --git a/kernel/os/selftest/src/testcases/os_mbuf_test_pack_chains.c b/kernel/os/selftest/src/testcases/os_mbuf_test_pack_chains.c new file mode 100644 index 000..a684506 --- /dev/null +++ b/kernel/os/selftest/src/testcases/os_mbuf_test_pack_chains.c @@ -0,0 +1,371 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#include "os_test_priv.h" + +#if MBUF_TEST_POOL_BUF_SIZE != 256 +#error "Test pool buffer size must be 256!" +#endif + +/* This structure is used to create mbuf chains. It contains the length + of data that should be in each mbuf in the chain and the amount of + leading space in the mbuf */ +struct os_mbtpc_cd +{ +uint16_t mlen; +uint16_t leadingspace; +}; + +/* The random seed (chosen at random) */ +static unsigned long int rand_next = 1001; + +/*
[GitHub] [mynewt-core] wes3 merged pull request #2075: kernel/os: Add os_mbuf_pack_chains
wes3 merged pull request #2075: kernel/os: Add os_mbuf_pack_chains URL: https://github.com/apache/mynewt-core/pull/2075 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] wes3 commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains
wes3 commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains URL: https://github.com/apache/mynewt-core/pull/2075#discussion_r340387979 ## File path: kernel/os/selftest/src/testcases/os_mbuf_test_pack_chains.c ## @@ -0,0 +1,371 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#include "os_test_priv.h" + +#if MBUF_TEST_POOL_BUF_SIZE != 256 +#error "Test pool buffer size must be 256!" +#endif + +/* This structure is used to create mbuf chains. It contains the length + of data that should be in each mbuf in the chain and the amount of + leading space in the mbuf */ +struct os_mbtpc_cd +{ +uint16_t mlen; +uint16_t leadingspace; +}; + +/* The random seed (chosen at random) */ +static unsigned long int rand_next = 1001; + +/* Used for data integrity testing */ +static uint8_t os_mbuf_test_pack_chains_test_data[2048]; + +/** + * Calculates the total number of mbufs needed for a chain + * presuming each mbuf is filled to capacity except the last. + * NOTE: the pkthdr_len must include the os_mbuf_pkthdr struct; + * it is not automatically accounted for. + */ +uint16_t +os_mbuf_test_pack_chains_calc_total_mbufs(uint16_t len, int pkthdr_len) +{ +uint16_t total; +uint16_t rem; +uint16_t dbuflen; + +rem = len; +dbuflen = os_mbuf_pool.omp_databuf_len; + +/* Only the first mbuf should have a packet header so this is subtracted + for only one mbuf (if present) */ +total = 1; +if (len > (dbuflen - pkthdr_len)) { +rem -= (dbuflen - pkthdr_len); +while (rem > 0) { +++total; +if (rem <= dbuflen) { +break; +} +rem -= dbuflen; +} +} + +return total; +} + +struct os_mbuf * +os_mbuf_test_pack_chains_create_chain(int num_mbufs, struct os_mbtpc_cd *mdata, + uint16_t srcoff, int is_pkthdr, + uint8_t pkthdr_len) +{ +int i; +int rc; +struct os_mbuf *m; +struct os_mbuf *cur; +struct os_mbuf *tmp; +uint8_t *src; +uint16_t hdrlen; + +TEST_ASSERT_FATAL(mdata != NULL, "mdata NULL"); +TEST_ASSERT_FATAL(num_mbufs != 0, "mbufs cannot be zero"); + +if (is_pkthdr) { +m = os_mbuf_get_pkthdr(_mbuf_pool, pkthdr_len); +m->om_data += mdata[0].leadingspace; +hdrlen = sizeof(struct os_mbuf_pkthdr) + pkthdr_len; +} else { +m = os_mbuf_get(_mbuf_pool, mdata[0].leadingspace); +hdrlen = 0; +} +os_mbuf_test_misc_assert_sane(m, NULL, 0, 0, hdrlen); +TEST_ASSERT_FATAL(mdata[0].mlen != 0, "mlen cannot be zero"); + +src = os_mbuf_test_pack_chains_test_data + srcoff; +rc = os_mbuf_copyinto(m, 0, src, (int)mdata[0].mlen); +TEST_ASSERT_FATAL(rc == 0, "copyinto failed"); +src += mdata[0].mlen; + +cur = m; +for (i = 1; i < num_mbufs; ++i) { +tmp = os_mbuf_get(_mbuf_pool, mdata[i].leadingspace); +os_mbuf_test_misc_assert_sane(tmp, NULL, 0, 0, 0); +rc = os_mbuf_copyinto(tmp, 0, src, (int)mdata[i].mlen); +TEST_ASSERT_FATAL(rc == 0, "copyinto failed"); +if (is_pkthdr) { +OS_MBUF_PKTLEN(m) += mdata[i].mlen; +} +src += mdata[i].mlen; +SLIST_NEXT(cur, om_next) = tmp; +cur = tmp; +} +return m; +} + +/* + * This is here cause I dont feel like calling rand :-) + * + * Taken from the K C programming language book. Page 46. + * returns a pseudo-random integer of 0..32767. Note that + * this is compatible with the System V function rand(), not + * with the bsd function rand() that returns 0..(2**31)-1. + */ +unsigned int +os_mbuf_test_pack_chans_rand(void) Review comment: As to the API with just one mbuf passed in, well, I am not going to change it now. I think this is fine. You can use it with just a single chain (pass NULL for m2) and it does make a sort of sense when "re-assembling" things (i.e. you have an existing chain and want to add an mbuf or mbuf chain to it). This is an automated message from the Apache Git Service. To respond to
[GitHub] [mynewt-core] wes3 commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains
wes3 commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains URL: https://github.com/apache/mynewt-core/pull/2075#discussion_r340383932 ## File path: kernel/os/src/os_mbuf.c ## @@ -1036,3 +1036,90 @@ os_mbuf_widen(struct os_mbuf *om, uint16_t off, uint16_t len) return 0; } + +struct os_mbuf * +os_mbuf_pack_chains(struct os_mbuf *m1, struct os_mbuf *m2) +{ +uint16_t rem_len; +uint16_t copylen; Review comment: Yes; I am not terribly consistent. I just thought remlen looked weird whereas copylen looks nice :-) This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] wes3 commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains
wes3 commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains URL: https://github.com/apache/mynewt-core/pull/2075#discussion_r340383783 ## File path: kernel/os/selftest/src/testcases/os_mbuf_test_pack_chains.c ## @@ -0,0 +1,371 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#include "os_test_priv.h" + +#if MBUF_TEST_POOL_BUF_SIZE != 256 +#error "Test pool buffer size must be 256!" +#endif + +/* This structure is used to create mbuf chains. It contains the length + of data that should be in each mbuf in the chain and the amount of + leading space in the mbuf */ +struct os_mbtpc_cd +{ +uint16_t mlen; +uint16_t leadingspace; +}; + +/* The random seed (chosen at random) */ +static unsigned long int rand_next = 1001; + +/* Used for data integrity testing */ +static uint8_t os_mbuf_test_pack_chains_test_data[2048]; + +/** + * Calculates the total number of mbufs needed for a chain + * presuming each mbuf is filled to capacity except the last. + * NOTE: the pkthdr_len must include the os_mbuf_pkthdr struct; + * it is not automatically accounted for. + */ +uint16_t +os_mbuf_test_pack_chains_calc_total_mbufs(uint16_t len, int pkthdr_len) +{ +uint16_t total; +uint16_t rem; +uint16_t dbuflen; + +rem = len; +dbuflen = os_mbuf_pool.omp_databuf_len; + +/* Only the first mbuf should have a packet header so this is subtracted + for only one mbuf (if present) */ +total = 1; +if (len > (dbuflen - pkthdr_len)) { +rem -= (dbuflen - pkthdr_len); +while (rem > 0) { +++total; +if (rem <= dbuflen) { +break; +} +rem -= dbuflen; +} +} + +return total; +} + +struct os_mbuf * +os_mbuf_test_pack_chains_create_chain(int num_mbufs, struct os_mbtpc_cd *mdata, + uint16_t srcoff, int is_pkthdr, + uint8_t pkthdr_len) +{ +int i; +int rc; +struct os_mbuf *m; +struct os_mbuf *cur; +struct os_mbuf *tmp; +uint8_t *src; +uint16_t hdrlen; + +TEST_ASSERT_FATAL(mdata != NULL, "mdata NULL"); +TEST_ASSERT_FATAL(num_mbufs != 0, "mbufs cannot be zero"); + +if (is_pkthdr) { +m = os_mbuf_get_pkthdr(_mbuf_pool, pkthdr_len); +m->om_data += mdata[0].leadingspace; +hdrlen = sizeof(struct os_mbuf_pkthdr) + pkthdr_len; +} else { +m = os_mbuf_get(_mbuf_pool, mdata[0].leadingspace); +hdrlen = 0; +} +os_mbuf_test_misc_assert_sane(m, NULL, 0, 0, hdrlen); +TEST_ASSERT_FATAL(mdata[0].mlen != 0, "mlen cannot be zero"); + +src = os_mbuf_test_pack_chains_test_data + srcoff; +rc = os_mbuf_copyinto(m, 0, src, (int)mdata[0].mlen); +TEST_ASSERT_FATAL(rc == 0, "copyinto failed"); +src += mdata[0].mlen; + +cur = m; +for (i = 1; i < num_mbufs; ++i) { +tmp = os_mbuf_get(_mbuf_pool, mdata[i].leadingspace); +os_mbuf_test_misc_assert_sane(tmp, NULL, 0, 0, 0); +rc = os_mbuf_copyinto(tmp, 0, src, (int)mdata[i].mlen); +TEST_ASSERT_FATAL(rc == 0, "copyinto failed"); +if (is_pkthdr) { +OS_MBUF_PKTLEN(m) += mdata[i].mlen; +} +src += mdata[i].mlen; +SLIST_NEXT(cur, om_next) = tmp; +cur = tmp; +} +return m; +} + +/* + * This is here cause I dont feel like calling rand :-) + * + * Taken from the K C programming language book. Page 46. + * returns a pseudo-random integer of 0..32767. Note that + * this is compatible with the System V function rand(), not + * with the bsd function rand() that returns 0..(2**31)-1. + */ +unsigned int +os_mbuf_test_pack_chans_rand(void) Review comment: I have no good reason why I did not want to call rand() :-) I just wanted it all self-contained. I did have a reason why I used random data instead of, say, a pattern that increments by 1. I was worried that there might be some weird test patterns where the data would be the same but incorrect (if you see what I mean). I think with using random data we are pretty sure that wont be the case. Did not want to hash things or add a crc or
[GitHub] [mynewt-core] ccollins476ad commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains
ccollins476ad commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains URL: https://github.com/apache/mynewt-core/pull/2075#discussion_r340378649 ## File path: kernel/os/selftest/src/testcases/os_mbuf_test_pack_chains.c ## @@ -0,0 +1,371 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#include "os_test_priv.h" + +#if MBUF_TEST_POOL_BUF_SIZE != 256 +#error "Test pool buffer size must be 256!" +#endif + +/* This structure is used to create mbuf chains. It contains the length + of data that should be in each mbuf in the chain and the amount of + leading space in the mbuf */ +struct os_mbtpc_cd +{ +uint16_t mlen; +uint16_t leadingspace; +}; + +/* The random seed (chosen at random) */ +static unsigned long int rand_next = 1001; + +/* Used for data integrity testing */ +static uint8_t os_mbuf_test_pack_chains_test_data[2048]; + +/** + * Calculates the total number of mbufs needed for a chain + * presuming each mbuf is filled to capacity except the last. + * NOTE: the pkthdr_len must include the os_mbuf_pkthdr struct; + * it is not automatically accounted for. + */ +uint16_t +os_mbuf_test_pack_chains_calc_total_mbufs(uint16_t len, int pkthdr_len) +{ +uint16_t total; +uint16_t rem; +uint16_t dbuflen; + +rem = len; +dbuflen = os_mbuf_pool.omp_databuf_len; + +/* Only the first mbuf should have a packet header so this is subtracted + for only one mbuf (if present) */ +total = 1; +if (len > (dbuflen - pkthdr_len)) { +rem -= (dbuflen - pkthdr_len); +while (rem > 0) { +++total; +if (rem <= dbuflen) { +break; +} +rem -= dbuflen; +} +} + +return total; +} + +struct os_mbuf * +os_mbuf_test_pack_chains_create_chain(int num_mbufs, struct os_mbtpc_cd *mdata, + uint16_t srcoff, int is_pkthdr, + uint8_t pkthdr_len) +{ +int i; +int rc; +struct os_mbuf *m; +struct os_mbuf *cur; +struct os_mbuf *tmp; +uint8_t *src; +uint16_t hdrlen; + +TEST_ASSERT_FATAL(mdata != NULL, "mdata NULL"); +TEST_ASSERT_FATAL(num_mbufs != 0, "mbufs cannot be zero"); + +if (is_pkthdr) { +m = os_mbuf_get_pkthdr(_mbuf_pool, pkthdr_len); +m->om_data += mdata[0].leadingspace; +hdrlen = sizeof(struct os_mbuf_pkthdr) + pkthdr_len; +} else { +m = os_mbuf_get(_mbuf_pool, mdata[0].leadingspace); +hdrlen = 0; +} +os_mbuf_test_misc_assert_sane(m, NULL, 0, 0, hdrlen); +TEST_ASSERT_FATAL(mdata[0].mlen != 0, "mlen cannot be zero"); + +src = os_mbuf_test_pack_chains_test_data + srcoff; +rc = os_mbuf_copyinto(m, 0, src, (int)mdata[0].mlen); +TEST_ASSERT_FATAL(rc == 0, "copyinto failed"); +src += mdata[0].mlen; + +cur = m; +for (i = 1; i < num_mbufs; ++i) { +tmp = os_mbuf_get(_mbuf_pool, mdata[i].leadingspace); +os_mbuf_test_misc_assert_sane(tmp, NULL, 0, 0, 0); +rc = os_mbuf_copyinto(tmp, 0, src, (int)mdata[i].mlen); +TEST_ASSERT_FATAL(rc == 0, "copyinto failed"); +if (is_pkthdr) { +OS_MBUF_PKTLEN(m) += mdata[i].mlen; +} +src += mdata[i].mlen; +SLIST_NEXT(cur, om_next) = tmp; +cur = tmp; +} +return m; +} + +/* + * This is here cause I dont feel like calling rand :-) + * + * Taken from the K C programming language book. Page 46. + * returns a pseudo-random integer of 0..32767. Note that + * this is compatible with the System V function rand(), not + * with the bsd function rand() that returns 0..(2**31)-1. + */ +unsigned int +os_mbuf_test_pack_chans_rand(void) Review comment: There seems to be a typo here (`chans`). Out of curiosity, why don't you want to call `rand()`? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards,
[mynewt-core] branch master updated: otp_tool: return the key read using otp_read_key
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git The following commit(s) were added to refs/heads/master by this push: new 552d26c otp_tool: return the key read using otp_read_key 552d26c is described below commit 552d26cbcbadf2eefe03e2990977a2419cf4832d Author: Naveen Kaje AuthorDate: Mon Oct 28 11:02:44 2019 -0500 otp_tool: return the key read using otp_read_key Return the read key for further processing and verification. Signed-off-by: Naveen Kaje --- hw/bsp/dialog_da1469x-dk-pro/otp_tool.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/bsp/dialog_da1469x-dk-pro/otp_tool.py b/hw/bsp/dialog_da1469x-dk-pro/otp_tool.py index 34feafc..bd39981 100755 --- a/hw/bsp/dialog_da1469x-dk-pro/otp_tool.py +++ b/hw/bsp/dialog_da1469x-dk-pro/otp_tool.py @@ -151,6 +151,7 @@ def otp_read_key(index, segment, uart): else: raise SystemExit("Error reading key with status %s" % hex(response.status)) +return key @click.argument('infile') @@ -336,7 +337,7 @@ def flash_read(uart, length, outfile, offset): help='flash address offset, in hex') @click.option('-l', '--length', type=int, required=True, help='size to erase') @click.option('-u', '--uart', required=True, help='uart port') -@click.command(help='Write to flash') +@click.command(help='Erase flash') def flash_erase(uart, offset, length): try: ser = serial.Serial(port=uart, baudrate=100, timeout=60,
[GitHub] [mynewt-core] kasjer merged pull request #2072: otp_tool: return the key read using otp_read_key
kasjer merged pull request #2072: otp_tool: return the key read using otp_read_key URL: https://github.com/apache/mynewt-core/pull/2072 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] kasjer commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains
kasjer commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains URL: https://github.com/apache/mynewt-core/pull/2075#discussion_r340373238 ## File path: kernel/os/src/os_mbuf.c ## @@ -1036,3 +1036,90 @@ os_mbuf_widen(struct os_mbuf *om, uint16_t off, uint16_t len) return 0; } + +struct os_mbuf * +os_mbuf_pack_chains(struct os_mbuf *m1, struct os_mbuf *m2) +{ +uint16_t rem_len; +uint16_t copylen; +uint8_t *dptr; +struct os_mbuf *cur; +struct os_mbuf *next; + +/* If m1 is NULL, return NULL */ +if (m1 == NULL) { +return NULL; +} + +/* + * Concatenate the two chains to start. This will discard packet header in + * m2 and adjust packet length in m1 if m1 has a packet header. + */ +if (m2 != NULL) { +os_mbuf_concat(m1, m2); +} + +cur = m1; +while (1) { +/* If there is leading space in the mbuf, move data up */ +if (OS_MBUF_LEADINGSPACE(cur)) { +dptr = >om_databuf[0]; +if (OS_MBUF_IS_PKTHDR(cur)) { +dptr += cur->om_pkthdr_len; +} +memmove(dptr, cur->om_data, cur->om_len); +cur->om_data = dptr; +} + +/* Set pointer to where we will begin copying data in current mbuf */ +dptr = cur->om_data + cur->om_len; + +/* Get a pointer to the next buf we want to absorb */ +next = SLIST_NEXT(cur, om_next); + +/* + * Is there trailing space in the mbuf? If so, copy data from + * following mbufs into the current mbuf + */ +rem_len = OS_MBUF_TRAILINGSPACE(cur); +while (rem_len && next) { Review comment: in other cases length is compared to 0 and next to NULL while here is shorter version is used. Not that it matters. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] kasjer commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains
kasjer commented on a change in pull request #2075: kernel/os: Add os_mbuf_pack_chains URL: https://github.com/apache/mynewt-core/pull/2075#discussion_r340372502 ## File path: kernel/os/src/os_mbuf.c ## @@ -1036,3 +1036,90 @@ os_mbuf_widen(struct os_mbuf *om, uint16_t off, uint16_t len) return 0; } + +struct os_mbuf * +os_mbuf_pack_chains(struct os_mbuf *m1, struct os_mbuf *m2) +{ +uint16_t rem_len; +uint16_t copylen; Review comment: slight in-consequence in naming length rem_len has _ while copylen does not This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] wes3 opened a new pull request #2075: kernel/os: Add os_mbuf_pack_chains
wes3 opened a new pull request #2075: kernel/os: Add os_mbuf_pack_chains URL: https://github.com/apache/mynewt-core/pull/2075 This commit adds a new API for mbuf handling called os_mbuf_pack_chains. This API, given two mbuf chains, will concatenate them and copy data as needed so that each mbuf fully utilizes the data buffer in each mbuf. Unused mbufs are discarded. This API sacrifices speed for memory and may cause a lot of copying to occur within the mbuf chains. Test code has been written for a number of reasonable cases. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-newt] ccollins476ad merged pull request #348: Add size to raw entries in mfg manifest
ccollins476ad merged pull request #348: Add size to raw entries in mfg manifest URL: https://github.com/apache/mynewt-newt/pull/348 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[mynewt-newt] 02/02: Add size to raw entries in mfg manifest
This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git commit d703a10128a265435eab64cf6c89fbf9b6f7b10e Author: Christopher Collins AuthorDate: Tue Oct 29 10:05:01 2019 -0700 Add size to raw entries in mfg manifest The `size` field indicates the amount of flash occupied by the raw entry. --- newt/mfg/build.go | 10 ++ newt/mfg/emit.go | 3 +++ 2 files changed, 13 insertions(+) diff --git a/newt/mfg/build.go b/newt/mfg/build.go index 46e4e6a..162dd23 100644 --- a/newt/mfg/build.go +++ b/newt/mfg/build.go @@ -24,11 +24,13 @@ import ( "encoding/binary" "fmt" "io/ioutil" + "os" "path" "path/filepath" "sort" "strings" + "github.com/apache/mynewt-artifact/errors" "github.com/apache/mynewt-artifact/flash" "github.com/apache/mynewt-artifact/image" "github.com/apache/mynewt-artifact/manifest" @@ -54,6 +56,7 @@ type MfgBuildTarget struct { type MfgBuildRaw struct { Filename string Offsetint + Size int Area flash.FlashArea ExtraManifest map[string]interface{} } @@ -247,9 +250,16 @@ func newMfgBuildRaw(dr DecodedRaw, return MfgBuildRaw{}, err } + st, err := os.Stat(filename) + if err != nil { + return MfgBuildRaw{}, errors.Wrapf(err, + "failed to determine size of file \"%s\"", filename) + } + return MfgBuildRaw{ Filename: path.Clean(filename), Offset:dr.Offset, + Size: int(st.Size()), Area: area, ExtraManifest: dr.ExtraManifest, }, nil diff --git a/newt/mfg/emit.go b/newt/mfg/emit.go index 229abdf..0093665 100644 --- a/newt/mfg/emit.go +++ b/newt/mfg/emit.go @@ -63,6 +63,7 @@ type MfgEmitTarget struct { type MfgEmitRaw struct { Filename string Offsetint + Size int ExtraManifest map[string]interface{} } @@ -132,6 +133,7 @@ func newMfgEmitRaw(br MfgBuildRaw) MfgEmitRaw { return MfgEmitRaw{ Filename: br.Filename, Offset:br.Area.Offset + br.Offset, + Size: br.Size, ExtraManifest: br.ExtraManifest, } } @@ -391,6 +393,7 @@ func (me *MfgEmitter) emitManifest() ([]byte, error) { mmr := manifest.MfgManifestRaw{ Filename: strings.TrimPrefix(r.Filename, basePath+"/"), Offset: r.Offset, + Size: r.Size, BinPath: MfgRawBinPath(i), Extra:r.ExtraManifest, }
[mynewt-newt] 01/02: Use mynewt-artifact v0.0.9
This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git commit e72e88d13c8de3fb4e2cac1f5256670ec9268993 Author: Christopher Collins AuthorDate: Tue Oct 29 10:04:54 2019 -0700 Use mynewt-artifact v0.0.9 In mynewt-artifact v0.0.9, the image.GenerateSig() function returns a sec.Sig object, not a []byte. --- go.mod | 2 +- go.sum | 2 ++ newt/mfg/emit.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 153c2d0..e991a53 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( github.com/NickBall/go-aes-key-wrap v0.0.0-20170929221519-1c3aa3e4dfc5 - github.com/apache/mynewt-artifact v0.0.8 + github.com/apache/mynewt-artifact v0.0.9 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/sirupsen/logrus v1.4.2 diff --git a/go.sum b/go.sum index bc067d3..8543079 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,8 @@ github.com/apache/mynewt-artifact v0.0.6 h1:VvIdyo61Im7bvE5EGxByM6NzTaKkoqGQL3t1 github.com/apache/mynewt-artifact v0.0.6/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= github.com/apache/mynewt-artifact v0.0.8 h1:as5qSDTT5httEM1IclQM4XgoF9Wn/lTqeoJxV/PvZFw= github.com/apache/mynewt-artifact v0.0.8/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= +github.com/apache/mynewt-artifact v0.0.9 h1:Pv/nAD50Zvom6YJ5gzQG7M4jsItPA3txSV/5eelt3Cc= +github.com/apache/mynewt-artifact v0.0.9/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= diff --git a/newt/mfg/emit.go b/newt/mfg/emit.go index 5c216f0..229abdf 100644 --- a/newt/mfg/emit.go +++ b/newt/mfg/emit.go @@ -313,7 +313,7 @@ func (me *MfgEmitter) createSigs() ([]manifest.MfgManifestSig, error) { sigs = append(sigs, manifest.MfgManifestSig{ Key: hex.EncodeToString(keyHash), - Sig: hex.EncodeToString(sig), + Sig: hex.EncodeToString(sig.Data), }) }
[mynewt-newt] branch master updated (6bae1a2 -> d703a10)
This is an automated email from the ASF dual-hosted git repository. ccollins pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git. from 6bae1a2 Provide method for BSP to override image offset and padding new e72e88d Use mynewt-artifact v0.0.9 new d703a10 Add size to raw entries in mfg manifest The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: go.mod| 2 +- go.sum| 2 ++ newt/mfg/build.go | 10 ++ newt/mfg/emit.go | 5 - 4 files changed, 17 insertions(+), 2 deletions(-)
[GitHub] [mynewt-core] ccollins476ad commented on issue #2073: sys/flash_map: Keep non-overlapping default areas
ccollins476ad commented on issue #2073: sys/flash_map: Keep non-overlapping default areas URL: https://github.com/apache/mynewt-core/pull/2073#issuecomment-547608482 Thank you for the review @kasjer and @vrahane! This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[mynewt-core] 02/03: sys/flash_map: Keep non-overlapping default areas
This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git commit db942599ee19d3a31bc07e80db496bb109531f7c Author: Christopher Collins AuthorDate: Mon Oct 28 12:37:06 2019 -0700 sys/flash_map: Keep non-overlapping default areas Prior to this commit, a device with a flash map in its manufacturing meta region (MMR) would completely ignore the default flash map hardcoded in a firmware image. The rationale was that changes to the default flash map should not cause devices in the field to lose data present in the affected flash areas. This is reasonable, but there is one issue - if we add new flash areas to unused portions of flash, devices in the field will not be able to use them since they would not be present in the devices' flash maps. This commit allows a device to use new flash areas hardcoded in the image. The device will incorporate such a flash area into its flash map if it meets both of these criteria: 1. The area has a unique ID 2. The area does not overlap with any other flash areas in the MMR flash map. The first criterion means that if a firmware image rearranges or resizes some existing flash areas, these changes will *not* be incorporated into the device's flash map. These areas are not new, they are just modified, so their IDs are already present in the device's MMR flash map. The second criterion means that the device will only incorporate a new flash area into its flash map if the area resides entirely in unused flash. If the area overlaps any other areas, it is ignored. --- sys/flash_map/include/flash_map/flash_map.h | 10 +++ sys/flash_map/pkg.yml | 1 + sys/flash_map/src/flash_map.c | 101 +++- 3 files changed, 109 insertions(+), 3 deletions(-) diff --git a/sys/flash_map/include/flash_map/flash_map.h b/sys/flash_map/include/flash_map/flash_map.h index 217cf53..131bc30 100644 --- a/sys/flash_map/include/flash_map/flash_map.h +++ b/sys/flash_map/include/flash_map/flash_map.h @@ -44,6 +44,8 @@ extern "C" { #include #include +#include "syscfg/syscfg.h" + struct flash_area { uint8_t fa_id; uint8_t fa_device_id; @@ -131,6 +133,14 @@ int flash_area_getnext_sector(int id, int *sec_id, struct flash_area *ret); int flash_area_id_from_image_slot(int slot); int flash_area_id_to_image_slot(int area_id); +#if MYNEWT_VAL(SELFTEST) +/** + * Adds areas from the hardcoded flash map that aren't present in, and don't + * overlap with, the manufacturing flash map. Only exposed to unit tests. + */ +void flash_map_add_new_dflt_areas_extern(void); +#endif + #ifdef __cplusplus } #endif diff --git a/sys/flash_map/pkg.yml b/sys/flash_map/pkg.yml index 686f2c7..2482833 100644 --- a/sys/flash_map/pkg.yml +++ b/sys/flash_map/pkg.yml @@ -28,6 +28,7 @@ pkg.keywords: pkg.deps: - "@apache-mynewt-core/sys/defs" - "@apache-mynewt-core/sys/mfg" +- "@apache-mynewt-core/sys/log/modlog" pkg.init: flash_map_init: 'MYNEWT_VAL(FLASH_MAP_SYSINIT_STAGE)' diff --git a/sys/flash_map/src/flash_map.c b/sys/flash_map/src/flash_map.c index b1b2f99..6d3dcca 100644 --- a/sys/flash_map/src/flash_map.c +++ b/sys/flash_map/src/flash_map.c @@ -406,6 +406,84 @@ flash_map_read_mfg(int max_areas, } } +/** + * Determines if the specified flash area overlaps any areas in the flash map. + * + * @param area1 The flash area to compare against the flash + * map. + * + * @return True if there is an overlap; false otherwise. + */ +static bool +flash_map_area_overlaps(const struct flash_area *area1) +{ +const struct flash_area *area2; +uint32_t end1; +uint32_t end2; +int i; + +for (i = 0; i < flash_map_entries; i++) { +area2 = _map[i]; + +if (area1->fa_device_id == area2->fa_device_id) { +end1 = area1->fa_off + area1->fa_size; +end2 = area2->fa_off + area2->fa_size; + +if (end1 > area2->fa_off && area1->fa_off < end2) { +return true; +} +} +} + +return false; +} + +/** + * Adds areas from the hardcoded flash map that aren't present in, and don't + * overlap with, the manufacturing flash map. + */ +static void +flash_map_add_new_dflt_areas(void) +{ +static const int num_dflt_entries = +sizeof sysflash_map_dflt / sizeof sysflash_map_dflt[0]; + +const struct flash_area *dflt_area; +struct flash_area *dst_area; +int i; + +for (i = 0; i < num_dflt_entries; i++) { +dflt_area = _map_dflt[i]; + +/* If there is already a manufacturing area with this ID, discard the + * default area. + */ +if (flash_area_find_idx(dflt_area->fa_id) == -1) { +
[mynewt-core] 01/03: sys/flash_map: Add flash_area_find_idx() function
This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git commit 80970ae5a0e24ced90b89111c621a907e4b88eea Author: Christopher Collins AuthorDate: Mon Oct 28 12:34:38 2019 -0700 sys/flash_map: Add flash_area_find_idx() function This is an internal utility function that will simplify an upcoming feature (inclusion of non-overlapping default flash areas). --- sys/flash_map/src/flash_map.c | 34 +- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/sys/flash_map/src/flash_map.c b/sys/flash_map/src/flash_map.c index 88c11e5..b1b2f99 100644 --- a/sys/flash_map/src/flash_map.c +++ b/sys/flash_map/src/flash_map.c @@ -31,25 +31,41 @@ const struct flash_area *flash_map; int flash_map_entries; -int -flash_area_open(uint8_t id, const struct flash_area **fap) +static int +flash_area_find_idx(uint8_t id) { -const struct flash_area *area; int i; if (flash_map == NULL) { -return SYS_EACCES; +return -1; } for (i = 0; i < flash_map_entries; i++) { -area = flash_map + i; -if (area->fa_id == id) { -*fap = area; -return 0; +if (flash_map[i].fa_id == id) { +return i; } } -return SYS_ENOENT; +return -1; +} + +int +flash_area_open(uint8_t id, const struct flash_area **fap) +{ +int idx; + +if (flash_map == NULL) { +return SYS_EACCES; +} + +idx = flash_area_find_idx(id); +if (idx == -1) { +return SYS_ENOENT; +} + +*fap = _map[idx]; + +return 0; } int
[mynewt-core] branch master updated (e2b3ca8 -> d595640)
This is an automated email from the ASF dual-hosted git repository. ccollins pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git. from e2b3ca8 da1469x_charger: Fix deps to included modules new 80970ae sys/flash_map: Add flash_area_find_idx() function new db94259 sys/flash_map: Keep non-overlapping default areas new d595640 sys/flash_map: selftests for dflt flash areas The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: sys/flash_map/include/flash_map/flash_map.h| 10 ++ sys/flash_map/pkg.yml | 1 + sys/flash_map/selftest/src/flash_map_test.c| 2 + .../src/testcases/flash_map_test_case_new_areas.c | 187 + sys/flash_map/src/flash_map.c | 135 +-- 5 files changed, 323 insertions(+), 12 deletions(-) create mode 100644 sys/flash_map/selftest/src/testcases/flash_map_test_case_new_areas.c
[GitHub] [mynewt-core] ccollins476ad merged pull request #2073: sys/flash_map: Keep non-overlapping default areas
ccollins476ad merged pull request #2073: sys/flash_map: Keep non-overlapping default areas URL: https://github.com/apache/mynewt-core/pull/2073 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[mynewt-core] 03/03: sys/flash_map: selftests for dflt flash areas
This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git commit d59564091d141bda7761e871bf50a0dc48670b7a Author: Christopher Collins AuthorDate: Mon Oct 28 12:37:00 2019 -0700 sys/flash_map: selftests for dflt flash areas Add some self tests for the recent "Include areas from default flash map" feature. --- sys/flash_map/selftest/src/flash_map_test.c| 2 + .../src/testcases/flash_map_test_case_new_areas.c | 187 + 2 files changed, 189 insertions(+) diff --git a/sys/flash_map/selftest/src/flash_map_test.c b/sys/flash_map/selftest/src/flash_map_test.c index e1ad72f..1961a92 100644 --- a/sys/flash_map/selftest/src/flash_map_test.c +++ b/sys/flash_map/selftest/src/flash_map_test.c @@ -37,12 +37,14 @@ struct flash_area *fa_sectors; TEST_CASE_DECL(flash_map_test_case_1) TEST_CASE_DECL(flash_map_test_case_2) TEST_CASE_DECL(flash_map_test_case_3) +TEST_CASE_DECL(flash_map_test_case_new_areas) TEST_SUITE(flash_map_test_suite) { flash_map_test_case_1(); flash_map_test_case_2(); flash_map_test_case_3(); +flash_map_test_case_new_areas(); } int diff --git a/sys/flash_map/selftest/src/testcases/flash_map_test_case_new_areas.c b/sys/flash_map/selftest/src/testcases/flash_map_test_case_new_areas.c new file mode 100644 index 000..5a1f900 --- /dev/null +++ b/sys/flash_map/selftest/src/testcases/flash_map_test_case_new_areas.c @@ -0,0 +1,187 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "flash_map_test.h" + +static struct flash_area scratch_flash_map[100]; + +static int +flash_area_cmp(const struct flash_area *fa, const struct flash_area *fb) +{ +int64_t diff; + +diff = fb->fa_id - fa->fa_id; +if (diff != 0) { +return diff; +} + +diff = fb->fa_device_id - fa->fa_device_id; +if (diff != 0) { +return diff; +} + +diff = fb->fa_off - fa->fa_off; +if (diff != 0) { +return diff; +} + +diff = fb->fa_size - fa->fa_size; +if (diff != 0) { +return diff; +} + +return 0; +} + +static int +flash_map_cmp(const struct flash_area *fma, int fma_size, + const struct flash_area *fmb, int fmb_size) +{ +const struct flash_area *fa; +const struct flash_area *fb; +bool found; +int diff; +int ai; +int bi; + +diff = fmb_size - fma_size; +if (diff != 0) { +return diff; +} + +for (ai = 0; ai < fma_size; ai++) { +fa = [ai]; + +found = false; +for (bi = 0; bi < fmb_size; bi++) { +fb = [bi]; + +if (fa->fa_id == fb->fa_id) { +diff = flash_area_cmp(fa, fb); +if (diff != 0) { +return diff; +} + +found = true; +break; +} +} + +if (!found) { +return 1; +} +} + +return 0; +} + +TEST_CASE_SELF(flash_map_test_case_new_areas) +{ +const int sysflash_map_dflt_sz = +sizeof sysflash_map_dflt / sizeof sysflash_map_dflt[0]; + +bool found; +int scratch_num_areas; +int rc; +int i; + +/*** No new areas. */ + +flash_map = scratch_flash_map; +memcpy(scratch_flash_map, sysflash_map_dflt, sizeof sysflash_map_dflt); +flash_map_entries = sysflash_map_dflt_sz; + +flash_map_add_new_dflt_areas_extern(); +rc = flash_map_cmp(flash_map, flash_map_entries, + sysflash_map_dflt, sysflash_map_dflt_sz); +TEST_ASSERT(rc == 0); + +/*** All new areas. */ + +flash_map = scratch_flash_map; +flash_map_entries = 0; + +flash_map_add_new_dflt_areas_extern(); +rc = flash_map_cmp(flash_map, flash_map_entries, + sysflash_map_dflt, sysflash_map_dflt_sz); +TEST_ASSERT(rc == 0); + +/*** One new area sandwiched between existing areas. */ + +memcpy(scratch_flash_map, sysflash_map_dflt, sizeof sysflash_map_dflt); + +/* Remove image slot 1 from flash map. */ +found = false; +for (i = 0; i < sysflash_map_dflt_sz - 1; i++) { +
[GitHub] [mynewt-newt] ccollins476ad opened a new pull request #348: Add size to raw entries in mfg manifest
ccollins476ad opened a new pull request #348: Add size to raw entries in mfg manifest URL: https://github.com/apache/mynewt-newt/pull/348 The `size` field indicates the amount of flash occupied by the raw entry. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] andrzej-kaczmarek commented on issue #2040: Build failure due to implicit declaration of 'static_assert'
andrzej-kaczmarek commented on issue #2040: Build failure due to implicit declaration of 'static_assert' URL: https://github.com/apache/mynewt-core/issues/2040#issuecomment-547327313 imo we should change `static_assert` (C++ symbol) to `_Static_assert` (C11 symbol) - we anyway have `#define` to redefine the former to the latter. not sure if this will be supported by old GCC, but works fine in 7.x+. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[mynewt-core] branch master updated: da1469x_charger: Fix deps to included modules
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git The following commit(s) were added to refs/heads/master by this push: new e2b3ca8 da1469x_charger: Fix deps to included modules e2b3ca8 is described below commit e2b3ca84fabcc04ed3ceefc49a1b3daec9a710d1 Author: Jerzy Kasenberg AuthorDate: Tue Oct 22 15:36:19 2019 +0200 da1469x_charger: Fix deps to included modules Charger shell code conditionally includes two modules. Those two were not added to dependency list. Missing modules were: util/parse hw/drivers/adc/gpadc_da1469x hw/drivers/adc/sdadc_da1469x --- hw/drivers/chg_ctrl/da1469x_charger/pkg.yml | 6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/drivers/chg_ctrl/da1469x_charger/pkg.yml b/hw/drivers/chg_ctrl/da1469x_charger/pkg.yml index 098bfad..7b908ea 100644 --- a/hw/drivers/chg_ctrl/da1469x_charger/pkg.yml +++ b/hw/drivers/chg_ctrl/da1469x_charger/pkg.yml @@ -26,5 +26,11 @@ pkg.keywords: pkg.deps: - "@apache-mynewt-core/kernel/os" - "@apache-mynewt-core/hw/hal" +pkg.deps.DA1469X_CHARGER_CLI: +- "@apache-mynewt-core/util/parse" +pkg.deps.GPADC_BATTERY: +- '@apache-mynewt-core/hw/drivers/adc/gpadc_da1469x' +pkg.deps.SDADC_BATTERY: +- '@apache-mynewt-core/hw/drivers/adc/sdadc_da1469x' pkg.deps.DA1469X_CHARGER_USE_CHARGE_CONTROL: - '@apache-mynewt-core/hw/charge-control'
[GitHub] [mynewt-core] deepthits commented on issue #2040: Build failure due to implicit declaration of 'static_assert'
deepthits commented on issue #2040: Build failure due to implicit declaration of 'static_assert' URL: https://github.com/apache/mynewt-core/issues/2040#issuecomment-547300540 What is the solution for this issue? Even I am facing this This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services