Skip to content

Commit c1c3e01

Browse files
committed
turn off pcie_aspm
1 parent c52be9f commit c1c3e01

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pibox-host",
3-
"version": "1.48.0",
3+
"version": "1.49.0",
44
"private": true,
55
"bin": "server.js",
66
"scripts": {

public/favicon.png

1.68 KB
Loading

server.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const handle = app.getRequestHandler()
2929
async function start() {
3030
console.log('Starting PiBox Host')
3131
await startFramebuffer()
32+
await checkBootFirmwareCmdline()
3233
await getVersion()
3334
app.prepare().then(async () => {
3435
createServer((req, res) => {
@@ -92,9 +93,10 @@ async function getOrCreateKeys() {
9293
}
9394

9495
async function startFramebuffer() {
96+
const path = '/boot/firmware/config.txt'
9597
try {
9698
// Check that SPI is enabled
97-
let bootConfigLines = (await readFile('/boot/config.txt', 'utf8')).split('\n')
99+
let bootConfigLines = (await readFile(path, 'utf8')).split('\n')
98100
let requiresReboot = false
99101
bootConfigLines = bootConfigLines.map((line) => {
100102
if (line === 'dtparam=spi=off' || line === '#dtparam=spi=on' || line === '#dtparam=spi=off') {
@@ -106,7 +108,8 @@ async function startFramebuffer() {
106108
})
107109
if (requiresReboot) {
108110
console.log('Enabling SPI, rebooting...')
109-
await writeFile('/boot/config.txt', bootConfigLines.join('\n'))
111+
await writeFile(path, bootConfigLines.join('\n'))
112+
await execAsync('sync')
110113
await execAsync('reboot now')
111114
process.exit()
112115
}
@@ -119,6 +122,23 @@ async function startFramebuffer() {
119122
}
120123
}
121124

125+
async function checkBootFirmwareCmdline() {
126+
let cmdlineOpts = (await readFile('/boot/firmware/cmdline.txt', 'utf8')).split(' ')
127+
const includesPcieAspm = cmdlineOpts.find((opt) => opt.startsWith('pcie_aspm='))
128+
if (includesPcieAspm) {
129+
console.log('✓ PCIe ASPM mode set:', includesPcieAspm)
130+
} else {
131+
// insert pcie_aspm=off before rootwait
132+
const rootwaitIndex = cmdlineOpts.indexOf('rootwait')
133+
cmdlineOpts.splice(rootwaitIndex, 0, 'pcie_aspm=off')
134+
console.log('Disabling PCIe ASPM mode, rebooting...')
135+
await writeFile('/boot/firmware/cmdline.txt', cmdlineOpts.join(' '))
136+
await execAsync('sync')
137+
await execAsync('reboot now')
138+
process.exit()
139+
}
140+
}
141+
122142
async function getVersion() {
123143
try {
124144
const pkgPath = process.cwd() + '/package.json'

0 commit comments

Comments
 (0)