cpt1020

@cpt

Joined on Jun 28, 2021

  • 原文:A ‘C’ Test: The 0x10 Best Questions for Would-be Embedded Programmers 紀錄閱讀這篇原文時做的筆記~ Preprocessor 1. 使用 #define 宣告一個常數,這個常數代表一年有多少秒(不用考慮閏年) #define SECONDS_PER_YEAR (60UL * 60UL * 24UL * 365UL) 要注意的地方: #define 的基本語法,例如:不需要以分號 ; 做結尾 使用 ( ) 包起來,以確保運算順序
     Like  Bookmark
  • DMZ 102 有時候公司或組織會需要提供對外的服務,像是 mail server 或 web server,讓別人從外網可以存取到這些提供的服務,但同時公司也有一些東西不想被外界存取、只想給公司內部使用。這時就可以用 Demilitarized zone(DMZ)非軍事化區域(又稱作 perimeter network 或 screened subnet)。 非軍事化區域其實就是在公司/組織的內網和外網之間多一個 physical 或 logical 的 subnetwork。將欲提供給外部使用的伺服器都放在 DMZ 裡面,外網的使用者可以存取到 DMZ 裡面的服務;而公司不想讓外界存取的東西則用防火牆擋住,放在公司的 LAN 裡面,讓外界無法存取到 LAN 內的東西。 Architectures of DMZ 有許多不同的方式可以用來設計 DMZ,其中兩種最基本的方式是使用 single firewall 以及 dual firewalls。這些架構可以被擴展來建立更複雜的架構。
     Like  Bookmark
  • Ping 在測試是否能到達位在某個網路的某個 host 時,很常用到的一個工具就是 ping。ping 會先發出 ICMP echo request 封包,若此封包有到達指定的 host,且該 host 的設定是會回覆 ICMP echo request,那就會回傳 ICMP echo reply 的封包。待我們收到 ICMP echo reply 後,ping 就會計算 round-trip time、packet loss 等資訊。 :::info ICMP 是 network-layer 的 protocol,也就是第三層的 protocol。TCP 跟 UDP 由於會用到 port number,所以是屬於第四層的 protocol。而 ICMP 不需要用到 port number,只需要用到 IP address,所以是第三層的 protocol。 ::: 所以若 ping 了某個 IP 但沒回應,並不一定代表那個 IP 沒有 host,有可能是那個 host 選擇不回應 ICMP echo request。 那什麼情況會選擇不回應 ICMP echo request?
     Like  Bookmark
  • 以下紀錄自己學習 iptables 的筆記~ 資料透過網路傳輸時,會被切割成一個一個的封包,封包裡面除了含有要傳送的 data,也含有這個封包的資訊,像是 souce address、protocol 等等資訊。 而說到 Linux 的防火牆,就會提到 iptables。當封包進到 iptables 裡面,iptables 就會查看這個封包的資訊,並依據我們設定的防火牆規則對這個封包做處理。 以下簡單介紹 iptables 和它的指令~ Linux Firewall linux firewall
     Like 2 Bookmark
  • 由於 Marvell ESPRESSObin v7 官網介紹安裝 OpenWRT 的版本有點舊了、安裝的環境也有點舊 😵‍💫 所以自己研究了一下從下載 OpenWRT source code、編譯 image、到使用 SD 卡開機的過程~ Host Machine Host machine 是安裝在 MacBook M3 的 VirtualBox 的 Ubuntu 24.04 虛擬機: $ cat /etc/os-release PRETTY_NAME="Ubuntu 24.04.1 LTS" NAME="Ubuntu" VERSION_ID="24.04" VERSION="24.04.1 LTS (Noble Numbat)"
     Like  Bookmark
  • 2016 年買的 MacBook Air 用了八年,到去年年底才換了 M3 的 MacBook Air。 一開始在裝 Ubuntu 虛擬機時因為用了 Intel 架構的 Ubuntu image,結果都一直失敗 😣 查了一下才知道因為 Apple Silicon M3 晶片是 ARM 架構,所以不能用 Intel 架構的 Ubuntu image,必須要用 ARM 架構的。 一開始以為 Ubuntu 官方沒有提供 Ubuntu Desktop for ARM,所以安裝了 Ubuntu Server for ARM,然後再用 sudo apt install ubuntu-desktop 安裝 Desktop GUI,結果常常會用到一半卡住,重開虛擬機後直接說有 critical error,整個虛擬機開不了,只好重灌 😵‍💫 上網查,在 Reddit 看到原來 Ubuntu 是有提供 Desktop for ARM 的 image! 以下就紀錄安裝和設定的過程~包含啟用 host 和虛擬機之間的 copy paste、shared folder、以及偵測 USB 裝置。
     Like 2 Bookmark
  • 2023 年暑假畢業流程紀錄 保羅老師實驗室論文模板 保羅老師實驗室論文模板 論文好幫手😇 Sci-hub (https://sci-hub.se)有些文獻學校沒買,可以到這網站查看看,有可能可以下載到 Grammarly (https://www.grammarly.com)
     Like 5 Bookmark
  • Preface 前言 TelAF Simulation Installing Ubuntu 18.04 on VirtualBox 安裝 TelAF Simulation & 執行 helloApp Legato Application Framework [Legato] Legato 框架基本介紹 [Legato] Log
     Like  Bookmark
  • App/System Configuration:https://docs.legato.io/latest/conceptsConfig.html Config Tree:https://docs.legato.io/latest/legatoServicesConfigTree.html Config Tree API:https://docs.legato.io/latest/c_config.html le_cfg API Reference:https://docs.legato.io/latest/group__le__cfg.html Config Tree Admin API:https://docs.legato.io/latest/c_configAdmin.html le_cfgAdmin API Reference:https://docs.legato.io/latest/group__le__cfgAdmin.html config Target Tool:https://docs.legato.io/latest/toolsTarget_config.html The configTree subsection of the requires section in .adef:https://docs.legato.io/latest/defFilesAdef.html#defFilesAdef_requiresConfigTree Intro to Config Tree
     Like  Bookmark
  • Legato Application Framework 是由 Sierra Wireless Inc. 公司所開發的框架,主要是用來開發 Internet of Everything。 Qualcomm 的 TelAF 是基於 Legato 所開發的,所以在使用 TelAF 前要先稍微瞭解 Legato 才能比較快上手 Legato 的 System、App、Executable、以及 Component 架構 image (圖片擷取自 Legato 官網:https://docs.legato.io/latest/conceptsEnvironment.html) Legato 框架有幾個重要的概念,分別是 Component、Executable、App、以及 System。
     Like  Bookmark
  • Logging:https://docs.legato.io/latest/conceptsLogs.html log(target tool):https://docs.legato.io/latest/toolsTarget_log.html Logging API:https://docs.legato.io/latest/c_logging.html Logging API Documentation:https://docs.legato.io/latest/le__log_8h.html Qualcomm Logging API:https://docs.qualcomm.com/bundle/publicresource/topics/80-41102-2/page_c_logging.html#Documentationa00789 Log Level Legato 的 log 訊息分成以下六種 levels,越後面的代表越嚴重: DEBUG:Handy for troubleshooting.
     Like  Bookmark
  • Legato 官網對 Layered Publish-Subscribe Handlers 的說明:https://docs.legato.io/latest/c_eventLoop.html#c_event_layeredPublishSubscribe 在使用 Legato 框架做開發時,若需要讓 client 因 server 發佈某個 event 而去執行 handler function,這時就可以用 Legato 的 Layered Publish-Subscribe Handler 機制。 Layered Publish-Subscribe Handlers 的 Layered 是指有兩層的 handler,第一層 handler 由 server 端執行,第二層 handler 由 client 端執行,當第一層 handler 執行完就會去呼叫第二層 handler。 基本流程: Server 發布一個 event Server 先執行第一層 handler,並且有需要的話可以在第一層 handler 內處理 event data。然後在第一層 handler 內呼叫第二層 handler,並且將剛剛處理過的 event data 一起傳給第二層 handler
     Like  Bookmark
  • 官方網頁:https://docs.qualcomm.com/bundle/publicresource/topics/80-41102-1/use-telaf-simulation.html :::warning Qualcomm 有提供 docker container 可以用來模擬 TelAF 跑在 tagert machine 的狀況。這個模擬用的 docker container 有 Ubuntu 18.04 和 Ubuntu 22.04,而他們的 cgroup 都必須是 cgroup1,不可以是 cgroup2。 我一開始是開一個 LXD 的 Ubuntu 18.04 container 安裝 TelAF simulation 所需的 packages,以及安裝它的 docker image。但由於我桌機裝的 Ubuntu 是 24.04,預設是 cgroup2,而 LXD container 的 cgroup 也會一併受 host 影響而變成 cgroup2。 雖然有試過一些方法將桌機 Ubuntu 24.04 改成 cgroup1,但 LXD container 頂多變成是 cgroup1 和 cgroup2 同時存在,無法變成 cgroup1 only,這樣仍會導致模擬時的一些功能有受限。 最後是改成用 VirtualBox 跑 Ubuntu 18.04 虛擬機來跑 TelAF simulation 才有效。
     Like  Bookmark
  • https://docs.legato.io/latest/apiFilesC.html#apiFilesC_asyncServer https://docs.legato.io/latest/defFilesCdef.html#defFilesCdef_providesApiAsync Legato 預設上,提供 API 的 server 端是同步的 server,也就是 client 端呼叫了 API,server 端會依序處理其接收到的 client 端的 API 請求。 若 API 的執行會花很多時間,且要 return 執行的結果給 client 端,這樣會花很多時間。 倘若將 server 端設定成非同步,則當 server 的 main thread 每接收到 client 端的一個 API 請求,我們就可以把這個 API 請求轉給 worker thread 執行,待 worker thread 完成後,再通知 main thread,main thread 再把執行結果回傳給 client 端。 這樣當 worker thread 在執行 API 時,main thread 可以繼續接收其他 client 端的 API 請求、並再轉發給其他 worker thread 處理,而不會被卡住。
     Like  Bookmark
  • https://docs.legato.io/latest/c_mutex.html https://docs.legato.io/latest/le__mutex_8h.html Recursive vs Non-Recursive Mutex Legato mutex 有分成 recursive 和 non-recursive 的 mutex。 Recursive mutex同一個 thread 可以一直去鎖同一個 mutex,但鎖了幾次就要解鎖幾次。 Non-recursive mutex
     Like  Bookmark
  • https://docs.legato.io/latest/c_semaphore.html https://docs.legato.io/latest/le__semaphore_8h.html Legato Semaphore 基本使用流程 使用 le_sem_Create() 建立 semaphore 並初始化 semaphore 的值,此 API 會 return le_sem_Ref_t。Semaphore 初始值必須大於等於 0,否則 process 會 exit。 減少 semaphore 的值可以用以下 APIs: le_sem_Wait() le_sem_TryWait()
     Like  Bookmark
  • https://docs.legato.io/latest/c_threading.html https://docs.legato.io/latest/le__thread_8h.html Legato Thraed 基本使用流程 image2024-9-19_15-11-38 Legato Thread 基本使用流程如上圖所示。 一個 worker thread 有三種可能的原因結束:
     Like  Bookmark
  • https://docs.legato.io/latest/c_timer.html https://docs.legato.io/latest/le__timer_8h.html Legato Timer 基本使用流程 用 le_timer_Create 來建立每個 timer,並且取得該 timer 的 reference le_timer_Ref_t 在 timer 被啟動前,設定 timer 的 attributes:le_timer_SetHandler設定當 timer 到期後,要執行哪個 timer expiry handler function timer expiry handler function 的 prototype:typedef void (*le_timer_ExpiryHandler_t) ( le_timer_Ref_t timerRef ) le_timer_SetInterval() (or le_timer_SetMsInterval())
     Like  Bookmark
  • https://docs.legato.io/latest/c_eventLoop.html https://docs.legato.io/latest/le__eventLoop_8h.html Legato Event Loop 基本介紹 Legato Event Loop API 支援 event-driven programming。 每個 Legato thread 都會有一個 Event Loop,而每個 Event Loop 裡面都會有一個 Event Queue。當 Event Queue 裡面的 Event 到達了 Queue 的 front,就會處理該 Event(也就是執行其 handler function)。 Legato 的 event 是用 Event ID(le_event_Id_t)來識別每一個 event,我們要使用 le_event_CreateId() 來建立 event。
     Like  Bookmark
  • 紀錄在 VirtualBox 安裝 Ubuntu 18.04 的過程,以及設定共享資料夾及開啟複製貼上功能 Installing VirtualBox 至 VirtualBox 官網下載安裝檔~ https://www.virtualbox.org/wiki/Downloads 我的桌機是 Ubuntu 24.04,就到 VirtualBox 官網下載相對應的 VirtualBox 安裝檔: https://www.virtualbox.org/wiki/Linux_Downloads image
     Like  Bookmark