Skip to content

Instantly share code, notes, and snippets.

@uraimo
Created April 29, 2017 10:26
Show Gist options
  • Save uraimo/4b8ee271cd394522cd5700418fe379af to your computer and use it in GitHub Desktop.
Save uraimo/4b8ee271cd394522cd5700418fe379af to your computer and use it in GitHub Desktop.
How to enable the SD card insertion detection on a Banana Pi M3

Once you dd the image they provide, you'll notice that you can only boot from eMMC when the SD is not inserted and if you inser it after boot, the system doesn't even discover the devices.

There is an easy fix for this.

At boot, uBoot looks for /boot/bananapi/bpi-m3/linux/uEnv.txt and loads /boot/bananapi/bpi-m3/linux/script.bin that contains additional configuration, like how to manage the SD, in binary format.

You just need to follow a few simple steps to enable SD discovery after boot (there is a way to boot from the boot partition on the SD and then load the OS from eMMC but I didn't have time to experiment with that).

  1. Copy the current script.bin to your home and make a backup:

    sudo cp /boot/bananapi/bpi-m3/linux/script.bin  ~
    sudo cp /boot/bananapi/bpi-m3/linux/script.bin  /boot/bananapi/bpi-m3/linux/script.bin.orig
    
  2. Convert it to its textual form:

    bin2fex script.bin > sys_config.fex
    
  3. Open sys_config.fex, search for mmc0_para and change sdc_detmore from 3 to 1 (the same parameter under mmc1 can stay at 4):

    [mmc0_para]
    sdc_used = 1
    sdc_detmode = 1
    
  4. Convert it back to binary:

    fex2bin sys_config.fex > script.bin
    
  5. Copy it back:

    sudo cp script.bin /boot/bananapi/bpi-m3/linux/script.bin
    
@Nargren
Copy link

Nargren commented Jan 21, 2018

Hi, thanks for the help, great!

I see that this is 9 months old, so it might be due to an upgrade, but for me script.bin is under
/boot/firmware/bananapi/bpi-m3/linux/script.bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment