devos50 / qemu-ios

A QEMU emulator for legacy Apple devices
Other
865 stars 63 forks source link

SIGSEV trying to emulate iPod 2g #136

Open datawater opened 5 months ago

datawater commented 5 months ago

How to replicate

Uname

Linux fedora 6.6.13-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Jan 20 18:03:28 UTC 2024 x86_64 GNU/Linux

Grab the source code

git clone https://github.com/devos50/qemu-ios/
git checkout ipod_touch_2g
git pull

Build

mkdir build
cd build

../configure --enable-sdl --disable-cocoa --target-list=arm-softmmu --disable-capstone --disable-pie --disable-slirp --extra-cflags='-I/usr/include/openssl/ -Wno-error' --extra-ldflags='-L/usr/lib64/ -lcrypto'
make -j4

Download system files

cd ../
mkdir ipodtouch2g
cd ipodtouch2g

wget https://github.com/devos50/qemu-ios/releases/download/n72ap_v1/nor_n72ap.bin
wget https://github.com/devos50/qemu-ios/releases/download/n72ap_v1/nand_n72ap.zip
wget https://github.com/devos50/qemu-ios/releases/download/n72ap_v1/bootrom_240_4

unzip nand_n72ap.zip

Run

../build/arm-softmmu/qemu-system-arm -M iPod-Touch,bootrom=bootrom_240_4,nand=nand -serial mon:stdio -cpu max -m 1G -d unimp -pflash nor_n72ap.

Output:

WARNING: Image format was not specified for 'nor_n72ap.bin' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
fish: Job 1, '../build/arm-softmmu/qemu-syste…' terminated by signal SIGSEGV (Address boundary error)

After running gdb I found where the SIGSEGV happens

(gdb) r -M iPod-Touch,bootrom=bootrom_240_4,nand=nand -serial mon:stdio -m 1G -d unimp -pflash nor_n72ap.bin
Starting program: /home/datawater/Desktop/Programming/third-party/qemu/build/arm-softmmu/qemu-system-arm -M iPod-Touch,bootrom=bootrom_240_4,nand=nand -serial mon:stdio -m 1G -d unimp -pflash nor_n72ap.bin
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff53186c0 (LWP 33389)]
[New Thread 0x7ffff4a166c0 (LWP 33390)]
[New Thread 0x7fffeffff6c0 (LWP 33391)]
[New Thread 0x7fffef7fe6c0 (LWP 33392)]
[New Thread 0x7fffeeffd6c0 (LWP 33393)]
[New Thread 0x7fffee7fc6c0 (LWP 33394)]
[New Thread 0x7fffeda736c0 (LWP 33395)]
WARNING: Image format was not specified for 'nor_n72ap.bin' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
[New Thread 0x7fffed0706c0 (LWP 33396)]

Thread 1 "qemu-system-arm" received signal SIGSEGV, Segmentation fault.
0x00000000007a140a in s5l8900_get_irq (n=<optimized out>, s=<optimized out>) at ../hw/arm/ipod_touch_2g.c:174
174     return s->irq[n / S5L8720_VIC_SIZE][n % S5L8720_VIC_SIZE];
MrDiagnose commented 5 months ago

try this ./configure --enable-sdl --disable-cocoa --target-list=arm-softmmu --disable-capstone --disable-slirp --extra-cflags=-I/usr/include/openssl --extra-ldflags='-lcrypto' --disable-werror --enable-pie

datawater commented 5 months ago

try this ./configure --enable-sdl --disable-cocoa --target-list=arm-softmmu --disable-capstone --disable-slirp --extra-cflags=-I/usr/include/openssl --extra-ldflags='-lcrypto' --disable-werror --enable-pie

Doesn't seem to solve the issue :(

MrDiagnose commented 5 months ago

try this ./configure --enable-sdl --disable-cocoa --target-list=arm-softmmu --disable-capstone --disable-slirp --extra-cflags=-I/usr/include/openssl --extra-ldflags='-lcrypto' --disable-werror --enable-pie

Doesn't seem to solve the issue :(

./qemu-system-arm -M iPod-Touch,bootrom=bootrom_240_4,nand=nand,nor=nor_n72ap.bin -serial mon:stdio -cpu max -m 2G -d unimp

datawater commented 5 months ago

still nope, crashes at the exact same place, doesn't spew out the warning anymore though!

MrDiagnose commented 5 months ago

It must be Linux Fedora Issue 🤔 This is what worked for me on Linux/Ubuntu

  1. sudo apt update sudo apt upgrade sudo apt install make ninja-build pkg-config libssl-dev libsdl2-dev libpixman-1-dev libpixman-1-0 libglib2.0-dev

  2. git clone https://github.com/devos50/qemu-ios.git

  3. cd qemu-ios

  4. ./configure --enable-sdl --disable-cocoa --target-list=arm-softmmu --disable-capstone --disable-slirp --extra-cflags=-I/usr/include/openssl --extra-ldflags='-lcrypto' --disable-werror --enable-pie

  5. make -j(assign number of cpu cores)

  6. cd build/arm-softmmu and copy bootrom, nand(after extracting it) & nor files here (https://github.com/devos50/qemu-ios/releases/tag/n72ap_v1)

  7. run./qemu-system-arm -M iPod-Touch,bootrom=bootrom_240_4,nand=nand,nor=nor_n72ap.bin -serial mon:stdio -cpu max -m 2G -d unimp