diff --git a/tools/flashy/checks_and_remediations/common/90_expose_real_flash0_on_secondary_boot.go b/tools/flashy/checks_and_remediations/common/90_expose_real_flash0_on_secondary_boot.go index 314ca2b16a61..8648a6128ab0 100644 --- a/tools/flashy/checks_and_remediations/common/90_expose_real_flash0_on_secondary_boot.go +++ b/tools/flashy/checks_and_remediations/common/90_expose_real_flash0_on_secondary_boot.go @@ -54,23 +54,12 @@ func ExposeRealFlash0OnSecondaryBoot(stepParams step.StepParams) step.StepExitEr return step.ExitSafeToReboot{Err: errors.Errorf("Unable to fetch machine: %v", err)} } - etcIssueVer, err := utils.GetOpenBMCVersionFromIssueFile() - if err != nil { - return step.ExitSafeToReboot{Err: errors.Errorf("Unable to fetch /etc/issue: %v", err)} - } - // Bail if not running on AST2400 (armv5tejl) nor AST2500 (armv6l) if machine != "armv5tejl" && machine != "armv6l" { log.Printf("Remediation handles only AST2400 and AST2500") return nil } - // WDT2 reset logic doesn't work on old versions of cmm (it keeps rebooting to the other flash) - if etcIssueVer == "cmm-v29" { - log.Printf("Old galaxy cmm version detected (%v), skipping step...", etcIssueVer) - return nil - } - mem, err := MmapDevMemRw() if err != nil { return step.ExitSafeToReboot{Err: errors.Errorf("Unable to mmap /dev/mem: %v", err)} diff --git a/tools/flashy/checks_and_remediations/common/90_expose_real_flash0_on_secondary_boot_test.go b/tools/flashy/checks_and_remediations/common/90_expose_real_flash0_on_secondary_boot_test.go index f16a6210034d..9f2d149c7465 100644 --- a/tools/flashy/checks_and_remediations/common/90_expose_real_flash0_on_secondary_boot_test.go +++ b/tools/flashy/checks_and_remediations/common/90_expose_real_flash0_on_secondary_boot_test.go @@ -184,29 +184,4 @@ func TestExposeRealFlash0OnSecondaryBoot(t *testing.T) { } }) - - t.Run("Should bail out if running old versions of galaxy cmm", func(t *testing.T) { - var buf bytes.Buffer - log.SetOutput(&buf) - - GetMachineOrig := utils.GetMachine - defer func() { utils.GetMachine = GetMachineOrig }() - utils.GetMachine = func() (string, error) { return "armv6l", nil } - - utils.GetOpenBMCVersionFromIssueFile = func() (string, error) { return "cmm-v29", nil} - - res := ExposeRealFlash0OnSecondaryBoot(step.StepParams{}) - - if res != nil { - t.Errorf("Expected ExposeRealFlash0OnSecondaryBoot() to return nil, got %v", res) - } - - re_expected_log_buffer := "" + - "^[^\n]+Old galaxy cmm version detected .cmm-v29., skipping step..." - - if !regexp.MustCompile(re_expected_log_buffer).Match(buf.Bytes()) { - t.Errorf("Unexpected log buffer: %v", buf.String()) - } - - }) } diff --git a/tools/flashy/checks_and_remediations/galaxy100/00_erase_data_partition.go b/tools/flashy/checks_and_remediations/galaxy100/00_erase_data_partition.go deleted file mode 100644 index aba68705eb31..000000000000 --- a/tools/flashy/checks_and_remediations/galaxy100/00_erase_data_partition.go +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright 2020-present Facebook. All Rights Reserved. - * - * This program file is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program in a file named COPYING; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -package remediations_galaxy100 - -import ( - "log" - "time" - - "github.com/facebook/openbmc/tools/flashy/lib/fileutils" - "github.com/facebook/openbmc/tools/flashy/lib/flash/flashutils" - "github.com/facebook/openbmc/tools/flashy/lib/step" - "github.com/facebook/openbmc/tools/flashy/lib/utils" - "github.com/pkg/errors" -) - -func init() { - step.RegisterStep(eraseDataPartition) -} - -var diagPaths = []string{ - "/mnt/data/Diag_FAB", - "/mnt/data/Diag_LC", -} - -// eraseDataPartition works around JFFS failures caused by Diag_LC and Diag_FAB -// in the /mnt/data partition. -// Galaxy has LCs (line cards) and FABs (fabric cards). -// This step can be removed after next galaxy card update. -func eraseDataPartition(stepParams step.StepParams) step.StepExitError { - data0, err := flashutils.GetFlashDevice("mtd:data0") - if err != nil { - log.Printf("Skipping this step: no data0 partition found: %v", err) - return nil - } - - for _, p := range diagPaths { - if fileutils.DirExists(p) { - log.Printf("Galaxy100 card with '%v' present, erasing data0 partition '%v'.", - p, data0) - - mounted, err := utils.IsDataPartitionMounted() - if err != nil { - return step.ExitSafeToReboot{ - errors.Errorf("Failed to check if /mnt/data is mounted: %v", err), - } - } - if mounted { - return step.ExitSafeToReboot{ - errors.Errorf("/mnt/data is still mounted, this may mean that the " + - "unmount data partition step fell back to remounting RO. This current step " + - "needs /mnt/data to be completely unmounted!"), - } - } - - eraseCmd := []string{ - "flash_eraseall", - "-j", - data0.GetFilePath(), - } - _, err, _, _ = utils.RunCommand(eraseCmd, 15*time.Minute) - if err != nil { - return step.ExitSafeToReboot{ - errors.Errorf("Failed to erase data0 partition: %v", err), - } - } - log.Printf("Successfully erased data0 partition.") - return nil - } - } - - return nil -} diff --git a/tools/flashy/checks_and_remediations/galaxy100/00_erase_data_partition_test.go b/tools/flashy/checks_and_remediations/galaxy100/00_erase_data_partition_test.go deleted file mode 100644 index 85d4646f8d61..000000000000 --- a/tools/flashy/checks_and_remediations/galaxy100/00_erase_data_partition_test.go +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright 2020-present Facebook. All Rights Reserved. - * - * This program file is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program in a file named COPYING; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -package remediations_galaxy100 - -import ( - "reflect" - "strings" - "testing" - "time" - - "github.com/facebook/openbmc/tools/flashy/lib/fileutils" - "github.com/facebook/openbmc/tools/flashy/lib/flash/flashutils" - "github.com/facebook/openbmc/tools/flashy/lib/flash/flashutils/devices" - "github.com/facebook/openbmc/tools/flashy/lib/step" - "github.com/facebook/openbmc/tools/flashy/lib/utils" - "github.com/pkg/errors" -) - -type mockFlashDevice struct { -} - -func (m *mockFlashDevice) GetType() string { return "mocktype" } -func (m *mockFlashDevice) GetSpecifier() string { return "mockspec" } -func (m *mockFlashDevice) GetFilePath() string { return "/dev/mock" } -func (m *mockFlashDevice) GetFileSize() uint64 { return uint64(1234) } -func (m *mockFlashDevice) MmapRO() ([]byte, error) { return nil, nil } -func (m *mockFlashDevice) Munmap([]byte) error { return nil } -func (m *mockFlashDevice) Validate() error { return nil } - -func TestEraseDataPartition(t *testing.T) { - // mock and defer restore GetFlashDevice, DirExists and RunCommand - getFlashDeviceOrig := flashutils.GetFlashDevice - isDataPartitionMountedOrig := utils.IsDataPartitionMounted - dirExistsOrig := fileutils.DirExists - runCommandOrig := utils.RunCommand - defer func() { - flashutils.GetFlashDevice = getFlashDeviceOrig - utils.IsDataPartitionMounted = isDataPartitionMountedOrig - fileutils.DirExists = dirExistsOrig - utils.RunCommand = runCommandOrig - }() - - flashDevice := &mockFlashDevice{} - - cases := []struct { - name string - getFlashDeviceErr error - dirsExist []string - dataPartMounted bool - dataPartErr error - wantCmds []string - cmdErr error - want step.StepExitError - }{ - { - name: "found and erased", - getFlashDeviceErr: nil, - dirsExist: []string{ - "/mnt/data/Diag_FAB", - "/mnt/data/Diag_LC", - }, - dataPartMounted: false, - dataPartErr: nil, - wantCmds: []string{"flash_eraseall -j /dev/mock"}, - cmdErr: nil, - want: nil, - }, - { - name: "No 'data0' partition found", - getFlashDeviceErr: errors.Errorf("not found"), - dirsExist: []string{}, - dataPartMounted: false, - dataPartErr: nil, - wantCmds: []string{}, - cmdErr: nil, - want: nil, - }, - { - name: "No Diag paths found", - getFlashDeviceErr: nil, - dirsExist: []string{}, - dataPartMounted: false, - dataPartErr: nil, - wantCmds: []string{}, - cmdErr: nil, - want: nil, - }, - { - name: "flash_eraseall failed", - getFlashDeviceErr: nil, - dirsExist: []string{ - "/mnt/data/Diag_FAB", - "/mnt/data/Diag_LC", - }, - dataPartMounted: false, - dataPartErr: nil, - wantCmds: []string{"flash_eraseall -j /dev/mock"}, - cmdErr: errors.Errorf("flash_eraseall failed"), - want: step.ExitSafeToReboot{ - errors.Errorf("Failed to erase data0 partition: flash_eraseall failed"), - }, - }, - { - name: "error checking /mnt/data mount status", - getFlashDeviceErr: nil, - dirsExist: []string{ - "/mnt/data/Diag_FAB", - }, - dataPartMounted: false, - dataPartErr: errors.Errorf("check failed"), - wantCmds: []string{}, - cmdErr: nil, - want: step.ExitSafeToReboot{ - errors.Errorf("Failed to check if /mnt/data is mounted: check failed"), - }, - }, - { - name: "/mnt/data still mounted (RO, possibly)", - getFlashDeviceErr: nil, - dirsExist: []string{ - "/mnt/data/Diag_FAB", - }, - dataPartMounted: true, - dataPartErr: nil, - wantCmds: []string{}, - cmdErr: nil, - want: step.ExitSafeToReboot{ - errors.Errorf("/mnt/data is still mounted, this may mean that the " + - "unmount data partition step fell back to remounting RO. This current step " + - "needs /mnt/data to be completely unmounted!"), - }, - }, - } - - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - gotCmds := []string{} - flashutils.GetFlashDevice = func(deviceID string) (devices.FlashDevice, error) { - if deviceID != "mtd:data0" { - t.Errorf("deviceID: want '%v' got '%v'", "mtd:data0", deviceID) - } - return flashDevice, tc.getFlashDeviceErr - } - fileutils.DirExists = func(filename string) bool { - return utils.StringFind(filename, tc.dirsExist) >= 0 - } - utils.RunCommand = func(cmdArr []string, timeout time.Duration) (int, error, string, string) { - gotCmds = append(gotCmds, strings.Join(cmdArr, " ")) - return 0, tc.cmdErr, "", "" - } - utils.IsDataPartitionMounted = func() (bool, error) { - return tc.dataPartMounted, tc.dataPartErr - } - - got := eraseDataPartition(step.StepParams{}) - step.CompareTestExitErrors(tc.want, got, t) - if !reflect.DeepEqual(tc.wantCmds, gotCmds) { - t.Errorf("cmds: want '%v' got '%v'", tc.wantCmds, gotCmds) - } - }) - } -} diff --git a/tools/flashy/install/install.go b/tools/flashy/install/install.go index ac7ede289d9d..7b9afbd436b2 100644 --- a/tools/flashy/install/install.go +++ b/tools/flashy/install/install.go @@ -31,7 +31,6 @@ import ( // all packages containing steps must be included to successfully run install _ "github.com/facebook/openbmc/tools/flashy/checks_and_remediations/bletchley" _ "github.com/facebook/openbmc/tools/flashy/checks_and_remediations/common" - _ "github.com/facebook/openbmc/tools/flashy/checks_and_remediations/galaxy100" _ "github.com/facebook/openbmc/tools/flashy/checks_and_remediations/wedge100" _ "github.com/facebook/openbmc/tools/flashy/checks_and_remediations/yamp" _ "github.com/facebook/openbmc/tools/flashy/flash_procedure" diff --git a/tools/flashy/lib/utils/system.go b/tools/flashy/lib/utils/system.go index 67d22cf3f49f..b972034ad2fa 100644 --- a/tools/flashy/lib/utils/system.go +++ b/tools/flashy/lib/utils/system.go @@ -301,7 +301,7 @@ var GetOpenBMCVersionFromIssueFile = func() (string, error) { } etcIssueStr := strings.ToLower(string(etcIssueBuf)) - // handle ancient galaxy100 linecard release with missing version info + // handle ancient release with missing version info if strings.HasPrefix(etcIssueStr, "openbmc release \n") { return "unknown-v1", nil } diff --git a/tools/flashy/lib/utils/system_test.go b/tools/flashy/lib/utils/system_test.go index 9c8375bea362..57c0f5eb0c2e 100644 --- a/tools/flashy/lib/utils/system_test.go +++ b/tools/flashy/lib/utils/system_test.go @@ -565,7 +565,7 @@ func TestGetOpenBMCVersionFromIssueFile(t *testing.T) { wantErr: nil, }, { - name: "ancient galaxy100 /etc/issue", + name: "ancient /etc/issue", etcIssueContents: `OpenBMC Release `, etcIssueReadErr: nil, diff --git a/tools/flashy/lib/validate/compatibility_test.go b/tools/flashy/lib/validate/compatibility_test.go index dbdb2e3ec825..7267d2fd4a01 100644 --- a/tools/flashy/lib/validate/compatibility_test.go +++ b/tools/flashy/lib/validate/compatibility_test.go @@ -94,13 +94,13 @@ func TestCheckImageBuildNameCompatibility(t *testing.T) { { name: "ancient image", etcIssueVer: "unknown-v52.1", - imageFileVer: "wedge40-v2019.01.3", + imageFileVer: "wedge400-v2019.01.3", want: nil, }, { name: "older image", etcIssueVer: "unknown-v42", - imageFileVer: "wedge40-v2019.01.3", + imageFileVer: "wedge400-v2019.01.3", want: nil, }, }