Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't find pdz file main.pdz #41

Open
pomettini opened this issue Apr 27, 2023 · 31 comments
Open

Couldn't find pdz file main.pdz #41

pomettini opened this issue Apr 27, 2023 · 31 comments

Comments

@pomettini
Copy link
Contributor

pomettini commented Apr 27, 2023

Hi,

I've been using Crankstart to test my Chip-8 emulator on the Playdate Simulator and it's been a joy to use! <3

I was curious if my "game" would also run on my real Playdate, but every time try to I upload the package with Device > Upload the device crashes and displays the message: Couldn't find pdz file main.pdz

Curiously, I double-checked if it was also happening with the examples, with the Klondike and the Nine Lives demo, and it was indeed happening in all of the cases

The output .pdx file contains:

  • pdex.bin
  • pdex.dylib
  • pdxinfo

While on a Playdate game the package usually contains:

  • main.pdz
  • pdxinfo

I'm on nightly-aarch64-apple-darwin and I'm running Crank and Crankstart on a M1 Pro Macbook Pro

Do you perhaps have any suggestions? I've tried everything but to no avail 😔

Thank you

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

That wasn't the case a few months ago, but I'll take a look tomorrow and see what I can learn.

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

I can't reproduce this with Klondike on my M1 MacBook Air running 13.3.1 (22E261).

What does crank -V tell you?

@pomettini
Copy link
Contributor Author

I can't reproduce this with Klondike on my M1 MacBook Air running 13.3.1 (22E261).

What does crank -V tell you?

Hi @rtsuk thank you for the quick reply 🙂

The command crank -V gives me crank 0.2.8

@pomettini
Copy link
Contributor Author

I made the repository public if you want to give it a try https://github.com/Pomettini/yet-another-chip-8-emulator/tree/main/playdate (sorry the project is a bit messy haha 😅)

@tjkirch
Copy link
Contributor

tjkirch commented Apr 27, 2023

I know this is something that can happen with a game misconfiguration or a weird command rather than a crankstart issue because I see it once in a while when I change something, but I can't quite remember what it is at the moment... I'll see if I can track it down.

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

I was able to compile it and run it fine on the device.

What does rustc +nightly -V say?

@pomettini
Copy link
Contributor Author

I was able to compile it and run it fine on the device.

What does rustc +nightly -V say?

It prints rustc 1.71.0-nightly (458d4dae8 2023-04-25)

@pomettini
Copy link
Contributor Author

This is what is says if I run crank -v run --release

INFO  crank > starting
INFO  crank > manifest = Manifest {
   targets: [
       Target {
           name: "chip8-playdate",
           assets: Some(
               [],
           ),
           metadata: Some(
               Metadata {
                   name: Some(
                       "Chip8 Playdate",
                   ),
                   author: Some(
                       "Giorgio Pomettini",
                   ),
                   description: Some(
                       "",
                   ),
                   bundle_id: Some(
                       "com.pomettini.chip8pd",
                   ),
                   version: Some(
                       "0.1",
                   ),
                   build_number: None,
                   image_path: Some(
                       "assets/launcher",
                   ),
                   launch_sound_path: None,
               },
           ),
       },
   ],
}
INFO  crank > building
INFO  crank > build command: "cargo" "build" "--lib" "--release"
   Finished release [optimized] target(s) in 0.02s
INFO  crank > make_source_dir
INFO  crank > link_dylib
INFO  crank > copy_assets
INFO  crank > make_manifest
INFO  crank > run_pdc
INFO  crank > run_simulator

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

I was just going to ask that, but with --device.

@pomettini
Copy link
Contributor Author

I was just going to ask that, but with --device.

Sure thing!

 INFO  crank > starting
 INFO  crank > manifest = Manifest {
    targets: [
        Target {
            name: "chip8-playdate",
            assets: Some(
                [],
            ),
            metadata: Some(
                Metadata {
                    name: Some(
                        "Chip8 Playdate",
                    ),
                    author: Some(
                        "Giorgio Pomettini",
                    ),
                    description: Some(
                        "",
                    ),
                    bundle_id: Some(
                        "com.pomettini.chip8pd",
                    ),
                    version: Some(
                        "0.1",
                    ),
                    build_number: None,
                    image_path: Some(
                        "assets/launcher",
                    ),
                    launch_sound_path: None,
                },
            ),
        },
    ],
}
 INFO  crank > building
 INFO  crank > build command: "cargo" "+nightly" "build" "--lib" "--release" "--target" "thumbv7em-none-eabihf"
