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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ The version lives in `_VER` in `src/main.c`. Binaries are published only as the
[`latest`](https://github.com/OpenIPC/microsnander/releases/latest) release, rebuilt
from every push to `main`; this file is the change history.

## 1.43.0 — 2026-11-16

- Android app: a hex view of the last dump (#85), under the status registers, as in the web
mode: address, bytes and ASCII, 16 bytes a row, 512 bytes a page, 00 and FF dim; Prev, Next and
Go to an address in hex (up to 12 digits, inside the dump). Only that page is read from the
file, so a dump of any size opens at once; the panel follows the newest dump.

## 1.42.1 — 2026-11-16

- Android app: the APK carries native code for ARM only, arm64-v8a and armeabi-v7a (phones and
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ with the remote).
- A tap on a register lamp flips that bit: Detect, a question with the old and the new value,
the write on every die, then the registers read again. WEL, BUSY (WIP) and SUS are the state of
the chip, R bits are reserved and LB1–LB3 are one-time locks: those lamps take no tap.
- **Hex view** of the last dump, as in the web mode: 512 bytes a page, address, bytes and ASCII
(00 and FF dim), Prev, Next and Go to an address in hex; the D-pad of a TV box moves through
them, and the table scrolls sideways on a narrow screen.
- The app runs the same C code as microsnander (`src/`), built with the NDK, on the device the
Android USB manager opened (its file descriptor, through the usbfs code, no libusb). The signed APK is in the release:
`microsnander-android.apk` in [latest](https://github.com/OpenIPC/microsnander/releases/latest).
Expand Down
3 changes: 3 additions & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ Android TV (Android 5.0 и новее, без root; на приставке он
- Нажатие на лампу регистра меняет этот бит: Detect, вопрос со старым и новым значением, запись
на всех кристаллах, затем регистры читаются заново. WEL, BUSY (WIP) и SUS — состояние
микросхемы, биты R зарезервированы, а LB1–LB3 — одноразовая блокировка: на эти лампы нажать нельзя.
- **Hex view** последнего дампа, как в веб-режиме: по 512 байт, адрес, байты и ASCII (00 и FF
приглушены), Prev, Next и Go — переход по адресу в hex; на ТВ-приставке по ним ходят пультом,
на узком экране таблица прокручивается вбок.
- Приложение работает на том же коде C, что и microsnander (`src/`), собранном NDK, с устройством,
которое открыл менеджер USB Android (через его файловый дескриптор и код usbfs, без libusb). Подписанный APK — в релизе:
`microsnander-android.apk` в [latest](https://github.com/OpenIPC/microsnander/releases/latest).
Expand Down
2 changes: 2 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ root;在电视盒子上会出现在主屏幕,可用遥控器操作)。
**Self-test**(在 Detect 和确认之后对第一个块执行 `-t`)。
- 点击寄存器指示灯即可翻转该位:先 Detect,再询问并显示旧值和新值,在每个晶粒上写入,然后重新读取寄存器。
WEL、BUSY(WIP)和 SUS 是芯片的状态,R 位为保留位,LB1–LB3 为一次性锁定位:这些指示灯不能点击。
- 最近一次转储的 **Hex view**,与 Web 模式相同:每页 512 字节,地址、字节和 ASCII(00 和 FF 显示为暗色),
Prev、Next 和 Go(跳转到十六进制地址);电视盒子上可用遥控器方向键操作,窄屏上表格可横向滚动。
- 应用使用与 microsnander 相同的 C 代码(`src/`),由 NDK 编译,访问 Android USB 管理器打开的
设备(通过其文件描述符和 usbfs 代码,不使用 libusb)。签名的 APK 在发布版中:[latest](https://github.com/OpenIPC/microsnander/releases/latest) 里的 `microsnander-android.apk`。

Expand Down
120 changes: 120 additions & 0 deletions android/app/src/main/java/org/openipc/microsnander/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import android.text.style.ForegroundColorSpan;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
Expand All @@ -41,6 +43,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -100,6 +103,14 @@ public class MainActivity extends Activity {
private View regsPanel;
private Button[] buttons;
private Button saveAs, share;
// the hex view of the last dump: its file and the address of the page shown
private static final int HEX_PAGE = 512;
private static String hexName; // the dump shown: name, time and length, a rewritten one counts as new
private static long hexOff;
private View hexPanel;
private TextView hexFile, hexText;
private EditText hexAddr;
private Button hexPrev, hexNext, hexGoButton;
private Runnable afterPermission;

@Override
Expand All @@ -116,6 +127,22 @@ protected void onCreate(Bundle saved) {
regsNote = findViewById(R.id.regs_note);
saveAs = findViewById(R.id.b_save_as);
share = findViewById(R.id.b_share);
hexPanel = findViewById(R.id.hex_panel);
hexFile = findViewById(R.id.hex_file);
hexText = findViewById(R.id.hex);
hexAddr = findViewById(R.id.hex_addr);
hexPrev = findViewById(R.id.b_hex_prev);
hexNext = findViewById(R.id.b_hex_next);
hexGoButton = findViewById(R.id.b_hex_go);
// not while an operation runs: it may be writing the dump shown
hexPrev.setOnClickListener(v -> { if (busy) return; hexOff = Math.max(0, hexOff - HEX_PAGE); showHex(); });
hexNext.setOnClickListener(v -> { if (busy) return; hexOff += HEX_PAGE; showHex(); });
hexGoButton.setOnClickListener(v -> { if (!busy) hexGo(); });
hexAddr.setOnEditorActionListener((v, id, e) -> {
if (id != EditorInfo.IME_ACTION_GO && e == null) return false;
if (!busy) hexGo();
return true;
});
((TextView) findViewById(R.id.version)).setText(getString(R.string.version, BuildConfig.VERSION_NAME));
buttons = new Button[] {
findViewById(R.id.b_detect), findViewById(R.id.b_read), findViewById(R.id.b_erase),
Expand Down Expand Up @@ -693,6 +720,99 @@ private void enable(boolean on) {
boolean dump = on && lastDump() != null;
saveAs.setEnabled(dump);
share.setEnabled(dump);
hexAddr.setEnabled(on);
hexGoButton.setEnabled(on);
if (on)
showHex();
else {
hexPrev.setEnabled(false);
hexNext.setEnabled(false);
}
}

// ---- the hex view ----

/** Go: an address in hex inside the dump, the page from it (on a 16-byte row) */
private void hexGo() {
File f = lastDump();
String v = hexAddr.getText().toString().trim().replaceFirst("^0[xX]", "");
if (f == null) return;
if (!v.matches("[0-9a-fA-F]{1,12}")) {
hexText.setText(R.string.hex_bad_addr);
return;
}
long a = Long.parseLong(v, 16);
if (a >= f.length()) {
hexText.setText(getString(R.string.hex_past_end, sizeOf(f.length()), Math.max(0, f.length() - 1)));
return;
}
hexOff = a / 16 * 16;
showHex();
}

private static String hex(long v, int n) {
StringBuilder s = new StringBuilder(Long.toHexString(v).toUpperCase(java.util.Locale.ROOT));
while (s.length() < n) s.insert(0, '0');
return s.toString();
}

/** the page of the last dump at hexOff: address, 16 bytes, ASCII a row; none: the panel goes */
private void showHex() {
File f = lastDump();
if (f == null) {
hexPanel.setVisibility(View.GONE);
hexName = null;
return;
}
String id = f.getName() + ':' + f.lastModified() + ':' + f.length();
if (!id.equals(hexName)) { // another dump, or the same name written again: from its start
hexName = id;
hexOff = 0;
}
long len = f.length();
if (hexOff >= len) hexOff = Math.max(0, (len - 1) / HEX_PAGE * HEX_PAGE);
hexPanel.setVisibility(View.VISIBLE);
hexFile.setText(f.getName());
byte[] b = new byte[(int) Math.min(HEX_PAGE, len - hexOff)];
try (RandomAccessFile r = new RandomAccessFile(f, "r")) {
r.seek(hexOff);
r.readFully(b);
} catch (IOException e) {
hexText.setText(R.string.hex_cannot);
return;
}
int amber = col(R.color.amber), dim = col(R.color.dim);
SpannableStringBuilder h = new SpannableStringBuilder();
for (int i = 0; i < b.length; i += 16) {
int from = h.length();
h.append(hex(hexOff + i, 8));
h.setSpan(new ForegroundColorSpan(amber), from, h.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
h.append(" ");
StringBuilder c = new StringBuilder();
for (int k = 0; k < 16; k++) {
if (k == 8) h.append(' ');
if (i + k < b.length) {
int v = b[i + k] & 0xff;
int at = h.length();
h.append(hex(v, 2));
if (v == 0 || v == 0xff)
h.setSpan(new ForegroundColorSpan(dim), at, h.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
h.append(' ');
c.append(v >= 32 && v < 127 ? (char) v : '.');
} else
h.append(" ");
}
h.append(' ');
int at = h.length();
h.append(c);
h.setSpan(new ForegroundColorSpan(dim), at, h.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
if (i + 16 < b.length) h.append('\n');
}
if (b.length == 0) h.append(getString(R.string.hex_empty));
hexText.setText(h);
hexAddr.setText(getString(R.string.hex_addr, hexOff));
hexPrev.setEnabled(hexOff > 0);
hexNext.setEnabled(hexOff + HEX_PAGE < len);
}

private void showBusy() {
Expand Down
110 changes: 110 additions & 0 deletions android/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,115 @@
android:paddingRight="24dp"
android:text="@string/unprotect" />
</LinearLayout>

<LinearLayout
android:id="@+id/hex_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/panel"
android:orientation="vertical"
android:padding="18dp"
android:visibility="gone">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
style="@style/Plate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hex_view" />

<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />

<TextView
android:id="@+id/hex_file"
style="@style/Plate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false" />
</LinearLayout>

<EditText
android:id="@+id/hex_addr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="@drawable/display"
android:digits="0123456789abcdefABCDEFxX"
android:fontFamily="monospace"
android:hint="@string/hex_hint"
android:imeOptions="actionGo"
android:importantForAutofill="no"
android:inputType="textNoSuggestions|textVisiblePassword"
android:maxLength="14"
android:padding="10dp"
android:singleLine="true"
android:textColor="@color/amber"
android:textColorHint="@color/dim"
android:textSize="14sp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/b_hex_prev"
style="@style/Brass"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hex_prev" />

<Button
android:id="@+id/b_hex_go"
style="@style/Brass"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hex_go" />

<Button
android:id="@+id/b_hex_next"
style="@style/Brass"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hex_next" />
</LinearLayout>

<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="@drawable/display">

<TextView
android:id="@+id/hex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:padding="10dp"
android:textColor="@color/ink"
android:textSize="11sp"
android:typeface="monospace" />
</HorizontalScrollView>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="monospace"
android:text="@string/hex_note"
android:textColor="@color/dim"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
11 changes: 11 additions & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,15 @@
<string name="bit_risky">SRP0, SRP1 and SRWD lock the registers (with the WP# pin low, or until the chip is powered off); SRP0 and SRP1 together would lock them for good and are refused. QE, HOLD and WPS change what the pins of the chip do: a board may not boot from it until they are set back.</string>
<string name="bit_changed">Another chip is in the programmer: its registers are shown now, tap the bit again.</string>
<string name="bit_cannot">This chip has no such status register to write.</string>
<string name="hex_view">HEX VIEW</string>
<string name="hex_prev">Prev</string>
<string name="hex_next">Next</string>
<string name="hex_go">Go</string>
<string name="hex_hint">0x0</string>
<string name="hex_addr" translatable="false">0x%1$X</string>
<string name="hex_note">The last dump, 512 bytes at a time. Address in hex; 00 and FF bytes are dim.</string>
<string name="hex_bad_addr">An address in hex, as 0x1F000.</string>
<string name="hex_past_end">Past the end of the dump (%1$s): the last address is 0x%2$X.</string>
<string name="hex_cannot">The dump cannot be read.</string>
<string name="hex_empty">Empty.</string>
</resources>
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
struct flash_cmd prog;
extern unsigned int bsize;

#define _VER "1.42.1"
#define _VER "1.43.0"

const char *ms_version = _VER;

Expand Down
Loading