VirtualBox 網路模式整體來分有4種
而NAT可對外部網路連線, 但對本機則需要透過port轉送的設定才可以完成連線, 內部網路和未附加則是無法對外部網路連線
在實體主機產生一張橋接介面網路卡, 讓虛擬機器經由這個網卡連接上外部網路
當已經建好橋接網路就可以開始進行虛擬機器的設定了,
設定值 -> 網路 -> 啟用網路卡 -> [附加到]網路介面卡
PS. 當名稱的欄位是未選取表示bridge沒有設定成功!!
!!! 但我認為應該還有其他方法可以解決這個問題 想到新的idea再來嘗試看看
這陣子程式量偏多又苦於沒有硬體和Debugger工具可以測試軟體的安全性, 想起過去看到成大資工系的piko-rt專案使用make做build時可以順便做測試, 覺得這個方法很不錯所以特地撥空寫了這個筆記文
Makefile格式是由目標(target),相依檔案(filename),和規則(rule)組成, 必須注意規則前面的空白是tab
# <target>: <filename>
# <rule>
all: main.c
gcc main.c -o main.o
當專案的檔案非常多的時候, 檔案的相依性會變得非常多打起來非常麻煩, 使用macro可以更方便的修改資料, 還有一些參數設定等等功能
# 宣告
變數名稱 = 變數資料
# 呼叫
$(變數名稱)
還有一個不錯的功能, 假設有個.c檔案編譯之後會產生一個.o檔案, 這時候可以用這個方法直接幫macro宣告過的檔案全部換副檔名
SOURCE = aa.c bb.c cc.c
OBJECT = $(SOURCE:.c=.o)
# 這時候 $(OBJECT) 就是 aa.o bb.o cc.o 了
符號 | 功能 |
---|---|
$< | 屬於第一個相依項目 |
$@ | 當前目標相依項目 |
屬於第一個相依的項目
test: main.c main.h
gcc -c $<
則編譯時會變成
gcc -c main.c
當前目標相依項目
test: main.c main.h
gcc -c $< -o $@
則編譯時期會變成
gcc -c main.c -o test.exe # windows mingw32
gcc -c main.c -o test # Linux gcc
兩三個月前寫了一篇windows的燒錄筆記(Link), 最近有空也把linux上的dfu燒錄方法做一下紀錄
我使用的 Linux 發行版是 ubuntu , 這個燒錄的套件是 dfu-util
sudo apt-get install dfu-util
為了確保stm32的usb正常運作, 可以透過 lsusb
來檢查usb運作的狀態
lsusb
看到 [STMicroelectronics STM Device in DFU Mode] 表示進入DFU模式了, 成功之後可以進行下一個動作了
Bus 001 Device 013: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
備註: 我插在 USB3.0 的 Port 時常常會斷線, 後來改用 USB2.0 的 Port 就沒問題了
dfu-util 支援 .bin
和 .dfu
的燒錄
燒錄資訊
sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D stm32_demo.bin
user@ubuntu:~$ sudo apt-get install dfu-util
[sudo] password for user:
... 省略 ...
user@ubuntu:~$ cd stm32_demo/
user@ubuntu:~/stm32_demo$ ls
stm32_demo.bin # 其他檔案省略
user@ubuntu:~/stm32_demo$ lsusb
Bus 001 Device 013: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
... 省略 ...
user@ubuntu:~/stm32_demo$ sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D stm32_demo.bin
dfu-util 0.8
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08000000, size = 4696
Download [=========================] 100% 4696 bytes
Download done.
File downloaded successfully
# 完成!
https://wiki.bitcraze.io/projects:crazyflie2:development:dfu
Git 版本控制 可以紀錄每個提交, 過去沒接觸到版本控制之前只用壓縮檔案備份檔案常常發現一些問題, 除了無法得知某個壓縮檔當時備份時修改過甚麼, 還有檔案多人共用的時候回復檔案後也常常發現資料有衝突不知道哪個檔案最終版本是甚麼, 發現版本控制之後可以解決這些問題, 不只可以多人共同工作每個提交(備份)都會有一筆紀錄, 發現程式檔案毀掉的時候可以用以前提交的紀錄來進行資料回復
檔案修改後將加入暫存區, 作法有2種
加入這個目錄下的所有被變更的檔案
git add .
加入指定檔案
git add <file_name>
工作告一段落之後提交一個紀錄, 這個提交只會紀錄有被追蹤的檔案
使用Command Line來操作系統中的檔案
開始之前, 必須先了解位置表示法中的幾個符號的意義
符號 | 意義 |
---|---|
/ | 根目錄 |
. | 當前目錄 |
.. | 上一層目錄 |
~ | 家目錄 |
/
.
..
~
~
表示, 因此再不同的使用者 ~
位置都不一樣, 大部份的使用者家目錄都位於 /home
中, 但root就是個例外root的家目錄是/root絕對路徑和相對路徑的差異
/
.
, ..
或 ~
就是相對路徑ls
顯示出目錄中的所有檔案user@server:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
當要找出隱藏檔案時可以加入參數 a
user@server:~$ ls -a
. .. .ssh Desktop Documents Downloads Music Pictures Public Templates Videos
想要將所有目錄樹顯示可以加入參數 R
user@server:~$ ls -R
.:
Desktop Documents Downloads Music Pictures Public Templates Videos
./Desktop
./Documents
books.pdf mydoc.odf
./Downloads
./Music
music.mp3
./Pictures
./Public
./Templates
./Videos
vedio.mp4
pwd
查詢現在所在目錄查詢所在目錄的指令是 pwd
, 這個指令會完整的顯示出目前所在位置的絕對路徑
user@server:~$ pwd
/home/user # 這邊顯示出我們正在user這個目錄中
cd
切換目錄切換目錄的指令是 cd
, 這個指令可以為我們切換到我們要求的地方
user@server:~$ pwd
/home/user # 現在位置是user的家目錄
user@server:~$ cd /tmp # 切換到/tmp
user@server:/tmp$ pwd
/tmp # 成功切換到/tmp
user@server:~$ pwd
/home/user # 現在位置
user@server:~$ cd .. # 切換到上一層目錄
user@server:/home$ pwd
/home # 現在位置/home
~
切換回家目錄user@server:/home$ pwd
/home # 現在位置
user@server:/homr$ cd ~ # 切換到上一層目錄
user@server:~$ pwd
/home/user # 現在位置/home
mkdir
建立目錄user@server:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ mkdir newdir
newdir Desktop Documents Downloads Music Pictures Public Templates Videos
touch
建立一個空白檔案檔案不存在時使用touch
會建立一個檔案
user@server:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ touch abc.txt
user@server:~$ ls
abc.txt Desktop Documents Downloads Music Pictures Public Templates Videos
mv
移動檔案/目錄mv 可以用來搬移檔案或搬移目錄, 搬移時可以指定新的名字或是使用.
來沿用舊名
mv <移動的檔案> <新位置or新名字>
user@server:~$ ls
abc.txt Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ mv abc.txt /tmp/.
user@server:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ cd /tmp
user@server:/tmp$ pwd
/tmp
user@server:~$ ls
abc.txt
user@server:~$ ls
abc.txt Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ mv abc.txt /tmp/aaa.txt
user@server:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ cd /tmp
user@server:/tmp$ pwd
/tmp
user@server:~$ ls
aaa.txt
cp
複製檔案mv 複製時可以指定新的名字或是使用.
來沿用舊名, 但複製目錄的時候要加上參數R
cp <複製目標> <新檔案>
cp -R <複製目標> <新檔案>
user@server:~$ ls
abc.txt Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ cp abc.txt /tmp/.
user@server:~$ ls
abc.txt Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ cd /tmp
user@server:/tmp$ pwd
/tmp
user@server:~$ ls
abc.txt
user@server:~$ ls
abc.txt Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ mv abc.txt /tmp/aaa.txt
user@server:~$ ls
abc.txt Desktop Documents Downloads Music Pictures Public Templates Videos
user@server:~$ cd /tmp
user@server:/tmp$ pwd
/tmp
user@server:~$ ls
aaa.txt
Git 是現在很流行的版本控制系統, 2005年Linus Torvalds為了更方便的管理Linux Kernel 開發而設計出來的, 目前由Git團隊維護中
# Debian/Ubuntu系列
root@server:~$ apt-get install git
# RedHat/Fedora系列
root@server:~$ yum install git-core
當我們一個專案的目錄需要進行版本控制的時候可以使用init
指令來建立一個新的儲存庫,
PS. 此範例使用的目錄是~/project
user@localhost:~/project$ git init
當我們要複製一個專案下來本地端進行修改時可以用clone這個指令
# 請將clone路徑改為您的路徑
user@server:~$ git https://github.com/yuhao-kuo/test.git
# ^^^^^^^^^^^ clone 路徑 ^^^^^^^^^^^^^^