warning: dropping unsupported crate type `cdylib` for target `thumbv7em-none-eabihf`

warning: `chip8_playdate` (lib) generated 1 warning
    Finished release [optimized] target(s) in 0.03s
 INFO  crank > make_source_dir
 INFO  crank > compile_setup: "/usr/local/bin/arm-none-eabi-gcc" "-g" "-c" "-mthumb" "-mcpu=cortex-m7" "-mfloat-abi=hard" "-mfpu=fpv4-sp-d16" "-D__FPU_USED=1" "-O2" "-falign-functions=16" "-fomit-frame-pointer" "-gdwarf-2" "-Wall" "-Wno-unused" "-Wstrict-prototypes" "-Wno-unknown-pragmas" "-fverbose-asm" "-ffunction-sections" "-fdata-sections" "-DTARGET_PLAYDATE=1" "-DTARGET_EXTENSION=1" "/Users/pomettini/Developer/PlaydateSDK/C_API/buildsupport/setup.c" "-I" "/Users/pomettini/Developer/PlaydateSDK/C_API" "-o" "/Users/pomettini/Git/yet-another-chip-8-emulator/playdate/target/thumbv7em-none-eabihf/release/setup.o"
 INFO  crank > link_binary: "/usr/local/bin/arm-none-eabi-gcc" "/Users/pomettini/Git/yet-another-chip-8-emulator/playdate/target/thumbv7em-none-eabihf/release/setup.o" "/Users/pomettini/Git/yet-another-chip-8-emulator/playdate/target/thumbv7em-none-eabihf/release/libchip8_playdate.a" "-mthumb" "-mcpu=cortex-m7" "-mfloat-abi=hard" "-mfpu=fpv4-sp-d16" "-D__FPU_USED=1" "-Wl,--gc-sections,--no-warn-mismatch" "-T" "/Users/pomettini/Developer/PlaydateSDK/C_API/buildsupport/link_map.ld" "-o" "/Users/pomettini/Git/yet-another-chip-8-emulator/playdate/target/thumbv7em-none-eabihf/release/chip8_playdate.elf"
 INFO  crank > make_binary: "/usr/local/bin/arm-none-eabi-objcopy" "-O" "binary" "/Users/pomettini/Git/yet-another-chip-8-emulator/playdate/target/thumbv7em-none-eabihf/release/chip8_playdate.elf" "/Users/pomettini/Git/yet-another-chip-8-emulator/playdate/target/thumbv7em-none-eabihf/release/chip8_playdate.bin"
 INFO  crank > copy_assets
 INFO  crank > make_manifest
 INFO  crank > run_pdc
 INFO  crank > run_target

@tjkirch
Copy link
Contributor

tjkirch commented Apr 27, 2023

It prints rustc 1.71.0-nightly (458d4dae8 2023-04-25)

It's worth trying an older nightly - I've been using nightly-2023-02-09 for some time with no issues. Newer nightlies introduce problems like rust-lang/rust#109934 that cause compilation failures, and are taking some time to address upstream.

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

It's working fine for me on almost exactly the same host hardware and rustc 1.71.0-nightly (458d4dae8 2023-04-25).

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

So, I went back and reread your initial message and see you're trying to useDevice > Upload, which I've not tried in years and which shouldn't be necessary. crank run should copy the package to the device and launch it.

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

I also see that when you run, logging stops after INFO crank > run_target. I get

INFO  crank > datadisk cmd: Command {
    program: "/Users/rob/Developer/PlaydateSDK/bin/pdutil",
    args: [
        "/Users/rob/Developer/PlaydateSDK/bin/pdutil",
        "/dev/cu.usbmodemPDU1_Y0005491",
        "datadisk",
        "/Users/rob/projects/playdate/yet-another-chip-8-emulator/playdate/target/Chip8 Playdate.pdx",
    ],
}
 INFO  crank > copy_directory "/Users/rob/projects/playdate/yet-another-chip-8-emulator/playdate/target/Chip8 Playdate.pdx" -> "/Volumes/PLAYDATE/Games/Chip8 Playdate.pdx"
 INFO  crank > copy_file "/Users/rob/projects/playdate/yet-another-chip-8-emulator/playdate/target/Chip8 Playdate.pdx/pdex.dylib" -> "/Volumes/PLAYDATE/Games/Chip8 Playdate.pdx/pdex.dylib"
 INFO  crank > copy_file "/Users/rob/projects/playdate/yet-another-chip-8-emulator/playdate/target/Chip8 Playdate.pdx/pdxinfo" -> "/Volumes/PLAYDATE/Games/Chip8 Playdate.pdx/pdxinfo"
 INFO  crank > copy_file "/Users/rob/projects/playdate/yet-another-chip-8-emulator/playdate/target/Chip8 Playdate.pdx/pdex.bin" -> "/Volumes/PLAYDATE/Games/Chip8 Playdate.pdx/pdex.bin"
 INFO  crank > eject cmd: Command {
    program: "diskutil",
    args: [
        "diskutil",
        "eject",
        "/Volumes/PLAYDATE",
    ],
}
Disk /Volumes/PLAYDATE ejected
 INFO  crank > run cmd: Command {
    program: "/Users/rob/Developer/PlaydateSDK/bin/pdutil",
    args: [
        "/Users/rob/Developer/PlaydateSDK/bin/pdutil",
        "/dev/cu.usbmodemPDU1_Y0005491",
        "run",
        "/Games/Chip8 Playdate.pdx",
    ],
}

If you are up for it, you could improve the logging in crank around the run command and see where it is failing.

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

Also, Device > Upload works for me.

@pomettini
Copy link
Contributor Author

pomettini commented Apr 27, 2023

Unfortunately downgrading Rust to nightly-2023-02-09 didn't help. By the way, I fear that even if the .pdx would be uploaded without using the emulator, it's still missing the main.pdz file in the package, so the game crashes as the device won't find an entry point 😔

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

I'm not sure why there needs to be a main.pdz file. I don't have one and it works fine for me.

rob@RoboAir ~ % ls -l /Volumes/PLAYDATE/Games/Chip8\ Playdate.pdx 
total 264
-rwxrwxrwx  1 rob  staff  27784 Apr 27 07:39 pdex.bin
-rwxrwxrwx  1 rob  staff  99092 Apr 27 07:39 pdex.dylib
-rwxrwxrwx  1 rob  staff     37 Apr 27 07:39 pdxinfo

@pomettini
Copy link
Contributor Author

I'm not sure why there needs to be a main.pdz file. I don't have one and it works fine for me.

rob@RoboAir ~ % ls -l /Volumes/PLAYDATE/Games/Chip8\ Playdate.pdx 
total 264
-rwxrwxrwx  1 rob  staff  27784 Apr 27 07:39 pdex.bin
-rwxrwxrwx  1 rob  staff  99092 Apr 27 07:39 pdex.dylib
-rwxrwxrwx  1 rob  staff     37 Apr 27 07:39 pdxinfo

I tried uploading the game from the simulator out of curiosity and... Inexplicably, it worked 🤯

I can't say exactly what caused this. I thought that was related to the main.pdz file since the device was telling me it needed that file, but apparently it wasn't the case. I will investigate on the matter, and also try to figure out why crank run --device hangs on my machine 💪

Meanwhile, thank you so much @rtsuk and @tjkirch for the patience and the quick replies! I really appreciate it! 😊

@tjkirch
Copy link
Contributor

tjkirch commented Apr 27, 2023

I'm curious to see what you find about the hanging, if it's reproducible! I'd try running through strace - that's how I figured out an issue with the commands pdutil (via PlaydateSimulator) was sending to the device. Something like strace -f -s256 -o sim.trace -- PlaydateSimulator and then try to upload the game from the simulator. Or run crank run --device through strace instead, if that's the problem area. There will be a ton in the output file, but something may stick out about the pdutil call, or something else in that area.

My understanding is that pdz files are compiled lua, and since with crankstart we don't use any lua, it shouldn't be necessary; if it's looking for pdz, my suspicion is that the pdx is missing something that tells Playdate it's a C game. The target/GAME.pdx should have pdxinfo, pdex.bin, and pdex.so/pdex.dylib files, which yours does, so I'm not sure. FWIW, my pdxinfo only has name, version, pdxversion, and buildtime, so not much is required there. I really wish I could remember what caused this for me before, I'm sorry.

@pomettini
Copy link
Contributor Author

pomettini commented Apr 27, 2023

