Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrasbiro/grubswitch
Raspberry pi pico based physical GRUB select switch
https://github.com/andrasbiro/grubswitch
grub grub2 mass-storage mass-storage-device raspberry-pi-pico rp2040 rp2040-zero usb-mass-storage
Last synced: about 7 hours ago
JSON representation
Raspberry pi pico based physical GRUB select switch
- Host: GitHub
- URL: https://github.com/andrasbiro/grubswitch
- Owner: andrasbiro
- License: mit
- Created: 2024-10-21T18:43:40.000Z (17 days ago)
- Default Branch: main
- Last Pushed: 2024-10-24T16:50:09.000Z (14 days ago)
- Last Synced: 2024-10-25T23:55:35.867Z (13 days ago)
- Topics: grub, grub2, mass-storage, mass-storage-device, raspberry-pi-pico, rp2040, rp2040-zero, usb-mass-storage
- Language: C
- Homepage:
- Size: 124 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GRUB switch
This is a simple physical switch to control GRUB2 inspired by a [simplar project
for STM32](https://github.com/stecman/hw-boot-selection), but implemented on the
Raspberry Pi Pico (developed on RP2040-Zero, but any Pico should be good).The code is using an SPDT On-Off-On switch, one side selects Linux, the other
Windows, while in the middle selection, the GRUB menu stays on indefinately -
but this should be very easy to modify.I needed this, because I have a strange dual boot setup where my monitor usually
turns on with the input that is not the default from my UEFI setup.A 3d printable case is also available in the case folder, with Fusion 360 design
files.## Build and install
An uf2 binary is available as release for easy testing.
Install the [pico-SDK](https://github.com/raspberrypi/pico-sdk), cmake and
arm-eabi-gcc.Make sure to set the environemnt variable PICO_SDK_PATH to point the folder
where your pico-SDK is (e.g. `export PICO_SDK_PATH=/usr/share/pico-sdk`).Then continue with the usual cmake setup:
```bash
mkdir build
cd build
cmake ..
make
```Finally, install the generated `build/grubswitch.uf2` on the Pico. It will
reboot as a FAT16 drive, labeled "GRUB-SWITCH".The switch should be connected to pin28 and pin29 if the code is used
unmodified.## Setup GRUB
Copy [49_switch](49_switch) to `/etc/grub.d`. Modify the entry numbers
highlighted with comments. Make sure it's executable and run `update-grub` as
root.## Modification
The letters set by the switch are defined in [msc_disk.h](src/msc_disk.h). The
switch is read in [main.c](src/main.c). The filesystem and filename are defined
in [msc_dis.c](src/msc_disk.c) - although I wouldn't recommend changing this
unless you have to.## Inspiration
This project was developed based on the following:
* [The ST implementation of the same
idea](https://github.com/stecman/hw-boot-selection)
* [Another pico
implementation](https://www.hackster.io/Madrajib/hardware-boot-select-switch-using-pico-a3e3d5)
I just didn't like that it's a documentation on how to modify an example
* [A nice demonstration project of USB
MSC](https://github.com/brendena/pico_drag_n_drop_programmer) with a lot of
links and explanation video.