For students who want to learn ARM assembly, using an ARM development board is a common and effective approach. However, purchasing such a board can be costly, and setting it up for each test is time-consuming and inconvenient. To overcome these challenges, we can use an ARM simulator called SkyEye. With SkyEye, you can develop and debug ARM assembly code directly on your PC, eliminating the need for physical hardware. It's a powerful and convenient tool!
Here’s how to get started with SkyEye:
1. **Download SkyEye**:
Visit the official SourceForge page (https://sourceforge.net/projects/skyeye/) to download the latest version of SkyEye. For this tutorial, we'll use `skyeye-1.3.4_rc1.tar.gz`. Additionally, download the `skyeye-testsuite-1.3.4` package, which includes example programs like `arm_hello` and the `ArmLinux` test environment.
2. **Install SkyEye**:
Extract the downloaded files and follow the installation steps.
```bash
$ tar zxvf skyeye-1.3.4_rc1.tar.gz
$ cd skyeye-1.3.4_rc1
```
Then run the following commands:
```bash
$ ./configure
$ make lib
$ make
$ sudo make install
$ sudo make install_lib
```
If you encounter missing dependencies, install them using `apt-get`. For example:
```bash
$ sudo apt-get install python-dev
$ sudo apt-get install llvm
```
3. **Set Environment Variables**:
By default, SkyEye is installed in `/opt/`. To make it easier to access, add its path to your `.bashrc` file:
```bash
# Add to ~/.bashrc
export PATH=/opt/skyeye/bin:$PATH
```
After saving, apply the changes by running:
```bash
$ source ~/.bashrc
```
4. **Run the arm_hello Test Program**:
The `arm_hello` program is located in `/opt/skyeye/testsuite/arm_hello`. Navigate to that directory and run:
```bash
$ cd /opt/skyeye/testsuite/arm_hello
$ skyeye -e arm_hello
```
You will enter the SkyEye command mode. Type `start` to begin execution, and a terminal window will appear showing "helloworld" being printed continuously.
5. **Explore Other Commands**:
In the SkyEye command line, you can:
- `stop`: to stop the program.
- `quit`: to exit SkyEye.
- `help`: to view available commands.
6. **Simulate Linux on SkyEye**:
To simulate a full Linux environment, extract the `skyeye-testsuite-1.3.4_rc1.tar.gz` package. Inside, there's a `linux/s3c2410/s3c2410x-2.6.36` folder containing `vmlinux`, `skyeye.conf`, and `initrd.img`. Copy these into a new directory:
```bash
$ sudo mkdir /opt/skyeye/testsuite/armlinux
$ sudo cp linux/s3c2410/s3c2410x-2.6.36/* /opt/skyeye/testsuite/armlinux/
```
Then run:
```bash
$ cd /opt/skyeye/testsuite/armlinux
$ skyeye -e vmlinux
```
If the serial port doesn't open, modify `uart:mod=stdio` to `uart:mod=term` in `skyeye.conf`.
7. **Create a Custom Application**:
Let's create a simple C program called `myhello.c` that outputs 'a' continuously:
```c
#define INTERVAL 100000
void myhello(void) {
long *addr = (long *)0x50000020;
int timeout = 0;
while(1) {
timeout = 0;
while(++timeout <= INTERVAL);
*addr = 'a';
}
}
```
This writes to the UART buffer, which is displayed on the screen in the simulator.
8. **Write a Startup File**:
Create a `start.S` file that jumps to the `myhello` function:
```asm
.text
.align 4
.global _start
_start:
ldr sp, =1024*4
bl myhello
halt:
b halt
```
9. **Link Script**:
Create a `myhello.lds` file to define the memory layout:
```ld
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS {
. = 0x00000000;
.text : {
start.o
myhello.o
*(.rodata)
}
. = ALIGN(8192);
.data : {*(.data)}
.bss : {*(.bss)}
}
```
10. **Makefile**:
Define build rules in a `Makefile`:
```makefile
CC=arm-linux-gcc
LD=arm-linux-ld
CFLAGS= -c -g -march=armv4 -mtune=arm920t
LDFLAGS= -N -p -X -Tmyhello.lds
myhello: start.o myhello.o
$(LD) $(LDFLAGS) start.o myhello.o -o myhello
start.o: start.S
$(CC) $(CFLAGS) start.S
myhello.o: myhello.c
$(CC) $(CFLAGS) myhello.c
clean:
rm -rf *.o myhello *.s *.r *.n
```
11. **SkyEye Configuration**:
Create a `skyeye.conf` file to configure the simulation:
```conf
Arch:arm
Cpu: arm920t
Mach: s3c2410x
Mem_bank: map=M, type=RW, addr=0x00000000, size=0x04000000, boot=yes
Mem_bank: map=M, type=RW, addr=0x30000000, size=0x02000000
Mem_bank: map=I, type=RW, addr=0x48000000, size=0x20000000
Uart:mod=stdio
```
12. **Compile and Run**:
Navigate to the `myhello` directory and run:
```bash
$ cd /opt/skyeye/testsuite/myhello
$ make
$ skyeye -e myhello
```
Enter the SkyEye command mode and type `start` followed by `run`. You should see the character 'a' being printed repeatedly.
**Note**: Pay attention to the Makefile flags and the `skyeye.conf` settings. Adjusting these can improve performance or fix issues like UART output problems.
Bang Bc5000 Einweg Vape Pen,Cheap Bang Energy Drink,Bang Bc5000 Box 5000 Puffs
Longhua Manxueling Trading Company , https://www.mxlvape.com