randyrossi / bmc64

A bare metal Commodore 64 emulator for the Raspberry Pi with true 50hz/60hz smooth scrolling, low input latency and better audio/video sync.
GNU General Public License v3.0
473 stars 56 forks source link

Simple dual boot #174

Closed jaromaz closed 2 years ago

jaromaz commented 3 years ago

Under Raspbian I move the contents of /boot directory to /boot/raspbian_backup/ and placed bmc64 into /boot. After a reboot, bmc64 starts up :)

Now I need a similar option under the bmc64 to backup bmc64 and move the contents of the /raspbian_backup/ directory to the / directory, to revert to Raspbian after a reboot.

A simple file manager would be useful, or an option that performs this step automatically (necessary files only). @randyrossi - can we hope for that kind of solution? :)

cleverca22 commented 3 years ago
[root@system76:~]# cat /mnt/autoboot.txt
gpio=26=ip,pu

[gpio26=0]
boot_partition=2

[gpio26=1]
boot_partition=3

i discovered something a few months back

if you have an autoboot.txt file on the 1st fat32 partition, then the boot_partition= entry in there, says what fat32 partition to find all other config/firmware/kernels on and gpio conditionals work in there, so you can select which fat32 partition you boot from, by holding a gpio pin in a certain state

if on a pi0-pi3 model, bootcode.bin must also be on that 1st partition for pi4/pi400, bootcode.bin is held in SPI flash instead

jaromaz commented 3 years ago

Thanks for the information - I will test this solution, however I prefer a software option :)

jaromaz commented 2 years ago

@cleverca22 @randyrossi I installed the Raspberry Pi OS, shrunk the second, root partition, created a third partition and put the BMC64 on it. The BMC64 booted from the third partition correctly (thanks to autoboot.txt), but it only displays a message that the firmware files are missing - apparently it's not looking for them on the third partition, but on the first, boot partition :(

randyrossi commented 2 years ago

Have you tried adding disk_partition=3 in cmdline.txt ? (or disk_partition=2 if it's zero indexed, I can't remember). When you say 'firmware', you mean the C64 kernel roms and other files it can't find?

On Sat, Nov 6, 2021 at 1:35 PM Jaromaz @.***> wrote:

@cleverca22 https://github.com/cleverca22 @randyrossi https://github.com/randyrossi I installed the Raspberry Pi OS, shrunk the second, root partition, created a third partition and put the BMC64 on it. The BMC64 booted from the third partition correctly (thanks to autoboot.txt), but it only displays a message that the firmware files are missing - apparently it's not looking for them on the third partition, but on the first, boot partition :(

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/174#issuecomment-962484574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3HKBA3X2H3ZW6DVCOLFLUKVRNZANCNFSM44ZMFFVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Randy Rossi

jaromaz commented 2 years ago

@randyrossi

Have you tried adding disk_partition=3 in cmdline.txt ?

Yes, but that wouldn't help anyway because according to the documentation: "The files the Raspbery Pi itself needs to boot BMC64 must still reside in the first partition." But this partition is already occupied by Raspberry Pi OS files.

Additionally, in my project I need to switch between Commodore 64, 128 and PET, and this will not be possible because according to the documentation: "Machine switching is currently NOT supported if you use any partition other than the first partition on the SDCard."

A great solution to making a simple dual boot would be to add a simple file manager where you could delete BMC64 files and copy Raspberry Pi OS boot files.The question is, will the BMC64 allow itself to be deleted? :) This is possible for the /boot partition on Raspberry Pi OS.

I solve it as follows, but restoring the Rasperry Pi OS requires connecting the SD card to a second computer (this is not acceptable in my project), but swapping the Pi OS to the BMC64 does not require taking out the SD card and is done directly on the Raspberry Pi OS.

Perhaps my bash scripts will be helpful in establishing a simple dual boot mechanism in BMC64:

https://gitlab.com/jaromaz/bmc64-pios-dual-boot

cleverca22 commented 2 years ago

@jaromaz you could swap things around move all of the rpi-os /boot files to the 3rd partition, and use boot_partition=3 to make it boot up

then put bmc64, bootcode.bin, and autoboot.txt on the 1st partition, to make bmc64 happy

then you just need to make sure that /etc/fstab in raspi-os is happy, and it will mount the right one as for a software solution, if you run reboot 1 or reboot 3 from raspi-os, it will boot into the fat32 partition by that number so your autoboot.txt could be only boot_partition=3 and then you reboot 1 to force it to load bmc64 in theory, bmc64 could also be extended to have access to that reboot 3 mechanism, then you could run a command from bmc64/basic, to trigger booting raspi-os

jaromaz commented 2 years ago

@randyrossi

@cleverca22 solution works great ! A small problem is that switching machines starts Raspberry Pi OS, and running sudo reboot 1 again restarts the BMC64, but already with the changed machine :)

The usual reboot option in the BMC64 is also missing. At the moment, to boot into Raspberry Pi OS I switch the machine to the same one I'm currently using. It works :)

Anyway, the current solution solves my problem - @cleverca22 thank You for your help.

If anyone wants to practice shrinking the rootfs partition, they can use my Live Demo with a virtual disk residing in RAM - available at: https://jm.iq.pl/rescshri-linux-mini-distribution/