I'm curious to see what you find about the hanging, if it's reproducible! I'd try running through strace - that's how I figured out an issue with the commands pdutil (via PlaydateSimulator) was sending to the device. Something like strace -f -s256 -o sim.trace -- PlaydateSimulator and then try to upload the game from the simulator. Or run crank run --device through strace instead, if that's the problem area. There will be a ton in the output file, but something may stick out about the pdutil call, or something else in that area.

My understanding is that pdz files are compiled lua, and since with crankstart we don't use any lua, it shouldn't be necessary; if it's looking for pdz, my suspicion is that the pdx is missing something that tells Playdate it's a C game. The target/GAME.pdx should have pdxinfo, pdex.bin, and pdex.so/pdex.dylib files, which yours does, so I'm not sure. FWIW, my pdxinfo only has name, version, pdxversion, and buildtime, so not much is required there. I really wish I could remember what caused this for me before, I'm sorry.

I'm on Mac so I can't use strace I'm afraid 😔

By the way, while I was randomly testing stuff, the simulator was not updating the build on the device, so I deleted the target folder with cargo clean and... now I'm getting the same missing main.pdz error again 😔

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

Make sure that macOS isn't asking for permissions while crank is running. I think I saw some of those while testing just now and it caused crank to hang.

@tjkirch
Copy link
Contributor

tjkirch commented Apr 27, 2023

I'm on Mac so I can't use strace I'm afraid 😔

It looks like dtruss would do the same job on a Mac, maybe? I don't think SIP would come into play for the downloaded simulator binary, but it looks like codesign can remove its signature if it has one somehow.

By the way, while I was randomly testing stuff, the simulator was not updating the build on the device, so I deleted the target folder with cargo clean and... now I'm getting the same missing main.pdz error again 😔

I wonder if an empty main.pdz would work around the check, and the game would still run because it's not actually needed... :|

@pomettini
Copy link
Contributor Author

pomettini commented Apr 27, 2023

I'm on Mac so I can't use strace I'm afraid 😔

It looks like dtruss would do the same job on a Mac, maybe? I don't think SIP would come into play for the downloaded simulator binary, but it looks like codesign can remove its signature if it has one somehow.

By the way, while I was randomly testing stuff, the simulator was not updating the build on the device, so I deleted the target folder with cargo clean and... now I'm getting the same missing main.pdz error again 😔

I wonder if an empty main.pdz would work around the check, and the game would still run because it's not actually needed... :|

I tried putting a main.pdz file and the stacktrace on the device says that the file is too small, no matter how large it is. Funnily enough, I noticed the pdex.bin file on the package is actually empty, maybe that is causing the issue? But if so, how is it running on the simulator?

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

That is certainly the cause. It works on the simulator because the simulator uses the dylib, not the binary.

@pomettini
Copy link
Contributor Author

That is certainly the cause. It works on the simulator because the simulator uses the dylib, not the binary.

Ahhh that makes sense now! I made a quick test with crank run --device --release (which still hangs) and manually copied the .pdx file and yeah, it worked! So now I have to figure out how to make the transfer work and that should be it! Thanks again folks! 💪

@rtsuk
Copy link
Collaborator

rtsuk commented Apr 27, 2023

Do check for permission requests that are popped up behind your active window.

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Oct 10, 2023

Just got my playdate and ran into this instantly, have anybody found a workaround for this?

@paulyoung
Copy link
Contributor

I’m also unable to use crank run --device with it hanging. I’m doing crank build --device and then uploading via the simulator as a workaround.

I’m AFK now but wondering if this is only when my game is already running. I’ve noticed that I can’t upload to device from the simulator when a game is running (the “Device” menu disappears and the Cmd+U shortcut is disabled)

@paulyoung
Copy link
Contributor

I’m AFK now but wondering if this is only when my game is already running. I’ve noticed that I can’t upload to device from the simulator when a game is running (the “Device” menu disappears and the Cmd+U shortcut is disabled)

I tried this and it made no difference. Being on the home screen didn't help.

@paulyoung
Copy link
Contributor

I did some investigating and found that modem_path.exists() is false. I'll open an issue over in the crank repo.

@paulyoung
Copy link
Contributor

Seems to be explained by pd-rs/crank#24; modem_path defaults to /dev/cu.usbmodemPDU1_Y0005491 unless PLAYDATE_SERIAL_DEVICE is set.

There's apparently some way to try and find this but it's only for Linux: pd-rs/crank#38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants