added README.md #1

Merged
wt merged 1 commits from develop into main 2026-03-19 14:36:15 +07:00
+141
View File
@@ -0,0 +1,141 @@
# UP - Embedded Linux Update Server
A Go-based HTTP server for managing embedded Linux system updates, designed for Orange Pi Zero 2W (Allwinner H618) and similar ARM-based devices.
## Overview
This server provides a web interface and REST API for:
- Uploading and managing boot files (U-Boot, kernel, DTB)
- Editing extlinux boot configuration
- Monitoring system temperature
- Remote system reboot
- File version tracking
## Project Structure
```
up/
├── main.go # Application entry point
├── go.mod # Go module definition
├── up.conf # Environment configuration file
├── api/ # HTTP handlers
│ ├── frontend/ # Embedded web UI (HTML, CSS, JS)
│ ├── Extlinux.go # Boot config read/write router
│ ├── ExtlinuxRead.go # Read extlinux.conf
│ ├── ExtlinuxWrite.go # Write extlinux.conf
│ ├── FileDate.go # Get file version timestamps
│ ├── HandleReboot.go # System reboot endpoint
│ ├── HandleTemperature.go # Temperature monitoring
│ ├── HandleUpload.go # File upload handler
│ ├── MountStatus.go # Mount status checker
│ └── spa.go # SPA file server
├── server/ # Server configuration
│ ├── Configure.go # Route configuration
│ └── Run.go # Server startup (HTTP/HTTPS)
└── utils/ # Utility functions
├── mtd/ # MTD (Memory Technology Device) utilities
├── EnsureDir.go # Directory creation
├── GetTargetFilename.go # Filename resolution by type
├── LoadEnv.go # Environment loader
├── MountDevice.go # Device mounting
└── WriteUbootToDevices.go # U-Boot flashing
```
## Configuration
The server uses `up.conf` (dotenv format) for configuration:
```env
ENABLE_TLS=false # Enable HTTPS
CERT_FILE=cert.crt # TLS certificate path
KEY_FILE=privkey.key # TLS key path
SERVER_ADDRESS=0.0.0.0 # Bind address
SERVER_PORT=8989 # Bind port
MOUNT_POINT=/media # Mount point for target device
DEVICE=/dev/mmcblk1p1 # Target block device
KERNEL_FILE=Image.gz # Kernel image filename
DTB_FILE=sun50i-h618-orangepi-zero2w.dtb # Device tree blob
UBOOT_FILE=uboot.env # U-Boot environment file
EXTLINUX_FILE=extlinux/extlinux.conf # Bootloader config
MAX_FILE_SIZE=200 # Max upload size (MB)
UBOOT_BIN_FILE=u-boot-sunxi-with-spl.bin # U-Boot binary
UBOOT_MAX_SIZE=1 # Max U-Boot size (MB)
MMC_BOOT_OFFSET=8192 # MMC boot offset
```
## API Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Web UI (SPA) |
| `/api/mount` | GET | Get mount status |
| `/api/extlinux` | GET | Read extlinux.conf |
| `/api/extlinux` | POST | Write extlinux.conf |
| `/api/filedate` | GET | Get file version date |
| `/api/temperature` | GET | Get CPU temperature |
| `/api/upload` | POST | Upload files |
| `/api/reboot` | POST | Reboot system |
### API Examples
**Get Temperature:**
```bash
curl http://localhost:8989/api/temperature
# Response: {"success":true,"temperature":45.2,"unit":"Celsius"}
```
**Upload File:**
```bash
curl -X POST -F "type=kernel" -F "file=@Image.gz" http://localhost:8989/api/upload
```
**Reboot System:**
```bash
curl -X POST http://localhost:8989/api/reboot
```
**Read Boot Config:**
```bash
curl http://localhost:8989/api/extlinux
```
**Write Boot Config:**
```bash
curl -X POST -H "Content-Type: application/json" \
-d '{"content":"default linux\n label linux\n kernel /Image.gz\n"}' \
http://localhost:8989/api/extlinux
```
## Supported Upload Types
The server supports uploading the following file types:
- `kernel` - Kernel image (Image.gz)
- `dtb` - Device tree blob
- `uboot_bin` - U-Boot bootloader
- `uboot_env` - U-Boot environment
- `extlinux` - Bootloader configuration
## Building
```bash
# Build
go build -o up
# Run
./up
```
## Requirements
- Go 1.26+
- Root privileges (for mounting devices and rebooting)
- Target storage device (eMMC/SD card)
## Features
- **Web Interface**: Embedded SPA frontend for easy management
- **TLS Support**: Optional HTTPS with certificate configuration
- **Progress Tracking**: Real-time upload progress monitoring
- **Version Tracking**: Automatic timestamp logging for uploaded files
- **Safe Reboot**: Graceful unmount and sync before reboot
- **Temperature Monitoring**: CPU thermal sensor readings