(mynewt-core) branch master updated: fs/fcb: Coverity fix
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 24fc28100 fs/fcb: Coverity fix 24fc28100 is described below commit 24fc2810053f3b0006098853dc8b5a1cab4f062d Author: Jerzy Kasenberg AuthorDate: Wed Sep 11 12:17:15 2024 +0200 fs/fcb: Coverity fix There was no real problem with the code 356 loc1.fe_area = fcb_get_prev_area(fcb, loc->fe_area); >>> CID 418283: Code maintainability issues (UNUSED_VALUE) >>> Assigning value "0UL" to "loc1.fe_elem_off" here, but that stored value is overwritten before it can be used. 357 loc1.fe_elem_off = 0; This should satisfy coverity Signed-off-by: Jerzy Kasenberg --- fs/fcb/src/fcb_getnext.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/fcb/src/fcb_getnext.c b/fs/fcb/src/fcb_getnext.c index 6c9d17c63..196a9c457 100644 --- a/fs/fcb/src/fcb_getnext.c +++ b/fs/fcb/src/fcb_getnext.c @@ -347,15 +347,13 @@ fcb_step(struct fcb *fcb, struct fcb_entry *loc, int previous_error) loc1.fe_data_len = 0; /* Begin of sector ? */ -if (loc->fe_elem_off == first_entry_offset) { +if (loc->fe_elem_off == first_entry_offset || target_ix < 0) { /* Oldest sector, nowhere to go */ if (fcb->f_oldest == loc->fe_area) { rc = FCB_ERR_NOVAR; } else { /* Switch to previous sector and find last entry */ loc1.fe_area = fcb_get_prev_area(fcb, loc->fe_area); -loc1.fe_elem_off = 0; -loc1.fe_elem_ix = 0; } } if (rc != FCB_ERR_NOVAR) { @@ -418,14 +416,14 @@ fcb_step(struct fcb *fcb, struct fcb_entry *loc, int previous_error) } else { if (loc->fe_area == NULL) { loc->fe_area = fcb->f_oldest; -loc->fe_elem_off = fcb_start_offset(fcb); +loc->fe_elem_off = first_entry_offset; loc->fe_elem_ix = 0; loc->fe_data_len = 0; } else if (previous_error == FCB_ERR_NOVAR) { /* If there are more sectors, move to next one */ if (loc->fe_area != fcb->f_active.fe_area) { loc->fe_area = fcb_getnext_area(fcb, loc->fe_area); -loc->fe_elem_off = fcb_start_offset(fcb); +loc->fe_elem_off = first_entry_offset; loc->fe_elem_ix = 0; loc->fe_data_len = 0; } else { @@ -433,7 +431,7 @@ fcb_step(struct fcb *fcb, struct fcb_entry *loc, int previous_error) rc = FCB_ERR_NOVAR; } } else if (loc->fe_elem_off == 0) { -loc->fe_elem_off = fcb_start_offset(fcb); +loc->fe_elem_off = first_entry_offset; loc->fe_elem_ix = 0; loc->fe_data_len = 0; } else {
(mynewt-core) branch master updated (6a86c2b6b -> f3bd5749b)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 6a86c2b6b tinyusb: Add support for LPC55xx devices new 0645b3dee sys/log: Add option to limit number of printed logs new c63619e87 fs/fcb: Add support for backward walk new 13df1677b fs/fcb: Add fcb_write function new 1063e8201 sys/log: Add support for walking back in log new ab3f5e376 fs/fcb: Fix fcb_walk local variable initialization new f3bd5749b fs/fcb: Clean fcb_append inconsistency The 6 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: fs/fcb/include/fcb/fcb.h | 80 fs/fcb/src/fcb.c | 3 + fs/fcb/src/fcb_append.c| 30 +- fs/fcb/src/fcb_getnext.c | 480 +++-- fs/fcb/src/fcb_priv.h | 13 + fs/fcb/src/fcb_walk.c | 31 +- .../lcd_itf/itf_lcd_da1469x => fs/fcb}/syscfg.yml | 16 +- sys/log/full/include/log/log.h | 2 + sys/log/full/src/log_fcb.c | 35 +- sys/log/full/src/log_shell.c | 44 +- 10 files changed, 656 insertions(+), 78 deletions(-) copy {hw/drivers/display/lcd_itf/itf_lcd_da1469x => fs/fcb}/syscfg.yml (80%)
(mynewt-core) 05/06: fs/fcb: Fix fcb_walk local variable initialization
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 commit ab3f5e376afc0edac49d9bf7d00f9c0a6158b7a3 Author: Jerzy Kasenberg AuthorDate: Wed Aug 7 13:25:35 2024 +0200 fs/fcb: Fix fcb_walk local variable initialization fcb_walk initialize only certain fields of fcb_entry before walking. This could lead to unpredictable behaviour if additional fields were utilized. Signed-off-by: Jerzy Kasenberg --- fs/fcb/src/fcb_walk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/fcb/src/fcb_walk.c b/fs/fcb/src/fcb_walk.c index b3e61fde6..9daf55f23 100644 --- a/fs/fcb/src/fcb_walk.c +++ b/fs/fcb/src/fcb_walk.c @@ -27,11 +27,10 @@ int fcb_walk(struct fcb *fcb, struct flash_area *fap, fcb_walk_cb cb, void *cb_arg) { -struct fcb_entry loc; +struct fcb_entry loc = {0}; int rc; loc.fe_area = fap; -loc.fe_elem_off = 0; rc = os_mutex_pend(&fcb->f_mtx, OS_WAIT_FOREVER); if (rc && rc != OS_NOT_STARTED) {
(mynewt-core) 06/06: fs/fcb: Clean fcb_append inconsistency
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 commit f3bd5749bb3cbd5af04ad6149709b5d580f41b35 Author: Jerzy Kasenberg AuthorDate: Wed Aug 7 13:57:17 2024 +0200 fs/fcb: Clean fcb_append inconsistency Variable cnt and len were reused leading to some inconsistencies. 1. cnt was number of bytes needed to store len but it was later changed to store number of bytes in flash to store len (that can be larger when flash alignment restrictions are applied). Later it was used to actually write len filed to flash, however if alignment was not 1 or 2 some random data would be written to flash (starting from tmp_str but extending to other values on stack). No there is separate variable to keep track how many bytes in flash are needed. 2. calculating whether entry will fit in current sector, fcb_disk_area was not aligned correctly that could lead to problems for flash that has alignment that is higher then 8. 3. append_loc was partially updated but fe_data_len was never filled leaving structure in inconsistent state. 4. active->fe_data_len could have incorrect value (rounded up to alignment) This was small inconsistency that probably would not result in any problem Signed-off-by: Jerzy Kasenberg --- fs/fcb/src/fcb_append.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/fcb/src/fcb_append.c b/fs/fcb/src/fcb_append.c index 444fda25b..ad804c0dc 100644 --- a/fs/fcb/src/fcb_append.c +++ b/fs/fcb/src/fcb_append.c @@ -86,24 +86,26 @@ fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *append_loc) struct flash_area *fa; uint8_t tmp_str[2]; int cnt; +int len_bytes_in_flash; +int entry_len_in_flash; int rc; cnt = fcb_put_len(tmp_str, len); if (cnt < 0) { return cnt; } -cnt = fcb_len_in_flash(fcb, cnt); -len = fcb_len_in_flash(fcb, len) + fcb_len_in_flash(fcb, FCB_CRC_SZ); +len_bytes_in_flash = fcb_len_in_flash(fcb, cnt); +entry_len_in_flash = fcb_entry_total_len(fcb, len); rc = os_mutex_pend(&fcb->f_mtx, OS_WAIT_FOREVER); if (rc && rc != OS_NOT_STARTED) { return FCB_ERR_ARGS; } active = &fcb->f_active; -if (active->fe_elem_off + len + cnt > active->fe_area->fa_size) { +if (active->fe_elem_off + entry_len_in_flash > active->fe_area->fa_size) { fa = fcb_new_area(fcb, fcb->f_scratch_cnt); if (!fa || (fa->fa_size < -sizeof(struct fcb_disk_area) + len + cnt)) { +fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)) + entry_len_in_flash)) { rc = FCB_ERR_NOSPACE; goto err; } @@ -124,9 +126,10 @@ fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *append_loc) } append_loc->fe_area = active->fe_area; append_loc->fe_elem_off = active->fe_elem_off; -append_loc->fe_data_off = active->fe_elem_off + cnt; +append_loc->fe_data_off = active->fe_elem_off + len_bytes_in_flash; +append_loc->fe_data_len = len; -active->fe_elem_off = append_loc->fe_data_off + len; +active->fe_elem_off = append_loc->fe_elem_off + entry_len_in_flash; active->fe_data_off = append_loc->fe_data_off; active->fe_data_len = len;
(mynewt-core) 04/06: sys/log: Add support for walking back in log
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 commit 1063e8201b1b89c6ee19945e9479055957b421be Author: Jerzy Kasenberg AuthorDate: Mon Aug 5 15:23:08 2024 +0200 sys/log: Add support for walking back in log This adds field to log_offset that allows to specify log walk back direction. For now only log_fcb/fcb use implement walking back. Signed-off-by: Jerzy Kasenberg --- sys/log/full/include/log/log.h | 2 ++ sys/log/full/src/log_fcb.c | 35 +-- sys/log/full/src/log_shell.c | 12 +++- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/sys/log/full/include/log/log.h b/sys/log/full/include/log/log.h index 7e874ceb0..d04a191eb 100644 --- a/sys/log/full/include/log/log.h +++ b/sys/log/full/include/log/log.h @@ -60,6 +60,8 @@ struct log_offset { /* Specific to walk / read function. */ void *lo_arg; + +bool lo_walk_backward; }; #if MYNEWT_VAL(LOG_STORAGE_INFO) diff --git a/sys/log/full/src/log_fcb.c b/sys/log/full/src/log_fcb.c index 82bd1a415..5ed640820 100644 --- a/sys/log/full/src/log_fcb.c +++ b/sys/log/full/src/log_fcb.c @@ -135,6 +135,9 @@ log_fcb_find_gte(struct log *log, struct log_offset *log_offset, /* Attempt to read the first entry. If this fails, the FCB is empty. */ memset(out_entry, 0, sizeof *out_entry); +if (log_offset->lo_ts < 0) { +out_entry->fe_step_back = true; +} rc = fcb_getnext(fcb, out_entry); if (rc == FCB_ERR_NOVAR) { return SYS_ENOENT; @@ -146,7 +149,7 @@ log_fcb_find_gte(struct log *log, struct log_offset *log_offset, * if timestamp for request is < 0, return last log entry */ if (log_offset->lo_ts < 0) { -*out_entry = fcb->f_active; +out_entry->fe_step_back = false; return 0; } @@ -348,7 +351,7 @@ log_fcb_append_body(struct log *log, const struct log_entry_hdr *hdr, } memcpy(buf + hdr_len, u8p, hdr_alignment); -rc = flash_area_write(loc.fe_area, loc.fe_data_off, buf, chunk_sz); +rc = fcb_write(fcb, &loc, buf, chunk_sz); if (rc != 0) { return rc; } @@ -359,8 +362,7 @@ log_fcb_append_body(struct log *log, const struct log_entry_hdr *hdr, body_len -= hdr_alignment; if (body_len > 0) { -rc = flash_area_write(loc.fe_area, loc.fe_data_off + chunk_sz, u8p, - body_len); +rc = fcb_write(fcb, &loc, u8p, body_len); if (rc != 0) { return rc; } @@ -578,6 +580,7 @@ log_fcb_walk_impl(struct log *log, log_walk_func_t walk_func, struct fcb_entry loc; struct flash_area *fap; int rc; +struct fcb_entry_cache cache; fcb_log = log->l_arg; fcb = &fcb_log->fl_fcb; @@ -596,6 +599,14 @@ log_fcb_walk_impl(struct log *log, log_walk_func_t walk_func, } fap = loc.fe_area; +if (log_offset->lo_walk_backward) { +loc.fe_step_back = true; +if (MYNEWT_VAL(FCB_BIDIRECTIONAL_CACHE)) { +fcb_cache_init(fcb, &cache, 50); +loc.fe_cache = &cache; +} +} + #if MYNEWT_VAL(LOG_FCB_BOOKMARKS) /* If a minimum index was specified (i.e., we are not just retrieving the * last entry), add a bookmark pointing to this walk's start location. @@ -605,24 +616,28 @@ log_fcb_walk_impl(struct log *log, log_walk_func_t walk_func, } #endif +rc = 0; do { if (area) { if (fap != loc.fe_area) { -return 0; +break; } } rc = walk_func(log, log_offset, &loc, loc.fe_data_len); if (rc != 0) { -if (rc < 0) { -return rc; -} else { -return 0; +if (rc > 0) { +rc = 0; } +break; } } while (fcb_getnext(fcb, &loc) == 0); -return 0; +if (log_offset->lo_walk_backward && MYNEWT_VAL(FCB_BIDIRECTIONAL_CACHE)) { +fcb_cache_free(fcb, &cache); +} + +return rc; } static int diff --git a/sys/log/full/src/log_shell.c b/sys/log/full/src/log_shell.c index e252d33f8..342fb202b 100644 --- a/sys/log/full/src/log_shell.c +++ b/sys/log/full/src/log_shell.c @@ -156,6 +156,7 @@ shell_log_dump_cmd(int argc, char **argv) bool stream; bool partial_match = false; bool clear_log; +bool reverse = false; bool dump_logs = true; struct walk_arg arg = {}; int i; @@ -193,6 +194,10 @@ shell_log_dump_cmd(int argc, char **argv) dump_logs = false; continue; } +if (0 == strcmp(argv[i], "-r")) { +reverse = true; +continue; +} /* th
(mynewt-core) 03/06: fs/fcb: Add fcb_write function
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 commit 13df1677b04c2781724877820fb2ede8002503a0 Author: Jerzy Kasenberg AuthorDate: Wed Aug 7 13:39:57 2024 +0200 fs/fcb: Add fcb_write function Previously fcb sequence to write FCB entry was: fcb_append(fcb, len, loc) flash_area_write(fa,...) fcb_finish(fcb, loc) This adds function fcb_write() that should be used instead of direct call to flash_area_write to make it more consistent. Signed-off-by: Jerzy Kasenberg --- fs/fcb/include/fcb/fcb.h | 15 +++ fs/fcb/src/fcb_append.c | 13 + 2 files changed, 28 insertions(+) diff --git a/fs/fcb/include/fcb/fcb.h b/fs/fcb/include/fcb/fcb.h index d382521fe..7f97b9ee1 100644 --- a/fs/fcb/include/fcb/fcb.h +++ b/fs/fcb/include/fcb/fcb.h @@ -141,6 +141,21 @@ int fcb_init(struct fcb *fcb); int fcb_append(struct fcb *, uint16_t len, struct fcb_entry *loc); int fcb_append_finish(struct fcb *, struct fcb_entry *append_loc); +/** + * Write to flash user data. + * + * Function should be called after fcb_append is called and before fcb_finish + * This is wrapper for flash_area_write() function and uses loc for starting + * location. loc is modified and can be used for subsequent writes. + * + * @param fcb - fcb to write entry to + * @param loc - location of the entry + * @param buf - data to write + * @param len - number of bytes to write to fcb + * @return 0 on success, non-zero on failure + */ +int fcb_write(struct fcb *fcb, struct fcb_entry *loc, const uint8_t *buf, size_t len); + /** * Walk over all entries in FCB. * cb gets called for every entry. If cb wants to stop the walk, it should diff --git a/fs/fcb/src/fcb_append.c b/fs/fcb/src/fcb_append.c index b23f43a60..444fda25b 100644 --- a/fs/fcb/src/fcb_append.c +++ b/fs/fcb/src/fcb_append.c @@ -66,6 +66,19 @@ fcb_append_to_scratch(struct fcb *fcb) return FCB_OK; } +int +fcb_write(struct fcb *fcb, struct fcb_entry *loc, const uint8_t *buf, size_t len) +{ +int rc; + +rc = flash_area_write(loc->fe_area, loc->fe_data_off, buf, len); +if (rc == 0) { +loc->fe_data_off += len; +} + +return rc; +} + int fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *append_loc) {
(mynewt-core) 01/06: sys/log: Add option to limit number of printed logs
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 commit 0645b3deec84efe146bf0c1227f7ec4cc7f5da53 Author: Jerzy Kasenberg AuthorDate: Mon Aug 5 14:36:12 2024 +0200 sys/log: Add option to limit number of printed logs Option -s allows to skip number of logs from the start Usage: log [-n ] [-s ] i.e.: log -s 100 -n 10 will print at most 10 entries from each log skipping first 100 entries Signed-off-by: Jerzy Kasenberg --- sys/log/full/src/log_shell.c | 32 +++- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/sys/log/full/src/log_shell.c b/sys/log/full/src/log_shell.c index 0de60d776..e252d33f8 100644 --- a/sys/log/full/src/log_shell.c +++ b/sys/log/full/src/log_shell.c @@ -43,7 +43,11 @@ static uint32_t shell_log_count; struct walk_arg { +/* Number of entries to skip */ +uint32_t skip; +/* Number of entries to process */ uint32_t count_limit; +/* Entry number */ uint32_t count; }; @@ -56,7 +60,7 @@ shell_log_count_entry(struct log *log, struct log_offset *log_offset, shell_log_count++; if (arg) { arg->count++; -if (arg->count >= arg->count_limit) { +if ((arg->count_limit > 0) && (arg->count >= arg->count_limit)) { return 1; } } @@ -81,6 +85,14 @@ shell_log_dump_entry(struct log *log, struct log_offset *log_offset, bool read_data = ueh->ue_etype != LOG_ETYPE_CBOR; bool read_hash = ueh->ue_flags & LOG_FLAGS_IMG_HASH; +if (arg) { +arg->count++; +/* Continue walk if number of entries to skip not reached yet */ +if (arg->count <= arg->skip) { +return 0; +} +} + dlen = min(len, 128); if (read_data) { @@ -125,8 +137,7 @@ shell_log_dump_entry(struct log *log, struct log_offset *log_offset, console_write("\n", 1); if (arg) { -arg->count++; -if (arg->count >= arg->count_limit) { +if ((arg->count_limit > 0) && (arg->count - arg->skip >= arg->count_limit)) { return 1; } } @@ -137,7 +148,7 @@ int shell_log_dump_cmd(int argc, char **argv) { struct log *log; -struct log_offset log_offset; +struct log_offset log_offset = {}; bool list_only = false; char *log_name = NULL; uint32_t log_last_index = 0; @@ -167,6 +178,17 @@ shell_log_dump_cmd(int argc, char **argv) ++i; continue; } +if (0 == strcmp(argv[i], "-s")) { +if (i + 1 < argc) { +arg.skip = parse_ll_bounds(argv[i + 1], 0, 100, &rc); +if (rc) { +arg.skip = 0; +} +log_offset.lo_arg = &arg; +} +++i; +continue; +} if (0 == strcmp(argv[i], "-t")) { dump_logs = false; continue; @@ -221,7 +243,6 @@ shell_log_dump_cmd(int argc, char **argv) console_printf("Dumping log %s\n", log->l_name); } -log_offset.lo_arg = NULL; log_offset.lo_ts = 0; log_last_index = log_get_last_index(log); if (log_limit == 0 || log_last_index < log_limit) { @@ -232,6 +253,7 @@ shell_log_dump_cmd(int argc, char **argv) log_offset.lo_data_len = 0; if (dump_logs) { +arg.count = 0; rc = log_walk_body(log, shell_log_dump_entry, &log_offset); } else { /* Measure time for log_walk */
(mynewt-core) 02/06: fs/fcb: Add support for backward walk
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 commit c63619e8750747d9a3f6c26319cdff6ffeca1ca6 Author: Jerzy Kasenberg AuthorDate: Mon Aug 5 15:13:47 2024 +0200 fs/fcb: Add support for backward walk This extends fcb_entry structure with field that can change direction of the walk. fcb_getnext() function can now walk in backward direction. Signed-off-by: Jerzy Kasenberg --- fs/fcb/include/fcb/fcb.h | 65 +++ fs/fcb/src/fcb.c | 3 + fs/fcb/src/fcb_append.c | 2 + fs/fcb/src/fcb_getnext.c | 480 ++- fs/fcb/src/fcb_priv.h| 13 ++ fs/fcb/src/fcb_walk.c| 28 +++ fs/fcb/syscfg.yml| 28 +++ 7 files changed, 574 insertions(+), 45 deletions(-) diff --git a/fs/fcb/include/fcb/fcb.h b/fs/fcb/include/fcb/fcb.h index 4e43e7f0b..d382521fe 100644 --- a/fs/fcb/include/fcb/fcb.h +++ b/fs/fcb/include/fcb/fcb.h @@ -38,6 +38,17 @@ extern "C" { #define FCB_MAX_LEN(CHAR_MAX | CHAR_MAX << 7) /* Max length of element */ +struct fcb_entry_cache { +/* Sector number in FCB */ +uint16_t sector_ix; +/* Number of entries that cache can keep */ +uint16_t cache_size; +/* Number of entries in cache */ +uint16_t cache_count; +/* Cached data */ +uint16_t *cache_data; +}; + /** * Entry location is pointer to area (within fcb->f_sectors), and offset * within that area. @@ -47,6 +58,9 @@ struct fcb_entry { uint32_t fe_elem_off; /* start of entry */ uint32_t fe_data_off; /* start of data */ uint16_t fe_data_len; /* size of data area */ +uint16_t fe_elem_ix;/* Element index in current sector */ +struct fcb_entry_cache *fe_cache; +bool fe_step_back; /* walk backwards */ }; struct fcb { @@ -55,6 +69,8 @@ struct fcb { uint8_t f_version; /* Current version number of the data */ uint16_t f_sector_cnt; /* Number of elements in sector array */ uint16_t f_scratch_cnt;/* How many sectors should be kept empty */ +/** Number of element in active sector (f_active) */ +uint16_t f_active_sector_entry_count; struct flash_area *f_sectors; /* Array of sectors, must be contiguous */ /* Flash circular buffer internal state */ @@ -65,6 +81,41 @@ struct fcb { uint8_t f_align; /* writes to flash have to aligned to this */ }; +/** + * Init FCB cache that can be used for walking back optimization. + * + * Note: Cache can be used to speed up walk back functionality. + * Cache uses memory allocated by os_malloc/os_realloc and must + * be freed after use with fcb_cache_free(). + * + * To setup cache: + * struct fcb_entry_cache cache; + * struct fcb_entry loc = {}; + * + * loc.fe_cache = &cache; + * fcb_cache_init(fcb, &cache, 100); + * loc.fe_step_back = true; + * + * fcb_getnext(fcb, &loc); + * + * fcb_cache_free(fcb, cache); + * + * @param fcb - fcb to init cache for + * @param cache - cache to init + * @param initial_entry_count - initial number of entries in the cache + * @return 0 - on success + * SYS_ENOMEM - when cache memory can't be allocated. + */ +int fcb_cache_init(struct fcb *fcb, struct fcb_entry_cache *cache, int initial_entry_count); + +/** + * Free memory allocate by fcb cache. + * + * @param fcb - fcb associated with cache + * @param cache - cache to free + */ +void fcb_cache_free(struct fcb *fcb, struct fcb_entry_cache *cache); + /** * Error codes. */ @@ -102,6 +153,20 @@ typedef int (*fcb_walk_cb)(struct fcb_entry *loc, void *arg); int fcb_walk(struct fcb *, struct flash_area *, fcb_walk_cb cb, void *cb_arg); int fcb_getnext(struct fcb *, struct fcb_entry *loc); +#if MYNEWT_VAL_FCB_BIDIRECTIONAL +/** + * Call 'cb' for every element in flash circular buffer moving + * from the newest to oldest entries. + * + * @param fcb - fcb to walk through + * @param cb - function to call for each entry + * @param cb_arg - argument to pass to cb + * @return 0 after whole buffer was traversed + * non zero value if cb requested termination of the walk + */ +int fcb_walk_back(struct fcb *fcb, fcb_walk_cb cb, void *cb_arg); +#endif + /** * Erases the data from oldest sector. */ diff --git a/fs/fcb/src/fcb.c b/fs/fcb/src/fcb.c index 4e18fb867..967f5b460 100644 --- a/fs/fcb/src/fcb.c +++ b/fs/fcb/src/fcb.c @@ -82,6 +82,7 @@ fcb_init(struct fcb *fcb) fcb->f_active.fe_area = newest_fap; fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); fcb->f_active_id = newest; +fcb->f_active.fe_elem_ix = 0; /* Require alignment to be a power of two. Some code depends on this * assumption. @@ -98,6 +99,8 @@ fcb_init(struct fcb *fcb) break; } } +fcb->f_active_sector_entry_count = fcb->f_acti
(mynewt-core) 03/04: tinyusb: Add support for USB selection
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 commit 5e0fe70c17b824ce20e43bc79dce3be28cb1b0cd Author: Jerzy Kasenberg AuthorDate: Thu Aug 22 10:55:12 2024 +0200 tinyusb: Add support for USB selection Some MCU have more then one USB controller So far RHPORT0 was always used. Only one USB device can be configured in mynewt (host is not supported yet) Now application can decide which USB controller to use by specifying USBD_RHPORT: USB0 or USB1 Signed-off-by: Jerzy Kasenberg --- hw/usb/tinyusb/std_descriptors/include/tusb_config.h | 19 ++- hw/usb/tinyusb/std_descriptors/src/std_descriptors.c | 10 +- hw/usb/tinyusb/syscfg.yml| 7 +++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/hw/usb/tinyusb/std_descriptors/include/tusb_config.h b/hw/usb/tinyusb/std_descriptors/include/tusb_config.h index 26b25c7b0..eadf278c1 100755 --- a/hw/usb/tinyusb/std_descriptors/include/tusb_config.h +++ b/hw/usb/tinyusb/std_descriptors/include/tusb_config.h @@ -42,7 +42,24 @@ extern "C" { #error CFG_TUSB_MCU must be defined #endif -#define CFG_TUSB_RHPORT0_MODE ((OPT_MODE_DEVICE) | (CFG_TUSB_RHPORT0_SPEED)) +#if MYNEWT_VAL_CHOICE(USBD_RHPORT, USB0) +#undef CFG_TUSB_RHPORT0_MODE +#if MYNEWT_VAL(USBD_HIGH_SPEED) +#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED) +#else +#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED) +#endif +#define USBD_RHPORT_MODE CFG_TUSB_RHPORT0_MODE + +#elif MYNEWT_VAL_CHOICE(USBD_RHPORT, USB1) +#undef CFG_TUSB_RHPORT1_MODE +#if MYNEWT_VAL(USBD_HIGH_SPEED) +#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED) +#else +#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED) +#endif +#define USBD_RHPORT_MODE CFG_TUSB_RHPORT1_MODE +#endif #if MYNEWT_VAL(OS_SCHEDULING) #define CFG_TUSB_OS OPT_OS_MYNEWT diff --git a/hw/usb/tinyusb/std_descriptors/src/std_descriptors.c b/hw/usb/tinyusb/std_descriptors/src/std_descriptors.c index 6f3980ace..9981b754d 100755 --- a/hw/usb/tinyusb/std_descriptors/src/std_descriptors.c +++ b/hw/usb/tinyusb/std_descriptors/src/std_descriptors.c @@ -310,32 +310,32 @@ const uint8_t desc_configuration[] = { #if CFG_TUD_BTH TUD_BTH_DESCRIPTOR(ITF_NUM_BTH, BTH_IF_STR_IX, USBD_BTH_EVENT_EP, USBD_BTH_EVENT_EP_SIZE, USBD_BTH_EVENT_EP_INTERVAL, USBD_BTH_DATA_IN_EP, USBD_BTH_DATA_OUT_EP, - (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 512 : USBD_BTH_DATA_EP_SIZE, + (USBD_RHPORT_MODE & OPT_MODE_HIGH_SPEED) ? 512 : USBD_BTH_DATA_EP_SIZE, 0, 9, 17, 25, 33, 49), #endif #if CFG_CDC_CONSOLE TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_CONSOLE, CDC_CONSOLE_IF_STR_IX, USBD_CDC_CONSOLE_NOTIFY_EP, USBD_CDC_CONSOLE_NOTIFY_EP_SIZE, USBD_CDC_CONSOLE_DATA_OUT_EP, USBD_CDC_CONSOLE_DATA_IN_EP, - (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 512 : USBD_CDC_CONSOLE_DATA_EP_SIZE), + (USBD_RHPORT_MODE & OPT_MODE_HIGH_SPEED) ? 512 : USBD_CDC_CONSOLE_DATA_EP_SIZE), #endif #if CFG_CDC_HCI TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_HCI, CDC_HCI_IF_STR_IX, USBD_CDC_HCI_NOTIFY_EP, USBD_CDC_HCI_NOTIFY_EP_SIZE, USBD_CDC_HCI_DATA_OUT_EP, USBD_CDC_HCI_DATA_IN_EP, - (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 512 : USBD_CDC_HCI_DATA_EP_SIZE), + (USBD_RHPORT_MODE & OPT_MODE_HIGH_SPEED) ? 512 : USBD_CDC_HCI_DATA_EP_SIZE), #endif #if CFG_CDC TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, CDC_IF_STR_IX, USBD_CDC_NOTIFY_EP, USBD_CDC_NOTIFY_EP_SIZE, USBD_CDC_DATA_OUT_EP, USBD_CDC_DATA_IN_EP, - (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 512 : USBD_CDC_DATA_EP_SIZE), + (USBD_RHPORT_MODE & OPT_MODE_HIGH_SPEED) ? 512 : USBD_CDC_DATA_EP_SIZE), #endif #if CFG_TUD_MSC /* TODO: MSC not handled yet */ TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, MSC_IF_STR_IX, USBD_MSC_DATA_OUT_EP, USBD_MSC_DATA_IN_EP, - (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 512 : 64), + (USBD_RHPORT_MODE & OPT_MODE_HIGH_SPEED) ? 512 : 64), #endif #if CFG_TUD_HID diff --git a/hw/usb/tinyusb/syscfg.yml b/hw/usb/tinyusb/syscfg.yml index d59ef2a86..9ccd8c5d6 100644 --- a/hw/usb/tinyusb/syscfg.yml +++ b/hw/usb/tinyusb/syscfg.yml @@ -53,3 +53,10 @@ syscfg.defs: description: > Enable USB high speed if device supports it. value: 0 +USBD_RHPORT: +description: +Selects which peripheral is used for USBD +value: USB0 +choices: +- USB0 +- USB1
(mynewt-core) branch master updated: hw/drivers/bme280: Fix writes to I2C
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 22ccc6836 hw/drivers/bme280: Fix writes to I2C 22ccc6836 is described below commit 22ccc683646e77d9874e2f5d64c3c6f0bdbeabdc Author: Jerzy Kasenberg AuthorDate: Mon Sep 9 12:46:30 2024 +0200 hw/drivers/bme280: Fix writes to I2C I2C writes when driver was enabled clear MSB of register address. This prevented any write to control registers. Now registers MSB is cleared on write only for SPI. Writing registers also requires single start condition. Code was doing write with restart condtion that does not seem to work correctly Signed-off-by: Jerzy Kasenberg --- hw/drivers/sensors/bme280/include/bme280/bme280.h | 1 + hw/drivers/sensors/bme280/src/bme280.c| 27 +-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/hw/drivers/sensors/bme280/include/bme280/bme280.h b/hw/drivers/sensors/bme280/include/bme280/bme280.h index 42b877fcf..276f1a961 100644 --- a/hw/drivers/sensors/bme280/include/bme280/bme280.h +++ b/hw/drivers/sensors/bme280/include/bme280/bme280.h @@ -111,6 +111,7 @@ struct bme280 { struct bus_i2c_node i2c_node; struct bus_spi_node spi_node; }; +bool node_is_spi; #else struct os_dev dev; #endif diff --git a/hw/drivers/sensors/bme280/src/bme280.c b/hw/drivers/sensors/bme280/src/bme280.c index 384803005..93fadb6d7 100644 --- a/hw/drivers/sensors/bme280/src/bme280.c +++ b/hw/drivers/sensors/bme280/src/bme280.c @@ -75,6 +75,14 @@ static const struct sensor_driver g_bme280_sensor_driver = { bme280_sensor_get_config }; +#if MYNEWT_VAL(BUS_DRIVER_PRESENT) +static bool +bme280_uses_spi(struct sensor_itf *itf) +{ +return ((struct bme280 *)(itf->si_dev))->node_is_spi; +} +#endif + static int bme280_default_cfg(struct bme280_cfg *cfg) { @@ -894,6 +902,12 @@ bme280_writelen(struct sensor_itf *itf, uint8_t addr, uint8_t *payload, int rc; #if MYNEWT_VAL(BUS_DRIVER_PRESENT) +uint8_t buf[4]; + +if (len > 3) { +return SYS_EINVAL; +} + struct os_dev *dev = itf->si_dev; rc = bus_node_lock(dev, OS_TIMEOUT_NEVER); @@ -901,16 +915,15 @@ bme280_writelen(struct sensor_itf *itf, uint8_t addr, uint8_t *payload, return SYS_EINVAL; } -addr &= ~BME280_SPI_READ_CMD_BIT; - -rc = bus_node_write(dev, &addr, 1, OS_TIMEOUT_NEVER, BUS_F_NOSTOP); -if (rc) { -goto done; +if (bme280_uses_spi(itf)) { +addr &= ~BME280_SPI_READ_CMD_BIT; } -rc = bus_node_simple_write(dev, payload, len); +buf[0] = addr; +memcpy(buf + 1, payload, len); + +rc = bus_node_simple_write(dev, buf, len + 1); -done: (void)bus_node_unlock(dev); #else int i;
(mynewt-core) 02/03: boot/startup: Linker script template unification
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 commit 0fb90bd3a192b11f486ad8cc22877708da324758 Author: Jerzy Kasenberg AuthorDate: Thu Aug 22 10:05:35 2024 +0200 boot/startup: Linker script template unification Now all cortex linker script files have region for interrupt stack. It can be provided by memory_regions.ld.h if stack is to be placed in separate memory region. If MCU/BSP specific region is defined (no definition of STACk_REGION) STACK_RAM region is created at the end of RAM. This simplifies check for heap. mtb section is removed for now from all linker script templates as it is not present in any MCU that has generated linker script. Few templates had duplicating section .bssnz that is now removed. bss sections now have (NOLOAD) attribute Signed-off-by: Jerzy Kasenberg --- boot/startup/mynewt_cortex_m0.ld | 42 +++ boot/startup/mynewt_cortex_m3.ld | 42 +++ boot/startup/mynewt_cortex_m33.ld | 42 +++ boot/startup/mynewt_cortex_m7.ld | 35 +--- 4 files changed, 79 insertions(+), 82 deletions(-) diff --git a/boot/startup/mynewt_cortex_m0.ld b/boot/startup/mynewt_cortex_m0.ld index ce4d8c0fa..b74fd10de 100644 --- a/boot/startup/mynewt_cortex_m0.ld +++ b/boot/startup/mynewt_cortex_m0.ld @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -36,7 +37,18 @@ MEMORY #ifdef FLASH_AREA_IMAGE_0_OFFSET SLOT0 (rx!w) : ORIGIN = FLASH_AREA_IMAGE_0_OFFSET, LENGTH = FLASH_AREA_IMAGE_0_SIZE #endif +/* + * If STACK_REGION is defined it means that MCU stack is place in other region then RAM + * int that case RAM region size is exactly RAM_SIZE + * If STACK_REGION is NOT defined STACK_RAM region is place at the end of RAM + * and RAM region size is shortened. + */ +#ifdef STACK_REGION RAM (rwx) : ORIGIN = RAM_START, LENGTH = RAM_SIZE +#else +RAM (rwx) : ORIGIN = RAM_START, LENGTH = (RAM_SIZE - STACK_SIZE) +STACK_RAM (rw) : ORIGIN = RAM_START + RAM_SIZE - STACK_SIZE, LENGTH = STACK_SIZE +#endif #include } @@ -247,7 +259,7 @@ SECTIONS __data_image__ = LOADADDR(.data); _sidata = LOADADDR(.data); -.bssnz : +.bssnz (NOLOAD) : { . = ALIGN(4); __bssnz_start__ = .; @@ -269,14 +281,8 @@ SECTIONS __ecorebss = .; } > COREBSS_RAM #endif -.bssnz (NOLOAD): -{ -. = ALIGN(4); -*(.bss.core.nz) -. = ALIGN(4); -} > RAM -.bss : +.bss (NOLOAD) : { . = ALIGN(4); _sbss = .; @@ -291,27 +297,19 @@ SECTIONS /* Heap starts after BSS */ . = ALIGN(8); __HeapBase = .; +/* Top of head is the bottom of the stack */ +__HeapLimit = ORIGIN(RAM) + LENGTH(RAM); -/* Dummy section to calculate whether we need to move stack out of MTB - * buffer or not. */ -.mtb (NOLOAD) : -{ -KEEP(*(.mtb)); -} +/* Check if data + heap + stack exceeds RAM limit */ +ASSERT(__HeapBase <= __HeapLimit, "No space for MCU heap") _ram_start = ORIGIN(RAM); /* Set stack top to end of RAM, and stack limit move down by * size of stack_dummy section */ -__StackTop = ORIGIN(RAM) + LENGTH(RAM) - SIZEOF(.mtb); +__StackTop = ORIGIN(STACK_RAM) + LENGTH(STACK_RAM); +__StackLimit = ORIGIN(STACK_RAM); _estack = __StackTop; -__StackLimit = __StackTop - STACK_SIZE; PROVIDE(__stack = __StackTop); - -/* Top of head is the bottom of the stack */ -__HeapLimit = __StackLimit; - -/* Check if data + heap + stack exceeds RAM limit */ -ASSERT(__HeapBase <= __HeapLimit, "region RAM overflowed with stack") } diff --git a/boot/startup/mynewt_cortex_m3.ld b/boot/startup/mynewt_cortex_m3.ld index ce4d8c0fa..b74fd10de 100644 --- a/boot/startup/mynewt_cortex_m3.ld +++ b/boot/startup/mynewt_cortex_m3.ld @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -36,7 +37,18 @@ MEMORY #ifdef FLASH_AREA_IMAGE_0_OFFSET SLOT0 (rx!w) : ORIGIN = FLASH_AREA_IMAGE_0_OFFSET, LENGTH = FLASH_AREA_IMAGE_0_SIZE #endif +/* + * If STACK_REGION is defined it means that MCU stack is place in other region then RAM + * int that case RAM region size is exactly RAM_SIZE + * If STACK_REGION is NOT defined STACK_RAM region is place at the end of RAM + * and RAM region size is shortened. + */ +#ifdef STACK_REGION RAM (rwx) : ORIGIN = RAM_START, LENGTH = RAM_SIZE +#else +RAM (rwx) : ORIGIN = RAM_START, LENGTH = (RAM_SIZE - STACK_SIZE) +STACK_RAM (rw) : ORIGIN = RAM_START + RAM_SIZE - STACK_SIZE, LENGTH = STACK_SIZE +#endif #include
(mynewt-core) 01/03: boot/startup: Add user_section.ld.h
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 commit bdf7b18d1a06ae2ac25650554209e5a63737e719 Author: Jerzy Kasenberg AuthorDate: Thu Aug 22 09:55:02 2024 +0200 boot/startup: Add user_section.ld.h Some MCU/applications may require special sections in linker script So far memory_regions.ld.h could add non standard memory regions, newt link_tables could add filters to read only data for easy link time table generations. This adds way to add whole sections and or symbol definitions if required Signed-off-by: Jerzy Kasenberg --- boot/startup/mynewt_cortex_m0.ld | 2 ++ boot/startup/mynewt_cortex_m3.ld | 2 ++ boot/startup/mynewt_cortex_m33.ld | 2 ++ boot/startup/mynewt_cortex_m4.ld | 2 ++ boot/startup/mynewt_cortex_m7.ld | 2 ++ boot/startup/scripts/generate_linker_script.sh | 1 + 6 files changed, 11 insertions(+) diff --git a/boot/startup/mynewt_cortex_m0.ld b/boot/startup/mynewt_cortex_m0.ld index 204f29f1f..ce4d8c0fa 100644 --- a/boot/startup/mynewt_cortex_m0.ld +++ b/boot/startup/mynewt_cortex_m0.ld @@ -43,6 +43,8 @@ MEMORY /* Define output sections */ SECTIONS { +#include + /* * Image header is added by newt tool during execution newt image-create. * This section allows to have complete elf with predefined image header that diff --git a/boot/startup/mynewt_cortex_m3.ld b/boot/startup/mynewt_cortex_m3.ld index 204f29f1f..ce4d8c0fa 100644 --- a/boot/startup/mynewt_cortex_m3.ld +++ b/boot/startup/mynewt_cortex_m3.ld @@ -43,6 +43,8 @@ MEMORY /* Define output sections */ SECTIONS { +#include + /* * Image header is added by newt tool during execution newt image-create. * This section allows to have complete elf with predefined image header that diff --git a/boot/startup/mynewt_cortex_m33.ld b/boot/startup/mynewt_cortex_m33.ld index 204f29f1f..ce4d8c0fa 100644 --- a/boot/startup/mynewt_cortex_m33.ld +++ b/boot/startup/mynewt_cortex_m33.ld @@ -43,6 +43,8 @@ MEMORY /* Define output sections */ SECTIONS { +#include + /* * Image header is added by newt tool during execution newt image-create. * This section allows to have complete elf with predefined image header that diff --git a/boot/startup/mynewt_cortex_m4.ld b/boot/startup/mynewt_cortex_m4.ld index 6f0237751..b74fd10de 100644 --- a/boot/startup/mynewt_cortex_m4.ld +++ b/boot/startup/mynewt_cortex_m4.ld @@ -55,6 +55,8 @@ MEMORY /* Define output sections */ SECTIONS { +#include + /* * Image header is added by newt tool during execution newt image-create. * This section allows to have complete elf with predefined image header that diff --git a/boot/startup/mynewt_cortex_m7.ld b/boot/startup/mynewt_cortex_m7.ld index 0d5031827..5bbe1f069 100644 --- a/boot/startup/mynewt_cortex_m7.ld +++ b/boot/startup/mynewt_cortex_m7.ld @@ -44,6 +44,8 @@ MEMORY /* Define output sections */ SECTIONS { +#include + /* * Image header is added by newt tool during execution newt image-create. * This section allows to have complete elf with predefined image header that diff --git a/boot/startup/scripts/generate_linker_script.sh b/boot/startup/scripts/generate_linker_script.sh index a9215ad06..4e528b5fe 100755 --- a/boot/startup/scripts/generate_linker_script.sh +++ b/boot/startup/scripts/generate_linker_script.sh @@ -25,6 +25,7 @@ touch ${MYNEWT_BUILD_GENERATED_DIR}/link/include/target_config.ld.h touch ${MYNEWT_BUILD_GENERATED_DIR}/link/include/memory_regions.ld.h touch ${MYNEWT_BUILD_GENERATED_DIR}/link/include/bsp_config.ld.h touch ${MYNEWT_BUILD_GENERATED_DIR}/link/include/mcu_config.ld.h +touch ${MYNEWT_BUILD_GENERATED_DIR}/link/include/user_sections.ld.h set >env.txt ${MYNEWT_CC_PATH} -xc -DMYNEWT_SYSFLASH_ONLY_CONST -P -E \
(mynewt-core) 03/03: mcu/stm32h7: Fix core dump configuration
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 commit cd5c257de84a98e23b19323f6e08fcb677c1217b Author: Jerzy Kasenberg AuthorDate: Thu Aug 22 10:11:08 2024 +0200 mcu/stm32h7: Fix core dump configuration When BSP switched to use autogenerated linker script definitions for _dtcmram_start and _itcmram_start were not present in generated script. Now STM32H7 MCU adds user_sections.ld.h that provides missing symbols. Signed-off-by: Jerzy Kasenberg --- .../stm/stm32h7xx/link/include/user_sections.ld.h | 23 ++ 1 file changed, 23 insertions(+) diff --git a/hw/mcu/stm/stm32h7xx/link/include/user_sections.ld.h b/hw/mcu/stm/stm32h7xx/link/include/user_sections.ld.h new file mode 100644 index 0..b5a18a10e --- /dev/null +++ b/hw/mcu/stm/stm32h7xx/link/include/user_sections.ld.h @@ -0,0 +1,23 @@ +/* + * 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. + */ + +_dtcmram_start = ORIGIN(DTCM); +_dtcmram_limit = ORIGIN(DTCM) + LENGTH(DTCM); +_itcmram_start = ORIGIN(ITCM); +_itcmram_limit = ORIGIN(ITCM) + LENGTH(ITCM);
(mynewt-core) 03/03: sys/log: Add option to limit number of printed logs
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 commit 23b6eeb325cd922f1e65825ea7ac0647635062ad Author: Jerzy Kasenberg AuthorDate: Mon Aug 5 14:36:12 2024 +0200 sys/log: Add option to limit number of printed logs This adds -n option that can be used to specify number of logs to print with log command. Usage: log -n i.e.: log -n 10 will print at most 10 entries from each log Signed-off-by: Jerzy Kasenberg --- sys/log/full/src/log_shell.c | 40 ++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/sys/log/full/src/log_shell.c b/sys/log/full/src/log_shell.c index a1d446c7e..0de60d776 100644 --- a/sys/log/full/src/log_shell.c +++ b/sys/log/full/src/log_shell.c @@ -41,11 +41,26 @@ static uint32_t shell_log_count; + +struct walk_arg { +uint32_t count_limit; +uint32_t count; +}; + static int shell_log_count_entry(struct log *log, struct log_offset *log_offset, const struct log_entry_hdr *ueh, const void *dptr, uint16_t len) { +struct walk_arg *arg = (struct walk_arg *)log_offset->lo_arg; + shell_log_count++; +if (arg) { +arg->count++; +if (arg->count >= arg->count_limit) { +return 1; +} +} + return 0; } @@ -59,6 +74,7 @@ shell_log_dump_entry(struct log *log, struct log_offset *log_offset, struct CborParser cbor_parser; struct CborValue cbor_value; struct log_cbor_reader cbor_reader; +struct walk_arg *arg = (struct walk_arg *)log_offset->lo_arg; char tmp[32 + 1]; int off; int blksz; @@ -108,6 +124,12 @@ shell_log_dump_entry(struct log *log, struct log_offset *log_offset, } console_write("\n", 1); +if (arg) { +arg->count++; +if (arg->count >= arg->count_limit) { +return 1; +} +} return 0; } @@ -124,6 +146,7 @@ shell_log_dump_cmd(int argc, char **argv) bool partial_match = false; bool clear_log; bool dump_logs = true; +struct walk_arg arg = {}; int i; int rc; @@ -133,6 +156,17 @@ shell_log_dump_cmd(int argc, char **argv) list_only = true; break; } +if (0 == strcmp(argv[i], "-n")) { +if (i + 1 < argc) { +arg.count_limit = parse_ll_bounds(argv[i + 1], 1, 100, &rc); +if (rc) { +arg.count_limit = 1; +} +log_offset.lo_arg = &arg; +} +++i; +continue; +} if (0 == strcmp(argv[i], "-t")) { dump_logs = false; continue; @@ -241,8 +275,10 @@ shell_log_storage_cmd(int argc, char **argv) if (log_storage_info(log, &info)) { console_printf("Storage info not supported for %s\n", log->l_name); } else { -console_printf("%s: %d of %d used\n", log->l_name, - (unsigned)info.used, (unsigned)info.size); +uint32_t entry_count = 0; +log_get_entry_count(log, &entry_count); +console_printf("%s: %d of %d used; %d entries\n", log->l_name, + (unsigned)info.used, (unsigned)info.size, (int)entry_count); #if MYNEWT_VAL(LOG_STORAGE_WATERMARK) console_printf("%s: %d of %d used by unread entries\n", log->l_name, (unsigned)info.used_unread, (unsigned)info.size);
(mynewt-core) 02/03: sys/log: Add log-fill command
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 commit 97a90d5573e3939d97dfea5b3f5f9d8e10164972 Author: Jerzy Kasenberg AuthorDate: Wed Jul 31 19:38:02 2024 +0200 sys/log: Add log-fill command This adds log-fill command to the log cli. It allows to fill specific log with auto generated logs. usage: log-fill [] i.e.: log-fill 1000 reboot_log Command is added when syscfg value LOG_CLI_FILL_CMD is set Signed-off-by: Jerzy Kasenberg --- sys/log/full/pkg.yml | 3 +++ sys/log/full/src/log_shell.c | 41 + sys/log/full/syscfg.yml | 4 3 files changed, 48 insertions(+) diff --git a/sys/log/full/pkg.yml b/sys/log/full/pkg.yml index c8b8b0abf..fe6f8c8b2 100644 --- a/sys/log/full/pkg.yml +++ b/sys/log/full/pkg.yml @@ -65,3 +65,6 @@ pkg.req_apis.LOG_STATS: pkg.init: log_init: 'MYNEWT_VAL(LOG_SYSINIT_STAGE_MAIN)' + +pkg.init.LOG_CLI_FILL_CMD: +shell_log_fill_register: $after:shell_init diff --git a/sys/log/full/src/log_shell.c b/sys/log/full/src/log_shell.c index 0f0036e16..a1d446c7e 100644 --- a/sys/log/full/src/log_shell.c +++ b/sys/log/full/src/log_shell.c @@ -254,4 +254,45 @@ shell_log_storage_cmd(int argc, char **argv) } #endif +static int +log_fill_command(int argc, char **argv) +{ +const char *log_name; +struct log *log; +int num = 1; + +if (argc > 2) { +log_name = argv[2]; +log = log_find(log_name); +} else { +log = log_list_get_next(NULL); +} +if (log == NULL) { +console_printf("No log to fill\n"); +return -1; +} +if (argc > 1) { +num = atoi(argv[1]); +if (num <= 0 || num > 1) { +num = 1; +} +} + +for (int i = 0; i < num; ++i) { +log_printf(log, MODLOG_MODULE_DFLT, LOG_LEVEL_INFO, "Log os_time %d", (int)os_time_get()); +} + +return 0; +} + +static struct shell_cmd log_fill_cmd = { +.sc_cmd = "log-fill", +.sc_cmd_func = log_fill_command +}; + +void +shell_log_fill_register(void) +{ +shell_cmd_register(&log_fill_cmd); +} #endif diff --git a/sys/log/full/syscfg.yml b/sys/log/full/syscfg.yml index 91709976f..d48ae9703 100644 --- a/sys/log/full/syscfg.yml +++ b/sys/log/full/syscfg.yml @@ -85,6 +85,10 @@ syscfg.defs: restrictions: - SHELL_TASK +LOG_CLI_FILL_CMD: +description: 'Add "log-fill" command for filling up log' +value: 0 + LOG_SHELL_SHOW_INDEX: description: '"log" command shows log index when dumping entries' value: 0
(mynewt-core) branch master updated (89ee1a105 -> ddae64e9b)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 89ee1a105 drivers/i2s: Fix missing dependency new 5b3cb7a57 kernel/os: Add msys unit tests new ddae64e9b kernel/os: Fix msys allocation with multiply mpools 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: kernel/os/selftest/include/os_test/os_test.h | 1 + kernel/os/selftest/src/msys_test.c | 100 + .../os/selftest/src/{mbuf_test.h => msys_test.h} | 37 +++- kernel/os/selftest/src/os_test.c | 1 + .../os/selftest/src/testcases/os_msys_test_cases.c | 228 + kernel/os/src/os_msys.c| 32 ++- 6 files changed, 378 insertions(+), 21 deletions(-) create mode 100644 kernel/os/selftest/src/msys_test.c copy kernel/os/selftest/src/{mbuf_test.h => msys_test.h} (50%) create mode 100644 kernel/os/selftest/src/testcases/os_msys_test_cases.c
(mynewt-newt) branch master updated: newt: Extend link tables filter
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-newt.git The following commit(s) were added to refs/heads/master by this push: new b2468d97 newt: Extend link tables filter b2468d97 is described below commit b2468d970cb73b3276c6ea2bf684a5f6bf752c79 Author: Jerzy Kasenberg AuthorDate: Thu May 16 09:42:41 2024 +0200 newt: Extend link tables filter So far for link time generated tables only exact section name was added to filter like in this example: pkg.link_tables: - foo would generate link_tables.ld.h with following content __foo_start__ = .; KEEP(*(.foo)) __foo_end__ = .; Now additional filter will be added __foo_start__ = .; KEEP(*(.foo)) KEEP(*(SORT(.foo.*))) __foo_end__ = .; This is general rule for many sections like .text or .data This is specifically required for xc32 compiler that adds variable name to section by itself even though __attribute__((section, "foo")) is used and arm gcc treats name in attribute verbatim and not as prefix. --- newt/builder/extcmd.go | 1 + 1 file changed, 1 insertion(+) diff --git a/newt/builder/extcmd.go b/newt/builder/extcmd.go index e75530f8..dcad7a40 100644 --- a/newt/builder/extcmd.go +++ b/newt/builder/extcmd.go @@ -189,6 +189,7 @@ func getLinkTableEntry(name string) string { entry := indent + "__" + name + "_start__ = .;\n" + indent + "KEEP(*(." + name + "))\n" + + indent + "KEEP(*(SORT(." + name + ".*)))\n" + indent + "__" + name + "_end__ = .;\n\n" return entry
(mynewt-core) branch master updated: hw/bsp: pca10059 update readme.md
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 a9ea41cbf hw/bsp: pca10059 update readme.md a9ea41cbf is described below commit a9ea41cbf115860eabeb7a2e308a8cf7f457669b Author: Jerzy Kasenberg AuthorDate: Tue Sep 3 11:14:32 2024 +0200 hw/bsp: pca10059 update readme.md Readme is updated with syscfg.yml that shows configuration of blehci. Signed-off-by: Jerzy Kasenberg --- hw/bsp/nordic_pca10059/readme.md | 35 +-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/hw/bsp/nordic_pca10059/readme.md b/hw/bsp/nordic_pca10059/readme.md index a8ebe6ca3..def6b3ed6 100644 --- a/hw/bsp/nordic_pca10059/readme.md +++ b/hw/bsp/nordic_pca10059/readme.md @@ -31,7 +31,7 @@ Here are steps to flash mynewt application: 1. Flash map of the application must be changed to match what Nordic bootloader expects. Here is example target file with flash map suitable for Nordic bootloader. -target file: *targets/nordic_pca10059-blehci_nrf52dfu* +target file: *targets/nordic_pca10059-blehci_nrf52dfu/target.yml* ```yml target.app: "@apache-mynewt-nimble/apps/blehci" target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10059" @@ -52,7 +52,7 @@ bsp.flash_map: offset: 0x000E size: 128kB # mynewt image -FLASH_AREA_IMAGE_0: +FLASH_AREA_IMAGE_0: device: 0 offset: 0x1000 size: 396kB @@ -69,6 +69,37 @@ bsp.flash_map: offset: 0x000CC000 size: 16kB ``` +Example configuration file *targets/nordic_pca10059-blehci_nrf52dfu/syscfg.yml*: +```yml +syscfg.vals: +# Skip includsion of image header in the build +INCLUDE_IMAGE_HEADER: 0 + +# Configuration for dongle to show up as bluetooth device in host system +BLE_TRANSPORT_HS: usb +USBD_PID: 0xC01A +USBD_VID: 0xC0CA +USBD_BTH: 1 +# Optional name of +USBD_PRODUCT_STRING: '"NimBLE"' +USBD_BTH_DESCRIPTOR_STRING: '"NimBLE"' + +# Set to 1 if testing on Windows +BLE_LL_HBD_FAKE_DUAL_MODE: 0 + +syscfg.vals.BLE_LL_HBD_FAKE_DUAL_MODE: +USBD_PRODUCT_STRING: '"NimBLE (For Windows)"' +USBD_BTH_DESCRIPTOR_STRING: '"NimBLE (For Windows)"' +# Public address is required, it should be provisioned not set this way +BLE_LL_PUBLIC_DEV_ADDR: 0x010101010102 +BLE_TRANSPORT_EVT_SIZE: 257 +``` +Example target package file *targets/nordic_pca10059-blehci_nrf52dfu/pkg.yml*: +```yml +pkg.name: "targets/nordic_pca10059-blehci_nrf52dfu" +pkg.type: target +``` + **FLASH_AREA_MBR** and **FLASH_AREA_NRF52_BOOTLOADER** are here to denote flash area not available to mynewt. **FLASH_AREA_IMAGE_0** must start from **0x1000**
(mynewt-core) branch master updated: hw/bsp: pca10059 add readme.md
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 1f47c49e9 hw/bsp: pca10059 add readme.md 1f47c49e9 is described below commit 1f47c49e980ad16590c37e4b199a4bb309f3cd03 Author: Jerzy Kasenberg AuthorDate: Mon Sep 2 11:01:12 2024 +0200 hw/bsp: pca10059 add readme.md This adds readme.md files that explains how to use board without hardware debugger when factory programmed Open DFU Bootloader is present. Signed-off-by: Jerzy Kasenberg --- hw/bsp/nordic_pca10059/readme.md | 93 1 file changed, 93 insertions(+) diff --git a/hw/bsp/nordic_pca10059/readme.md b/hw/bsp/nordic_pca10059/readme.md new file mode 100644 index 0..a8ebe6ca3 --- /dev/null +++ b/hw/bsp/nordic_pca10059/readme.md @@ -0,0 +1,93 @@ + + +# PCA10059: NRF52840 USB dongle + +## Flashing application without debugger + +Board comes from factory with Nordic DFU Bootloader that does not recognize images created by **newt** tool. + +Board with Nordic bootloader can be programmed using Nordic's [**nrfutil**](https://www.nordicsemi.com/Products/Development-tools/nRF-Util). + +Here are steps to flash mynewt application: + +1. Flash map of the application must be changed to match what Nordic bootloader expects. +Here is example target file with flash map suitable for Nordic bootloader. +target file: *targets/nordic_pca10059-blehci_nrf52dfu* +```yml +target.app: "@apache-mynewt-nimble/apps/blehci" +target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10059" +target.build_profile: debug + +bsp.flash_map: +areas: +# NRF52 MBR area. +FLASH_AREA_MBR: +user_id: 20 +device: 0 +offset: 0x +size: 4kB +# NRF52 bootloader ara. +FLASH_AREA_NRF52_BOOTLOADER: +user_id: 21 +device: 0 +offset: 0x000E +size: 128kB +# mynewt image +FLASH_AREA_IMAGE_0: +device: 0 +offset: 0x1000 +size: 396kB + +# User areas. +FLASH_AREA_REBOOT_LOG: +user_id: 0 +device: 0 +offset: 0x000C8000 +size: 16kB +FLASH_AREA_NFFS: +user_id: 1 +device: 0 +offset: 0x000CC000 +size: 16kB +``` +**FLASH_AREA_MBR** and **FLASH_AREA_NRF52_BOOTLOADER** are here to denote flash area not available to mynewt. + +**FLASH_AREA_IMAGE_0** must start from **0x1000** + +2. Build application with newt tool: +```shell +newt build nordic_pca10059-blehci_nrf52dfu +``` +3. Create hex file needed by nrfutil: +```shell +cd bin/targets/nordic_pca10059-blehci_nrf52dfu/app/@apache-mynewt-nimble/apps/blehci/ +arm-none-eabi-objcopy -O ihex blehci.elf blehci.hex +``` +4. Create package zip file for nrfutil: +```shell +nrfutil pkg generate --hw-version 52 --sd-req 0 --application blehci.hex --application-version 1 blehci_nrf52dfu_package.zip +``` +5. Enter bootloader mode by clicking reset button while user button is held. When Nordic Open DFU Bootloader is activated board red LED starts to blink and serial port is visible in the host system (**COM***x* for Windows or **/dev/ttyACM***x* for Linux). +6. Flash application package with nrfutil: +```shell +nrfutil dfu usb-serial -p /dev/ttyACM0 --package blehci_nrf52dfu_package.zip +```
(mynewt-core) branch master updated (ed30c61ab -> edce0a697)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from ed30c61ab hw/mcu/stm32: Fix WFI in RAM for -O3 new d4ff6d5bf hw/mcu: Add nxp sdk repository new e03d95965 hw/mcu: Remove copy of NXP sdk files new ed617e67f hw/mcu: Add LPC55xx family MCU from NXP new edce0a697 hw/bsp: Add lpcxpresso55s28 BSP The 4 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: .rat-excludes | 6 - .style_ignored_dirs| 2 + LICENSE|11 - hw/bsp/{ruuvitag_rev_b => lpcxpresso55s28}/bsp.yml |39 +- .../frdm-k64_debug.sh => lpcxpresso55s28/debug.sh} | 2 +- .../include/bsp/bsp.h |40 +- hw/bsp/{reel_board => lpcxpresso55s28}/pkg.yml |19 +- hw/bsp/lpcxpresso55s28/src/hal_bsp.c | 185 + hw/bsp/{frdm-k64f => lpcxpresso55s28}/syscfg.yml |23 +- hw/mcu/nxp/kinetis/MK64F12/include/MK64F12.h | 22404 --- .../nxp/kinetis/MK64F12/include/MK64F12_features.h | 1979 -- hw/mcu/nxp/kinetis/MK64F12/include/fsl_clock.h | 1567 -- .../kinetis/MK64F12/include/fsl_device_registers.h |36 - .../nxp/kinetis/MK64F12/include/system_MK64F12.h | 165 - hw/mcu/nxp/kinetis/MK64F12/pkg.yml | 1 + hw/mcu/nxp/kinetis/MK64F12/src/fsl_clock.c | 2337 -- hw/mcu/nxp/kinetis/MK64F12/src/system_MK64F12.c| 242 - hw/mcu/nxp/kinetis/MK64F12/syscfg.yml |12 + .../nxp/kinetis/MK8xF/MK82F/include/MK82F25615.h | 27511 --- .../MK8xF/MK82F/include/MK82F25615_features.h | 2101 -- .../MK8xF/MK82F/include/fsl_device_registers.h |35 - .../MK8xF/MK82F/include/system_MK82F25615.h| 132 - .../mcu/nxp/kinetis/MK8xF/MK82F}/syscfg.yml| 4 +- hw/mcu/nxp/kinetis/MK8xF/include/fsl_clock.h | 1640 -- hw/mcu/nxp/kinetis/MK8xF/include/mcu/cmsis_nvic.h | 2 +- hw/mcu/nxp/kinetis/MK8xF/include/mcu/cortex_m4.h | 2 +- hw/mcu/nxp/kinetis/MK8xF/pkg.yml | 1 + hw/mcu/nxp/kinetis/MK8xF/src/fsl_clock.c | 2379 -- hw/mcu/nxp/kinetis/MK8xF/syscfg.yml|12 + hw/mcu/nxp/kinetis/include/mcu/kinetis_common.h| 2 + hw/mcu/nxp/kinetis/pkg.yml | 9 +- hw/mcu/nxp/kinetis/src/hal_flash.c | 1 - hw/mcu/nxp/kinetis/src/hal_lpuart.c| 2 +- hw/mcu/nxp/kinetis/src/hal_reset_cause.c | 2 +- hw/mcu/nxp/kinetis/src/hal_uart.c | 1 - .../src => mcu/nxp/lpc55xx/include}/clock_config.h | 111 +- .../lpc55xx}/include/mcu/cmsis_nvic.h | 4 +- .../lpc55xx}/include/mcu/cortex_m33.h | 1 - hw/mcu/{native => nxp/lpc55xx}/include/mcu/mcu.h | 7 +- .../nxp/lpc55xx/include/mcu/mcu_vectors.h} | 7 +- .../lpc55xx/include/mcu/mcux_hal.h}|28 +- .../lpc55xx/include/mcu/vectors/lpc55s28_vectors.h |95 + hw/mcu/{stm/stm32_common => nxp/lpc55xx}/pkg.yml |45 +- hw/mcu/nxp/lpc55xx/src/clock_config.c | 374 + hw/mcu/nxp/lpc55xx/src/hal_flash.c | 178 + hw/mcu/nxp/lpc55xx/src/hal_gpio.c | 255 + hw/mcu/nxp/{kinetis => lpc55xx}/src/hal_os_tick.c | 2 +- .../nxp/{kinetis => lpc55xx}/src/hal_reset_cause.c |50 +- hw/mcu/nxp/{kinetis => lpc55xx}/src/hal_system.c |24 +- .../mcu/nxp/lpc55xx/src/hal_system_init.c |12 +- .../{kinetis => lpc55xx}/src/hal_system_start.c| 5 +- hw/mcu/nxp/lpc55xx/src/hal_timer.c | 399 + hw/mcu/nxp/lpc55xx/src/hal_uart.c | 645 + .../mcu/nxp/lpc55xx/src/hal_watchdog.c |45 +- hw/mcu/nxp/{kinetis => lpc55xx}/syscfg.yml | 264 +- hw/mcu/nxp/mcux-sdk/include/mcux_common.h | 370 + hw/mcu/nxp/mcux-sdk/pkg.yml| 1279 + hw/mcu/nxp/mcux-sdk/syscfg.yml | 1223 + hw/mcu/nxp/src/ext/nxp-kinetis-sdk/COPYING-BSD-3 |33 - .../src/ext/nxp-kinetis-sdk/drivers/fsl_adc16.c| 501 - .../src/ext/nxp-kinetis-sdk/drivers/fsl_adc16.h| 516 - .../src/ext/nxp-kinetis-sdk/drivers/fsl_cache.c| 500 - .../src/ext/nxp-kinetis-sdk/drivers/fsl_cache.h| 340 - .../nxp/src/ext/nxp-kinetis-sdk/drivers/fsl_cmp.c | 371 - .../nxp/src/ext/nxp-kinetis-sdk/drivers/fsl_cmp.h | 321 - .../nxp/src/ext/nxp-kinetis-sdk/drivers/fsl_cmt.c | 330 - .../nxp/src/ext/nxp-kinetis-sdk/drivers/fsl_cmt.h | 378 - .../src/ext/nxp-kinet
(mynewt-core) 01/04: hw/mcu: Add nxp sdk repository
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 commit d4ff6d5bf9b1905989554938ed335ce9e5a672bb Author: Jerzy Kasenberg AuthorDate: Thu Jun 29 22:34:16 2023 +0200 hw/mcu: Add nxp sdk repository --- hw/mcu/nxp/mcux-sdk/include/mcux_common.h | 370 + hw/mcu/nxp/mcux-sdk/pkg.yml | 1279 + hw/mcu/nxp/mcux-sdk/syscfg.yml| 1223 +++ 3 files changed, 2872 insertions(+) diff --git a/hw/mcu/nxp/mcux-sdk/include/mcux_common.h b/hw/mcu/nxp/mcux-sdk/include/mcux_common.h new file mode 100644 index 0..a4a7d2b2f --- /dev/null +++ b/hw/mcu/nxp/mcux-sdk/include/mcux_common.h @@ -0,0 +1,370 @@ +/* + * 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. + */ + +#ifndef __MCUX_COMMON_H_ +#define __MCUX_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#if MYNEWT_VAL(MCU_K32L2A31A) +#include +#elif MYNEWT_VAL(MCU_K32L2A41A) +#include +#elif MYNEWT_VAL(MCU_K32L2B11A) +#include +#elif MYNEWT_VAL(MCU_K32L2B21A) +#include +#elif MYNEWT_VAL(MCU_K32L2B31A) +#include +#elif MYNEWT_VAL(MCU_K32L3A60) +#include +#elif MYNEWT_VAL(MCU_LPC51U68) +#include +#elif MYNEWT_VAL(MCU_LPC54005) +#include +#elif MYNEWT_VAL(MCU_LPC54016) +#include +#elif MYNEWT_VAL(MCU_LPC54018) +#include +#elif MYNEWT_VAL(MCU_LPC54018M) +#include +#elif MYNEWT_VAL(MCU_LPC54113) +#include +#elif MYNEWT_VAL(MCU_LPC54114) +#include +#elif MYNEWT_VAL(MCU_LPC54605) +#include +#elif MYNEWT_VAL(MCU_LPC54606) +#include +#elif MYNEWT_VAL(MCU_LPC54607) +#include +#elif MYNEWT_VAL(MCU_LPC54608) +#include +#elif MYNEWT_VAL(MCU_LPC54616) +#include +#elif MYNEWT_VAL(MCU_LPC54618) +#include +#elif MYNEWT_VAL(MCU_LPC54628) +#include +#elif MYNEWT_VAL(MCU_LPC54S005) +#include +#elif MYNEWT_VAL(MCU_LPC54S016) +#include +#elif MYNEWT_VAL(MCU_LPC54S018) +#include +#elif MYNEWT_VAL(MCU_LPC54S018M) +#include +#elif MYNEWT_VAL(MCU_LPC5502) +#include +#elif MYNEWT_VAL(MCU_LPC5502CP) +#include +#elif MYNEWT_VAL(MCU_LPC5504) +#include +#elif MYNEWT_VAL(MCU_LPC5504CP) +#include +#elif MYNEWT_VAL(MCU_LPC5506) +#include +#elif MYNEWT_VAL(MCU_LPC5506CP) +#include +#elif MYNEWT_VAL(MCU_LPC5512) +#include +#elif MYNEWT_VAL(MCU_LPC5514) +#include +#elif MYNEWT_VAL(MCU_LPC5516) +#include +#elif MYNEWT_VAL(MCU_LPC5526) +#include +#elif MYNEWT_VAL(MCU_LPC5528) +#include +#elif MYNEWT_VAL(MCU_LPC55S04) +#include +#elif MYNEWT_VAL(MCU_LPC55S06) +#include +#elif MYNEWT_VAL(MCU_LPC55S14) +#include +#elif MYNEWT_VAL(MCU_LPC55S16) +#include +#elif MYNEWT_VAL(MCU_LPC55S26) +#include +#elif MYNEWT_VAL(MCU_LPC55S28) +#include +#elif MYNEWT_VAL(MCU_LPC55S66) +#include +#elif MYNEWT_VAL(MCU_LPC55S69) +#include +#elif MYNEWT_VAL(MCU_LPC802) +#include +#elif MYNEWT_VAL(MCU_LPC804) +#include +#elif MYNEWT_VAL(MCU_LPC810) +#include +#elif MYNEWT_VAL(MCU_LPC811) +#include +#elif MYNEWT_VAL(MCU_LPC812) +#include +#elif MYNEWT_VAL(MCU_LPC822) +#include +#elif MYNEWT_VAL(MCU_LPC824) +#include +#elif MYNEWT_VAL(MCU_LPC832) +#include +#elif MYNEWT_VAL(MCU_LPC834) +#include +#elif MYNEWT_VAL(MCU_LPC844) +#include +#elif MYNEWT_VAL(MCU_LPC845) +#include +#elif MYNEWT_VAL(MCU_MCIMX7U3) +#include +#elif MYNEWT_VAL(MCU_MCIMX7U5) +#include +#elif MYNEWT_VAL(MCU_MIMX8DX1) +#include +#elif MYNEWT_VAL(MCU_MIMX8DX2) +#include +#elif MYNEWT_VAL(MCU_MIMX8DX3) +#include +#elif MYNEWT_VAL(MCU_MIMX8DX4) +#include +#elif MYNEWT_VAL(MCU_MIMX8DX5) +#include +#elif MYNEWT_VAL(MCU_MIMX8DX6) +#include +#elif MYNEWT_VAL(MCU_MIMX8MD6) +#include +#elif MYNEWT_VAL(MCU_MIMX8MD7) +#include +#elif MYNEWT_VAL(MCU_MIMX8ML3) +#include +#elif MYNEWT_VAL(MCU_MIMX8ML4) +#include +#elif MYNEWT_VAL(MCU_MIMX8ML6) +#include +#elif MYNEWT_VAL(MCU_MIMX8ML8) +#include +#elif MYNEWT_VAL(MCU_MIMX8MM1) +#include +#elif MYNEWT_VAL(MCU_MIMX8MM2) +#include +#elif MYNEWT_VAL(MCU_MIMX8MM3) +#include +#elif MYNEWT_VAL(MCU_MIMX8MM4) +#include +#elif MYNEWT_VAL(MCU_MIMX8MM5) +#include +#elif MYNEWT_VAL(MCU_MIMX8MM6) +#include +#elif MYNEWT_VAL(MCU_MIMX8MN1) +#include
(mynewt-core) 03/04: hw/mcu: Add LPC55xx family MCU from NXP
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 commit ed617e67f4c7d9ed956af67e11db3ec991d37da0 Author: Jerzy Kasenberg AuthorDate: Thu Jun 29 23:29:19 2023 +0200 hw/mcu: Add LPC55xx family MCU from NXP This adds basic support for NXP LPC55xx family. Currently watchdog, flash, uart, gpio is suported. No I2C, SPI, timers. --- .style_ignored_dirs| 2 + hw/mcu/nxp/lpc55xx/include/clock_config.h | 167 ++ hw/mcu/nxp/lpc55xx/include/mcu/cmsis_nvic.h| 29 + hw/mcu/nxp/lpc55xx/include/mcu/cortex_m33.h| 40 ++ hw/mcu/nxp/lpc55xx/include/mcu/mcu.h | 41 ++ hw/mcu/nxp/lpc55xx/include/mcu/mcu_vectors.h | 24 + hw/mcu/nxp/lpc55xx/include/mcu/mcux_hal.h | 64 ++ .../lpc55xx/include/mcu/vectors/lpc55s28_vectors.h | 95 +++ hw/mcu/nxp/lpc55xx/pkg.yml | 62 ++ hw/mcu/nxp/lpc55xx/src/clock_config.c | 374 hw/mcu/nxp/lpc55xx/src/hal_flash.c | 178 ++ hw/mcu/nxp/lpc55xx/src/hal_gpio.c | 255 hw/mcu/nxp/lpc55xx/src/hal_os_tick.c | 64 ++ hw/mcu/nxp/lpc55xx/src/hal_reset_cause.c | 70 +++ hw/mcu/nxp/lpc55xx/src/hal_system.c| 58 ++ hw/mcu/nxp/lpc55xx/src/hal_system_init.c | 31 + hw/mcu/nxp/lpc55xx/src/hal_system_start.c | 52 ++ hw/mcu/nxp/lpc55xx/src/hal_timer.c | 399 + hw/mcu/nxp/lpc55xx/src/hal_uart.c | 645 + hw/mcu/nxp/lpc55xx/src/hal_watchdog.c | 56 ++ hw/mcu/nxp/lpc55xx/syscfg.yml | 385 21 files changed, 3091 insertions(+) diff --git a/.style_ignored_dirs b/.style_ignored_dirs index db0468117..ca3a119eb 100644 --- a/.style_ignored_dirs +++ b/.style_ignored_dirs @@ -57,6 +57,8 @@ hw/mcu/stm/stm32_common/src/stm32_driver_mod_i2c_v2.c hw/mcu/stm/stm32_common/src/stm32_driver_mod_timer.c hw/mcu/stm/stm32_common/src/stm32_driver_mod_spi.c +hw/mcu/nxp/lpc55xx/src/clock_config.c + # Nordic preserved code style hw/mcu/nordic/nrf52xxx/src/system_nrf52.c hw/mcu/nordic/nrf51xxx/src/system_nrf51.c diff --git a/hw/mcu/nxp/lpc55xx/include/clock_config.h b/hw/mcu/nxp/lpc55xx/include/clock_config.h new file mode 100644 index 0..1e37f41b5 --- /dev/null +++ b/hw/mcu/nxp/lpc55xx/include/clock_config.h @@ -0,0 +1,167 @@ +/* + * Copyright 2017-2019 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +/*** + * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file + * will be overwritten if the respective MCUXpresso Config Tools is used to update this file. + **/ + +#ifndef _CLOCK_CONFIG_H_ +#define _CLOCK_CONFIG_H_ + +#include "fsl_common.h" + +/*** + * Definitions + **/ +#define BOARD_XTAL0_CLK_HZ 1600U /*!< Board xtal frequency in Hz */ +#define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32K frequency in Hz */ + +/*** + BOARD_InitBootClocks function + **/ + +#if defined(__cplusplus) +extern "C" { +#endif /* __cplusplus*/ + +/*! + * @brief This function executes default configuration of clocks. + * + */ +void BOARD_InitBootClocks(void); + +#if defined(__cplusplus) +} +#endif /* __cplusplus*/ + +/*** + Configuration BOARD_BootClockFRO12M ** + **/ +/*** + * Definitions for BOARD_BootClockFRO12M configuration + **/ +#define BOARD_BOOTCLOCKFRO12M_CORE_CLOCK 1200U /*!< Core clock frequency: 1200Hz */ + +/*** + * API for BOARD_BootClockFRO12M configuration + **/ +#if defined(__cplusplus) +extern "C" { +#endif /* __cplusplus*/ + +/*! + * @brief This function executes configuration of clocks. + * + */ +void BOARD_BootClockF
(mynewt-core) 04/04: hw/bsp: Add lpcxpresso55s28 BSP
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 commit edce0a697ed200d4386b552c2de78e287fb16910 Author: Jerzy Kasenberg AuthorDate: Thu Jun 29 23:40:19 2023 +0200 hw/bsp: Add lpcxpresso55s28 BSP This adds support for NXP LPCXPRESSO55S28 board. --- hw/bsp/lpcxpresso55s28/bsp.yml | 59 ++ hw/bsp/lpcxpresso55s28/debug.sh | 37 +++ hw/bsp/lpcxpresso55s28/include/bsp/bsp.h | 61 ++ hw/bsp/lpcxpresso55s28/pkg.yml | 38 +++ hw/bsp/lpcxpresso55s28/src/hal_bsp.c | 185 +++ hw/bsp/lpcxpresso55s28/syscfg.yml| 71 6 files changed, 451 insertions(+) diff --git a/hw/bsp/lpcxpresso55s28/bsp.yml b/hw/bsp/lpcxpresso55s28/bsp.yml new file mode 100644 index 0..d189a3de6 --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/bsp.yml @@ -0,0 +1,59 @@ +# +# 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. +# + +bsp.name: "LPCXpresso55s28: Freedom Development Platform" +bsp.url: https://www.nxp.com/design/development-boards/lpcxpresso-boards/lpcxpresso55s28-development-board:LPC55S28-EVK +bsp.maker: "NXP" +bsp.arch: cortex_m33 +bsp.compiler: compiler/arm-none-eabi-m33 +bsp.linkerscript: autogenerated +bsp.downloadscript: "@apache-mynewt-core/hw/scripts/download.sh" +bsp.debugscript: "@apache-mynewt-core/hw/bsp/lpcxpresso55s28/debug.sh" + +bsp.flash_map: +areas: +# System areas. +FLASH_AREA_BOOTLOADER: +device: 0 +offset: 0x +size: 40kB +FLASH_AREA_IMAGE_SCRATCH: +device: 0 +offset: 0xA000 +size: 8kB +FLASH_AREA_IMAGE_0: +device: 0 +offset: 0xC000 +size: 216kB +FLASH_AREA_IMAGE_1: +device: 0 +offset: 0x00042000 +size: 216kB + +# User areas +FLASH_AREA_REBOOT_LOG: +user_id: 0 +device: 0 +offset: 0x00078000 +size: 16kB +FLASH_AREA_NFFS: +user_id: 1 +device: 0 +offset: 0x0007C000 +size: 16kB diff --git a/hw/bsp/lpcxpresso55s28/debug.sh b/hw/bsp/lpcxpresso55s28/debug.sh new file mode 100755 index 0..fa069cecb --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/debug.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# 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. +# + +# Called with following variables set: +# - CORE_PATH is absolute path to @apache-mynewt-core +# - BSP_PATH is absolute path to hw/bsp/bsp_name +# - BIN_BASENAME is the path to prefix to target binary, +#.elf appended to name is the ELF file +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software +# - RESET set if target should be reset when attaching +# - NO_GDB set if we should not start gdb to debug +# + +. $CORE_PATH/hw/scripts/pyocd.sh + +FILE_NAME=$BIN_BASENAME.elf +TARGET=lpc55s28 +EXTRA_GDB_CMDS="mem 0x2003 0x rw nocache" + +pyocd_debug diff --git a/hw/bsp/lpcxpresso55s28/include/bsp/bsp.h b/hw/bsp/lpcxpresso55s28/include/bsp/bsp.h new file mode 100644 index 0..a36400566 --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/include/bsp/bsp.h @@ -0,0 +1,61 @@ +/* + * Licensed to
(mynewt-core) branch master updated: hw/mcu/stm32: Fix WFI in RAM for -O3
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 ed30c61ab hw/mcu/stm32: Fix WFI in RAM for -O3 ed30c61ab is described below commit ed30c61ab5ba21ec873b28a5a25205d2fba6151e Author: Jerzy Kasenberg AuthorDate: Sat Aug 17 12:21:44 2024 +0200 hw/mcu/stm32: Fix WFI in RAM for -O3 Even though function stm32_wfi_from_ram() has attribute to be placed in ram in -03 it can be inlined that can effectively run WFI from flash. Now additional attribute is added to make sure that it is not inlined. bx lr is also removed allowing compiler to make normal exit from function (which in most cases will be bx lr) Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32_common/src/hal_os_tick.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/mcu/stm/stm32_common/src/hal_os_tick.c b/hw/mcu/stm/stm32_common/src/hal_os_tick.c index ab512f0c4..a61e53b13 100644 --- a/hw/mcu/stm/stm32_common/src/hal_os_tick.c +++ b/hw/mcu/stm/stm32_common/src/hal_os_tick.c @@ -28,11 +28,10 @@ #endif #if MYNEWT_VAL(STM32_WFI_FROM_RAM) -__attribute__((section(".text_ram"))) void +__attribute__((section(".text_ram"),noinline)) void stm32_wfi_from_ram(void) { -__ASM volatile ("wfi\n" -"bx lr"); +__ASM volatile ("wfi"); } #endif
(mynewt-core) branch master updated (1f3f7c53a -> 393dc5abe)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 1f3f7c53a tinyusb: Add hardware initialization for stm32f3 new 77540fb4c hw/mcu/stm32: Add option to set HSE_VALUE from syscfg new 393dc5abe hw/bsp/stm32: Allow to specify HSE value in syscfg 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: hw/bsp/ada_feather_stm32f405/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/b-l072z-lrwan1/include/bsp/stm32l0xx_hal_conf.h | 4 +++- hw/bsp/b-l475e-iot01a/include/bsp/stm32l4xx_hal_conf.h | 4 +++- hw/bsp/black_vet6/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/bluepill/include/bsp/stm32f1xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f030r8/include/bsp/stm32f0xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f072rb/include/bsp/stm32f0xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f103rb/include/bsp/stm32f1xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f303k8/include/bsp/stm32f3xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f303re/include/bsp/stm32f3xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f401re/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f411re/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f413zh/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f439zi/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f746zg/include/bsp/stm32f7xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f767zi/include/bsp/stm32f7xx_hal_conf.h | 4 +++- hw/bsp/nucleo-g0b1re/include/bsp/stm32g0xx_hal_conf.h | 4 +++- hw/bsp/nucleo-g491re/include/bsp/stm32g4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-h723zg/include/bsp/stm32h7xx_hal_conf.h | 4 +++- hw/bsp/nucleo-l073rz/include/bsp/stm32l0xx_hal_conf.h | 4 +++- hw/bsp/nucleo-l476rg/include/bsp/stm32l4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-u575zi-q/include/bsp/stm32u5xx_hal_conf.h| 4 +++- hw/bsp/olimex-p103/include/bsp/stm32f1xx_hal_conf.h| 4 +++- hw/bsp/olimex_stm32-e407_devboard/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/p-nucleo-wb55-usbdongle/include/bsp/stm32wbxx_hal_conf.h| 4 +++- hw/bsp/p-nucleo-wb55/include/bsp/stm32wbxx_hal_conf.h | 4 +++- hw/bsp/stm32f3discovery/include/bsp/stm32f3xx_hal_conf.h | 4 +++- hw/bsp/stm32f411discovery/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/stm32f429discovery/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/stm32f4discovery/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/stm32f7discovery/include/bsp/stm32f7xx_hal_conf.h | 4 +++- hw/bsp/stm32l152discovery/include/bsp/stm32l1xx_hal_conf.h | 4 +++- hw/bsp/weact_g431cb/include/bsp/stm32g4xx_hal_conf.h | 4 +++- hw/mcu/stm/stm32f0xx/syscfg.yml| 4 hw/mcu/stm/stm32f1xx/syscfg.yml| 4 hw/mcu/stm/stm32f3xx/syscfg.yml| 4 hw/mcu/stm/stm32f4xx/syscfg.yml| 4 hw/mcu/stm/stm32f7xx/syscfg.yml| 4 hw/mcu/stm/stm32g0xx/syscfg.yml| 4 hw/mcu/stm/stm32g4xx/syscfg.yml| 4 hw/mcu/stm/stm32h7xx/syscfg.yml| 4 hw/mcu/stm/stm32l0xx/syscfg.yml| 4 hw/mcu/stm/stm32l1xx/syscfg.yml| 4 hw/mcu/stm/stm32l4xx/syscfg.yml| 4 hw/mcu/stm/stm32u5xx/syscfg.yml| 4 hw/mcu/stm/stm32wbxx/syscfg.yml| 4 46 files changed, 151 insertions(+), 33 deletions(-)
(mynewt-core) 01/02: hw/mcu/stm32: Add option to set HSE_VALUE from syscfg
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 commit 77540fb4c7891397dc45ffdb0e472afdbec9811b Author: Jerzy Kasenberg AuthorDate: Fri Jul 5 09:48:38 2024 +0200 hw/mcu/stm32: Add option to set HSE_VALUE from syscfg This adds STM32_CLOCK_HSE_VALUE that can be used to specify HSE frequency in mynewt style. It could be always set w macro HSE_VALUE but this makes it easier to manipulate this value in similar way as most other parameters. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f0xx/syscfg.yml | 4 hw/mcu/stm/stm32f1xx/syscfg.yml | 4 hw/mcu/stm/stm32f3xx/syscfg.yml | 4 hw/mcu/stm/stm32f4xx/syscfg.yml | 4 hw/mcu/stm/stm32f7xx/syscfg.yml | 4 hw/mcu/stm/stm32g0xx/syscfg.yml | 4 hw/mcu/stm/stm32g4xx/syscfg.yml | 4 hw/mcu/stm/stm32h7xx/syscfg.yml | 4 hw/mcu/stm/stm32l0xx/syscfg.yml | 4 hw/mcu/stm/stm32l1xx/syscfg.yml | 4 hw/mcu/stm/stm32l4xx/syscfg.yml | 4 hw/mcu/stm/stm32u5xx/syscfg.yml | 4 hw/mcu/stm/stm32wbxx/syscfg.yml | 4 13 files changed, 52 insertions(+) diff --git a/hw/mcu/stm/stm32f0xx/syscfg.yml b/hw/mcu/stm/stm32f0xx/syscfg.yml index 453317607..054f52223 100644 --- a/hw/mcu/stm/stm32f0xx/syscfg.yml +++ b/hw/mcu/stm/stm32f0xx/syscfg.yml @@ -49,6 +49,10 @@ syscfg.defs: description: 0 for xtal; 1 for input clock value: 0 +STM32_CLOCK_HSE_VALUE: +description: High-speed external clock speed in Hz +value: + STM32_CLOCK_HSI: description: Enable high-speed internal clock source value: 1 diff --git a/hw/mcu/stm/stm32f1xx/syscfg.yml b/hw/mcu/stm/stm32f1xx/syscfg.yml index d26493890..675e736e1 100644 --- a/hw/mcu/stm/stm32f1xx/syscfg.yml +++ b/hw/mcu/stm/stm32f1xx/syscfg.yml @@ -47,6 +47,10 @@ syscfg.defs: description: 0 for xtal; 1 for input clock value: 0 +STM32_CLOCK_HSE_VALUE: +description: High-speed external clock speed in Hz +value: + STM32_CLOCK_HSI: description: Enable high-speed internal clock source value: 1 diff --git a/hw/mcu/stm/stm32f3xx/syscfg.yml b/hw/mcu/stm/stm32f3xx/syscfg.yml index 97d1a81c8..d1936cb01 100644 --- a/hw/mcu/stm/stm32f3xx/syscfg.yml +++ b/hw/mcu/stm/stm32f3xx/syscfg.yml @@ -47,6 +47,10 @@ syscfg.defs: description: 0 for xtal; 1 for input clock value: 0 +STM32_CLOCK_HSE_VALUE: +description: High-speed external clock speed in Hz +value: + STM32_CLOCK_HSI: description: Enable high-speed internal clock source value: 1 diff --git a/hw/mcu/stm/stm32f4xx/syscfg.yml b/hw/mcu/stm/stm32f4xx/syscfg.yml index e6d136727..34c99d1eb 100644 --- a/hw/mcu/stm/stm32f4xx/syscfg.yml +++ b/hw/mcu/stm/stm32f4xx/syscfg.yml @@ -51,6 +51,10 @@ syscfg.defs: description: 0 for xtal; 1 for input clock value: 0 +STM32_CLOCK_HSE_VALUE: +description: High-speed external clock speed in Hz +value: + STM32_CLOCK_HSI: description: Enable high-speed internal clock source value: 1 diff --git a/hw/mcu/stm/stm32f7xx/syscfg.yml b/hw/mcu/stm/stm32f7xx/syscfg.yml index 9ba4dd0ab..698796afd 100644 --- a/hw/mcu/stm/stm32f7xx/syscfg.yml +++ b/hw/mcu/stm/stm32f7xx/syscfg.yml @@ -59,6 +59,10 @@ syscfg.defs: description: 0 for xtal; 1 for input clock value: 0 +STM32_CLOCK_HSE_VALUE: +description: High-speed external clock speed in Hz +value: + STM32_CLOCK_HSI: description: Enable high-speed internal clock source value: 1 diff --git a/hw/mcu/stm/stm32g0xx/syscfg.yml b/hw/mcu/stm/stm32g0xx/syscfg.yml index 7109837d0..bcab44d50 100644 --- a/hw/mcu/stm/stm32g0xx/syscfg.yml +++ b/hw/mcu/stm/stm32g0xx/syscfg.yml @@ -55,6 +55,10 @@ syscfg.defs: description: 0 for xtal; 1 for input clock value: 0 +STM32_CLOCK_HSE_VALUE: +description: High-speed external clock speed in Hz +value: + STM32_CLOCK_HSI: description: Enable high-speed internal clock source value: 1 diff --git a/hw/mcu/stm/stm32g4xx/syscfg.yml b/hw/mcu/stm/stm32g4xx/syscfg.yml index 5655870c9..b809ffd7f 100644 --- a/hw/mcu/stm/stm32g4xx/syscfg.yml +++ b/hw/mcu/stm/stm32g4xx/syscfg.yml @@ -55,6 +55,10 @@ syscfg.defs: description: 0 for xtal; 1 for input clock value: 0 +STM32_CLOCK_HSE_VALUE: +description: High-speed external clock speed in Hz +value: + STM32_CLOCK_HSI: description: Enable high-speed internal clock source value: 1 diff --git a/hw/mcu/stm/stm32h7xx/syscfg.yml b/hw/mcu/stm/stm32h7xx/syscfg.yml index 06f080fa4..622a888dd 100644 --- a/hw/mcu/stm/stm32h7xx/syscfg.yml +++ b/hw/mcu/stm/stm32h7xx/syscfg.yml @@ -58,6 +58,10 @@ syscfg.defs: description: 0 for xtal; 1 for input
(mynewt-core) 02/02: hw/bsp/stm32: Allow to specify HSE value in syscfg
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 commit 393dc5abe6c8ae61224916b4c82f09459459a78e Author: Jerzy Kasenberg AuthorDate: Fri Jul 5 09:58:32 2024 +0200 hw/bsp/stm32: Allow to specify HSE value in syscfg This modifies stm32xxx_hal_conf.h to use STM32_CLOCK_HSE_VALUE from syscfg if specified. This is done because evaluation boards often allow to modify how HSE is connected with solder bridges. Signed-off-by: Jerzy Kasenberg --- hw/bsp/ada_feather_stm32f405/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/b-l072z-lrwan1/include/bsp/stm32l0xx_hal_conf.h | 4 +++- hw/bsp/b-l475e-iot01a/include/bsp/stm32l4xx_hal_conf.h | 4 +++- hw/bsp/black_vet6/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/bluepill/include/bsp/stm32f1xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f030r8/include/bsp/stm32f0xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f072rb/include/bsp/stm32f0xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f103rb/include/bsp/stm32f1xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f303k8/include/bsp/stm32f3xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f303re/include/bsp/stm32f3xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f401re/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f411re/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f413zh/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f439zi/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f746zg/include/bsp/stm32f7xx_hal_conf.h | 4 +++- hw/bsp/nucleo-f767zi/include/bsp/stm32f7xx_hal_conf.h | 4 +++- hw/bsp/nucleo-g0b1re/include/bsp/stm32g0xx_hal_conf.h | 4 +++- hw/bsp/nucleo-g491re/include/bsp/stm32g4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-h723zg/include/bsp/stm32h7xx_hal_conf.h | 4 +++- hw/bsp/nucleo-l073rz/include/bsp/stm32l0xx_hal_conf.h | 4 +++- hw/bsp/nucleo-l476rg/include/bsp/stm32l4xx_hal_conf.h | 4 +++- hw/bsp/nucleo-u575zi-q/include/bsp/stm32u5xx_hal_conf.h| 4 +++- hw/bsp/olimex-p103/include/bsp/stm32f1xx_hal_conf.h| 4 +++- hw/bsp/olimex_stm32-e407_devboard/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/p-nucleo-wb55-usbdongle/include/bsp/stm32wbxx_hal_conf.h| 4 +++- hw/bsp/p-nucleo-wb55/include/bsp/stm32wbxx_hal_conf.h | 4 +++- hw/bsp/stm32f3discovery/include/bsp/stm32f3xx_hal_conf.h | 4 +++- hw/bsp/stm32f411discovery/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/stm32f429discovery/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/stm32f4discovery/include/bsp/stm32f4xx_hal_conf.h | 4 +++- hw/bsp/stm32f7discovery/include/bsp/stm32f7xx_hal_conf.h | 4 +++- hw/bsp/stm32l152discovery/include/bsp/stm32l1xx_hal_conf.h | 4 +++- hw/bsp/weact_g431cb/include/bsp/stm32g4xx_hal_conf.h | 4 +++- 33 files changed, 99 insertions(+), 33 deletions(-) diff --git a/hw/bsp/ada_feather_stm32f405/include/bsp/stm32f4xx_hal_conf.h b/hw/bsp/ada_feather_stm32f405/include/bsp/stm32f4xx_hal_conf.h index 546918ff6..2e4cc4964 100644 --- a/hw/bsp/ada_feather_stm32f405/include/bsp/stm32f4xx_hal_conf.h +++ b/hw/bsp/ada_feather_stm32f405/include/bsp/stm32f4xx_hal_conf.h @@ -114,7 +114,9 @@ *This value is used by the RCC HAL module to compute the system frequency *(when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) +#if defined (MYNEWT_VAL_STM32_CLOCK_HSE_VALUE) +#define HSE_VALUEMYNEWT_VAL(STM32_CLOCK_HSE_VALUE) +#elif !defined (HSE_VALUE) #define HSE_VALUE((uint32_t)1200) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ diff --git a/hw/bsp/b-l072z-lrwan1/include/bsp/stm32l0xx_hal_conf.h b/hw/bsp/b-l072z-lrwan1/include/bsp/stm32l0xx_hal_conf.h index 00140ca12..38b7272f7 100644 --- a/hw/bsp/b-l072z-lrwan1/include/bsp/stm32l0xx_hal_conf.h +++ b/hw/bsp/b-l072z-lrwan1/include/bsp/stm32l0xx_hal_conf.h @@ -91,7 +91,9 @@ *This value is used by the RCC HAL module to compute the system frequency *(when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) +#if defined (MYNEWT_VAL_STM32_CLOCK_HSE_VALUE) +#define HSE_VALUEMYNEWT_VAL(STM32_CLOCK_HSE_VALUE) +#elif !defined (HSE_VALUE) #define HSE_VALUE((uint32_t)800U) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ diff --git a/hw/bsp/b-l475e-iot01a/include/bsp/stm32l4xx_hal_conf.h b/hw/bsp/b-l475e-iot01a/include/bsp/stm32l4xx_hal_conf.h index f1396846d..9831de858 100644 --- a/hw/bsp/b-l475e-iot01a/include/bsp/stm32l4xx_hal_conf.h +++ b/hw/bsp/b-l475e-
(mynewt-core) branch master updated: tinyusb: Add hardware initialization for stm32f3
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 1f3f7c53a tinyusb: Add hardware initialization for stm32f3 1f3f7c53a is described below commit 1f3f7c53aff01c3e0d313a49718f015450633d75 Author: Jerzy Kasenberg AuthorDate: Fri Jul 5 20:07:37 2024 +0200 tinyusb: Add hardware initialization for stm32f3 STM32F3 while similar to STM32F1 has different interrupt settings. This also allows signal disconnect on D+ line during restart. Signed-off-by: Jerzy Kasenberg --- hw/usb/tinyusb/pkg.yml | 2 + .../tinyusb/stm32_fsdev/stm32f3/include/tusb_hw.h | 89 ++ hw/usb/tinyusb/stm32_fsdev/stm32f3/pkg.yml | 33 +++ .../tinyusb/stm32_fsdev/stm32f3/src/stm32_fsdev.c | 102 + hw/usb/tinyusb/stm32_fsdev/stm32f3/syscfg.yml | 46 ++ 5 files changed, 272 insertions(+) diff --git a/hw/usb/tinyusb/pkg.yml b/hw/usb/tinyusb/pkg.yml index df9554700..2f0e41830 100644 --- a/hw/usb/tinyusb/pkg.yml +++ b/hw/usb/tinyusb/pkg.yml @@ -56,6 +56,8 @@ pkg.deps.MCU_STM32U5: - "@apache-mynewt-core/hw/usb/tinyusb/synopsys" pkg.deps.MCU_STM32F1: - "@apache-mynewt-core/hw/usb/tinyusb/stm32_fsdev" +pkg.deps.MCU_STM32F3: +- "@apache-mynewt-core/hw/usb/tinyusb/stm32_fsdev/stm32f3" pkg.deps.MCU_STM32L0: - "@apache-mynewt-core/hw/usb/tinyusb/stm32_fsdev/stm32l0" pkg.deps.MCU_STM32WB: diff --git a/hw/usb/tinyusb/stm32_fsdev/stm32f3/include/tusb_hw.h b/hw/usb/tinyusb/stm32_fsdev/stm32f3/include/tusb_hw.h new file mode 100644 index 0..14dc7f2f0 --- /dev/null +++ b/hw/usb/tinyusb/stm32_fsdev/stm32f3/include/tusb_hw.h @@ -0,0 +1,89 @@ +/* + * 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. + */ + +#ifndef __TUSB_HW_H__ +#define __TUSB_HW_H__ + +#define CFG_TUSB_MCU OPT_MCU_STM32F3 + +#include + +#define CFG_TUSB_RHPORT0_SPEED OPT_MODE_FULL_SPEED + +#if defined(MYNEWT_VAL_USBD_CDC_NOTIFY_EP) +#define USBD_CDC_NOTIFY_EP MYNEWT_VAL(USBD_CDC_NOTIFY_EP) +#else +#define USBD_CDC_NOTIFY_EP 0x81 +#endif + +#if defined(MYNEWT_VAL_USBD_CDC_NOTIFY_EP_SIZE) +#define USBD_CDC_NOTIFY_EP_SIZE MYNEWT_VAL(USBD_CDC_NOTIFY_EP_SIZE) +#else +#define USBD_CDC_NOTIFY_EP_SIZE 0x08 +#endif + +#if defined(MYNEWT_VAL_USBD_CDC_DATA_OUT_EP) +#define USBD_CDC_DATA_OUT_EPMYNEWT_VAL(USBD_CDC_DATA_OUT_EP) +#else +#define USBD_CDC_DATA_OUT_EP0x01 +#endif + +#if defined(MYNEWT_VAL_USBD_CDC_DATA_IN_EP) +#define USBD_CDC_DATA_IN_EP MYNEWT_VAL(USBD_CDC_DATA_IN_EP) +#else +#define USBD_CDC_DATA_IN_EP 0x82 +#endif + +#if defined(MYNEWT_VAL_USBD_CDC_DATA_EP_SIZE) +#define USBD_CDC_DATA_EP_SIZE MYNEWT_VAL(USBD_CDC_DATA_EP_SIZE) +#else +#define USBD_CDC_DATA_EP_SIZE 0x40 +#endif + +#if defined(MYNEWT_VAL_USBD_HID_REPORT_EP) +#define USBD_HID_REPORT_EP MYNEWT_VAL(USBD_HID_REPORT_EP) +#else +#define USBD_HID_REPORT_EP 0x83 +#endif + +#if defined(MYNEWT_VAL_USBD_HID_REPORT_EP_SIZE) +#define USBD_HID_REPORT_EP_SIZE MYNEWT_VAL(USBD_HID_REPORT_EP_SIZE) +#else +#define USBD_HID_REPORT_EP_SIZE 0x10 +#endif + +#if defined(MYNEWT_VAL_USBD_HID_REPORT_EP_INTERVAL) +#define USBD_HID_REPORT_EP_INTERVAL MYNEWT_VAL(USBD_HID_REPORT_EP_INTERVAL) +#else +#define USBD_HID_REPORT_EP_INTERVAL 10 +#endif + +#if defined(MYNEWT_VAL_USBD_MSC_DATA_IN_EP) +#define USBD_MSC_DATA_IN_EP MYNEWT_VAL(USBD_MSC_DATA_IN_EP) +#else +#define USBD_MSC_DATA_IN_EP 0x86 +#endif + +#if defined(MYNEWT_VAL_USBD_MSC_DATA_OUT_EP) +#define USBD_MSC_DATA_OUT_EP MYNEWT_VAL(USBD_MSC_DATA_OUT_EP) +#else +#define USBD_MSC_DATA_OUT_EP 0x06 +#endif + +#endif diff --git a/hw/usb/tinyusb/stm32_fsdev/stm32f3/pkg.yml b/hw/usb/tinyusb/stm32_fsdev/stm32f3/pkg.yml new file mode 100644 index 0..094695c68 --- /dev/null +++ b/hw/usb/tinyusb/stm32_fsdev/stm32f3/pkg.yml @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distri
(mynewt-core) branch master updated: hw/mcu/stm32: Disable SysTick when RTC is selected as tick source
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 5a37e2248 hw/mcu/stm32: Disable SysTick when RTC is selected as tick source 5a37e2248 is described below commit 5a37e2248a41097c9958fa95ca17dc11f15cee38 Author: Jerzy Kasenberg AuthorDate: Sun Jul 7 00:03:42 2024 +0200 hw/mcu/stm32: Disable SysTick when RTC is selected as tick source When tick was provided by RTC instead of SysTick (default) and MCUboot used SysTick during boot, SysTick was never turned off and was running in application code. This resulted in two interrupts advancing mynewt OS tick so clock was running too fast. Now os_tick_init() from RTC code disables SysTick that could be started in bootloader. Same code was already applied to STM32F1 that has different RTC block. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32_common/src/hal_os_tick.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/mcu/stm/stm32_common/src/hal_os_tick.c b/hw/mcu/stm/stm32_common/src/hal_os_tick.c index 4a2869078..ab512f0c4 100644 --- a/hw/mcu/stm/stm32_common/src/hal_os_tick.c +++ b/hw/mcu/stm/stm32_common/src/hal_os_tick.c @@ -307,6 +307,12 @@ os_tick_init(uint32_t os_ticks_per_sec, int prio) .PeriphClockSelection = RCC_PERIPHCLK_RTC, .RTCClockSelection = RCC_RTCCLKSOURCE_LSE, }; +/* + * Disable SysTick so only one interrupt advances time. + * this is needed when bootloader enabled SysTick + */ +SysTick->CTRL = 0; + HAL_RCCEx_PeriphCLKConfig(&clock_init); /* Set the system tick priority. */
(mynewt-core) 01/02: hal_flash: Add hal_flash_sector_info
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 commit ff86f8f8f15a6b8679c516b6a627b9bb9d436c93 Author: Jerzy Kasenberg AuthorDate: Fri Jun 28 13:48:08 2024 +0200 hal_flash: Add hal_flash_sector_info In several places code was accessing hal_flash structure and then pointer to hff_sector_info to get sector information. Now function is exposed to make it things simpler. Signed-off-by: Jerzy Kasenberg --- hw/hal/include/hal/hal_flash.h | 15 +++ hw/hal/src/hal_flash.c | 15 +++ 2 files changed, 30 insertions(+) diff --git a/hw/hal/include/hal/hal_flash.h b/hw/hal/include/hal/hal_flash.h index 9aa8679ac..95807ddef 100644 --- a/hw/hal/include/hal/hal_flash.h +++ b/hw/hal/include/hal/hal_flash.h @@ -35,6 +35,21 @@ extern "C" { int hal_flash_ioctl(uint8_t flash_id, uint32_t cmd, void *args); +/** + * @brief Return information about flash sector + * + * @param flash_id The ID of the flash device to read from. + * @param sector_index The sector number to get information about. + * @param start_address A buffer to fill with start address of the sector. + * @param size A buffer for sector size. + * + * @return 0 on success; + * SYS_EINVAL on bad argument error; + * SYS_EIO on flash driver error. + */ +int hal_flash_sector_info(uint8_t flash_id, int sector_index, + uint32_t *start_address, uint32_t *size); + /** * @brief Reads a block of data from flash. * diff --git a/hw/hal/src/hal_flash.c b/hw/hal/src/hal_flash.c index b54f65b82..29cf72d49 100644 --- a/hw/hal/src/hal_flash.c +++ b/hw/hal/src/hal_flash.c @@ -77,6 +77,21 @@ hal_flash_erased_val(uint8_t flash_id) return hf->hf_erased_val; } +int +hal_flash_sector_info(uint8_t flash_id, int sector_index, + uint32_t *start_address, uint32_t *size) +{ +const struct hal_flash *hf; + +hf = hal_bsp_flash_dev(flash_id); +if (!hf) { +return SYS_EINVAL; +} + +return hf->hf_itf->hff_sector_info(hf, sector_index, start_address, size); +} + + uint32_t hal_flash_sector_size(const struct hal_flash *hf, int sec_idx) {
(mynewt-core) branch master updated (9bd0f022f -> 869218ffd)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 9bd0f022f kernel/os_task: Update doxygen comments in the header file new ff86f8f8f hal_flash: Add hal_flash_sector_info new 869218ffd flash_test: Add flash area access support 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: hw/hal/include/hal/hal_flash.h | 15 hw/hal/src/hal_flash.c | 15 test/flash_test/pkg.yml | 1 + test/flash_test/src/flash_test.c | 159 +-- 4 files changed, 134 insertions(+), 56 deletions(-)
(mynewt-core) 02/02: flash_test: Add flash area access support
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 commit 869218ffd0b44c4402311b75294b8f0c60489dd2 Author: Jerzy Kasenberg AuthorDate: Fri Jun 28 13:44:08 2024 +0200 flash_test: Add flash area access support There was "flash area" command that showed flash areas. To read or write actual flash area user had to specify flash id and offset from the beginning of flash to read data from flash area. Now when command start with 'flash area' id that used mean flash id will mean flash area id. Than makes it more convenient to read specific flash area. Additionally command that showed sectors from given flash is modified. It used to show up to 32 sectors with sized and later ... would follow. Now same size sectors are showed in more compact manner. Hexadecimal values were printed inconsistently with or without 0x prefix, now all hex values starts with 0x Signed-off-by: Jerzy Kasenberg --- test/flash_test/pkg.yml | 1 + test/flash_test/src/flash_test.c | 159 +-- 2 files changed, 104 insertions(+), 56 deletions(-) diff --git a/test/flash_test/pkg.yml b/test/flash_test/pkg.yml index 3d5226598..ca2045060 100644 --- a/test/flash_test/pkg.yml +++ b/test/flash_test/pkg.yml @@ -26,6 +26,7 @@ pkg.deps: - "@apache-mynewt-core/kernel/os" - "@apache-mynewt-core/hw/hal" - "@apache-mynewt-core/sys/shell" +- "@apache-mynewt-core/util/parse" pkg.req_apis: - console diff --git a/test/flash_test/src/flash_test.c b/test/flash_test/src/flash_test.c index f1b975072..f9a89d48a 100644 --- a/test/flash_test/src/flash_test.c +++ b/test/flash_test/src/flash_test.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,19 @@ static struct shell_cmd flash_cmd_struct = static struct shell_cmd flash_speed_cli_struct = SHELL_CMD_EXT("flash_speed", flash_speed_test_cli, NULL); +static void +dump_sector_range_info(struct streamer *streamer, int start_sector, uint32_t start_address, + int sector_count, uint32_t sector_size) +{ +if (sector_count == 1) { +streamer_printf(streamer, " %d: 0x%lx\n", start_sector, +(long unsigned int)sector_size); +} else { +streamer_printf(streamer, " %d-%d: 0x%lx (total 0x%x)\n", start_sector, start_sector + sector_count - 1, +(long unsigned int)sector_size, sector_size * sector_count); +} +} + static int flash_cli_cmd(const struct shell_cmd *cmd, int argc, char **argv, struct streamer *streamer) @@ -46,43 +60,70 @@ flash_cli_cmd(const struct shell_cmd *cmd, int argc, char **argv, const struct hal_flash *hf; uint32_t off = 0; uint32_t sz = 1; +uint32_t fa_off = 0; int sec_cnt; int i; -int devid; +int devid = 0; +int rc; char *eptr; char tmp_buf[32]; char pr_str[80]; +/* arg_idx points to first argument after 'flash' */ +int arg_idx = 1; if (argc > 1 && (!strcmp(argv[1], "?") || !strcmp(argv[1], "help"))) { streamer_printf(streamer, "Commands Available\n"); -streamer_printf(streamer, "flash [flash-id] -- dumps sector map \n"); -streamer_printf(streamer, "flash read -- reads bytes from flash \n"); -streamer_printf(streamer, "flash write -- writes incrementing data pattern 0-8 to flash \n"); -streamer_printf(streamer, "flash erase -- erases flash \n"); -streamer_printf(streamer, "flash area -- shows flash areas \n"); +streamer_printf(streamer, "flash [] -- dumps sector map\n"); +streamer_printf(streamer, "flash [area] read -- reads bytes from flash\n"); +streamer_printf(streamer, +"flash [area] write -- writes incrementing data pattern 0-8 to flash\n"); +streamer_printf(streamer, "flash [area] erase -- erases flash\n"); +streamer_printf(streamer, "flash area -- shows flash areas\n"); return 0; } -if (argc > 1 && strcmp(argv[1], "area") == 0) { -streamer_printf(streamer, "AreaID FlashId Offset Size\n"); -for (i = 0; i < ARRAY_SIZE(sysflash_map_dflt); ++i) { -streamer_printf(streamer, "%6u %7u 0x%08x 0x%06x\n", sysflash_map_dflt[i].fa_id, -sysflash_map_dflt[i].fa_device_id, -(unsigned)sysflash_map_dflt[i].fa_off, -(unsigned)sysflas
(mynewt-core) branch master updated: util/stream: Add ostream_write_str function
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 297da0533 util/stream: Add ostream_write_str function 297da0533 is described below commit 297da05336a83fd159175fe4f75c548d584606cc Author: Jerzy Kasenberg AuthorDate: Mon Jul 1 14:34:06 2024 +0200 util/stream: Add ostream_write_str function This is simple utility function to write null terminated string to stream. Function is already referenced in msc_fat_view. --- util/stream/include/stream/stream.h | 10 ++ util/stream/src/stream.c| 7 +++ 2 files changed, 17 insertions(+) diff --git a/util/stream/include/stream/stream.h b/util/stream/include/stream/stream.h index a28c94d3d..ac23e361c 100644 --- a/util/stream/include/stream/stream.h +++ b/util/stream/include/stream/stream.h @@ -249,4 +249,14 @@ ostream_write_uint32(struct out_stream *ostream, uint32_t data) return ostream_write(ostream, (uint8_t *)&data, 4, false); } +/** + * Write null terminated string to output stream + * + * @param ostream - stream to write to + * @param str - string to write to stream + * + * @return number of bytes written, negative on error + */ +int ostream_write_str(struct out_stream *ostream, const char *str); + #endif /* H_STREAM_ */ diff --git a/util/stream/src/stream.c b/util/stream/src/stream.c index fe7605157..80473505b 100644 --- a/util/stream/src/stream.c +++ b/util/stream/src/stream.c @@ -136,3 +136,10 @@ stream_pump(struct in_stream *istream, struct out_stream *ostream, uint32_t coun } return pumped; } + +int +ostream_write_str(struct out_stream *ostream, const char *str) +{ +int len = strlen(str); +return ostream_write(ostream, (const uint8_t *)str, len, false); +}
(mynewt-core) branch master updated: util/stream: Update OSTREAM_DEF and ISTREAM_DEF
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 616d3e60f util/stream: Update OSTREAM_DEF and ISTREAM_DEF 616d3e60f is described below commit 616d3e60fe7febda1c0969da276affef312e8017 Author: Jerzy Kasenberg AuthorDate: Tue Jul 2 08:18:36 2024 +0200 util/stream: Update OSTREAM_DEF and ISTREAM_DEF OSTREAM_DEF macro is utility macro for creating function table for output stream with function names derived from stream type name. i.e. OSTREAM_DEF(mem) would create function table like this: const struct out_stream_vft mem_vft = { .write = mem_write, .flush = mem_flush, .pump_from = mem_pump_from, } along with prototypes: static int mem_write(struct out_stream *, const uint8_t *, uint32_t); static int mem_flush(struct out_stream *); static int mem_pump_from(struct out_stream *, struct in_stream *, uint32_t); last function was late addition and is optional This change removes requirement to define pump_from function from OSTREAM_DEF User still can create function table with pump_from function without using macro if pumping is required. Same applies to ISTREAM_DEF --- util/stream/include/stream/stream.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/util/stream/include/stream/stream.h b/util/stream/include/stream/stream.h index 61137951f..a28c94d3d 100644 --- a/util/stream/include/stream/stream.h +++ b/util/stream/include/stream/stream.h @@ -127,11 +127,10 @@ struct mem_in_stream { #define OSTREAM_DEF(type) \ static int type ## _write(struct out_stream *ostream, const uint8_t *buf, uint32_t count); \ static int type ## _flush(struct out_stream *ostream); \ -static int type ## _pump_from(struct out_stream *ostream, struct in_stream *istream, uint32_t count); \ const struct out_stream_vft type ## _vft = { \ .write = type ## _write, \ .flush = type ## _flush, \ -.pump_from = type ## _pump_from, \ +.pump_from = NULL, \ } #define OSTREAM_VFT(type, _write, _flush, _pump) \ @@ -156,7 +155,7 @@ struct mem_in_stream { const struct in_stream_vft type ## _vft = { \ .available = type ## _available,\ .read = type ## _read, \ -.pump_to = type ## _pump_to,\ +.pump_to = NULL,\ } #define ISTREAM(type, name) \
(mynewt-core) branch master updated: hw/bsp/nucleo-l073: Fix flash map scratch area
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 2c7803131 hw/bsp/nucleo-l073: Fix flash map scratch area 2c7803131 is described below commit 2c780313142f81f4966b3838024186396df6e9d8 Author: Jerzy Kasenberg AuthorDate: Sun Jun 30 16:54:07 2024 +0200 hw/bsp/nucleo-l073: Fix flash map scratch area STM32L0 has 128 byte page, this would allow for 16kB of slot0/1 size to be supported by mcuboot. For this reason flash page is artificially reported to mcuboot to be 2kB. Scratch area was put in flash with size 1kB making in unusable for mcuboot. This could be fixed by: - removing this limit from mcuboot (most reasonable solution) - setting page size to be 1kB instead of 2 - changing flash area layout to have at least 2kB scratch sector Third option is chosen because flash area layout was already left with some holes. Now scratch has 4kB Reboot log is reduced to 2kB since current implementation of reboot_log uses only one sector so 75% was unusable anyway Signed-off-by: Jerzy Kasenberg --- hw/bsp/nucleo-l073rz/bsp.yml | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/bsp/nucleo-l073rz/bsp.yml b/hw/bsp/nucleo-l073rz/bsp.yml index 97cc97920..765bd5f4d 100644 --- a/hw/bsp/nucleo-l073rz/bsp.yml +++ b/hw/bsp/nucleo-l073rz/bsp.yml @@ -43,15 +43,15 @@ bsp.flash_map: size: 72kB FLASH_AREA_IMAGE_SCRATCH: device: 0 -offset: 0x08005C00 -size: 1kB +offset: 0x0802f000 +size: 4kB # User areas. FLASH_AREA_REBOOT_LOG: user_id: 0 device: 0 -offset: 0x0802c000 -size: 8kB +offset: 0x0802E800 +size: 2kB FLASH_AREA_NFFS: user_id: 1 device: 0
(mynewt-core) branch master updated: util/crc: Add option for crc16_ccitt without table
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 a01518ce6 util/crc: Add option for crc16_ccitt without table a01518ce6 is described below commit a01518ce681b89b5925233c762920474acdb1c5c Author: Jerzy Kasenberg AuthorDate: Sun Jun 30 12:58:30 2024 +0200 util/crc: Add option for crc16_ccitt without table This adds crc16_ccitt() version without table. It makes it slower but can reduce flash usage about 512 bytes. Default still uses table but can be disabled with UTIL_CRC_CRC16_CCITT_USE_TABLE: 0 Signed-off-by: Jerzy Kasenberg --- util/crc/src/crc16.c | 24 +++- util/crc/syscfg.yml | 23 +++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/util/crc/src/crc16.c b/util/crc/src/crc16.c index 6ece41909..fce23a068 100644 --- a/util/crc/src/crc16.c +++ b/util/crc/src/crc16.c @@ -26,10 +26,12 @@ */ #include +#include #include "crc/crc16.h" -/* CRC16 implementation acording to CCITT standards */ +/* CRC16 implementation according to CCITT standards */ +#if MYNEWT_VAL(UTIL_CRC_CRC16_CCITT_USE_TABLE) static const uint16_t crc16tab[256]= { 0x,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7, 0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef, @@ -81,3 +83,23 @@ crc16_ccitt(uint16_t initial_crc, const void *buf, int len) return crc; } + +#else + +uint16_t +crc16_ccitt(uint16_t initial_crc, const void *buf, int len) +{ +uint8_t x; +uint16_t crc = initial_crc; +const uint8_t *ptr = buf; +int i; + +for (i = 0; i < len; ++i) { +x = (crc >> 8) ^ ptr[i]; +x ^= x >> 4; +crc = (crc << 8) ^ ((uint16_t)(x << 12)) ^ ((uint16_t)(x << 5)) ^ ((uint16_t)x); +} +return crc; +} + +#endif diff --git a/util/crc/syscfg.yml b/util/crc/syscfg.yml new file mode 100644 index 0..e6231abd8 --- /dev/null +++ b/util/crc/syscfg.yml @@ -0,0 +1,23 @@ +# 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. + +syscfg.defs: +UTIL_CRC_CRC16_CCITT_USE_TABLE: +description: > +Use table for calculation CRC to make it faster. +Set it 0 to reduce code size. +value: 1
(mynewt-core) branch master updated (494057320 -> f8422a595)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 494057320 hw/mcu/stm32f3: Fix flash write add f8422a595 spiflash: Add missing include No new revisions were added by this update. Summary of changes: hw/drivers/flash/spiflash/include/spiflash/spiflash.h | 1 + 1 file changed, 1 insertion(+)
(mynewt-core) branch master updated: hw/mcu/stm32f3: Fix flash write
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 494057320 hw/mcu/stm32f3: Fix flash write 494057320 is described below commit 4940573209f2e7d2758a2ea24b159a7903201f45 Author: Jerzy Kasenberg AuthorDate: Sat Jun 29 16:14:30 2024 +0200 hw/mcu/stm32f3: Fix flash write STM32_HAL_FLASH_INIT macro was empty unlike all other implementations leaving embedded flash locked. stm32_mcu_flash_erase_sector() unlocked flash before erase and locked it afterwards. Erase flash worked but write did not since write is done in common stm32 code that assumed that flash is unlocked. Now flash is unlocked at the start and not locked during erase. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h | 5 - hw/mcu/stm/stm32f3xx/src/hal_flash.c | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h b/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h index f6f231a31..03149901a 100644 --- a/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h +++ b/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h @@ -83,7 +83,10 @@ struct stm32_hal_spi_cfg { #include "stm32f3xx_hal_def.h" #include "stm32f3xx_hal_flash.h" #include "stm32f3xx_hal_flash_ex.h" -#define STM32_HAL_FLASH_INIT() +#define STM32_HAL_FLASH_INIT()\ +do { \ +HAL_FLASH_Unlock(); \ +} while (0) #define FLASH_PROGRAM_TYPE FLASH_TYPEPROGRAM_HALFWORD #define STM32_HAL_FLASH_CLEAR_ERRORS()\ do { \ diff --git a/hw/mcu/stm/stm32f3xx/src/hal_flash.c b/hw/mcu/stm/stm32f3xx/src/hal_flash.c index 9cb1813d7..b4d8be293 100644 --- a/hw/mcu/stm/stm32f3xx/src/hal_flash.c +++ b/hw/mcu/stm/stm32f3xx/src/hal_flash.c @@ -32,11 +32,9 @@ stm32_mcu_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_addres erase.PageAddress = sector_address; erase.NbPages = 1; -HAL_FLASH_Unlock(); if (HAL_OK == HAL_FLASHEx_Erase(&erase, &errorPage)) { rc = 0; } -HAL_FLASH_Lock(); return rc; }
(mynewt-core) branch master updated: flash_test: Show printable characters along when read
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 ae7765449 flash_test: Show printable characters along when read ae7765449 is described below commit ae7765449f7dfdb806a587bca403f4c0ea3e308c Author: Jerzy Kasenberg AuthorDate: Wed Jun 26 23:58:34 2024 +0200 flash_test: Show printable characters along when read So far flash read displayed data in hexadecimal format only. Now additional ascii values are shown for printable characters, which is common practice Old format: compat> flash 0 read 0x1d110100 0x20 Read 0x1d110100 + 32 0x1d110100: 0x09 0x0f 0x00 0x6c 0x6f 0x67 0x2d 0x73 0x1d110108: 0x74 0x6f 0x72 0x61 0x67 0x65 0x20 0xff New format: compat> flash 0 read 0x1d110100 0x20 Read 0x1d110100 + 32 0x1d110100: 0x09 0x0f 0x00 0x6c 0x6f 0x67 0x2d 0x73 ...log-s 0x1d110108: 0x74 0x6f 0x72 0x61 0x67 0x65 0x20 0xff torage . Signed-off-by: Jerzy Kasenberg Signed-off-by: Jerzy Kasenberg --- test/flash_test/src/flash_test.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/test/flash_test/src/flash_test.c b/test/flash_test/src/flash_test.c index ef5fa8303..f1b975072 100644 --- a/test/flash_test/src/flash_test.c +++ b/test/flash_test/src/flash_test.c @@ -26,6 +26,7 @@ #include #include #include +#include static int flash_cli_cmd(const struct shell_cmd *cmd, int argc, char **argv, struct streamer *streamer); @@ -48,7 +49,6 @@ flash_cli_cmd(const struct shell_cmd *cmd, int argc, char **argv, int sec_cnt; int i; int devid; -int soff; char *eptr; char tmp_buf[32]; char pr_str[80]; @@ -157,21 +157,20 @@ flash_cli_cmd(const struct shell_cmd *cmd, int argc, char **argv, (long unsigned int) off); break; } -for (i = 0, soff = 0; i < sec_cnt; i++) { -soff += snprintf(pr_str + soff, sizeof(pr_str) - soff, - "0x%02x ", tmp_buf[i] & 0xff); -if (i % 8 == 7) { -streamer_printf(streamer, " 0x%lx: %s\n", - (long unsigned int) off, pr_str); -soff = 0; -off += 8; +for (i = 0; i < sec_cnt; i++) { +int n = i & 7; +if (n == 0) { +streamer_printf(streamer, " 0x%lx: ", (long unsigned int)off + i); +} +snprintf(pr_str + n * 5, 6, "0x%02x ", tmp_buf[i] & 0xff); +pr_str[41 + n] = isprint((uint8_t)tmp_buf[i]) ? tmp_buf[i] : '.'; +if (n == 7 || i + 1 == sec_cnt) { +pr_str[41 + n + 1] = '\0'; +memset(pr_str + (5 * n + 5), ' ', 5 * (7 - n) + 1); +streamer_printf(streamer, "%s\n", pr_str); } } -if (i % 8) { -streamer_printf(streamer, " 0x%lx: %s\n", - (long unsigned int) off, pr_str); -off += i; -} +off += sec_cnt; } } else if (!strcmp(argv[2], "write")) { streamer_printf(streamer, "Write 0x%lx + %lx\n",
(mynewt-core) branch master updated: tinyusb/msc_fat_view: Fix constnes of link table entries
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 540aa34b0 tinyusb/msc_fat_view: Fix constnes of link table entries 540aa34b0 is described below commit 540aa34b04fc0ffec1f7e23f187a5a2b76bb3b67 Author: Jerzy Kasenberg AuthorDate: Wed Jun 26 00:49:17 2024 +0200 tinyusb/msc_fat_view: Fix constnes of link table entries qualifier const was incorrectly added to what pointed value instead of pointer itself. Pointer should go to section that is put in flash. For PIC32 this non-constant pointers were put in wrong state as if they in RAM (although addresses were in flash) and init code tried to initialize them resulting in access violation. Signed-off-by: Jerzy Kasenberg --- hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h b/hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h index 3895467b4..88aaa7af3 100644 --- a/hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h +++ b/hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h @@ -108,7 +108,7 @@ void msc_fat_view_media_insert(void); .delete_entry = delete_fun,\ .valid = valid_fun,\ }; \ -const file_entry_t *entry ## _ptr ROOT_DIR_SECTION = &entry; +file_entry_t *const entry ## _ptr ROOT_DIR_SECTION = &entry; /** * Macro to add static write handlers @@ -118,7 +118,7 @@ void msc_fat_view_media_insert(void); .write_sector = _write_sector, \ .file_written = _file_written, \ }; \ -const msc_fat_view_write_handler_t *entry ## _ptr WRITE_HANDLER_SECTION = &entry; +msc_fat_view_write_handler_t *const entry ## _ptr WRITE_HANDLER_SECTION = &entry; #define TABLE_START(table) __ ## table ## _start__ #define TABLE_END(table) __ ## table ## _end__
(mynewt-core) 03/03: sys/log_fcb: Relax write alignment restriction
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 commit a09610139bafc095312a6e194f4137a50cc58e5f Author: Jerzy Kasenberg AuthorDate: Wed Jun 26 12:53:17 2024 +0200 sys/log_fcb: Relax write alignment restriction Code was limiting usage of FCB and FCB2 to flashes with at most 8 bytes write alignment. There was no actual reason to have this limitation and now log can be used with STM32H7 and STM32U5 boards that have alignment 16 or 32 bytes. Signed-off-by: Jerzy Kasenberg --- sys/log/full/src/log_fcb.c | 4 ++-- sys/log/full/src/log_fcb2.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/log/full/src/log_fcb.c b/sys/log/full/src/log_fcb.c index 5f4df8e31..82bd1a415 100644 --- a/sys/log/full/src/log_fcb.c +++ b/sys/log/full/src/log_fcb.c @@ -27,8 +27,8 @@ #include "fcb/fcb.h" #include "log/log.h" -/* Assume the flash alignment requirement is no stricter than 8. */ -#define LOG_FCB_MAX_ALIGN 8 +/* Assume the flash alignment requirement is no stricter than 32. */ +#define LOG_FCB_MAX_ALIGN 32 static int log_fcb_rtr_erase(struct log *log); diff --git a/sys/log/full/src/log_fcb2.c b/sys/log/full/src/log_fcb2.c index c8a5d07b2..826150a12 100644 --- a/sys/log/full/src/log_fcb2.c +++ b/sys/log/full/src/log_fcb2.c @@ -27,8 +27,8 @@ #include "log/log.h" #include "fcb/fcb2.h" -/* Assume the flash alignment requirement is no stricter than 8. */ -#define LOG_FCB2_MAX_ALIGN 8 +/* Assume the flash alignment requirement is no stricter than 32. */ +#define LOG_FCB2_MAX_ALIGN 32 static int log_fcb2_rtr_erase(struct log *log);
(mynewt-core) branch master updated (6177f10f6 -> a09610139)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 6177f10f6 stm32: Fix flash write new 47a215ddf fs/fcb: Add support for flash with write size > 8 new 526237ba3 fs/fcb2: Fix data access for flash with big data alignment new a09610139 sys/log_fcb: Relax write alignment restriction 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: fs/fcb/src/fcb.c| 2 +- fs/fcb/src/fcb_append.c | 4 ++-- fs/fcb/src/fcb_getnext.c| 4 ++-- fs/fcb/src/fcb_rotate.c | 2 +- fs/fcb2/src/fcb_getnext.c | 3 ++- sys/log/full/src/log_fcb.c | 4 ++-- sys/log/full/src/log_fcb2.c | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-)
(mynewt-core) 01/03: fs/fcb: Add support for flash with write size > 8
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 commit 47a215ddfb2e18715d05f87e9666238984e8b4b2 Author: Jerzy Kasenberg AuthorDate: Tue Jun 25 15:59:39 2024 +0200 fs/fcb: Add support for flash with write size > 8 Most of the code already respected flash alignment restriction. For write restriction greater then 8, space reserved for fcb_disk_area has to be adjusted when fe_elem_off is initialized. Signed-off-by: Jerzy Kasenberg --- fs/fcb/src/fcb.c | 2 +- fs/fcb/src/fcb_append.c | 4 ++-- fs/fcb/src/fcb_getnext.c | 4 ++-- fs/fcb/src/fcb_rotate.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/fcb/src/fcb.c b/fs/fcb/src/fcb.c index 0fe7e1f5b..4e18fb867 100644 --- a/fs/fcb/src/fcb.c +++ b/fs/fcb/src/fcb.c @@ -80,7 +80,7 @@ fcb_init(struct fcb *fcb) fcb->f_align = max_align; fcb->f_oldest = oldest_fap; fcb->f_active.fe_area = newest_fap; -fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area); +fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); fcb->f_active_id = newest; /* Require alignment to be a power of two. Some code depends on this diff --git a/fs/fcb/src/fcb_append.c b/fs/fcb/src/fcb_append.c index 6d1bc86a8..bc44b13ee 100644 --- a/fs/fcb/src/fcb_append.c +++ b/fs/fcb/src/fcb_append.c @@ -61,7 +61,7 @@ fcb_append_to_scratch(struct fcb *fcb) return rc; } fcb->f_active.fe_area = fa; -fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area); +fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); fcb->f_active_id++; return FCB_OK; } @@ -99,7 +99,7 @@ fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *append_loc) goto err; } fcb->f_active.fe_area = fa; -fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area); +fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); fcb->f_active_id++; } diff --git a/fs/fcb/src/fcb_getnext.c b/fs/fcb/src/fcb_getnext.c index 6ca08ce85..2cf97f696 100644 --- a/fs/fcb/src/fcb_getnext.c +++ b/fs/fcb/src/fcb_getnext.c @@ -66,7 +66,7 @@ fcb_getnext_nolock(struct fcb *fcb, struct fcb_entry *loc) /* * If offset is zero, we serve the first entry from the area. */ -loc->fe_elem_off = sizeof(struct fcb_disk_area); +loc->fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); rc = fcb_elem_info(fcb, loc); } else { rc = fcb_getnext_in_area(fcb, loc); @@ -94,7 +94,7 @@ next_sector: return FCB_ERR_NOVAR; } loc->fe_area = fcb_getnext_area(fcb, loc->fe_area); -loc->fe_elem_off = sizeof(struct fcb_disk_area); +loc->fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); rc = fcb_elem_info(fcb, loc); switch (rc) { case 0: diff --git a/fs/fcb/src/fcb_rotate.c b/fs/fcb/src/fcb_rotate.c index 7135fa674..6ccba8219 100644 --- a/fs/fcb/src/fcb_rotate.c +++ b/fs/fcb/src/fcb_rotate.c @@ -46,7 +46,7 @@ fcb_rotate(struct fcb *fcb) goto out; } fcb->f_active.fe_area = fap; -fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area); +fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); fcb->f_active_id++; } fcb->f_oldest = fcb_getnext_area(fcb, fcb->f_oldest);
(mynewt-core) 02/03: fs/fcb2: Fix data access for flash with big data alignment
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 commit 526237ba31bce4accb6058b09183c4de33dc7e74 Author: Jerzy Kasenberg AuthorDate: Wed Jun 26 12:49:43 2024 +0200 fs/fcb2: Fix data access for flash with big data alignment In one place size of structure that was stored in flash was assumed to be FCB2_ENTRY_SIZE while in fact it was greater for flash with write alignment >= 8. Now entry locate takes into account actual space needed by entry. Signed-off-by: Jerzy Kasenberg --- fs/fcb2/src/fcb_getnext.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fcb2/src/fcb_getnext.c b/fs/fcb2/src/fcb_getnext.c index ea18be4f7..8a4f8f305 100644 --- a/fs/fcb2/src/fcb_getnext.c +++ b/fs/fcb2/src/fcb_getnext.c @@ -36,7 +36,8 @@ fcb2_getnext_in_area(struct fcb2 *fcb, struct fcb2_entry *loc) fcb2_len_in_flash(loc->fe_range, 2); /* Possible entry offset for next data */ next_entry_offset = fcb->f_active.fe_range->fsr_sector_size - -(FCB2_ENTRY_SIZE * (loc->fe_entry_num + 1)); +(fcb2_len_in_flash(fcb->f_active.fe_range, FCB2_ENTRY_SIZE) * + (loc->fe_entry_num + 1)); loc->fe_data_len = 0; loc->fe_entry_num++; /* If there is no space for next entry just finish search */
(mynewt-core) branch master updated: stm32: Fix flash write
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 6177f10f6 stm32: Fix flash write 6177f10f6 is described below commit 6177f10f67ca96ef52678796c08f298d98359a7a Author: Jerzy Kasenberg AuthorDate: Tue Jun 25 15:13:02 2024 +0200 stm32: Fix flash write Code could corrupt stack when writing to flash that requires write of size greater then 1. memset function used for filling buffer so writes have correct number of bytes incorrectly cast buffer to (uint32_t *) and then added number of bytes resulting in possible write to unintended stack memory. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32_common/src/hal_flash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mcu/stm/stm32_common/src/hal_flash.c b/hw/mcu/stm/stm32_common/src/hal_flash.c index d4f04ac51..7acf028f2 100644 --- a/hw/mcu/stm/stm32_common/src/hal_flash.c +++ b/hw/mcu/stm/stm32_common/src/hal_flash.c @@ -120,7 +120,7 @@ stm32_flash_write_linear(const struct hal_flash *dev, uint32_t address, for (i = 0; i < num_words; i++) { if (num_bytes < align) { memcpy(&val, &((uint8_t *)src)[i * align], num_bytes); -memset((uint32_t *)&val + num_bytes, dev->hf_erased_val, align - num_bytes); +memset((uint8_t *)&val + num_bytes, dev->hf_erased_val, align - num_bytes); } else { memcpy(&val, &((uint8_t *)src)[i * align], align); }
(mynewt-core) branch master updated: ci: check_style: Fix awk filter for nimble
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 820bcbc19 ci: check_style: Fix awk filter for nimble 820bcbc19 is described below commit 820bcbc190701f903eac49993eef9ad1f24ef9f4 Author: Jerzy Kasenberg AuthorDate: Mon Jun 24 09:37:15 2024 +0200 ci: check_style: Fix awk filter for nimble nimble repository uses same check_style.py but calls it from different location resulting in missing uncrasitfy.awk script This explicitly sets path to awk script so it is found always regardless of how check_style.py was executd Signed-off-by: Jerzy Kasenberg --- .github/check_style.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/check_style.py b/.github/check_style.py index 471b88f0e..de5112cd0 100755 --- a/.github/check_style.py +++ b/.github/check_style.py @@ -26,6 +26,8 @@ import tempfile import sys INFO_URL = "https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md"; +# uncrustify.awk is one directory level above current script +uncrustify_awk = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "uncrustify.awk") def get_lines_range(m: re.Match) -> range: first = int(m.group(1)) @@ -61,7 +63,7 @@ def check_file(fname: str, commit: str, upstream: str) -> list[str]: in_chunk = False for s in run_cmd(f"uncrustify -q -c uncrustify.cfg -f {tmpf.name} | " - f"awk -f uncrustify.awk | " + f"awk -f {uncrustify_awk} | " f"diff -u0 -p {tmpf.name} - || true"): m = re.match(r"^@@ -(\d+)(?:,(\d+))? \+\d+(?:,\d+)? @@", s) if not m:
(mynewt-core) branch master updated: tinyusb/cdc_console: Fix syscfg.yml doubled section
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 87116ffd7 tinyusb/cdc_console: Fix syscfg.yml doubled section 87116ffd7 is described below commit 87116ffd790918fd0ed7484964641946ad25159d Author: Jerzy Kasenberg AuthorDate: Fri Jun 21 12:05:08 2024 +0200 tinyusb/cdc_console: Fix syscfg.yml doubled section syscfg.defs section was added twice and now text is rearranged Signed-off-by: Jerzy Kasenberg --- hw/usb/tinyusb/cdc_console/syscfg.yml | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/usb/tinyusb/cdc_console/syscfg.yml b/hw/usb/tinyusb/cdc_console/syscfg.yml index b04d0a2ce..0fe967427 100755 --- a/hw/usb/tinyusb/cdc_console/syscfg.yml +++ b/hw/usb/tinyusb/cdc_console/syscfg.yml @@ -22,15 +22,14 @@ syscfg.defs: description: String for CDC/Console interface value: '"Mynewt console"' -syscfg.vals: -USBD_CDC_CONSOLE: 1 - -syscfg.defs: CONSOLE_USB_CDC_SYSINIT_STAGE: description: > Initialize USB CDC Console at the specified sysinit level value: 502 +syscfg.vals: +USBD_CDC_CONSOLE: 1 + syscfg.restrictions: - "USBD_CDC_CONSOLE" - CONSOLE_USB_CDC_SYSINIT_STAGE > USBD_SYSINIT_STAGE
(mynewt-core) branch master updated: tinyusb/msc_fat_view: Fix update handler
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 b057a93b0 tinyusb/msc_fat_view: Fix update handler b057a93b0 is described below commit b057a93b0f1c264569b211330442661a0c751efa Author: Jerzy Kasenberg AuthorDate: Tue Jun 18 21:44:38 2024 +0200 tinyusb/msc_fat_view: Fix update handler When update handler for writing images to flash was moved to separate file pkg.yml was changed to have update_handler.c included conditionally but syscfg definition was not commited This fixes the problem and updates can be used again Signed-off-by: Jerzy Kasenberg --- hw/usb/tinyusb/msc_fat_view/syscfg.yml | 4 1 file changed, 4 insertions(+) diff --git a/hw/usb/tinyusb/msc_fat_view/syscfg.yml b/hw/usb/tinyusb/msc_fat_view/syscfg.yml index a3c773d7a..447feecf3 100644 --- a/hw/usb/tinyusb/msc_fat_view/syscfg.yml +++ b/hw/usb/tinyusb/msc_fat_view/syscfg.yml @@ -97,6 +97,10 @@ syscfg.defs: description: > If set to 1, adds 'Drop image here' file. value: 0 +MSC_FAT_VIEW_UPDATE_HANDLER: +description: > +If set to 1, image can be dropped to upgrade firmware. +value: 0 MSC_FAT_VIEW_SYSTEM_VOLUME_INFORMATION: description: > If set to 1, adds 'System Volume Information' file.
(mynewt-core) branch master updated (13f24628f -> 78039454f)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 13f24628f stylecheck: Add uncrastify exception for STATS new 733fe888e mcu/stm32f7: Fix reset reason new 67a7b81ba hw/mcu/stm32f7: Covert CRLF to LF new a5448a3bf hw/mcu/stm32f7: Use common startup code new 4e5614991 hw/bsp: Update all STMF7 BSPs to use common startup new 78039454f Update STM32F7xx RAT style and license excludes The 5 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: .rat-excludes | 6 +- .style_ignored_dirs| 1 + LICENSE| 3 - hw/bsp/nucleo-f746zg/boot-nucleo-f746zg.ld | 30 - hw/bsp/nucleo-f746zg/bsp.yml | 9 +- hw/bsp/nucleo-f746zg/include/bsp/bsp.h | 12 +- .../link/include/mcu_config.ld.h | 15 +- .../link/include/memory_regions.ld.h | 19 +- hw/bsp/nucleo-f746zg/nucleo-f746zg_debug.cmd | 22 - hw/bsp/nucleo-f746zg/nucleo-f746zg_download.cmd| 22 - hw/bsp/nucleo-f746zg/pkg.yml | 2 + .../src/arch/cortex_m7/startup_stm32f746xx.s | 609 - hw/bsp/nucleo-f746zg/src/hal_bsp.c | 10 +- hw/bsp/nucleo-f746zg/syscfg.yml| 7 + hw/bsp/nucleo-f767zi/boot-nucleo-f767zi.ld | 30 - hw/bsp/nucleo-f767zi/bsp.yml | 7 +- hw/bsp/nucleo-f767zi/include/bsp/bsp.h | 12 +- .../link/include/mcu_config.ld.h | 15 +- .../link/include/memory_regions.ld.h | 19 +- hw/bsp/nucleo-f767zi/pkg.yml | 1 + .../src/arch/cortex_m7/startup_stm32f767xx.s | 656 -- hw/bsp/nucleo-f767zi/src/hal_bsp.c | 10 +- hw/bsp/nucleo-f767zi/syscfg.yml| 2 + hw/bsp/stm32f7discovery/boot-stm32f7discovery.ld | 32 - hw/bsp/stm32f7discovery/bsp.yml| 7 +- hw/bsp/stm32f7discovery/include/bsp/bsp.h | 16 +- hw/bsp/stm32f7discovery/pkg.yml| 2 + .../src/arch/cortex_m7/startup_stm32f746xx.s | 609 - hw/bsp/stm32f7discovery/src/hal_bsp.c | 15 +- hw/bsp/stm32f7discovery/stm32f7discovery.ld| 32 - hw/bsp/stm32f7discovery/syscfg.yml | 9 +- hw/mcu/stm/stm32f7xx/include/mcu/cmsis_nvic.h | 12 +- hw/mcu/stm/stm32f7xx/include/mcu/mcu_vectors.h | 50 ++ .../include/mcu/vectors/stm32f722xx_vectors.h} | 33 +- .../include/mcu/vectors/stm32f723xx_vectors.h} | 33 +- .../include/mcu/vectors/stm32f730xx_vectors.h} | 35 +- .../include/mcu/vectors/stm32f732xx_vectors.h} | 35 +- .../include/mcu/vectors/stm32f733xx_vectors.h} | 35 +- .../include/mcu/vectors/stm32f745xx_vectors.h} | 11 +- .../include/mcu/vectors/stm32f746xx_vectors.h} | 11 +- .../include/mcu/vectors/stm32f750xx_vectors.h} | 9 +- .../include/mcu/vectors/stm32f756xx_vectors.h} | 9 +- .../include/mcu/vectors/stm32f765xx_vectors.h} | 46 +- .../include/mcu/vectors/stm32f767xx_vectors.h} | 23 +- .../include/mcu/vectors/stm32f769xx_vectors.h} | 21 +- .../include/mcu/vectors/stm32f777xx_vectors.h} | 21 +- .../include/mcu/vectors/stm32f779xx_vectors.h} | 19 +- hw/mcu/stm/stm32f7xx/src/clock_stm32f7xx.c | 8 - hw/mcu/stm/stm32f7xx/src/hal_reset_cause.c | 10 +- .../{stm32wbxx => stm32f7xx}/src/hal_system_init.c | 16 +- hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c| 737 ++--- hw/mcu/stm/stm32f7xx/stm32f746.ld | 217 -- hw/mcu/stm/stm32f7xx/stm32f767.ld | 217 -- 53 files changed, 785 insertions(+), 3064 deletions(-) delete mode 100644 hw/bsp/nucleo-f746zg/boot-nucleo-f746zg.ld copy hw/bsp/{ada_feather_stm32f405 => nucleo-f746zg}/link/include/mcu_config.ld.h (81%) copy hw/bsp/{nucleo-f303re => nucleo-f746zg}/link/include/memory_regions.ld.h (60%) delete mode 100644 hw/bsp/nucleo-f746zg/nucleo-f746zg_debug.cmd delete mode 100644 hw/bsp/nucleo-f746zg/nucleo-f746zg_download.cmd delete mode 100644 hw/bsp/nucleo-f746zg/src/arch/cortex_m7/startup_stm32f746xx.s delete mode 100644 hw/bsp/nucleo-f767zi/boot-nucleo-f767zi.ld copy hw/bsp/{ada_feather_stm32f405 => nucleo-f767zi}/link/include/mcu_config.ld.h (81%) copy hw/bsp/{nucleo-f303re => nucleo-f767zi}/link/include/memory_regions.ld.h (60%) delete mode 100644 hw/bsp/nucleo-f767zi/src/arch/cortex_m7/startup_stm32f767xx.s delete mode 100644 hw/bsp/stm32f7discove
(mynewt-core) 03/05: hw/mcu/stm32f7: Use common startup code
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 commit a5448a3bf01ad90deb2c46302cdf0ba7c146d4f4 Author: Jerzy Kasenberg AuthorDate: Mon Jun 10 13:14:58 2024 +0200 hw/mcu/stm32f7: Use common startup code STM32F7 now uses common startup code for Cortex-M7 and autogenerated linker script. Flash cache initialization moved to hal_system_init.c to make system_stm32f7xx.c more like original ST file so future updates will be easier. Unused ld scripts remove NVIC_NUM_VECTOR corrected (probably value was from other MCU) Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f7xx/include/mcu/cmsis_nvic.h | 12 +- hw/mcu/stm/stm32f7xx/include/mcu/mcu_vectors.h | 50 + .../include/mcu/vectors/stm32f722xx_vectors.h | 139 + .../include/mcu/vectors/stm32f723xx_vectors.h | 139 + .../include/mcu/vectors/stm32f730xx_vectors.h | 139 + .../include/mcu/vectors/stm32f732xx_vectors.h | 139 + .../include/mcu/vectors/stm32f733xx_vectors.h | 139 + .../include/mcu/vectors/stm32f745xx_vectors.h | 133 + .../include/mcu/vectors/stm32f746xx_vectors.h | 133 + .../include/mcu/vectors/stm32f750xx_vectors.h | 133 + .../include/mcu/vectors/stm32f756xx_vectors.h | 133 + .../include/mcu/vectors/stm32f765xx_vectors.h | 145 ++ .../include/mcu/vectors/stm32f767xx_vectors.h | 145 ++ .../include/mcu/vectors/stm32f769xx_vectors.h | 145 ++ .../include/mcu/vectors/stm32f777xx_vectors.h | 145 ++ .../include/mcu/vectors/stm32f779xx_vectors.h | 145 ++ hw/mcu/stm/stm32f7xx/src/clock_stm32f7xx.c | 8 - hw/mcu/stm/stm32f7xx/src/hal_system_init.c | 50 + hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c| 9 - hw/mcu/stm/stm32f7xx/stm32f746.ld | 217 - hw/mcu/stm/stm32f7xx/stm32f767.ld | 217 - 21 files changed, 2056 insertions(+), 459 deletions(-) diff --git a/hw/mcu/stm/stm32f7xx/include/mcu/cmsis_nvic.h b/hw/mcu/stm/stm32f7xx/include/mcu/cmsis_nvic.h index a9dea74a7..040d9cf16 100644 --- a/hw/mcu/stm/stm32f7xx/include/mcu/cmsis_nvic.h +++ b/hw/mcu/stm/stm32f7xx/include/mcu/cmsis_nvic.h @@ -9,16 +9,12 @@ #include -#if defined(STM32F746xx) - #define MCU_NUM_PERIPH_VECTORS 98 -#elif defined(STM32F767xx) - #define MCU_NUM_PERIPH_VECTORS 110 -#else - #error "Number of peripheral vectors not defined for this MCU." -#endif +extern uint32_t __isr_vector_start[]; +extern uint32_t __isr_vector_end[]; +/* Extract number of vectors from .interrupt section size */ +#define NVIC_NUM_VECTORS (__isr_vector_end - __isr_vector_start) #define NVIC_USER_IRQ_OFFSET 16 -#define NVIC_NUM_VECTORS (16 + MCU_NUM_PERIPH_VECTORS) #include "stm32f7xx.h" diff --git a/hw/mcu/stm/stm32f7xx/include/mcu/mcu_vectors.h b/hw/mcu/stm/stm32f7xx/include/mcu/mcu_vectors.h new file mode 100644 index 0..0002f237a --- /dev/null +++ b/hw/mcu/stm/stm32f7xx/include/mcu/mcu_vectors.h @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#if defined(STM32F722xx) +#include "vectors/stm32f722xx_vectors.h" +#elif defined(STM32F723xx) +#include "vectors/stm32f723xx_vectors.h" +#elif defined(STM32F732xx) +#include "vectors/stm32f732xx_vectors.h" +#elif defined(STM32F733xx) +#include "vectors/stm32f733xx_vectors.h" +#elif defined(STM32F756xx) +#include "vectors/stm32f756xx_vectors.h" +#elif defined(STM32F746xx) +#include "vectors/stm32f746xx_vectors.h" +#elif defined(STM32F745xx) +#include "vectors/stm32f745xx_vectors.h" +#elif defined(STM32F765xx) +#include "vectors/stm32f765xx_vectors.h" +#elif defined(STM32F767xx) +#include "vectors/stm32f767xx_vectors.h" +#elif defined(STM32F769xx) +#include "vectors/stm3
(mynewt-core) 01/05: mcu/stm32f7: Fix reset reason
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 commit 733fe888ea435bc0a64f3c361902ab7ac4004baf Author: Jerzy Kasenberg AuthorDate: Mon Jun 10 13:04:46 2024 +0200 mcu/stm32f7: Fix reset reason POR was not correctly reported. POR and BOR moved up. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f7xx/src/hal_reset_cause.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/mcu/stm/stm32f7xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32f7xx/src/hal_reset_cause.c index 19cbccc41..04014c5f8 100644 --- a/hw/mcu/stm/stm32f7xx/src/hal_reset_cause.c +++ b/hw/mcu/stm/stm32f7xx/src/hal_reset_cause.c @@ -31,16 +31,18 @@ hal_reset_cause(void) } reg = RCC->CSR; -if (reg & RCC_CSR_WWDGRSTF || reg & RCC_CSR_IWDGRSTF) { +if (reg & RCC_CSR_PORRSTF) { +reason = HAL_RESET_POR; +} else if (reg & RCC_CSR_BORRSTF) { +reason = HAL_RESET_BROWNOUT; +} else if (reg & RCC_CSR_WWDGRSTF || reg & RCC_CSR_IWDGRSTF) { reason = HAL_RESET_WATCHDOG; } else if (reg & RCC_CSR_SFTRSTF) { reason = HAL_RESET_SOFT; } else if (reg & RCC_CSR_PINRSTF) { reason = HAL_RESET_PIN; -} else if (reg & RCC_CSR_BORRSTF) { -reason = HAL_RESET_BROWNOUT; } else { -reason = HAL_RESET_POR; +reason = HAL_RESET_OTHER; } RCC->CSR |= RCC_CSR_RMVF; return reason;
(mynewt-core) 02/05: hw/mcu/stm32f7: Covert CRLF to LF
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 commit 67a7b81ba78acaa6bbf809e8fac64da7d6abffa2 Author: Jerzy Kasenberg AuthorDate: Mon Jun 10 13:13:44 2024 +0200 hw/mcu/stm32f7: Covert CRLF to LF Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c | 746 ++-- 1 file changed, 373 insertions(+), 373 deletions(-) diff --git a/hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c b/hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c index 4b8fb2cdf..a1906a6d5 100644 --- a/hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c +++ b/hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c @@ -1,373 +1,373 @@ -/** - ** - * @filesystem_stm32f7xx.c - * @author MCD Application Team - * @version V1.2.0 - * @date30-December-2016 - * @brief CMSIS Cortex-M7 Device Peripheral Access Layer System Source File. - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32f7xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * - ** - * @attention - * - * © COPYRIGHT 2016 STMicroelectronics - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ** - */ - -#include "bsp/stm32f7xx_hal_conf.h" -#include "stm32f7xx.h" -#include "mcu/cmsis_nvic.h" - -/* This variable is updated in three ways: -1) by calling CMSIS function SystemCoreClockUpdate() -2) by calling HAL API function HAL_RCC_GetHCLKFreq() -3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. -*/ -uint32_t SystemCoreClock = 1600; -const uint8_t AHBPrescTable[16] = { -0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9 -}; -const uint8_t APBPrescTable[8] = { -0, 0, 0, 0, 1, 2, 3, 4 -}; - -/* - * XXX BSP specific - */ -void SystemClock_Config(void); - -/** - * @brief Setup the microcontroller system - * Initialize the Embedded Flash Interface, the PLL and update the - * SystemFrequency variable. - * @param None - * @retval None - */ -void SystemInit(void) -{ -/* - * FPU settings - */ - -#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) -/* set CP10 and CP11 Full Access */ -SCB-
(mynewt-core) 05/05: Update STM32F7xx RAT style and license excludes
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 commit 78039454f8fc8d66bed040c14952dfba81790bed Author: Jerzy Kasenberg AuthorDate: Mon Jun 10 14:25:40 2024 +0200 Update STM32F7xx RAT style and license excludes Signed-off-by: Jerzy Kasenberg --- .rat-excludes | 6 +- .style_ignored_dirs | 1 + LICENSE | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.rat-excludes b/.rat-excludes index 3b49e655d..38733a9d7 100644 --- a/.rat-excludes +++ b/.rat-excludes @@ -251,9 +251,8 @@ tsl2561_shell.c p32mx470f512h.h ppic32mx.h -# STM32F7 Discovery BSP - BSD License +# STM32F7 Discovery BSP, NUCLEO-F767 BSP, NUCLEO-F746 - BSD License stm32f7xx_hal_conf.h -startup_stm32f746xx.s # STM32L152C BSP - BSD License stm32l1xx_hal_conf.h @@ -270,9 +269,6 @@ clock_stm32u5xx.c # NUCLEO-U575ZI-Q BSP - BSD License stm32u5xx_hal_conf.h -# NUCLEO-F767 BSP - BSD License -startup_stm32f767xx.s - # NUCLEO-L467rg BSP - BSD License stm32l4xx_hal_conf.h diff --git a/.style_ignored_dirs b/.style_ignored_dirs index a88806ee2..db0468117 100644 --- a/.style_ignored_dirs +++ b/.style_ignored_dirs @@ -47,6 +47,7 @@ hw/bsp/nucleo-u575zi-q/include/bsp/stm32u5xx_hal_conf.h hw/bsp/weact_g431cb/include/bsp/stm32g4xx_hal_conf.h hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c +hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c hw/mcu/stm/stm32g0xx/src/system_stm32g0xx.c hw/mcu/stm/stm32g4xx/src/system_stm32g4xx.c hw/mcu/stm/stm32u5xx/src/system_stm32u5xx.c diff --git a/LICENSE b/LICENSE index 591c58955..d33d3a9a6 100644 --- a/LICENSE +++ b/LICENSE @@ -309,11 +309,8 @@ This product bundles parts of STM32CubeF7, which is available under the * hw/mcu/stm/stm32f7xx/src/clock_stm32f7xx.c * hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c * hw/bsp/nucleo-f767zi/include/bsp/stm32f7xx_hal_conf.h -* hw/bsp/nucleo-f767zi/src/arch/cortex_m7/startup_stm32f767xx.s * hw/bsp/stm32f7discovery/include/bsp/stm32f7xx_hal_conf.h -* hw/bsp/stm32f7discovery/src/arch/cortex_m7/startup_stm32f746xx.s * hw/bsp/nucleo-f746zg/include/bsp/stm32f7xx_hal_conf.h -* hw/bsp/nucleo-f746zg/src/arch/cortex_m7/startup_stm32f746xx.s This product bundles parts of STM32CubeF3, which is available under the "3-clause BSD" license. Bundled files are:
(mynewt-core) 04/05: hw/bsp: Update all STMF7 BSPs to use common startup
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 commit 4e5614991e91195b709a5c668b4d16bc617d4525 Author: Jerzy Kasenberg AuthorDate: Mon Jun 10 13:20:14 2024 +0200 hw/bsp: Update all STMF7 BSPs to use common startup This removes local startup code and linker scripts Signed-off-by: Jerzy Kasenberg --- hw/bsp/nucleo-f746zg/bsp.yml | 9 +- hw/bsp/nucleo-f746zg/include/bsp/bsp.h | 12 +- .../include/mcu_config.ld.h} | 28 +- .../link/include/memory_regions.ld.h} | 28 +- hw/bsp/nucleo-f746zg/nucleo-f746zg_debug.cmd | 22 - hw/bsp/nucleo-f746zg/nucleo-f746zg_download.cmd| 22 - hw/bsp/nucleo-f746zg/pkg.yml | 2 + .../src/arch/cortex_m7/startup_stm32f746xx.s | 609 --- hw/bsp/nucleo-f746zg/src/hal_bsp.c | 10 +- hw/bsp/nucleo-f746zg/syscfg.yml| 7 + hw/bsp/nucleo-f767zi/bsp.yml | 7 +- hw/bsp/nucleo-f767zi/include/bsp/bsp.h | 12 +- .../include/mcu_config.ld.h} | 28 +- .../link/include/memory_regions.ld.h} | 28 +- hw/bsp/nucleo-f767zi/pkg.yml | 1 + .../src/arch/cortex_m7/startup_stm32f767xx.s | 656 - hw/bsp/nucleo-f767zi/src/hal_bsp.c | 10 +- hw/bsp/nucleo-f767zi/syscfg.yml| 2 + hw/bsp/stm32f7discovery/bsp.yml| 7 +- hw/bsp/stm32f7discovery/include/bsp/bsp.h | 16 +- hw/bsp/stm32f7discovery/pkg.yml| 2 + .../src/arch/cortex_m7/startup_stm32f746xx.s | 609 --- hw/bsp/stm32f7discovery/src/hal_bsp.c | 15 +- hw/bsp/stm32f7discovery/syscfg.yml | 9 +- 24 files changed, 134 insertions(+), 2017 deletions(-) diff --git a/hw/bsp/nucleo-f746zg/bsp.yml b/hw/bsp/nucleo-f746zg/bsp.yml index 3ae5e0f89..708639e82 100644 --- a/hw/bsp/nucleo-f746zg/bsp.yml +++ b/hw/bsp/nucleo-f746zg/bsp.yml @@ -22,16 +22,9 @@ bsp.url: https://www.st.com/en/evaluation-tools/nucleo-f746zg.html bsp.maker: "STMicroelectronics" bsp.arch: cortex_m7 bsp.compiler: compiler/arm-none-eabi-m7 -bsp.linkerscript: -- "hw/bsp/nucleo-f746zg/nucleo-f746zg.ld" -- "@apache-mynewt-core/hw/mcu/stm/stm32f7xx/stm32f746.ld" -bsp.linkerscript.BOOT_LOADER.OVERWRITE: -- "hw/bsp/nucleo-f746zg/boot-nucleo-f746zg.ld" -- "@apache-mynewt-core/hw/mcu/stm/stm32f7xx/stm32f746.ld" +bsp.linkerscript: autogenerated bsp.downloadscript: "hw/bsp/nucleo-f746zg/nucleo-f746zg_download.sh" bsp.debugscript: "hw/bsp/nucleo-f746zg/nucleo-f746zg_debug.sh" -bsp.downloadscript.WINDOWS.OVERWRITE: "hw/bsp/nucleo-f746zg/nucleo-f746zg_download.cmd" -bsp.debugscript.WINDOWS.OVERWRITE: "hw/bsp/nucleo-f746zg/nucleo-f746zg_debug.cmd" bsp.flash_map: areas: diff --git a/hw/bsp/nucleo-f746zg/include/bsp/bsp.h b/hw/bsp/nucleo-f746zg/include/bsp/bsp.h index 34c447ee4..bde2851bf 100644 --- a/hw/bsp/nucleo-f746zg/include/bsp/bsp.h +++ b/hw/bsp/nucleo-f746zg/include/bsp/bsp.h @@ -34,15 +34,15 @@ extern "C" { /* More convenient section placement macros. */ #define bssnz_t sec_bss_nz_core -extern uint8_t _ram_start; -extern uint8_t _dtcmram_start; -extern uint8_t _itcmram_start; -extern uint8_t _ram2_start; +extern uint8_t _ram_start[]; +extern uint8_t _dtcm_start[]; +extern uint8_t _itcm_start[]; +extern uint8_t _ram2_start[]; #define RAM_SIZE(240 * 1024) #define RAM2_SIZE (16 * 1024) -#define DTCMRAM_SIZE(64 * 1024) -#define ITCMRAM_SIZE(16 * 1024) +#define DTCM_SIZE (64 * 1024) +#define ITCM_SIZE (16 * 1024) /* LED pins */ #define LED_1 MCU_GPIO_PORTB(0) diff --git a/hw/bsp/nucleo-f746zg/boot-nucleo-f746zg.ld b/hw/bsp/nucleo-f746zg/link/include/mcu_config.ld.h similarity index 63% rename from hw/bsp/nucleo-f746zg/boot-nucleo-f746zg.ld rename to hw/bsp/nucleo-f746zg/link/include/mcu_config.ld.h index b5f64df1b..cdf034b78 100644 --- a/hw/bsp/nucleo-f746zg/boot-nucleo-f746zg.ld +++ b/hw/bsp/nucleo-f746zg/link/include/mcu_config.ld.h @@ -17,14 +17,22 @@ * under the License. */ -/* Linker script to configure memory regions. */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x0800, LENGTH = 32K - ITCM (rx) : ORIGIN = 0x, LENGTH = 16K - DTCM (rwx) : ORIGIN = 0x2000, LENGTH = 64K - RAM (rwx) : ORIGIN = 0x2001, LENGTH = 256K -} +/* + * Memory regions placed in DTCM + * If stack or core data or other section should be place in RAM + * /link/include/target_config.ld.h should just do: + * #undef BSSNZ_RAM + * #undef COREBSS_RAM + * #undef COREDATA_RAM + * #undef STACK_REGION + * #undef VECTOR_RELOCATION_R
(mynewt-core) branch master updated: stylecheck: Add uncrastify exception for STATS
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 13f24628f stylecheck: Add uncrastify exception for STATS 13f24628f is described below commit 13f24628f3d123a2de9fe3e6c6c9d2c1d29fe680 Author: Jerzy Kasenberg AuthorDate: Thu May 23 08:37:48 2024 +0200 stylecheck: Add uncrastify exception for STATS Uncrustify removes leading spaces from STATS. This simple awk scrip if executed after uncrustify inserts spaces when expected Signed-off-by: Jerzy Kasenberg --- .github/check_style.py | 1 + uncrustify.awk | 37 + 2 files changed, 38 insertions(+) diff --git a/.github/check_style.py b/.github/check_style.py index 7b2fa5b8f..471b88f0e 100755 --- a/.github/check_style.py +++ b/.github/check_style.py @@ -61,6 +61,7 @@ def check_file(fname: str, commit: str, upstream: str) -> list[str]: in_chunk = False for s in run_cmd(f"uncrustify -q -c uncrustify.cfg -f {tmpf.name} | " + f"awk -f uncrustify.awk | " f"diff -u0 -p {tmpf.name} - || true"): m = re.match(r"^@@ -(\d+)(?:,(\d+))? \+\d+(?:,\d+)? @@", s) if not m: diff --git a/uncrustify.awk b/uncrustify.awk new file mode 100644 index 0..a2cd7894c --- /dev/null +++ b/uncrustify.awk @@ -0,0 +1,37 @@ +# +# 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. +# + +# awk script run AFTER uncrustify reformats code to format +# STATS_NAME and STATS_SECT block to have indents removed +# by uncrustify + +# detect begining of STATS_NAME section +/^(static )?STATS_NAME_START[(]/ { stats_name = 1 } +# detect end of STATN_NAME section +/^STATS_NAME_END/ { stats_name = 0 } +# for each line in sectin add 4 spaces eaten by uncrustify +/^STATS_NAME[(]/ && stats_name == 1 { printf "" } + +# detect begining of STATS_SECT section +/^STATS_SECT_START[(]/ { stats_sect = 1 } +# detect end of STATN_SECT section +/^STATS_SECT_END/ { stats_sect = 0 } +# for each line in sectin add 4 spaces eaten by uncrustify +/^STATS_SECT_ENTRY[(]/ && stats_sect == 1 { printf "" } +{ print }
(mynewt-core) branch master updated: spiflash: Add stats
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 884ed2e08 spiflash: Add stats 884ed2e08 is described below commit 884ed2e08660ce41f101b8be672fe3c69bc691a8 Author: Jerzy Kasenberg AuthorDate: Fri Jun 14 14:20:49 2024 +0200 spiflash: Add stats This adds simple stats that can be use to evaluate spiflash usage. Signed-off-by: Jerzy Kasenberg --- .../flash/spiflash/include/spiflash/spiflash.h | 26 ++ hw/drivers/flash/spiflash/src/spiflash.c | 31 +- hw/drivers/flash/spiflash/syscfg.yml | 5 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/hw/drivers/flash/spiflash/include/spiflash/spiflash.h b/hw/drivers/flash/spiflash/include/spiflash/spiflash.h index f57c402fd..7e6298b48 100644 --- a/hw/drivers/flash/spiflash/include/spiflash/spiflash.h +++ b/hw/drivers/flash/spiflash/include/spiflash/spiflash.h @@ -29,6 +29,10 @@ #include #endif +#if MYNEWT_VAL(SPIFLASH_STAT) +#include "stats/stats.h" +#endif + #ifdef __cplusplus extern "C" { #endif @@ -51,6 +55,25 @@ struct spiflash_characteristics { struct spiflash_time_spec tbp1; /* Byte program time */ }; +#if MYNEWT_VAL(SPIFLASH_STAT) +STATS_SECT_START(spiflash_stats_section) +STATS_SECT_ENTRY(read_count) +STATS_SECT_ENTRY(write_count) +STATS_SECT_ENTRY(erase_count) +STATS_SECT_ENTRY(error_count) +STATS_SECT_ENTRY(read_bytes) +STATS_SECT_ENTRY(written_bytes) +STATS_SECT_END + +#define SPIFLASH_STATS_INC STATS_INC +#define SPIFLASH_STATS_INCN STATS_INCN + +#else + +#define SPIFLASH_STATS_INC(__sectvarname, __var) do {} while (0) +#define SPIFLASH_STATS_INCN(__sectvarname, __var, __n) do {} while (0) +#endif + struct spiflash_dev { struct hal_flash hal; #if MYNEWT_VAL(BUS_DRIVER_PRESENT) @@ -83,6 +106,9 @@ struct spiflash_dev { uint32_t cached_addr; uint8_t cache[MYNEWT_VAL(SPIFLASH_CACHE_SIZE)]; #endif +#if MYNEWT_VAL(SPIFLASH_STAT) +STATS_SECT_DECL(spiflash_stats_section) stats; +#endif }; extern struct spiflash_dev spiflash_dev; diff --git a/hw/drivers/flash/spiflash/src/spiflash.c b/hw/drivers/flash/spiflash/src/spiflash.c index 5ed115d24..f00d1c3a4 100644 --- a/hw/drivers/flash/spiflash/src/spiflash.c +++ b/hw/drivers/flash/spiflash/src/spiflash.c @@ -33,6 +33,17 @@ #if MYNEWT_VAL(SPIFLASH) +#if MYNEWT_VAL(SPIFLASH_STAT) +STATS_NAME_START(spiflash_stats_section) +STATS_NAME(spiflash_stats_section, read_count) +STATS_NAME(spiflash_stats_section, write_count) +STATS_NAME(spiflash_stats_section, erase_count) +STATS_NAME(spiflash_stats_section, error_count) +STATS_NAME(spiflash_stats_section, read_bytes) +STATS_NAME(spiflash_stats_section, written_bytes) +STATS_NAME_END(spiflash_stats_section) +#endif + #if MYNEWT_VAL(SPIFLASH_SPI_CS_PIN) < 0 #error SPIFLASH_SPI_CS_PIN must be set to the correct value in bsp syscfg.yml #endif @@ -1022,6 +1033,8 @@ hal_spiflash_read(const struct hal_flash *hal_flash_dev, uint32_t addr, void *bu spiflash_lock(dev); +SPIFLASH_STATS_INC(dev->stats, read_count); + err = spiflash_wait_ready(dev, 100); if (!err) { #if MYNEWT_VAL(SPIFLASH_CACHE_SIZE) @@ -1086,6 +1099,7 @@ hal_spiflash_read(const struct hal_flash *hal_flash_dev, uint32_t addr, void *bu MYNEWT_VAL(SPIFLASH_CACHE_SIZE)); } #endif +SPIFLASH_STATS_INCN(dev->stats, read_bytes, len); } } @@ -1126,6 +1140,8 @@ hal_spiflash_write(const struct hal_flash *hal_flash_dev, uint32_t addr, pp_time_maximum = pp_time_typical; } +SPIFLASH_STATS_INC(dev->stats, write_count); + while (len) { spiflash_write_enable(dev); @@ -1160,9 +1176,12 @@ hal_spiflash_write(const struct hal_flash *hal_flash_dev, uint32_t addr, addr += to_write; u8buf += to_write; len -= to_write; - +SPIFLASH_STATS_INCN(dev->stats, written_bytes, to_write); } err: +if (rc) { +SPIFLASH_STATS_INC(dev->stats, error_count); +} spiflash_unlock(dev); return rc; @@ -1301,10 +1320,12 @@ spiflash_erase(struct spiflash_dev *dev, uint32_t address, uint32_t size) int rc = 0; if (address == 0 && size == dev->hal.hf_size) { +SPIFLASH_STATS_INC(dev->stats, erase_count); return spiflash_chip_erase(dev); } address &= ~0xFFFU; while (size) { +SPIFLASH_STATS_INC(dev->stats, erase_count); #if MYNEWT_VAL(SPIFLASH_BLOCK_ERASE_64BK) if ((address & 0xU) == 0 && (size >= 0x1)) { /* 64 KB erase if possible */ @@ -1456,6 +1477,14 @@ hal_spiflash_init(const struct hal_flash *hal_flash
(mynewt-core) 01/02: bus/spi_stm32: Fix configuration for STM32G0
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 commit bbef6602f849730f8a835dab3a8b98dd603c8368 Author: Jerzy Kasenberg AuthorDate: Thu Jun 13 15:11:18 2024 +0200 bus/spi_stm32: Fix configuration for STM32G0 STM32G0 has alternate function mapping for spi similar to STM32F0. Same goes for PCLK. Signed-off-by: Jerzy Kasenberg --- hw/bus/drivers/spi_stm32/src/spi_stm32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/bus/drivers/spi_stm32/src/spi_stm32.c b/hw/bus/drivers/spi_stm32/src/spi_stm32.c index 91987..6eaac4e95 100644 --- a/hw/bus/drivers/spi_stm32/src/spi_stm32.c +++ b/hw/bus/drivers/spi_stm32/src/spi_stm32.c @@ -147,7 +147,7 @@ struct spi_pin_def { #define SPI_PIN_DEF(_spi_num, _pin, _func, _alt) { _spi_num, _pin, _func, _alt } /* STMF0 and STML0 have distinct alternate pin functions */ -#if MYNEWT_VAL(MCU_STM32L0) || MYNEWT_VAL(MCU_STM32F0) +#if MYNEWT_VAL(MCU_STM32L0) || MYNEWT_VAL(MCU_STM32F0)|| MYNEWT_VAL(MCU_STM32G0) static const struct spi_pin_def spi_pin[] = { #if MYNEWT_VAL(SPI_0_MASTER) SPI_PIN_DEF(0, MCU_GPIO_PORTA(5), SPI_SCK, SPI_AF_0), @@ -293,7 +293,7 @@ static const struct stm32_spi_hw stm32_spi1_hw = { .irqn = SPI1_IRQn, .irq_handler = spi1_irq_handler, .enable_clock = spi1_clock_enable, -#if MYNEWT_VAL(MCU_STM32F0) +#if MYNEWT_VAL(MCU_STM32F0) || MYNEWT_VAL(MCU_STM32G0) .get_pclk = HAL_RCC_GetPCLK1Freq, #else .get_pclk = HAL_RCC_GetPCLK2Freq,
(mynewt-core) 02/02: bus/spi_stm32: Add stats for SPI
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 commit 823d50d7e842f9e78f18d579a99583d561058612 Author: Jerzy Kasenberg AuthorDate: Fri Jun 14 14:19:13 2024 +0200 bus/spi_stm32: Add stats for SPI Signed-off-by: Jerzy Kasenberg --- hw/bus/drivers/spi_stm32/src/spi_stm32.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/hw/bus/drivers/spi_stm32/src/spi_stm32.c b/hw/bus/drivers/spi_stm32/src/spi_stm32.c index 6eaac4e95..689095a77 100644 --- a/hw/bus/drivers/spi_stm32/src/spi_stm32.c +++ b/hw/bus/drivers/spi_stm32/src/spi_stm32.c @@ -74,16 +74,28 @@ #if MYNEWT_VAL(SPI_STM32_STAT) STATS_SECT_START(spi_stm32_stats_section) +STATS_SECT_ENTRY(read_count) +STATS_SECT_ENTRY(write_count) +STATS_SECT_ENTRY(transaction_error_count) STATS_SECT_ENTRY(read_bytes) STATS_SECT_ENTRY(written_bytes) STATS_SECT_ENTRY(dma_transferred_bytes) STATS_SECT_END STATS_NAME_START(spi_stm32_stats_section) +STATS_NAME(spi_stm32_stats_section, read_count) +STATS_NAME(spi_stm32_stats_section, write_count) +STATS_NAME(spi_stm32_stats_section, transaction_error_count) STATS_NAME(spi_stm32_stats_section, read_bytes) STATS_NAME(spi_stm32_stats_section, written_bytes) STATS_NAME(spi_stm32_stats_section, dma_transferred_bytes) STATS_NAME_END(spi_stm32_stats_section) + +#define SPI_STATS_INC STATS_INC +#define SPI_STATS_INCN STATS_INCN +#else +#define SPI_STATS_INC(__sectvarname, __var) do {} while (0) +#define SPI_STATS_INCN(__sectvarname, __var, __n) do {} while (0) #endif /* Driver specific data needed for SPI transfer */ @@ -695,6 +707,8 @@ spi_stm32_read(struct bus_dev *bdev, struct bus_node *bnode, hal_gpio_write(node->pin_cs, 0); } +SPI_STATS_INC(dd->stats, read_count); + if (MYNEWT_VAL(OS_SCHEDULING)) { assert(os_sem_get_count(&dd->sem) == 0); @@ -708,6 +722,9 @@ spi_stm32_read(struct bus_dev *bdev, struct bus_node *bnode, if (rc) { HAL_SPI_Abort(&dd->hspi); +SPI_STATS_INC(dd->stats, transaction_error_count); +} else { +SPI_STATS_INCN(dd->stats, read_bytes, length); } rc = os_error_to_sys(rc); @@ -740,6 +757,8 @@ spi_stm32_write(struct bus_dev *bdev, struct bus_node *bnode, dd = driver_data(dev); +SPI_STATS_INC(dd->stats, write_count); + /* Activate CS */ if (node->pin_cs >= 0) { hal_gpio_write(node->pin_cs, 0); @@ -758,6 +777,9 @@ spi_stm32_write(struct bus_dev *bdev, struct bus_node *bnode, if (rc) { HAL_SPI_Abort(&dd->hspi); +SPI_STATS_INC(dd->stats, transaction_error_count); +} else { +SPI_STATS_INCN(dd->stats, written_bytes, length); } rc = os_error_to_sys(rc); @@ -795,6 +817,8 @@ spi_stm32_duplex_write_read(struct bus_dev *bdev, struct bus_node *bnode, hal_gpio_write(node->pin_cs, 0); } +SPI_STATS_INC(dd->stats, write_count); + if (MYNEWT_VAL(OS_SCHEDULING)) { assert(os_sem_get_count(&dd->sem) == 0); @@ -808,6 +832,13 @@ spi_stm32_duplex_write_read(struct bus_dev *bdev, struct bus_node *bnode, if (rc) { HAL_SPI_Abort(&dd->hspi); +SPI_STATS_INC(dd->stats, transaction_error_count); +} else { +if (MIN_DMA_TX_SIZE >= 0 && length >= MIN_DMA_TX_SIZE) { +SPI_STATS_INCN(dd->stats, dma_transferred_bytes, length); +} +SPI_STATS_INCN(dd->stats, read_bytes, length); +SPI_STATS_INCN(dd->stats, written_bytes, length); } rc = os_error_to_sys(rc);
(mynewt-core) branch master updated (6d2f840cc -> 823d50d7e)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 6d2f840cc hw/mcu/stm32f1: Disable SysTick when RTC is selected as tick source new bbef6602f bus/spi_stm32: Fix configuration for STM32G0 new 823d50d7e bus/spi_stm32: Add stats for SPI 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: hw/bus/drivers/spi_stm32/src/spi_stm32.c | 35 ++-- 1 file changed, 33 insertions(+), 2 deletions(-)
(mynewt-core) branch master updated: hw/mcu/stm32f1: Disable SysTick when RTC is selected as tick source
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 6d2f840cc hw/mcu/stm32f1: Disable SysTick when RTC is selected as tick source 6d2f840cc is described below commit 6d2f840ccd2981e18088a588baf23af160ac757b Author: Jerzy Kasenberg AuthorDate: Wed Jun 12 12:37:27 2024 +0200 hw/mcu/stm32f1: Disable SysTick when RTC is selected as tick source When tick was provided by RTC instead of SysTick (default) and MCUboot used SysTick during boot, SysTick was never turned off and was running in application code. This resulted in two interrupts advancing mynewt OS tick so clock was running too fast. Now os_tick_init() from RTC code disables SysTick that could be started in bootloader Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c b/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c index 3220991f3..9f27be4f1 100644 --- a/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c +++ b/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c @@ -120,6 +120,7 @@ os_tick_init(uint32_t os_ticks_per_sec, int prio) .PeriphClockSelection = RCC_PERIPHCLK_RTC, .RTCClockSelection = RCC_RTCCLKSOURCE_LSE, }; +SysTick->CTRL = 0; HAL_RCCEx_PeriphCLKConfig(&clock_init); __HAL_RCC_RTC_ENABLE();
(mynewt-core) branch master updated (c5ca50357 -> 0a83b28f8)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from c5ca50357 hw/mcu/nrf91: Fix number of vectors new 56d0094e7 hw/mcu/stm32f1: Covert CRLF to LF new 0a83b28f8 hw/mcu/stm32f1: Remove duplicate code 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: .style_ignored_dirs | 1 + hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c | 671 ++-- 2 files changed, 332 insertions(+), 340 deletions(-)
(mynewt-core) 02/02: hw/mcu/stm32f1: Remove duplicate code
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 commit 0a83b28f8e2f724cf7526e578fb3ad1214149ed9 Author: Jerzy Kasenberg AuthorDate: Tue Jun 11 14:44:06 2024 +0200 hw/mcu/stm32f1: Remove duplicate code sequence of calls: SystemClock_Config() SystemCoreClockUpdate() NVIC_Relocate() was already moved to hal_system_init.c This makes system_stm32f1xx.c more like original ST code Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c | 9 - 1 file changed, 9 deletions(-) diff --git a/hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c b/hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c index 03f9a12c1..f7ca66010 100644 --- a/hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c +++ b/hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c @@ -117,15 +117,6 @@ SystemInit(void) SystemInit_ExtMemCtl(); #endif #endif - -/* Configure System Clock */ -SystemClock_Config(); - -/* Update SystemCoreClock global variable */ -SystemCoreClockUpdate(); - -/* Relocate the vector table */ -NVIC_Relocate(); } /**
(mynewt-core) 01/02: hw/mcu/stm32f1: Covert CRLF to LF
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 commit 56d0094e7d63002d85060de1a9a2795f4088b549 Author: Jerzy Kasenberg AuthorDate: Tue Jun 11 14:43:28 2024 +0200 hw/mcu/stm32f1: Covert CRLF to LF --- .style_ignored_dirs | 1 + hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c | 680 ++-- 2 files changed, 341 insertions(+), 340 deletions(-) diff --git a/.style_ignored_dirs b/.style_ignored_dirs index cd3d83dc4..a88806ee2 100644 --- a/.style_ignored_dirs +++ b/.style_ignored_dirs @@ -45,6 +45,7 @@ hw/bsp/stm32f7discovery/include/bsp/stm32f7xx_hal_conf.h hw/bsp/stm32l152discovery/include/bsp/stm32l1xx_hal_conf.h hw/bsp/nucleo-u575zi-q/include/bsp/stm32u5xx_hal_conf.h hw/bsp/weact_g431cb/include/bsp/stm32g4xx_hal_conf.h +hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c hw/mcu/stm/stm32g0xx/src/system_stm32g0xx.c hw/mcu/stm/stm32g4xx/src/system_stm32g4xx.c diff --git a/hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c b/hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c index f3d5709d7..03f9a12c1 100644 --- a/hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c +++ b/hw/mcu/stm/stm32f1xx/src/system_stm32f1xx.c @@ -1,340 +1,340 @@ -/** - * © COPYRIGHT(c) 2017 STMicroelectronics - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "bsp/stm32f1xx_hal_conf.h" -#include "stm32f1xx.h" -#include "mcu/cmsis_nvic.h" -#include "mcu/stm32_hal.h" - -/* Uncomment the following line if you need to use external SRAM */ -#if defined(STM32F100xE) || \ -defined(STM32F101xE) || \ -defined(STM32F101xG) || \ -defined(STM32F103xE) || \ -defined(STM32F103xG) -/* #define DATA_IN_ExtSRAM */ -#endif - -uint32_t SystemCoreClock; -const uint8_t AHBPrescTable[16U] = { -0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9 -}; -const uint8_t APBPrescTable[8U] = { -0, 0, 0, 0, 1, 2, 3, 4 -}; - -#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) -#ifdef DATA_IN_ExtSRAM -static void SystemInit_ExtMemCtl(void); -#endif -#endif - -/* - * XXX BSP specific - */ -void SystemClock_Config(void); - -/** - * @brief Setup the microcontroller system - * Initialize the Embedded Flash Interface, the PLL and update the - * SystemCoreClock variable. - * @note This function should be used only after reset. - * @param None - * @retval None - */ -void -SystemInit(void) -{ -/* - * Reset the RCC clock configuration to the default reset state(for debug purpose) - */ - -/* Set HSION bit */ -RCC->CR |= 0x0001U; - -/* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ -#if !defined(STM32F105xC) && !defined(STM32F107xC) -RCC->CFGR &= 0xF8FFU; -#else -RCC->CFGR &= 0xF0FFU; -#endif - -/* Reset HSEON, CSSON and PLLON bits */ -RCC->CR &= 0xFEF6U; - -/* Reset HSEBYP bit */ -RCC->CR &= 0xFFFBU; - -/* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ -RCC->CFGR &= 0xFF80U; - -#if defined(STM32F105xC) || defined(STM32F107xC) -/* Reset PLL2ON and PLL3ON bits */ -RCC->CR &= 0xEBFFU; - -/* Disable all interrupts and clear pending bits
(mynewt-core) branch master updated: hw/mcu/nrf91: Fix number of vectors
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 c5ca50357 hw/mcu/nrf91: Fix number of vectors c5ca50357 is described below commit c5ca5035751f788fba9aa0a91e5fe1f7aa6feb4d Author: Michal Gorecki AuthorDate: Wed Jun 12 13:27:52 2024 +0200 hw/mcu/nrf91: Fix number of vectors --- hw/mcu/nordic/nrf91xx/include/mcu/cmsis_nvic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mcu/nordic/nrf91xx/include/mcu/cmsis_nvic.h b/hw/mcu/nordic/nrf91xx/include/mcu/cmsis_nvic.h index 7ea55d254..26656353f 100644 --- a/hw/mcu/nordic/nrf91xx/include/mcu/cmsis_nvic.h +++ b/hw/mcu/nordic/nrf91xx/include/mcu/cmsis_nvic.h @@ -10,7 +10,7 @@ #include #include "nrf.h" -#define NVIC_NUM_VECTORS (NVIC_USER_IRQ_OFFSET + 240) /* CORE + MCU Peripherals */ +#define NVIC_NUM_VECTORS (NVIC_USER_IRQ_OFFSET + 64) /* CORE + MCU Peripherals */ #ifdef __cplusplus extern "C" {
(mynewt-core) branch master updated: stm32/hal_timer: Improve timer power consumption
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 e8277f3a5 stm32/hal_timer: Improve timer power consumption e8277f3a5 is described below commit e8277f3a5a9ec4b8c56b0e8d7751af725da4a13f Author: Jerzy Kasenberg AuthorDate: Sun Jun 2 15:30:02 2024 +0200 stm32/hal_timer: Improve timer power consumption Code allows to disable hal timer after it was running for some time (number over overflows) and it was not used for anything. This can reduce power consumption without sacrificing usability. This can be useful for cputimer that is required but not used extensively. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32_common/src/hal_timer.c | 25 + hw/mcu/stm/stm32_common/syscfg.yml | 12 2 files changed, 37 insertions(+) diff --git a/hw/mcu/stm/stm32_common/src/hal_timer.c b/hw/mcu/stm/stm32_common/src/hal_timer.c index 023ace55e..de91262a3 100644 --- a/hw/mcu/stm/stm32_common/src/hal_timer.c +++ b/hw/mcu/stm/stm32_common/src/hal_timer.c @@ -40,6 +40,9 @@ struct stm32_hal_tmr { TIM_TypeDef *sht_regs; /* Pointer to timer registers */ uint32_t sht_oflow; /* 16 bits of overflow to make timer 32bits */ TAILQ_HEAD(hal_timer_qhead, hal_timer) sht_timers; +#if MYNEWT_VAL(STM32_TIMER_AUTO_OFF_COUNT) +uint8_t sht_empty_run; +#endif }; #if MYNEWT_VAL(TIMER_0) @@ -94,6 +97,9 @@ stm32_tmr_cbs(struct stm32_hal_tmr *tmr) } ht = TAILQ_FIRST(&tmr->sht_timers); if (ht) { +#if MYNEWT_VAL(STM32_TIMER_AUTO_OFF_COUNT) +tmr->sht_empty_run = 0; +#endif tmr->sht_regs->CCR1 = ht->expiry & 0xU; } else { tmr->sht_regs->DIER &= ~TIM_DIER_CC1IE; @@ -120,6 +126,9 @@ stm32_tmr_irq(struct stm32_hal_tmr *tmr) */ tmr->sht_oflow += STM32_OFLOW_VALUE; clr |= TIM_SR_UIF; +#if MYNEWT_VAL(STM32_TIMER_AUTO_OFF_COUNT) +tmr->sht_empty_run++; +#endif } if (sr & TIM_SR_CC1IF) { /* @@ -130,6 +139,13 @@ stm32_tmr_irq(struct stm32_hal_tmr *tmr) } tmr->sht_regs->SR = ~clr; + +#if MYNEWT_VAL(STM32_TIMER_AUTO_OFF_COUNT) +if (tmr->sht_empty_run >= MYNEWT_VAL(STM32_TIMER_AUTO_OFF_COUNT)) { +/* Timer oveflowed few times without any usage, disable it till it used again */ +tmr->sht_regs->CR1 &= ~TIM_CR1_CEN; +} +#endif } #endif @@ -579,6 +595,10 @@ hal_timer_cnt(struct stm32_hal_tmr *tmr) uint32_t cnt; int sr; +#if MYNEWT_VAL(STM32_TIMER_AUTO_OFF_COUNT) +tmr->sht_empty_run = 0; +#endif + __HAL_DISABLE_INTERRUPTS(sr); if (tmr->sht_regs->SR & TIM_SR_UIF) { /* @@ -590,6 +610,11 @@ hal_timer_cnt(struct stm32_hal_tmr *tmr) cnt = tmr->sht_oflow + tmr->sht_regs->CNT; __HAL_ENABLE_INTERRUPTS(sr); +#if MYNEWT_VAL(STM32_TIMER_AUTO_OFF_COUNT) +/* Timer could be turned off, so turn it on */ +tmr->sht_regs->CR1 |= TIM_CR1_CEN; +#endif + return cnt; } diff --git a/hw/mcu/stm/stm32_common/syscfg.yml b/hw/mcu/stm/stm32_common/syscfg.yml index 1603bced6..a6bdc785e 100644 --- a/hw/mcu/stm/stm32_common/syscfg.yml +++ b/hw/mcu/stm/stm32_common/syscfg.yml @@ -472,5 +472,17 @@ syscfg.defs: This may be needed for several MCU's including STM32F40x. value: +STM32_TIMER_AUTO_OFF_COUNT: +description: > +Turn off hal timer if it is not used for a specific number of overflows. +HAL timers are used for high frequency time measurement or delays. +Due to high frequency nature of the timer, counter overflows interrupts +would interrupt sleep event if timer is not in use. +This value when set to value graters then 0 will all to turn off timer +after number of overflow events without user code asking for timer value +or scheduling event. +range: 0..255 +value: 0 + syscfg.vals: OS_TICKS_PER_SEC: 1000
(mynewt-core) 01/02: util/stream: Add pumping functions
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 commit 1ac7f5e802512b8cf565aee7da049907396c80a3 Author: Jerzy Kasenberg AuthorDate: Fri May 24 14:11:20 2024 +0200 util/stream: Add pumping functions This extends in_stream and out_stream to provide pumping functions Additionally stream_pump() function is added to allow easy pumping data between streams. Signed-off-by: Jerzy Kasenberg --- util/stream/include/stream/stream.h | 52 +++-- util/stream/src/stream.c| 29 + 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/util/stream/include/stream/stream.h b/util/stream/include/stream/stream.h index 209c660ce..61137951f 100644 --- a/util/stream/include/stream/stream.h +++ b/util/stream/include/stream/stream.h @@ -61,6 +61,17 @@ struct in_stream_vft { * negative error code */ int (*available)(struct in_stream *istream); + +/** + * Pump data from this in_stream to other out_stream + * + * @param istream - this input stream to get data from + * @param ostream - output stream to put data to + * @param count - number of bytes to pump + * @return non-negative number of bytes written + * negative error code + */ +int (*pump_to)(struct in_stream *istream, struct out_stream *ostream, uint32_t count); }; /* Output stream functions */ @@ -83,6 +94,17 @@ struct out_stream_vft { * negative error code */ int (*flush)(struct out_stream *ostream); + +/** + * Pump data from in_stream to this out_stream + * + * @param ostream - this output stream to write data to + * @param istream - other input stream to get data from + * @param count - number for bytes to pump + * @return non-negative number of bytes written + * negative error code + */ +int (*pump_from)(struct out_stream *ostream, struct in_stream *istream, uint32_t count); }; /* Plain input stream */ @@ -102,15 +124,39 @@ struct mem_in_stream { uint32_t read_ptr; }; +#define OSTREAM_DEF(type) \ +static int type ## _write(struct out_stream *ostream, const uint8_t *buf, uint32_t count); \ +static int type ## _flush(struct out_stream *ostream); \ +static int type ## _pump_from(struct out_stream *ostream, struct in_stream *istream, uint32_t count); \ +const struct out_stream_vft type ## _vft = { \ +.write = type ## _write, \ +.flush = type ## _flush, \ +.pump_from = type ## _pump_from, \ +} + +#define OSTREAM_VFT(type, _write, _flush, _pump) \ +static int _write(struct out_stream *ostream, const uint8_t *buf, uint32_t count); \ +static int _flush(struct out_stream *ostream); \ +static int _pump_from(struct out_stream *ostream, struct in_stream *istream, uint32_t count); \ +const struct out_stream_vft type ## _vft = { \ +.write = _write, \ +.flush = _flush, \ +.pump_from = _pump_from, \ +} + #define OSTREAM(type, name) \ struct type name = {\ .vft = &type ## _vft\ } +#define OSTREAM_INIT(type, field) \ +.field.vft = &type ## _vft + #define ISTREAM_DEF(type) \ const struct in_stream_vft type ## _vft = { \ .available = type ## _available,\ .read = type ## _read, \ +.pump_to = type ## _pump_to,\ } #define ISTREAM(type, name) \ @@ -118,8 +164,8 @@ struct mem_in_stream { .vft = &type ## _vft\ } -#define ISTREAM_INIT(type) \ -.type.vft = &type ## _vft \ +#define ISTREAM_INIT(type, field) \ +.field.vft = &type ## _vft \ /** * Check how many bytes can be read out of stream. @@ -175,6 +221,8 @@ int ostream_flush(struct out_stream *ostream); */ int ostream_write(struct out_stream *ostream, const uint8_t *buf, uint32_t count, bool flush); +int stream_pump(struct in_stream *istream, struct out_stream *ostream, uint32_t count); + /** * Initialize memory input stream * diff --git a/util/stream/src/stream.c b/util/stream/src/stream.c index e0ce166fe..fe7605157 100644 --- a/util/stream/src/stream.c +++ b/util/stream/src/stream.c @@ -20,6 +20,7 @@ #include #include +#include "os/os.h" int istream_flush(struct in_stream *istream) @@ -107,3 +108,31 @@ istream_read(struct in_stream *istream, uint8_t *buf, uint32_t count) return istream->vft->read(istream, buf, count); } +int +stream_pump(struct in_stream *istream, struct out_stream *ostream, uint32_t count) +{ +int pumped; + +/* If output stream has pump_from function used it */ +if (ostream->vft->pump_from) { +pumped = ostream->vft->pump_from(ostream, istrea
(mynewt-core) branch master updated (7939d1e50 -> d0e995403)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 7939d1e50 ci: Update ignored BSP list for bootloader build test new 1ac7f5e80 util/stream: Add pumping functions new d0e995403 i2s: Add stream for i2s_out 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: .../i2s_nrfx.h => include/i2s/i2s_stream.h}| 27 --- hw/drivers/i2s/src/i2s_stream.c| 93 ++ util/stream/include/stream/stream.h| 52 +++- util/stream/src/stream.c | 29 +++ 4 files changed, 186 insertions(+), 15 deletions(-) copy hw/drivers/i2s/{i2s_nrfx/include/i2s_nrfx/i2s_nrfx.h => include/i2s/i2s_stream.h} (67%) create mode 100644 hw/drivers/i2s/src/i2s_stream.c
(mynewt-core) 02/02: i2s: Add stream for i2s_out
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 commit d0e99540372d50b961f2b139937e566cef35d715 Author: Jerzy Kasenberg AuthorDate: Fri May 24 14:13:20 2024 +0200 i2s: Add stream for i2s_out Code provides wrapper to use i2s with streaming API Signed-off-by: Jerzy Kasenberg --- hw/drivers/i2s/include/i2s/i2s_stream.h | 46 hw/drivers/i2s/src/i2s_stream.c | 93 + 2 files changed, 139 insertions(+) diff --git a/hw/drivers/i2s/include/i2s/i2s_stream.h b/hw/drivers/i2s/include/i2s/i2s_stream.h new file mode 100644 index 0..83849a1ab --- /dev/null +++ b/hw/drivers/i2s/include/i2s/i2s_stream.h @@ -0,0 +1,46 @@ +/* + * 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. + */ + +#ifndef _HW_DRIVERS_I2S_STREAM_H +#define _HW_DRIVERS_I2S_STREAM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct i2s_out_stream { +struct out_stream ostream; +struct i2s *i2s; +struct i2s_sample_buffer *buffer; +}; + +#define I2S_OUT_STREAM_DEF(var) \ +extern const struct out_stream_vft i2s_out_stream_vft; \ +struct i2s_out_stream var = { \ +OSTREAM_INIT(i2s_out_stream, ostream), \ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _HW_DRIVERS_I2S_STREAM_H */ diff --git a/hw/drivers/i2s/src/i2s_stream.c b/hw/drivers/i2s/src/i2s_stream.c new file mode 100644 index 0..93a4e8a13 --- /dev/null +++ b/hw/drivers/i2s/src/i2s_stream.c @@ -0,0 +1,93 @@ +/* + * 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 + +#include +#include +#include +#include + +OSTREAM_DEF(i2s_out_stream); + +static int +i2s_out_stream_pump_from(struct out_stream *ostream, struct in_stream *istream, uint32_t count) +{ +struct i2s_out_stream *i2s_str = CONTAINER_OF(ostream, struct i2s_out_stream, ostream); +struct i2s_sample_buffer *buffer = i2s_str->buffer; +struct i2s *i2s = i2s_str->i2s; +int written = 0; +uint32_t available = istream_available(istream); +uint32_t sample_count; + +if (available < count) { +count = available; +} +sample_count = count / i2s->sample_size_in_bytes; + +while (sample_count) { +if (buffer == NULL) { +buffer = i2s_buffer_get(i2s, 0); +if (buffer == NULL) { +break; +} +buffer->sample_count = 0; +} +uint32_t space = buffer->capacity - buffer->sample_count; +size_t copied = min(space, sample_count); +if (copied) { +uint8_t *buf = buffer->sample_data; +istream_read(istream, buf + buffer->sample_count * i2s->sample_size_in_bytes, + copied * i2s->sample_size_in_bytes); +buffer->sample_count += copied; +written += copied; +sample_count -= copied; +} +if (buffer->sample_count >= buffer->capacity) { +i2s_buffer_put(i2s, buffer); +buffer = NULL; +} +} +i2s_str->buffer = buffer; +return written * i2s_str->i2s->sample_size_in_bytes; +} + +static int +i2s_out_stream_write(struct out_stream *ostream, const uint8_t *buf, uint32_t count) +{ +struct mem_in_stream
(mynewt-core) 01/06: mcu/stm32f3: Fix reset reason
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 commit 209fbe6b46cfe2b744eb0fc53f35cb559cfc2dfe Author: Jerzy Kasenberg AuthorDate: Wed Jun 5 21:53:37 2024 +0200 mcu/stm32f3: Fix reset reason POR was not correctly reported. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f3xx/src/hal_reset_cause.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/mcu/stm/stm32f3xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32f3xx/src/hal_reset_cause.c index e3e28013e..be974a186 100644 --- a/hw/mcu/stm/stm32f3xx/src/hal_reset_cause.c +++ b/hw/mcu/stm/stm32f3xx/src/hal_reset_cause.c @@ -31,16 +31,16 @@ hal_reset_cause(void) } reg = RCC->CSR; -if (reg & RCC_CSR_WWDGRSTF || reg & RCC_CSR_IWDGRSTF) { +if (reg & RCC_CSR_PORRSTF) { +reason = HAL_RESET_POR; +} else if (reg & RCC_CSR_WWDGRSTF || reg & RCC_CSR_IWDGRSTF) { reason = HAL_RESET_WATCHDOG; } else if (reg & RCC_CSR_SFTRSTF) { reason = HAL_RESET_SOFT; } else if (reg & RCC_CSR_PINRSTF) { reason = HAL_RESET_PIN; -} else if (reg & RCC_CSR_PORRSTF) { -reason = HAL_RESET_BROWNOUT; } else { -reason = HAL_RESET_POR; +reason = HAL_RESET_OTHER; } RCC->CSR |= RCC_CSR_RMVF; return reason;
(mynewt-core) 05/06: Update STM32F3xx RAT style and license excludes
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 commit 58a56243befaeabc77fd593f22ea18cd0bd92818 Author: Jerzy Kasenberg AuthorDate: Wed Jun 5 23:10:24 2024 +0200 Update STM32F3xx RAT style and license excludes Signed-off-by: Jerzy Kasenberg --- .rat-excludes | 7 +-- .style_ignored_dirs | 1 + LICENSE | 3 --- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.rat-excludes b/.rat-excludes index ce3f98ca0..3b49e655d 100644 --- a/.rat-excludes +++ b/.rat-excludes @@ -255,9 +255,6 @@ ppic32mx.h stm32f7xx_hal_conf.h startup_stm32f746xx.s -# STM32F3 Discovery BSP - BSD License -startup_stm32f303xc.s - # STM32L152C BSP - BSD License stm32l1xx_hal_conf.h startup_stm32l152xc.s @@ -334,9 +331,7 @@ system_apollo3.h clock_stm32f3xx.c system_stm32f3xx.c -# Nucleo-F303K8, Nucleo-F303RE - BSD License. -startup_stm32f303x8.s -startup_stm32f303xe.s +# Nucleo-F303K8, Nucleo-F303RE, STM32F3 Discovery - BSD License. stm32f3xx_hal_conf.h # Ignore documentation folder diff --git a/.style_ignored_dirs b/.style_ignored_dirs index d2f32bc77..cd3d83dc4 100644 --- a/.style_ignored_dirs +++ b/.style_ignored_dirs @@ -45,6 +45,7 @@ hw/bsp/stm32f7discovery/include/bsp/stm32f7xx_hal_conf.h hw/bsp/stm32l152discovery/include/bsp/stm32l1xx_hal_conf.h hw/bsp/nucleo-u575zi-q/include/bsp/stm32u5xx_hal_conf.h hw/bsp/weact_g431cb/include/bsp/stm32g4xx_hal_conf.h +hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c hw/mcu/stm/stm32g0xx/src/system_stm32g0xx.c hw/mcu/stm/stm32g4xx/src/system_stm32g4xx.c hw/mcu/stm/stm32u5xx/src/system_stm32u5xx.c diff --git a/LICENSE b/LICENSE index 76e463a3b..591c58955 100644 --- a/LICENSE +++ b/LICENSE @@ -320,11 +320,8 @@ This product bundles parts of STM32CubeF3, which is available under the * hw/mcu/stm/stm32f3xx/src/clock_stm32f3xx.c * hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c * hw/bsp/stm32f3discovery/include/bsp/stm32f3xx_hal_conf.h -* hw/bsp/stm32f3discovery/src/arch/cortex_m4/startup_stm32f303xc.s * hw/bsp/nucleo-f303k8/include/bsp/stm32f3xx_hal_conf.h -* hw/bsp/nucleo-f303k8/src/arch/cortex_m4/startup_stm32f303x8.s * hw/bsp/nucleo-f303re/include/bsp/stm32f3xx_hal_conf.h -* hw/bsp/nucleo-f303re/src/arch/cortex_m4/startup_stm32f303xe.s This product bundles parts of STM32CubeH7, which is available under the "3-clause BSD" license. Bundled files are:
(mynewt-core) 02/06: hw/mcu/stm32f3: Covert CRLF to LF
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 commit cd4bffd31cbd83c8e3b2096ed4dd574f3f880107 Author: Jerzy Kasenberg AuthorDate: Wed Jun 5 22:01:24 2024 +0200 hw/mcu/stm32f3: Covert CRLF to LF Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c | 424 ++-- 1 file changed, 212 insertions(+), 212 deletions(-) diff --git a/hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c b/hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c index 57c652679..c351c51b0 100644 --- a/hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c +++ b/hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c @@ -1,212 +1,212 @@ -/** - * © COPYRIGHT(c) 2016 STMicroelectronics - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ** - */ - -#include "bsp/stm32f3xx_hal_conf.h" -#include "stm32f3xx.h" -#include "mcu/cmsis_nvic.h" - -/* - * This variable is updated in three ways: - * 1) by calling CMSIS function SystemCoreClockUpdate() - * 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - * 3) each time HAL_RCC_ClockConfig() is called to configure the system clock - *frequency - * Note: If you use this function to configure the system clock; then there - * is no need to call the 2 first functions listed above, since SystemCoreClock - * variable is updated automatically. - */ -uint32_t SystemCoreClock; -const uint8_t AHBPrescTable[16] = { -0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9 -}; -const uint8_t APBPrescTable[8] = { -0, 0, 0, 0, 1, 2, 3, 4 -}; - -/* - * XXX BSP specific - */ -void SystemClock_Config(void); - -/** - * @brief Setup the microcontroller system - * Initialize the FPU setting, vector table location and the PLL configuration is reset. - * @param None - * @retval None - */ -void SystemInit(void) -{ -/* - * FPU settings - */ - -#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) -/* set CP10 and CP11 Full Access */ -SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); -#endif - -/* - * Reset the RCC clock configuration to the default reset state - */ - -/* Set HSION bit */ -RCC->CR |= (uint32_t)0x0001; - -/* Reset CFGR register */ -RCC->CFGR &= 0xF87FC00C; - -/* Reset HSEON, CSSON and PLLON bits */ -RCC->CR &= (uint32_t)0xFEF6; - -/* Reset HSEBYP bit */ -RCC->CR &= (uint32_t)0xFFFB; - -/* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE bits */ -RCC->CFGR &= (uint32_t)0xFF80; - -/* Reset PREDIV1[3:0] bits */ -RCC->CFGR2 &= (uint32_t)0xFFF0; - -/* Reset USARTSW[1:0], I2CSW and TIMs bits */ -RCC->CFGR3 &= (uint32_t)0xFF00FCCC; - -/* Disable all interrupts */ -RCC->CIR = 0x; - -/* Configure System Clock */ -SystemClock_Config(); - -/* Update SystemCoreClock global variable */ -SystemCoreClockUpdate(); - -/* Relocate the vector table */ -NVIC_Relocate(); -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - *
(mynewt-core) 06/06: ci: Update ignored BSP list for bootloader build test
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 commit 7939d1e50958921979c3443722ef6e52f9c62fad Author: Jerzy Kasenberg AuthorDate: Thu Jun 6 08:07:06 2024 +0200 ci: Update ignored BSP list for bootloader build test STM32F303K8 board don't have space for bootloader in bsp. Signed-off-by: Jerzy Kasenberg --- .github/test_build_bootloader.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/test_build_bootloader.sh b/.github/test_build_bootloader.sh index 8389a7a9f..96caa9f85 100644 --- a/.github/test_build_bootloader.sh +++ b/.github/test_build_bootloader.sh @@ -22,6 +22,7 @@ EXIT_CODE=0 BSPS=$(ls repos/apache-mynewt-core/hw/bsp) IGNORED_BSPS="ci40 dialog_cmac embarc_emsk hifive1 native native-armv7\ native-mips nucleo-f030r8 nucleo-f072rb\ + nucleo-f303k8\ olimex-p103 olimex-pic32-emz64 olimex-pic32-hmz144\ pic32mx470_6lp_clicker pic32mz2048_wi-fire usbmkw41z\ weact_g431cb"
(mynewt-core) 03/06: hw/mcu/stm32f3: Use common startup code
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 commit 76415488c23c3baf8fbcc26babb5d1b15bdf0b97 Author: Jerzy Kasenberg AuthorDate: Wed Jun 5 22:03:51 2024 +0200 hw/mcu/stm32f3: Use common startup code STM32F3 now uses common startup code for Cortex-M4 and autogenerated linker script. Flash cache initialization moved to hal_system_init.c to make system_stm32f3xx.c more like original ST file so future updates will be easier. Unused ld scripts remove NVIC_NUM_VECTOR corrected (probably value was from other MCU) Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f3xx/include/mcu/cmsis_nvic.h | 6 +- hw/mcu/stm/stm32f3xx/include/mcu/mcu_vectors.h | 50 + .../include/mcu/vectors/stm32f301x8_vectors.h | 117 +++ .../include/mcu/vectors/stm32f302x8_vectors.h | 117 +++ .../include/mcu/vectors/stm32f302xc_vectors.h | 117 +++ .../include/mcu/vectors/stm32f302xe_vectors.h | 120 .../include/mcu/vectors/stm32f303x8_vectors.h | 117 +++ .../include/mcu/vectors/stm32f303xc_vectors.h | 117 +++ .../include/mcu/vectors/stm32f303xe_vectors.h | 120 .../include/mcu/vectors/stm32f318xx_vectors.h | 117 +++ .../include/mcu/vectors/stm32f328xx_vectors.h | 117 +++ .../include/mcu/vectors/stm32f334x8_vectors.h | 117 +++ .../include/mcu/vectors/stm32f358xx_vectors.h | 117 +++ .../include/mcu/vectors/stm32f373xc_vectors.h | 117 +++ .../include/mcu/vectors/stm32f378xx_vectors.h | 117 +++ .../include/mcu/vectors/stm32f398xx_vectors.h | 120 .../stm/stm32f3xx/src/hal_system_init.c} | 41 ++-- hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c| 9 - hw/mcu/stm/stm32f3xx/stm32f303.ld | 214 - 19 files changed, 1729 insertions(+), 238 deletions(-) diff --git a/hw/mcu/stm/stm32f3xx/include/mcu/cmsis_nvic.h b/hw/mcu/stm/stm32f3xx/include/mcu/cmsis_nvic.h index df47262dc..ceb3f8651 100644 --- a/hw/mcu/stm/stm32f3xx/include/mcu/cmsis_nvic.h +++ b/hw/mcu/stm/stm32f3xx/include/mcu/cmsis_nvic.h @@ -28,7 +28,11 @@ #include -#define NVIC_NUM_VECTORS (16 + 81) // CORE + MCU Peripherals +extern uint32_t __isr_vector_start[]; +extern uint32_t __isr_vector_end[]; + +/* Extract number of vectors from .interrupt section size */ +#define NVIC_NUM_VECTORS (__isr_vector_end - __isr_vector_start) #define NVIC_USER_IRQ_OFFSET 16 #include "stm32f3xx.h" diff --git a/hw/mcu/stm/stm32f3xx/include/mcu/mcu_vectors.h b/hw/mcu/stm/stm32f3xx/include/mcu/mcu_vectors.h new file mode 100644 index 0..24e2bf3ba --- /dev/null +++ b/hw/mcu/stm/stm32f3xx/include/mcu/mcu_vectors.h @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#if defined(STM32F301x8) +#include "vectors/stm32f301x8_vectors.h" +#elif defined(STM32F302x8) +#include "vectors/stm32f302x8_vectors.h" +#elif defined(STM32F302xC) +#include "vectors/stm32f302xc_vectors.h" +#elif defined(STM32F302xE) +#include "vectors/stm32f302xe_vectors.h" +#elif defined(STM32F303x8) +#include "vectors/stm32f303x8_vectors.h" +#elif defined(STM32F303xC) +#include "vectors/stm32f303xc_vectors.h" +#elif defined(STM32F303xE) +#include "vectors/stm32f303xe_vectors.h" +#elif defined(STM32F373xC) +#include "vectors/stm32f373xc_vectors.h" +#elif defined(STM32F334x8) +#include "vectors/stm32f334x8_vectors.h" +#elif defined(STM32F318xx) +#include "vectors/stm32f318xx_vectors.h" +#elif defined(STM32F328xx) +#include "vectors/stm32f328xx_vectors.h" +#elif defined(STM32F358xx) +#include "vectors/stm32f358xx_vectors.h" +#elif defined(STM32F378xx) +#include "vectors/stm32f378xx_vectors.h" +#elif defined(STM32F398xx) +#include "vectors/stm32f398xx_vectors.h" +#else +#error "Please select first the tar
(mynewt-core) 04/06: hw/bsp: Update all STMF3 BSPs to use common startup
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 commit c287f6089f89453dcef5df8a750ff450e9df6d21 Author: Jerzy Kasenberg AuthorDate: Wed Jun 5 22:11:51 2024 +0200 hw/bsp: Update all STMF3 BSPs to use common startup This removes local startup code and linker scripts Signed-off-by: Jerzy Kasenberg --- hw/bsp/nucleo-f303k8/bsp.yml | 8 +- .../link/include/mcu_config.ld.h} | 27 +- .../link/include/memory_regions.ld.h} | 22 +- hw/bsp/nucleo-f303k8/nucleo-f303k8_debug.cmd | 22 - hw/bsp/nucleo-f303k8/nucleo-f303k8_download.cmd| 22 - hw/bsp/nucleo-f303k8/nucleo-f303k8_download.sh | 55 --- hw/bsp/nucleo-f303k8/pkg.yml | 2 + .../src/arch/cortex_m4/startup_stm32f303x8.s | 408 - hw/bsp/nucleo-f303k8/syscfg.yml| 8 + hw/bsp/nucleo-f303re/bsp.yml | 11 +- .../include/mcu_config.ld.h} | 27 +- .../include/memory_regions.ld.h} | 22 +- hw/bsp/nucleo-f303re/nucleo-f303re_debug.cmd | 22 - hw/bsp/nucleo-f303re/nucleo-f303re_download.cmd| 22 - hw/bsp/nucleo-f303re/nucleo-f303re_download.sh | 57 --- hw/bsp/nucleo-f303re/pkg.yml | 2 + .../src/arch/cortex_m4/startup_stm32f303xe.s | 506 - hw/bsp/nucleo-f303re/syscfg.yml| 9 + hw/bsp/stm32f3discovery/bsp.yml| 11 +- .../link/include/mcu_config.ld.h} | 27 +- .../link/include/memory_regions.ld.h} | 23 +- hw/bsp/stm32f3discovery/pkg.yml| 2 + .../src/arch/cortex_m4/startup_stm32f303xc.s | 493 hw/bsp/stm32f3discovery/stm32f3discovery_debug.cmd | 22 - .../stm32f3discovery/stm32f3discovery_download.cmd | 22 - .../stm32f3discovery/stm32f3discovery_download.sh | 41 -- hw/bsp/stm32f3discovery/syscfg.yml | 8 + 27 files changed, 103 insertions(+), 1798 deletions(-) diff --git a/hw/bsp/nucleo-f303k8/bsp.yml b/hw/bsp/nucleo-f303k8/bsp.yml index 89e7d8bb6..e910ac0d6 100644 --- a/hw/bsp/nucleo-f303k8/bsp.yml +++ b/hw/bsp/nucleo-f303k8/bsp.yml @@ -22,13 +22,9 @@ bsp.url: https://www.st.com/en/evaluation-tools/nucleo-f303k8.html bsp.maker: "STMicroelectronics" bsp.arch: cortex_m4 bsp.compiler: compiler/arm-none-eabi-m4 -bsp.linkerscript: -- "hw/bsp/nucleo-f303k8/nucleo-f303k8.ld" -- "@apache-mynewt-core/hw/mcu/stm/stm32f3xx/stm32f303.ld" -bsp.downloadscript: "hw/bsp/nucleo-f303k8/nucleo-f303k8_download.sh" +bsp.linkerscript: autogenerated +bsp.downloadscript: "hw/scripts/download.sh" bsp.debugscript: "hw/bsp/nucleo-f303k8/nucleo-f303k8_debug.sh" -bsp.downloadscript.WINDOWS.OVERWRITE: "hw/bsp/nucleo-f303k8/nucleo-f303k8_download.cmd" -bsp.debugscript.WINDOWS.OVERWRITE: "hw/bsp/nucleo-f303k8/nucleo-f303k8_debug.cmd" bsp.flash_map: areas: diff --git a/hw/bsp/stm32f3discovery/stm32f3discovery.ld b/hw/bsp/nucleo-f303k8/link/include/mcu_config.ld.h similarity index 69% rename from hw/bsp/stm32f3discovery/stm32f3discovery.ld rename to hw/bsp/nucleo-f303k8/link/include/mcu_config.ld.h index 0316a347b..3596fc2cc 100644 --- a/hw/bsp/stm32f3discovery/stm32f3discovery.ld +++ b/hw/bsp/nucleo-f303k8/link/include/mcu_config.ld.h @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -6,7 +6,7 @@ * 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, @@ -16,17 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -ENTRY(Reset_Handler) /* - * Memory map + * Memory regions placed in CCM + * If stack or core data or other section should be place in RAM + * /link/include/target_config.ld.h should just do: + * #undef BSSNZ_RAM + * #undef COREBSS_RAM + * #undef COREDATA_RAM + * #undef STACK_REGION */ -MEMORY { -FLASH (rx): ORIGIN = 0x08004000, LENGTH = 88K -CCRAM (rw): ORIGIN = 0x1000, LENGTH = 8K -SRAM (rw): ORIGIN = 0x2000, LENGTH = 40K -} -/* - * Image header size - no bootloader support, no header. - */ -_imghdr_size = 0x20; + +#define BSSNZ_RAM CCM +#define COREBSS_RAM CCM +#define COREDATA_RAM CCM +#define STACK_REGION CCM diff --git a/hw/bsp/stm32f3discovery/boot-stm32f3discovery.ld b/hw/bsp/nucleo-f303k8/link/include/memory_regions.ld.h similari
(mynewt-core) branch master updated (f48267d02 -> 7939d1e50)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from f48267d02 bsp: Leave HSI on for STM32F1 new 209fbe6b4 mcu/stm32f3: Fix reset reason new cd4bffd31 hw/mcu/stm32f3: Covert CRLF to LF new 76415488c hw/mcu/stm32f3: Use common startup code new c287f6089 hw/bsp: Update all STMF3 BSPs to use common startup new 58a56243b Update STM32F3xx RAT style and license excludes new 7939d1e50 ci: Update ignored BSP list for bootloader build test The 6 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: .github/test_build_bootloader.sh | 1 + .rat-excludes | 7 +- .style_ignored_dirs| 1 + LICENSE| 3 - hw/bsp/nucleo-f303k8/bsp.yml | 8 +- .../link/include/mcu_config.ld.h | 0 .../link/include/memory_regions.ld.h | 6 +- hw/bsp/nucleo-f303k8/nucleo-f303k8.ld | 33 -- hw/bsp/nucleo-f303k8/nucleo-f303k8_debug.cmd | 22 - hw/bsp/nucleo-f303k8/nucleo-f303k8_download.cmd| 22 - hw/bsp/nucleo-f303k8/nucleo-f303k8_download.sh | 55 --- hw/bsp/nucleo-f303k8/pkg.yml | 2 + .../src/arch/cortex_m4/startup_stm32f303x8.s | 408 - hw/bsp/nucleo-f303k8/syscfg.yml| 8 + hw/bsp/nucleo-f303re/boot-nucleo-f303re.ld | 31 -- hw/bsp/nucleo-f303re/bsp.yml | 11 +- .../link/include/mcu_config.ld.h | 0 .../link/include/memory_regions.ld.h | 6 +- hw/bsp/nucleo-f303re/nucleo-f303re.ld | 32 -- hw/bsp/nucleo-f303re/nucleo-f303re_debug.cmd | 22 - hw/bsp/nucleo-f303re/nucleo-f303re_download.cmd| 22 - hw/bsp/nucleo-f303re/nucleo-f303re_download.sh | 57 --- hw/bsp/nucleo-f303re/pkg.yml | 2 + .../src/arch/cortex_m4/startup_stm32f303xe.s | 506 - hw/bsp/nucleo-f303re/syscfg.yml| 9 + hw/bsp/stm32f3discovery/boot-stm32f3discovery.ld | 31 -- hw/bsp/stm32f3discovery/bsp.yml| 11 +- .../link/include/mcu_config.ld.h | 0 .../link/include/memory_regions.ld.h | 6 +- hw/bsp/stm32f3discovery/pkg.yml| 2 + .../src/arch/cortex_m4/startup_stm32f303xc.s | 493 hw/bsp/stm32f3discovery/stm32f3discovery.ld| 32 -- hw/bsp/stm32f3discovery/stm32f3discovery_debug.cmd | 22 - .../stm32f3discovery/stm32f3discovery_download.cmd | 22 - .../stm32f3discovery/stm32f3discovery_download.sh | 41 -- hw/bsp/stm32f3discovery/syscfg.yml | 8 + hw/mcu/stm/stm32f3xx/include/mcu/cmsis_nvic.h | 6 +- hw/mcu/stm/stm32f3xx/include/mcu/mcu_vectors.h | 50 ++ .../include/mcu/vectors/stm32f301x8_vectors.h} | 43 +- .../include/mcu/vectors/stm32f302x8_vectors.h} | 53 ++- .../include/mcu/vectors/stm32f302xc_vectors.h} | 55 ++- .../include/mcu/vectors/stm32f302xe_vectors.h} | 58 +-- .../include/mcu/vectors/stm32f303x8_vectors.h} | 59 ++- .../include/mcu/vectors/stm32f303xc_vectors.h} | 50 +- .../include/mcu/vectors/stm32f303xe_vectors.h} | 55 +-- .../include/mcu/vectors/stm32f318xx_vectors.h} | 43 +- .../include/mcu/vectors/stm32f328xx_vectors.h} | 59 ++- .../include/mcu/vectors/stm32f334x8_vectors.h} | 59 ++- .../include/mcu/vectors/stm32f358xx_vectors.h} | 57 ++- .../include/mcu/vectors/stm32f373xc_vectors.h} | 63 ++- .../include/mcu/vectors/stm32f378xx_vectors.h} | 63 ++- .../include/mcu/vectors/stm32f398xx_vectors.h} | 53 ++- hw/mcu/stm/stm32f3xx/src/hal_reset_cause.c | 8 +- .../{stm32f1xx => stm32f3xx}/src/hal_system_init.c | 6 +- hw/mcu/stm/stm32f3xx/src/system_stm32f3xx.c| 415 + hw/mcu/stm/stm32f3xx/stm32f303.ld | 214 - 56 files changed, 687 insertions(+), 2724 deletions(-) copy hw/bsp/{ada_feather_stm32f405 => nucleo-f303k8}/link/include/mcu_config.ld.h (100%) copy hw/bsp/{ada_feather_stm32f405 => nucleo-f303k8}/link/include/memory_regions.ld.h (82%) delete mode 100644 hw/bsp/nucleo-f303k8/nucleo-f303k8.ld delete mode 100644 hw/bsp/nucleo-f303k8/nucleo-f303k8_debug.cmd delete mode 100644 hw/bsp/nucleo-f303k8/nucleo-f303k8_download.cmd delete mode 100755 hw/bsp/nucleo-f303k8/nucleo-f303k8_download.sh delete mode 100644 hw/bsp/nucleo-f303k8/src/arch/cortex_m4/startup_stm32f303x8.s delete mode 100644 hw/bsp/nucleo-f303re/boot-
(mynewt-core) branch master updated: bsp: Leave HSI on for STM32F1
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 f48267d02 bsp: Leave HSI on for STM32F1 f48267d02 is described below commit f48267d0290b39eda8c0b927cb33a09318b82dbe Author: Jerzy Kasenberg AuthorDate: Sat Jun 8 23:37:26 2024 +0200 bsp: Leave HSI on for STM32F1 HSI is needed for flash writes so now it's turned on by default. Signed-off-by: Jerzy Kasenberg --- hw/bsp/bluepill/syscfg.yml| 2 +- hw/bsp/olimex-p103/syscfg.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/bsp/bluepill/syscfg.yml b/hw/bsp/bluepill/syscfg.yml index d601947e2..292ae39f9 100644 --- a/hw/bsp/bluepill/syscfg.yml +++ b/hw/bsp/bluepill/syscfg.yml @@ -29,7 +29,7 @@ syscfg.vals: CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS NFFS_FLASH_AREA: FLASH_AREA_NFFS COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1 -STM32_CLOCK_HSI: 0 +STM32_CLOCK_HSI: 1 STM32_CLOCK_HSE: 1 STM32_CLOCK_HSE_BYPASS: 0 STM32_CLOCK_PLL_MUL: 'RCC_PLL_MUL9' diff --git a/hw/bsp/olimex-p103/syscfg.yml b/hw/bsp/olimex-p103/syscfg.yml index 14d2e035d..f57363b7c 100644 --- a/hw/bsp/olimex-p103/syscfg.yml +++ b/hw/bsp/olimex-p103/syscfg.yml @@ -32,7 +32,7 @@ syscfg.vals: CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS NFFS_FLASH_AREA: FLASH_AREA_NFFS COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1 -STM32_CLOCK_HSI: 0 +STM32_CLOCK_HSI: 1 STM32_CLOCK_HSE: 1 STM32_CLOCK_HSE_BYPASS: 0 STM32_CLOCK_PLL_MUL: 'RCC_PLL_MUL9'
(mynewt-core) branch master updated: mcu/stm32: Fix hal_nvreg_write for STM32F1
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 5477f8fed mcu/stm32: Fix hal_nvreg_write for STM32F1 5477f8fed is described below commit 5477f8fed4ffe0e1fb7efa5aaa13bbead6824b2e Author: Jerzy Kasenberg AuthorDate: Sat Jun 8 16:46:14 2024 +0200 mcu/stm32: Fix hal_nvreg_write for STM32F1 Writing to backup registers requires enabling BPK_CLK. For read it does not seem to be needed. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32_common/src/hal_nvreg.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/mcu/stm/stm32_common/src/hal_nvreg.c b/hw/mcu/stm/stm32_common/src/hal_nvreg.c index c2953aa21..82b210745 100644 --- a/hw/mcu/stm/stm32_common/src/hal_nvreg.c +++ b/hw/mcu/stm/stm32_common/src/hal_nvreg.c @@ -39,9 +39,15 @@ hal_nvreg_write(unsigned int reg, uint32_t val) #if PWR_ENABLED RTC_HandleTypeDef hrtc = { .Instance = RTC }; if (reg < HAL_NVREG_MAX) { +#if defined(__HAL_RCC_BKP_CLK_ENABLE) +__HAL_RCC_BKP_CLK_ENABLE(); +#endif HAL_PWR_EnableBkUpAccess(); HAL_RTCEx_BKUPWrite(&hrtc, reg, val); HAL_PWR_DisableBkUpAccess(); +#if defined(__HAL_RCC_BKP_CLK_DISABLE) +__HAL_RCC_BKP_CLK_DISABLE(); +#endif } #endif }
(mynewt-core) branch master updated: apps/coremark: Tickle watchdog in coremark shell command
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 5f7243fb8 apps/coremark: Tickle watchdog in coremark shell command 5f7243fb8 is described below commit 5f7243fb8ed863963c6eabfe1b5e30e099d8f7c6 Author: Jerzy Kasenberg AuthorDate: Fri Jun 7 19:41:44 2024 +0200 apps/coremark: Tickle watchdog in coremark shell command This simply tickle watchdog before and after running coremark to prevent accidental reboot during command execution if watchdog was enabled. Signed-off-by: Jerzy Kasenberg --- util/coremark/src/coremark_shell.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util/coremark/src/coremark_shell.c b/util/coremark/src/coremark_shell.c index a736da8d8..4d5ef7c5f 100644 --- a/util/coremark/src/coremark_shell.c +++ b/util/coremark/src/coremark_shell.c @@ -20,8 +20,7 @@ #include #include -#include -#include +#include #include extern uint32_t SystemCoreClock; @@ -32,7 +31,13 @@ coremark_shell_cmd(int argc, char **argv) printf("Coremark running on %s at %lu MHz\n\n", MYNEWT_VAL(BSP_NAME), SystemCoreClock / 100L); +if(MYNEWT_VAL(WATCHDOG_INTERVAL) > 0) { +hal_watchdog_tickle(); +} coremark_run(); +if(MYNEWT_VAL(WATCHDOG_INTERVAL) > 0) { +hal_watchdog_tickle(); +} return 0; }
(mynewt-core) branch master updated: hw/mcu/stm32: Add option to place WFI in RAM
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 03f4a508b hw/mcu/stm32: Add option to place WFI in RAM 03f4a508b is described below commit 03f4a508b5126e110183ddf5e22dc57d8656fd18 Author: Jerzy Kasenberg AuthorDate: Sun May 26 12:41:07 2024 +0200 hw/mcu/stm32: Add option to place WFI in RAM Some STM32 devices have erratas for flash related issues that recommend workaround of placing WFI instruction in RAM. This is the case for STM32F4xx devices where other solution was to put WFI instruction at specific address locations (divisible by 8). New syscfg value STM32_WFI_FROM_RAM is introduced that adds function stm32_wfi_from_ram(). STM32_WFI is also added and can be used instead of WFI when needed BSP for affected STM32F4xx devices now use WFI from RAM instead of placing WFI instruction at aligne address. STM32L0 devices are also updated since anomally was also observed there. Signed-off-by: Jerzy Kasenberg --- hw/bsp/ada_feather_stm32f405/syscfg.yml| 1 + hw/bsp/b-l072z-lrwan1/syscfg.yml | 1 + hw/bsp/black_vet6/syscfg.yml | 1 + hw/bsp/nucleo-l073rz/syscfg.yml| 1 + hw/bsp/olimex_stm32-e407_devboard/syscfg.yml | 1 + hw/mcu/stm/stm32_common/include/stm32_common/mcu.h | 7 hw/mcu/stm/stm32_common/src/hal_os_tick.c | 39 +- hw/mcu/stm/stm32_common/syscfg.yml | 6 8 files changed, 33 insertions(+), 24 deletions(-) diff --git a/hw/bsp/ada_feather_stm32f405/syscfg.yml b/hw/bsp/ada_feather_stm32f405/syscfg.yml index 3e0ff7546..fc9fcd2fc 100644 --- a/hw/bsp/ada_feather_stm32f405/syscfg.yml +++ b/hw/bsp/ada_feather_stm32f405/syscfg.yml @@ -48,6 +48,7 @@ syscfg.vals: STM32_FLASH_PREFETCH_ENABLE: 1 STM32_INSTRUCTION_CACHE_ENABLE: 1 STM32_DATA_CACHE_ENABLE: 1 +STM32_WFI_FROM_RAM: 1 WATCHDOG_INTERVAL: 28000 # UART0 is on the large breakout connector, pins TX and RX. UART_0_PIN_TX: 'MCU_GPIO_PORTB(10)' diff --git a/hw/bsp/b-l072z-lrwan1/syscfg.yml b/hw/bsp/b-l072z-lrwan1/syscfg.yml index ca61b36b6..c893b7f7b 100644 --- a/hw/bsp/b-l072z-lrwan1/syscfg.yml +++ b/hw/bsp/b-l072z-lrwan1/syscfg.yml @@ -51,6 +51,7 @@ syscfg.vals: STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1' STM32_FLASH_LATENCY: 1 # max 32MHz STM32_FLASH_PREFETCH_ENABLE: 0 +STM32_WFI_FROM_RAM: 1 WATCHDOG_INTERVAL: 25000 UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)' UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)' diff --git a/hw/bsp/black_vet6/syscfg.yml b/hw/bsp/black_vet6/syscfg.yml index e5653b1a0..82335b00a 100644 --- a/hw/bsp/black_vet6/syscfg.yml +++ b/hw/bsp/black_vet6/syscfg.yml @@ -64,6 +64,7 @@ syscfg.vals: STM32_FLASH_PREFETCH_ENABLE: 1 STM32_INSTRUCTION_CACHE_ENABLE: 1 STM32_DATA_CACHE_ENABLE: 1 +STM32_WFI_FROM_RAM: 1 WATCHDOG_INTERVAL: 25000 SPI_0_MASTER: 1 diff --git a/hw/bsp/nucleo-l073rz/syscfg.yml b/hw/bsp/nucleo-l073rz/syscfg.yml index a964b30ff..fa2678abe 100644 --- a/hw/bsp/nucleo-l073rz/syscfg.yml +++ b/hw/bsp/nucleo-l073rz/syscfg.yml @@ -57,6 +57,7 @@ syscfg.vals: STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1' STM32_FLASH_LATENCY: 1 # max 32MHz STM32_FLASH_PREFETCH_ENABLE: 0 +STM32_WFI_FROM_RAM: 1 WATCHDOG_INTERVAL: 25000 UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)' UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)' diff --git a/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml b/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml index 27cc90cce..e6fb90f58 100644 --- a/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml +++ b/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml @@ -48,6 +48,7 @@ syscfg.vals: STM32_FLASH_PREFETCH_ENABLE: 1 STM32_INSTRUCTION_CACHE_ENABLE: 1 STM32_DATA_CACHE_ENABLE: 1 +STM32_WFI_FROM_RAM: 1 WATCHDOG_INTERVAL: 28000 UART_0_PIN_TX: 'MCU_GPIO_PORTC(6)' UART_0_PIN_RX: 'MCU_GPIO_PORTC(7)' diff --git a/hw/mcu/stm/stm32_common/include/stm32_common/mcu.h b/hw/mcu/stm/stm32_common/include/stm32_common/mcu.h index b0612b58f..a6c67fe21 100644 --- a/hw/mcu/stm/stm32_common/include/stm32_common/mcu.h +++ b/hw/mcu/stm/stm32_common/include/stm32_common/mcu.h @@ -108,6 +108,13 @@ extern "C" { void stm32_start_bootloader(void); +#if MYNEWT_VAL_STM32_WFI_FROM_RAM +extern void stm32_wfi_from_ram(void); +#define STM32_WFI stm32_wfi_from_ram +#else +#define STM32_WFI __WFI +#endif + #ifdef __cplusplus } #endif diff --git a/hw/mcu/stm/stm32_common/src/hal_os_tick.c b/hw/mcu/stm/stm32_common/src/hal_os_tick.c index fa7d14fda..4a2869078 100644 --- a/hw/mcu/stm/stm32_common/src/hal_os_tick.c +++ b/hw/mcu/stm/
(mynewt-core) 01/04: tinyusb/msc_fat_view: Add entry for sys/config
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 commit 6e3371f5bb14d9b176d966b0a123b0a42d85bada Author: Jerzy Kasenberg AuthorDate: Thu Apr 25 15:38:17 2024 +0200 tinyusb/msc_fat_view: Add entry for sys/config Signed-off-by: Jerzy Kasenberg --- hw/usb/tinyusb/msc_fat_view/pkg.yml| 7 ++ hw/usb/tinyusb/msc_fat_view/src/entry_config.c | 112 + hw/usb/tinyusb/msc_fat_view/syscfg.yml | 5 ++ 3 files changed, 124 insertions(+) diff --git a/hw/usb/tinyusb/msc_fat_view/pkg.yml b/hw/usb/tinyusb/msc_fat_view/pkg.yml index 51355fdf1..e57fb4ba5 100644 --- a/hw/usb/tinyusb/msc_fat_view/pkg.yml +++ b/hw/usb/tinyusb/msc_fat_view/pkg.yml @@ -30,8 +30,12 @@ pkg.deps: - "@apache-mynewt-core/kernel/os" - "@apache-mynewt-core/hw/usb/tinyusb" - "@apache-mynewt-core/mgmt/imgmgr" +- "@apache-mynewt-core/util/stream" - "@mcuboot/boot/bootutil" +pkg.deps.MSC_FAT_VIEW_CONFIG: +- "@apache-mynewt-core/sys/config" + pkg.deps.MSC_FAT_VIEW_COREDUMP_FILES: - "@apache-mynewt-core/sys/coredump" @@ -58,6 +62,9 @@ pkg.source_files.MSC_FAT_VIEW_SLOT0_HEX: pkg.source_files.MSC_FAT_VIEW_MYNEWT_SHORTCUT: - src/entry_mynewt_htm.c +pkg.source_files.MSC_FAT_VIEW_CONFIG: +- src/entry_config.c + pkg.link_tables: - msc_fat_view_root_entry diff --git a/hw/usb/tinyusb/msc_fat_view/src/entry_config.c b/hw/usb/tinyusb/msc_fat_view/src/entry_config.c new file mode 100644 index 0..be7f25a20 --- /dev/null +++ b/hw/usb/tinyusb/msc_fat_view/src/entry_config.c @@ -0,0 +1,112 @@ +/* + * 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 +#include +#include +#include +#include +#include + +struct config_export_stream { +struct out_stream out_stream; +uint8_t *buffer; +uint32_t buffer_start_offset; +uint16_t buffer_end_offset; +uint32_t write_offset; +}; + +static int +config_export_write(struct out_stream *ostream, const uint8_t *buf, uint32_t count) +{ +struct config_export_stream *str = (struct config_export_stream *)ostream; +uint32_t upper_limit = str->write_offset + count; +uint32_t lower_limit = str->write_offset; +int cnt = count; + +if (lower_limit < str->buffer_end_offset && upper_limit > str->buffer_start_offset) { +if (lower_limit < str->buffer_start_offset) { +cnt -= str->buffer_start_offset - lower_limit; +lower_limit = str->buffer_start_offset; +} +if (upper_limit > str->buffer_end_offset) { +cnt -= upper_limit - str->buffer_end_offset; +} +memcpy(str->buffer + lower_limit - str->buffer_start_offset, + buf + (lower_limit - str->write_offset), cnt); +} +str->write_offset += count; + +return count; +} + +static int +config_export_flush(struct out_stream *ostream) +{ +return 0; +} + +OSTREAM_DEF(config_export); + +static struct config_export_stream export_stream = { +.out_stream.vft = &config_export_vft, +}; + +static void +config_text_export(char *name, char *val) +{ +int name_len = strlen(name); +int val_len = 0; +if (val) { +val_len = strlen(val); +} +ostream_write(&export_stream.out_stream, (const uint8_t *)name, name_len, false); +ostream_write(&export_stream.out_stream, (const uint8_t *)" = ", 3, false); +if (val) { +ostream_write(&export_stream.out_stream, (const uint8_t *)val, val_len, false); +} +ostream_write(&export_stream.out_stream, (const uint8_t *)"\n", 1, false); +} + +static uint32_t +config_txt_size(const file_entry_t *file_entry) +{ +export_stream.buffer = NULL; +export_stream.buffer_start_offset = 0; +export_stream.buffer_end_offset = 0; +export_stream.write_offset = 0; + +conf_export(config_text_export, CONF_EXPORT_SHOW); + +return export_stream.write_offset; +} + +static void +
(mynewt-core) 02/04: tinyusb/msc_fat_view: Add multiply write handlers
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 commit 0c6895a801890c4f63186b2d0617ede9d2e29b57 Author: Jerzy Kasenberg AuthorDate: Wed May 29 15:47:29 2024 +0200 tinyusb/msc_fat_view: Add multiply write handlers This update msc_fat_view so: - statically added entries (link tables) can be hidden if valid() tells to hide - there was only one handler that could take care of writes to unallocated disk area. Now several can be used (image write, config write, possible U2C) --- .../include/msc_fat_view/msc_fat_view.h| 82 +-- hw/usb/tinyusb/msc_fat_view/pkg.yml| 2 + hw/usb/tinyusb/msc_fat_view/src/entry_huge_file.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/entry_mynewt_htm.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/entry_readme.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/entry_slot0.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/entry_slot0_hex.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c | 155 + 8 files changed, 116 insertions(+), 133 deletions(-) diff --git a/hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h b/hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h index 77e425289..3895467b4 100644 --- a/hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h +++ b/hw/usb/tinyusb/msc_fat_view/include/msc_fat_view/msc_fat_view.h @@ -21,6 +21,9 @@ #define __MSC_FAT_VIEW_H__ #include +#include + +#define SECTOR_SIZE 512 #define FAT_FILE_ENTRY_ATTRIBUTE_FILE 0x00 #define FAT_FILE_ENTRY_ATTRIBUTE_READ_ONLY 0x01 @@ -30,6 +33,9 @@ #define FAT_FILE_ENTRY_ATTRIBUTE_DIRECTORY 0x10 #define FAT_FILE_ENTRY_ATTRIBUTE_ARCHIVE0x20 +#define MSC_FAT_VIEW_FILE_ENTRY_VALID 0 +#define MSC_FAT_VIEW_FILE_ENTRY_NOT_VALID 1 + typedef struct file_entry { /** File name */ const char *name; @@ -38,13 +44,25 @@ typedef struct file_entry { /** Function returning file size */ uint32_t (*size)(const struct file_entry *entry); /** Function called when host tries to read file sector */ -void (*read_sector)(const struct file_entry *entry, uint32_t file_sector, uint8_t buffer[512]); +void (*read_sector)(const struct file_entry *entry, +uint32_t file_sector, uint8_t buffer[512]); /** Function called when host tries to write file sector */ -void (*write_sector)(const struct file_entry *entry, uint32_t file_sector, const uint8_t buffer[512]); +void (*write_sector)(const struct file_entry *entry, + uint32_t file_sector, uint8_t buffer[512]); /** Function called when host deletes file */ void (*delete_entry)(const struct file_entry *entry); +/** Function called before entry is added to root folder, + * allows to have statically created entry to be removed */ +int (*valid)(const struct file_entry *entry); } file_entry_t; +typedef struct msc_fat_view_write_handler { +int (*write_sector)(struct msc_fat_view_write_handler *handler, +uint32_t sector, uint8_t buffer[512]); +int (*file_written)(struct msc_fat_view_write_handler *handler, +uint32_t size, uint32_t sector, bool first_sector); +} msc_fat_view_write_handler_t; + /** * Add file handler to root folder. * @@ -74,17 +92,59 @@ void msc_fat_view_media_insert(void); /* Section name for root entries */ #define ROOT_DIR_SECTION __attribute__((section(".msc_fat_view_root_entry"), used)) +/* Section name for write handlers */ +#define WRITE_HANDLER_SECTION __attribute__((section(".msc_fat_view_write_handlers"), used)) + /** * Macro to add static root entries */ -#define ROOT_DIR_ENTRY(entry, file_name, attr, size_fun, read_fun, write_fun, delete_fun) \ -const file_entry_t entry ROOT_DIR_SECTION = { \ -.name = file_name, \ -.attributes = attr,\ -.size = size_fun, \ -.read_sector = read_fun, \ -.write_sector = write_fun, \ -.delete_entry = delete_fun,\ -} +#define ROOT_DIR_ENTRY(entry, file_name, attr, size_fun, read_fun, write_fun, delete_fun, valid_fun) \ +file_entry_t entry = { \ +.name = file_name, \ +.attributes = attr,\ +.size = size_fun, \ +.read_sector = read_fun, \ +.write_sector = write_fun, \ +.delete_entry = delete_fun,\ +.valid = valid_fun,\ +}; \ +const file_entry_t *entry ## _ptr ROOT_DIR_SECTION = &entry; + +/** + * M
(mynewt-core) 03/04: tinyusb/msc_fat_view: Add update handler
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 commit 5b547eb1a8450aea2c4cb4778cff8b6030aefb73 Author: Jerzy Kasenberg AuthorDate: Wed May 29 15:50:04 2024 +0200 tinyusb/msc_fat_view: Add update handler Update handler in separate file, code was part of msc_fat_view.c --- hw/usb/tinyusb/msc_fat_view/pkg.yml | 3 + hw/usb/tinyusb/msc_fat_view/src/update_handler.c | 250 +++ 2 files changed, 253 insertions(+) diff --git a/hw/usb/tinyusb/msc_fat_view/pkg.yml b/hw/usb/tinyusb/msc_fat_view/pkg.yml index 42ba4c9f2..a03134786 100644 --- a/hw/usb/tinyusb/msc_fat_view/pkg.yml +++ b/hw/usb/tinyusb/msc_fat_view/pkg.yml @@ -65,6 +65,9 @@ pkg.source_files.MSC_FAT_VIEW_MYNEWT_SHORTCUT: pkg.source_files.MSC_FAT_VIEW_CONFIG: - src/entry_config.c +pkg.source_files.MSC_FAT_VIEW_UPDATE_HANDLER: +- src/update_handler.c + pkg.link_tables: - msc_fat_view_root_entry - msc_fat_view_write_handlers diff --git a/hw/usb/tinyusb/msc_fat_view/src/update_handler.c b/hw/usb/tinyusb/msc_fat_view/src/update_handler.c new file mode 100644 index 0..7512518a2 --- /dev/null +++ b/hw/usb/tinyusb/msc_fat_view/src/update_handler.c @@ -0,0 +1,250 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if MYNEWT_VAL(BOOT_LOADER) +#define BOOT_LOADER 1 +#define FLASH_AREA_IMAGE FLASH_AREA_IMAGE_0 +#else +#define BOOT_LOADER 0 +#ifdef FLASH_AREA_IMAGE_1 +#define FLASH_AREA_IMAGE FLASH_AREA_IMAGE_1 +#endif +#endif + +/* If true, test image will be confirmed on root directory read */ +static bool confirmed; + +typedef enum { +MEDIUM_NOT_PRESENT, +REPORT_MEDIUM_CHANGE, +MEDIUM_RELOAD, +MEDIUM_PRESENT, +} medium_state_t; + +static medium_state_t medium_state; + +struct unallocated_write { +uint32_t first_sector; +uint32_t last_sector; +enum { +NOT_TOUCHED_YET = 0, +WRITE_IN_PROGRESS = 1, +NOT_AN_IMAGE = -1, +CURRENT_IMAGE_NOT_CONFIRMED = -2, +WRITE_EXCEEDED_SPACE = -3, +WRITE_NOT_IN_SEQUENCE = -4, +} write_status; +} unallocated_write; + +static int write_status; +static const char *write_result_text[] = { +"File that was written was not a valid image.", +"Current image not confirmed, new image rejected.", +"File write error.", +}; + +static uint32_t +flash_result_create_content(struct MemFile *file) +{ +int ix = abs(write_status) - 1; +if (ix > 2) { +ix = 2; +} +fwrite(write_result_text[ix], 1, strlen(write_result_text[ix]), &file->file); + +return file->bytes_written; +} + +static uint32_t +flash_result_size(const file_entry_t *file_entry) +{ +struct MemFile sector_file; + +(void)file_entry; +fmemopen_w(§or_file, (char *)NULL, 0); + +flash_result_create_content(§or_file); + +return sector_file.bytes_written; +} + +static void +flash_result_read(const struct file_entry *entry, uint32_t file_sector, uint8_t buffer[512]) +{ +struct MemFile sector_file; +int written = 0; +(void)entry; + +if (file_sector == 0) { +fmemopen_w(§or_file, (char *)buffer, 512); +flash_result_create_content(§or_file); +written = sector_file.bytes_written; +} + +memset(buffer + written, 0, 512 - written); +} + +static const file_entry_t flash_result = { +.name = "Write error.txt", +.attributes = FAT_FILE_ENTRY_ATTRIBUTE_READ_ONLY, +.size = flash_result_size, +.read_sector = flash_result_read, +}; + +static int +image_write_sector(struct msc_fat_view_write_handler *handler, uint32_t sector, uint8_t *buffer) +{ +#ifdef FLASH_AREA_IMAGE +const struct flash_area *fa; +uint32_t write_offset; +int rc; + +if (unallocated_write.write_status < 0) { +return 0; +} +flash_area_open(FLASH_AREA_IMAGE, &fa); +if (unallocated_write.write_status == NOT_TOUCHED_YET) { +if (BOOT_LOA
(mynewt-core) branch master updated (6f5cef0bb -> 3ea5f71fb)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 6f5cef0bb stm32f1/rtc_tick: Fix tick interrupt generation new 6e3371f5b tinyusb/msc_fat_view: Add entry for sys/config new 0c6895a80 tinyusb/msc_fat_view: Add multiply write handlers new 5b547eb1a tinyusb/msc_fat_view: Add update handler new 3ea5f71fb tinyusb/msc_fat_view: Add write support for config.txt The 4 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: .../include/msc_fat_view/msc_fat_view.h| 82 +- hw/usb/tinyusb/msc_fat_view/pkg.yml| 12 + hw/usb/tinyusb/msc_fat_view/src/entry_config.c | 289 + hw/usb/tinyusb/msc_fat_view/src/entry_huge_file.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/entry_mynewt_htm.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/entry_readme.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/entry_slot0.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/entry_slot0_hex.c | 2 +- hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c | 155 +++ hw/usb/tinyusb/msc_fat_view/src/update_handler.c | 250 ++ hw/usb/tinyusb/msc_fat_view/syscfg.yml | 5 + 11 files changed, 670 insertions(+), 133 deletions(-) create mode 100644 hw/usb/tinyusb/msc_fat_view/src/entry_config.c create mode 100644 hw/usb/tinyusb/msc_fat_view/src/update_handler.c
(mynewt-core) 04/04: tinyusb/msc_fat_view: Add write support for config.txt
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 commit 3ea5f71fb72c37f7b51739f98b88dd792a59ed46 Author: Jerzy Kasenberg AuthorDate: Wed May 29 15:53:30 2024 +0200 tinyusb/msc_fat_view: Add write support for config.txt Code allows to write back configuration. Signed-off-by: Jerzy Kasenberg --- hw/usb/tinyusb/msc_fat_view/src/entry_config.c | 185 - 1 file changed, 181 insertions(+), 4 deletions(-) diff --git a/hw/usb/tinyusb/msc_fat_view/src/entry_config.c b/hw/usb/tinyusb/msc_fat_view/src/entry_config.c index be7f25a20..91f1be0ea 100644 --- a/hw/usb/tinyusb/msc_fat_view/src/entry_config.c +++ b/hw/usb/tinyusb/msc_fat_view/src/entry_config.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -26,9 +27,13 @@ struct config_export_stream { struct out_stream out_stream; +/* Buffer to write to (can be NULL) */ uint8_t *buffer; +/* Stream start offset, writes to stream preceding this will be dropped */ uint32_t buffer_start_offset; +/* Stream end offset, writes to stream after this will be dropped */ uint16_t buffer_end_offset; +/* Current stream write offset */ uint32_t write_offset; }; @@ -73,6 +78,7 @@ config_text_export(char *name, char *val) { int name_len = strlen(name); int val_len = 0; + if (val) { val_len = strlen(val); } @@ -84,6 +90,17 @@ config_text_export(char *name, char *val) ostream_write(&export_stream.out_stream, (const uint8_t *)"\n", 1, false); } +static const char *const CONFIG_BEGIN = " Config begin \n"; +static const char *const CONFIG_END = "# Config end #\n"; + +void +config_txt_render_file(struct out_stream *stream) +{ +ostream_write_str(&export_stream.out_stream, CONFIG_BEGIN); +conf_export(config_text_export, CONF_EXPORT_SHOW); +ostream_write_str(&export_stream.out_stream, CONFIG_END); +} + static uint32_t config_txt_size(const file_entry_t *file_entry) { @@ -92,7 +109,7 @@ config_txt_size(const file_entry_t *file_entry) export_stream.buffer_end_offset = 0; export_stream.write_offset = 0; -conf_export(config_text_export, CONF_EXPORT_SHOW); +config_txt_render_file(&export_stream.out_stream); return export_stream.write_offset; } @@ -105,8 +122,168 @@ config_txt_read(const struct file_entry *entry, uint32_t file_sector, uint8_t bu export_stream.buffer_end_offset = export_stream.buffer_start_offset + 512; export_stream.write_offset = 0; -MSC_FAT_VIEW_LOG_DEBUG("Config.txt read %d\n", file_sector); -conf_export(config_text_export, CONF_EXPORT_SHOW); +MSC_FAT_VIEW_LOG_DEBUG("Config.txt read sector %d\n", file_sector); +config_txt_render_file(&export_stream.out_stream); +} + +static uint8_t *line; +static size_t line_len; + +enum config_write_state { +WRITE_STATE_IDLE, +WRITE_STATE_DROP, +WRITE_STATE_CONFIG_LINES, +WRITE_STATE_CONFIG_WRITTEN, + +} config_write_state; + +static struct os_callout reboot_callout; + +static void +reboot_fun(struct os_event *ev) +{ +os_reboot(0); +} + +static void +handle_line(uint8_t *bl, uint8_t *el) +{ +size_t len = el - bl; +uint8_t *p; +uint8_t *nb; +uint8_t *ne; +uint8_t *vb; + +if (config_write_state == WRITE_STATE_IDLE) { +if (memcmp(CONFIG_BEGIN, bl, len) == 0) { +config_write_state = WRITE_STATE_CONFIG_LINES; +return; +} +} else if (config_write_state == WRITE_STATE_CONFIG_LINES) { +if (memcmp(CONFIG_END, bl, len) == 0) { +conf_commit(NULL); +conf_save(); +config_write_state = WRITE_STATE_CONFIG_WRITTEN; +os_callout_init(&reboot_callout, os_eventq_dflt_get(), reboot_fun, NULL); +os_callout_reset(&reboot_callout, os_time_ms_to_ticks32(2000)); +return; +} + +/* Trim line to first # */ +for (p = bl; p < el && *p != '#'; ++p) { +} +el = p; +/* Trim trailing spaces */ +for (p = el - 1; p >= bl && isspace(*p); --p) { +} +el = p + 1; + +/* Trim leading spaces */ +for (p = bl; p < el && isspace(*p); ++p) { +} +if (p >= el) { +return; +} +/* Variable name start found */ +nb = p; +/* Find variable name end */ +for (; p < el && !isspace(*p) && *p != '='; ++p) { +} +ne = p; +/* Skip spaces if any */ +for (; p < el && isspace(*p); ++p) { +} +/* If next character is not = nothing to set */ +if (p >= el || *p != '=') { +return;
(mynewt-core) branch master updated: stm32f1/rtc_tick: Fix tick interrupt generation
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 6f5cef0bb stm32f1/rtc_tick: Fix tick interrupt generation 6f5cef0bb is described below commit 6f5cef0bb94fb9eacfe3b9431796b9499306ddf6 Author: Jerzy Kasenberg AuthorDate: Wed Jun 5 23:48:51 2024 +0200 stm32f1/rtc_tick: Fix tick interrupt generation When RTC (STM32F1 specific only) was used as os tick source. If OS requested longer tickles time RTC alarm was set to some time in the future. After WFI finished RTC periodic tick interrupt was not enabled. If then some task took more time and periodically checked time, time would never advance due to RTC tick interrupt being disabled. Time would advance only in idle task. Now normal tick is working all the time unless there is nothing to do and after WFI finishes tick is enabled again. Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c b/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c index febceda4e..3220991f3 100644 --- a/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c +++ b/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c @@ -108,6 +108,8 @@ os_tick_idle(os_time_t ticks) */ stm32_os_tick_update_rtc(); } +/* Disable alarm, enable tick interrupt. */ +RTC->CRH = RTC_CRH_SECIE_Msk; } void
(mynewt-core) branch master updated: boot/startup: Fix linker script filter for code in RAM
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 e54ac3174 boot/startup: Fix linker script filter for code in RAM e54ac3174 is described below commit e54ac3174139f302a53d766e038d5fe29d44270d Author: Jerzy Kasenberg AuthorDate: Wed Jun 5 23:03:13 2024 +0200 boot/startup: Fix linker script filter for code in RAM Filter .text* was before .text_ram* resulting in code intended for ram to be placed in normal flash. Now .text.* is used for flash destination Signed-off-by: Jerzy Kasenberg --- boot/startup/mynewt_cortex_m0.ld | 2 +- boot/startup/mynewt_cortex_m3.ld | 2 +- boot/startup/mynewt_cortex_m33.ld | 2 +- boot/startup/mynewt_cortex_m4.ld | 2 +- boot/startup/mynewt_cortex_m7.ld | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boot/startup/mynewt_cortex_m0.ld b/boot/startup/mynewt_cortex_m0.ld index 9585918be..204f29f1f 100644 --- a/boot/startup/mynewt_cortex_m0.ld +++ b/boot/startup/mynewt_cortex_m0.ld @@ -89,7 +89,7 @@ SECTIONS { . = ALIGN(4); *(.text) /* .text sections (code) */ -*(.text*)/* .text* sections (code) */ +*(.text.*) /* .text* sections (code) */ KEEP(*(.init)) KEEP(*(.fini)) diff --git a/boot/startup/mynewt_cortex_m3.ld b/boot/startup/mynewt_cortex_m3.ld index 9585918be..204f29f1f 100644 --- a/boot/startup/mynewt_cortex_m3.ld +++ b/boot/startup/mynewt_cortex_m3.ld @@ -89,7 +89,7 @@ SECTIONS { . = ALIGN(4); *(.text) /* .text sections (code) */ -*(.text*)/* .text* sections (code) */ +*(.text.*) /* .text* sections (code) */ KEEP(*(.init)) KEEP(*(.fini)) diff --git a/boot/startup/mynewt_cortex_m33.ld b/boot/startup/mynewt_cortex_m33.ld index 9585918be..204f29f1f 100644 --- a/boot/startup/mynewt_cortex_m33.ld +++ b/boot/startup/mynewt_cortex_m33.ld @@ -89,7 +89,7 @@ SECTIONS { . = ALIGN(4); *(.text) /* .text sections (code) */ -*(.text*)/* .text* sections (code) */ +*(.text.*) /* .text* sections (code) */ KEEP(*(.init)) KEEP(*(.fini)) diff --git a/boot/startup/mynewt_cortex_m4.ld b/boot/startup/mynewt_cortex_m4.ld index 3f9703fd3..6f0237751 100644 --- a/boot/startup/mynewt_cortex_m4.ld +++ b/boot/startup/mynewt_cortex_m4.ld @@ -101,7 +101,7 @@ SECTIONS { . = ALIGN(4); *(.text) /* .text sections (code) */ -*(.text*)/* .text* sections (code) */ +*(.text.*) /* .text* sections (code) */ KEEP(*(.init)) KEEP(*(.fini)) diff --git a/boot/startup/mynewt_cortex_m7.ld b/boot/startup/mynewt_cortex_m7.ld index 18db83a6d..0d5031827 100644 --- a/boot/startup/mynewt_cortex_m7.ld +++ b/boot/startup/mynewt_cortex_m7.ld @@ -90,7 +90,7 @@ SECTIONS { . = ALIGN(4); *(.text) /* .text sections (code) */ -*(.text*)/* .text* sections (code) */ +*(.text.*) /* .text* sections (code) */ KEEP(*(.init)) KEEP(*(.fini))
(mynewt-core) 02/02: hw/bsp: Fix Watchdog interval for STM32 BSPs
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 commit 5c117444941c1c51093af59f977143a749d11626 Author: Jerzy Kasenberg AuthorDate: Sat May 25 23:44:04 2024 +0200 hw/bsp: Fix Watchdog interval for STM32 BSPs Default value 30s is out of range for all STM32 devices. This sets WATCHDOG_INTERVAL to maximum correct value that depends on LSI_VALUE for each MCU. Additionally static assert is added to hal_watchdog.c that checks if WATCHDOG_INTERVAL value does not exceed range. --- hw/bsp/ada_feather_stm32f405/syscfg.yml | 1 + hw/bsp/b-l072z-lrwan1/syscfg.yml | 1 + hw/bsp/b-l475e-iot01a/syscfg.yml | 1 + hw/bsp/black_vet6/syscfg.yml | 1 + hw/bsp/bluepill/syscfg.yml | 1 + hw/bsp/nucleo-f030r8/syscfg.yml | 1 + hw/bsp/nucleo-f072rb/syscfg.yml | 1 + hw/bsp/nucleo-f103rb/syscfg.yml | 1 + hw/bsp/nucleo-f303k8/syscfg.yml | 1 + hw/bsp/nucleo-f303re/syscfg.yml | 1 + hw/bsp/nucleo-f401re/syscfg.yml | 1 + hw/bsp/nucleo-f411re/syscfg.yml | 1 + hw/bsp/nucleo-f413zh/syscfg.yml | 1 + hw/bsp/nucleo-f439zi/syscfg.yml | 1 + hw/bsp/nucleo-f746zg/syscfg.yml | 1 + hw/bsp/nucleo-f767zi/syscfg.yml | 1 + hw/bsp/nucleo-g0b1re/syscfg.yml | 1 + hw/bsp/nucleo-g491re/syscfg.yml | 1 + hw/bsp/nucleo-h723zg/syscfg.yml | 1 + hw/bsp/nucleo-l073rz/syscfg.yml | 1 + hw/bsp/nucleo-l476rg/syscfg.yml | 1 + hw/bsp/nucleo-u575zi-q/syscfg.yml| 1 + hw/bsp/olimex-p103/syscfg.yml| 1 + hw/bsp/olimex_stm32-e407_devboard/syscfg.yml | 1 + hw/bsp/p-nucleo-wb55-usbdongle/syscfg.yml| 1 + hw/bsp/p-nucleo-wb55/syscfg.yml | 1 + hw/bsp/stm32f3discovery/syscfg.yml | 1 + hw/bsp/stm32f411discovery/syscfg.yml | 1 + hw/bsp/stm32f429discovery/syscfg.yml | 1 + hw/bsp/stm32f4discovery/syscfg.yml | 1 + hw/bsp/stm32f7discovery/syscfg.yml | 1 + hw/bsp/stm32l152discovery/syscfg.yml | 1 + hw/bsp/weact_g431cb/syscfg.yml | 1 + hw/mcu/stm/stm32_common/src/hal_watchdog.c | 5 + 34 files changed, 38 insertions(+) diff --git a/hw/bsp/ada_feather_stm32f405/syscfg.yml b/hw/bsp/ada_feather_stm32f405/syscfg.yml index e9661eb75..3e0ff7546 100644 --- a/hw/bsp/ada_feather_stm32f405/syscfg.yml +++ b/hw/bsp/ada_feather_stm32f405/syscfg.yml @@ -48,6 +48,7 @@ syscfg.vals: STM32_FLASH_PREFETCH_ENABLE: 1 STM32_INSTRUCTION_CACHE_ENABLE: 1 STM32_DATA_CACHE_ENABLE: 1 +WATCHDOG_INTERVAL: 28000 # UART0 is on the large breakout connector, pins TX and RX. UART_0_PIN_TX: 'MCU_GPIO_PORTB(10)' UART_0_PIN_RX: 'MCU_GPIO_PORTB(11)' diff --git a/hw/bsp/b-l072z-lrwan1/syscfg.yml b/hw/bsp/b-l072z-lrwan1/syscfg.yml index b4830..ca61b36b6 100644 --- a/hw/bsp/b-l072z-lrwan1/syscfg.yml +++ b/hw/bsp/b-l072z-lrwan1/syscfg.yml @@ -51,6 +51,7 @@ syscfg.vals: STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1' STM32_FLASH_LATENCY: 1 # max 32MHz STM32_FLASH_PREFETCH_ENABLE: 0 +WATCHDOG_INTERVAL: 25000 UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)' UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)' SPI_1_CUSTOM_CFG: 1 diff --git a/hw/bsp/b-l475e-iot01a/syscfg.yml b/hw/bsp/b-l475e-iot01a/syscfg.yml index 6e8a3e4fb..2b8cbfab3 100644 --- a/hw/bsp/b-l475e-iot01a/syscfg.yml +++ b/hw/bsp/b-l475e-iot01a/syscfg.yml @@ -59,6 +59,7 @@ syscfg.vals: STM32_FLASH_PREFETCH_ENABLE: 0 STM32_INSTRUCTION_CACHE_ENABLE: 1 STM32_DATA_CACHE_ENABLE: 1 +WATCHDOG_INTERVAL: 25000 UART_0_PIN_TX: 'MCU_GPIO_PORTB(6)' UART_0_PIN_RX: 'MCU_GPIO_PORTB(7)' I2C_0_PIN_SCL: 'MCU_GPIO_PORTB(8)' diff --git a/hw/bsp/black_vet6/syscfg.yml b/hw/bsp/black_vet6/syscfg.yml index cdcf4490b..e5653b1a0 100644 --- a/hw/bsp/black_vet6/syscfg.yml +++ b/hw/bsp/black_vet6/syscfg.yml @@ -64,6 +64,7 @@ syscfg.vals: STM32_FLASH_PREFETCH_ENABLE: 1 STM32_INSTRUCTION_CACHE_ENABLE: 1 STM32_DATA_CACHE_ENABLE: 1 +WATCHDOG_INTERVAL: 25000 SPI_0_MASTER: 1 # On board SPIFLASH configuration for W25Q16VBS diff --git a/hw/bsp/bluepill/syscfg.yml b/hw/bsp/bluepill/syscfg.yml index f191db868..d601947e2 100644 --- a/hw/bsp/bluepill/syscfg.yml +++ b/hw/bsp/bluepill/syscfg.yml @@ -39,6 +39,7 @@ syscfg.vals: STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1' STM32_FLASH_LATENCY: 'FLASH_LATENCY_2' STM32_FLASH_PREFETCH_ENABLE: 1 +WATCHDOG_INTERVAL: 22000 UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)' UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)' SPI_0_PIN_SS: 'MCU_GPIO_PORTA(4)' diff --gi
(mynewt-core) branch master updated (f2b4e4102 -> 5c1174449)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from f2b4e4102 pwm/pwm_da1469x: Preserve timer state on frequency change. new 43525cb69 mcu/stm32: Fix hal_reset_cause for some stm32 devices new 5c1174449 hw/bsp: Fix Watchdog interval for STM32 BSPs 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: hw/bsp/ada_feather_stm32f405/syscfg.yml | 1 + hw/bsp/b-l072z-lrwan1/syscfg.yml | 1 + hw/bsp/b-l475e-iot01a/syscfg.yml | 1 + hw/bsp/black_vet6/syscfg.yml | 1 + hw/bsp/bluepill/syscfg.yml | 1 + hw/bsp/nucleo-f030r8/syscfg.yml | 1 + hw/bsp/nucleo-f072rb/syscfg.yml | 1 + hw/bsp/nucleo-f103rb/syscfg.yml | 1 + hw/bsp/nucleo-f303k8/syscfg.yml | 1 + hw/bsp/nucleo-f303re/syscfg.yml | 1 + hw/bsp/nucleo-f401re/syscfg.yml | 1 + hw/bsp/nucleo-f411re/syscfg.yml | 1 + hw/bsp/nucleo-f413zh/syscfg.yml | 1 + hw/bsp/nucleo-f439zi/syscfg.yml | 1 + hw/bsp/nucleo-f746zg/syscfg.yml | 1 + hw/bsp/nucleo-f767zi/syscfg.yml | 1 + hw/bsp/nucleo-g0b1re/syscfg.yml | 1 + hw/bsp/nucleo-g491re/syscfg.yml | 1 + hw/bsp/nucleo-h723zg/syscfg.yml | 1 + hw/bsp/nucleo-l073rz/syscfg.yml | 1 + hw/bsp/nucleo-l476rg/syscfg.yml | 1 + hw/bsp/nucleo-u575zi-q/syscfg.yml| 1 + hw/bsp/olimex-p103/syscfg.yml| 1 + hw/bsp/olimex_stm32-e407_devboard/syscfg.yml | 1 + hw/bsp/p-nucleo-wb55-usbdongle/syscfg.yml| 1 + hw/bsp/p-nucleo-wb55/syscfg.yml | 1 + hw/bsp/stm32f3discovery/syscfg.yml | 1 + hw/bsp/stm32f411discovery/syscfg.yml | 1 + hw/bsp/stm32f429discovery/syscfg.yml | 1 + hw/bsp/stm32f4discovery/syscfg.yml | 1 + hw/bsp/stm32f7discovery/syscfg.yml | 1 + hw/bsp/stm32l152discovery/syscfg.yml | 1 + hw/bsp/weact_g431cb/syscfg.yml | 1 + hw/mcu/stm/stm32_common/src/hal_watchdog.c | 5 + hw/mcu/stm/stm32f0xx/src/hal_reset_cause.c | 8 hw/mcu/stm/stm32f1xx/src/hal_reset_cause.c | 9 - hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c | 6 -- hw/mcu/stm/stm32l4xx/src/hal_reset_cause.c | 9 - hw/mcu/stm/stm32u5xx/src/hal_reset_cause.c | 9 - hw/mcu/stm/stm32wbxx/src/hal_reset_cause.c | 9 - 40 files changed, 62 insertions(+), 26 deletions(-)
(mynewt-core) 01/02: mcu/stm32: Fix hal_reset_cause for some stm32 devices
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 commit 43525cb6913f5a5dc6a56befd24057bb6bfce778 Author: Jerzy Kasenberg AuthorDate: Sat May 25 23:35:08 2024 +0200 mcu/stm32: Fix hal_reset_cause for some stm32 devices This is common rework for hal_reset_cause(). Mostly Power on reset or Brown out reset were never reported due to reset pin having priority over those two. Watchdog for some MCU was never reported. --- hw/mcu/stm/stm32f0xx/src/hal_reset_cause.c | 8 hw/mcu/stm/stm32f1xx/src/hal_reset_cause.c | 9 - hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c | 6 -- hw/mcu/stm/stm32l4xx/src/hal_reset_cause.c | 9 - hw/mcu/stm/stm32u5xx/src/hal_reset_cause.c | 9 - hw/mcu/stm/stm32wbxx/src/hal_reset_cause.c | 9 - 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/hw/mcu/stm/stm32f0xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32f0xx/src/hal_reset_cause.c index 1e9325054..9c692bdfc 100644 --- a/hw/mcu/stm/stm32f0xx/src/hal_reset_cause.c +++ b/hw/mcu/stm/stm32f0xx/src/hal_reset_cause.c @@ -31,16 +31,16 @@ hal_reset_cause(void) } reg = RCC->CSR; -if (reg & RCC_CSR_WWDGRSTF || reg & RCC_CSR_IWDGRSTF) { +if (reg & RCC_CSR_PORRSTF) { +reason = HAL_RESET_POR; +} else if (reg & RCC_CSR_WWDGRSTF || reg & RCC_CSR_IWDGRSTF) { reason = HAL_RESET_WATCHDOG; } else if (reg & RCC_CSR_SFTRSTF) { reason = HAL_RESET_SOFT; } else if (reg & RCC_CSR_PINRSTF) { reason = HAL_RESET_PIN; -} else if (reg & RCC_CSR_PORRSTF) { -reason = HAL_RESET_BROWNOUT; } else { -reason = HAL_RESET_POR; +reason = HAL_RESET_OTHER; } RCC->CSR |= RCC_CSR_RMVF; return reason; diff --git a/hw/mcu/stm/stm32f1xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32f1xx/src/hal_reset_cause.c index e98aeec3a..d6c1343c7 100644 --- a/hw/mcu/stm/stm32f1xx/src/hal_reset_cause.c +++ b/hw/mcu/stm/stm32f1xx/src/hal_reset_cause.c @@ -32,17 +32,16 @@ hal_reset_cause(void) reg = RCC->CSR; -if (reg & RCC_CSR_WWDGRSTF) { +if (reg & (RCC_CSR_PORRSTF)) { +reason = HAL_RESET_POR; +} else if (reg & (RCC_CSR_WWDGRSTF | RCC_CSR_IWDGRSTF)) { reason = HAL_RESET_WATCHDOG; } else if (reg & RCC_CSR_SFTRSTF) { reason = HAL_RESET_SOFT; } else if (reg & RCC_CSR_PINRSTF) { reason = HAL_RESET_PIN; -} else if (reg & RCC_CSR_LPWRRSTF) { -/* For L1xx this is low-power reset */ -reason = HAL_RESET_BROWNOUT; } else { -reason = HAL_RESET_POR; +reason = HAL_RESET_OTHER; } RCC->CSR |= RCC_CSR_RMVF; return reason; diff --git a/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c index f5ca0a030..b734d88ff 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c @@ -32,7 +32,9 @@ hal_reset_cause(void) reg = RCC->CSR; -if (reg & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF)) { +if (reg & RCC_CSR_PORRSTF) { +reason = HAL_RESET_POR; +} else if (reg & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF)) { reason = HAL_RESET_WATCHDOG; } else if (reg & RCC_CSR_SFTRSTF) { reason = HAL_RESET_SOFT; @@ -43,7 +45,7 @@ hal_reset_cause(void) reason = HAL_RESET_BROWNOUT; #endif } else { -reason = HAL_RESET_POR; +reason = HAL_RESET_OTHER; } RCC->CSR |= RCC_CSR_RMVF; return reason; diff --git a/hw/mcu/stm/stm32l4xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32l4xx/src/hal_reset_cause.c index a56891699..47586eb29 100644 --- a/hw/mcu/stm/stm32l4xx/src/hal_reset_cause.c +++ b/hw/mcu/stm/stm32l4xx/src/hal_reset_cause.c @@ -32,17 +32,16 @@ hal_reset_cause(void) reg = RCC->CSR; -if (reg & RCC_CSR_WWDGRSTF) { +if (reg & (RCC_CSR_BORRSTF)) { +reason = HAL_RESET_BROWNOUT; +} else if (reg & (RCC_CSR_WWDGRSTF | RCC_CSR_IWDGRSTF)) { reason = HAL_RESET_WATCHDOG; } else if (reg & RCC_CSR_SFTRSTF) { reason = HAL_RESET_SOFT; } else if (reg & RCC_CSR_PINRSTF) { reason = HAL_RESET_PIN; -} else if (reg & RCC_CSR_LPWRRSTF) { -/* For L1xx this is low-power reset */ -reason = HAL_RESET_BROWNOUT; } else { -reason = HAL_RESET_POR; +reason = HAL_RESET_OTHER; } RCC->CSR |= RCC_CSR_RMVF; return reason; diff --git a/hw/mcu/stm/stm32u5xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32u5xx/src/hal_reset_cause.c index 6dc6c006e..8c8dd0c78 100644 --- a/hw/mcu/stm/stm32u5xx/src/hal_reset_cause.c +++ b/hw/mcu/stm/stm32u5xx/src/hal_reset_cause.c @@ -32,17 +32,16 @@ hal_reset_cause(void) reg = RCC->CSR; -
(mynewt-core) 02/03: sensors/ina219: Fix voltage calculation
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 commit bb0a5dea46897e5a466929fcf25c794605dfd8e4 Author: Jerzy Kasenberg AuthorDate: Sat May 18 16:55:19 2024 +0200 sensors/ina219: Fix voltage calculation For voltage calculation wrong bit was tested to see if range is 16 or 32V. This could resulted in incorrect value being computed depending if BRNG bit was matching bit from BG. mcu/pic32: Add minimal boot code There is special flash area dedicated to bootloader (0xbfc0-0xbfc0FF00). Code from this area is execute first. This is where mcuboot is placed. It is possible to build application elf that provides minimal code that jumps to normal flash area dedicated for applications. The elf generated this way can then easyly be used in MPLAB X ide instead of command line gdb. When syscfg has MCU_NO_BOOTLOADER_BUILD set to 1 additional section is generated that goes to bootloader area of MCU. mcu/pic32: Add minimal boot code There is special flash area dedicated to bootloader (0xbfc0-0xbfc0FF00). Code from this area is execute first. This is where mcuboot is placed. It is possible to build application elf that provides minimal code that jumps to normal flash area dedicated for applications. The elf generated this way can then easyly be used in MPLAB X ide instead of command line gdb. When syscfg has MCU_NO_BOOTLOADER_BUILD set to 1 additional section is generated that goes to bootloader area of MCU. --- hw/drivers/sensors/ina219/src/ina219.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/drivers/sensors/ina219/src/ina219.c b/hw/drivers/sensors/ina219/src/ina219.c index ab058f314..2bc16391b 100644 --- a/hw/drivers/sensors/ina219/src/ina219.c +++ b/hw/drivers/sensors/ina219/src/ina219.c @@ -206,7 +206,7 @@ ina219_read_bus_voltage(struct ina219_dev *ina219, uint16_t *voltage, bool *conv rc = ina219_read_bus_voltage_reg(ina219, &v); if (rc == SYS_EOK) { -if (ina219->config_reg & INA219_CONF_REG_PG_Msk) { +if (ina219->config_reg & INA219_CONF_REG_BRNG_Msk) { *voltage = (v >> 3) * INA219_BUS_VOLTAGE_32V_LSB; } else { *voltage = (v >> 3) * INA219_BUS_VOLTAGE_16V_LSB;
(mynewt-core) branch master updated (9d887036e -> 5946fe6cd)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 9d887036e hw/bsp: Add support for WeAct STM32G431 board new 5f815dbf4 sensors/ina219: Convert CRLF to LF new bb0a5dea4 sensors/ina219: Fix voltage calculation new 5946fe6cd sensors/ina2xx: Handle uninitialized value warning 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: hw/drivers/sensors/ina219/src/ina219.c | 992 +-- hw/drivers/sensors/ina219/src/ina219_shell.c | 8 +- hw/drivers/sensors/ina226/src/ina226_shell.c | 8 +- 3 files changed, 504 insertions(+), 504 deletions(-)
(mynewt-core) 03/03: sensors/ina2xx: Handle uninitialized value warning
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 commit 5946fe6cd520ec4039f093ef2d3eddce895a33d4 Author: Jerzy Kasenberg AuthorDate: Sat May 18 17:08:47 2024 +0200 sensors/ina2xx: Handle uninitialized value warning Warning are false positive but code is changed anyway. --- hw/drivers/sensors/ina219/src/ina219_shell.c | 8 hw/drivers/sensors/ina226/src/ina226_shell.c | 8 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/drivers/sensors/ina219/src/ina219_shell.c b/hw/drivers/sensors/ina219/src/ina219_shell.c index 89732b062..e6ea4c2a6 100644 --- a/hw/drivers/sensors/ina219/src/ina219_shell.c +++ b/hw/drivers/sensors/ina219/src/ina219_shell.c @@ -79,7 +79,7 @@ static int ina219_shell_cmd_fs(int argc, char **argv) { int rc = -1; -long long val; +long long val = 0; if (argc == 3) { val = parse_ll_bounds(argv[2], 0, 1, &rc); @@ -96,7 +96,7 @@ static int ina219_shell_cmd_soft_avg(int argc, char **argv) { int rc = -1; -long long val; +long long val = 0; if (argc == 3) { val = parse_ll_bounds(argv[2], 1, 100, &rc); @@ -113,7 +113,7 @@ static int ina219_shell_cmd_smod(int argc, char **argv) { int rc = -1; -long long val; +long long val = 0; if (argc == 3) { val = parse_ll_bounds(argv[2], 0, 7, &rc); @@ -130,7 +130,7 @@ static int ina219_shell_cmd_vmod(int argc, char **argv) { int rc = -1; -long long val; +long long val = 0; if (argc == 3) { val = parse_ll_bounds(argv[2], 0, 15, &rc); diff --git a/hw/drivers/sensors/ina226/src/ina226_shell.c b/hw/drivers/sensors/ina226/src/ina226_shell.c index 72ff90938..3ecf8c648 100644 --- a/hw/drivers/sensors/ina226/src/ina226_shell.c +++ b/hw/drivers/sensors/ina226/src/ina226_shell.c @@ -82,7 +82,7 @@ static int ina226_shell_cmd_avg(int argc, char **argv) { int rc = -1; -long long val; +long long val = 0; if (argc == 3) { val = parse_ll_bounds(argv[2], 0, 7, &rc); @@ -99,7 +99,7 @@ static int ina226_shell_cmd_soft_avg(int argc, char **argv) { int rc = -1; -long long val; +long long val = 0; if (argc == 3) { val = parse_ll_bounds(argv[2], 1, 100, &rc); @@ -116,7 +116,7 @@ static int ina226_shell_cmd_sct(int argc, char **argv) { int rc = -1; -long long val; +long long val = 0; if (argc == 3) { val = parse_ll_bounds(argv[2], 0, 7, &rc); @@ -133,7 +133,7 @@ static int ina226_shell_cmd_vct(int argc, char **argv) { int rc = -1; -long long val; +long long val = 0; if (argc == 3) { val = parse_ll_bounds(argv[2], 0, 7, &rc);
(mynewt-core) 01/03: sensors/ina219: Convert CRLF to LF
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 commit 5f815dbf48ef0bc0a6f319390cd5a5280a7c007f Author: Jerzy Kasenberg AuthorDate: Tue May 21 18:03:06 2024 +0200 sensors/ina219: Convert CRLF to LF --- hw/drivers/sensors/ina219/src/ina219.c | 992 - 1 file changed, 496 insertions(+), 496 deletions(-) diff --git a/hw/drivers/sensors/ina219/src/ina219.c b/hw/drivers/sensors/ina219/src/ina219.c index 5b9ad5349..ab058f314 100644 --- a/hw/drivers/sensors/ina219/src/ina219.c +++ b/hw/drivers/sensors/ina219/src/ina219.c @@ -1,496 +1,496 @@ -/* - * Copyright 2020 Jesus Ipanienko - * - * Licensed 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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* Define stat names for querying */ -STATS_NAME_START(ina219_stat_section) -STATS_NAME(ina219_stat_section, read_count) -STATS_NAME(ina219_stat_section, write_count) -STATS_NAME(ina219_stat_section, read_errors) -STATS_NAME(ina219_stat_section, write_errors) -STATS_NAME_END(ina219_stat_section) - -/* Exports for the sensor API */ -static int ina219_sensor_read(struct sensor *sensor, sensor_type_t typ, - sensor_data_func_t data_func, void *data_func_arg, uint32_t timeout); - -static int ina219_sensor_get_config(struct sensor *sensor, sensor_type_t typ, -struct sensor_cfg *cfg); - -static const struct sensor_driver g_ina219_sensor_driver = { -.sd_read = ina219_sensor_read, -.sd_get_config = ina219_sensor_get_config, -}; - -/* Conversion times depending on ADC settings */ -static const uint32_t conversion_times[16] = { -93, 163, 304, 586, 93, 163, 304, 586, 586, 1060, 2130, 4260, 8510, 17020, 34050, 68100 -}; - -/* Calculate total conversion time in us. */ -static uint32_t -ina219_conversion_time(uint32_t config_reg) -{ -uint32_t time; - -if (config_reg & INA219_OPER_SHUNT_VOLTAGE_TRIGGERED) { -time = conversion_times[(config_reg & INA219_CONF_REG_SADC_Msk) >> INA219_CONF_REG_SADC_Pos]; -} else { -time = 0; -} -if (config_reg & INA219_OPER_BUS_VOLTAGE_TRIGGERED) { -time += conversion_times[(config_reg & INA219_CONF_REG_BADC_Msk) >> INA219_CONF_REG_BADC_Pos]; -} -return time; -} - -int -ina219_write_reg(struct ina219_dev *ina219, uint8_t reg, uint16_t reg_val) -{ -int rc; -uint8_t payload[3] = {reg, reg_val >> 8, (uint8_t)reg_val }; - -struct hal_i2c_master_data data_struct = { -.address = ina219->sensor.s_itf.si_addr, -.len = 3, -.buffer = payload, -}; - -rc = sensor_itf_lock(&ina219->sensor.s_itf, MYNEWT_VAL(INA219_ITF_LOCK_TMO)); -if (rc) { -return rc; -} -STATS_INC(ina219->stats, write_count); -rc = i2cn_master_write(ina219->sensor.s_itf.si_num, &data_struct, OS_TICKS_PER_SEC / 10, 1, - MYNEWT_VAL(INA219_I2C_RETRIES)); -if (rc) { -STATS_INC(ina219->stats, write_errors); -INA219_LOG_ERROR("INA219 write I2C failed\n"); -} - -sensor_itf_unlock(&ina219->sensor.s_itf); - -return rc; -} - -int -ina219_read_reg(struct ina219_dev *ina219, uint8_t reg, uint16_t *reg_val) -{ -int rc; -uint8_t payload[2] = { reg }; - -struct hal_i2c_master_data data_struct = { -.address = ina219->sensor.s_itf.si_addr, -.len = 1, -.buffer = payload -}; - -rc = sensor_itf_lock(&ina219->sensor.s_itf, MYNEWT_VAL(INA219_ITF_LOCK_TMO)); -if (rc) { -return rc; -} - -STATS_INC(ina219->stats, read_count); -rc = i2cn_master_write(ina219->sensor.s_itf.si_num, &data_struct, OS_TICKS_PER_SEC / 10, - 1, MYNEWT_VAL(INA219_I2C_RETRIES)); -if (rc) { -STATS_INC(ina219->stats, read_errors); -INA219_LOG_ERROR("INA219 write I2C failed\n"); -goto exit; -} - -data_struct.len = 2; -rc = i2cn_master_read(ina219->sensor.s_itf.si_num, &data_struct, OS_TICKS_PER_SEC / 10, - 1, MYNEWT_VAL(INA219_I2C_RETRIES)); -if (rc) { -STATS_INC(ina219->sta
(mynewt-core) branch master updated: hw/bsp: Add support for WeAct STM32G431 board
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 9d887036e hw/bsp: Add support for WeAct STM32G431 board 9d887036e is described below commit 9d887036e64c99f08a322fdfbb8e3918bac4d62d Author: Jerzy Kasenberg AuthorDate: Fri Apr 26 13:27:57 2024 +0200 hw/bsp: Add support for WeAct STM32G431 board This adds support for chip STM32G431 board with just one area for bootloader. Signed-off-by: Jerzy Kasenberg --- .github/test_build_bootloader.sh | 3 +- .style_ignored_dirs| 1 + LICENSE| 1 + hw/bsp/weact_g431cb/bsp.yml| 47 +++ hw/bsp/weact_g431cb/debug.sh | 34 ++ hw/bsp/weact_g431cb/include/bsp/bsp.h | 55 +++ .../weact_g431cb/include/bsp/stm32g4xx_hal_conf.h | 381 + hw/bsp/weact_g431cb/link/include/bsp_config.ld.h | 22 ++ hw/bsp/weact_g431cb/pkg.yml| 37 ++ hw/bsp/weact_g431cb/src/hal_bsp.c | 207 +++ hw/bsp/weact_g431cb/syscfg.yml | 82 + 11 files changed, 869 insertions(+), 1 deletion(-) diff --git a/.github/test_build_bootloader.sh b/.github/test_build_bootloader.sh index 59e59790c..8389a7a9f 100644 --- a/.github/test_build_bootloader.sh +++ b/.github/test_build_bootloader.sh @@ -23,7 +23,8 @@ BSPS=$(ls repos/apache-mynewt-core/hw/bsp) IGNORED_BSPS="ci40 dialog_cmac embarc_emsk hifive1 native native-armv7\ native-mips nucleo-f030r8 nucleo-f072rb\ olimex-p103 olimex-pic32-emz64 olimex-pic32-hmz144\ - pic32mx470_6lp_clicker pic32mz2048_wi-fire usbmkw41z" + pic32mx470_6lp_clicker pic32mz2048_wi-fire usbmkw41z\ + weact_g431cb" BSP_COUNT=0 diff --git a/.style_ignored_dirs b/.style_ignored_dirs index 28bbb59f4..d2f32bc77 100644 --- a/.style_ignored_dirs +++ b/.style_ignored_dirs @@ -44,6 +44,7 @@ hw/bsp/stm32f4discovery/include/bsp/stm32f4xx_hal_conf.h hw/bsp/stm32f7discovery/include/bsp/stm32f7xx_hal_conf.h hw/bsp/stm32l152discovery/include/bsp/stm32l1xx_hal_conf.h hw/bsp/nucleo-u575zi-q/include/bsp/stm32u5xx_hal_conf.h +hw/bsp/weact_g431cb/include/bsp/stm32g4xx_hal_conf.h hw/mcu/stm/stm32g0xx/src/system_stm32g0xx.c hw/mcu/stm/stm32g4xx/src/system_stm32g4xx.c hw/mcu/stm/stm32u5xx/src/system_stm32u5xx.c diff --git a/LICENSE b/LICENSE index 3a3706971..76e463a3b 100644 --- a/LICENSE +++ b/LICENSE @@ -302,6 +302,7 @@ This product bundles parts of STM32CubeF4 1.5, which is available under the * hw/bsp/nucleo-f439zi/include/bsp/stm32f4xx_hal_conf.h * hw/bsp/stm32f411discovery/include/bsp/stm32f4xx_hal_conf.h * hw/bsp/stm32f429discovery/include/bsp/stm32f4xx_hal_conf.h +* hw/bsp/weact_g431cb/include/bsp/stm32g4xx_hal_conf.h This product bundles parts of STM32CubeF7, which is available under the "3-clause BSD" license. Bundled files are: diff --git a/hw/bsp/weact_g431cb/bsp.yml b/hw/bsp/weact_g431cb/bsp.yml new file mode 100644 index 0..62b503f9e --- /dev/null +++ b/hw/bsp/weact_g431cb/bsp.yml @@ -0,0 +1,47 @@ +# +# 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. +# + +bsp.name: "WeAct_G431CB" +bsp.url: https://github.com/WeActStudio/WeActStudio.STM32G431CoreBoard +bsp.maker: "WeActStudio" +bsp.arch: cortex_m4 +bsp.compiler: compiler/arm-none-eabi-m4 +bsp.linkerscript: autogenerated +bsp.downloadscript: "hw/scripts/download.sh" +bsp.debugscript: "hw/bsp/weact_g431cb/debug.sh" + +bsp.flash_map: +areas: +# Only one flash area for code +FLASH_AREA_BOOTLOADER: +device: 0 +offset: 0x0800 +size: 96kB +FLASH_AREA_NFFS: +user_id: 1 +device: 0 +offset: 0x08018000 +size: 32kB +# Empty flash area to allow build +FLASH_AREA_IMAGE_0: +device: 0 +offset: 0x0
(mynewt-core) 02/02: bsp/nucleo-h723zg: Use common startup and linker script
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 commit 3483c77d359a8e08a0734e6845cd55a7a773ecf2 Author: Jerzy Kasenberg AuthorDate: Wed Feb 7 11:14:46 2024 +0100 bsp/nucleo-h723zg: Use common startup and linker script This removes local startup code and linker scripts Signed-off-by: Jerzy Kasenberg --- .rat-excludes | 1 - LICENSE| 1 - hw/bsp/nucleo-h723zg/boot-nucleo-h723zg.ld | 32 - hw/bsp/nucleo-h723zg/bsp.yml | 7 +- hw/bsp/nucleo-h723zg/nucleo-h723zg.ld | 34 - .../src/arch/cortex_m7/startup_stm32h723xx.s | 773 - 6 files changed, 1 insertion(+), 847 deletions(-) diff --git a/.rat-excludes b/.rat-excludes index 41315f80f..ce3f98ca0 100644 --- a/.rat-excludes +++ b/.rat-excludes @@ -265,7 +265,6 @@ startup_stm32l152xc.s # NUCLEO-H723ZG BSP - BSD License stm32h7xx_hal_conf.h system_stm32h7xx.c -startup_stm32h723xx.s # STM32U5 - BSD License system_stm32u5xx.c diff --git a/LICENSE b/LICENSE index 6356c49d7..3a3706971 100644 --- a/LICENSE +++ b/LICENSE @@ -330,7 +330,6 @@ This product bundles parts of STM32CubeH7, which is available under the * hw/mcu/stm/stm32h7xx/src/clock_stm32h7xx.c * hw/mcu/stm/stm32h7xx/src/system_stm32h7xx.c * hw/bsp/nucleo-h723zg/include/bsp/stm32h7xx_hal_conf.h -* hw/bsp/nucleo-h723zg/src/arch/cortex_m7/startup_stm32h723xx.s This product bundles parts of stm32l1xx, which is available under the "3-clause BSD" license. Bundled files are: diff --git a/hw/bsp/nucleo-h723zg/boot-nucleo-h723zg.ld b/hw/bsp/nucleo-h723zg/boot-nucleo-h723zg.ld deleted file mode 100644 index 557c23972..0 --- a/hw/bsp/nucleo-h723zg/boot-nucleo-h723zg.ld +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ - -/* Linker script to configure memory regions. */ -MEMORY -{ - ITCM (xrw) : ORIGIN = 0x, LENGTH = 64K - DTCM (xrw) : ORIGIN = 0x2000, LENGTH = 128K - FLASH (rx) : ORIGIN = 0x0800, LENGTH = 128K /* Bootloader area */ - RAM (xrw) : ORIGIN = 0x2400, LENGTH = 320K /* AXI (128) + AXI/ITCM (192) */ - RAM_D2 (xrw): ORIGIN = 0x3000, LENGTH = 32K /* SRAM1 + SRMA2 */ - RAM_D3 (xrw): ORIGIN = 0x3800, LENGTH = 16K /* SRAM4 */ -} - -/* The bootloader does not contain an image header */ -_imghdr_size = 0x0; diff --git a/hw/bsp/nucleo-h723zg/bsp.yml b/hw/bsp/nucleo-h723zg/bsp.yml index f96f05bce..afdc6f194 100644 --- a/hw/bsp/nucleo-h723zg/bsp.yml +++ b/hw/bsp/nucleo-h723zg/bsp.yml @@ -22,12 +22,7 @@ bsp.url: https://www.st.com/en/evaluation-tools/nucleo-h723zg.html bsp.maker: "STMicroelectronics" bsp.arch: cortex_m7 bsp.compiler: compiler/arm-none-eabi-m7 -bsp.linkerscript: -- "hw/bsp/nucleo-h723zg/nucleo-h723zg.ld" -- "@apache-mynewt-core/hw/mcu/stm/stm32h7xx/stm32h723.ld" -bsp.linkerscript.BOOT_LOADER.OVERWRITE: -- "hw/bsp/nucleo-h723zg/boot-nucleo-h723zg.ld" -- "@apache-mynewt-core/hw/mcu/stm/stm32h7xx/stm32h723.ld" +bsp.linkerscript: autogenerated bsp.downloadscript: "hw/scripts/download.sh" bsp.debugscript: "hw/bsp/nucleo-h723zg/nucleo-h723zg_debug.sh" diff --git a/hw/bsp/nucleo-h723zg/nucleo-h723zg.ld b/hw/bsp/nucleo-h723zg/nucleo-h723zg.ld deleted file mode 100644 index 81045cbd4..0 --- a/hw/bsp/nucleo-h723zg/nucleo-h723zg.ld +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 requi
(mynewt-core) branch master updated (00452e683 -> 3483c77d3)
This is an automated email from the ASF dual-hosted git repository. jerzy pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git from 00452e683 Merge pull request #3230 from JuulLabs/config_fcb_wd_kick new 689dcf8bb hw/mcu: STM32H7 use autogenerated linker script new 3483c77d3 bsp/nucleo-h723zg: Use common startup and linker script 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: .rat-excludes | 1 - LICENSE| 1 - hw/bsp/nucleo-h723zg/boot-nucleo-h723zg.ld | 32 - hw/bsp/nucleo-h723zg/bsp.yml | 7 +- hw/bsp/nucleo-h723zg/nucleo-h723zg.ld | 34 - .../src/arch/cortex_m7/startup_stm32h723xx.s | 773 - hw/mcu/stm/stm32h7xx/include/mcu/cmsis_nvic.h | 10 +- hw/mcu/stm/stm32h7xx/include/mcu/mcu_vectors.h | 66 ++ .../include/mcu/vectors/stm32h723xx_vectors.h} | 116 +++- .../include/mcu/vectors/stm32h725xx_vectors.h} | 116 +++- .../include/mcu/vectors/stm32h730xx_vectors.h} | 104 ++- .../include/mcu/vectors/stm32h730xxq_vectors.h}| 104 ++- .../include/mcu/vectors/stm32h733xx_vectors.h} | 104 ++- .../include/mcu/vectors/stm32h735xx_vectors.h} | 104 ++- .../include/mcu/vectors/stm32h742xx_vectors.h} | 99 ++- .../include/mcu/vectors/stm32h743xx_vectors.h} | 103 ++- .../include/mcu/vectors/stm32h745xg_vectors.h} | 91 ++- .../include/mcu/vectors/stm32h745xx_vectors.h} | 91 ++- .../include/mcu/vectors/stm32h747xg_vectors.h} | 89 ++- .../include/mcu/vectors/stm32h747xx_vectors.h} | 89 ++- .../include/mcu/vectors/stm32h750xx_vectors.h} | 89 ++- .../include/mcu/vectors/stm32h753xx_vectors.h} | 89 ++- .../include/mcu/vectors/stm32h755xx_vectors.h} | 89 ++- .../include/mcu/vectors/stm32h757xx_vectors.h} | 87 ++- .../include/mcu/vectors/stm32h7a3xx_vectors.h} | 110 ++- .../include/mcu/vectors/stm32h7a3xxq_vectors.h}| 110 ++- .../include/mcu/vectors/stm32h7b0xx_vectors.h} | 110 ++- .../include/mcu/vectors/stm32h7b0xxq_vectors.h}| 110 ++- .../include/mcu/vectors/stm32h7b3xx_vectors.h} | 110 ++- .../include/mcu/vectors/stm32h7b3xxq_vectors.h}| 110 ++- .../link/include/mcu_config.ld.h | 6 +- .../link/include/memory_regions.ld.h | 3 +- hw/mcu/stm/stm32h7xx/pkg.yml | 1 + .../{stm32u5xx => stm32h7xx}/src/hal_system_init.c | 0 hw/mcu/stm/stm32h7xx/src/system_stm32h7xx.c| 9 - hw/mcu/stm/stm32h7xx/syscfg.yml| 7 + 36 files changed, 1863 insertions(+), 1311 deletions(-) delete mode 100644 hw/bsp/nucleo-h723zg/boot-nucleo-h723zg.ld delete mode 100644 hw/bsp/nucleo-h723zg/nucleo-h723zg.ld delete mode 100644 hw/bsp/nucleo-h723zg/src/arch/cortex_m7/startup_stm32h723xx.s create mode 100644 hw/mcu/stm/stm32h7xx/include/mcu/mcu_vectors.h copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f446xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h723xx_vectors.h} (59%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f446xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h725xx_vectors.h} (59%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f439xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h730xx_vectors.h} (59%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f439xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h730xxq_vectors.h} (59%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f439xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h733xx_vectors.h} (59%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f439xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h735xx_vectors.h} (59%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f446xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h742xx_vectors.h} (64%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f446xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h743xx_vectors.h} (63%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f469xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h745xg_vectors.h} (62%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f469xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h745xx_vectors.h} (62%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f469xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h747xg_vectors.h} (63%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f469xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h747xx_vectors.h} (63%) copy hw/mcu/stm/{stm32f4xx/include/mcu/vectors/stm32f479xx_vectors.h => stm32h7xx/include/mcu/vectors/stm32h750xx_ve
(mynewt-core) branch master updated: mcu/stm32l0: Fix voltage scaling configuration
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 262a66bf6 mcu/stm32l0: Fix voltage scaling configuration 262a66bf6 is described below commit 262a66bf657240a15f9c0c65b4ffdbaac6617873 Author: Jerzy Kasenberg AuthorDate: Sat May 18 20:06:21 2024 +0200 mcu/stm32l0: Fix voltage scaling configuration Voltage scaling setting was done with PWR peripheral clock turned off which does not change anything. --- hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c b/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c index f5d1f3e67..b844afc24 100644 --- a/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c +++ b/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c @@ -59,7 +59,9 @@ SystemClock_Config(void) * voltage scaling value regarding system frequency refer to product * datasheet. */ +__HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(MYNEWT_VAL(STM32_CLOCK_VOLTAGESCALING_CONFIG)); +__HAL_RCC_PWR_CLK_DISABLE(); osc_init.OscillatorType = RCC_OSCILLATORTYPE_NONE;
(mynewt-core) branch master updated: stm32/hal: Fix STM32H7 with RTC as system tick
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 c9e1d65bf stm32/hal: Fix STM32H7 with RTC as system tick c9e1d65bf is described below commit c9e1d65bfbe6e9f0ca345487b4b9cc0b70a255a3 Author: Jerzy Kasenberg AuthorDate: Sat May 18 22:35:35 2024 +0200 stm32/hal: Fix STM32H7 with RTC as system tick STM32H7 HAL has __HAL_RCC_RTC_CLK_ENABLE macro for turning on RTC clock. Some other MCUs also have this and for historical reasons have __HAL_RCC_RTCAPB_CLK_ENABLE that is an alias. Other only have __HAL_RCC_RTCAPB_CLK_ENABLE. This uses __HAL_RCC_RTC_CLK_ENABLE() if defined to enable RTC clock in RCC. --- hw/mcu/stm/stm32_common/src/hal_os_tick.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/mcu/stm/stm32_common/src/hal_os_tick.c b/hw/mcu/stm/stm32_common/src/hal_os_tick.c index 1b167092c..fa7d14fda 100644 --- a/hw/mcu/stm/stm32_common/src/hal_os_tick.c +++ b/hw/mcu/stm/stm32_common/src/hal_os_tick.c @@ -324,6 +324,8 @@ os_tick_init(uint32_t os_ticks_per_sec, int prio) #ifdef __HAL_RCC_RTCAPB_CLK_ENABLE __HAL_RCC_RTCAPB_CLK_ENABLE(); +#elif defined(__HAL_RCC_RTC_CLK_ENABLE) +__HAL_RCC_RTC_CLK_ENABLE(); #endif #ifdef __HAL_RCC_RTCAPB_CLKAM_ENABLE __HAL_RCC_RTCAPB_CLKAM_ENABLE();
(mynewt-core) branch master updated: stm32/hal_watchdog: Fix timeout calculations
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 174494407 stm32/hal_watchdog: Fix timeout calculations 174494407 is described below commit 174494407379406fe6adcf54566f300f9e8b1da4 Author: Jerzy Kasenberg AuthorDate: Sat May 18 16:38:28 2024 +0200 stm32/hal_watchdog: Fix timeout calculations All STM32 devices use LSI for watchdog functionality. LSI frequency varies between MCUs and it's approximation is define by LSI_VALUE in stm32xxx_hal_conf.h. Code was assuming 32768 which is ok for devices that have LSI rate at 30kHz. Some device has 37kHz others 40kHz it those cases calculated time could be too much off resulting in reset by watchdog. Now code uses LSI_VALUE adding 10% to avoid cases when LSI runs faster then nominal. --- hw/mcu/stm/stm32_common/src/hal_watchdog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/mcu/stm/stm32_common/src/hal_watchdog.c b/hw/mcu/stm/stm32_common/src/hal_watchdog.c index 421993fb4..649b6b6f1 100644 --- a/hw/mcu/stm/stm32_common/src/hal_watchdog.c +++ b/hw/mcu/stm/stm32_common/src/hal_watchdog.c @@ -29,7 +29,8 @@ hal_watchdog_init(uint32_t expire_msecs) uint32_t reload; /* Max prescaler is 256 */ -reload = 32768 / 256; +/* LSI is not very precise, assume 10% inaccuracy when calculating reload value */ +reload = LSI_VALUE * 11 / 2560; reload = (reload * expire_msecs) / 1000; /* Check to make sure we are not trying a reload value that is too large */
(mynewt-core) branch master updated: stm32/hal_reset: Fix reported reset reason
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 6b81c5844 stm32/hal_reset: Fix reported reset reason 6b81c5844 is described below commit 6b81c58446a3f8a92553dd08d81c4fce10e6f29c Author: Jerzy Kasenberg AuthorDate: Sat May 18 16:47:02 2024 +0200 stm32/hal_reset: Fix reported reset reason Often when device is powered up Reset pin is also activated. This cause power on never to be reported in favor of reset pin. Now Power On has highest priority. Independent watchdog that is actually used in mynewt was not reported at all as reset reason. Only Windowed watchdog would be reported but is not used in mynwet-core. This adds flag check so Watchdog reset can be detected. --- hw/mcu/stm/stm32l0xx/src/hal_reset_cause.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/mcu/stm/stm32l0xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32l0xx/src/hal_reset_cause.c index b9d3074cb..c13930a6c 100644 --- a/hw/mcu/stm/stm32l0xx/src/hal_reset_cause.c +++ b/hw/mcu/stm/stm32l0xx/src/hal_reset_cause.c @@ -32,7 +32,9 @@ hal_reset_cause(void) reg = RCC->CSR; -if (reg & RCC_CSR_WWDGRSTF) { +if (reg & RCC_CSR_PORRSTF) { +reason = HAL_RESET_POR; +} else if (reg & (RCC_CSR_WWDGRSTF | RCC_CSR_IWDGRSTF)) { reason = HAL_RESET_WATCHDOG; } else if (reg & RCC_CSR_SFTRSTF) { reason = HAL_RESET_SOFT;