Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
debootstrap
debootstrap-prefetched
deploy
toolchain/extracted
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ toolchain/extracted
*.tsv
*.xml
*.bak
pcb/
opencode.json
.config/
104 changes: 104 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# AGENTS.md

## Build SD card image

Uses Docker - no host dependencies needed.

```bash
# First run (prefetch debootstrap + build kernel/uboot/tfa)
docker compose run build --variant decktrix --prefetch-debootstrap

# Subsequent builds (uses cached debootstrap)
docker compose run build --variant decktrix --use-prefetch-debootstrap
```

Output: `deploy/sdcard.img.gz`

Variants: `stm32`, `stm32-jadard`, `decktrix`

## Project structure

- `Dockerfile` + `docker-compose.yml` - build environment
- `build-image.sh` - main build script
- `board/linux/patches/` - kernel patches (Jadard driver, DTS, pinctrl)
- `board/tfa/patches/` - TF-A patches (pinctrl)
- `board/u-boot/patches/` - U-Boot patches (DSI disable, pinctrl)
- `board/tfa/decktrix-v1.dts` - TF-A device tree (LDO overrides)
- `board/u-boot/decktrix-v1.dts` - U-Boot device tree
- `scripts/gdrive-upload.sh` - upload file to Google Drive
- `scripts/gdrive-auth.sh` - re-authenticate when token expires

## Decktrix v1 board differences from DK2

| Component | Devboard (DK2) | Decktrix PCB |
|---|---|---|
| PMIC I2C4 SCL | PZ4 | PD12 (AF4) |
| PMIC I2C4 SDA | PZ5 | PD13 (AF4) |
| LDO1 | 1.8V (v1v8_audio) | 2.8V (display AVDD) |
| LDO6 | 1.2V (v1v2_hdmi) | 1.8V (display IOVCC) |
| LCD reset | PE4 | PD11 |
| LCD backlight | PA15 | PF6 (TPS61042 ctrl) |
| Touch IRQ | PF2 | PG7 |
| Touch reset | PF4 | PE10 |
| BT UART | USART2 (PA2/PA3) | UART8 (PE0/PE1) |
| BT shutdown | PZ6 | PB10 |
| WiFi reset | PH4 | PE6 |
| WiFi chip | BCM43430 | u-blox MAYA-W166 (NXP IW416) |
| Display power | GPIO vdd/vccio | Always-on PMIC rails |

Display is powered by PMIC regulators (always-on):
- LDO1 (2.8V) -> display AVDD
- LDO6 (1.8V) -> display IOVCC
- No GPIO enable needed

Jadard driver uses `devm_gpiod_get_optional()` for vdd/vccio/dbg GPIOs.

## Creating patches

**Do NOT write patch files manually.** Always:
1. Reset the relevant git tree to clean state
2. Apply existing patches in order
3. Make the desired changes to the source files
4. Run `git diff` (or `git diff --cached` after `git add`)
5. Wrap the diff in a proper patch header (From/Date/Subject/Signed-off-by)
6. Save as the next numbered patch file in the `patches/` directory
7. Remove any standalone files that should be in the patch (not copied)

## Google Drive upload

```bash
./scripts/gdrive-upload.sh <path-to-file>
```

Credentials in `.config/opencode/gdrive-token.json` (not in git).

### Initial setup (from scratch)

1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create project `decktrix`
3. Enable **Google Drive API** (APIs & Services -> Library)
4. Go to **APIs & Services -> OAuth consent screen**
5. Set User type to **External**
6. Add your email under **Test users**
7. Go to **APIs & Services -> Credentials**
8. Click **Create Credentials -> OAuth client ID**
9. Application type: **Desktop app**, name: `decktrix`
10. Click **Create**
11. Click **Download JSON** on the popup
12. Save as `~/.config/opencode/gcp-oauth.json`
13. Run `./scripts/gdrive-auth.sh`
14. It prints an OAuth URL - open in browser
15. Sign in with your Google account, approve access
16. Browser redirects to `http://localhost/?code=XXXXX...`
17. Copy the code from the URL (everything between `code=` and `&`)
18. Paste it into the terminal
19. Script creates `.config/opencode/gdrive-token.json`

### When token expires (after 7 days)

The refresh token expires after 7 days. When this happens:
1. `gdrive-upload.sh` will fail with "Failed to refresh access token"
2. Run `./scripts/gdrive-auth.sh`
3. It prints an OAuth URL - open it, approve, paste the code
4. Token file is updated automatically
5. Run `gdrive-upload.sh` again
24 changes: 20 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
FROM ubuntu:noble

