Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ coverage/

# Emus pak cache (cores/ directory contains downloaded and override cores)
workspace/all/paks/Emus/cores/
workspace/tg5050/libmsettings/*.so*
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif

# Default platforms to build (can be overridden with PLATFORMS=...)
ifeq (,$(PLATFORMS))
PLATFORMS = miyoomini trimuismart rg35xx rg35xxplus my355 tg5040 zero28 rgb30 m17 my282 magicmini retroid
PLATFORMS = miyoomini trimuismart rg35xx rg35xxplus my355 tg5040 tg5050 zero28 rgb30 m17 my282 magicmini retroid
endif

###########################################################
Expand Down Expand Up @@ -284,6 +284,12 @@ clean:
@find workspace -type f -name "*.bmp" -path "*/boot/*.bmp" -delete 2>/dev/null || true
@find workspace -type f -name "boot_logo.png" -path "*/boot/boot_logo.png" -delete 2>/dev/null || true
@rm -rf workspace/all/paks/Emus/cores/extracted/
@echo "Cleaning platform-specific build artifacts..."
@find workspace -type f -name "*.o" -delete 2>/dev/null || true
@find workspace -type f -name "*.elf" -delete 2>/dev/null || true
@find workspace -path "*/other/*/DinguxCommander" -type f -delete 2>/dev/null || true
@find workspace -path "*/other/*/351files" -type f -delete 2>/dev/null || true
@echo "Clean complete"

# Prepare fresh build directory and skeleton
setup: name
Expand Down
301 changes: 301 additions & 0 deletions docs/tg5050-platform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
# TG5050 Platform (Trimui Smart Pro S)

This document describes the hardware and software requirements for supporting the Trimui Smart Pro S (TG5050) device.

## Overview

| Property | Value |
| --------- | -------------------------------------------- |
| Device | Trimui Smart Pro S |
| Model ID | TG5050 |
| SoC | Allwinner A523 (sun55iw3) |
| CPU | 8x Cortex-A55 (dual cluster: cpu0-3, cpu4-7) |
| Display | 1280x720, DSI panel |
| Toolchain | `tg5040` (shared with Smart Pro) |

**Important:** Despite sharing the same form factor and toolchain as the Smart Pro (TG5040/T527), the Smart Pro S uses completely different hardware (A523 SoC) with different drivers and control interfaces.

## Hardware Detection

### Device Identification

The device can be identified by checking the MainUI binary:

```bash
# Check for TG5050
if strings /usr/trimui/bin/MainUI | grep -q "TG5050"; then
DEVICE="tg5050"
fi
```

Or by reading the hardware serial:

```bash
cat /sys/class/sunxi_info/sys_info | grep hwserial
# Returns: TG5050XXXXXXXXXX
```

### SoC Identification

```bash
cat /sys/firmware/devicetree/base/compatible
# Returns: allwinner,a523 arm,sun55iw3p1
```

## Display

### Backlight Control

Uses standard sysfs backlight interface (NOT `/dev/disp` ioctl):

```bash
# Path
/sys/class/backlight/backlight0/brightness

# Range: 0-255 (stock OS clamps to 10-220)
echo 128 > /sys/class/backlight/backlight0/brightness
```

### Display Enhancement (optional)

```bash
/sys/devices/virtual/disp/disp/attr/enhance_contrast # 0-100
/sys/devices/virtual/disp/disp/attr/enhance_saturation # 0-100
/sys/devices/virtual/disp/disp/attr/enhance_bright # 0-100 (exposure)
/sys/devices/virtual/disp/disp/attr/color_temperature # color temp adjustment
```

### Screen Rotation

DSI panel rotation (if needed):

```bash
/sys/class/drm/card0-DSI-1/rotate
```

## Audio

### ALSA Mixer Controls

The A523 uses different mixer control names than T527:

| Control | Purpose |
| ------------ | ---------------------------------------------------------- |
| `DAC Volume` | Main volume control (use tinyalsa `mixer_ctl_set_percent`) |
| `HPOUT` | Headphone output (unmute on init) |
| `SPK` | Speaker output (unmute on init) |
| `LINEOUTL` | Line out left (unmute on init) |
| `LINEOUTR` | Line out right (unmute on init) |

### Speaker Mute

Hardware speaker mute via sysfs:

```bash
# Mute speaker (also stops hissing)
echo 1 > /sys/class/speaker/mute

# Unmute speaker
echo 0 > /sys/class/speaker/mute
```

### Initialization Sequence

```bash
# Unmute all outputs on init
amixer sset 'HPOUT' unmute
amixer sset 'SPK' unmute
amixer sset 'LINEOUTL' unmute
amixer sset 'LINEOUTR' unmute
```

### Volume Control (tinyalsa)

```c
#include <tinyalsa/mixer.h>

void SetRawVolume(int val) { // 0-100
struct mixer *mixer = mixer_open(0);
if (!mixer) return;

struct mixer_ctl *ctl = mixer_get_ctl_by_name(mixer, "DAC Volume");
if (ctl) {
mixer_ctl_set_percent(ctl, 0, val);
}
mixer_close(mixer);

// Full mute requires sysfs
putInt("/sys/class/speaker/mute", val == 0 ? 1 : 0);
}
```

### Headphone Jack Detection

```bash
# TODO: Verify path on actual hardware
/sys/bus/platform/devices/singleadc-joypad/hp
```

## CPU Frequency Scaling

> **Note:** CPU scaling is **disabled (no-op)** for initial tg5050 implementation. The dual-cluster architecture requires a broader overhaul to properly support big/little SoC configurations. Use `schedutil` governor and let the kernel handle scaling for now.

### Hardware Reference (for future implementation)

The A523 has two CPU clusters with separate frequency policies:

| Cluster | CPUs | Policy Path | Frequency Range |
| ------- | ---- | ------------------------------------------ | --------------- |
| Little | 0-3 | `/sys/devices/system/cpu/cpufreq/policy0/` | 408-1416 MHz |
| Big | 4-7 | `/sys/devices/system/cpu/cpufreq/policy4/` | 408-2160 MHz |

Available frequencies (big cluster):

```
408000 672000 840000 1008000 1200000 1344000 1488000 1584000 1680000 1800000 1992000 2088000 2160000
```

### Current Implementation (No-Op)

```c
void PLAT_setCPUSpeed(int speed) {
(void)speed; // No-op for now - using schedutil governor
}

int PLAT_getAvailableCPUFrequencies(int* frequencies, int max_count) {
(void)frequencies;
(void)max_count;
return 0; // Return 0 to disable auto-CPU scaling
}
```

## Input

### Rumble/Vibration

