• Stars
    star
    186
  • Rank 207,316 (Top 5 %)
  • Language
    C
  • License
    BSD 2-Clause "Sim...
  • Created over 6 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LSI SAS2008/SAS2108 low-level recovery tool for Linux

lsirec - LSI SAS2008/2108 HBA low-level recovery tool for Linux

Currently supports reading and writing the SBR and booting the card in host boot mode.

Use lsiutil to crossflash between IT/IR firmwares from Linux, without vendor/product ID restrictions.

Quick guide to cleanly crossflash between IT/IR firmwares

# lsiutil -e

Select your adapter.

46. Upload FLASH section → 5. Complete (all sections)

Make a complete Flash backup to be safe.

67. Dump all port state

68. Show port state summary

Copy and paste these somewhere safe. Take special note of the SAS WWID.

33. Erase non-volatile adapter storage → 3. FLASH, then also 8. Persistent manufacturing config pages

Wipe the whole Flash. This will take a while. Option number 3 excludes the manufacturing config pages, so you need both.

2. Download firmware (update the FLASH)

Flash the new firmware. Optionally, use 4. Download/erase BIOS and/or FCode (update the FLASH) to flash the BIOS/EFI module (not necessary if you're not booting from the adapter).

Exit lsiutil.

# ./lsirec 0000:01:00.0 readsbr sbr_backup.bin

Where 0000:01:00.0 is your PCI device ID.

# python3 sbrtool.py parse sbr_backup.bin sbr.cfg

Edit sbr.cfg with your favorite text editor. You may want to add SASAddr = 0xYOUR_SAS_WWID to make the SAS WWID persist in the SBR (I'm not sure which firmwares use this, but I've seen it in some SBRs). You may want to change the Subsystem VID/PID, or use another SBR as a template.

# python3 sbrtool.py build sbr.cfg sbr_new.bin

# ./lsirec 0000:01:00.0 writesbr sbr_new.bin

Reboot and cross your fingers.

When the system comes back up, if all went well, launch lsiutil -e again and use 18. Change SAS WWID to update the WWID if necessary, then reboot again (this writes it to the config section in Flash, not to the SBR).

NEW: instead of rebooting, you can use:

# ./lsirec 0000:01:00.0 reset

# ./lsirec 0000:01:00.0 rescan

Make sure your disks are not in use if you do this. reset might fail if you have just flashed a new firmware. This is normal, as the adapter takes a while to copy the firmware to the backup area on first boot. Wait a few seconds and use # ./lsirec 0000:01:00.0 info until it returns IOC is READY.

UNTESTED procedure to convert from MegaRAID to IT/IR firmware or recover a bricked card

WARNING: this is completely untested. Host boot support has only been tested so far on a card that was already IT/IR. Please report back if you try this. This process initially boots the IT/IR firwmare without touching Flash, and I'm not sure if it might balk at whatever MegaRAID stuff was left there before we have a chance to wipe it.

This procedure (obviously) resets the adapter, so make sure your disks are not in use and any dm/md/lvm mappings have been removed!

This mode requires HugeTLB support enabled in your kernel:

# echo 16 > /proc/sys/vm/nr_hugepages

This process is also incompatible with IOMMUs. If you have one, make sure it is not active (e.g. check that /sys/kernel/iommu_groups is an empty directory).

Make note of your SAS WWID (e.g. using MegaCLI or the kernel interfaces).

# ./lsirec 0000:01:00.0 unbind

Where 0000:01:00.0 is your PCI device ID. Unbind the kernel driver (if any).

# ./lsirec 0000:01:00.0 halt

Halt the IOP, so that the firmware will not interfere with subsequent operations.

# ./lsirec 0000:01:00.0 readsbr sbr_backup.bin

Back up your MegaRAID SBR.

# python3 sbrtool.py parse sbr_backup.bin sbr.cfg

Edit sbr.cfg with your favorite text editor. You'll probably want to use an IT SBR as a template, such as sbr_sas9211-8i_itir.cfg. At the very least you need to set PCIPID properly (0x0072 for SAS2008-based cards) and set Interface to 0x00 for IT/IR mode. You may want to add SASAddr = 0xYOUR_SAS_WWID to make the SAS WWID persist in the SBR (I'm not sure which firmwares use this, but I've seen it in some SBRs).

# python3 sbrtool.py build sbr.cfg sbr_new.bin

# ./lsirec 0000:01:00.0 writesbr sbr_new.bin

Write the new IT/IR mode SBR. This does not immediately take effect.

# ./lsirec 0000:01:00.0 hostboot 2118it.bin

Where 2118it.bin is your desired firmware. If all went well, you should see something like this:

# ./lsirec 0000:01:00.0 hostboot 2118it.bin
Device in MPT mode
Resetting adapter in HCB mode...
Trying unlock in MPT mode...
Device in MPT mode
IOC is RESET
Setting up HCB...
HCDW virtual: 0x7fca79e00000
HCDW physical: 0x439a00000
Loading firmware...
Loaded 722708 bytes
Booting IOC...
IOC is READY
IOC Host Boot successful.

At this point the PCI VID/PID should've changed, but the kernel will not have noticed. Check with lspci:

# lspci -vns 0000:01:00.0 -A linux-sysfs | head -n 2

# lspci -vns 0000:01:00.0 -A intel-conf1 | head -n 2

The first command should still show the old VID/PID, but the second one should show the new (MPT mode) ones. To make the kernel notice:

# ./lsirec 0000:01:00.0 rescan

This removes the PCI device from the kernel and requests a rescan. At this point the mpt3sas kernel driver should load. Check dmesg for any errors.

If all went well, you can use lsiutil to wipe Flash and flash your new firmware:

# lsiutil -e

Select your adapter.

46. Upload FLASH section → 5. Complete (all sections)

Make a complete Flash backup to be safe.

33. Erase non-volatile adapter storage → 3. FLASH, then also 8. Persistent manufacturing config pages

Wipe the whole Flash. This will take a while. Option number 3 excludes the manufacturing config pages, so you need both.

2. Download firmware (update the FLASH)

Flash the new firmware. Optionally, use 4. Download/erase BIOS and/or FCode (update the FLASH) to flash the BIOS/EFI module (not necessary if you're not booting from the adapter).

Exit lsiutil.

Finally, if all went well, reset into normal mode:

# ./lsirec 0000:01:00.0 reset

This might complain about IOC not becoming ready, but this is normal, as the first boot takes longer. Use ./lsirec 0000:01:00.0 info after a few seconds and check for IOC is READY.

# ./lsirec 0000:01:00.0 rescan

If all went well, dmesg should show the driver loading again successfully. Launch lsiutil -e again and use 18. Change SAS WWID to update the WWID if necessary, then reset and rescan again to make sure the kernel sees the new WWID.

Enjoy your shiny new IT/IR-mode HBA.

Disclaimer

This has barely been tested a couple of cards. Don't blame me if this bricks or smokes your HBA.

DO NOT attempt to use this tool on non-SAS2x08 chipsets. It probably won't work and may do horrible things. This tool deliberately does not check the VID/PID so it can be used on cards with wacky SBRs, but that means it will happily try to write the SBR into any random PCI device too.

I have tested this on an LSI SAS2108-based MegaRAID card (Fujitsu D2616) with MegaRAID firmware and it successfully backed up the SBR, but the action triggered a PCI error in syslog (though the controller kept working). Your mileage may vary. I have not yet tried crossflashing it live to IT/IR mode.

License

2-clause BSD. See the LICENSE file.

More Repositories

1

takeover.sh

Wipe and reinstall a running Linux system via SSH, without rebooting. You know you want to.
Shell
7,091
star
2

speculation-bugs

Docs and resources on CPU Speculative Execution bugs
368
star
3

openlase

Open source realtime laser graphics framework
C
338
star
4

blitzloop

Open source karaoke software
Python
197
star
5

cl-waifu2x

OpenCL implementation of waifu2x image upscaling
Python
141
star
6

rtlmic

Wireless FM microphone receiver for RTL-SDR
C
88
star
7

deresuteme

The code behind https://deresute.me
Python
77
star
8

asbestos

PS3 Linux bootloader
C
69
star
9

sigmafix

Make old Sigma lenses work on newer Canon bodies.
Assembly
58
star
10

qsw-tools

QNAP QSW switch tools
Python
52
star
11

certbot-external

Certbot plugin that uses an external shell script for domain validation
Shell
51
star
12

hackit

Hack It Framework
Python
27
star
13

cd-analysis

Scripts to analyze audio CD data quality
Python
24
star
14

circa

Consumer IR encoding/decoding/format conversion
Python
16
star
15

lighthouses_aicontest

Euskal Encounter 21 AI Contest
Python
15
star
16

xmos-speaker-dsp

5.1 speaker DSP controller firmware based on the XMOS USB 2.0 Multichannel Audio Reference board
XC
13
star
17

skyeye-starlet

Very hacky Starlet emulator. Here be dragons, this was never meant to be released.
C
11
star
18

blitzloop-tools

Python
10
star
19

esp-sensornode

ESP8266 + BME280 sensor node
C
9
star
20

pacemaker-exporter

Prometheus Pacemaker exporter
Python
9
star
21

spmp

Misc SPMP305x development
C
8
star
22

mt7687flash

Portable MT7687 flasher/recovery utility
Python
8
star
23

kinlarm

Kinect security system
Python
8
star
24

openlase-vj

OpenLASE based live lasershow thing
Python
4
star
25

ctf

Random CTF tools and writeups
Python
4
star
26

blitzloop-songs

Public BlitzLoop songs repository
2
star
27

crinklux

Linker script hack to build small demos for Linux
C
2
star
28

jacktools

Misc JACK-related tools
Python
2
star
29

music-stuff

sheet music and other musical shenanigans
2
star
30

unity-obj-exporter

Export .obj from .unity3d
JavaScript
2
star
31

uhub-proxy

Scalable frontend for uhub
Rust
1
star