RUN apt-get update
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get install -y \
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
wget \
curl \
ca-certificates \
git \
bc \
bison \
build-essential \
Expand All @@ -16,11 +19,24 @@ RUN apt-get install -y \
python3-setuptools \
swig \
uuid-dev \
build-essential \
python3-cryptography \
python3-pyelftools \
build-essential \
device-tree-compiler \
dosfstools \
genimage \
mtools \
debootstrap \
qemu-user-static \
&& rm -rf /var/lib/apt/lists/*

RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/builduser \
&& chmod 0440 /etc/sudoers.d/builduser

WORKDIR /build

COPY build-image.sh .
RUN chmod +x build-image.sh

USER ubuntu

ENTRYPOINT ["./build-image.sh"]
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,25 @@ design and features are expected.
git submodule update --init --recursive --depth 1
```

2. Prefetch debootstrap on first run to speed next iterations
### Using Docker (recommended)

No need to install dependencies on the host or provide sudo password.

2. Prefetch debootstrap on first run to speed up next iterations

```
docker compose run build --prefetch-debootstrap
```

3. Build SD card image

```
docker compose run build --use-prefetch-debootstrap
```

### Using host directly

2. Prefetch debootstrap on first run to speed up next iterations

```
sudo ./build-image.sh --prefetch-debootstrap
Expand Down
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# TODO

- [ ] SD card detect: replace `broken-cd` with actual GPIO `<&gpioe 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>` (PE3) in both U-Boot and kernel DTS patches
- [ ] WiFi/BT: u-blox MAYA-W166 (NXP IW416) driver, SDMMC3, UART8
24 changes: 6 additions & 18 deletions board/linux/patches/0003-display-Add-Jadard-MIPI-driver.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Signed-off-by: Kirill Yatsenko <kiriyatsenko@gmail.com>
drivers/gpu/drm/panel/Kconfig | 8 +
drivers/gpu/drm/panel/Makefile | 1 +
drivers/gpu/drm/panel/panel-jadard-jd9365tn.c | 489 ++++++++++++++++++
5 files changed, 506 insertions(+), 3 deletions(-)
5 files changed, 494 insertions(+), 3 deletions(-)
create mode 100644 drivers/gpu/drm/panel/panel-jadard-jd9365tn.c

diff --git a/arch/arm/boot/dts/st/stm32mp157c-dk2-jadard.dts b/arch/arm/boot/dts/st/stm32mp157c-dk2-jadard.dts
Expand Down Expand Up @@ -84,7 +84,7 @@ new file mode 100644
index 000000000000..2537338a081b
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-jadard-jd9365tn.c
@@ -0,0 +1,489 @@
@@ -0,0 +1,477 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Author:
Expand Down Expand Up @@ -500,25 +500,13 @@ index 000000000000..2537338a081b
+ }
+
+ /* VDD pin is connected to power regulator enable pin on adapter board */
+ jadard->vdd = devm_gpiod_get(dev, "vdd", GPIOD_OUT_LOW);
+ if (IS_ERR(jadard->vdd)) {
+ DRM_DEV_ERROR(&dsi->dev, "failed to get vdd GPIO\n");
+ return PTR_ERR(jadard->vdd);
+ }
+ jadard->vdd = devm_gpiod_get_optional(dev, "vdd", GPIOD_OUT_LOW);
+
+ /* VCCIO pin is connected to power regulator enable pin on adapter board */
+ jadard->vccio = devm_gpiod_get(dev, "vccio", GPIOD_OUT_LOW);
+ if (IS_ERR(jadard->vccio)) {
+ DRM_DEV_ERROR(&dsi->dev, "failed to get vccio GPIO\n");
+ return PTR_ERR(jadard->vccio);
+ }
+ jadard->vccio = devm_gpiod_get_optional(dev, "vccio", GPIOD_OUT_LOW);
+
+ /* DBG pin is used for osciloscope debugging */
+ jadard->dbg = devm_gpiod_get(dev, "dbg", GPIOD_OUT_HIGH);
+ if (IS_ERR(jadard->dbg)) {
+ DRM_DEV_ERROR(&dsi->dev, "failed to get dbg GPIO\n");
+ return PTR_ERR(jadard->dbg);
+ }
+ /* DBG pin is used for oscilloscope debugging */
+ jadard->dbg = devm_gpiod_get_optional(dev, "dbg", GPIOD_OUT_HIGH);
+
+ drm_panel_init(&jadard->panel, dev, &jadard_funcs,
+ DRM_MODE_CONNECTOR_DSI);
Expand Down
Loading