最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

01-對readme.md的搬運和翻譯

2023-07-24 09:10 作者:Xdz-2333  | 我要投稿

本文是對Readme.md文件的翻譯,原文放在文章最后,GitHub地址在上一篇文章中.

下面的非黑色字體都是我自己加上去的

給樹莓派"裸機"寫一個操作系統(tǒng)

簡介

? ? ? ? 作為RealVNC的技術(shù)CEO,我不再寫代碼了.但是最近我意識到了我是多么的懷念它.

? ? ? ? 由于最近新冠疫情導(dǎo)致的全國性的"封鎖",(我也因此不用通勤了),我發(fā)現(xiàn)我一天多出來了幾個小時.我把這段時間留給自己,并且用來實現(xiàn)我兒時的目標--寫一個可以在商用的硬件上寫一個裸機操作系統(tǒng).

"裸機"是什么意思

? ? ? ? 當我們買電腦,平板或者手機的時候,里面經(jīng)常會預(yù)裝一些軟件.當你第一次啟動設(shè)備時,你應(yīng)該會對看到Windows,Mac OS,IOS和安卓甚至Linux感到很熟悉.這些都是操作系統(tǒng)--為你和我這種普通人而把電腦芯片變?yōu)榭梢蚤_箱即用所設(shè)計的軟件.它們通過在屏幕上繪制圖案,處理來自像鍵盤和鼠標等設(shè)備的信息,使用網(wǎng)絡(luò)設(shè)備將你的電腦連接到網(wǎng)上,允許我們播放聲音等許多工作來幫助我們和設(shè)備進行交互.

????????世界上的程序員開發(fā)能運行在操作系統(tǒng)之上的軟件.這些軟件通過操作系統(tǒng)與硬件打交道,這樣這些復(fù)雜的代碼就不用一遍又一遍的被實現(xiàn).結(jié)果就是對硬件不怎么了解也可以稱為一個程序員.操作系統(tǒng)做了最困難的工作才讓我們用上了像臉書,Instagram, WhatsApp, TikTok這樣的軟件.

????????可以說沒有操作系統(tǒng),計算機硬件做不了什么有用的事.它們只是坐在這然后等待命令.所以,為什么只有軟件巨頭們像微軟,蘋果,谷歌來告訴大多數(shù)電腦它們啟動的時候應(yīng)該怎么做呢?我們不行嗎?當然,我們可以,這就是裸機編程.

硬件的選擇

????????如果你對可以告訴計算機去做什么感到興奮,那么你需要對硬件有一定的興趣.要完成你的任務(wù)的電腦芯片叫作CPU(中央處理單元)--它是每個計算機設(shè)備跳動的心臟.多年來,許多公司都設(shè)計了這樣的CPU,但是只有AMD和Intel兩家的CPU被廣泛采用.這些芯片都有它們的優(yōu)點和缺點.如果你有智能手機,它們大概率在ARM設(shè)計的芯片上運行.如果你有臺運行Windows的筆記本,那么它大概率運行在Intel的芯片上.你會想對兩種架構(gòu)最終都能有所了解,但是我為這個項目選擇了ARM公司的設(shè)備.

????????最新的樹莓派4B是一款低功耗電腦,有1.5G四核64位A72處理器.這是一款世界上數(shù)百萬人都在用的設(shè)備,所以為其編寫裸機代碼是非常令人興奮的事情.想象一下某人某天可能用你寫的操作系統(tǒng)!樹莓派還有一些有用的附加硬件可以在這一過程中幫助我們.

硬件要求

????????你需要一些硬件來開始編寫你的操作系統(tǒng):

????????1.帶有專用電源線的樹莓派和HDMI線

????????2.一個通過HDMI與樹莓派相連的顯示屏 / TV

????????3.用來啟動樹莓派的micro-SD卡

????????4.一個用來開編寫代碼的電腦,比如Windows或者Mac 筆記本(開發(fā)設(shè)備)

????????你需要確認你能用你的開發(fā)設(shè)備讀寫micro-SD卡.對我來講,這意味著要買一個SD卡讀適配器,因為micro-SD卡對于我筆記本電腦的插槽來講太小了.你也可能需要一個,甚至一個USB SD卡讀寫器,如果你的電腦沒有內(nèi)置的話.

????????其他十分有用的硬件,你離開它你甚至不能工作:

????????1.一副眉毛鑷子(我從我妻子那里借來的!)-對從樹莓派的插槽里面插入或者拔出micro-SD卡很有用

????????2.一根USB轉(zhuǎn)TTL線,在你的操作系統(tǒng)把信息顯示在屏幕上之前你可以看到它在做什么

軟件要求

  如果你不能使其他人的操作系統(tǒng)運行,那么你就寫不了自己的操作系統(tǒng).所以我用Raspbian--樹莓派官網(wǎng)推薦的操作系統(tǒng).我使用了它們網(wǎng)站上提供的,非常簡潔的鏡像制作工具來做到完成.

????????連接好您的樹莓派4并且確保它啟動到了Raspbian.網(wǎng)上有很多資源來幫助你完整這件事.啟動Raspbian能測試你的硬件設(shè)置是否正常工作.注意:因為我把樹莓派連接到我的(不明亮的)TV,我需要在SD卡中的config.txt 文件里面進行編輯(設(shè)置hdmi_safe=1)來確保我能看到屏幕.沒有這個,它就不亮.如果你仍然遇到了問題,去查看樹莓派網(wǎng)站上config.txt其他選項的視頻.

????????在Raspbian運行之前不要繼續(xù)!

????????樹莓派4在ARM的A72處理器上運行,而你的電腦大大概率運行在Intel的處理器上.因此你需要一些軟件來幫助你編譯代碼以運行在不同的架構(gòu)上.這叫做交叉編譯.

在Linux上使用ARM的編譯器

????????下載并解壓ARM的gcc編譯器.由于某些原因,我不會在這里詳細展開,你需要使用"AArch64 ELF bare-metal target".因為我使用Windows10的WSL來模擬Ubuntu,我下載了x86_64 Linux 的交叉編譯器.

????????我也提倡安裝GNU make - 你待會就會需要它的.因為我用WSL,所以我只用打出"sudo apt install make" 然后輸入我的密碼.

在MAC OS X 上使用 Clang (蘋果芯片或者Intel的芯片)

????????從應(yīng)用商店下載并安裝 XCode.它將給你提供大量的開發(fā)工具,包括make.我推薦使用 Homebrew來安裝LLVM,對于我,Homebrew應(yīng)安裝好了,所以我只要敲下"brew install llvm"

????????LLVM可以滿足你對于使用MAC在樹莓派裸機上編程的所有需求.它甚至可以在我的運行在蘋果芯片上的M1 Macbook pro上運行.這臺電腦運行ARM的處理器而不是Intel的.

直接在樹莓派4上編譯

????????你可以從這里閱讀關(guān)于在樹莓派上編譯的更多信息.(見下一篇PRI-BUILD.md的翻譯)

????????現(xiàn)在你可以去寫自己的操作系統(tǒng)了.

致謝

???????這些代碼并非都是我的原創(chuàng)產(chǎn)品,而是收到其他杰出的貢獻者啟發(fā)和整理的.

感謝:

????????Zoltan Baldaszti的“裸機樹莓派3教程”(github)????https://github.com/bztsrc/raspi3-tutorial

? ? ? ? 如果你也想在這里得到認可,請聯(lián)系我們!



Writing a "bare metal" operating system for Raspberry Pi 4


Introduction

As a tech CEO @RealVNC, I don't write code any more. And I've recently realised just how much I miss it.


Currently in the throes of a nationwide "lockdown" due to Covid-19 (and having been spared my usual commute), I've found myself with more hours in the day. I have taken this time for myself and used it to fulfil a childhood ambition - to write a **bare metal** operating system that runs on commercial hardware.


What does bare metal mean?

When we buy a computer or a tablet/smartphone it typically comes with some basic software pre-installed. You'll likely be familiar with watching Microsoft Windows, Mac OS, iOS, Android or maybe even Linux start up as you power the device (or **boot** it) for the first time. These are all operating systems - software designed to make computer chips work out of the box for mere mortals like you and me. They help us interact with the machine by drawing to a screen, processing messages from devices like keyboards & mice, working with networking hardware to connect you to the Internet, allowing us to playback sound and much, much more.


Software developers around the world then build applications (apps) that run on top of these operating systems. These apps talk to the hardware via the operating system (**OS**), so this complex code doesn't have to be written over and over again. As a result, it's possible to be a software developer without knowing much about hardware at all! It's the OS that does the hard work that allows us to use apps like Facebook, Instagram, WhatsApp, TikTok etc.


It's fair to say that _computers can't do anything useful without an OS_. They just sit there waiting to be told what to do. So, why is it that only software giants like Microsoft, Apple and Google get to tell the majority of computers what to do as they're being switched on? Why can't we? Well, we can, and that is what bare metal programming is.


Choice of hardware

If you're excited by the prospect of telling a computer what to do then you need an interest in hardware. The computer chip that's going to do your bidding is called a **CPU** (Central Processing Unit) - it's the beating heart of every computer device. Lots of companies have designed such CPUs over the years, but two - Intel and Arm - are most widely adopted. These each have their advantages and disadvantages. If you own a smartphone, it's highly likely that it's running on a chip designed by Arm. If you own a laptop running Microsoft Windows then it's likely to be running on an Intel chip. You'll want to develop an understanding of both **architectures** eventually, but I've chosen an Arm device for this project.


The new [Raspberry Pi 4 Model B](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/) is a low-cost computer that runs on a 1.5 GHz 64-bit quad-core Arm Cortex-A72 processor. It's a device that many millions of people worldwide use, and so it's exciting to write bare metal code for it. Imagine that somebody else might one day use your OS! The **RPi4** also has some useful attached hardware that will help us along the way.


Hardware prerequisites

You'll need some hardware to get started with writing your OS:


?* An RPi4 with a dedicated power supply and HDMI lead

?* A monitor/TV connected to the RPi4 via HDMI

?* A micro-SD card to boot the RPi4 from

?* A computer to write your code on e.g. a Windows/Mac laptop (the **dev machine**)


You'll need to make sure that you can write to the micro-SD card using your dev machine. For me, that meant buying an SD card adapter, because the micro-SD card was too small for the slot in my laptop. You may need the same, or even a USB SD card reader too if your laptop doesn't have one built-in.


Other incredibly useful hardware that you simply can't do without:


?* A pair of eyebrow tweezers (I borrowed these from my wife!) - useful to insert/remove the micro-SD card into the tiny slot on the RPi4

?* A [USB to serial TTL cable](https://www.amazon.co.uk/gp/product/B01N4X3BJB/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1) - useful to see what your OS is doing long before you can write information to the screen


Software prerequisites

If you can't get someone else's OS running, you likely won't be able to write your own. So I started by flashing the SD card with Raspbian - Raspberry Pi's recommended OS. I used the very neat [Imager tool](https://www.raspberrypi.org/downloads/) that they make available on their website to do this.


Hook up your RPi4 and make sure it boots into Raspbian. There are plenty of resources online to help you achieve/troubleshoot this. Getting Raspbian up will test that your hardware setup is working properly. Note: because I connected my RPi4 to my (not brilliant) TV, I needed to make an edit in the _config.txt_ file on the SD card (setting the `hdmi_safe` parameter to 1) to ensure that I could see the screen. Without that, it was just black. If you're still having trouble, check out the other _config.txt_ video options [here on the Raspberry Pi website](https://www.raspberrypi.com/documentation/computers/config_txt.html#video-options).


Don't proceed until you get Raspbian running!


The RPi4 runs on an Arm Cortex-A72 processor. Your dev machine is likely running on an Intel processor. You'll therefore need some software that helps you build code to run on a different architecture. This is called a **cross-compiler**.


Using Arm's compiler for Linux

Download and unpack [Arm's gcc compiler](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads). For reasons that I won't go into here, you'll need to use the "AArch64 ELF bare-metal target". Since I'm using WSL on Windows 10 to emulate Ubuntu, I downloaded the x86_64 Linux hosted cross-compiler.


I also advocate installing GNU make - you'll need it soon enough. Because I'm using WSL, for me that was simply a matter of typing `sudo apt install make` and entering my password.


Using clang on Mac OS X (Apple Silicon or Intel)

Download and install XCode from the App Store. This will give you a raft of developer tools for free, including `make`.


I recommend using [Homebrew](https://docs.brew.sh/Installation) to install LLVM. For me, Homebrew was already installed, so this was a simple case of typing `brew install llvm`.


LLVM will give you all you need to start building for Raspberry Pi bare metal on Mac. It even works on my M1 MacBook Pro with Apple Silicon, which runs an ARM processor rather than an Intel processsor.


Building directly on a Raspberry Pi 4

You can read more about how to build on the Pi itself [here](./RPI-BUILD.md).


_Now you're ready to start writing your OS!_


[Go to part1-bootstrapping >](./part1-bootstrapping/)


Acknowledgements

Not all of the code here is my original work, but has been collated from and inspired by some fantastic contributors.


Thanks go to:


?* Zoltan Baldaszti's "Bare metal Raspberry Pi 3 tutorials" [(github)](https://github.com/bztsrc/raspi3-tutorial/)


Do reach out if you would like to be acknowledged here too!


????????

01-對readme.md的搬運和翻譯的評論 (共 條)

分享到微博請遵守國家法律
晋江市| 高碑店市| 巴南区| 安远县| 辰溪县| 龙岩市| 北安市| 镇宁| 高邑县| 调兵山市| 连云港市| 公主岭市| 南溪县| 郴州市| 泊头市| 长岛县| 穆棱市| 柳江县| 青川县| 巨野县| 集贤县| 合江县| 淮南市| 班戈县| 尼玛县| 邹平县| 涞水县| 遵义县| 日照市| 西畴县| 普宁市| 扎赉特旗| 铜梁县| 安图县| 宣威市| 广河县| 耿马| 响水县| 宁德市| 连城县| 长海县|