{"id":20255816,"url":"https://github.com/samcv/a485-rtl8822be-firmware","last_synced_at":"2025-09-19T01:58:08.261Z","repository":{"id":152732708,"uuid":"152661668","full_name":"samcv/A485-RTL8822BE-firmware","owner":"samcv","description":"Firmware for RTL8822BE to Fix Bluetooth on the Lenovo A485","archived":false,"fork":false,"pushed_at":"2018-12-12T05:43:37.000Z","size":91,"stargazers_count":12,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-19T01:58:07.293Z","etag":null,"topics":["a485","bluetooth","firmware","lenovo","linux","realtek","rtl8822be","thinkpad","wifi"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samcv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-11T22:08:45.000Z","updated_at":"2021-09-14T06:28:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"817e69ac-9963-44bc-a265-0cf76cbf457d","html_url":"https://github.com/samcv/A485-RTL8822BE-firmware","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samcv/A485-RTL8822BE-firmware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samcv%2FA485-RTL8822BE-firmware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samcv%2FA485-RTL8822BE-firmware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samcv%2FA485-RTL8822BE-firmware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samcv%2FA485-RTL8822BE-firmware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samcv","download_url":"https://codeload.github.com/samcv/A485-RTL8822BE-firmware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samcv%2FA485-RTL8822BE-firmware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275867739,"owners_count":25542807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a485","bluetooth","firmware","lenovo","linux","realtek","rtl8822be","thinkpad","wifi"],"created_at":"2024-11-14T10:41:24.559Z","updated_at":"2025-09-19T01:58:08.187Z","avatar_url":"https://github.com/samcv.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bluetooth fix for Lenovo A485 (and possibly others with RTL8822BE wifi)\n\n## Steps\n\n1. Download [`rtl8822befw.bin`](https://github.com/samcv/A485-RTL8822BE-firmware/raw/master/rtl8822befw.bin) and\n[`rtl_bt-rtl8822b_fw.bin`](https://github.com/samcv/A485-RTL8822BE-firmware/raw/master/rtl_bt-rtl8822b_fw.bin)\n2. Backup old wifi firmware ` sudo cp /lib64/firmware/rtlwifi/rtl8822befw.bin /lib64/firmware/rtlwifi/rtl8822befw.bin.bak`\n3. Backup old bluetooth firmware `sudo cp /lib64/firmware/rtl_bt/rtl8822b_fw.bin /lib64/firmware/rtl_bt/rtl8822b_fw.bin.bak`\n4. Copy new wifi firmware: `sudo cp rtl8822befw.bin /lib64/firmware/rtlwifi/rtl8822befw.bin`\n5. copy new Bluetooth firmware: `sudo cp rtl_bt-rtl8822b_fw.bin /lib64/firmware/rtl_bt/rtl8822b_fw.bin`\n6. Reboot (though putting it to sleep may work too).\n* Note: firmware may be in `/lib/firmware` instead of `/lib64/firmware` on some systems\n\n## Caveats\nBluetooth will start working the first time the laptop comes out of sleep. So if you restart your computer, you will\nhave to put it to sleep and wake it up. The bluetooth will then be fully functional. This is probably caused by a bug in the\nkernel code which handles loading of the bluetooth firmware. Both wifi and bluetooth firmware must be loaded to the card\non startup and on resuming from sleep; for whatever reason the kernel doesn't try and load bluetooth firmware no boot but resume works fine.\n\n\n## Where is this firmware from? How did you get it?\n\nWith a fair amount of effort I was able to extract the Lenovo provided firmware\nfor this wifi card.\n\nHow did I do this?\nAfter much debugging trying to fix the bluetooth on Linux I decided to try another approach. I downloaded the Windows wifi driver from Lenovo\n[`801373fb20311f5acc45476c7caeeb45b7fc39fb r0wrw05w.exe`](https://support.lenovo.com/us/en/downloads/ds504117)\n\nAfter installing it you will find a binary blob located at `C:/DRIVERS/WLAN Driver/Source/rtwlane.sys` (sha1sum `eb63b4db367003382d3189e23f57798c1661815e`). The problem was to\nfind where in this large file the firmware was (where it started and where it ended).\nI ended up spending a lot of time in a hex editor viewing this binary blob and the current\nlinux-firmware provided one. After identifying where I thought the start of the file was (at bytes `22 88 00`),\nthe next issue was where it ended. Not finding any real identifier at the end of the\nlinux-firmware version I looked to the Linux source code where the firmware is loaded.\nYou want `drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c` in function\nhalmac_download_firmware_88xx(). Here I was able to find the validation code that is used to validate\nfirmware prior to loading. Lucky for me there are 4 or so locations toward the start of the firmware\nwhich after some operations are applied to it allow it to validate the firmware has the correct length.\nBy using the hex editor and finding these locations I was able to find the correct length of the firmware.\n\nIn case anybody doesn't trust the firmware I provide you can download Lenovo's firmware (check that the sha1sum is the\nsame) and do:\n\n```\ndd if=rtwlane.sys of=rtl8822befw.bin skip=4932176 bs=1 count=78320\n```\n\nFinal result should have the following checksum:\n`0017b27df0dcd9b944f40fce873487b80c3d9eb4  rtl8822befw.bin`\n\nThe Bluetooth firmware was far easier, once the Lenovo [driver download](https://pcsupport.lenovo.com/us/en/products/LAPTOPS-AND-NETBOOKS/THINKPAD-A-SERIES-LAPTOPS/THINKPAD-A485-TYPE-20MU-20MV/downloads/DS504118) is installed, the Bluetooth firmware is at `C:/DRIVERS/Bluetooth Driver/Source/rtl8822b_mp_chip_bt40_fw_asic_rom_patch_new.dll` with sha1sum a4288e0e7b3f818d50251e8115885ed35b11beef\n\nWhat | offset | width | Description|Hex Data|Value\n-----|--------|-------|-------------|-------|------\nHALMAC_FWHDR_OFFSET_VERSION_88XX | 4 | 2 bytes | Major firmware version number|14|20\nHALMAC_FWHDR_OFFSET_SUBVERSION_88XX | 6 | 1 byte | Minor firmware version number|04|4\nHALMAC_FWHDR_OFFSET_SUBINDEX_88XX | 7 | 1 byte | Patch firmware version number|00|0\nHALMAC_FWHDR_OFFSET_MEM_USAGE_88XX | 24 | 1 byte || 08 | 8\nHALMAC_FWHDR_OFFSET_DMEM_SIZE_88XX | 36 | 4 bytes ||D8 0B 00 |3032\nHALMAC_FWHDR_OFFSET_IRAM_SIZE_88XX |48 | 4 bytes| |C8 25 01|75208\nHALMAC_FWHDR_OFFSET_ERAM_SIZE_88XX| 52|4 bytes| |00 00 00 | 0\n\nStatic Values:\n* HALMAC_FW_CHKSUM_DUMMY_SIZE_88XX = 8\n* HALMAC_FWHDR_SIZE_88XX = 64\n\nSimplified\n\n```\n/* Simplified algorithm based on code in halmac_api_88xx.c */\ndmem_pkt_size = DMEM_SIZE + HALMAC_FW_CHKSUM_DUMMY_SIZE_88XX;\niram_pkt_size = IRAM_SIZE + HALMAC_FW_CHKSUM_DUMMY_SIZE_88XX;\nif ((MEM_USAGE \u0026 4) != 0)\n    eram_pkt_size = ERAM_SIZE;\nif (eram_pkt_size != 0)\n    eram_pkt_size += HALMAC_FW_CHKSUM_DUMMY_SIZE_88XX;\nhalmac_fw_size = (HALMAC_FWHDR_SIZE_88XX + dmem_pkt_size + iram_pkt_size + eram_pkt_size);\n/* Now solving for halmac_fw_size by using our calculated values: */\n78320          =            64           +   (3032+8)    + (75208+8)     + (0)\n\n```\n\nThe Lenovo provided firmware shows this is version 20.4.0 based on the above values stored in those offsets. All values\nare little endian by the way.\n\n# Hardware info\nUSB shows up as:\n`Bus 004 Device 008: ID 0bda:b023 Realtek Semiconductor Corp. `\nWifi shows up as:\n`02:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8822BE 802.11a/b/g/n/ac WiFi adapter [10ec:b822]`\n\n\n# 18 October Lenovo Update:\nOn 18 October Lenovo published an update which also contains updated firmware,\nupdating it from version 20.4.0 to 27.2.0.\n\n```\nVersion: 1B: 27\nSubver: 02: 2\npatch: 0\nHALMAC_FWHDR_OFFSET_MEM_USAGE_88XX | 08 | 8\nHALMAC_FWHDR_OFFSET_DMEM_SIZE_88XX | 58 2C 00 00 | 11352\nHALMAC_FWHDR_OFFSET_IRAM_SIZE_88XX | 20 72 02 00 | 160288\nHALMAC_FWHDR_OFFSET_ERAM_SIZE_88XX | 00 00 00 00 | 0\n\n171720 = 64 + (11352 +8) + (160288+8) + 0\n```\n\n\nsha1sum of the 27.2.0 firmware is 25d2ba457bc1884e81b2579a249e960dbbc997c2\nafter extracting it from rtwlane.sys.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamcv%2Fa485-rtl8822be-firmware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamcv%2Fa485-rtl8822be-firmware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamcv%2Fa485-rtl8822be-firmware/lists"}