diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in index ef51e5db5..b7223dc5c 100644 --- a/contrib/fwupd.spec.in +++ b/contrib/fwupd.spec.in @@ -233,7 +233,6 @@ mkdir -p --mode=0700 $RPM_BUILD_ROOT%{_localstatedir}/lib/fwupd/gnupg %{_libdir}/fwupd-plugins-3/libfu_plugin_dfu.so %{_libdir}/fwupd-plugins-3/libfu_plugin_ebitdo.so %{_libdir}/fwupd-plugins-3/libfu_plugin_nitrokey.so -%{_libdir}/fwupd-plugins-3/libfu_plugin_raspberrypi.so %{_libdir}/fwupd-plugins-3/libfu_plugin_steelseries.so %if 0%{?have_dell} %{_libdir}/fwupd-plugins-3/libfu_plugin_synapticsmst.so diff --git a/plugins/meson.build b/plugins/meson.build index 8d7774ee7..4567e192d 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -1,6 +1,5 @@ subdir('dfu') subdir('ebitdo') -subdir('raspberrypi') subdir('steelseries') subdir('nitrokey') subdir('test') diff --git a/plugins/raspberrypi/README.md b/plugins/raspberrypi/README.md deleted file mode 100644 index 62ad11108..000000000 --- a/plugins/raspberrypi/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Raspberry Pi Support -==================== - -Introduction ------------- - -This plugin can flash the boot firmware on the Raspberry Pi. It is not endorsed -by the Raspberry Pi foundation. diff --git a/plugins/raspberrypi/fu-plugin-raspberrypi.c b/plugins/raspberrypi/fu-plugin-raspberrypi.c deleted file mode 100644 index 80ead56fc..000000000 --- a/plugins/raspberrypi/fu-plugin-raspberrypi.c +++ /dev/null @@ -1,234 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2015-2016 Richard Hughes - * - * Licensed under the GNU General Public License Version 2 - * - * This program 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; either version 2 of the License, or - * (at your option) any later version. - * - * 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include -#include - -#include "fu-plugin.h" -#include "fu-plugin-vfuncs.h" -#include "fu-plugin-raspberrypi.h" - -#define FU_PLUGIN_RPI_FIRMWARE_FILENAME "start.elf" - -struct FuPluginData { - gchar *fw_dir; -}; - -static gchar * -fu_plugin_raspberrypi_strstr (const guint8 *haystack, - gsize haystack_len, - const gchar *needle, - gsize *offset) -{ - gsize needle_len; - - if (needle == NULL || needle[0] == '\0') - return NULL; - if (haystack == NULL || haystack_len == 0) - return NULL; - needle_len = strlen (needle); - if (needle_len > haystack_len) - return NULL; - for (gsize i = 0; i < haystack_len - needle_len; i++) { - if (memcmp (haystack + i, needle, needle_len) == 0) { - if (offset != NULL) - *offset = i + needle_len; - return g_strdup ((const gchar *) &haystack[i + needle_len]); - } - } - return NULL; -} - -static gboolean -fu_plugin_raspberrypi_parse_firmware (FuDevice *device, const gchar *fn, GError **error) -{ - GDate *date; - gsize len = 0; - gsize offset; - g_autofree gchar *fwver = NULL; - g_autofree gchar *platform = NULL; - g_autofree gchar *vc_date = NULL; - g_autofree gchar *vc_time = NULL; - g_autofree guint8 *data = NULL; - - /* read file -- things we can find are: - * - * VC_BUILD_ID_USER: dc4 - * VC_BUILD_ID_TIME: 14:58:37 - * VC_BUILD_ID_BRANCH: master - * VC_BUILD_ID_TIME: Aug 3 2015 - * VC_BUILD_ID_HOSTNAME: dc4-XPS13-9333 - * VC_BUILD_ID_PLATFORM: raspberrypi_linux - * VC_BUILD_ID_VERSION: 4b51d81eb0068a875b336f4cc2c468cbdd06d0c5 (clean) - */ - if (!g_file_get_contents (fn, (gchar **) &data, &len, error)) - return FALSE; - - /* check the platform matches */ - platform = fu_plugin_raspberrypi_strstr (data, len, - "VC_BUILD_ID_PLATFORM: ", - NULL); - if (g_strcmp0 (platform, "raspberrypi_linux") != 0) { - g_set_error (error, - FWUPD_ERROR, - FWUPD_ERROR_INVALID_FILE, - "not a RasberryPi, platform is %s", - platform); - return FALSE; - } - - /* find the VC_BUILD info which paradoxically is split into two - * string segments */ - vc_time = fu_plugin_raspberrypi_strstr (data, len, - "VC_BUILD_ID_TIME: ", &offset); - if (vc_time == NULL) { - g_set_error_literal (error, - FWUPD_ERROR, - FWUPD_ERROR_INVALID_FILE, - "Failed to get 1st VC_BUILD_ID_TIME"); - return FALSE; - } - vc_date = fu_plugin_raspberrypi_strstr (data + offset, len - offset, - "VC_BUILD_ID_TIME: ", NULL); - if (vc_date == NULL) { - g_set_error_literal (error, - FWUPD_ERROR, - FWUPD_ERROR_INVALID_FILE, - "Failed to get 2nd VC_BUILD_ID_TIME"); - return FALSE; - } - - /* parse the date */ - date = g_date_new (); - g_date_set_parse (date, vc_date); - if (!g_date_valid (date)) { - g_set_error (error, - FWUPD_ERROR, - FWUPD_ERROR_INVALID_FILE, - "Failed to parse date '%s'", - vc_date); - return FALSE; - } - - /* create a version number from the date and time */ - fwver = g_strdup_printf ("%04i%02u%02i", - g_date_get_year (date), - g_date_get_month (date), - g_date_get_day (date)); - fu_device_set_version (device, fwver); - - g_date_free (date); - return TRUE; -} - -gboolean -fu_plugin_update (FuPlugin *plugin, - FuDevice *device, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) -{ - FuPluginData *data = fu_plugin_get_data (plugin); - g_autofree gchar *fwfn = NULL; - - /* decompress anything matching either glob */ - fu_device_set_status (device, FWUPD_STATUS_DEVICE_WRITE); - if (!fu_common_extract_archive (blob_fw, data->fw_dir, error)) - return FALSE; - - /* get the new VC build info */ - fu_device_set_status (device, FWUPD_STATUS_DEVICE_VERIFY); - fwfn = g_build_filename (data->fw_dir, - FU_PLUGIN_RPI_FIRMWARE_FILENAME, - NULL); - return fu_plugin_raspberrypi_parse_firmware (device, fwfn, error); -} - -void -fu_plugin_raspberrypi_set_fw_dir (FuPlugin *plugin, const gchar *fw_dir) -{ - FuPluginData *data = fu_plugin_get_data (plugin); - g_free (data->fw_dir); - data->fw_dir = g_strdup (fw_dir); - g_mkdir_with_parents (fw_dir, 0700); -} - -void -fu_plugin_init (FuPlugin *plugin) -{ - FuPluginData *data = fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); - const gchar *tmp; - - /* allow this to be overidden for testing */ - data->fw_dir = g_strdup ("/boot"); - tmp = g_getenv ("FWUPD_RPI_FW_DIR"); - if (tmp != NULL) - fu_plugin_raspberrypi_set_fw_dir (plugin, tmp); -} - -void -fu_plugin_destroy (FuPlugin *plugin) -{ - FuPluginData *data = fu_plugin_get_data (plugin); - g_free (data->fw_dir); -} - -gboolean -fu_plugin_coldplug (FuPlugin *plugin, GError **error) -{ - FuPluginData *data = fu_plugin_get_data (plugin); - g_autofree gchar *fwfn = NULL; - g_autoptr(FuDevice) device = NULL; - - /* anything interesting */ - fwfn = g_build_filename (data->fw_dir, - FU_PLUGIN_RPI_FIRMWARE_FILENAME, - NULL); - if (!g_file_test (fwfn, G_FILE_TEST_EXISTS)) { - g_set_error (error, - FWUPD_ERROR, - FWUPD_ERROR_NOT_SUPPORTED, - "Raspberry PI firmware updating not supported, no %s", - fwfn); - return FALSE; - } - - /* create fake device */ - device = fu_device_new (); - fu_device_set_id (device, "raspberry-pi"); - fu_device_add_guid (device, "raspberrypi"); - fu_device_set_name (device, "Raspberry Pi"); - fu_device_set_vendor (device, "Raspberry Pi Foundation"); - fu_device_set_summary (device, "A tiny and affordable computer"); - fu_device_add_icon (device, "computer"); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_INTERNAL); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_REQUIRE_AC); - - /* get the VC build info */ - if (!fu_plugin_raspberrypi_parse_firmware (device, fwfn, error)) - return FALSE; - - fu_plugin_device_add (plugin, device); - return TRUE; -} diff --git a/plugins/raspberrypi/fu-plugin-raspberrypi.h b/plugins/raspberrypi/fu-plugin-raspberrypi.h deleted file mode 100644 index 4245bb7c4..000000000 --- a/plugins/raspberrypi/fu-plugin-raspberrypi.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2016 Richard Hughes - * - * Licensed under the GNU General Public License Version 2 - * - * This program 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; either version 2 of the License, or - * (at your option) any later version. - * - * 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __FU_PLUGIN_RPI_H -#define __FU_PLUGIN_RPI_H - -G_BEGIN_DECLS - -void fu_plugin_raspberrypi_set_fw_dir (FuPlugin *plugin, - const gchar *fw_dir); - -G_END_DECLS - -#endif /* __FU_PLUGIN_RPI_H */ diff --git a/plugins/raspberrypi/fu-self-test.c b/plugins/raspberrypi/fu-self-test.c deleted file mode 100644 index 00b1b2743..000000000 --- a/plugins/raspberrypi/fu-self-test.c +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2015-2016 Richard Hughes - * - * Licensed under the GNU General Public License Version 2 - * - * This program 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; either version 2 of the License, or - * (at your option) any later version. - * - * 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include -#include -#include -#include - -#include "fu-plugin-private.h" -#include "fu-plugin-raspberrypi.h" -#include "fu-test.h" - -static void -_plugin_status_changed_cb (FuDevice *device, GParamSpec *pspec, gpointer user_data) -{ - guint *cnt = (guint *) user_data; - g_debug ("device %s now %s", - fu_device_get_id (device), - fwupd_status_to_string (fu_device_get_status (device))); - (*cnt)++; -} - -static void -_plugin_device_added_cb (FuPlugin *plugin, FuDevice *device, gpointer user_data) -{ - FuDevice **dev = (FuDevice **) user_data; - *dev = g_object_ref (device); -} -static void -fu_plugin_raspberrypi_func (void) -{ - gboolean ret; - guint cnt = 0; - g_autoptr(GError) error = NULL; - g_autofree gchar *path = NULL; - g_autofree gchar *pending_db = NULL; - g_autofree gchar *fwfile = NULL; - g_autoptr(FuDevice) device = NULL; - g_autoptr(FuPlugin) plugin = NULL; - g_autoptr(GBytes) blob_fw = NULL; - g_autoptr(GMappedFile) mapped_file = NULL; - - /* test location */ - path = fu_test_get_filename (TESTDATADIR, "rpiboot"); - if (path == NULL) { - g_test_skip ("no rpiboot available"); - return; - } - - /* create a fake device */ - plugin = fu_plugin_new (); - ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_raspberrypi.so", &error); - g_assert_no_error (error); - g_assert (ret); - - fu_plugin_raspberrypi_set_fw_dir (plugin, path); - g_signal_connect (plugin, "device-added", - G_CALLBACK (_plugin_device_added_cb), - &device); - ret = fu_plugin_runner_startup (plugin, &error); - g_assert_no_error (error); - g_assert (ret); - ret = fu_plugin_runner_coldplug (plugin, &error); - g_assert_no_error (error); - g_assert (ret); - - /* check we did the right thing */ - g_assert_cmpint (cnt, ==, 0); - g_assert (device != NULL); - g_assert_cmpstr (fu_device_get_id (device), ==, - "94f01ac16574856944fb7e7583db423360430f97"); - g_assert_cmpstr (fu_device_get_guid_default (device), ==, - "91dd7368-8640-5d72-a217-a505c034dd0b"); - g_assert_cmpstr (fu_device_get_version (device), ==, - "20150803"); - - /* ensure clean */ - g_unlink ("/tmp/rpiboot/start.elf"); - - /* do update */ - fu_plugin_raspberrypi_set_fw_dir (plugin, "/tmp/rpiboot"); - fwfile = fu_test_get_filename (TESTDATADIR, "rpiupdate/firmware.bin"); - g_assert (fwfile != NULL); - mapped_file = g_mapped_file_new (fwfile, FALSE, &error); - g_assert_no_error (error); - g_assert (mapped_file != NULL); - blob_fw = g_mapped_file_get_bytes (mapped_file); - g_signal_connect (device, "notify::status", - G_CALLBACK (_plugin_status_changed_cb), - &cnt); - ret = fu_plugin_runner_update (plugin, device, NULL, blob_fw, - FWUPD_INSTALL_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - g_assert_cmpint (cnt, ==, 2); - - /* check the file was exploded to the right place */ - g_assert (g_file_test ("/tmp/rpiboot/start.elf", G_FILE_TEST_EXISTS)); - g_assert (g_file_test ("/tmp/rpiboot/overlays/test.dtb", G_FILE_TEST_EXISTS)); - g_assert_cmpstr (fu_device_get_version (device), ==, - "20150805"); - - /* clean up */ - pending_db = g_build_filename (LOCALSTATEDIR, "lib", "fwupd", "pending.db", NULL); - g_unlink (pending_db); -} - -int -main (int argc, char **argv) -{ - g_test_init (&argc, &argv, NULL); - - /* only critical and error are fatal */ - g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL); - - g_assert_cmpint (g_mkdir_with_parents ("/tmp/fwupd-self-test/var/lib/fwupd", 0755), ==, 0); - - /* tests go here */ - g_test_add_func ("/fwupd/plugin{raspberrypi}", fu_plugin_raspberrypi_func); - return g_test_run (); -} diff --git a/plugins/raspberrypi/meson.build b/plugins/raspberrypi/meson.build deleted file mode 100644 index f5d5b5cce..000000000 --- a/plugins/raspberrypi/meson.build +++ /dev/null @@ -1,58 +0,0 @@ -subdir('rpiupdate') - -cargs = ['-DG_LOG_DOMAIN="FuPluginRpi"'] - -shared_module('fu_plugin_raspberrypi', - sources : [ - 'fu-plugin-raspberrypi.c', - ], - include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), - ], - install : true, - install_dir: plugin_dir, - c_args : [ - cargs, - '-DLOCALSTATEDIR="' + localstatedir + '"', - ], - dependencies : [ - plugin_deps, - ], -) - -if get_option('tests') - testdatadir_src = meson.current_source_dir() - testdatadir_dst = meson.current_build_dir() - e = executable( - 'raspberrypi-self-test', - raspberrypi_firmware_bin, - sources : [ - 'fu-self-test.c', - 'fu-plugin-raspberrypi.c', - ], - include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), - ], - dependencies : [ - plugin_deps, - sqlite, - valgrind, - ], - link_with : [ - fwupd, - libfwupdprivate, - ], - c_args : [ - cargs, - '-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"', - '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"', - '-DLOCALSTATEDIR="/tmp/fwupd-self-test/var"', - '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"', - ], - ) - test('raspberrypi-self-test', e) -endif diff --git a/plugins/raspberrypi/rpiboot/start.elf b/plugins/raspberrypi/rpiboot/start.elf deleted file mode 100644 index 731bf3e43..000000000 Binary files a/plugins/raspberrypi/rpiboot/start.elf and /dev/null differ diff --git a/plugins/raspberrypi/rpiupdate/README b/plugins/raspberrypi/rpiupdate/README deleted file mode 100644 index e69de29bb..000000000 diff --git a/plugins/raspberrypi/rpiupdate/firmware.inf b/plugins/raspberrypi/rpiupdate/firmware.inf deleted file mode 100644 index 9352063e0..000000000 --- a/plugins/raspberrypi/rpiupdate/firmware.inf +++ /dev/null @@ -1,19 +0,0 @@ -; Copyright (C) 2015 Richard Hughes - -[Version] -Class=Firmware -ClassGuid={f2e7dd72-6468-4e36-b6f1-6488f42c1b52} - -[Firmware_CopyFiles] -firmware.bin - -[Firmware_AddReg] -HKR,,FirmwareId,,{c77029fe-ffb2-3706-dc67-67af4a132afd} -HKR,,FirmwareVersion,%REG_DWORD%,0x0000000 -HKR,,FirmwareFilename,,firmware.bin - -[Strings] -Provider = "Raspberry Pi Foundation" -MfgName = "Raspberry Pi" -FirmwareDesc = "Raspberry Pi Firmware" -DiskName = "Firmware for the Raspberry Pi" diff --git a/plugins/raspberrypi/rpiupdate/firmware.metainfo.xml b/plugins/raspberrypi/rpiupdate/firmware.metainfo.xml deleted file mode 100644 index 9cdd02510..000000000 --- a/plugins/raspberrypi/rpiupdate/firmware.metainfo.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - c77029fe-ffb2-3706-dc67-67af4a132afd - Raspberry Pi Device Update - Firmware for the Raspberry Pi - -

