Skip to content

STM32 firmware for a physical switch to set the GRUB boot selection

Notifications You must be signed in to change notification settings

0-Xanthium/hw-boot-selection

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GRUB boot selector switch

Firmware for the Hardware Boot Selection Switch project: This acts as a USB mass storage device containing a dynamic GRUB script, which sets a varible to indicate the position of the physical switch.

Building

You'll need gcc-arm-none-eabi to build and openocd to flash.

# Pull in libopencm3
git submodule init
git submodule update

# Build opencm3 (only needed once)
cd libopencm3
make -j8

# Build firmware
cd src
make

# Flash (assumes a J-Link programmer connected to SWD on the device)
make flash

GRUB config

You'll need to modify your system's GRUB config to look for and read from this device. Here's an example of how this can be done in GRUB script:

# Look for hardware switch device by its hard-coded filesystem ID
search --no-floppy --fs-uuid --set hdswitch 55AA-6922

# If found, read dynamic config file and select appropriate entry for each position
if [ "${hdswitch}" ] ; then
  source ($hdswitch)/switch_position_grub.cfg

  if [ "${os_hw_switch}" == 0 ] ; then
    # Boot Linux
    set default="0"
  elif [ "${os_hw_switch}" == 1 ] ; then
    # Boot Windows
    set default="2"
  else
    # Fallback to default
    set default="${GRUB_DEFAULT}"
  fi

else
  set default="${GRUB_DEFAULT}"
fi

About

STM32 firmware for a physical switch to set the GRUB boot selection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 68.8%
  • Makefile 27.8%
  • Shell 3.4%