Uses GPIO 236 (different from T527's GPIO 227):

```bash
# Enable rumble
echo 1 > /sys/class/gpio/gpio236/value

# Disable rumble
echo 0 > /sys/class/gpio/gpio236/value

# Set rumble intensity (optional)
echo <0-65535> > /sys/class/motor/level
```

### Buttons

Device has L3/R3 (stick click) buttons. Uses `trimui_inputd` for turbo and input remapping.

## Power Management

### Battery Status

```bash
# Capacity (0-100)
cat /sys/class/power_supply/axp2202-battery/capacity

# Charging status
cat /sys/class/power_supply/axp2202-usb/online # 1 = charger connected
cat /sys/class/power_supply/axp2202-battery/time_to_full_now # >0 = charging
```

### CPU Temperature

```bash
cat /sys/devices/virtual/thermal/thermal_zone0/temp
# Returns millidegrees, divide by 1000 for Celsius
```

### Fan Control

```bash
# Set fan speed (0-31, or use thermal daemon for auto)
echo <0-31> > /sys/class/thermal/cooling_device0/cur_state
```

## Graphics

### OpenGL ES

Request GLES 3.2 context:

```c
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
```

### SDL Hints

```c
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1");
```

## Networking

### WiFi Module

Uses `aic8800_fdrv.ko` driver:

```bash
modprobe aic8800_fdrv.ko
/etc/wifi/wifi_init.sh start
```

### Bluetooth

Uses `aic8800_btlpm.ko` driver:

```bash
modprobe aic8800_btlpm.ko
hciattach -n ttyAS1 aic &
/etc/bluetooth/bluetoothd start
```

## LED Control

### LED Animation Paths

```bash
/sys/class/led_anim/max_scale # Global brightness
/sys/class/led_anim/effect_l # Left joystick LED
/sys/class/led_anim/effect_r # Right joystick LED
/sys/class/led_anim/effect_m # Logo LED
/sys/class/led_anim/effect_duration_* # Animation speed
/sys/class/led_anim/effect_rgb_hex_* # Color (hex)
```

## Platform Constants

```c
#define PLATFORM "tg5050"
#define SDCARD_PATH "/mnt/SDCARD"
#define FIXED_WIDTH 1280
#define FIXED_HEIGHT 720
#define FIXED_PITCH (FIXED_WIDTH * 4)

// Uses tg5040 toolchain
// #define TOOLCHAIN "tg5040"
```

## Implementation Checklist

- [ ] Create `workspace/tg5050/` directory structure
- [ ] Create `platform/platform.h` with constants
- [ ] Create `platform/platform.c` with hardware abstraction
- [ ] Create `libmsettings/msettings.c` with A523-specific controls
- [ ] Create `skeleton/SYSTEM/tg5050/` with system files
- [ ] Create `workspace/all/paks/LessUI/platforms/tg5050/` init scripts
- [ ] Add tg5050 to `toolchains.json` (uses tg5040 toolchain)
- [ ] Add tg5050 to Makefile PLATFORMS
- [ ] Update pak platform lists

## References

- NextUI tg5050 branch: https://github.com/shauninman/NextUI (tg5050 branch)
- System report: `/Volumes/LESSUI_DEV/system_report_trimuismartpro_*.md`
5 changes: 5 additions & 0 deletions scripts/generate-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ $MAGICK $SRC/logo.png -filter Point -resize 128x128! -background black -gravity
-extent 128x128 -define bmp3:alpha=true BMP3:workspace/all/paks/Bootlogo/tg5040/bootlogo.bmp
echo " ✓ tg5040 bootlogo.bmp (128×128, 32-bit)"

# tg5050: 128×128, 32-bit, bottom-up (same as tg5040)
$MAGICK $SRC/logo.png -filter Point -resize 128x128! -background black -gravity center \
-extent 128x128 -define bmp3:alpha=true BMP3:workspace/all/paks/Bootlogo/tg5050/bootlogo.bmp
echo " ✓ tg5050 bootlogo.bmp (128×128, 32-bit)"

# tg5040 brick: 216×237, 24-bit, bottom-up
$MAGICK $SRC/logo.png -filter Point -resize 216x216! -background black -gravity center \
-extent 216x237 -type TrueColor -define bmp:format=bmp3 \
Expand Down
1 change: 1 addition & 0 deletions scripts/generate-scaling-configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"m17": (480, 272, 4.3), # Miyoo A30 / similar
"trimuismart": (640, 480, 4.95),
"tg5040": (1280, 720, 4.96), # Trimui Smart Pro
"tg5050": (1280, 720, 4.95), # Trimui Smart Pro S
"retroid": (1920, 1080, 5.5), # Pocket 5, Flip 2 (FHD)
}

Expand Down
3 changes: 3 additions & 0 deletions skeleton/BOOT/common/updater
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ else
*"SStar"*)
PLATFORM="miyoomini"
;;
*"TG5050"*)
PLATFORM="tg5050" # Trimui Smart Pro S
;;
*"TG5040"*|*"TG3040"*)
PLATFORM="tg5040" # Trimui Smart Pro or Brick
;;
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions skeleton/SYSTEM/tg5050/bin/setterm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# generates unnecessary errors when missing
exit 0
Loading