From 48003b2d5313c42b8c3ea281653acb11a988db6a Mon Sep 17 00:00:00 2001 From: zhoulq1024 <1248471212@qq.com> Date: Wed, 17 Nov 2021 11:30:02 +0800 Subject: [PATCH 1/2] add apriltag origin patch and patch sha256 --- components/utility/apriltag/origin.patch | 2560 ++++++++++++++++++++++ components/utility/apriltag/patch.sha256 | 1 + 2 files changed, 2561 insertions(+) create mode 100644 components/utility/apriltag/origin.patch create mode 100644 components/utility/apriltag/patch.sha256 diff --git a/components/utility/apriltag/origin.patch b/components/utility/apriltag/origin.patch new file mode 100644 index 0000000..3864437 --- /dev/null +++ b/components/utility/apriltag/origin.patch @@ -0,0 +1,2560 @@ +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c 2021-11-17 11:07:32.498776572 +0800 +@@ -54,6 +54,8 @@ + + #include "common/postscript_utils.h" + ++#include "port.h" ++ + #ifndef M_PI + # define M_PI 3.141592653589793238462643383279502884196 + #endif +@@ -158,12 +160,12 @@ + + matd_destroy(quad->H); + matd_destroy(quad->Hinv); +- free(quad); ++ OS_FREE(quad); + } + + static struct quad *quad_copy(struct quad *quad) + { +- struct quad *q = calloc(1, sizeof(struct quad)); ++ struct quad *q = OS_CALLOC(1, sizeof(struct quad)); + memcpy(q, quad, sizeof(struct quad)); + if (quad->H) + q->H = matd_copy(quad->H); +@@ -191,8 +193,8 @@ + return; + + struct quick_decode *qd = (struct quick_decode*) fam->impl; +- free(qd->entries); +- free(qd); ++ OS_FREE(qd->entries); ++ OS_FREE(qd); + fam->impl = NULL; + } + +@@ -201,7 +203,7 @@ + assert(family->impl == NULL); + assert(family->ncodes < 65536); + +- struct quick_decode *qd = calloc(1, sizeof(struct quick_decode)); ++ struct quick_decode *qd = OS_CALLOC(1, sizeof(struct quick_decode)); + int capacity = family->ncodes; + + int nbits = family->nbits; +@@ -220,7 +222,7 @@ + // printf("capacity %d, size: %.0f kB\n", + // capacity, qd->nentries * sizeof(struct quick_decode_entry) / 1024.0); + +- qd->entries = calloc(qd->nentries, sizeof(struct quick_decode_entry)); ++ qd->entries = OS_CALLOC(qd->nentries, sizeof(struct quick_decode_entry)); + if (qd->entries == NULL) { + printf("apriltag.c: failed to allocate hamming decode table. Reduce max hamming size.\n"); + exit(-1); +@@ -350,7 +352,7 @@ + + apriltag_detector_t *apriltag_detector_create() + { +- apriltag_detector_t *td = (apriltag_detector_t*) calloc(1, sizeof(apriltag_detector_t)); ++ apriltag_detector_t *td = (apriltag_detector_t*) OS_CALLOC(1, sizeof(apriltag_detector_t)); + + td->nthreads = 1; + td->quad_decimate = 2.0; +@@ -390,7 +392,7 @@ + apriltag_detector_clear_families(td); + + zarray_destroy(td->tag_families); +- free(td); ++ OS_FREE(td); + } + + struct quad_decode_task +@@ -523,7 +525,7 @@ + } + + static void sharpen(apriltag_detector_t* td, double* values, int size) { +- double *sharpened = malloc(sizeof(double)*size*size); ++ double *sharpened = OS_MALLOC(sizeof(double)*size*size); + double kernel[9] = { + 0, -1, 0, + -1, 4, -1, +@@ -551,7 +553,7 @@ + } + } + +- free(sharpened); ++ OS_FREE(sharpened); + } + + // returns the decision margin. Return < 0 if the detection should be rejected. +@@ -672,7 +674,7 @@ + float black_score = 0, white_score = 0; + float black_score_count = 1, white_score_count = 1; + +- double *values = calloc(family->total_width*family->total_width, sizeof(double)); ++ double *values = OS_CALLOC(family->total_width*family->total_width, sizeof(double)); + + int min_coord = (family->width_at_border - family->total_width)/2; + for (int i = 0; i < family->nbits; i++) { +@@ -725,7 +727,7 @@ + } + + quick_decode_codeword(family, rcode, entry); +- free(values); ++ OS_FREE(values); + return fmin(white_score / white_score_count, black_score / black_score_count); + } + +@@ -915,7 +917,7 @@ + float decision_margin = quad_decode(td, family, im, quad, &entry, task->im_samples); + + if (decision_margin >= 0 && entry.hamming < 255) { +- apriltag_detection_t *det = calloc(1, sizeof(apriltag_detection_t)); ++ apriltag_detection_t *det = OS_CALLOC(1, sizeof(apriltag_detection_t)); + + det->family = family; + det->id = entry.id; +@@ -971,7 +973,7 @@ + return; + + matd_destroy(det->H); +- free(det); ++ OS_FREE(det); + } + + static int prefer_smaller(int pref, double q0, double q1) +@@ -1125,7 +1127,7 @@ + + int chunksize = 1 + zarray_size(quads) / (APRILTAG_TASKS_PER_THREAD_TARGET * td->nthreads); + +- struct quad_decode_task *tasks = malloc(sizeof(struct quad_decode_task)*(zarray_size(quads) / chunksize + 1)); ++ struct quad_decode_task *tasks = OS_MALLOC(sizeof(struct quad_decode_task)*(zarray_size(quads) / chunksize + 1)); + + int ntasks = 0; + for (int i = 0; i < zarray_size(quads); i+= chunksize) { +@@ -1144,7 +1146,7 @@ + + workerpool_run(td->wp); + +- free(tasks); ++ OS_FREE(tasks); + + if (im_samples != NULL) { + image_u8_write_pnm(im_samples, "debug_samples.pnm"); +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c 2021-11-17 11:07:32.498776572 +0800 +@@ -6,6 +6,8 @@ + #include "common/homography.h" + #include "common/image_u8x3.h" + ++#include "port.h" ++ + + /** + * Calculate projection operator from image points. +@@ -48,13 +50,13 @@ + } + matd_scale_inplace(p_mean, 1.0/n_points); + +- matd_t** p_res = malloc(sizeof(matd_t *)*n_points); ++ matd_t** p_res = OS_MALLOC(sizeof(matd_t *)*n_points); + for (int i = 0; i < n_points; i++) { + p_res[i] = matd_op("M-M", p[i], p_mean); + } + + // Compute M1_inv. +- matd_t** F = malloc(sizeof(matd_t *)*n_points); ++ matd_t** F = OS_MALLOC(sizeof(matd_t *)*n_points); + matd_t *avg_F = matd_create(3, 3); + for (int i = 0; i < n_points; i++) { + F[i] = calculate_F(v[i]); +@@ -83,7 +85,7 @@ + matd_destroy(M2); + + // Calculate rotation. +- matd_t** q = malloc(sizeof(matd_t *)*n_points); ++ matd_t** q = OS_MALLOC(sizeof(matd_t *)*n_points); + matd_t* q_mean = matd_create(3, 1); + for (int j = 0; j < n_points; j++) { + q[j] = matd_op("M*(M*M+M)", F[j], *R, p[j], *t); +@@ -123,7 +125,7 @@ + } + prev_error = error; + +- free(q); ++ OS_FREE(q); + } + + matd_destroy(I3); +@@ -132,8 +134,8 @@ + matd_destroy(p_res[i]); + matd_destroy(F[i]); + } +- free(p_res); +- free(F); ++ OS_FREE(p_res); ++ OS_FREE(F); + matd_destroy(p_mean); + return prev_error; + } +@@ -171,12 +173,12 @@ + } + + // Calculate roots of derivative. +- double *p_der = malloc(sizeof(double)*degree); ++ double *p_der = OS_MALLOC(sizeof(double)*degree); + for (int i = 0; i < degree; i++) { + p_der[i] = (i + 1) * p[i+1]; + } + +- double *der_roots = malloc(sizeof(double)*(degree - 1)); ++ double *der_roots = OS_MALLOC(sizeof(double)*(degree - 1)); + int n_der_roots; + solve_poly_approx(p_der, degree - 1, der_roots, &n_der_roots); + +@@ -250,8 +252,8 @@ + } + } + +- free(der_roots); +- free(p_der); ++ OS_FREE(der_roots); ++ OS_FREE(p_der); + } + + /** +@@ -309,9 +311,9 @@ + double t_initial = atan2(sin_beta, cos_beta); + matd_destroy(R_trans); + +- matd_t** v_trans = malloc(sizeof(matd_t *)*n_points); +- matd_t** p_trans = malloc(sizeof(matd_t *)*n_points); +- matd_t** F_trans = malloc(sizeof(matd_t *)*n_points); ++ matd_t** v_trans = OS_MALLOC(sizeof(matd_t *)*n_points); ++ matd_t** p_trans = OS_MALLOC(sizeof(matd_t *)*n_points); ++ matd_t** F_trans = OS_MALLOC(sizeof(matd_t *)*n_points); + matd_t* avg_F_trans = matd_create(3, 3); + for (int i = 0; i < n_points; i++) { + p_trans[i] = matd_op("M'*M", R_z, p[i]); +@@ -386,9 +388,9 @@ + matd_destroy(v_trans[i]); + matd_destroy(F_trans[i]); + } +- free(p_trans); +- free(v_trans); +- free(F_trans); ++ OS_FREE(p_trans); ++ OS_FREE(v_trans); ++ OS_FREE(F_trans); + matd_destroy(avg_F_trans); + matd_destroy(G); + +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thresh.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thresh.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thresh.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thresh.c 2021-11-17 11:07:32.498776572 +0800 +@@ -44,6 +44,8 @@ + #include "common/postscript_utils.h" + #include "common/math_util.h" + ++#include "port.h" ++ + #ifdef _WIN32 + static inline long int random(void) + { +@@ -312,7 +314,7 @@ + if (ksz < 2) + return 0; + +- double *errs = malloc(sizeof(double)*sz); ++ double *errs = OS_MALLOC(sizeof(double)*sz); + + for (int i = 0; i < sz; i++) { + fit_line(lfps, sz, (i + sz - ksz) % sz, (i + ksz) % sz, NULL, &errs[i], NULL); +@@ -320,7 +322,7 @@ + + // apply a low-pass filter to errs + if (1) { +- double *y = malloc(sizeof(double)*sz); ++ double *y = OS_MALLOC(sizeof(double)*sz); + + // how much filter to apply? + +@@ -342,7 +344,7 @@ + + // For default values of cutoff = 0.05, sigma = 3, + // we have fsz = 17. +- float *f = malloc(sizeof(float)*fsz); ++ float *f = OS_MALLOC(sizeof(float)*fsz); + + for (int i = 0; i < fsz; i++) { + int j = i - fsz / 2; +@@ -359,12 +361,12 @@ + } + + memcpy(errs, y, sizeof(double)*sz); +- free(y); +- free(f); ++ OS_FREE(y); ++ OS_FREE(f); + } + +- int *maxima = malloc(sizeof(int)*sz); +- double *maxima_errs = malloc(sizeof(double)*sz); ++ int *maxima = OS_MALLOC(sizeof(int)*sz); ++ double *maxima_errs = OS_MALLOC(sizeof(double)*sz); + int nmaxima = 0; + + for (int i = 0; i < sz; i++) { +@@ -374,12 +376,12 @@ + nmaxima++; + } + } +- free(errs); ++ OS_FREE(errs); + + // if we didn't get at least 4 maxima, we can't fit a quad. + if (nmaxima < 4){ +- free(maxima); +- free(maxima_errs); ++ OS_FREE(maxima); ++ OS_FREE(maxima_errs); + return 0; + } + +@@ -387,7 +389,7 @@ + int max_nmaxima = td->qtp.max_nmaxima; + + if (nmaxima > max_nmaxima) { +- double *maxima_errs_copy = malloc(sizeof(double)*nmaxima); ++ double *maxima_errs_copy = OS_MALLOC(sizeof(double)*nmaxima); + memcpy(maxima_errs_copy, maxima_errs, sizeof(double)*nmaxima); + + // throw out all but the best handful of maxima. Sorts descending. +@@ -401,9 +403,9 @@ + maxima[out++] = maxima[in]; + } + nmaxima = out; +- free(maxima_errs_copy); ++ OS_FREE(maxima_errs_copy); + } +- free(maxima_errs); ++ OS_FREE(maxima_errs); + + int best_indices[4]; + double best_error = HUGE_VALF; +@@ -461,7 +463,7 @@ + } + } + +- free(maxima); ++ OS_FREE(maxima); + + if (best_error == HUGE_VALF) + return 0; +@@ -489,9 +491,9 @@ + + int rvalloc_pos = 0; + int rvalloc_size = 3*sz; +- struct remove_vertex *rvalloc = calloc(rvalloc_size, sizeof(struct remove_vertex)); ++ struct remove_vertex *rvalloc = OS_CALLOC(rvalloc_size, sizeof(struct remove_vertex)); + +- struct segment *segs = calloc(sz, sizeof(struct segment)); ++ struct segment *segs = OS_CALLOC(sz, sizeof(struct segment)); + + // populate with initial entries + for (int i = 0; i < sz; i++) { +@@ -570,7 +572,7 @@ + nvertices--; + } + +- free(rvalloc); ++ OS_FREE(rvalloc); + zmaxheap_destroy(heap); + + int idx = 0; +@@ -580,7 +582,7 @@ + } + } + +- free(segs); ++ OS_FREE(segs); + + return 1; + } +@@ -590,7 +592,7 @@ + * efficiently computed for any contiguous range of indices. + */ + struct line_fit_pt* compute_lfps(int sz, zarray_t* cluster, image_u8_t* im) { +- struct line_fit_pt *lfps = calloc(sz, sizeof(struct line_fit_pt)); ++ struct line_fit_pt *lfps = OS_CALLOC(sz, sizeof(struct line_fit_pt)); + + for (int i = 0; i < sz; i++) { + struct pt *p; +@@ -686,7 +688,7 @@ + + // a merge sort with temp storage. + +- struct pt *tmp = malloc(sizeof(struct pt) * sz); ++ struct pt *tmp = OS_MALLOC(sizeof(struct pt) * sz); + + memcpy(tmp, pts, sizeof(struct pt) * sz); + +@@ -720,7 +722,7 @@ + if (bpos < bsz) + memcpy(&pts[outpos], &bs[bpos], (bsz-bpos)*sizeof(struct pt)); + +- free(tmp); ++ OS_FREE(tmp); + + #undef MERGE + } +@@ -980,7 +982,7 @@ + + finish: + +- free(lfps); ++ OS_FREE(lfps); + + return res; + } +@@ -1129,8 +1131,8 @@ + int tw = w / tilesz; + int th = h / tilesz; + +- uint8_t *im_max = calloc(tw*th, sizeof(uint8_t)); +- uint8_t *im_min = calloc(tw*th, sizeof(uint8_t)); ++ uint8_t *im_max = OS_CALLOC(tw*th, sizeof(uint8_t)); ++ uint8_t *im_min = OS_CALLOC(tw*th, sizeof(uint8_t)); + + // first, collect min/max statistics for each tile + for (int ty = 0; ty < th; ty++) { +@@ -1158,8 +1160,8 @@ + // over larger areas. This reduces artifacts due to abrupt changes + // in the threshold value. + if (1) { +- uint8_t *im_max_tmp = calloc(tw*th, sizeof(uint8_t)); +- uint8_t *im_min_tmp = calloc(tw*th, sizeof(uint8_t)); ++ uint8_t *im_max_tmp = OS_CALLOC(tw*th, sizeof(uint8_t)); ++ uint8_t *im_min_tmp = OS_CALLOC(tw*th, sizeof(uint8_t)); + + for (int ty = 0; ty < th; ty++) { + for (int tx = 0; tx < tw; tx++) { +@@ -1185,8 +1187,8 @@ + im_min_tmp[ty*tw + tx] = min; + } + } +- free(im_max); +- free(im_min); ++ OS_FREE(im_max); ++ OS_FREE(im_min); + im_max = im_max_tmp; + im_min = im_min_tmp; + } +@@ -1270,8 +1272,8 @@ + } + } + +- free(im_min); +- free(im_max); ++ OS_FREE(im_min); ++ OS_FREE(im_max); + + // this is a dilate/erode deglitching scheme that does not improve + // anything as far as I can tell. +@@ -1332,8 +1334,8 @@ + + uint8_t *im_max[4], *im_min[4]; + for (int i = 0; i < 4; i++) { +- im_max[i] = calloc(tw*th, sizeof(uint8_t)); +- im_min[i] = calloc(tw*th, sizeof(uint8_t)); ++ im_max[i] = OS_CALLOC(tw*th, sizeof(uint8_t)); ++ im_min[i] = OS_CALLOC(tw*th, sizeof(uint8_t)); + } + + for (int ty = 0; ty < th; ty++) { +@@ -1424,8 +1426,8 @@ + } + + for (int i = 0; i < 4; i++) { +- free(im_min[i]); +- free(im_max[i]); ++ OS_FREE(im_min[i]); ++ OS_FREE(im_max[i]); + } + + timeprofile_stamp(td->tp, "threshold"); +@@ -1446,7 +1448,7 @@ + + int sz = h; + int chunksize = 1 + sz / (APRILTAG_TASKS_PER_THREAD_TARGET * td->nthreads); +- struct unionfind_task *tasks = malloc(sizeof(struct unionfind_task)*(sz / chunksize + 1)); ++ struct unionfind_task *tasks = OS_MALLOC(sizeof(struct unionfind_task)*(sz / chunksize + 1)); + + int ntasks = 0; + +@@ -1475,19 +1477,19 @@ + do_unionfind_line2(uf, threshim, h, w, ts, tasks[i].y0 - 1); + } + +- free(tasks); ++ OS_FREE(tasks); + } + return uf; + } + + zarray_t* do_gradient_clusters(image_u8_t* threshim, int ts, int y0, int y1, int w, int nclustermap, unionfind_t* uf, zarray_t* clusters) { +- struct uint64_zarray_entry **clustermap = calloc(nclustermap, sizeof(struct uint64_zarray_entry*)); ++ struct uint64_zarray_entry **clustermap = OS_CALLOC(nclustermap, sizeof(struct uint64_zarray_entry*)); + + int mem_chunk_size = 2048; +- struct uint64_zarray_entry** mem_pools = malloc(sizeof(struct uint64_zarray_entry *)*(1 + 2 * nclustermap / mem_chunk_size)); // SmodeTech: avoid memory corruption when nclustermap < mem_chunk_size ++ struct uint64_zarray_entry** mem_pools = OS_MALLOC(sizeof(struct uint64_zarray_entry *)*(1 + 2 * nclustermap / mem_chunk_size)); // SmodeTech: avoid memory corruption when nclustermap < mem_chunk_size + int mem_pool_idx = 0; + int mem_pool_loc = 0; +- mem_pools[mem_pool_idx] = calloc(mem_chunk_size, sizeof(struct uint64_zarray_entry)); ++ mem_pools[mem_pool_idx] = OS_CALLOC(mem_chunk_size, sizeof(struct uint64_zarray_entry)); + + for (int y = y0; y < y1; y++) { + for (int x = 1; x < w-1; x++) { +@@ -1546,7 +1548,7 @@ + if (mem_pool_loc == mem_chunk_size) { \ + mem_pool_loc = 0; \ + mem_pool_idx++; \ +- mem_pools[mem_pool_idx] = calloc(mem_chunk_size, sizeof(struct uint64_zarray_entry)); \ ++ mem_pools[mem_pool_idx] = OS_CALLOC(mem_chunk_size, sizeof(struct uint64_zarray_entry)); \ + } \ + entry = mem_pools[mem_pool_idx] + mem_pool_loc; \ + mem_pool_loc++; \ +@@ -1577,7 +1579,7 @@ + for (int i = 0; i < nclustermap; i++) { + int start = zarray_size(clusters); + for (struct uint64_zarray_entry *entry = clustermap[i]; entry; entry = entry->next) { +- struct cluster_hash* cluster_hash = malloc(sizeof(struct cluster_hash)); ++ struct cluster_hash* cluster_hash = OS_MALLOC(sizeof(struct cluster_hash)); + cluster_hash->hash = u64hash_2(entry->id) % nclustermap; + cluster_hash->id = entry->id; + cluster_hash->data = entry->cluster; +@@ -1602,10 +1604,10 @@ + } + } + for (int i = 0; i <= mem_pool_idx; i++) { +- free(mem_pools[i]); ++ OS_FREE(mem_pools[i]); + } +- free(mem_pools); +- free(clustermap); ++ OS_FREE(mem_pools); ++ OS_FREE(clustermap); + + return clusters; + } +@@ -1638,7 +1640,7 @@ + i1++; + i2++; + zarray_destroy(h2->data); +- free(h2); ++ OS_FREE(h2); + } else if (h2->hash < h1->hash || (h2->hash == h1->hash && h2->id < h1->id)) { + zarray_add(ret, &h2); + i2++; +@@ -1672,7 +1674,7 @@ + + int sz = h - 1; + int chunksize = 1 + sz / td->nthreads; +- struct cluster_task *tasks = malloc(sizeof(struct cluster_task)*(sz / chunksize + 1)); ++ struct cluster_task *tasks = OS_MALLOC(sizeof(struct cluster_task)*(sz / chunksize + 1)); + + int ntasks = 0; + +@@ -1694,7 +1696,7 @@ + + workerpool_run(td->wp); + +- zarray_t** clusters_list = malloc(sizeof(zarray_t *)*ntasks); ++ zarray_t** clusters_list = OS_MALLOC(sizeof(zarray_t *)*ntasks); + for (int i = 0; i < ntasks; i++) { + clusters_list[i] = tasks[i].clusters; + } +@@ -1720,11 +1722,11 @@ + struct cluster_hash* hash; + zarray_get(clusters_list[0], i, &hash); + zarray_add(clusters, &hash->data); +- free(hash); ++ OS_FREE(hash); + } + zarray_destroy(clusters_list[0]); +- free(clusters_list); +- free(tasks); ++ OS_FREE(clusters_list); ++ OS_FREE(tasks); + return clusters; + } + +@@ -1750,7 +1752,7 @@ + + int sz = zarray_size(clusters); + int chunksize = 1 + sz / (APRILTAG_TASKS_PER_THREAD_TARGET * td->nthreads); +- struct quad_task *tasks = malloc(sizeof(struct quad_task)*(sz / chunksize + 1)); ++ struct quad_task *tasks = OS_MALLOC(sizeof(struct quad_task)*(sz / chunksize + 1)); + + int ntasks = 0; + for (int i = 0; i < sz; i += chunksize) { +@@ -1772,7 +1774,7 @@ + + workerpool_run(td->wp); + +- free(tasks); ++ OS_FREE(tasks); + + return quads; + } +@@ -1799,7 +1801,7 @@ + if (td->debug) { + image_u8x3_t *d = image_u8x3_create(w, h); + +- uint32_t *colors = (uint32_t*) calloc(w*h, sizeof(*colors)); ++ uint32_t *colors = (uint32_t*) OS_CALLOC(w*h, sizeof(*colors)); + + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { +@@ -1827,7 +1829,7 @@ + } + } + +- free(colors); ++ OS_FREE(colors); + + image_u8x3_write_pnm(d, "debug_segmentation.pnm"); + image_u8x3_destroy(d); +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_floats_impl.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_floats_impl.h +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_floats_impl.h 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_floats_impl.h 2021-11-17 11:07:32.502776606 +0800 +@@ -33,6 +33,8 @@ + #include "matd.h" + #include "math_util.h" + ++#include "port.h" ++ + // XXX Write unit tests for me! + // XXX Rewrite matd_coords in terms of this. + +@@ -70,7 +72,7 @@ + if (!v) + return NULL; + +- TNAME *r = (TNAME*)malloc(len * sizeof(TNAME)); ++ TNAME *r = (TNAME*)OS_MALLOC(len * sizeof(TNAME)); + memcpy(r, v, len * sizeof(TNAME)); + return r; + } +@@ -688,11 +690,11 @@ + const TNAME *C, int Crows, int Ccols, + TNAME *R, int Rrows, int Rcols) + { +- TNAME *tmp = malloc(sizeof(TNAME)*Arows*Bcols); ++ TNAME *tmp = OS_MALLOC(sizeof(TNAME)*Arows*Bcols); + + TFN(s_mat_AB)(A, Arows, Acols, B, Brows, Bcols, tmp, Arows, Bcols); + TFN(s_mat_AB)(tmp, Arows, Bcols, C, Crows, Ccols, R, Rrows, Rcols); +- free(tmp); ++ OS_FREE(tmp); + } + + static inline void TFN(s_mat_Ab)(const TNAME *A, int Arows, int Acols, +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c 2021-11-17 11:07:32.502776606 +0800 +@@ -37,6 +37,8 @@ + #include "getopt.h" + #include "common/math_util.h" + ++#include "port.h" ++ + #define GOO_BOOL_TYPE 1 + #define GOO_STRING_TYPE 2 + +@@ -66,7 +68,7 @@ + + getopt_t *getopt_create() + { +- getopt_t *gopt = (getopt_t*) calloc(1, sizeof(getopt_t)); ++ getopt_t *gopt = (getopt_t*) OS_CALLOC(1, sizeof(getopt_t)); + + gopt->lopts = zhash_create(sizeof(char*), sizeof(getopt_option_t*), zhash_str_hash, zhash_str_equals); + gopt->sopts = zhash_create(sizeof(char*), sizeof(getopt_option_t*), zhash_str_hash, zhash_str_equals); +@@ -78,18 +80,24 @@ + + void getopt_option_destroy(getopt_option_t *goo) + { +- free(goo->sname); +- free(goo->lname); +- free(goo->svalue); +- free(goo->help); ++ OS_FREE(goo->sname); ++ OS_FREE(goo->lname); ++ OS_FREE(goo->svalue); ++ OS_FREE(goo->help); + memset(goo, 0, sizeof(getopt_option_t)); +- free(goo); ++ OS_FREE(goo); ++} ++ ++void getopt_free(void *p) ++{ ++ OS_FREE(p); + } + + void getopt_destroy(getopt_t *gopt) + { + // free the extra arguments and container +- zarray_vmap(gopt->extraargs, free); ++ //zarray_vmap(gopt->extraargs, free); ++ zarray_vmap(gopt->extraargs, getopt_free); + zarray_destroy(gopt->extraargs); + + // deep free of the getopt_option structs. Also frees key/values, so +@@ -102,7 +110,7 @@ + zhash_destroy(gopt->sopts); + + memset(gopt, 0, sizeof(getopt_t)); +- free(gopt); ++ OS_FREE(gopt); + } + + static void getopt_modify_string(char **str, char *newvalue) +@@ -110,7 +118,7 @@ + char *old = *str; + *str = newvalue; + if (old != NULL) +- free(old); ++ OS_FREE(old); + } + + static char *get_arg_assignment(char *arg) +@@ -168,7 +176,7 @@ + val[last] = 0; + char *valclean = strdup(&val[1]); + zarray_add(toks, &valclean); +- free(val); ++ OS_FREE(val); + } else { + zarray_add(toks, &val); + } +@@ -184,7 +192,7 @@ + + // rather than free statement throughout this while loop + if (tok != NULL) +- free(tok); ++ OS_FREE(tok); + + zarray_get(toks, i, &tok); + +@@ -303,7 +311,7 @@ + i++; + } + if (tok != NULL) +- free(tok); ++ OS_FREE(tok); + + zarray_destroy(toks); + +@@ -312,7 +320,7 @@ + + void getopt_add_spacer(getopt_t *gopt, const char *s) + { +- getopt_option_t *goo = (getopt_option_t*) calloc(1, sizeof(getopt_option_t)); ++ getopt_option_t *goo = (getopt_option_t*) OS_CALLOC(1, sizeof(getopt_option_t)); + goo->spacer = 1; + goo->help = strdup(s); + zarray_add(gopt->options, &goo); +@@ -345,7 +353,7 @@ + exit (EXIT_FAILURE); + } + +- getopt_option_t *goo = (getopt_option_t*) calloc(1, sizeof(getopt_option_t)); ++ getopt_option_t *goo = (getopt_option_t*) OS_CALLOC(1, sizeof(getopt_option_t)); + goo->sname=strdup(sname); + goo->lname=strdup(lname); + goo->svalue=strdup(def ? "true" : "false"); +@@ -395,7 +403,7 @@ + exit (EXIT_FAILURE); + } + +- getopt_option_t *goo = (getopt_option_t*) calloc(1, sizeof(getopt_option_t)); ++ getopt_option_t *goo = (getopt_option_t*) OS_CALLOC(1, sizeof(getopt_option_t)); + goo->sname=strdup(sname); + goo->lname=strdup(lname); + goo->svalue=strdup(def); +@@ -488,7 +496,7 @@ + { + char * usage = getopt_get_usage(gopt); + printf("%s", usage); +- free(usage); ++ OS_FREE(usage); + } + + char * getopt_get_usage(getopt_t *gopt) +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c 2021-11-17 11:07:32.502776606 +0800 +@@ -35,18 +35,20 @@ + #include "common/pnm.h" + #include "common/math_util.h" + ++#include "port.h" ++ + // least common multiple of 64 (sandy bridge cache line) and 24 (stride + // needed for RGB in 8-wide vector processing) + #define DEFAULT_ALIGNMENT_U8 96 + + image_u8_t *image_u8_create_stride(unsigned int width, unsigned int height, unsigned int stride) + { +- uint8_t *buf = calloc(height*stride, sizeof(uint8_t)); ++ uint8_t *buf = OS_CALLOC(height*stride, sizeof(uint8_t)); + + // const initializer + image_u8_t tmp = { .width = width, .height = height, .stride = stride, .buf = buf }; + +- image_u8_t *im = calloc(1, sizeof(image_u8_t)); ++ image_u8_t *im = OS_CALLOC(1, sizeof(image_u8_t)); + memcpy(im, &tmp, sizeof(image_u8_t)); + return im; + } +@@ -68,13 +70,13 @@ + + image_u8_t *image_u8_copy(const image_u8_t *in) + { +- uint8_t *buf = malloc(in->height*in->stride*sizeof(uint8_t)); ++ uint8_t *buf = OS_MALLOC(in->height*in->stride*sizeof(uint8_t)); + memcpy(buf, in->buf, in->height*in->stride*sizeof(uint8_t)); + + // const initializer + image_u8_t tmp = { .width = in->width, .height = in->height, .stride = in->stride, .buf = buf }; + +- image_u8_t *copy = calloc(1, sizeof(image_u8_t)); ++ image_u8_t *copy = OS_CALLOC(1, sizeof(image_u8_t)); + memcpy(copy, &tmp, sizeof(image_u8_t)); + return copy; + } +@@ -84,8 +86,8 @@ + if (!im) + return; + +- free(im->buf); +- free(im); ++ OS_FREE(im->buf); ++ OS_FREE(im); + } + + //////////////////////////////////////////////////////////// +@@ -320,26 +322,26 @@ + + for (int y = 0; y < im->height; y++) { + +- uint8_t *x = malloc(sizeof(uint8_t)*im->stride); ++ uint8_t *x = OS_MALLOC(sizeof(uint8_t)*im->stride); + memcpy(x, &im->buf[y*im->stride], im->stride); + + convolve(x, &im->buf[y*im->stride], im->width, k, ksz); +- free(x); ++ OS_FREE(x); + } + + for (int x = 0; x < im->width; x++) { +- uint8_t *xb = malloc(sizeof(uint8_t)*im->height); +- uint8_t *yb = malloc(sizeof(uint8_t)*im->height); ++ uint8_t *xb = OS_MALLOC(sizeof(uint8_t)*im->height); ++ uint8_t *yb = OS_MALLOC(sizeof(uint8_t)*im->height); + + for (int y = 0; y < im->height; y++) + xb[y] = im->buf[y*im->stride + x]; + + convolve(xb, yb, im->height, k, ksz); +- free(xb); ++ OS_FREE(xb); + + for (int y = 0; y < im->height; y++) + im->buf[y*im->stride + x] = yb[y]; +- free(yb); ++ OS_FREE(yb); + } + } + +@@ -351,7 +353,7 @@ + assert((ksz & 1) == 1); // ksz must be odd. + + // build the kernel. +- double *dk = malloc(sizeof(double)*ksz); ++ double *dk = OS_MALLOC(sizeof(double)*ksz); + + // for kernel of length 5: + // dk[0] = f(-2), dk[1] = f(-1), dk[2] = f(0), dk[3] = f(1), dk[4] = f(2) +@@ -369,7 +371,7 @@ + for (int i = 0; i < ksz; i++) + dk[i] /= acc; + +- uint8_t *k = malloc(sizeof(uint8_t)*ksz); ++ uint8_t *k = OS_MALLOC(sizeof(uint8_t)*ksz); + for (int i = 0; i < ksz; i++) + k[i] = dk[i]*255; + +@@ -377,10 +379,10 @@ + for (int i = 0; i < ksz; i++) + printf("%d %15f %5d\n", i, dk[i], k[i]); + } +- free(dk); ++ OS_FREE(dk); + + image_u8_convolve_2D(im, k, ksz); +- free(k); ++ OS_FREE(k); + } + + image_u8_t *image_u8_rotate(const image_u8_t *in, double rad, uint8_t pad) +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3.c 2021-11-17 11:07:32.502776606 +0800 +@@ -36,6 +36,8 @@ + + #include "image_u8x3.h" + ++#include "port.h" ++ + // least common multiple of 64 (sandy bridge cache line) and 48 (stride needed + // for 16byte-wide RGB processing). (It's possible that 48 would be enough). + #define DEFAULT_ALIGNMENT_U8X3 192 +@@ -52,25 +54,25 @@ + if ((stride % alignment) != 0) + stride += alignment - (stride % alignment); + +- uint8_t *buf = calloc(height*stride, sizeof(uint8_t)); ++ uint8_t *buf = OS_CALLOC(height*stride, sizeof(uint8_t)); + + // const initializer + image_u8x3_t tmp = { .width = width, .height = height, .stride = stride, .buf = buf }; + +- image_u8x3_t *im = calloc(1, sizeof(image_u8x3_t)); ++ image_u8x3_t *im = OS_CALLOC(1, sizeof(image_u8x3_t)); + memcpy(im, &tmp, sizeof(image_u8x3_t)); + return im; + } + + image_u8x3_t *image_u8x3_copy(const image_u8x3_t *in) + { +- uint8_t *buf = malloc(in->height*in->stride*sizeof(uint8_t)); ++ uint8_t *buf = OS_MALLOC(in->height*in->stride*sizeof(uint8_t)); + memcpy(buf, in->buf, in->height*in->stride*sizeof(uint8_t)); + + // const initializer + image_u8x3_t tmp = { .width = in->width, .height = in->height, .stride = in->stride, .buf = buf }; + +- image_u8x3_t *copy = calloc(1, sizeof(image_u8x3_t)); ++ image_u8x3_t *copy = OS_CALLOC(1, sizeof(image_u8x3_t)); + memcpy(copy, &tmp, sizeof(image_u8x3_t)); + return copy; + } +@@ -80,8 +82,8 @@ + if (!im) + return; + +- free(im->buf); +- free(im); ++ OS_FREE(im->buf); ++ OS_FREE(im); + } + + //////////////////////////////////////////////////////////// +@@ -210,7 +212,7 @@ + assert((ksz & 1) == 1); // ksz must be odd. + + // build the kernel. +- double *dk = malloc(sizeof(double)*ksz); ++ double *dk = OS_MALLOC(sizeof(double)*ksz); + + // for kernel of length 5: + // dk[0] = f(-2), dk[1] = f(-1), dk[2] = f(0), dk[3] = f(1), dk[4] = f(2) +@@ -228,7 +230,7 @@ + for (int i = 0; i < ksz; i++) + dk[i] /= acc; + +- uint8_t *k = malloc(sizeof(uint8_t)*ksz); ++ uint8_t *k = OS_MALLOC(sizeof(uint8_t)*ksz); + for (int i = 0; i < ksz; i++) + k[i] = dk[i]*255; + +@@ -236,39 +238,39 @@ + for (int i = 0; i < ksz; i++) + printf("%d %15f %5d\n", i, dk[i], k[i]); + } +- free(dk); ++ OS_FREE(dk); + + for (int c = 0; c < 3; c++) { + for (int y = 0; y < im->height; y++) { + +- uint8_t *in = malloc(sizeof(uint8_t)*im->stride); +- uint8_t *out = malloc(sizeof(uint8_t)*im->stride); ++ uint8_t *in = OS_MALLOC(sizeof(uint8_t)*im->stride); ++ uint8_t *out = OS_MALLOC(sizeof(uint8_t)*im->stride); + + for (int x = 0; x < im->width; x++) + in[x] = im->buf[y*im->stride + 3 * x + c]; + + convolve(in, out, im->width, k, ksz); +- free(in); ++ OS_FREE(in); + + for (int x = 0; x < im->width; x++) + im->buf[y*im->stride + 3 * x + c] = out[x]; +- free(out); ++ OS_FREE(out); + } + + for (int x = 0; x < im->width; x++) { +- uint8_t *in = malloc(sizeof(uint8_t)*im->height); +- uint8_t *out = malloc(sizeof(uint8_t)*im->height); ++ uint8_t *in = OS_MALLOC(sizeof(uint8_t)*im->height); ++ uint8_t *out = OS_MALLOC(sizeof(uint8_t)*im->height); + + for (int y = 0; y < im->height; y++) + in[y] = im->buf[y*im->stride + 3*x + c]; + + convolve(in, out, im->height, k, ksz); +- free(in); ++ OS_FREE(in); + + for (int y = 0; y < im->height; y++) + im->buf[y*im->stride + 3*x + c] = out[y]; +- free(out); ++ OS_FREE(out); + } + } +- free(k); ++ OS_FREE(k); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4.c 2021-11-17 11:07:32.502776606 +0800 +@@ -34,6 +34,8 @@ + #include "pnm.h" + #include "image_u8x4.h" + ++#include "port.h" ++ + // least common multiple of 64 (sandy bridge cache line) and 64 (stride needed + // for 16byte-wide RGBA processing). + #define DEFAULT_ALIGNMENT_U8X4 64 +@@ -50,25 +52,25 @@ + if ((stride % alignment) != 0) + stride += alignment - (stride % alignment); + +- uint8_t *buf = calloc(height*stride, sizeof(uint8_t)); ++ uint8_t *buf = OS_CALLOC(height*stride, sizeof(uint8_t)); + + // const initializer + image_u8x4_t tmp = { .width = width, .height = height, .stride = stride, .buf = buf }; + +- image_u8x4_t *im = calloc(1, sizeof(image_u8x4_t)); ++ image_u8x4_t *im = OS_CALLOC(1, sizeof(image_u8x4_t)); + memcpy(im, &tmp, sizeof(image_u8x4_t)); + return im; + } + + image_u8x4_t *image_u8x4_copy(const image_u8x4_t *in) + { +- uint8_t *buf = malloc(in->height*in->stride*sizeof(uint8_t)); ++ uint8_t *buf = OS_MALLOC(in->height*in->stride*sizeof(uint8_t)); + memcpy(buf, in->buf, in->height*in->stride*sizeof(uint8_t)); + + // const initializer + image_u8x4_t tmp = { .width = in->width, .height = in->height, .stride = in->stride, .buf = buf }; + +- image_u8x4_t *copy = calloc(1, sizeof(image_u8x4_t)); ++ image_u8x4_t *copy = OS_CALLOC(1, sizeof(image_u8x4_t)); + memcpy(copy, &tmp, sizeof(image_u8x4_t)); + return copy; + } +@@ -78,8 +80,8 @@ + if (!im) + return; + +- free(im->buf); +- free(im); ++ OS_FREE(im->buf); ++ OS_FREE(im); + } + + //////////////////////////////////////////////////////////// +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c 2021-11-17 11:07:32.502776606 +0800 +@@ -37,6 +37,8 @@ + #include "common/svd22.h" + #include "common/matd.h" + ++#include "port.h" ++ + // a matd_t with rows=0 cols=0 is a SCALAR. + + // to ease creating mati, matf, etc. in the future. +@@ -50,7 +52,7 @@ + if (rows == 0 || cols == 0) + return matd_create_scalar(0); + +- matd_t *m = calloc(1, sizeof(matd_t) + (rows*cols*sizeof(double))); ++ matd_t *m = OS_CALLOC(1, sizeof(matd_t) + (rows*cols*sizeof(double))); + m->nrows = rows; + m->ncols = cols; + +@@ -59,7 +61,7 @@ + + matd_t *matd_create_scalar(TYPE v) + { +- matd_t *m = calloc(1, sizeof(matd_t) + sizeof(double)); ++ matd_t *m = OS_CALLOC(1, sizeof(matd_t) + sizeof(double)); + m->nrows = 0; + m->ncols = 0; + m->data[0] = v; +@@ -224,7 +226,7 @@ + return; + + assert(m != NULL); +- free(m); ++ OS_FREE(m); + } + + matd_t *matd_multiply(const matd_t *a, const matd_t *b) +@@ -811,7 +813,7 @@ + va_list ap; + va_start(ap, expr); + +- matd_t **args = malloc(sizeof(matd_t*)*nargs); ++ matd_t **args = OS_MALLOC(sizeof(matd_t*)*nargs); + for (int i = 0; i < nargs; i++) { + args[i] = va_arg(ap, matd_t*); + // XXX: sanity check argument; emit warning/error if args[i] +@@ -826,10 +828,10 @@ + + // can't create more than 2 new result per character + // one result, and possibly one argument to free +- matd_t **garb = malloc(sizeof(matd_t*)*2*exprlen); ++ matd_t **garb = OS_MALLOC(sizeof(matd_t*)*2*exprlen); + + matd_t *res = matd_op_recurse(expr, &pos, NULL, args, &argpos, garb, &garbpos, 0); +- free(args); ++ OS_FREE(args); + + // 'res' may need to be freed as part of garbage collection (i.e. expr = "F") + matd_t *res_copy = (res ? matd_copy(res) : NULL); +@@ -837,7 +839,7 @@ + for (int i = 0; i < garbpos; i++) { + matd_destroy(garb[i]); + } +- free(garb); ++ OS_FREE(garb); + + return res_copy; + } +@@ -1024,7 +1026,7 @@ + // + int vlen = A->nrows - hhidx; + +- double *v = malloc(sizeof(double)*vlen); ++ double *v = OS_MALLOC(sizeof(double)*vlen); + + double mag2 = 0; + for (int i = 0; i < vlen; i++) { +@@ -1045,7 +1047,7 @@ + + // this case arises with matrices of all zeros, for example. + if (mag == 0) { +- free(v); ++ OS_FREE(v); + continue; + } + +@@ -1079,13 +1081,13 @@ + MATD_EL(B, hhidx+j, i) -= 2*dot*v[j]; + } + +- free(v); ++ OS_FREE(v); + } + + if (hhidx+2 < A->ncols) { + int vlen = A->ncols - hhidx - 1; + +- double *v = malloc(sizeof(double)*vlen); ++ double *v = OS_MALLOC(sizeof(double)*vlen); + + double mag2 = 0; + for (int i = 0; i < vlen; i++) { +@@ -1135,7 +1137,7 @@ + MATD_EL(B, i, hhidx+1+j) -= 2*dot*v[j]; + } + +- free(v); ++ OS_FREE(v); + } + } + +@@ -1156,7 +1158,7 @@ + + // for each of the first B->ncols rows, which index has the + // maximum absolute value? (used by method 1) +- int *maxrowidx = malloc(sizeof(int)*B->ncols); ++ int *maxrowidx = OS_MALLOC(sizeof(int)*B->ncols); + int lastmaxi, lastmaxj; + + if (find_max_method == 1) { +@@ -1370,7 +1372,7 @@ + } + } + +- free(maxrowidx); ++ OS_FREE(maxrowidx); + + if (!(flags & MATD_SVD_NO_WARNINGS) && iter == maxiters) { + printf("WARNING: maximum iters (maximum = %d, matrix %d x %d, max=%.15f)\n", +@@ -1381,8 +1383,8 @@ + + // them all positive by flipping the corresponding columns of + // U/LS. +- int *idxs = malloc(sizeof(int)*A->ncols); +- double *vals = malloc(sizeof(double)*A->ncols); ++ int *idxs = OS_MALLOC(sizeof(int)*A->ncols); ++ double *vals = OS_MALLOC(sizeof(double)*A->ncols); + for (int i = 0; i < A->ncols; i++) { + idxs[i] = i; + vals[i] = MATD_EL(B, i, i); +@@ -1418,8 +1420,8 @@ + MATD_EL(LP, idxs[i], i) = vals[i] < 0 ? -1 : 1; + MATD_EL(RP, idxs[i], i) = 1; //vals[i] < 0 ? -1 : 1; + } +- free(idxs); +- free(vals); ++ OS_FREE(idxs); ++ OS_FREE(vals); + + // we've factored: + // LP*(something)*RP' +@@ -1508,14 +1510,14 @@ + + matd_plu_t *matd_plu(const matd_t *a) + { +- unsigned int *piv = calloc(a->nrows, sizeof(unsigned int)); ++ unsigned int *piv = OS_CALLOC(a->nrows, sizeof(unsigned int)); + int pivsign = 1; + matd_t *lu = matd_copy(a); + + // only for square matrices. + assert(a->nrows == a->ncols); + +- matd_plu_t *mlu = calloc(1, sizeof(matd_plu_t)); ++ matd_plu_t *mlu = OS_CALLOC(1, sizeof(matd_plu_t)); + + for (int i = 0; i < a->nrows; i++) + piv[i] = i; +@@ -1544,7 +1546,7 @@ + + // swap rows p and j? + if (p != j) { +- TYPE *tmp = malloc(sizeof(TYPE)*lu->ncols); ++ TYPE *tmp = OS_MALLOC(sizeof(TYPE)*lu->ncols); + memcpy(tmp, &MATD_EL(lu, p, 0), sizeof(TYPE) * lu->ncols); + memcpy(&MATD_EL(lu, p, 0), &MATD_EL(lu, j, 0), sizeof(TYPE) * lu->ncols); + memcpy(&MATD_EL(lu, j, 0), tmp, sizeof(TYPE) * lu->ncols); +@@ -1552,7 +1554,7 @@ + piv[p] = piv[j]; + piv[j] = k; + pivsign = -pivsign; +- free(tmp); ++ OS_FREE(tmp); + } + + double LUjj = MATD_EL(lu, j, j); +@@ -1589,9 +1591,9 @@ + void matd_plu_destroy(matd_plu_t *mlu) + { + matd_destroy(mlu->lu); +- free(mlu->piv); ++ OS_FREE(mlu->piv); + memset(mlu, 0, sizeof(matd_plu_t)); +- free(mlu); ++ OS_FREE(mlu); + } + + double matd_plu_det(const matd_plu_t *mlu) +@@ -1819,7 +1821,7 @@ + // XXX NGV Cholesky + /*static double *matd_cholesky_raw(double *A, int n) + { +- double *L = (double*)calloc(n * n, sizeof(double)); ++ double *L = (double*)OS_CALLOC(n * n, sizeof(double)); + + for (int i = 0; i < n; i++) { + for (int j = 0; j < (i+1); j++) { +@@ -1840,7 +1842,7 @@ + assert(A->nrows == A->ncols); + double *L_data = matd_cholesky_raw(A->data, A->nrows); + matd_t *L = matd_create_data(A->nrows, A->ncols, L_data); +- free(L_data); ++ OS_FREE(L_data); + return L; + }*/ + +@@ -1887,7 +1889,7 @@ + } + } + +- matd_chol_t *chol = calloc(1, sizeof(matd_chol_t)); ++ matd_chol_t *chol = OS_CALLOC(1, sizeof(matd_chol_t)); + chol->is_spd = is_spd; + chol->u = U; + return chol; +@@ -1896,7 +1898,7 @@ + void matd_chol_destroy(matd_chol_t *chol) + { + matd_destroy(chol->u); +- free(chol); ++ OS_FREE(chol); + } + + // Solve: (U')x = b, U is upper triangular +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c 2021-11-17 11:07:32.502776606 +0800 +@@ -32,6 +32,8 @@ + + #include "pam.h" + ++#include "port.h" ++ + pam_t *pam_create_from_file(const char *inpath) + { + FILE *infile = fopen(inpath, "r"); +@@ -40,7 +42,7 @@ + return NULL; + } + +- pam_t *pam = calloc(1, sizeof(pam_t)); ++ pam_t *pam = OS_CALLOC(1, sizeof(pam_t)); + pam->width = -1; + pam->height = -1; + pam->depth = -1; +@@ -140,7 +142,7 @@ + assert(pam->maxval == 255); + + pam->datalen = pam->width * pam->height * pam->depth; +- pam->data = malloc(pam->datalen); ++ pam->data = OS_MALLOC(pam->datalen); + if (pam->datalen != fread(pam->data, 1, pam->datalen, infile)) { + printf("pam.c: couldn't read body\n"); + goto fail; +@@ -150,7 +152,7 @@ + return pam; + + fail: +- free(pam); ++ OS_FREE(pam); + fclose(infile); + return NULL; + } +@@ -197,13 +199,13 @@ + if (!pam) + return; + +- free(pam->data); +- free(pam); ++ OS_FREE(pam->data); ++ OS_FREE(pam); + } + + pam_t *pam_copy(pam_t *pam) + { +- pam_t *copy = calloc(1, sizeof(pam_t)); ++ pam_t *copy = OS_CALLOC(1, sizeof(pam_t)); + copy->width = pam->width; + copy->height = pam->height; + copy->depth = pam->depth; +@@ -211,7 +213,7 @@ + copy->type = pam->type; + + copy->datalen = pam->datalen; +- copy->data = malloc(pam->datalen); ++ copy->data = OS_MALLOC(pam->datalen); + memcpy(copy->data, pam->data, pam->datalen); + + return copy; +@@ -228,14 +230,14 @@ + int w = in->width; + int h = in->height; + +- pam_t *out = calloc(1, sizeof(pam_t)); ++ pam_t *out = OS_CALLOC(1, sizeof(pam_t)); + out->type = type; + out->width = w; + out->height = h; + out->maxval = in->maxval; + out->depth = 4; + out->datalen = 4 * w * h; +- out->data = malloc(out->datalen); ++ out->data = OS_MALLOC(out->datalen); + + if (in->type == PAM_RGB) { + assert(in->depth == 3); +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c 2021-11-17 11:07:32.502776606 +0800 +@@ -36,6 +36,8 @@ + #include "image_u8.h" + #include "image_u8x3.h" + ++#include "port.h" ++ + // https://www.w3.org/Graphics/JPEG/itu-t81.pdf + + void pjpeg_idct_2D_double(int32_t in[64], uint8_t *out, uint32_t outstride); +@@ -344,7 +346,7 @@ + return PJPEG_ERR_SOF; + + pjd->ncomponents = nf; +- pjd->components = calloc(nf, sizeof(struct pjpeg_component)); ++ pjd->components = OS_CALLOC(nf, sizeof(struct pjpeg_component)); + + for (int i = 0; i < nf; i++) { + // comp. identifier +@@ -449,7 +451,7 @@ + uint8_t ns = bd_consume_bits(&bd, 8); + + // for each component, what is the index into our pjd->components[] array? +- uint8_t *comp_idx = calloc(ns, sizeof(uint8_t)); ++ uint8_t *comp_idx = OS_CALLOC(ns, sizeof(uint8_t)); + + for (int i = 0; i < ns; i++) { + // component name +@@ -511,13 +513,12 @@ + int alignment = 32; + if ((comp->stride % alignment) != 0) + comp->stride += alignment - (comp->stride % alignment); +- +- comp->data = calloc(comp->height * comp->stride, 1); ++ comp->data = OS_CALLOC(comp->height * comp->stride, 1); + } + + + // each component has its own DC prediction +- int32_t *dcpred = calloc(ns, sizeof(int32_t)); ++ int32_t *dcpred = OS_CALLOC(ns, sizeof(int32_t)); + + pjd->reset_count = 0; + +@@ -647,9 +648,8 @@ + + } + } +- +- free(dcpred); +- free(comp_idx); ++ OS_FREE(dcpred); ++ OS_FREE(comp_idx); + + break; + } +@@ -691,10 +691,10 @@ + return; + + for (int i = 0; i < pj->ncomponents; i++) +- free(pj->components[i].data); +- free(pj->components); ++ OS_FREE(pj->components[i].data); ++ OS_FREE(pj->components); + +- free(pj); ++ OS_FREE(pj); + } + + +@@ -830,57 +830,53 @@ + fseek(f, 0, SEEK_END); + long buflen = ftell(f); + +- uint8_t *buf = malloc(buflen); ++ uint8_t *buf = OS_MALLOC(buflen); + fseek(f, 0, SEEK_SET); + int res = fread(buf, 1, buflen, f); + fclose(f); + if (res != buflen) { +- free(buf); ++ OS_FREE(buf); + if (error) + *error = PJPEG_ERR_FILE; + return NULL; + } + + pjpeg_t *pj = pjpeg_create_from_buffer(buf, buflen, flags, error); +- +- free(buf); ++ OS_FREE(buf); + return pj; + } + + pjpeg_t *pjpeg_create_from_buffer(uint8_t *buf, int buflen, uint32_t flags, int *error) + { +- struct pjpeg_decode_state pjd; +- memset(&pjd, 0, sizeof(pjd)); ++ struct pjpeg_decode_state *pjd = (struct pjpeg_decode_state *)OS_MALLOC(sizeof(struct pjpeg_decode_state)); ++ memset(pjd, 0, sizeof(*pjd)); + + if (flags & PJPEG_MJPEG) { +- pjd.in = mjpeg_dht; +- pjd.inlen = sizeof(mjpeg_dht); +- int result = pjpeg_decode_buffer(&pjd); ++ pjd->in = mjpeg_dht; ++ pjd->inlen = sizeof(mjpeg_dht); ++ int result = pjpeg_decode_buffer(pjd); + assert(result == 0); + } +- +- pjd.in = buf; +- pjd.inlen = buflen; +- pjd.flags = flags; +- +- int result = pjpeg_decode_buffer(&pjd); ++ pjd->in = buf; ++ pjd->inlen = buflen; ++ pjd->flags = flags; ++ int result = pjpeg_decode_buffer(pjd); + if (error) + *error = result; +- + if (result) { +- for (int i = 0; i < pjd.ncomponents; i++) +- free(pjd.components[i].data); +- free(pjd.components); ++ for (int i = 0; i < pjd->ncomponents; i++) ++ OS_FREE(pjd->components[i].data); ++ OS_FREE(pjd->components); + + return NULL; + } ++ pjpeg_t *pj = OS_CALLOC(1, sizeof(pjpeg_t)); + +- pjpeg_t *pj = calloc(1, sizeof(pjpeg_t)); +- +- pj->width = pjd.width; +- pj->height = pjd.height; +- pj->ncomponents = pjd.ncomponents; +- pj->components = pjd.components; ++ pj->width = pjd->width; ++ pj->height = pjd->height; ++ pj->ncomponents = pjd->ncomponents; ++ pj->components = pjd->components; ++ OS_FREE(pjd); + + return pj; + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c 2021-11-17 11:07:32.502776606 +0800 +@@ -32,13 +32,15 @@ + + #include "pnm.h" + ++#include "port.h" ++ + pnm_t *pnm_create_from_file(const char *path) + { + FILE *f = fopen(path, "rb"); + if (f == NULL) + return NULL; + +- pnm_t *pnm = calloc(1, sizeof(pnm_t)); ++ pnm_t *pnm = OS_CALLOC(1, sizeof(pnm_t)); + pnm->format = -1; + + char tmp[1024]; +@@ -91,7 +93,7 @@ + pnm->max = 1; + + pnm->buflen = pnm->height * ((pnm->width + 7) / 8); +- pnm->buf = malloc(pnm->buflen); ++ pnm->buf = OS_MALLOC(pnm->buflen); + size_t len = fread(pnm->buf, 1, pnm->buflen, f); + if (len != pnm->buflen) + goto error; +@@ -108,7 +110,7 @@ + else + assert(0); + +- pnm->buf = malloc(pnm->buflen); ++ pnm->buf = OS_MALLOC(pnm->buflen); + size_t len = fread(pnm->buf, 1, pnm->buflen, f); + if (len != pnm->buflen) + goto error; +@@ -125,7 +127,7 @@ + else + assert(0); + +- pnm->buf = malloc(pnm->buflen); ++ pnm->buf = OS_MALLOC(pnm->buflen); + size_t len = fread(pnm->buf, 1, pnm->buflen, f); + if (len != pnm->buflen) + goto error; +@@ -138,8 +140,8 @@ + fclose(f); + + if (pnm != NULL) { +- free(pnm->buf); +- free(pnm); ++ OS_FREE(pnm->buf); ++ OS_FREE(pnm); + } + + return NULL; +@@ -150,6 +152,6 @@ + if (pnm == NULL) + return; + +- free(pnm->buf); +- free(pnm); ++ OS_FREE(pnm->buf); ++ OS_FREE(pnm); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util.c 2021-11-17 11:07:32.502776606 +0800 +@@ -36,6 +36,8 @@ + #include "string_util.h" + #include "zarray.h" + ++#include "port.h" ++ + struct string_buffer + { + char *s; +@@ -63,7 +65,7 @@ + assert(fmt != NULL); + + int size = MIN_PRINTF_ALLOC; +- char *buf = malloc(size * sizeof(char)); ++ char *buf = OS_MALLOC(size * sizeof(char)); + + int returnsize; + va_list args; +@@ -78,9 +80,9 @@ + } + + // otherwise, we should try again +- free(buf); ++ OS_FREE(buf); + size = returnsize + 1; +- buf = malloc(size * sizeof(char)); ++ buf = OS_MALLOC(size * sizeof(char)); + + va_copy(args, orig_args); + returnsize = vsnprintf(buf, size, fmt, args); +@@ -107,7 +109,7 @@ + } + + // write the string +- char *str = malloc(len*sizeof(char) + 1); ++ char *str = OS_MALLOC(len*sizeof(char) + 1); + char *ptr = str; + { + va_list args; +@@ -203,7 +205,7 @@ + size_t off1 = pos; + + size_t len_off = off1 - off0; +- char *tok = malloc(len_off + 1); ++ char *tok = OS_MALLOC(len_off + 1); + memcpy(tok, &str[off0], len_off); + tok[len_off] = 0; + zarray_add(parts, &tok); +@@ -317,10 +319,10 @@ + + string_buffer_t* string_buffer_create() + { +- string_buffer_t *sb = (string_buffer_t*) calloc(1, sizeof(string_buffer_t)); ++ string_buffer_t *sb = (string_buffer_t*) OS_CALLOC(1, sizeof(string_buffer_t)); + assert(sb != NULL); + sb->alloc = 32; +- sb->s = calloc(sb->alloc, 1); ++ sb->s = OS_CALLOC(sb->alloc, 1); + return sb; + } + +@@ -330,10 +332,10 @@ + return; + + if (sb->s) +- free(sb->s); ++ OS_FREE(sb->s); + + memset(sb, 0, sizeof(string_buffer_t)); +- free(sb); ++ OS_FREE(sb); + } + + void string_buffer_append(string_buffer_t *sb, char c) +@@ -342,7 +344,7 @@ + + if (sb->size+2 >= sb->alloc) { + sb->alloc *= 2; +- sb->s = realloc(sb->s, sb->alloc); ++ sb->s = OS_REALLOC(sb->s, sb->alloc); + } + + sb->s[sb->size++] = c; +@@ -365,7 +367,7 @@ + assert(fmt != NULL); + + int size = MIN_PRINTF_ALLOC; +- char *buf = malloc(size * sizeof(char)); ++ char *buf = OS_MALLOC(size * sizeof(char)); + + int returnsize; + va_list args; +@@ -376,9 +378,9 @@ + + if (returnsize >= size) { + // otherwise, we should try again +- free(buf); ++ OS_FREE(buf); + size = returnsize + 1; +- buf = malloc(size * sizeof(char)); ++ buf = OS_MALLOC(size * sizeof(char)); + + va_start(args, fmt); + returnsize = vsnprintf(buf, size, fmt, args); +@@ -388,7 +390,7 @@ + } + + string_buffer_append_string(sb, buf); +- free(buf); ++ OS_FREE(buf); + } + + void string_buffer_append_string(string_buffer_t *sb, const char *str) +@@ -400,7 +402,7 @@ + + while (sb->size+len + 1 >= sb->alloc) { + sb->alloc *= 2; +- sb->s = realloc(sb->s, sb->alloc); ++ sb->s = OS_REALLOC(sb->s, sb->alloc); + } + + memcpy(&sb->s[sb->size], str, len); +@@ -443,7 +445,7 @@ + { + assert(str != NULL); + +- string_feeder_t *sf = (string_feeder_t*) calloc(1, sizeof(string_feeder_t)); ++ string_feeder_t *sf = (string_feeder_t*) OS_CALLOC(1, sizeof(string_feeder_t)); + sf->s = strdup(str); + sf->len = strlen(sf->s); + sf->line = 1; +@@ -469,9 +471,9 @@ + if (sf == NULL) + return; + +- free(sf->s); ++ OS_FREE(sf->s); + memset(sf, 0, sizeof(string_feeder_t)); +- free(sf); ++ OS_FREE(sf); + } + + bool string_feeder_has_next(string_feeder_t *sf) +@@ -506,7 +508,7 @@ + if (sf->pos + length > sf->len) + length = sf->len - sf->pos; + +- char *substr = calloc(length+1, sizeof(char)); ++ char *substr = OS_CALLOC(length+1, sizeof(char)); + for (int i = 0 ; i < length ; i++) + substr[i] = string_feeder_next(sf); + return substr; +@@ -529,7 +531,7 @@ + if (sf->pos + length > sf->len) + length = sf->len - sf->pos; + +- char *substr = calloc(length+1, sizeof(char)); ++ char *substr = OS_CALLOC(length+1, sizeof(char)); + memcpy(substr, &sf->s[sf->pos], length*sizeof(char)); + return substr; + } +@@ -632,7 +634,7 @@ + endidx = (long) strlen(str); + + size_t blen = endidx - startidx; // not counting \0 +- char *b = malloc(blen + 1); ++ char *b = OS_MALLOC(blen + 1); + memcpy(b, &str[startidx], blen); + b[blen] = 0; + return b; +@@ -680,7 +682,7 @@ + + char *replacement = va_arg(ap, char*); + char *tmp = str_replace(haystack, needle, replacement); +- free(haystack); ++ OS_FREE(haystack); + haystack = tmp; + } + +@@ -695,26 +697,26 @@ + va_list ap; + + int salloc = 128; +- char *s = malloc(salloc); ++ char *s = OS_MALLOC(salloc); + + va_start(ap, fmt); + int slen = vsnprintf(s, salloc, fmt, ap); + va_end(ap); + + if (slen >= salloc) { +- s = realloc(s, slen + 1); ++ s = OS_REALLOC(s, slen + 1); + va_start(ap, fmt); + vsprintf((char*) s, fmt, ap); + va_end(ap); + } + +- buf = realloc(buf, *bufpos + slen + 1); ++ buf = OS_REALLOC(buf, *bufpos + slen + 1); + *_buf = buf; + + memcpy(&buf[*bufpos], s, slen + 1); // get trailing \0 + (*bufpos) += slen; + +- free(s); ++ OS_FREE(s); + } + + static int is_variable_character(char c) +@@ -764,7 +766,7 @@ + if (env) + buffer_appendf(&out, &outpos, "%s", env); + +- free(varname); ++ OS_FREE(varname); + } + } + +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile.h +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile.h 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile.h 2021-11-17 11:07:32.502776606 +0800 +@@ -53,7 +53,7 @@ + + static inline timeprofile_t *timeprofile_create() + { +- timeprofile_t *tp = (timeprofile_t*) calloc(1, sizeof(timeprofile_t)); ++ timeprofile_t *tp = (timeprofile_t*) OS_CALLOC(1, sizeof(timeprofile_t)); + tp->stamps = zarray_create(sizeof(struct timeprofile_entry)); + + tp->utime = utime_now(); +@@ -64,7 +64,7 @@ + static inline void timeprofile_destroy(timeprofile_t *tp) + { + zarray_destroy(tp->stamps); +- free(tp); ++ OS_FREE(tp); + } + + static inline void timeprofile_clear(timeprofile_t *tp) +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c 2021-11-17 11:07:32.502776606 +0800 +@@ -29,6 +29,8 @@ + #include + #include "time_util.h" + ++#include "port.h" ++ + struct timeutil_rest + { + int64_t acc_time; +@@ -37,13 +39,13 @@ + + timeutil_rest_t *timeutil_rest_create() + { +- timeutil_rest_t *rest = calloc(1, sizeof(timeutil_rest_t)); ++ timeutil_rest_t *rest = OS_CALLOC(1, sizeof(timeutil_rest_t)); + return rest; + } + + void timeutil_rest_destroy(timeutil_rest_t *rest) + { +- free(rest); ++ OS_FREE(rest); + } + + int64_t utime_now() // blacklist-ignore +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h 2021-11-17 11:07:32.502776606 +0800 +@@ -30,6 +30,7 @@ + #include + #include + ++#include "port.h" + typedef struct unionfind unionfind_t; + + struct unionfind +@@ -51,9 +52,9 @@ + + static inline unionfind_t *unionfind_create(uint32_t maxid) + { +- unionfind_t *uf = (unionfind_t*) calloc(1, sizeof(unionfind_t)); ++ unionfind_t *uf = (unionfind_t*) OS_CALLOC(1, sizeof(unionfind_t)); + uf->maxid = maxid; +- uf->data = (struct ufrec*) malloc((maxid+1) * sizeof(struct ufrec)); ++ uf->data = (struct ufrec*) OS_MALLOC((maxid+1) * sizeof(struct ufrec)); + for (int i = 0; i <= maxid; i++) { + uf->data[i].size = 1; + uf->data[i].parent = i; +@@ -63,8 +64,8 @@ + + static inline void unionfind_destroy(unionfind_t *uf) + { +- free(uf->data); +- free(uf); ++ OS_FREE(uf->data); ++ OS_FREE(uf); + } + + /* +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool.c 2021-11-17 11:07:32.502776606 +0800 +@@ -104,12 +104,12 @@ + { + assert(nthreads > 0); + +- workerpool_t *wp = calloc(1, sizeof(workerpool_t)); ++ workerpool_t *wp = OS_CALLOC(1, sizeof(workerpool_t)); + wp->nthreads = nthreads; + wp->tasks = zarray_create(sizeof(struct task)); + + if (nthreads > 1) { +- wp->threads = calloc(wp->nthreads, sizeof(pthread_t)); ++ wp->threads = OS_CALLOC(wp->nthreads, sizeof(pthread_t)); + + pthread_mutex_init(&wp->mutex, NULL); + pthread_cond_init(&wp->startcond, NULL); +@@ -147,11 +147,11 @@ + pthread_mutex_destroy(&wp->mutex); + pthread_cond_destroy(&wp->startcond); + pthread_cond_destroy(&wp->endcond); +- free(wp->threads); ++ OS_FREE(wp->threads); + } + + zarray_destroy(wp->tasks); +- free(wp); ++ OS_FREE(wp); + } + + int workerpool_get_nthreads(workerpool_t *wp) +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h 2021-11-17 11:07:32.502776606 +0800 +@@ -32,6 +32,8 @@ + #include + #include + ++#include "port.h" ++ + #ifdef __cplusplus + extern "C" { + #endif +@@ -58,7 +60,7 @@ + { + assert(el_sz > 0); + +- zarray_t *za = (zarray_t*) calloc(1, sizeof(zarray_t)); ++ zarray_t *za = (zarray_t*) OS_CALLOC(1, sizeof(zarray_t)); + za->el_sz = el_sz; + return za; + } +@@ -73,9 +75,9 @@ + return; + + if (za->data != NULL) +- free(za->data); ++ OS_FREE(za->data); + memset(za, 0, sizeof(zarray_t)); +- free(za); ++ OS_FREE(za); + } + + /** Allocate a new zarray that contains a copy of the data in the argument. **/ +@@ -83,11 +85,11 @@ + { + assert(za != NULL); + +- zarray_t *zb = (zarray_t*) calloc(1, sizeof(zarray_t)); ++ zarray_t *zb = (zarray_t*) OS_CALLOC(1, sizeof(zarray_t)); + zb->el_sz = za->el_sz; + zb->size = za->size; + zb->alloc = za->alloc; +- zb->data = (char*) malloc(zb->alloc * zb->el_sz); ++ zb->data = (char*) OS_MALLOC(zb->alloc * zb->el_sz); + memcpy(zb->data, za->data, za->size * za->el_sz); + return zb; + } +@@ -113,11 +115,11 @@ + int start_idx, + int end_idx_exclusive) + { +- zarray_t *out = (zarray_t*) calloc(1, sizeof(zarray_t)); ++ zarray_t *out = (zarray_t*) OS_CALLOC(1, sizeof(zarray_t)); + out->el_sz = za->el_sz; + out->size = end_idx_exclusive - start_idx; + out->alloc = iceillog2(out->size); // round up pow 2 +- out->data = (char*) malloc(out->alloc * out->el_sz); ++ out->data = (char*) OS_MALLOC(out->alloc * out->el_sz); + memcpy(out->data, za->data +(start_idx*out->el_sz), out->size*out->el_sz); + return out; + } +@@ -167,8 +169,7 @@ + if (za->alloc < 8) + za->alloc = 8; + } +- +- za->data = (char*) realloc(za->data, za->alloc * za->el_sz); ++ za->data = (char*) OS_REALLOC(za->data, za->alloc * za->el_sz); + } + + /** +@@ -449,14 +450,14 @@ + + // Don't allocate on stack because el_sz could be larger than ~8 MB + // stack size +- char *tmp = (char*)calloc(1, dest->el_sz); ++ char *tmp = (char*)OS_CALLOC(1, dest->el_sz); + + for (int i = 0; i < zarray_size(source); i++) { + zarray_get(source, i, tmp); + zarray_add(dest, tmp); + } + +- free(tmp); ++ OS_FREE(tmp); + } + + #ifdef __cplusplus +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c 2021-11-17 11:07:32.502776606 +0800 +@@ -32,6 +32,8 @@ + + #include "zhash.h" + ++#include "port.h" ++ + // force a rehash when our capacity is less than this many times the size + #define ZHASH_FACTOR_CRITICAL 2 + +@@ -74,7 +76,7 @@ + nentries *= 2; + } + +- zhash_t *zh = (zhash_t*) calloc(1, sizeof(zhash_t)); ++ zhash_t *zh = (zhash_t*) OS_CALLOC(1, sizeof(zhash_t)); + zh->keysz = keysz; + zh->valuesz = valuesz; + zh->hash = hash; +@@ -83,7 +85,7 @@ + + zh->entrysz = 1 + zh->keysz + zh->valuesz; + +- zh->entries = calloc(zh->nentries, zh->entrysz); ++ zh->entries = OS_CALLOC(zh->nentries, zh->entrysz); + zh->nentries = nentries; + + return zh; +@@ -100,8 +102,8 @@ + if (zh == NULL) + return; + +- free(zh->entries); +- free(zh); ++ OS_FREE(zh->entries); ++ OS_FREE(zh); + } + + int zhash_size(const zhash_t *zh) +@@ -225,14 +227,14 @@ + + if (zh->entries[entry_idx * zh->entrysz]) { + // completely remove this entry +- char *tmp = malloc(sizeof(char)*zh->entrysz); ++ char *tmp = OS_MALLOC(sizeof(char)*zh->entrysz); + memcpy(tmp, &zh->entries[entry_idx * zh->entrysz], zh->entrysz); + zh->entries[entry_idx * zh->entrysz] = 0; + zh->size--; + // reinsert it + if (zhash_put(zh, &tmp[1], &tmp[1+zh->keysz], NULL, NULL)) + assert(0); +- free(tmp); ++ OS_FREE(tmp); + } else { + break; + } +@@ -337,7 +339,7 @@ + int entry_idx = (zit->last_entry + 1) & (zh->nentries - 1); + while (zh->entries[entry_idx *zh->entrysz]) { + // completely remove this entry +- char *tmp = malloc(sizeof(char)*zh->entrysz); ++ char *tmp = OS_MALLOC(sizeof(char)*zh->entrysz); + memcpy(tmp, &zh->entries[entry_idx * zh->entrysz], zh->entrysz); + zh->entries[entry_idx * zh->entrysz] = 0; + zh->size--; +@@ -345,7 +347,7 @@ + // reinsert it + if (zhash_put(zh, &tmp[1], &tmp[1+zh->keysz], NULL, NULL)) + assert(0); +- free(tmp); ++ OS_FREE(tmp); + + entry_idx = (entry_idx + 1) & (zh->nentries - 1); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h 2021-11-17 11:07:32.502776606 +0800 +@@ -35,6 +35,7 @@ + + #include "zarray.h" + ++#include "port.h" + + /** + * A hash table for structs and primitive types that stores entries by value. +@@ -388,8 +389,8 @@ + { + char *oldkey, *oldval; + if (zhash_put(zh, &key, &value, &oldkey, &oldval)) { +- free(oldkey); +- free(oldval); ++ OS_FREE(oldkey); ++ OS_FREE(oldval); + } + } + +@@ -400,8 +401,8 @@ + + char *key, *value; + while (zhash_iterator_next(&zit, &key, &value)) { +- free(key); +- free(value); ++ OS_FREE(key); ++ OS_FREE(value); + } + + zhash_destroy(zh); +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c 2021-11-17 11:07:32.502776606 +0800 +@@ -34,6 +34,8 @@ + + #include "zmaxheap.h" + ++#include "port.h" ++ + #ifdef _WIN32 + static inline long int random(void) + { +@@ -72,11 +74,11 @@ + heap->values[a] = heap->values[b]; + heap->values[b] = t; + +- char *tmp = malloc(sizeof(char)*heap->el_sz); ++ char *tmp = OS_MALLOC(sizeof(char)*heap->el_sz); + memcpy(tmp, &heap->data[a*heap->el_sz], heap->el_sz); + memcpy(&heap->data[a*heap->el_sz], &heap->data[b*heap->el_sz], heap->el_sz); + memcpy(&heap->data[b*heap->el_sz], tmp, heap->el_sz); +- free(tmp); ++ OS_FREE(tmp); + } + + static inline void swap_pointer(zmaxheap_t *heap, int a, int b) +@@ -94,7 +96,7 @@ + + zmaxheap_t *zmaxheap_create(size_t el_sz) + { +- zmaxheap_t *heap = calloc(1, sizeof(zmaxheap_t)); ++ zmaxheap_t *heap = OS_CALLOC(1, sizeof(zmaxheap_t)); + heap->el_sz = el_sz; + + heap->swap = swap_default; +@@ -107,10 +109,10 @@ + + void zmaxheap_destroy(zmaxheap_t *heap) + { +- free(heap->values); +- free(heap->data); ++ OS_FREE(heap->values); ++ OS_FREE(heap->data); + memset(heap, 0, sizeof(zmaxheap_t)); +- free(heap); ++ OS_FREE(heap); + } + + int zmaxheap_size(zmaxheap_t *heap) +@@ -134,8 +136,8 @@ + newcap *= 2; + } + +- heap->values = realloc(heap->values, newcap * sizeof(float)); +- heap->data = realloc(heap->data, newcap * heap->el_sz); ++ heap->values = OS_REALLOC(heap->values, newcap * sizeof(float)); ++ heap->data = OS_REALLOC(heap->data, newcap * heap->el_sz); + heap->alloc = newcap; + } + +@@ -361,7 +363,7 @@ + { + int cap = 10000; + int sz = 0; +- int32_t *vals = calloc(sizeof(int32_t), cap); ++ int32_t *vals = OS_CALLOC(sizeof(int32_t), cap); + + zmaxheap_t *heap = zmaxheap_create(sizeof(int32_t)); + +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c 2021-11-17 11:07:32.498776572 +0800 +@@ -62,14 +62,14 @@ + }; + apriltag_family_t *tag16h5_create() + { +- apriltag_family_t *tf = calloc(1, sizeof(apriltag_family_t)); ++ apriltag_family_t *tf = OS_CALLOC(1, sizeof(apriltag_family_t)); + tf->name = strdup("tag16h5"); + tf->h = 5; + tf->ncodes = 30; + tf->codes = codedata; + tf->nbits = 16; +- tf->bit_x = calloc(16, sizeof(uint32_t)); +- tf->bit_y = calloc(16, sizeof(uint32_t)); ++ tf->bit_x = OS_CALLOC(16, sizeof(uint32_t)); ++ tf->bit_y = OS_CALLOC(16, sizeof(uint32_t)); + tf->bit_x[0] = 1; + tf->bit_y[0] = 1; + tf->bit_x[1] = 2; +@@ -110,8 +110,8 @@ + + void tag16h5_destroy(apriltag_family_t *tf) + { +- free(tf->bit_x); +- free(tf->bit_y); +- free(tf->name); +- free(tf); ++ OS_FREE(tf->bit_x); ++ OS_FREE(tf->bit_y); ++ OS_FREE(tf->name); ++ OS_FREE(tf); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c 2021-11-17 11:07:32.498776572 +0800 +@@ -67,14 +67,14 @@ + }; + apriltag_family_t *tag25h9_create() + { +- apriltag_family_t *tf = calloc(1, sizeof(apriltag_family_t)); ++ apriltag_family_t *tf = OS_CALLOC(1, sizeof(apriltag_family_t)); + tf->name = strdup("tag25h9"); + tf->h = 9; + tf->ncodes = 35; + tf->codes = codedata; + tf->nbits = 25; +- tf->bit_x = calloc(25, sizeof(uint32_t)); +- tf->bit_y = calloc(25, sizeof(uint32_t)); ++ tf->bit_x = OS_CALLOC(25, sizeof(uint32_t)); ++ tf->bit_y = OS_CALLOC(25, sizeof(uint32_t)); + tf->bit_x[0] = 1; + tf->bit_y[0] = 1; + tf->bit_x[1] = 2; +@@ -133,8 +133,8 @@ + + void tag25h9_destroy(apriltag_family_t *tf) + { +- free(tf->bit_x); +- free(tf->bit_y); +- free(tf->name); +- free(tf); ++ OS_FREE(tf->bit_x); ++ OS_FREE(tf->bit_y); ++ OS_FREE(tf->name); ++ OS_FREE(tf); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c 2021-11-17 11:07:32.498776572 +0800 +@@ -619,14 +619,14 @@ + }; + apriltag_family_t *tag36h11_create() + { +- apriltag_family_t *tf = calloc(1, sizeof(apriltag_family_t)); ++ apriltag_family_t *tf = OS_CALLOC(1, sizeof(apriltag_family_t)); + tf->name = strdup("tag36h11"); + tf->h = 11; + tf->ncodes = 587; + tf->codes = codedata; + tf->nbits = 36; +- tf->bit_x = calloc(36, sizeof(uint32_t)); +- tf->bit_y = calloc(36, sizeof(uint32_t)); ++ tf->bit_x = OS_CALLOC(36, sizeof(uint32_t)); ++ tf->bit_y = OS_CALLOC(36, sizeof(uint32_t)); + tf->bit_x[0] = 1; + tf->bit_y[0] = 1; + tf->bit_x[1] = 2; +@@ -707,8 +707,8 @@ + + void tag36h11_destroy(apriltag_family_t *tf) + { +- free(tf->bit_x); +- free(tf->bit_y); +- free(tf->name); +- free(tf); ++ OS_FREE(tf->bit_x); ++ OS_FREE(tf->bit_y); ++ OS_FREE(tf->name); ++ OS_FREE(tf); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c 2021-11-17 11:07:32.498776572 +0800 +@@ -70,14 +70,14 @@ + }; + apriltag_family_t *tagCircle21h7_create() + { +- apriltag_family_t *tf = calloc(1, sizeof(apriltag_family_t)); ++ apriltag_family_t *tf = OS_CALLOC(1, sizeof(apriltag_family_t)); + tf->name = strdup("tagCircle21h7"); + tf->h = 7; + tf->ncodes = 38; + tf->codes = codedata; + tf->nbits = 21; +- tf->bit_x = calloc(21, sizeof(uint32_t)); +- tf->bit_y = calloc(21, sizeof(uint32_t)); ++ tf->bit_x = OS_CALLOC(21, sizeof(uint32_t)); ++ tf->bit_y = OS_CALLOC(21, sizeof(uint32_t)); + tf->bit_x[0] = 1; + tf->bit_y[0] = -2; + tf->bit_x[1] = 2; +@@ -128,8 +128,8 @@ + + void tagCircle21h7_destroy(apriltag_family_t *tf) + { +- free(tf->bit_x); +- free(tf->bit_y); +- free(tf->name); +- free(tf); ++ OS_FREE(tf->bit_x); ++ OS_FREE(tf->bit_y); ++ OS_FREE(tf->name); ++ OS_FREE(tf); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c 2021-11-17 11:07:32.498776572 +0800 +@@ -65567,14 +65567,14 @@ + }; + apriltag_family_t *tagCircle49h12_create() + { +- apriltag_family_t *tf = calloc(1, sizeof(apriltag_family_t)); ++ apriltag_family_t *tf = OS_CALLOC(1, sizeof(apriltag_family_t)); + tf->name = strdup("tagCircle49h12"); + tf->h = 12; + tf->ncodes = 65535; + tf->codes = codedata; + tf->nbits = 49; +- tf->bit_x = calloc(49, sizeof(uint32_t)); +- tf->bit_y = calloc(49, sizeof(uint32_t)); ++ tf->bit_x = OS_CALLOC(49, sizeof(uint32_t)); ++ tf->bit_y = OS_CALLOC(49, sizeof(uint32_t)); + tf->bit_x[0] = 1; + tf->bit_y[0] = -3; + tf->bit_x[1] = 2; +@@ -65681,8 +65681,8 @@ + + void tagCircle49h12_destroy(apriltag_family_t *tf) + { +- free(tf->bit_x); +- free(tf->bit_y); +- free(tf->name); +- free(tf); ++ OS_FREE(tf->bit_x); ++ OS_FREE(tf->bit_y); ++ OS_FREE(tf->name); ++ OS_FREE(tf); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c 2021-11-17 11:07:32.502776606 +0800 +@@ -42243,14 +42243,14 @@ + }; + apriltag_family_t *tagCustom48h12_create() + { +- apriltag_family_t *tf = calloc(1, sizeof(apriltag_family_t)); ++ apriltag_family_t *tf = OS_CALLOC(1, sizeof(apriltag_family_t)); + tf->name = strdup("tagCustom48h12"); + tf->h = 12; + tf->ncodes = 42211; + tf->codes = codedata; + tf->nbits = 48; +- tf->bit_x = calloc(48, sizeof(uint32_t)); +- tf->bit_y = calloc(48, sizeof(uint32_t)); ++ tf->bit_x = OS_CALLOC(48, sizeof(uint32_t)); ++ tf->bit_y = OS_CALLOC(48, sizeof(uint32_t)); + tf->bit_x[0] = -2; + tf->bit_y[0] = -2; + tf->bit_x[1] = -1; +@@ -42355,8 +42355,8 @@ + + void tagCustom48h12_destroy(apriltag_family_t *tf) + { +- free(tf->bit_x); +- free(tf->bit_y); +- free(tf->name); +- free(tf); ++ OS_FREE(tf->bit_x); ++ OS_FREE(tf->bit_y); ++ OS_FREE(tf->name); ++ OS_FREE(tf); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c 2021-11-17 11:07:32.502776606 +0800 +@@ -2147,14 +2147,14 @@ + }; + apriltag_family_t *tagStandard41h12_create() + { +- apriltag_family_t *tf = calloc(1, sizeof(apriltag_family_t)); ++ apriltag_family_t *tf = OS_CALLOC(1, sizeof(apriltag_family_t)); + tf->name = strdup("tagStandard41h12"); + tf->h = 12; + tf->ncodes = 2115; + tf->codes = codedata; + tf->nbits = 41; +- tf->bit_x = calloc(41, sizeof(uint32_t)); +- tf->bit_y = calloc(41, sizeof(uint32_t)); ++ tf->bit_x = OS_CALLOC(41, sizeof(uint32_t)); ++ tf->bit_y = OS_CALLOC(41, sizeof(uint32_t)); + tf->bit_x[0] = -2; + tf->bit_y[0] = -2; + tf->bit_x[1] = -1; +@@ -2245,8 +2245,8 @@ + + void tagStandard41h12_destroy(apriltag_family_t *tf) + { +- free(tf->bit_x); +- free(tf->bit_y); +- free(tf->name); +- free(tf); ++ OS_FREE(tf->bit_x); ++ OS_FREE(tf->bit_y); ++ OS_FREE(tf->name); ++ OS_FREE(tf); + } +diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c +--- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c 2021-09-18 23:48:09.000000000 +0800 ++++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c 2021-11-17 11:07:32.502776606 +0800 +@@ -48746,14 +48746,14 @@ + }; + apriltag_family_t *tagStandard52h13_create() + { +- apriltag_family_t *tf = calloc(1, sizeof(apriltag_family_t)); ++ apriltag_family_t *tf = OS_CALLOC(1, sizeof(apriltag_family_t)); + tf->name = strdup("tagStandard52h13"); + tf->h = 13; + tf->ncodes = 48714; + tf->codes = codedata; + tf->nbits = 52; +- tf->bit_x = calloc(52, sizeof(uint32_t)); +- tf->bit_y = calloc(52, sizeof(uint32_t)); ++ tf->bit_x = OS_CALLOC(52, sizeof(uint32_t)); ++ tf->bit_y = OS_CALLOC(52, sizeof(uint32_t)); + tf->bit_x[0] = -2; + tf->bit_y[0] = -2; + tf->bit_x[1] = -1; +@@ -48866,8 +48866,8 @@ + + void tagStandard52h13_destroy(apriltag_family_t *tf) + { +- free(tf->bit_x); +- free(tf->bit_y); +- free(tf->name); +- free(tf); +-} ++ OS_FREE(tf->bit_x); ++ OS_FREE(tf->bit_y); ++ OS_FREE(tf->name); ++ OS_FREE(tf); ++} +\ 文件尾没有换行符 +diff -Nur a/LiteOS/targets/STM32F769IDISCOVERY/include/asm/memmap_config.h b/LiteOS/targets/STM32F769IDISCOVERY/include/asm/memmap_config.h +--- a/LiteOS/targets/STM32F769IDISCOVERY/include/asm/memmap_config.h 2021-11-04 10:59:06.000000000 +0800 ++++ b/LiteOS/targets/STM32F769IDISCOVERY/include/asm/memmap_config.h 2021-11-17 11:07:32.558777078 +0800 +@@ -40,6 +40,10 @@ + #define OS_SYS_MEM_ADDR (VOID *)(__LOS_HEAP_ADDR_START__) + #define OS_SYS_MEM_SIZE ((UINT32)(__LOS_HEAP_ADDR_END__ - __LOS_HEAP_ADDR_START__ + 1)) + ++extern char _ext_addr_start; ++extern char _ext_addr_end; ++#define OS_SYS_EXT_MEM_ADDR (VOID *)(&_ext_addr_start) ++#define OS_SYS_EXT_MEM_SIZE ((UINT32)((&_ext_addr_end) - (&_ext_addr_start) + 1)) + #ifdef __cplusplus + #if __cplusplus + } +diff -Nur a/LiteOS/targets/STM32F769IDISCOVERY/liteos.ld b/LiteOS/targets/STM32F769IDISCOVERY/liteos.ld +--- a/LiteOS/targets/STM32F769IDISCOVERY/liteos.ld 2021-11-04 10:59:06.000000000 +0800 ++++ b/LiteOS/targets/STM32F769IDISCOVERY/liteos.ld 2021-11-17 11:07:32.558777078 +0800 +@@ -45,7 +45,7 @@ + { + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K +-SDRAM (rw) : ORIGIN = 0xC0400000, LENGTH = 4M ++SDRAM (rw) : ORIGIN = 0xC0400000, LENGTH = 4M /* 0xC0800000 */ + } + + /* Define output sections */ +@@ -184,6 +184,14 @@ + __los_heap_addr_end__ = ORIGIN(RAM) + LENGTH(RAM) - _Min_Stack_Size - 1; + + __fast_end = .; ++ ++ . = ALIGN(8); ++ ._user_ext_heap_stack : ++ { ++ . = ALIGN(8); ++ _ext_addr_start = .; ++ _ext_addr_end = ORIGIN(SDRAM) + LENGTH(SDRAM) - 1; ++ } >SDRAM + /* Remove information from the standard libraries */ + /DISCARD/ : + { +diff -Nur a/LiteOS/targets/STM32F769IDISCOVERY/Src/main.c b/LiteOS/targets/STM32F769IDISCOVERY/Src/main.c +--- a/LiteOS/targets/STM32F769IDISCOVERY/Src/main.c 2021-11-04 10:59:06.000000000 +0800 ++++ b/LiteOS/targets/STM32F769IDISCOVERY/Src/main.c 2021-11-17 11:07:32.558777078 +0800 +@@ -82,6 +82,11 @@ + if (ret != LOS_OK) { + return LOS_NOK; + } ++ ret = LOS_MemInit((VOID *)OS_SYS_EXT_MEM_ADDR, OS_SYS_EXT_MEM_SIZE); ++ if (ret != LOS_OK) { ++ PRINT_ERR("Ext mem init err.\n"); ++ return ret; ++ } + + OsStart(); + diff --git a/components/utility/apriltag/patch.sha256 b/components/utility/apriltag/patch.sha256 new file mode 100644 index 0000000..0912024 --- /dev/null +++ b/components/utility/apriltag/patch.sha256 @@ -0,0 +1 @@ +bd4eb52874a0e81cefe5b048ba4ff52238305014842d0757b58d0f9c375af303 origin.patch -- Gitee From 72f6bc8c3fced0e63f8b70f1ac47f173c9a14ecb Mon Sep 17 00:00:00 2001 From: zhoulq1024 <1248471212@qq.com> Date: Wed, 17 Nov 2021 11:57:28 +0800 Subject: [PATCH 2/2] modify apriltag patch --- components/utility/apriltag/origin.patch | 230 +++++++++-------------- components/utility/apriltag/patch.sha256 | 2 +- 2 files changed, 88 insertions(+), 144 deletions(-) diff --git a/components/utility/apriltag/origin.patch b/components/utility/apriltag/origin.patch index 3864437..6a0ac7e 100644 --- a/components/utility/apriltag/origin.patch +++ b/components/utility/apriltag/origin.patch @@ -1,6 +1,6 @@ -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c 2021-11-17 11:07:32.498776572 +0800 +diff -Nur a/apriltag-3.1.7/apriltag.c b/apriltag-3.1.7/apriltag.c +--- a/apriltag-3.1.7/apriltag.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/apriltag.c 2021-11-17 11:52:43.351070562 +0800 @@ -54,6 +54,8 @@ #include "common/postscript_utils.h" @@ -144,9 +144,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag.c b/LiteO if (im_samples != NULL) { image_u8_write_pnm(im_samples, "debug_samples.pnm"); -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c 2021-11-17 11:07:32.498776572 +0800 +diff -Nur a/apriltag-3.1.7/apriltag_pose.c b/apriltag-3.1.7/apriltag_pose.c +--- a/apriltag-3.1.7/apriltag_pose.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/apriltag_pose.c 2021-11-17 11:52:43.351070562 +0800 @@ -6,6 +6,8 @@ #include "common/homography.h" #include "common/image_u8x3.h" @@ -253,9 +253,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_pose.c b/ matd_destroy(avg_F_trans); matd_destroy(G); -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thresh.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thresh.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thresh.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thresh.c 2021-11-17 11:07:32.498776572 +0800 +diff -Nur a/apriltag-3.1.7/apriltag_quad_thresh.c b/apriltag-3.1.7/apriltag_quad_thresh.c +--- a/apriltag-3.1.7/apriltag_quad_thresh.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/apriltag_quad_thresh.c 2021-11-17 11:52:43.351070562 +0800 @@ -44,6 +44,8 @@ #include "common/postscript_utils.h" #include "common/math_util.h" @@ -630,9 +630,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/apriltag_quad_thre image_u8x3_write_pnm(d, "debug_segmentation.pnm"); image_u8x3_destroy(d); -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_floats_impl.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_floats_impl.h ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_floats_impl.h 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_floats_impl.h 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/doubles_floats_impl.h b/apriltag-3.1.7/common/doubles_floats_impl.h +--- a/apriltag-3.1.7/common/doubles_floats_impl.h 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/doubles_floats_impl.h 2021-11-17 11:52:43.355070596 +0800 @@ -33,6 +33,8 @@ #include "matd.h" #include "math_util.h" @@ -665,9 +665,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/doubles_flo } static inline void TFN(s_mat_Ab)(const TNAME *A, int Arows, int Acols, -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/getopt.c b/apriltag-3.1.7/common/getopt.c +--- a/apriltag-3.1.7/common/getopt.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/getopt.c 2021-11-17 11:52:43.355070596 +0800 @@ -37,6 +37,8 @@ #include "getopt.h" #include "common/math_util.h" @@ -798,9 +798,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/getopt.c b/ } char * getopt_get_usage(getopt_t *gopt) -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/image_u8.c b/apriltag-3.1.7/common/image_u8.c +--- a/apriltag-3.1.7/common/image_u8.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/image_u8.c 2021-11-17 11:52:43.355070596 +0800 @@ -35,18 +35,20 @@ #include "common/pnm.h" #include "common/math_util.h" @@ -915,9 +915,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8.c } image_u8_t *image_u8_rotate(const image_u8_t *in, double rad, uint8_t pad) -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/image_u8x3.c b/apriltag-3.1.7/common/image_u8x3.c +--- a/apriltag-3.1.7/common/image_u8x3.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/image_u8x3.c 2021-11-17 11:52:43.355070596 +0800 @@ -36,6 +36,8 @@ #include "image_u8x3.h" @@ -1036,9 +1036,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x3. - free(k); + OS_FREE(k); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/image_u8x4.c b/apriltag-3.1.7/common/image_u8x4.c +--- a/apriltag-3.1.7/common/image_u8x4.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/image_u8x4.c 2021-11-17 11:52:43.355070596 +0800 @@ -34,6 +34,8 @@ #include "pnm.h" #include "image_u8x4.h" @@ -1089,9 +1089,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/image_u8x4. } //////////////////////////////////////////////////////////// -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/matd.c b/apriltag-3.1.7/common/matd.c +--- a/apriltag-3.1.7/common/matd.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/matd.c 2021-11-17 11:52:43.355070596 +0800 @@ -37,6 +37,8 @@ #include "common/svd22.h" #include "common/matd.h" @@ -1325,9 +1325,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/matd.c b/Li } // Solve: (U')x = b, U is upper triangular -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/pam.c b/apriltag-3.1.7/common/pam.c +--- a/apriltag-3.1.7/common/pam.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/pam.c 2021-11-17 11:52:43.355070596 +0800 @@ -32,6 +32,8 @@ #include "pam.h" @@ -1407,9 +1407,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pam.c b/Lit if (in->type == PAM_RGB) { assert(in->depth == 3); -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/pjpeg.c b/apriltag-3.1.7/common/pjpeg.c +--- a/apriltag-3.1.7/common/pjpeg.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/pjpeg.c 2021-11-17 11:52:43.355070596 +0800 @@ -36,6 +36,8 @@ #include "image_u8.h" #include "image_u8x3.h" @@ -1558,9 +1558,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pjpeg.c b/L return pj; } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/pnm.c b/apriltag-3.1.7/common/pnm.c +--- a/apriltag-3.1.7/common/pnm.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/pnm.c 2021-11-17 11:52:43.355070596 +0800 @@ -32,13 +32,15 @@ #include "pnm.h" @@ -1625,9 +1625,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/pnm.c b/Lit + OS_FREE(pnm->buf); + OS_FREE(pnm); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/string_util.c b/apriltag-3.1.7/common/string_util.c +--- a/apriltag-3.1.7/common/string_util.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/string_util.c 2021-11-17 11:52:43.355070596 +0800 @@ -36,6 +36,8 @@ #include "string_util.h" #include "zarray.h" @@ -1847,9 +1847,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/string_util } } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile.h ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile.h 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile.h 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/timeprofile.h b/apriltag-3.1.7/common/timeprofile.h +--- a/apriltag-3.1.7/common/timeprofile.h 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/timeprofile.h 2021-11-17 11:52:43.355070596 +0800 @@ -53,7 +53,7 @@ static inline timeprofile_t *timeprofile_create() @@ -1868,9 +1868,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/timeprofile } static inline void timeprofile_clear(timeprofile_t *tp) -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/time_util.c b/apriltag-3.1.7/common/time_util.c +--- a/apriltag-3.1.7/common/time_util.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/time_util.c 2021-11-17 11:52:43.355070596 +0800 @@ -29,6 +29,8 @@ #include #include "time_util.h" @@ -1896,9 +1896,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/time_util.c } int64_t utime_now() // blacklist-ignore -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/unionfind.h b/apriltag-3.1.7/common/unionfind.h +--- a/apriltag-3.1.7/common/unionfind.h 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/unionfind.h 2021-11-17 11:52:43.355070596 +0800 @@ -30,6 +30,7 @@ #include #include @@ -1930,9 +1930,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/unionfind.h } /* -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/workerpool.c b/apriltag-3.1.7/common/workerpool.c +--- a/apriltag-3.1.7/common/workerpool.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/workerpool.c 2021-11-17 11:52:43.355070596 +0800 @@ -104,12 +104,12 @@ { assert(nthreads > 0); @@ -1962,9 +1962,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/workerpool. } int workerpool_get_nthreads(workerpool_t *wp) -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/zarray.h b/apriltag-3.1.7/common/zarray.h +--- a/apriltag-3.1.7/common/zarray.h 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/zarray.h 2021-11-17 11:52:43.355070596 +0800 @@ -32,6 +32,8 @@ #include #include @@ -2050,9 +2050,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zarray.h b/ } #ifdef __cplusplus -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/zhash.c b/apriltag-3.1.7/common/zhash.c +--- a/apriltag-3.1.7/common/zhash.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/zhash.c 2021-11-17 11:52:43.355070596 +0800 @@ -32,6 +32,8 @@ #include "zhash.h" @@ -2126,9 +2126,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.c b/L entry_idx = (entry_idx + 1) & (zh->nentries - 1); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/zhash.h b/apriltag-3.1.7/common/zhash.h +--- a/apriltag-3.1.7/common/zhash.h 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/zhash.h 2021-11-17 11:52:43.355070596 +0800 @@ -35,6 +35,7 @@ #include "zarray.h" @@ -2159,9 +2159,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zhash.h b/L } zhash_destroy(zh); -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/common/zmaxheap.c b/apriltag-3.1.7/common/zmaxheap.c +--- a/apriltag-3.1.7/common/zmaxheap.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/common/zmaxheap.c 2021-11-17 11:52:43.355070596 +0800 @@ -34,6 +34,8 @@ #include "zmaxheap.h" @@ -2228,9 +2228,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/common/zmaxheap.c zmaxheap_t *heap = zmaxheap_create(sizeof(int32_t)); -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c 2021-11-17 11:07:32.498776572 +0800 +diff -Nur a/apriltag-3.1.7/tag16h5.c b/apriltag-3.1.7/tag16h5.c +--- a/apriltag-3.1.7/tag16h5.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/tag16h5.c 2021-11-17 11:52:43.351070562 +0800 @@ -62,14 +62,14 @@ }; apriltag_family_t *tag16h5_create() @@ -2262,9 +2262,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag16h5.c b/LiteOS + OS_FREE(tf->name); + OS_FREE(tf); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c 2021-11-17 11:07:32.498776572 +0800 +diff -Nur a/apriltag-3.1.7/tag25h9.c b/apriltag-3.1.7/tag25h9.c +--- a/apriltag-3.1.7/tag25h9.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/tag25h9.c 2021-11-17 11:52:43.351070562 +0800 @@ -67,14 +67,14 @@ }; apriltag_family_t *tag25h9_create() @@ -2296,9 +2296,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag25h9.c b/LiteOS + OS_FREE(tf->name); + OS_FREE(tf); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c 2021-11-17 11:07:32.498776572 +0800 +diff -Nur a/apriltag-3.1.7/tag36h11.c b/apriltag-3.1.7/tag36h11.c +--- a/apriltag-3.1.7/tag36h11.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/tag36h11.c 2021-11-17 11:52:43.351070562 +0800 @@ -619,14 +619,14 @@ }; apriltag_family_t *tag36h11_create() @@ -2330,9 +2330,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tag36h11.c b/LiteO + OS_FREE(tf->name); + OS_FREE(tf); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c 2021-11-17 11:07:32.498776572 +0800 +diff -Nur a/apriltag-3.1.7/tagCircle21h7.c b/apriltag-3.1.7/tagCircle21h7.c +--- a/apriltag-3.1.7/tagCircle21h7.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/tagCircle21h7.c 2021-11-17 11:52:43.351070562 +0800 @@ -70,14 +70,14 @@ }; apriltag_family_t *tagCircle21h7_create() @@ -2364,9 +2364,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle21h7.c b/ + OS_FREE(tf->name); + OS_FREE(tf); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c 2021-11-17 11:07:32.498776572 +0800 +diff -Nur a/apriltag-3.1.7/tagCircle49h12.c b/apriltag-3.1.7/tagCircle49h12.c +--- a/apriltag-3.1.7/tagCircle49h12.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/tagCircle49h12.c 2021-11-17 11:52:43.351070562 +0800 @@ -65567,14 +65567,14 @@ }; apriltag_family_t *tagCircle49h12_create() @@ -2398,9 +2398,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCircle49h12.c b + OS_FREE(tf->name); + OS_FREE(tf); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/tagCustom48h12.c b/apriltag-3.1.7/tagCustom48h12.c +--- a/apriltag-3.1.7/tagCustom48h12.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/tagCustom48h12.c 2021-11-17 11:52:43.351070562 +0800 @@ -42243,14 +42243,14 @@ }; apriltag_family_t *tagCustom48h12_create() @@ -2432,9 +2432,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagCustom48h12.c b + OS_FREE(tf->name); + OS_FREE(tf); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/tagStandard41h12.c b/apriltag-3.1.7/tagStandard41h12.c +--- a/apriltag-3.1.7/tagStandard41h12.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/tagStandard41h12.c 2021-11-17 11:52:43.351070562 +0800 @@ -2147,14 +2147,14 @@ }; apriltag_family_t *tagStandard41h12_create() @@ -2466,9 +2466,9 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard41h12.c + OS_FREE(tf->name); + OS_FREE(tf); } -diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c ---- a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c 2021-09-18 23:48:09.000000000 +0800 -+++ b/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c 2021-11-17 11:07:32.502776606 +0800 +diff -Nur a/apriltag-3.1.7/tagStandard52h13.c b/apriltag-3.1.7/tagStandard52h13.c +--- a/apriltag-3.1.7/tagStandard52h13.c 2021-11-17 11:53:05.143261227 +0800 ++++ b/apriltag-3.1.7/tagStandard52h13.c 2021-11-17 11:52:43.351070562 +0800 @@ -48746,14 +48746,14 @@ }; apriltag_family_t *tagStandard52h13_create() @@ -2502,59 +2502,3 @@ diff -Nur a/LiteOS/components/utility/apriltag/apriltag-3.1.7/tagStandard52h13.c + OS_FREE(tf); +} \ 文件尾没有换行符 -diff -Nur a/LiteOS/targets/STM32F769IDISCOVERY/include/asm/memmap_config.h b/LiteOS/targets/STM32F769IDISCOVERY/include/asm/memmap_config.h ---- a/LiteOS/targets/STM32F769IDISCOVERY/include/asm/memmap_config.h 2021-11-04 10:59:06.000000000 +0800 -+++ b/LiteOS/targets/STM32F769IDISCOVERY/include/asm/memmap_config.h 2021-11-17 11:07:32.558777078 +0800 -@@ -40,6 +40,10 @@ - #define OS_SYS_MEM_ADDR (VOID *)(__LOS_HEAP_ADDR_START__) - #define OS_SYS_MEM_SIZE ((UINT32)(__LOS_HEAP_ADDR_END__ - __LOS_HEAP_ADDR_START__ + 1)) - -+extern char _ext_addr_start; -+extern char _ext_addr_end; -+#define OS_SYS_EXT_MEM_ADDR (VOID *)(&_ext_addr_start) -+#define OS_SYS_EXT_MEM_SIZE ((UINT32)((&_ext_addr_end) - (&_ext_addr_start) + 1)) - #ifdef __cplusplus - #if __cplusplus - } -diff -Nur a/LiteOS/targets/STM32F769IDISCOVERY/liteos.ld b/LiteOS/targets/STM32F769IDISCOVERY/liteos.ld ---- a/LiteOS/targets/STM32F769IDISCOVERY/liteos.ld 2021-11-04 10:59:06.000000000 +0800 -+++ b/LiteOS/targets/STM32F769IDISCOVERY/liteos.ld 2021-11-17 11:07:32.558777078 +0800 -@@ -45,7 +45,7 @@ - { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K --SDRAM (rw) : ORIGIN = 0xC0400000, LENGTH = 4M -+SDRAM (rw) : ORIGIN = 0xC0400000, LENGTH = 4M /* 0xC0800000 */ - } - - /* Define output sections */ -@@ -184,6 +184,14 @@ - __los_heap_addr_end__ = ORIGIN(RAM) + LENGTH(RAM) - _Min_Stack_Size - 1; - - __fast_end = .; -+ -+ . = ALIGN(8); -+ ._user_ext_heap_stack : -+ { -+ . = ALIGN(8); -+ _ext_addr_start = .; -+ _ext_addr_end = ORIGIN(SDRAM) + LENGTH(SDRAM) - 1; -+ } >SDRAM - /* Remove information from the standard libraries */ - /DISCARD/ : - { -diff -Nur a/LiteOS/targets/STM32F769IDISCOVERY/Src/main.c b/LiteOS/targets/STM32F769IDISCOVERY/Src/main.c ---- a/LiteOS/targets/STM32F769IDISCOVERY/Src/main.c 2021-11-04 10:59:06.000000000 +0800 -+++ b/LiteOS/targets/STM32F769IDISCOVERY/Src/main.c 2021-11-17 11:07:32.558777078 +0800 -@@ -82,6 +82,11 @@ - if (ret != LOS_OK) { - return LOS_NOK; - } -+ ret = LOS_MemInit((VOID *)OS_SYS_EXT_MEM_ADDR, OS_SYS_EXT_MEM_SIZE); -+ if (ret != LOS_OK) { -+ PRINT_ERR("Ext mem init err.\n"); -+ return ret; -+ } - - OsStart(); - diff --git a/components/utility/apriltag/patch.sha256 b/components/utility/apriltag/patch.sha256 index 0912024..3618f03 100644 --- a/components/utility/apriltag/patch.sha256 +++ b/components/utility/apriltag/patch.sha256 @@ -1 +1 @@ -bd4eb52874a0e81cefe5b048ba4ff52238305014842d0757b58d0f9c375af303 origin.patch +741380eb76a28e3d8e91b10797bf2ef052c5f9a205df5e6f2ca4355679932a51 origin.patch -- Gitee