嵌入式学习笔记(1)虚拟机和主机相互ping通

嵌入式学习笔记(1)虚拟机和主机相互ping通


最近又在重新倒腾嵌入式软件开发,没想到第一步就卡住了,还卡了好几天,太菜太菜了,索性干脆写个学习笔记,记录一下遇到的各种奇葩问题。
进入正题,这篇文章大致写了ping通的完整步骤,后续附加了几个我遇到的问题和解决方案。

概念

首先理一下概念

  • 宿主机:你用的Windows主机,如果用Linux系统作为主力机,忽略
  • 虚拟机:在VMWare/VirtualBox中安装的Linux操作系统
  • 目标机:你的嵌入式开发板

完整步骤

首先要安装好虚拟机和Linux操作系统

这没啥好说的,答主用的VirtualBox(体积不大、运行速度快,个人感觉比VMWare好用)+Ubuntu12(Ubuntu12这个版本比较稳定,后面的16、18版本实在没力气折腾了)

  • 设置好虚拟机的网络连接方式
    VirtualBox:控制 -> 设置 -> 网络 -> 连接方式设置为桥接网卡 -> 界面名称设置为PCIe接口的那个(这个应该没啥影响) 在这里插入图片描述

设置好虚拟机的静态IP地址

  • Ubuntu12:系统设置 -> 网络 -> 有线选项 -> IPv4设置
  • 我这里网关设置的是192.168.1.1,虚拟机IP设置为192.168.1.2,根据自己需要设置,只要在一个网段内就可以保证互相ping通在这里插入图片描述

设置好宿主机的静态IP地址

  • 这里有几个坑:
    1.一定要分清Win10分配的以太网,和VirtualBox分配的以太网
    2.Win10分配的以太网一定要插上网线才能打开
    3.VirtualBox的以太网IP,一定要和之前虚拟机里面设置的一样
    在这里插入图片描述

  • 1.网络连接 -> 以太网属性 -> 以太网属性(宿主机)-> Internet协议版本4 -> 手动设置IP为192.168.1.3
    在这里插入图片描述

  • 2.网络连接 -> VirtualBox网络属性 ->Internet协议版本4 -> 手动置IP为192.168.1.2(与前面设置一样)
    在这里插入图片描述

测试虚拟机和宿主机能否互相ping通

  • Window10:打开CMD,输入:ping 192.168.1.2在这里插入图片描述
  • Ubuntu12:打开终端,输入:ping 192.168.1.3
    在这里插入图片描述

遇到的各种坑(慢慢补充)

  • Windows10防火墙没关,导致虚拟机ping不通宿主机
  • Ubuntu防火墙没关,导致宿主机ping不通虚拟机
  • WindowsDefender 防火墙,ICMPv4规则没修改,解决:防火墙->高级设置->文件和打印机共享-回显请求-ICMPv4-In ->允许规则
  • 有时ubuntu更改设置之后无法及时生效,要重启网络
CarpVM 是一个用 C 语言编写的小型虚拟机。可以嵌入在应用程序中使用。 包含的指令集有: HALT (code): Halts and attempts to clean up stack, data memory, and label memory before exiting with given exit code. NOP (): Does nothing. Seriously. LOAD (reg, val): Loads given integer value into given register. MOV (dst, src): Copies contents of src register into dst register. ADD (): Pops the top two integers from the stack and pushes their sum. SUB (): Pops the top two integers from the stack and pushes the difference (lower minus upper). MUL (): Pops the top two integers from the stack and pushes their product. MOD (rega, regb): Computes rega % regb and stores in ERX. NOT (reg): Computes bitwise NOT of reg and stores in reg. XOR (): Pops the top two integers from the stack and XORs them. OR (): Pops the top two integers from the stack and ORs them. AND (): Pops the top two integers from the stack and ANDs them. INCR (reg): Increments value in given register. DECR (reg): Decrements value in given register. INC (): Increments the value at the top of the stack. DEC (): Decrements the value at the top of the stack. PUSHR (reg): Pushes value in given register. PUSH (val): Pushes given value. POP (val): Pops an integer from the stack and dumps it into GBG. CMP (): Pops the top two integers from the stack and checks if equal. 0 means equal. Result will be pushed onto the stack. MOV (rega, regb): Move value in rega to regb. JZ (addr): Jumps to given absolute address if top of the stack is 0. RJZ (diff): Adds differential to current EIP (relative jump) if top of the stack is 0. JNZ (addr): Jumps to given absolute address if top of the stack is not 0. RJNZ (diff): Adds differential to current EIP (relative jump) if top of the stack is not 0. JMP (addr): Jumps to given absolute address. RJMP (diff): Adds differential to current EIP (relative jump). DBS (key, val): Sets data memory at key (string pointer) to given value. DBG (key, reg): Gets value from data memory at key (string pointer) and dumps it into given register. CALL (key, nargs): Save state and set EIP to value in data memory at key. RET (val): Push return value and load state. PREG (reg): Prints contents of given register. PTOP (): Peeks top of stack and prints top value. 标签:CarpVM
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值