-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
584 lines (450 loc) · 50.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>吾辈之人,自当自强不息! - 博客</title><meta name="author" content="Merlynr"><meta name="copyright" content="Merlynr"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="向前一步">
<meta property="og:type" content="website">
<meta property="og:title" content="吾辈之人,自当自强不息!">
<meta property="og:url" content="https://merlynr.github.io/index.html">
<meta property="og:site_name" content="吾辈之人,自当自强不息!">
<meta property="og:description" content="向前一步">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://merlynr.github.io/img/thumb-78833.gif">
<meta property="article:author" content="Merlynr">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://merlynr.github.io/img/thumb-78833.gif"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://merlynr.github.io/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//www.google-analytics.com" crossorigin=""/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="google-site-verification" content="NxG6l55lxRJBy3WWiA4lqhdm77dCzqIMonHurWHQtu0"/><meta name="baidu-site-verification" content="code-K9eCtVEPQ1"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?2b88427b12";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script><script async="async" src="https://www.googletagmanager.com/gtag/js?id=NxG6l55lxRJBy3WWiA4lqhdm77dCzqIMonHurWHQtu0"></script><script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'NxG6l55lxRJBy3WWiA4lqhdm77dCzqIMonHurWHQtu0');
</script><script>const GLOBAL_CONFIG = {
root: '/',
algolia: undefined,
localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容:${query}"}},
translate: undefined,
noticeOutdate: undefined,
highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
copy: {
success: '复制成功',
error: '复制错误',
noSupport: '浏览器不支持'
},
relativeDate: {
homepage: false,
post: true
},
runtime: '天',
date_suffix: {
just: '刚刚',
min: '分钟前',
hour: '小时前',
day: '天前',
month: '个月前'
},
copyright: {"limitCount":50,"languages":{"author":"作者: Merlynr","link":"链接: ","source":"来源: 吾辈之人,自当自强不息!","info":"著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。"}},
lightbox: 'fancybox',
Snackbar: undefined,
source: {
justifiedGallery: {
js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
}
},
isPhotoFigcaption: true,
islazyload: false,
isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
title: '吾辈之人,自当自强不息!',
isPost: false,
isHome: true,
isHighlightShrink: false,
isToc: false,
postUpdate: '2023-11-13 03:01:00'
}</script><noscript><style type="text/css">
#nav {
opacity: 1
}
.justified-gallery img {
opacity: 1
}
#recent-posts time,
#post-meta time {
display: inline !important
}
</style></noscript><script>(win=>{
win.saveToLocal = {
set: function setWithExpiry(key, value, ttl) {
if (ttl === 0) return
const now = new Date()
const expiryDay = ttl * 86400000
const item = {
value: value,
expiry: now.getTime() + expiryDay,
}
localStorage.setItem(key, JSON.stringify(item))
},
get: function getWithExpiry(key) {
const itemStr = localStorage.getItem(key)
if (!itemStr) {
return undefined
}
const item = JSON.parse(itemStr)
const now = new Date()
if (now.getTime() > item.expiry) {
localStorage.removeItem(key)
return undefined
}
return item.value
}
}
win.getScript = url => new Promise((resolve, reject) => {
const script = document.createElement('script')
script.src = url
script.async = true
script.onerror = reject
script.onload = script.onreadystatechange = function() {
const loadState = this.readyState
if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
script.onload = script.onreadystatechange = null
resolve()
}
document.head.appendChild(script)
})
win.activateDarkMode = function () {
document.documentElement.setAttribute('data-theme', 'dark')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
}
}
win.activateLightMode = function () {
document.documentElement.setAttribute('data-theme', 'light')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
}
}
const t = saveToLocal.get('theme')
if (t === 'dark') activateDarkMode()
else if (t === 'light') activateLightMode()
const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
if (asideStatus === 'hide') {
document.documentElement.classList.add('hide-aside')
} else {
document.documentElement.classList.remove('hide-aside')
}
}
const detectApple = () => {
if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
document.documentElement.classList.add('apple')
}
}
detectApple()
})(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="吾辈之人,自当自强不息!" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/thumb-78833.gif" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">51</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">33</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">14</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header" style="background-image: url('http://files.shanqianche.cn/20225/1652620959138.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">吾辈之人,自当自强不息!</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">吾辈之人,自当自强不息!</h1><div id="site-subtitle"><span id="subtitle"></span></div><div id="site_social_icons"><a class="social-icon" href="https://github.com/Merlynr" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:[email protected]" rel="external nofollow noreferrer" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left"><a href="/2020/10/19/lesslessqiu-tu-greatergreater-pu-xi-jin/" title="《囚徒》普希金"><img class="post_bg" src="https://images.wallpaperscraft.com/image/single/cube_man_vitamins_smilies_104936_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="《囚徒》普希金"></a></div><div class="recent-post-info"><a class="article-title" href="/2020/10/19/lesslessqiu-tu-greatergreater-pu-xi-jin/" title="《囚徒》普希金">《囚徒》普希金</a><div class="article-meta-wrap"><span class="article-meta"><i class="fas fa-thumbtack sticky"></i><span class="sticky">置顶</span><span class="article-meta-separator">|</span></span><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2022-12-12T06:40:54.561Z" title="更新于 2022-12-12 14:40:54">2022-12-12</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/life/">life</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study/">study</a><span class="article-meta-link">•</span><a class="article-meta__tags" href="/tags/book/">book</a></span></div><div class="content">我坐在阴湿牢狱的铁栏后一只在禁锢中成长的鹰雏和我郁郁地做伴;它扑着翅膀,在铁窗下啄食着血腥的食物。它啄食着,丢弃着,又望望窗外,像是和我感到同样的烦恼。它用眼神和叫声向我招呼,像要说:“我们飞去吧,是时候了,“我们原是自由的鸟儿,飞去吧——飞到那乌云后面明媚的山峦,飞到那里,到那蓝色的海角,只有风在欢舞……还有我做伴……
</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/02/14/Linux%E5%86%85%E6%A0%B8%E7%A7%BB%E6%A4%8D/" title="Linux内核移植"><img class="post_bg" src="https://images.wallpaperscraft.com/image/single/astronaut_gravity_space_suit_138001_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Linux内核移植"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/14/Linux%E5%86%85%E6%A0%B8%E7%A7%BB%E6%A4%8D/" title="Linux内核移植">Linux内核移植</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-13T18:42:00.000Z" title="更新于 2023-02-14 02:42:00">2023-02-14</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/1-Linux/">1. Linux</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study-graduate-student-Linux/">study, graduate student,Linux</a></span></div><div class="content">Linux内核基本概念Linux内核特性
可移植性,支持的硬件平台广泛
超强的网络功能
多任务多用户系统
模块化的设计
五大子系统
进程管理子系统
内存管理子系统
文件系统子系统
网络协议子系统
设备管理子系统
目录结构目录结构的描述:
与平台相关的kernel会和与平台无关的kernel功能相辅相成,无关的会依赖相关代码
平台无关与平台无关的目录树:
平台有关–archarch中与平台相关代码:
命名规律当内核中头文件重名如何解决?
头文件命名规范:
内核配置问题
配置哪些目录需要编译
配置哪些文件需要编译 编译时到底文件是哪个目录? Makefile方法与思路
配置步骤:
配置仓库选取,即配置单的修改
交叉编译器的修改
体系结构体的选择
增删改查
体系结构选择的配置,交叉编译方式的选择修改Makefile
各个目录的编译有Makefile进行选择编译。
各个子目录Makefile
obj-y : 编译进内核
obj- : 不编译进去
obj-m: 以模块形式编译条件编译:
**主目录Makefile的修改: **
修改连接的平台相关代码:【h ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/2023/02/13/IIC%E5%8D%8F%E8%AE%AE/" title="IIC设备驱动及子系统开发"><img class="post_bg" src="http://www.obzhi.com/wp-content/uploads/2020/12/qilongzhu-1024x576.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="IIC设备驱动及子系统开发"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/13/IIC%E5%8D%8F%E8%AE%AE/" title="IIC设备驱动及子系统开发">IIC设备驱动及子系统开发</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-13T03:01:00.000Z" title="更新于 2023-02-13 11:01:00">2023-02-13</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Embedded/">Embedded</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study-graduate-student-embedded/">study, graduate student,embedded</a></span></div><div class="content">基本概念
设备都有自己得设备地址,EEprom存储设备信息,包括设备地址
一般为7位,前四位已经固化好了,其余三位可以通过设计图,上图,看出接地为000,P0,P1也在数据手册中进行描述,为未接,为0. 即AT24LC08(上图有误)地址为1010 000.
总线速度:标准速度100kbps,快速模式400kbps,高速模式3.4Mbps(一般为100,四百也多一点)
IIC特点: 半双工(串行方式),仅需要两根线(所以又被称为2-wixe总线)
设备操作时序
IIC从机设备地址是由主机写进去的
低电平写,高电平读
IIC开始条件和终止条件,基本时序图如下
读写时序分析按字节进行写操作主设备设备地址为1010 000,发送数据,写到地址0x3,写入0x5。
写入逻辑图
按页进行写操作按页进行写操作如下图。
当前地址读操作当前地址读操作如下图。
随机读操作随机读操作如下图。
序列号读操作序列化读操作如下图。
读写逻辑
结合上图随机读操作进行理解。
写数据
装载AT24C08设备地址:0xA0
设置IIC开始条件
使能ACK
检测状态
装载存 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/02/13/%E6%B1%87%E7%BC%96%E8%AF%AD%E8%A8%80%20%E9%80%9F%E6%95%88%E6%95%91%E5%BF%83%E4%B8%B8/" title="无题"><img class="post_bg" src="https://images.wallpaperscraft.com/image/single/deer_minimalism_vector_background_nature_93845_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="无题"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/13/%E6%B1%87%E7%BC%96%E8%AF%AD%E8%A8%80%20%E9%80%9F%E6%95%88%E6%95%91%E5%BF%83%E4%B8%B8/" title="无题">无题</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-12T19:00:59.624Z" title="更新于 2023-02-13 03:00:59">2023-02-13</time></span></div><div class="content">帮助快速上手汇编语言编程,虽然只限于编程
VScode配置调试环境
安装插件TASM/MASM
右键扩展设置,选择Assembler:MASM
右键调试即可开始调试了!
Debug.exe
R命令:查看、改变CPU寄存器的内容D命令:查看内存中的内容T命令:执行一条机器指令G命令:从停顿的地方运行到底
第一段代码:Hello World123456789101112131415161718192021DSEG SEGMENT MESS DB 'Hello, World!',0DH,0AH,24HDSEG ENDSSSEG SEGMENT PARA STACK DW 256 DUP(?)SSEG ENDSCSEG SEGMENT ASSUME CS:CSEG, DS:DSEG BEGIN:MOV AX,DSEG MOV DS,AX MOV DX,OFFSET MESS ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/2023/02/06/ARM%E7%A1%AC%E4%BB%B6%E5%9F%BA%E7%A1%80/" title="ARM硬件基础"><img class="post_bg" src="https://images.wallpaperscraft.com/image/single/smileys_stars_happy_125856_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ARM硬件基础"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/06/ARM%E7%A1%AC%E4%BB%B6%E5%9F%BA%E7%A1%80/" title="ARM硬件基础">ARM硬件基础</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-06T03:12:00.000Z" title="更新于 2023-02-06 11:12:00">2023-02-06</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/ARM/">ARM</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study-graduate-student-ARM/">study, graduate student,ARM</a></span></div><div class="content">CPU核心
SIMD:Single Instruction Multiple Data,单指令多数据流。单次处理多条数据。
NEON:加速多媒体和信号处理算法(如视频编码/解码、2D/3D图形、游戏、音频和语音处理图像处理技术、电话和声音合成),其性能至少为ARM5性能的3倍,为ARMv6SIMD性能的2倍。主要处理浮点数
系统外围
RTC:real-time clock
PLL:Phase Locked Loop,为锁相回路或锁相环,用来统一整合时脉讯号,使内存能正确的存取资料。
PWM Timer:脉冲宽度调制(Pulse Width Modulation),脉宽调制
Watchdog Timer:
DMA:帮助存储器与外设进行交互,减轻CPU压力
Keypad:按钮
ADC:Analog to Digital Converter,模数转换器
SISD&SIMDSISD:单指令单数据SIMD:单指令多数据
NEON:对SIMD进行扩展,加入向量表提高数据集的压缩,进而提高浮点数运算效率。
Cache 高速缓存
二级缓存的优化会大大影响程序运行速度。涉及到调优。
...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/02/06/bootloader%E6%A6%82%E8%BF%B0/" title="bootloader概述"><img class="post_bg" src="https://images.wallpaperscraft.com/image/single/smiles_emoticons_balls_141899_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="bootloader概述"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/06/bootloader%E6%A6%82%E8%BF%B0/" title="bootloader概述">bootloader概述</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-06T00:13:00.000Z" title="更新于 2023-02-06 08:13:00">2023-02-06</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Linux/">Linux</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study-graduate-student-Linux/">study, graduate student,Linux</a></span></div><div class="content">bootloader的作用和概述作用boot的目的(跳到C语言中):
关闭看门狗,中断,MMU,CACHE(影响数据完整性)
配置系统工作时钟(不同处理器、外设对于时钟要求不一样)
配置SDRAM的控制器(行地址数、列地址数、多少块,周期性的充电【难点 】
让sp指向可读可写的设备区间中,满足递减栈的规则SDAM
用哪些模式,就要初始化哪些模式下的SP
每个模式值不能覆盖其他模式
代码搬移(code太大需要转移到DRAM)
方式一,执行速度问题,把程序从存储器(nor-flash)搬移到快速的内存
方式二,只把存储器的一部分代码执行出来,把存储在其他位置上的低码搬移到内存,对应存储器的控制器的初始化
bl main
loader的目的:执行应用逻辑,点灯、uart,load linux kernel
</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/2023/02/06/ARM%E6%B1%87%E7%BC%96/" title="ARM汇编"><img class="post_bg" src="https://images.wallpaperscraft.com/image/single/tiger_face_stone_eyes_predator_92029_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ARM汇编"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/06/ARM%E6%B1%87%E7%BC%96/" title="ARM汇编">ARM汇编</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-05T17:04:00.000Z" title="更新于 2023-02-06 01:04:00">2023-02-06</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E6%B1%87%E7%BC%96/">汇编</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study-graduate-student-%E6%B1%87%E7%BC%96/">study, graduate student,汇编</a></span></div><div class="content">汇编概念
不同系统种汇编指令有差异
如何判断一个立即数是否合规:此数除以4,如果在0-255之间则合规。0x102:是立即数0x104:不是立即数
寻址模式
ARM堆栈
满堆栈:堆栈指针指向栈顶
空堆栈:堆栈指针指向栈底
递增堆栈:从低地址向高地址压栈
递减堆栈:从高地址向低地址压栈
汇编算数操作
内存操作
跳转与状态操作
跳转实质:给PC传程序地址,告诉CPU下一个执行的程序。BL:mov LR,PC 这样执行完可以在LR中找到执行记录返回
常用伪指令
混合编程
在C/C++代码中嵌入汇编指令。
汇编调用C/C+
C/C++调用汇编
C语言嵌入汇编限制条件:
不能直接向PC寄存器赋值,程序跳转要使用B或者BL指令;
在使用物理寄存器时,不要使用过于复杂的C表达式,避免物理寄存器冲突;
R12和R13可能被编译器用来存放中间编译结果,计算表达式值时可能把R0-R3、R12及R14用于子程序调用,因此避免直接使用这些物理寄存器;
在C中嵌入汇编指令123456789101112131415161718void my_str_cpy( ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/02/05/ARM%20%E4%BD%93%E7%B3%BB%E6%9E%B6%E6%9E%84/" title="ARM 体系架构粗了解"><img class="post_bg" src="https://images.wallpaperscraft.com/image/single/sky_light_abstraction_85064_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ARM 体系架构粗了解"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/05/ARM%20%E4%BD%93%E7%B3%BB%E6%9E%B6%E6%9E%84/" title="ARM 体系架构粗了解">ARM 体系架构粗了解</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-04T22:08:00.000Z" title="更新于 2023-02-05 06:08:00">2023-02-05</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/ARM/">ARM</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study-graduate-student-ARM/">study, graduate student,ARM</a></span></div><div class="content">版本差异
副处理器可以省电70%
CPU组成
基本组成:ALU(计算单元,累加器)、控制器(切换)、寄存器、总线(连接)
处理模式ARM7、ARM9:7中Cortex-A:9种。8种特权模式,一种非特权模式即用户模式
寄存器
SP:堆栈寄存器
LR:链接寄存器
PC:程序寄存器
PSR:程序状态寄存器
APSR:应用程序状态寄存器
CPSR:当前程序状态寄存器
SPSR:已存储程序状态寄存器
只有在用户模式下才是ASPR,其它模式都是CSPR
R0-R12通用寄存器,放通用数据,32bit
各个模式的R0-R12与USR模式是共享的(除了FIQ,R8-R12),PC,CPSR共享的
USRR模式没有SPSR
CSPR指令格式
M:九种模式,五位表示
T:是否使用Thumb指令
F:是否禁用FIQ
I:是否禁用IRQ
A:是否禁用ABT
E:存储字节的顺序(大段还是小段,因为存储时以字为单位,所以需要选择存储顺序)
IT:Thumb2指令的if…then…条件执行
GE:SIMD
J:Jazelle(Java)
Q:累计饱和instructions
V:ALU操作溢 ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/2023/02/04/Linux%E5%A4%9A%E7%BA%BF%E7%A8%8B%E7%9A%84%E5%90%8C%E6%AD%A5/" title="Linux多线程的同步"><img class="post_bg" src="http://www.obzhi.com/wp-content/uploads/2020/12/qilongzhu-1024x576.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Linux多线程的同步"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/04/Linux%E5%A4%9A%E7%BA%BF%E7%A8%8B%E7%9A%84%E5%90%8C%E6%AD%A5/" title="Linux多线程的同步">Linux多线程的同步</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-04T04:05:00.000Z" title="更新于 2023-02-04 12:05:00">2023-02-04</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Linux/">Linux</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study-graduate-student-Linux/">study, graduate student,Linux</a></span></div><div class="content"></div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/02/01/Linux%E5%A4%9A%E8%BF%9B%E7%A8%8B%E4%B9%8B%E9%97%B4%E7%9A%84%E9%80%9A%E4%BF%A1(%E4%BA%8C)/" title="Linux多进程之间的通信(二)"><img class="post_bg" src="https://images.wallpaperscraft.com/image/single/cat_drawing_art_apofiss_94604_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Linux多进程之间的通信(二)"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/02/01/Linux%E5%A4%9A%E8%BF%9B%E7%A8%8B%E4%B9%8B%E9%97%B4%E7%9A%84%E9%80%9A%E4%BF%A1(%E4%BA%8C)/" title="Linux多进程之间的通信(二)">Linux多进程之间的通信(二)</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time datetime="2023-02-01T02:01:00.000Z" title="更新于 2023-02-01 10:01:00">2023-02-01</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Linux/">Linux</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/study-graduate-student-Linux/">study, graduate student,Linux</a></span></div><div class="content">IPC 基本结构简述
IPC通信包括:共享内存,消息队列,信号灯
共享内存打开或创建一个共享内存对象,共享内核在内核是什么样子的?一块缓存,变类似于用户空间的数组或malloc函数分配的空间一样。
查看IPC对象:ipcs -m【查看共享内存】| -q【队列】| -s【信号灯】删除IPC对象:ipcrm -m | -q | -s id【IPC的ID】
共享内存可以通过memcpy写入,也可以通过键盘输入stdin
利用键盘输入读取共享内存123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051/************************************************************************* > File Name: shm_0.c > Author: Merlynr > Mail: [email protected] > Created Time: 20 ...</div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span><a class="page-number" href="/page/2/#content-inner">2</a><span class="space">…</span><a class="page-number" href="/page/6/#content-inner">6</a><a class="extend next" rel="next" href="/page/2/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/thumb-78833.gif" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Merlynr</div><div class="author-info__description">向前一步</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">51</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">33</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">14</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Merlynr" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:[email protected]" rel="external nofollow noreferrer" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/02/14/Linux%E5%86%85%E6%A0%B8%E7%A7%BB%E6%A4%8D/" title="Linux内核移植"><img src="https://images.wallpaperscraft.com/image/single/astronaut_gravity_space_suit_138001_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Linux内核移植"/></a><div class="content"><a class="title" href="/2023/02/14/Linux%E5%86%85%E6%A0%B8%E7%A7%BB%E6%A4%8D/" title="Linux内核移植">Linux内核移植</a><time datetime="2023-02-13T18:42:00.000Z" title="发表于 2023-02-14 02:42:00">2023-02-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/02/13/IIC%E5%8D%8F%E8%AE%AE/" title="IIC设备驱动及子系统开发"><img src="http://www.obzhi.com/wp-content/uploads/2020/12/qilongzhu-1024x576.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="IIC设备驱动及子系统开发"/></a><div class="content"><a class="title" href="/2023/02/13/IIC%E5%8D%8F%E8%AE%AE/" title="IIC设备驱动及子系统开发">IIC设备驱动及子系统开发</a><time datetime="2023-02-13T03:01:00.000Z" title="发表于 2023-02-13 11:01:00">2023-02-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/02/13/%E6%B1%87%E7%BC%96%E8%AF%AD%E8%A8%80%20%E9%80%9F%E6%95%88%E6%95%91%E5%BF%83%E4%B8%B8/" title="无题"><img src="https://images.wallpaperscraft.com/image/single/deer_minimalism_vector_background_nature_93845_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="无题"/></a><div class="content"><a class="title" href="/2023/02/13/%E6%B1%87%E7%BC%96%E8%AF%AD%E8%A8%80%20%E9%80%9F%E6%95%88%E6%95%91%E5%BF%83%E4%B8%B8/" title="无题">无题</a><time datetime="2023-02-12T19:00:59.624Z" title="发表于 2023-02-13 03:00:59">2023-02-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/02/06/ARM%E7%A1%AC%E4%BB%B6%E5%9F%BA%E7%A1%80/" title="ARM硬件基础"><img src="https://images.wallpaperscraft.com/image/single/smileys_stars_happy_125856_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ARM硬件基础"/></a><div class="content"><a class="title" href="/2023/02/06/ARM%E7%A1%AC%E4%BB%B6%E5%9F%BA%E7%A1%80/" title="ARM硬件基础">ARM硬件基础</a><time datetime="2023-02-06T03:12:00.000Z" title="发表于 2023-02-06 11:12:00">2023-02-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/02/06/bootloader%E6%A6%82%E8%BF%B0/" title="bootloader概述"><img src="https://images.wallpaperscraft.com/image/single/smiles_emoticons_balls_141899_300x168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="bootloader概述"/></a><div class="content"><a class="title" href="/2023/02/06/bootloader%E6%A6%82%E8%BF%B0/" title="bootloader概述">bootloader概述</a><time datetime="2023-02-06T00:13:00.000Z" title="发表于 2023-02-06 08:13:00">2023-02-06</time></div></div></div></div><div class="card-widget" id="card-newest-comments"><div class="item-headline"><i class="fas fa-comment-dots"></i><span>最新评论</span></div><div class="aside-list"><span>正在加载中...</span></div></div><div class="card-widget card-categories"><div class="item-headline">
<i class="fas fa-folder-open"></i>
<span>分类</span>
<a class="card-more-btn" href="/categories/" title="查看更多">
<i class="fas fa-angle-right"></i></a>
</div>
<ul class="card-category-list" id="aside-cat-list">
<li class="card-category-list-item "><a class="card-category-list-link" href="/categories/1-Linux/"><span class="card-category-list-name">1. Linux</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/ARM/"><span class="card-category-list-name">ARM</span><span class="card-category-list-count">2</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/C-Language/"><span class="card-category-list-name">C Language</span><span class="card-category-list-count">3</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Embedded/"><span class="card-category-list-name">Embedded</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/FE/"><span class="card-category-list-name">FE</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Linux/"><span class="card-category-list-name">Linux</span><span class="card-category-list-count">7</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/RPA/"><span class="card-category-list-name">RPA</span><span class="card-category-list-count">4</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/RTOS/"><span class="card-category-list-name">RTOS</span><span class="card-category-list-count">8</span></a></li>
</ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>标签</span></div><div class="card-tag-cloud"><a href="/tags/Java/" style="font-size: 1.1em; color: #999">Java</a> <a href="/tags/JavaScript/" style="font-size: 1.1em; color: #999">JavaScript</a> <a href="/tags/LSTM/" style="font-size: 1.1em; color: #999">LSTM</a> <a href="/tags/RPA/" style="font-size: 1.28em; color: #99a0aa">RPA</a> <a href="/tags/algorithm/" style="font-size: 1.43em; color: #99a6b8">algorithm</a> <a href="/tags/block-chain/" style="font-size: 1.1em; color: #999">block chain</a> <a href="/tags/book/" style="font-size: 1.14em; color: #999a9c">book</a> <a href="/tags/code/" style="font-size: 1.1em; color: #999">code</a> <a href="/tags/daily/" style="font-size: 1.14em; color: #999a9c">daily</a> <a href="/tags/data-mining/" style="font-size: 1.25em; color: #999fa7">data mining</a> <a href="/tags/deep-learning/" style="font-size: 1.35em; color: #99a3b1">deep learning</a> <a href="/tags/front-end/" style="font-size: 1.14em; color: #999a9c">front-end</a> <a href="/tags/graduate-student/" style="font-size: 1.46em; color: #99a8bc">graduate student</a> <a href="/tags/kernal-function/" style="font-size: 1.1em; color: #999">kernal function</a> <a href="/tags/kernal-method/" style="font-size: 1.1em; color: #999">kernal method</a> <a href="/tags/kernal-trick/" style="font-size: 1.1em; color: #999">kernal trick</a> <a href="/tags/machine-leaning/" style="font-size: 1.17em; color: #999ca0">machine leaning</a> <a href="/tags/machine-learning/" style="font-size: 1.35em; color: #99a3b1">machine learning</a> <a href="/tags/paper/" style="font-size: 1.39em; color: #99a5b5">paper</a> <a href="/tags/plan/" style="font-size: 1.1em; color: #999">plan</a> <a href="/tags/process-mining/" style="font-size: 1.21em; color: #999da3">process mining</a> <a href="/tags/security/" style="font-size: 1.1em; color: #999">security</a> <a href="/tags/study/" style="font-size: 1.5em; color: #99a9bf">study</a> <a href="/tags/study-graduate-student-RTOS/" style="font-size: 1.1em; color: #999">study, graduate student, RTOS</a> <a href="/tags/study-graduate-student-ARM/" style="font-size: 1.14em; color: #999a9c">study, graduate student,ARM</a> <a href="/tags/study-graduate-student-C-Language/" style="font-size: 1.17em; color: #999ca0">study, graduate student,C Language</a> <a href="/tags/study-graduate-student-Linux/" style="font-size: 1.32em; color: #99a2ae">study, graduate student,Linux</a> <a href="/tags/study-graduate-student-RTOS/" style="font-size: 1.32em; color: #99a2ae">study, graduate student,RTOS</a> <a href="/tags/study-graduate-student-STM32/" style="font-size: 1.1em; color: #999">study, graduate student,STM32</a> <a href="/tags/study-graduate-student-embedded/" style="font-size: 1.1em; color: #999">study, graduate student,embedded</a> <a href="/tags/study-graduate-student-%E6%B1%87%E7%BC%96/" style="font-size: 1.1em; color: #999">study, graduate student,汇编</a> <a href="/tags/study-graduate-student-Linux/" style="font-size: 1.1em; color: #999">study,graduate student,Linux</a> <a href="/tags/summarize/" style="font-size: 1.1em; color: #999">summarize</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span><a class="card-more-btn" href="/archives/" title="查看更多">
<i class="fas fa-angle-right"></i></a></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2023/02/"><span class="card-archive-list-date">二月 2023</span><span class="card-archive-list-count">9</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2023/01/"><span class="card-archive-list-date">一月 2023</span><span class="card-archive-list-count">7</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/12/"><span class="card-archive-list-date">十二月 2022</span><span class="card-archive-list-count">8</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/11/"><span class="card-archive-list-date">十一月 2022</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/05/"><span class="card-archive-list-date">五月 2022</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/07/"><span class="card-archive-list-date">七月 2021</span><span class="card-archive-list-count">10</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/06/"><span class="card-archive-list-date">六月 2021</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/05/"><span class="card-archive-list-date">五月 2021</span><span class="card-archive-list-count">9</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">51</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2020-05-19T16:00:00.000Z"></div></div><div class="webinfo-item"><div class="item-name">本站总字数 :</div><div class="item-count">79.8k</div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2023-11-12T19:00:58.732Z"></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://images.wallpaperscraft.com/image/single/silhouettes_mannequins_drops_214100_1920x1200.jpg')"><div id="footer-wrap"><div class="copyright">©2020 - 2023 By Merlynr</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener external nofollow noreferrer" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Hi, 加油!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="chat_btn" type="button" title="聊天"><i class="fas fa-sms"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span> 数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
endLoading: () => {
document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = '';
document.getElementById('loading-box').classList.remove("loaded")
}
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function subtitleType () {
if (true) {
window.typed = new Typed("#subtitle", {
strings: ["今日事,今日畢","Never put off till tomorrow what you can do today"],
startDelay: 300,
typeSpeed: 150,
loop: true,
backSpeed: 50
})
} else {
document.getElementById("subtitle").innerHTML = '今日事,今日畢'
}
}
if (true) {
if (typeof Typed === 'function') {
subtitleType()
} else {
getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
}
} else {
subtitleType()
}</script><script>(() => {
const $mermaidWrap = document.querySelectorAll('#article-container .mermaid-wrap')
if ($mermaidWrap.length) {
window.runMermaid = () => {
window.loadMermaid = true
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'
Array.from($mermaidWrap).forEach((item, index) => {
const mermaidSrc = item.firstElementChild
const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
const mermaidID = 'mermaid-' + index
const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
mermaid.mermaidAPI.render(mermaidID, mermaidDefinition, (svgCode) => {
mermaidSrc.insertAdjacentHTML('afterend', svgCode)
})
})
}
const loadMermaid = () => {
window.loadMermaid ? runMermaid() : getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaid)
}
window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
}
})()</script></div><script src="https://cdn.jsdelivr.net/npm/blueimp-md5/js/md5.min.js"></script><script>window.addEventListener('load', () => {
const changeContent = (content) => {
if (content === '') return content
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[图片]') // replace image link
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[代码]') // replace code
content = content.replace(/<[^>]+>/g,"") // remove html tag
if (content.length > 150) {
content = content.substring(0,150) + '...'
}
return content
}
const getIcon = (icon, mail) => {
if (icon) return icon
let defaultIcon = '?d=monsterid'
let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase()) + defaultIcon}`
return iconUrl
}
const generateHtml = array => {
let result = ''
if (array.length) {
for (let i = 0; i < array.length; i++) {
result += '<div class=\'aside-list-item\'>'
if (true) {
const name = 'src'
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
}
result += `<div class='content'>
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
</div></div>`
}
} else {
result += '没有评论'
}
let $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= result
window.lazyLoadInstance && window.lazyLoadInstance.update()
window.pjax && window.pjax.refresh($dom)
}
const getComment = () => {
const serverURL = 'https://os5grwrc.lc-cn-n1-shared.com'
var settings = {
"method": "GET",
"headers": {
"X-LC-Id": 'oS5GRWrcL4mqhmTb76gIam4o-gzGzoHsz',
"X-LC-Key": 'O3n8aheKbJxQxt2T6eYVtHDT',
"Content-Type": "application/json"
},
}
fetch(`${serverURL}/1.1/classes/Comment?limit=6&order=-createdAt`,settings)
.then(response => response.json())
.then(data => {
const valineArray = data.results.map(function (e) {
return {
'avatar': getIcon(e.QQAvatar, e.mail),
'content': changeContent(e.comment),
'nick': e.nick,
'url': e.url + '#' + e.objectId,
'date': e.updatedAt,
}
})
saveToLocal.set('valine-newest-comments', JSON.stringify(valineArray), 10/(60*24))
generateHtml(valineArray)
}).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "无法获取评论,请确认相关配置是否正确"
})
}
const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('valine-newest-comments')
if (data) {
generateHtml(JSON.parse(data))
} else {
getComment()
}
}
}
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})</script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><script>((window.gitter = {}).chat = {}).options = {
disableDefaultChat: true,
};
document.addEventListener('gitter-sidecar-ready', (e) => {
const GitterChat = e.detail.Chat
let chat
function initGitter () {
chat = new GitterChat({
room: 'Merlynr/blog_chat',
activationElement: '#chat_btn'
});
}
initGitter()
if (false) {
document.addEventListener('pjax:complete', () => {
chat.destroy()
initGitter()
})
}
})</script><script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async="async" defer="defer"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>