{"id":981,"date":"2023-07-07T17:55:59","date_gmt":"2023-07-07T09:55:59","guid":{"rendered":"https:\/\/nemo.cool\/?p=981"},"modified":"2024-11-26T15:14:23","modified_gmt":"2024-11-26T07:14:23","slug":"%e8%ae%be%e8%ae%a1%e6%9c%89%e7%bc%93%e5%ad%98%e5%bc%82%e6%ad%a5%e9%80%bb%e8%be%91%e7%9a%84%e7%9b%91%e6%8e%a7%e8%84%9a%e6%9c%ac%e5%b9%b6%e6%b5%8b%e8%af%95%e5%85%b6%e8%b5%84%e6%ba%90%e5%8d%a0%e7%94%a8","status":"publish","type":"post","link":"https:\/\/nemo.cool\/981.html","title":{"rendered":"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528"},"content":{"rendered":"<p>\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528<\/p>\n<p>\u63a5\u4e0a\u56de\uff1a<\/p>\n<div class=\"mdx-post-cot\" data-mdxposturl=\"https:\/\/nemo.cool\/973.html\"><div class=\"mdx-post-wait-out-c2\"><div class=\"mdx-post-wait-out-c mdui-valign\"><div class=\"mdx-github-wait-out\"><div class=\"mdx-github-wait\"><a href=\"https:\/\/nemo.cool\/973.html\"><div class=\"mdui-spinner\"><\/div><\/a><\/div><\/div><\/div><\/div><\/div>\n<h3>Buffer<\/h3>\n<p>\u6700\u5f00\u59cb\u7684\u60f3\u6cd5\u65e0\u6cd5\u6ee1\u8db3\u7f13\u5b58\u9700\u6c42\u4ee5\u53ca\u89c9\u5f97\u8d44\u6e90\u5360\u7528\u8fd8\u662f\u6709\u70b9\u591a\uff0c\u5c31\u91cd\u65b0\u8bbe\u60f3\u7a0b\u5e8f\u903b\u8f91\uff1a<\/p>\n<ul>\n<li>\u589e\u52a0\u7f13\u5b58<\/li>\n<li>\u5224\u65adARM\u53d1\u51fa\u7684\u5173\u673a\u6307\u4ee4\uff0c\u6700\u5927\u9650\u5ea6\u4fdd\u5b58\u65e5\u5fd7<\/li>\n<li>\u5b9e\u73b0\u8fd0\u884c\u3001\u6309\u5929\u3001\u5927\u5c0f\u6253\u5305\u65e5\u5fd7\u6587\u4ef6<\/li>\n<li>\u5f02\u6b65\u67b6\u6784<\/li>\n<\/ul>\n<p>\u4e3b\u8981\u76ee\u7684\u8fd8\u662f\u964d\u4f4eeMMC\u7684IO\u538b\u529b\uff0c\u63d0\u9ad8\u4f7f\u7528\u5bff\u547d<\/p>\n<blockquote>\n<p>eMMC\u82af\u7247\u7684\u8bfb\u5199\u901f\u5ea6\u548c\u5bff\u547d\u662f\u4f7f\u7528\u8fd9\u4e9b\u8bbe\u5907\u7684\u7528\u6237\u5173\u5fc3\u7684\u91cd\u8981\u53c2\u6570\u3002\u591a\u6b21\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u5bf9\u4e8eeMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u6709\u4e00\u5b9a\u7684\u5f71\u54cd\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u8c03\u7814\u8bf4\u660e\uff1a <\/p>\n<ol>\n<li>\u8bfb\u5199\u6b21\u6570\u9650\u5236 eMMC\u82af\u7247\u7684\u4e00\u4e2a\u91cd\u8981\u6027\u80fd\u6307\u6807\u662f\u64e6\u5199\u6b21\u6570\uff0c\u5373\u6bcf\u4e2a\u5b58\u50a8\u5355\u5143\u5728\u5931\u6548\u524d\u53ef\u4ee5\u627f\u53d7\u7684\u8bfb\u5199\u64cd\u4f5c\u6b21\u6570\u3002\u64e6\u5199\u6b21\u6570\u53d7\u5230\u5b58\u50a8\u5355\u5143\u7684\u7269\u7406\u7279\u6027\u9650\u5236\uff0c\u4e00\u822c\u5728\u51e0\u5343\u5230\u51e0\u5341\u4e07\u6b21\u4e4b\u95f4\u3002\u8fd9\u610f\u5473\u7740\u5728eMMC\u82af\u7247\u7684\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u4e2a\u5b58\u50a8\u5355\u5143\u7684\u8bfb\u5199\u6b21\u6570\u90fd\u9700\u8981\u5c3d\u53ef\u80fd\u5730\u5206\u644a\uff0c\u4ee5\u907f\u514d\u67d0\u4e9b\u5b58\u50a8\u5355\u5143\u8fc7\u65e9\u5931\u6548\u3002 <\/li>\n<li>\u8bfb\u5199\u5bff\u547d\u7684\u5f71\u54cd \u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u53ef\u4ee5\u51cf\u5c11\u82af\u7247\u7684\u8bfb\u5199\u6b21\u6570\u3002\u5bf9\u4e8eeMMC\u82af\u7247\uff0c\u8bfb\u5199\u64cd\u4f5c\u7684\u7c92\u5ea6\u662f\u9875\uff08page\uff09\uff0c\u800c\u64e6\u9664\u64cd\u4f5c\u7684\u7c92\u5ea6\u662f\u5757\uff08block\uff09\u3002\u5728\u6ca1\u6709\u5408\u5e76\u7684\u60c5\u51b5\u4e0b\uff0c\u591a\u6b21\u5c0fIO\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u5bf9\u591a\u4e2a\u5757\u8fdb\u884c\u64e6\u9664\u548c\u5199\u5165\uff0c\u4ece\u800c\u589e\u52a0\u82af\u7247\u7684\u8bfb\u5199\u6b21\u6570\u3002\u901a\u8fc7\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\uff0c\u53ef\u4ee5\u51cf\u5c11\u5bf9\u5757\u7684\u64e6\u9664\u548c\u5199\u5165\u6b21\u6570\uff0c\u4ece\u800c\u5ef6\u957f\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u3002 <\/li>\n<li>\u6027\u80fd\u4f18\u5316 \u9664\u4e86\u5bf9\u8bfb\u5199\u5bff\u547d\u7684\u5f71\u54cd\uff0c\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\u8fd8\u53ef\u4ee5\u63d0\u9ad8eMMC\u82af\u7247\u7684\u6027\u80fd\u3002\u968f\u673a\u8bfb\u5199\u64cd\u4f5c\u7684\u901f\u5ea6\u901a\u5e38\u4f4e\u4e8e\u987a\u5e8f\u8bfb\u5199\u64cd\u4f5c\uff0c\u56e0\u4e3a\u968f\u673a\u64cd\u4f5c\u9700\u8981\u5728\u591a\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u5bfb\u5740\u3002\u901a\u8fc7\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5c06\u968f\u673a\u64cd\u4f5c\u8f6c\u6362\u4e3a\u987a\u5e8f\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u9ad8\u82af\u7247\u7684\u8bfb\u5199\u901f\u5ea6\u3002 4. Wear Leveling\u6280\u672f \u4e3a\u4e86\u5ef6\u957feMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\uff0c\u82af\u7247\u63a7\u5236\u5668\u901a\u5e38\u4f1a\u91c7\u7528\u4e00\u79cd\u79f0\u4e3aWear Leveling\u7684\u6280\u672f\u3002Wear Leveling\u53ef\u4ee5\u5c06\u64e6\u9664\u548c\u5199\u5165\u64cd\u4f5c\u5728\u6574\u4e2a\u82af\u7247\u7684\u5b58\u50a8\u5355\u5143\u4e0a\u5747\u5300\u5206\u5e03\uff0c\u4ece\u800c\u907f\u514d\u67d0\u4e9b\u5b58\u50a8\u5355\u5143\u8fc7\u65e9\u5931\u6548\u3002\u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u53ef\u4ee5\u964d\u4f4eWear Leveling\u7b97\u6cd5\u7684\u590d\u6742\u6027\uff0c\u63d0\u9ad8\u5176\u6548\u679c\u3002 \u7efc\u4e0a\u6240\u8ff0\uff0c\u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u5bf9eMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u6709\u79ef\u6781\u5f71\u54cd\u3002\u8fd9\u79cd\u64cd\u4f5c\u65b9\u5f0f\u53ef\u4ee5\u964d\u4f4e\u64e6\u9664\u548c\u5199\u5165\u6b21\u6570\uff0c\u63d0\u9ad8\u82af\u7247\u7684\u6027\u80fd\uff0c\u5e76\u6709\u5229\u4e8eWear Leveling\u6280\u672f\u7684\u5b9e\u73b0\u3002\u5f53\u7136\uff0c\u8fd9\u79cd\u4f18\u5316\u9700\u8981\u5728\u4fdd\u8bc1\u6570\u636e\u5b8c\u6574\u6027\u548c\u5b9e\u65f6\u6027\u7684\u524d\u63d0\u4e0b<\/li>\n<\/ol>\n<p>\u53c2\u8003\u6587\u732e\uff1a<\/p>\n<ol>\n<li>\n<p>Micheloni, R., Crippa, L., &amp; Marelli, A. (2010). Inside NAND Flash Memories. Springer Science &amp; Business Media.<\/p>\n<\/li>\n<li>\n<p>Grupp, L. M., Davis, J. D., &amp; Swanson, S. (2012). The bleak future of NAND flash memory. In 10th {USENIX} Conference on File and Storage Technologies ({FAST} 12).<\/p>\n<\/li>\n<\/ol>\n<\/blockquote>\n<p>\u6839\u636e\u8fd9\u4e9b\u7406\u8bba\u4f9d\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u51fa\u7ed3\u8bba\uff1a\u5728\u5904\u7406\u4e32\u53e3\u6570\u636e\u65f6\uff0c\u4f7f\u7528\u7f13\u51b2\u533a\uff08buf\uff09\u5148\u5b58\u50a8\u6570\u636e\uff0c\u7136\u540e\u518d\u8fdb\u884c\u6279\u91cf\u5199\u5165\u7684\u65b9\u5f0f\uff0c\u76f8\u6bd4\u4e8e\u6536\u5230\u6570\u636e\u540e\u7acb\u5373\u5199\u5165\uff0c\u66f4\u6709\u5229\u4e8e\u5ef6\u957feMMC\u82af\u7247\u7684\u5bff\u547d\u3002<\/p>\n<p>\u91cd\u65b0\u8bbe\u8ba1\u540e\u7684\u4f2a\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">import os\nimport zipfile\nimport asyncio\nimport serial_asyncio\nimport configparser\nfrom datetime import datetime, timedelta\nimport re\nimport logging\nfrom logging.handlers import TimedRotatingFileHandler\nimport traceback\n\nShutDownFlag = &quot;AGV Key Shutdown&quot;\n\n# pre-compile regex\nre_printable_ascii = re.compile(r&#039;[^\\x20-\\x7E]+&#039;)\nre_log_file_suffix = re.compile(r&quot;^\\d{4}-\\d{2}-\\d{2}.log$&quot;)\n\n# read config file\nconfig = configparser.ConfigParser()\nconfig.read(&quot;\/etc\/xx.ini&quot;, encoding=&quot;utf-8&quot;)\n\n# read serial config\nserialPort = config.get(&quot;SERIAL_INFO&quot;, &quot;serialPort&quot;)\nserialBaudrate = config.getint(&quot;SERIAL_INFO&quot;, &quot;serialBaudrate&quot;)\nserialDatabits = config.getint(&quot;SERIAL_INFO&quot;, &quot;serialDatabits&quot;)\nserialStopbits = config.getint(&quot;SERIAL_INFO&quot;, &quot;serialStopbits&quot;)\nserialTimeout = config.getint(&quot;SERIAL_INFO&quot;, &quot;serialTimeout&quot;)\n\n# read log config\nlogPath = config.get(&quot;LOG_INFO&quot;, &quot;logPath&quot;)\nlogRetention = config.get(&quot;LOG_INFO&quot;, &quot;logRetention&quot;)\nlogRotaSize = config.get(&quot;LOG_INFO&quot;, &quot;logRotaSize&quot;)\nlogRotaTime = config.get(&quot;LOG_INFO&quot;, &quot;logRotaTime&quot;)\nlogCompression = config.get(&quot;LOG_INFO&quot;, &quot;logCompression&quot;)\nlogEncoding = config.get(&quot;LOG_INFO&quot;, &quot;logEncoding&quot;)\n\n# get log retention days\nlog_retention_days = int(&#039;&#039;.join(filter(str.isdigit, logRetention)))\n\nBUFFER_SIZE = xx  # Set buffer size according to your requirement\nlog_buffer = []\n\n# Configure logging\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.INFO)\n\n# Create log file handler with rotation\nfile_handler = TimedRotatingFileHandler(\n    logPath, when=&#039;midnight&#039;, backupCount=log_retention_days, delay=True)\nfile_handler.setFormatter(logging.Formatter(&#039;%(message)s&#039;))\n# Set the log file suffix to include the date\nfile_handler.suffix = &quot;%Y-%m-%d.log&quot;\n# Match log files with the correct suffix\nfile_handler.extMatch = re_log_file_suffix\n\n# Set the handler to append mode\nfile_handler.mode = &#039;a&#039;\n\nlogger.addHandler(file_handler)\n\nRSDEXCEPTION = None\nRUNEXCEPTION = None\nZIP_EXCEPTION = None\n\nasync def handle_serial_data(reader, writer):\n    global RSDEXCEPTION, log_buffer, BUFFER_SIZE\n\n    while True:\n        try:\n            ...\n            if byte_data and len(byte_data) &gt; 3:\n               ..\n                # Keep only printable ASCII characters\n                ...\n\n                # Get the current time when the data is received\n                ..\n\n                # Add log with timestamp to buffer\n                ...\n\n                if ShutDownFlag in str_data: # if agv shutdown, then shutdown this program\n                    BUFFER_SIZE = 1\n\n                # If buffer reaches its limit, write logs to file and reset buffer\n                if len(log_buffer) &gt;= BUFFER_SIZE:\n                    await write_log(log_buffer)\n                    log_buffer = []  # Reset the buffer after writing logs\n            else:\n                pass\n\n        except Exception as e:\n            if e != RSDEXCEPTION:\n                logger.error(&quot;Receive SerialData error: {0}&quot;, type(e).__name__)\n                RSDEXCEPTION = e\n            elif e == RSDEXCEPTION:\n                print(&quot;dump!&quot;, e)\n\n            await write_log(log_buffer)  # Write logs to file before exiting\n\n        else:\n            RSDEXCEPTION = None\n\n        # Ensure that logs in the buffer are written to the file before the function exits\n        finally:\n            pass\n\ndef write_log_sync(log_buffer):\n    logs_to_write = &#039;\\n&#039;.join(log_buffer)\n    logger.info(logs_to_write)\n\n    # Flush the logger to ensure logs are written to the file\n    logger.handlers[0].flush()\n\nasync def write_log(log_buffer):\n    loop = asyncio.get_event_loop()\n    await loop.run_in_executor(None, write_log_sync, log_buffer)\n\nasync def zip_log_file():\n    global ZIP_EXCEPTION\n    while True:\n        try:\n            ...\n            if os.path.exists(logPath) and os.path.getsize(logPath) &gt; 0:\n               ..\n                with zipfile.ZipFile(zip_name, &#039;w&#039;, zipfile.ZIP_DEFLATED) as zf:\n                    zf.write(logPath, arcname=os.path.basename(logPath))\n\n                os.remove(logPath)\n        except Exception as e:\n            if e != ZIP_EXCEPTION:\n                logger.error(&quot;zip_log_file error: {0}&quot;, type(e).__name__)\n                print(&quot;zip_log_file error: {0}&quot;, type(e).__name__)\n                ZIP_EXCEPTION = e\n        else:\n            ZIP_EXCEPTION = None\n\nasync def main():\n    # Check if log file exists and is not empty, zip and remove it before starting the program\n    if os.path.exists(logPath) and os.path.getsize(logPath) &gt; 0:\n        ..\n\n        with zipfile.ZipFile(zip_name, &#039;w&#039;, zipfile.ZIP_DEFLATED) as zf:\n            zf.write(logPath, arcname=os.path.basename(logPath))\n\n        os.remove(logPath)\n\n    global RUNEXCEPTION\n\n    try:\n        loop = asyncio.get_event_loop()\n        reader, writer = await serial_asyncio.open_serial_connection(\n            loop=loop, url=serialPort, baudrate=serialBaudrate\n        )\n\n    except Exception:\n        exc = traceback.format_exc()\n        if exc != RUNEXCEPTION:\n            logger.error(&quot;main error: {0}&quot;, exc)\n            RUNEXCEPTION = exc\n        return\n    else:\n        RUNEXCEPTION = None\n\n    try:\n        asyncio.create_task(zip_log_file())\n        await handle_serial_data(reader, writer)\n    finally:\n        writer.close()\n        await writer.wait_closed()\n\nif __name__ == &#039;__main__&#039;:\n    try:\n        asyncio.run(main())\n    except Exception as e:\n        logger.exception(&quot;main error!&quot;, type(e).__name__)\n<\/code><\/pre>\n<p>\u5173\u4e8e\u5f02\u6b65\u903b\u8f91\u7684\u4f7f\u7528\uff0c\u9700\u8981\u6839\u636e\uff1a<\/p>\n<ol>\n<li><strong>I\/O \u5bc6\u96c6\u578b\u64cd\u4f5c<\/strong>\uff1a\u5f02\u6b65\u7f16\u7a0b\u7279\u522b\u9002\u7528\u4e8e I\/O \u5bc6\u96c6\u578b\u4efb\u52a1\uff0c\u5982\u7f51\u7edc\u8bf7\u6c42\u3001\u6587\u4ef6\u8bfb\u5199\u7b49\u3002\u5728\u8fd9\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f02\u6b65\u7f16\u7a0b\u53ef\u4ee5\u907f\u514d\u963b\u585e\u4e3b\u7ebf\u7a0b\uff0c\u4ece\u800c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u54cd\u5e94\u901f\u5ea6\u3002<\/li>\n<li><strong>\u5e76\u53d1<\/strong>\uff1a\u5982\u679c\u7a0b\u5e8f\u9700\u8981\u540c\u65f6\u5904\u7406\u591a\u4e2a\u4efb\u52a1\uff0c\u5f02\u6b65\u7f16\u7a0b\u53ef\u4ee5\u5b9e\u73b0\u4efb\u52a1\u4e4b\u95f4\u7684\u5e76\u53d1\u6267\u884c\u3002\u8fd9\u53ef\u4ee5\u5728\u4e0d\u589e\u52a0\u989d\u5916\u7ebf\u7a0b\u5f00\u9500\u7684\u60c5\u51b5\u4e0b\uff0c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u541e\u5410\u91cf\u3002<\/li>\n<li><strong>\u53ef\u6269\u5c55\u6027<\/strong>\uff1a\u5f02\u6b65\u7f16\u7a0b\u5728\u5904\u7406\u5927\u91cf\u8bf7\u6c42\u65f6\u6709\u66f4\u597d\u7684\u53ef\u6269\u5c55\u6027\u3002\u4e0e\u591a\u7ebf\u7a0b\u76f8\u6bd4\uff0c\u5f02\u6b65\u7f16\u7a0b\u901a\u5e38\u4f7f\u7528\u66f4\u5c11\u7684\u7cfb\u7edf\u8d44\u6e90\uff08\u5982\u5185\u5b58\u3001\u7ebf\u7a0b\u7b49\uff09\uff0c\u56e0\u6b64\u5728\u8d44\u6e90\u6709\u9650\u7684\u73af\u5883\u4e2d\u4f1a\u66f4\u52a0\u9ad8\u6548\u3002<\/li>\n<li><strong>\u54cd\u5e94\u6027<\/strong>\uff1a\u5bf9\u4e8e\u9700\u8981\u5feb\u901f\u54cd\u5e94\u7528\u6237\u64cd\u4f5c\u6216\u5176\u4ed6\u4e8b\u4ef6\u7684\u7a0b\u5e8f\uff0c\u5f02\u6b65\u7f16\u7a0b\u53ef\u4ee5\u5e2e\u52a9\u4fdd\u6301\u7a0b\u5e8f\u7684\u54cd\u5e94\u6027\u3002\u901a\u8fc7\u907f\u514d\u963b\u585e\u4e3b\u7ebf\u7a0b\uff0c\u5f02\u6b65\u7f16\u7a0b\u786e\u4fdd\u7a0b\u5e8f\u80fd\u591f\u5728\u5904\u7406\u8017\u65f6\u64cd\u4f5c\u65f6\u4ecd\u7136\u5bf9\u7528\u6237\u64cd\u4f5c\u505a\u51fa\u53ca\u65f6\u54cd\u5e94\u3002<\/li>\n<li><strong>\u4efb\u52a1\u4f9d\u8d56\u5173\u7cfb<\/strong>\uff1a\u5f02\u6b65\u7f16\u7a0b\u5728\u5904\u7406\u5177\u6709\u590d\u6742\u4f9d\u8d56\u5173\u7cfb\u7684\u4efb\u52a1\u65f6\u5177\u6709\u4f18\u52bf\u3002\u901a\u8fc7\u4f7f\u7528 <code>asyncio<\/code> \u7b49\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ec4\u7ec7\u548c\u7f16\u6392\u4efb\u52a1\uff0c\u786e\u4fdd\u5b83\u4eec\u6309\u7167\u6b63\u786e\u7684\u987a\u5e8f\u548c\u4f18\u5148\u7ea7\u6267\u884c\u3002<\/li>\n<\/ol>\n<h3>\u8d44\u6e90\u5360\u7528\u76d1\u63a7<\/h3>\n<p>\u4e3a\u4e86\u6d4b\u8bd5\u65b0\u65b9\u6848\u7684\u6548\u679c\uff0c\u4f7f\u7528<code>psutil<\/code>\u83b7\u53d6\u7cfb\u7edf\u8d44\u6e90\u6570\u636e\u6bd4\u8f83\u4e24\u8005\u5dee\u522b\uff0c<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">import time\nfrom datetime import datetime\nimport psutil\nimport csv\n\n# Interval in seconds\nINTERVAL = 5\n\n# Output file\nOUTPUT_FILE = &quot;xx.csv&quot;\nSUMMARY_FILE = &quot;xx.csv&quot;\n\n# Number of top processes to display\nNUM_PROCESSES = 7\n\n# Write header to the output file\nwith open(OUTPUT_FILE, &quot;w&quot;, newline=&quot;&quot;) as f:\n    csv_writer = csv.writer(f)\n    csv_writer.writerow([&quot;Timestamp&quot;, &quot;PID&quot;, &quot;Process Name&quot;, &quot;Read Bytes (B)&quot;, &quot;Write Bytes (B)&quot;, &quot;CPU Time (s)&quot;, &quot;RAM Usage (B)&quot;, &quot;Open Files&quot;, &quot;Read Count&quot;, &quot;Write Count&quot;])\n\nprev_io_data = {}\ntotal_io_data = {}\n\ntry:\n    while True:\n        # Get a list of all running processes\n        processes = [proc for proc in psutil.process_iter()]\n\n        # Get I\/O and CPU data for each process and store it in a list\n        process_io_data = []\n        for process in processes:\n            try:\n                io_data = process.io_counters()\n                read_bytes = io_data.read_bytes\n                write_bytes = io_data.write_bytes\n                read_count = io_data.read_count\n                write_count = io_data.write_count\n                process_path = process.exe()\n                process_cmdline = &quot; &quot;.join(process.cmdline())\n\n                cpu_time = process.cpu_times().user + process.cpu_times().system\n\n                # Calculate the difference in read and write bytes and counts from last interval\n                if process.pid in prev_io_data:\n                    prev_read_bytes, prev_write_bytes, prev_cpu_time, prev_read_count, prev_write_count = prev_io_data[process.pid]\n                    read_bytes_diff = read_bytes - prev_read_bytes\n                    write_bytes_diff = write_bytes - prev_write_bytes\n                    read_count_diff = read_count - prev_read_count\n                    write_count_diff = write_count - prev_write_count\n                    cpu_time_diff = cpu_time - prev_cpu_time\n                else:\n                    read_bytes_diff = read_bytes\n                    write_bytes_diff = write_bytes\n                    read_count_diff = read_count\n                    write_count_diff = write_count\n                    cpu_time_diff = cpu_time\n\n                prev_io_data[process.pid] = (read_bytes, write_bytes, cpu_time, read_count, write_count)\n\n                # Get RAM usage (resident set size) for the process\n                ram_usage = process.memory_info().rss\n\n                # Get the list of open files for the process\n                open_files = process.open_files()\n                open_files_list = [open_file.path for open_file in open_files]\n\n                process_io_data.append((process.pid, process_cmdline, read_bytes_diff, write_bytes_diff, cpu_time_diff, ram_usage, open_files_list, read_count_diff, write_count_diff))\n\n                # Update the total I\/O data\n                if process.pid in total_io_data:\n                    process_name, total_read_bytes, total_write_bytes, total_cpu_time = total_io_data[process.pid]\n                    total_read_bytes += read_bytes_diff\n                    total_write_bytes += write_bytes_diff\n                    total_cpu_time += cpu_time_diff\n                else:\n                    process_name = process_cmdline\n                    total_read_bytes = read_bytes_diff\n                    total_write_bytes = write_bytes_diff\n                    total_cpu_time = cpu_time_diff\n\n                total_io_data[process.pid] = (process_name, total_read_bytes, total_write_bytes, total_cpu_time)\n\n            except (psutil.AccessDenied, psutil.NoSuchProcess):\n                pass\n\n        # Sort the list by total I\/O (read + write) in descending order\n        process_io_data.sort(key=lambda x: x[2] + x[3], reverse=True)\n\n        # Get the top I\/O processes\n        top_io_processes = process_io_data[:NUM_PROCESSES]\n\n        # Get the current timestamp\n        timestamp = datetime.now().strftime(&quot;%Y-%m-%d %H:%M:%S&quot;)\n\n        # Append the top I\/O processes data to OUTPUT_FILE\n        with open(OUTPUT_FILE, &quot;a&quot;, newline=&quot;&quot;) as f:\n            csv_writer = csv.writer(f)\n            for proc in top_io_processes:\n                csv_writer.writerow([timestamp, proc[0], proc[1], proc[2], proc[3], proc[4], proc[5], &quot;, &quot;.join(proc[6]), proc[7], proc[8]])\n\n        # Wait for the specified interval\n        time.sleep(INTERVAL)\nexcept KeyboardInterrupt:\n    # Sort the total I\/O data by total I\/O (read + write) in descending order\n    sorted_total_io_data = sorted(total_io_data.items(), key=lambda x: x[1][1]+ x[1][2], reverse=True)\n\n    # Write the summary to SUMMARY_FILE\n    with open(SUMMARY_FILE, &quot;w&quot;, newline=&quot;&quot;) as f:\n        csv_writer = csv.writer(f)\n        csv_writer.writerow([&quot;PID&quot;, &quot;Process Name&quot;, &quot;Total Read Bytes (B)&quot;, &quot;Total Write Bytes (B)&quot;, &quot;Total CPU Time (s)&quot;])\n        for proc in sorted_total_io_data:\n            csv_writer.writerow([proc[0], proc[1][0], proc[1][1], proc[1][2], proc[1][3]])<\/code><\/pre>\n<p>\u6839\u636ecsv\u6587\u4ef6\u7ed8\u5236\u66f2\u7ebf\u56fe\u76f4\u89c2\u6bd4\u8f83\uff1a<\/p>\n<pre><code class=\"language-python\">import pandas as pd\nimport matplotlib.pyplot as plt\nimport sys\nfrom datetime import datetime\nfrom dateutil import parser\n\ndef parse_log(file_path):\n    data = pd.read_csv(file_path)\n    data[&#039;Timestamp&#039;] = pd.to_datetime(data[&#039;Timestamp&#039;])\n    return data\n\ndef find_shortest_period(df1, df2):\n    start1, end1 = df1[&#039;Timestamp&#039;].min(), df1[&#039;Timestamp&#039;].max()\n    start2, end2 = df2[&#039;Timestamp&#039;].min(), df2[&#039;Timestamp&#039;].max()\n\n    if start1 &lt; start2:\n        common_start = start2\n    else:\n        common_start = start1\n\n    if end1 &lt; end2:\n        common_end = end1\n    else:\n        common_end = end2\n\n    return common_start, common_end\n\ndef compare_logs(log1, log2, pid1, pid2):\n    df1 = parse_log(log1)\n    df2 = parse_log(log2)\n\n    process_name1 = df1[df1[&#039;PID&#039;] == pid1][&#039;Process Name&#039;].iloc[0]\n    process_name2 = df2[df2[&#039;PID&#039;] == pid2][&#039;Process Name&#039;].iloc[0]\n\n    df1 = df1[df1[&#039;PID&#039;] == pid1].reset_index(drop=True)\n    df2 = df2[df2[&#039;PID&#039;] == pid2].reset_index(drop=True)\n\n    # Determine the longest period\n    maxlen = min(len(df1), len(df2))\n\n    # Pad the shorter dataframe with NaNs\n    if len(df1) &lt; maxlen:\n        df1 = df1.reindex(range(maxlen))\n    elif len(df2) &lt; maxlen:\n        df2 = df2.reindex(range(maxlen))\n\n    # Replace NaNs with zeros\n    df1.fillna(0, inplace=True)\n    df2.fillna(0, inplace=True)\n\n    # Remove rows where both data points are zero\n    mask = (df1[&#039;Write Bytes (B)&#039;] != 0) | (df2[&#039;Write Bytes (B)&#039;] != 0) | (df1[&#039;CPU Time (s)&#039;] != 0) | (df2[&#039;CPU Time (s)&#039;] != 0)\n    df1 = df1[mask]\n    df2 = df2[mask]\n\n    # Plotting\n    fig, (ax1, ax2, ax3,ax4,ax5) = plt.subplots(5, 1, figsize=(10, 15))\n\n    # Plot Write Bytes (B)\n    ax1.plot(df1.index, df1[&#039;Write Bytes (B)&#039;], label=f&quot;{process_name1} - PID {pid1}&quot;, color=&#039;b&#039;)\n    ax1.plot(df2.index, df2[&#039;Write Bytes (B)&#039;], label=f&quot;{process_name2} - PID {pid2}&quot;, color=&#039;r&#039;)\n    ax1.set_xlabel(&#039;Count&#039;)\n    ax1.set_ylabel(&#039;Write Bytes (B)&#039;)\n    ax1.legend()\n\n    # Plot Write Count\n    ax2.plot(df1.index, df1[&#039;Write Count&#039;], label=f&quot;{process_name1} - PID {pid1}&quot;, color=&#039;b&#039;)\n    ax2.plot(df2.index, df2[&#039;Write Count&#039;], label=f&quot;{process_name2} - PID {pid2}&quot;, color=&#039;r&#039;)\n    ax2.set_xlabel(&#039;Count&#039;)\n    ax2.set_ylabel(&#039;Write Count&#039;)\n    ax2.legend()\n\n    # Plot RAM Usage (B)\n    ax3.plot(df1.index, df1[&#039;RAM Usage (B)&#039;], label=f&quot;{process_name1} - PID {pid1}&quot;, color=&#039;b&#039;)\n    ax3.plot(df2.index, df2[&#039;RAM Usage (B)&#039;], label=f&quot;{process_name2} - PID {pid2}&quot;, color=&#039;r&#039;)\n    ax3.set_xlabel(&#039;Count&#039;)\n    ax3.set_ylabel(&#039;RAM Usage (B)&#039;)\n    ax3.legend()\n\n    # Plot CPU Usage\n    ax4.plot(df1.index, df1[&#039;CPU Time (s)&#039;], label=f&quot;{process_name1} - PID {pid1}&quot;, color=&#039;b&#039;)\n    ax4.plot(df2.index, df2[&#039;CPU Time (s)&#039;], label=f&quot;{process_name2} - PID {pid2}&quot;, color=&#039;r&#039;)\n    ax4.set_xlabel(&#039;Count&#039;)\n    ax4.set_ylabel(&#039;CPU Time (s)&#039;)\n    ax4.legend()\n\n    # Plot RAM Usage (B)\n    ax5.plot(df1.index, df1[&#039;RAM Usage (B)&#039;], label=f&quot;{process_name1} - PID {pid1}&quot;, color=&#039;b&#039;)\n    ax5.plot(df2.index, df2[&#039;RAM Usage (B)&#039;], label=f&quot;{process_name2} - PID {pid2}&quot;, color=&#039;r&#039;)\n    ax5.set_xlabel(&#039;Count&#039;)\n    ax5.set_ylabel(&#039;RAM Usage (B)&#039;)\n    ax5.legend()\n\n    plt.show()\n\n    # Calculate IO and CPU pressure\n    df1[&#039;IO Pressure&#039;] = df1[&#039;Write Bytes (B)&#039;]\n    df2[&#039;IO Pressure&#039;] = df2[&#039;Write Bytes (B)&#039;]\n\n    io_pressure_diff = df1[&#039;IO Pressure&#039;].sum() - df2[&#039;IO Pressure&#039;].sum()\n    cpu_usage_diff = df1[&#039;CPU Time (s)&#039;].sum() - df2[&#039;CPU Time (s)&#039;].sum()\n\n    # Generate report\n    report = f&quot;&quot;&quot;Report for comparing IO and CPU usage between {log1} (PID {pid1}) and {log2} (PID {pid2}):\n\nCharts:\n1. Write Bytes (B): Shows the Write Bytes (B) for each process during the same period.\n   Y-axis: Write Bytes (B)\n\n2. CPU Usage: Displays the CPU usage for each process during the same period.\n   Y-axis: CPU Usage (in CPU Time (s))\n\nPlease refer to the displayed charts for a visual comparison.\n\nResults:\n- IO Pressure Difference: {io_pressure_diff}\n  (Positive value means {log1} has more IO pressure, Negative value means {log2} has more IO pressure)\n\n- CPU Usage Difference: {cpu_usage_diff}\n  (Positive value means {log1} has higher CPU usage, Negative value means {log2} has higher CPU usage)\n&quot;&quot;&quot;\n    print(report)\n\nif __name__ == &#039;__main__&#039;:\n    log1 = &quot;xx.csv&quot;\n    log2 = &quot;xx.csv&quot;\n    pid1 = xx\n    pid2 = xx\n    compare_logs(log1, log2, pid1, pid2)<\/code><\/pre>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/kanghaov-img-1256185664.cos.ap-shanghai.myqcloud.com\/2023\/07\/07\/c375763c37100.png\" alt=\"Figure_1.png\" \/><\/p>\n<p>\u53ef\u4ee5\u5f88\u76f4\u89c2\u7684\u770b\u5230\u5728\u7f13\u5b58\u8bbe\u7f6e\u4e3a5\u7684\u60c5\u51b5\u4e0b\uff0c\u660e\u663e\u964d\u4f4eIO\u8bfb\u5199\u6b21\u6570\uff0c\u540c\u65f6\u5185\u5b58\u53caCPU\u5360\u7528\u4e5f\u4f18\u4e8e\u4f7f\u7528<code>loguru<\/code>\uff0c\u540c\u65f6\u5728\u63a5\u6536\u673a\u5668\u4eba\u5173\u673a\u4fe1\u53f7\u80fd\u591f\u53ca\u65f6\u4fdd\u5b58\u7f13\u5b58\u4e2d\u7684\u65e5\u5fd7\uff0c\u6ee1\u8db3\u9884\u671f\u3002<\/p>\n<p>~<\/p>\n<p>(\u8d81\u7740\u4e0b\u73ed\u524d\u4e00\u5c0f\u65f6\u603b\u7ed3\u7684~ \u732a\u8089\u672b\u4e00\u5757)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 \u63a5\u4e0a\u56de\uff1a Buffer \u6700\u5f00\u59cb\u7684\u60f3\u6cd5\u65e0\u6cd5\u6ee1\u8db3\u7f13\u5b58\u9700\u6c42\u4ee5\u53ca\u89c9\u5f97\u8d44\u6e90\u5360\u7528\u8fd8\u662f\u6709\u70b9\u591a\uff0c\u5c31\u91cd\u65b0\u8bbe\u60f3\u7a0b\u5e8f\u903b\u8f91\uff1a \u589e\u52a0\u7f13\u5b58 \u5224\u65adARM\u53d1\u51fa\u7684\u5173\u673a\u6307\u4ee4\uff0c\u6700\u5927\u9650\u5ea6\u4fdd\u5b58\u65e5\u5fd7 \u5b9e\u73b0\u8fd0\u884c\u3001\u6309\u5929\u3001\u5927\u5c0f\u6253\u5305\u65e5\u5fd7\u6587\u4ef6 \u5f02\u6b65\u67b6\u6784 \u4e3b\u8981\u76ee\u7684\u8fd8\u662f\u964d\u4f4eeMMC\u7684IO\u538b\u529b\uff0c\u63d0\u9ad8\u4f7f\u7528\u5bff\u547d eMMC\u82af\u7247\u7684\u8bfb\u5199\u901f\u5ea6\u548c\u5bff\u547d\u662f\u4f7f\u7528\u8fd9\u4e9b\u8bbe\u5907\u7684\u7528\u6237\u5173\u5fc3\u7684\u91cd\u8981\u53c2\u6570\u3002\u591a\u6b21\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u5bf9\u4e8eeMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u6709\u4e00\u5b9a\u7684\u5f71\u54cd\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u8c03\u7814\u8bf4\u660e\uff1a \u8bfb\u5199\u6b21\u6570\u9650\u5236 eMMC\u82af\u7247\u7684\u4e00\u4e2a\u91cd\u8981\u6027\u80fd\u6307\u6807\u662f\u64e6\u5199\u6b21\u6570\uff0c\u5373\u6bcf\u4e2a\u5b58\u50a8\u5355\u5143\u5728\u5931\u6548\u524d\u53ef\u4ee5\u627f\u53d7\u7684\u8bfb\u5199\u64cd\u4f5c\u6b21\u6570\u3002\u64e6\u5199\u6b21\u6570\u53d7\u5230\u5b58\u50a8\u5355\u5143\u7684\u7269\u7406\u7279\u6027\u9650\u5236\uff0c\u4e00\u822c\u5728\u51e0\u5343\u5230\u51e0\u5341\u4e07\u6b21\u4e4b\u95f4\u3002\u8fd9\u610f\u5473\u7740\u5728eMMC\u82af\u7247\u7684\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u4e2a\u5b58\u50a8\u5355\u5143\u7684\u8bfb\u5199\u6b21\u6570\u90fd\u9700\u8981\u5c3d\u53ef\u80fd\u5730\u5206\u644a\uff0c\u4ee5\u907f\u514d\u67d0\u4e9b\u5b58\u50a8\u5355\u5143\u8fc7\u65e9\u5931\u6548\u3002 \u8bfb\u5199\u5bff\u547d\u7684\u5f71\u54cd \u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u53ef\u4ee5\u51cf\u5c11\u82af\u7247\u7684\u8bfb\u5199\u6b21\u6570\u3002\u5bf9\u4e8eeMMC\u82af\u7247\uff0c\u8bfb\u5199\u64cd\u4f5c\u7684\u7c92\u5ea6\u662f\u9875\uff08page\uff09\uff0c\u800c\u64e6\u9664\u64cd\u4f5c\u7684\u7c92\u5ea6\u662f\u5757\uff08block\uff09\u3002\u5728\u6ca1\u6709\u5408\u5e76\u7684\u60c5\u51b5\u4e0b\uff0c\u591a\u6b21\u5c0fIO\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u5bf9\u591a\u4e2a\u5757\u8fdb\u884c\u64e6\u9664\u548c\u5199\u5165\uff0c\u4ece\u800c\u589e\u52a0\u82af\u7247\u7684\u8bfb\u5199\u6b21\u6570\u3002\u901a\u8fc7\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\uff0c\u53ef\u4ee5\u51cf\u5c11\u5bf9\u5757\u7684\u64e6\u9664\u548c\u5199\u5165\u6b21\u6570\uff0c\u4ece\u800c\u5ef6\u957f\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u3002 \u6027\u80fd\u4f18\u5316 \u9664\u4e86\u5bf9\u8bfb\u5199\u5bff\u547d\u7684\u5f71\u54cd\uff0c\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\u8fd8\u53ef\u4ee5\u63d0\u9ad8eMMC\u82af\u7247\u7684\u6027\u80fd\u3002\u968f\u673a\u8bfb\u5199\u64cd\u4f5c\u7684\u901f\u5ea6\u901a\u5e38\u4f4e\u4e8e\u987a\u5e8f\u8bfb\u5199\u64cd\u4f5c\uff0c\u56e0\u4e3a\u968f\u673a\u64cd\u4f5c\u9700\u8981\u5728\u591a\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u5bfb\u5740\u3002\u901a\u8fc7\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5c06\u968f\u673a\u64cd\u4f5c\u8f6c\u6362\u4e3a\u987a\u5e8f\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u9ad8\u82af\u7247\u7684\u8bfb\u5199\u901f\u5ea6\u3002 4. Wear Leveling\u6280\u672f \u4e3a\u4e86\u5ef6\u957feMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\uff0c\u82af\u7247\u63a7\u5236\u5668\u901a\u5e38\u4f1a\u91c7\u7528\u4e00\u79cd\u79f0\u4e3aWear Leveling\u7684\u6280\u672f\u3002Wear Leveling\u53ef\u4ee5\u5c06\u64e6\u9664\u548c\u5199\u5165\u64cd\u4f5c\u5728\u6574\u4e2a\u82af\u7247\u7684\u5b58\u50a8\u5355\u5143\u4e0a\u5747\u5300\u5206\u5e03\uff0c\u4ece\u800c\u907f\u514d\u67d0\u4e9b\u5b58\u50a8\u5355\u5143\u8fc7\u65e9\u5931\u6548\u3002\u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u53ef\u4ee5\u964d\u4f4eWear Leveling\u7b97\u6cd5\u7684\u590d\u6742\u6027\uff0c\u63d0\u9ad8\u5176\u6548\u679c\u3002 \u7efc\u4e0a\u6240\u8ff0\uff0c\u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u5bf9eMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u6709\u79ef\u6781\u5f71\u54cd\u3002\u8fd9\u79cd\u64cd\u4f5c\u65b9\u5f0f\u53ef\u4ee5\u964d\u4f4e\u64e6\u9664\u548c\u5199\u5165\u6b21\u6570\uff0c\u63d0\u9ad8\u82af\u7247\u7684\u6027\u80fd\uff0c\u5e76\u6709\u5229\u4e8eWear Leveling\u6280\u672f\u7684\u5b9e\u73b0\u3002\u5f53\u7136\uff0c\u8fd9\u79cd\u4f18\u5316\u9700\u8981\u5728\u4fdd\u8bc1\u6570\u636e\u5b8c\u6574\u6027\u548c\u5b9e\u65f6\u6027\u7684\u524d\u63d0\u4e0b \u53c2\u8003\u6587\u732e\uff1a Micheloni, R., Crippa, L., &amp; Marelli, A. (2010). Inside NAND Flash Memories. Springer Science &amp; Business Media. Grupp, L. M., Davis, J. D., &amp; Swanson, S. (2012). The bleak [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1025,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86,2,7],"tags":[79,102,18,10,116,98,130],"class_list":["post-981","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","category-py","category-robot","tag-agv","tag-amr","tag-matplotlib","tag-python","tag-116","tag-98","tag-130"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 - Nemo<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nemo.cool\/981.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 - Nemo\" \/>\n<meta property=\"og:description\" content=\"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 \u63a5\u4e0a\u56de\uff1a Buffer \u6700\u5f00\u59cb\u7684\u60f3\u6cd5\u65e0\u6cd5\u6ee1\u8db3\u7f13\u5b58\u9700\u6c42\u4ee5\u53ca\u89c9\u5f97\u8d44\u6e90\u5360\u7528\u8fd8\u662f\u6709\u70b9\u591a\uff0c\u5c31\u91cd\u65b0\u8bbe\u60f3\u7a0b\u5e8f\u903b\u8f91\uff1a \u589e\u52a0\u7f13\u5b58 \u5224\u65adARM\u53d1\u51fa\u7684\u5173\u673a\u6307\u4ee4\uff0c\u6700\u5927\u9650\u5ea6\u4fdd\u5b58\u65e5\u5fd7 \u5b9e\u73b0\u8fd0\u884c\u3001\u6309\u5929\u3001\u5927\u5c0f\u6253\u5305\u65e5\u5fd7\u6587\u4ef6 \u5f02\u6b65\u67b6\u6784 \u4e3b\u8981\u76ee\u7684\u8fd8\u662f\u964d\u4f4eeMMC\u7684IO\u538b\u529b\uff0c\u63d0\u9ad8\u4f7f\u7528\u5bff\u547d eMMC\u82af\u7247\u7684\u8bfb\u5199\u901f\u5ea6\u548c\u5bff\u547d\u662f\u4f7f\u7528\u8fd9\u4e9b\u8bbe\u5907\u7684\u7528\u6237\u5173\u5fc3\u7684\u91cd\u8981\u53c2\u6570\u3002\u591a\u6b21\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u5bf9\u4e8eeMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u6709\u4e00\u5b9a\u7684\u5f71\u54cd\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u8c03\u7814\u8bf4\u660e\uff1a \u8bfb\u5199\u6b21\u6570\u9650\u5236 eMMC\u82af\u7247\u7684\u4e00\u4e2a\u91cd\u8981\u6027\u80fd\u6307\u6807\u662f\u64e6\u5199\u6b21\u6570\uff0c\u5373\u6bcf\u4e2a\u5b58\u50a8\u5355\u5143\u5728\u5931\u6548\u524d\u53ef\u4ee5\u627f\u53d7\u7684\u8bfb\u5199\u64cd\u4f5c\u6b21\u6570\u3002\u64e6\u5199\u6b21\u6570\u53d7\u5230\u5b58\u50a8\u5355\u5143\u7684\u7269\u7406\u7279\u6027\u9650\u5236\uff0c\u4e00\u822c\u5728\u51e0\u5343\u5230\u51e0\u5341\u4e07\u6b21\u4e4b\u95f4\u3002\u8fd9\u610f\u5473\u7740\u5728eMMC\u82af\u7247\u7684\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u4e2a\u5b58\u50a8\u5355\u5143\u7684\u8bfb\u5199\u6b21\u6570\u90fd\u9700\u8981\u5c3d\u53ef\u80fd\u5730\u5206\u644a\uff0c\u4ee5\u907f\u514d\u67d0\u4e9b\u5b58\u50a8\u5355\u5143\u8fc7\u65e9\u5931\u6548\u3002 \u8bfb\u5199\u5bff\u547d\u7684\u5f71\u54cd \u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u53ef\u4ee5\u51cf\u5c11\u82af\u7247\u7684\u8bfb\u5199\u6b21\u6570\u3002\u5bf9\u4e8eeMMC\u82af\u7247\uff0c\u8bfb\u5199\u64cd\u4f5c\u7684\u7c92\u5ea6\u662f\u9875\uff08page\uff09\uff0c\u800c\u64e6\u9664\u64cd\u4f5c\u7684\u7c92\u5ea6\u662f\u5757\uff08block\uff09\u3002\u5728\u6ca1\u6709\u5408\u5e76\u7684\u60c5\u51b5\u4e0b\uff0c\u591a\u6b21\u5c0fIO\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u5bf9\u591a\u4e2a\u5757\u8fdb\u884c\u64e6\u9664\u548c\u5199\u5165\uff0c\u4ece\u800c\u589e\u52a0\u82af\u7247\u7684\u8bfb\u5199\u6b21\u6570\u3002\u901a\u8fc7\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\uff0c\u53ef\u4ee5\u51cf\u5c11\u5bf9\u5757\u7684\u64e6\u9664\u548c\u5199\u5165\u6b21\u6570\uff0c\u4ece\u800c\u5ef6\u957f\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u3002 \u6027\u80fd\u4f18\u5316 \u9664\u4e86\u5bf9\u8bfb\u5199\u5bff\u547d\u7684\u5f71\u54cd\uff0c\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\u8fd8\u53ef\u4ee5\u63d0\u9ad8eMMC\u82af\u7247\u7684\u6027\u80fd\u3002\u968f\u673a\u8bfb\u5199\u64cd\u4f5c\u7684\u901f\u5ea6\u901a\u5e38\u4f4e\u4e8e\u987a\u5e8f\u8bfb\u5199\u64cd\u4f5c\uff0c\u56e0\u4e3a\u968f\u673a\u64cd\u4f5c\u9700\u8981\u5728\u591a\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u5bfb\u5740\u3002\u901a\u8fc7\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5c06\u968f\u673a\u64cd\u4f5c\u8f6c\u6362\u4e3a\u987a\u5e8f\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u9ad8\u82af\u7247\u7684\u8bfb\u5199\u901f\u5ea6\u3002 4. Wear Leveling\u6280\u672f \u4e3a\u4e86\u5ef6\u957feMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\uff0c\u82af\u7247\u63a7\u5236\u5668\u901a\u5e38\u4f1a\u91c7\u7528\u4e00\u79cd\u79f0\u4e3aWear Leveling\u7684\u6280\u672f\u3002Wear Leveling\u53ef\u4ee5\u5c06\u64e6\u9664\u548c\u5199\u5165\u64cd\u4f5c\u5728\u6574\u4e2a\u82af\u7247\u7684\u5b58\u50a8\u5355\u5143\u4e0a\u5747\u5300\u5206\u5e03\uff0c\u4ece\u800c\u907f\u514d\u67d0\u4e9b\u5b58\u50a8\u5355\u5143\u8fc7\u65e9\u5931\u6548\u3002\u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u53ef\u4ee5\u964d\u4f4eWear Leveling\u7b97\u6cd5\u7684\u590d\u6742\u6027\uff0c\u63d0\u9ad8\u5176\u6548\u679c\u3002 \u7efc\u4e0a\u6240\u8ff0\uff0c\u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u5bf9eMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u6709\u79ef\u6781\u5f71\u54cd\u3002\u8fd9\u79cd\u64cd\u4f5c\u65b9\u5f0f\u53ef\u4ee5\u964d\u4f4e\u64e6\u9664\u548c\u5199\u5165\u6b21\u6570\uff0c\u63d0\u9ad8\u82af\u7247\u7684\u6027\u80fd\uff0c\u5e76\u6709\u5229\u4e8eWear Leveling\u6280\u672f\u7684\u5b9e\u73b0\u3002\u5f53\u7136\uff0c\u8fd9\u79cd\u4f18\u5316\u9700\u8981\u5728\u4fdd\u8bc1\u6570\u636e\u5b8c\u6574\u6027\u548c\u5b9e\u65f6\u6027\u7684\u524d\u63d0\u4e0b \u53c2\u8003\u6587\u732e\uff1a Micheloni, R., Crippa, L., &amp; Marelli, A. (2010). Inside NAND Flash Memories. Springer Science &amp; Business Media. Grupp, L. M., Davis, J. D., &amp; Swanson, S. (2012). The bleak [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nemo.cool\/981.html\" \/>\n<meta property=\"og:site_name\" content=\"Nemo\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-07T09:55:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-26T07:14:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/nemo.cool\/wp-content\/uploads\/2023\/07\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nemo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nemo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html\"},\"author\":{\"name\":\"Nemo\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/#\\\/schema\\\/person\\\/698f803ee811e2b140a90f5d5de913d2\"},\"headline\":\"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\",\"datePublished\":\"2023-07-07T09:55:59+00:00\",\"dateModified\":\"2024-11-26T07:14:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html\"},\"wordCount\":95,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/#\\\/schema\\\/person\\\/698f803ee811e2b140a90f5d5de913d2\"},\"image\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png\",\"keywords\":[\"agv\",\"amr\",\"Matplotlib\",\"python\",\"\u4f18\u5316\",\"\u6027\u80fd\",\"\u72b6\u6001\u673a\"],\"articleSection\":[\"Dev\",\"Python\",\"Robot\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nemo.cool\\\/981.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html\",\"url\":\"https:\\\/\\\/nemo.cool\\\/981.html\",\"name\":\"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 - Nemo\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png\",\"datePublished\":\"2023-07-07T09:55:59+00:00\",\"dateModified\":\"2024-11-26T07:14:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nemo.cool\\\/981.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html#primaryimage\",\"url\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png\",\"contentUrl\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png\",\"width\":1024,\"height\":1024},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/981.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/nemo.cool\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/#website\",\"url\":\"https:\\\/\\\/nemo.cool\\\/\",\"name\":\"Nemo\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/#\\\/schema\\\/person\\\/698f803ee811e2b140a90f5d5de913d2\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nemo.cool\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/nemo.cool\\\/#\\\/schema\\\/person\\\/698f803ee811e2b140a90f5d5de913d2\",\"name\":\"Nemo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg\",\"url\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg\",\"caption\":\"Nemo\"},\"logo\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg\"},\"sameAs\":[\"https:\\\/\\\/nemo.cool\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 - Nemo","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nemo.cool\/981.html","og_locale":"en_US","og_type":"article","og_title":"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 - Nemo","og_description":"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 \u63a5\u4e0a\u56de\uff1a Buffer \u6700\u5f00\u59cb\u7684\u60f3\u6cd5\u65e0\u6cd5\u6ee1\u8db3\u7f13\u5b58\u9700\u6c42\u4ee5\u53ca\u89c9\u5f97\u8d44\u6e90\u5360\u7528\u8fd8\u662f\u6709\u70b9\u591a\uff0c\u5c31\u91cd\u65b0\u8bbe\u60f3\u7a0b\u5e8f\u903b\u8f91\uff1a \u589e\u52a0\u7f13\u5b58 \u5224\u65adARM\u53d1\u51fa\u7684\u5173\u673a\u6307\u4ee4\uff0c\u6700\u5927\u9650\u5ea6\u4fdd\u5b58\u65e5\u5fd7 \u5b9e\u73b0\u8fd0\u884c\u3001\u6309\u5929\u3001\u5927\u5c0f\u6253\u5305\u65e5\u5fd7\u6587\u4ef6 \u5f02\u6b65\u67b6\u6784 \u4e3b\u8981\u76ee\u7684\u8fd8\u662f\u964d\u4f4eeMMC\u7684IO\u538b\u529b\uff0c\u63d0\u9ad8\u4f7f\u7528\u5bff\u547d eMMC\u82af\u7247\u7684\u8bfb\u5199\u901f\u5ea6\u548c\u5bff\u547d\u662f\u4f7f\u7528\u8fd9\u4e9b\u8bbe\u5907\u7684\u7528\u6237\u5173\u5fc3\u7684\u91cd\u8981\u53c2\u6570\u3002\u591a\u6b21\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u5bf9\u4e8eeMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u6709\u4e00\u5b9a\u7684\u5f71\u54cd\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u8c03\u7814\u8bf4\u660e\uff1a \u8bfb\u5199\u6b21\u6570\u9650\u5236 eMMC\u82af\u7247\u7684\u4e00\u4e2a\u91cd\u8981\u6027\u80fd\u6307\u6807\u662f\u64e6\u5199\u6b21\u6570\uff0c\u5373\u6bcf\u4e2a\u5b58\u50a8\u5355\u5143\u5728\u5931\u6548\u524d\u53ef\u4ee5\u627f\u53d7\u7684\u8bfb\u5199\u64cd\u4f5c\u6b21\u6570\u3002\u64e6\u5199\u6b21\u6570\u53d7\u5230\u5b58\u50a8\u5355\u5143\u7684\u7269\u7406\u7279\u6027\u9650\u5236\uff0c\u4e00\u822c\u5728\u51e0\u5343\u5230\u51e0\u5341\u4e07\u6b21\u4e4b\u95f4\u3002\u8fd9\u610f\u5473\u7740\u5728eMMC\u82af\u7247\u7684\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u4e2a\u5b58\u50a8\u5355\u5143\u7684\u8bfb\u5199\u6b21\u6570\u90fd\u9700\u8981\u5c3d\u53ef\u80fd\u5730\u5206\u644a\uff0c\u4ee5\u907f\u514d\u67d0\u4e9b\u5b58\u50a8\u5355\u5143\u8fc7\u65e9\u5931\u6548\u3002 \u8bfb\u5199\u5bff\u547d\u7684\u5f71\u54cd \u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u53ef\u4ee5\u51cf\u5c11\u82af\u7247\u7684\u8bfb\u5199\u6b21\u6570\u3002\u5bf9\u4e8eeMMC\u82af\u7247\uff0c\u8bfb\u5199\u64cd\u4f5c\u7684\u7c92\u5ea6\u662f\u9875\uff08page\uff09\uff0c\u800c\u64e6\u9664\u64cd\u4f5c\u7684\u7c92\u5ea6\u662f\u5757\uff08block\uff09\u3002\u5728\u6ca1\u6709\u5408\u5e76\u7684\u60c5\u51b5\u4e0b\uff0c\u591a\u6b21\u5c0fIO\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u5bf9\u591a\u4e2a\u5757\u8fdb\u884c\u64e6\u9664\u548c\u5199\u5165\uff0c\u4ece\u800c\u589e\u52a0\u82af\u7247\u7684\u8bfb\u5199\u6b21\u6570\u3002\u901a\u8fc7\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\uff0c\u53ef\u4ee5\u51cf\u5c11\u5bf9\u5757\u7684\u64e6\u9664\u548c\u5199\u5165\u6b21\u6570\uff0c\u4ece\u800c\u5ef6\u957f\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u3002 \u6027\u80fd\u4f18\u5316 \u9664\u4e86\u5bf9\u8bfb\u5199\u5bff\u547d\u7684\u5f71\u54cd\uff0c\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\u8fd8\u53ef\u4ee5\u63d0\u9ad8eMMC\u82af\u7247\u7684\u6027\u80fd\u3002\u968f\u673a\u8bfb\u5199\u64cd\u4f5c\u7684\u901f\u5ea6\u901a\u5e38\u4f4e\u4e8e\u987a\u5e8f\u8bfb\u5199\u64cd\u4f5c\uff0c\u56e0\u4e3a\u968f\u673a\u64cd\u4f5c\u9700\u8981\u5728\u591a\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u5bfb\u5740\u3002\u901a\u8fc7\u5408\u5e76\u591a\u6b21\u5c0fIO\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5c06\u968f\u673a\u64cd\u4f5c\u8f6c\u6362\u4e3a\u987a\u5e8f\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u9ad8\u82af\u7247\u7684\u8bfb\u5199\u901f\u5ea6\u3002 4. Wear Leveling\u6280\u672f \u4e3a\u4e86\u5ef6\u957feMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\uff0c\u82af\u7247\u63a7\u5236\u5668\u901a\u5e38\u4f1a\u91c7\u7528\u4e00\u79cd\u79f0\u4e3aWear Leveling\u7684\u6280\u672f\u3002Wear Leveling\u53ef\u4ee5\u5c06\u64e6\u9664\u548c\u5199\u5165\u64cd\u4f5c\u5728\u6574\u4e2a\u82af\u7247\u7684\u5b58\u50a8\u5355\u5143\u4e0a\u5747\u5300\u5206\u5e03\uff0c\u4ece\u800c\u907f\u514d\u67d0\u4e9b\u5b58\u50a8\u5355\u5143\u8fc7\u65e9\u5931\u6548\u3002\u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u53ef\u4ee5\u964d\u4f4eWear Leveling\u7b97\u6cd5\u7684\u590d\u6742\u6027\uff0c\u63d0\u9ad8\u5176\u6548\u679c\u3002 \u7efc\u4e0a\u6240\u8ff0\uff0c\u5c06\u591a\u6b21\u7684\u5c0fIO\u5408\u5e76\u6210\u4e00\u4e2a\u5927IO\u5bf9eMMC\u82af\u7247\u7684\u8bfb\u5199\u5bff\u547d\u6709\u79ef\u6781\u5f71\u54cd\u3002\u8fd9\u79cd\u64cd\u4f5c\u65b9\u5f0f\u53ef\u4ee5\u964d\u4f4e\u64e6\u9664\u548c\u5199\u5165\u6b21\u6570\uff0c\u63d0\u9ad8\u82af\u7247\u7684\u6027\u80fd\uff0c\u5e76\u6709\u5229\u4e8eWear Leveling\u6280\u672f\u7684\u5b9e\u73b0\u3002\u5f53\u7136\uff0c\u8fd9\u79cd\u4f18\u5316\u9700\u8981\u5728\u4fdd\u8bc1\u6570\u636e\u5b8c\u6574\u6027\u548c\u5b9e\u65f6\u6027\u7684\u524d\u63d0\u4e0b \u53c2\u8003\u6587\u732e\uff1a Micheloni, R., Crippa, L., &amp; Marelli, A. (2010). Inside NAND Flash Memories. Springer Science &amp; Business Media. Grupp, L. M., Davis, J. D., &amp; Swanson, S. (2012). The bleak [&hellip;]","og_url":"https:\/\/nemo.cool\/981.html","og_site_name":"Nemo","article_published_time":"2023-07-07T09:55:59+00:00","article_modified_time":"2024-11-26T07:14:23+00:00","og_image":[{"width":1024,"height":1024,"url":"https:\/\/nemo.cool\/wp-content\/uploads\/2023\/07\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png","type":"image\/png"}],"author":"Nemo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nemo","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nemo.cool\/981.html#article","isPartOf":{"@id":"https:\/\/nemo.cool\/981.html"},"author":{"name":"Nemo","@id":"https:\/\/nemo.cool\/#\/schema\/person\/698f803ee811e2b140a90f5d5de913d2"},"headline":"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528","datePublished":"2023-07-07T09:55:59+00:00","dateModified":"2024-11-26T07:14:23+00:00","mainEntityOfPage":{"@id":"https:\/\/nemo.cool\/981.html"},"wordCount":95,"commentCount":0,"publisher":{"@id":"https:\/\/nemo.cool\/#\/schema\/person\/698f803ee811e2b140a90f5d5de913d2"},"image":{"@id":"https:\/\/nemo.cool\/981.html#primaryimage"},"thumbnailUrl":"https:\/\/nemo.cool\/wp-content\/uploads\/2023\/07\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png","keywords":["agv","amr","Matplotlib","python","\u4f18\u5316","\u6027\u80fd","\u72b6\u6001\u673a"],"articleSection":["Dev","Python","Robot"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nemo.cool\/981.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nemo.cool\/981.html","url":"https:\/\/nemo.cool\/981.html","name":"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528 - Nemo","isPartOf":{"@id":"https:\/\/nemo.cool\/#website"},"primaryImageOfPage":{"@id":"https:\/\/nemo.cool\/981.html#primaryimage"},"image":{"@id":"https:\/\/nemo.cool\/981.html#primaryimage"},"thumbnailUrl":"https:\/\/nemo.cool\/wp-content\/uploads\/2023\/07\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png","datePublished":"2023-07-07T09:55:59+00:00","dateModified":"2024-11-26T07:14:23+00:00","breadcrumb":{"@id":"https:\/\/nemo.cool\/981.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nemo.cool\/981.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nemo.cool\/981.html#primaryimage","url":"https:\/\/nemo.cool\/wp-content\/uploads\/2023\/07\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png","contentUrl":"https:\/\/nemo.cool\/wp-content\/uploads\/2023\/07\/\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528\uff0c\u7528\u5728\u673a\u5668\u4eba\u4e0a.png","width":1024,"height":1024},{"@type":"BreadcrumbList","@id":"https:\/\/nemo.cool\/981.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/nemo.cool\/"},{"@type":"ListItem","position":2,"name":"\u8bbe\u8ba1\u6709\u7f13\u5b58\u5f02\u6b65\u903b\u8f91\u7684\u76d1\u63a7\u811a\u672c\u5e76\u6d4b\u8bd5\u5176\u8d44\u6e90\u5360\u7528"}]},{"@type":"WebSite","@id":"https:\/\/nemo.cool\/#website","url":"https:\/\/nemo.cool\/","name":"Nemo","description":"","publisher":{"@id":"https:\/\/nemo.cool\/#\/schema\/person\/698f803ee811e2b140a90f5d5de913d2"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nemo.cool\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/nemo.cool\/#\/schema\/person\/698f803ee811e2b140a90f5d5de913d2","name":"Nemo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nemo.cool\/wp-content\/uploads\/2024\/01\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg","url":"https:\/\/nemo.cool\/wp-content\/uploads\/2024\/01\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg","contentUrl":"https:\/\/nemo.cool\/wp-content\/uploads\/2024\/01\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg","caption":"Nemo"},"logo":{"@id":"https:\/\/nemo.cool\/wp-content\/uploads\/2024\/01\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg"},"sameAs":["https:\/\/nemo.cool"]}]}},"_links":{"self":[{"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/posts\/981","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/comments?post=981"}],"version-history":[{"count":0,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/posts\/981\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/media\/1025"}],"wp:attachment":[{"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/media?parent=981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/categories?post=981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/tags?post=981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}