diff --git a/bolt/src/run.cjs b/bolt/src/run.cjs index 346ac54..27d3ffb 100644 --- a/bolt/src/run.cjs +++ b/bolt/src/run.cjs @@ -18,6 +18,7 @@ */ const { Remote } = require('./Remote.cjs'); +const runtime = require('./runtime-config.cjs'); const { makeTemplate, applyGPUConfig } = require('./runtime-config.cjs'); const config = require('./config.cjs'); @@ -302,45 +303,17 @@ function run(remoteName, pkg, options) { } setupResources(remote, pkg); - - const waylandSocketPath = getWaylandSocketPath(pkg); - if (remote.socketExists(waylandSocketPath)) { - bundleConfig.mounts.push({ - source: waylandSocketPath, - destination: waylandSocketPath, - type: "bind", - options: [ - "rbind", - "rw" - ] - }); - const pathArray = waylandSocketPath.split("/"); - bundleConfig.process.env.push(`WAYLAND_DISPLAY=${pathArray.pop()}`); - bundleConfig.process.env.push(`XDG_RUNTIME_DIR=${pathArray.join("/")}`); - } - - const rialtoSocketPath = getRialtoSocketPath(pkg); - if (remote.socketExists(rialtoSocketPath)) { - bundleConfig.mounts.push({ - source: rialtoSocketPath, - destination: rialtoSocketPath, - type: "bind", - options: [ - "rbind", - "rw" - ] - }); - bundleConfig.process.env.push(`RIALTO_SOCKET_PATH=${rialtoSocketPath}`); - } + const waylandAvailable = runtime.configureWaylandSocket(remote, bundleConfig, getWaylandSocketPath(pkg)); + const rialtoAvailable = runtime.configureRialtoSocket(remote, bundleConfig, getRialtoSocketPath(pkg)); layerDirs.reverse(); prepareBundle(remote, pkg, bundleConfig, layerDirs, options); - if (!remote.socketExists(rialtoSocketPath)) { + if (!rialtoAvailable) { console.warn('\n\n\x1b[31mRialto socket not available! Playback not supported!\x1b[0m\n\n'); } - if (!remote.socketExists(waylandSocketPath)) { + if (!waylandAvailable) { console.warn('\n\n\x1b[31mWayland socket not available! Graphics rendering not available!\x1b[0m\n\n'); } diff --git a/bolt/src/runtime-config.cjs b/bolt/src/runtime-config.cjs index bc0dcdb..ffc7bc5 100644 --- a/bolt/src/runtime-config.cjs +++ b/bolt/src/runtime-config.cjs @@ -302,17 +302,21 @@ function hexToNumber(str) { throw new Error(`Cannot parse ${str} as hex number`); } +function applyAccessRights(remote, groupIds, path, perm, groupName) { + if (perm[7] === "r" && perm[8] === "w") { + } else if (groupIds.includes(groupName) && perm[4] === "r" && perm[5] === "w") { + } else { + console.warn(`Changing access rights for ${path}! (was ${perm}, group: ${groupName})`); + remote.exec(`chmod a+rw ${path}`); + } +} + function processDevNodeEntry(remote, config, devNode, groupIds) { try { const [perm, majorHex, minorHex, groupName] = remote.exec(`stat -c '%A:%t:%T:%G' ${devNode}`).trim().split(":"); if (perm.length === 10 && (perm[0] === "c" || perm[0] === "b")) { addDevice(config, devNode, perm[0], hexToNumber(majorHex), hexToNumber(minorHex)); - if (perm[7] === "r" && perm[8] === "w") { - } else if (groupIds.includes(groupName) && perm[4] === "r" && perm[5] === "w") { - } else { - console.warn(`Changing access rights for ${devNode}! (was ${perm}, group: ${groupName})`); - remote.exec(`chmod a+rw ${devNode}`); - } + applyAccessRights(remote, groupIds, devNode, perm, groupName); } else { throw new Error(`not a device (perm: ${perm})`); } @@ -386,5 +390,48 @@ function applyGPUConfig(remote, config, gpuConfig) { } } +function configureWaylandSocket(remote, bundleConfig, waylandSocketPath) { + if (remote.socketExists(waylandSocketPath)) { + const [perm, groupName] = remote.exec(`stat -c '%A:%G' ${waylandSocketPath}`).trim().split(":"); + applyAccessRights(remote, [], waylandSocketPath, perm, groupName); + + bundleConfig.mounts.push({ + source: waylandSocketPath, + destination: waylandSocketPath, + type: "bind", + options: [ + "rbind", + "rw" + ] + }); + const pathArray = waylandSocketPath.split("/"); + bundleConfig.process.env.push(`WAYLAND_DISPLAY=${pathArray.pop()}`); + bundleConfig.process.env.push(`XDG_RUNTIME_DIR=${pathArray.join("/")}`); + return true; + } + return false; +} + +function configureRialtoSocket(remote, bundleConfig, rialtoSocketPath) { + if (remote.socketExists(rialtoSocketPath)) { + const [perm, groupName] = remote.exec(`stat -c '%A:%G' ${rialtoSocketPath}`).trim().split(":"); + applyAccessRights(remote, [], rialtoSocketPath, perm, groupName); + bundleConfig.mounts.push({ + source: rialtoSocketPath, + destination: rialtoSocketPath, + type: "bind", + options: [ + "rbind", + "rw" + ] + }); + bundleConfig.process.env.push(`RIALTO_SOCKET_PATH=${rialtoSocketPath}`); + return true; + } + return false; +} + exports.makeTemplate = makeTemplate; exports.applyGPUConfig = applyGPUConfig; +exports.configureWaylandSocket = configureWaylandSocket; +exports.configureRialtoSocket = configureRialtoSocket; diff --git a/gpu-layer-poc/brcm974116sff.json b/gpu-layer-poc/brcm974116sff.json new file mode 100644 index 0000000..3f78842 --- /dev/null +++ b/gpu-layer-poc/brcm974116sff.json @@ -0,0 +1,21 @@ +{ + "vendorGpuSupport": { + "devNodes": [ + "/dev/nexus", + "/dev/nexusmem", + "/dev/dri/card0", + "/dev/dri/card1", + "/dev/dri/renderD128" + ], + "groupIds": [ + "video" + ], + "files": [ + { + "type": "bind", + "source": "/tmp/nxserver_ipc", + "destination": "/tmp/nxserver_ipc" + } + ] + } +} diff --git a/gpu-layer-poc/setup-gpu-layer.sh b/gpu-layer-poc/setup-gpu-layer.sh index edf4ccd..4d1b4a5 100755 --- a/gpu-layer-poc/setup-gpu-layer.sh +++ b/gpu-layer-poc/setup-gpu-layer.sh @@ -45,6 +45,12 @@ LIBS+=(/usr/lib/libGLESv2.so) LIBS+=(/usr/lib/libGLESv2.so.2) LIBS+=(/usr/lib/libwayland-egl.so.1) +declare -A FILE_INFO_FALLBACK + +FILE_INFO_FALLBACK[/usr/lib/libEGL.so]="'libEGL.so' -> 'libEGL.so.1'" +FILE_INFO_FALLBACK[/usr/lib/libGLESv1_CM.so]="'libGLESv1_CM.so' -> 'libGLESv1_CM.so.1'" +FILE_INFO_FALLBACK[/usr/lib/libGLESv2.so]="'libGLESv2.so' -> 'libGLESv2.so.2'" + BASE_LIBS+=(libwayland-server.so) BASE_LIBS+=(libwayland-client.so) BASE_LIBS+=(libdl.so) @@ -115,11 +121,18 @@ function add_deps { function main { local config_name local tmp_config - - config_name=$(get_platform)-$(get_version).json - - if [[ ! -f "${config_name}" ]]; then - echo "File ${config_name} not found, platform not supported." + local platform + local firmware_version + + platform=$(get_platform) + firmware_version=$(get_version) + + if [[ -f ${platform}-${firmware_version}.json ]]; then + config_name="${platform}-${firmware_version}.json" + elif [[ -f ${platform}.json ]]; then + config_name="${platform}.json" + else + echo "Config for platform ${platform} not found (${firmware_version})" exit 2 fi @@ -138,7 +151,7 @@ function main { PROCESSED_LIBS_SET[${lib}]=1 local file_info - file_info=$(remote stat -c '%N' "${lib}") + file_info=$(remote stat -c '%N' "${lib}" 2> /dev/null || echo "${FILE_INFO_FALLBACK[${lib}]}") echo "Processing ${lib}..."