- Updating the firmware on your Raspberry Pi device improves - performance and fixes reported bugs. -

-
- https://www.raspberrypi.org/ - CC0-1.0 - proprietary - Raspberry Pi Foundation - - - -

This release fixes device startup when running in FIXME mode.

-
-
-
-
diff --git a/plugins/raspberrypi/rpiupdate/meson.build b/plugins/raspberrypi/rpiupdate/meson.build deleted file mode 100644 index b262d5870..000000000 --- a/plugins/raspberrypi/rpiupdate/meson.build +++ /dev/null @@ -1,30 +0,0 @@ -tar = find_program('tar', required : false) -if tar.found() - raspberrypi_firmware_files = [ - 'README', - 'start.elf', - 'overlays/test.dtb', - ] - raspberrypi_firmware_bin = custom_target('raspberrypi-firmware-tar', - input : raspberrypi_firmware_files, - output : 'firmware.bin', - command : [ - tar, '--directory=' + meson.current_source_dir(), - '-cf', '@OUTPUT@', raspberrypi_firmware_files, - ], - ) -endif - -gcab = find_program('gcab', required : false) -if gcab.found() - raspberrypi_firmware_cab = custom_target('raspberrypi-firmware-cab', - input : [ - 'firmware.bin', - 'firmware.metainfo.xml', - ], - output : 'rpi-firmware-20150805.cab', - command : [ - gcab, '--create', '--nopath', '@OUTPUT@', '@INPUT@', - ], - ) -endif diff --git a/plugins/raspberrypi/rpiupdate/overlays/test.dtb b/plugins/raspberrypi/rpiupdate/overlays/test.dtb deleted file mode 100644 index e69de29bb..000000000 diff --git a/plugins/raspberrypi/rpiupdate/start.elf b/plugins/raspberrypi/rpiupdate/start.elf deleted file mode 100644 index 32577d8f0..000000000 Binary files a/plugins/raspberrypi/rpiupdate/start.elf and /dev/null differ