User Tools

Site Tools


pic32

This is an old revision of the document!


PIC32

The PIC32 is a PIC32MX795F512L. The programming connector (labeled PIC32) matches the PICkit pinout exactly - Readback protection is off :) so the firmware can be pulled over ICSP.

The firmware strings come from keys 0xc000 and 0xc001:

PROXmobil3 PIC32 / PM3-P32  rev 0.20 (Apr 2017)
PROXmobil3-Bootloader / PM3-BL  rev 1.1 (Sep 2016)

IPP reads and writes value keys, reads the EEPROMs, sets the watchdog, and reports the sensors. It has no memory-read command, and no PIC32 image ships on the host.

i.MX to PIC comms

The PIC32 talks IPP on /dev/ttymxc2 at 115200 8N1. Watchdog initialization and feeding: kibble.sal. The stop capture is euthasol.sal; the frame itself is under Watchdog and power.

The framing is the same as cVEND.

IPP message types

→ - i.MX to PIC
← - PIC to i.MX

msgType dir name description
0x02 → ValueRead accepts a 2-byte key, returns a variable-length value
0x03 ← ValueReadReply
0x04 → ValueWrite accepts a 2-byte key followed by a variable-length value, assigns value to key
0x05 ← ValueWriteReply
0x0a → 10000000000080 reads the external EEPROM, 18000000000080 the internal one
0x0c → empty payload immediately powers the device off
0x0e → empty payload immediately powers the device off
0x12 → SetLogLevel 0000 enables some kind of logging behavior, 8000 disables it

Types 0x80-0xff mirror 0x00-0x7f, but with CRC32 enabled.

0x0a takes a 7-byte payload: [device][00 00 00 00 00][len]. Device 0x10 is the external EEPROM, 0x18 the internal one, and the last byte is how many bytes to return. The five zero bytes are an address or padding.

strings on NxProx also shows host-side classes for commands that have not seen presented live while sniffing. The names are NxIppPic32ValueAttribRead, ValueAttribWrite, DeviceWrite, DeviceIoCtl, AppRequest, J1708Request, and J1708MsgReceived. NxIppPic32DeviceRead is the 0x0a EEPROM read above; the rest have no confirmed opcode.

Keys

Rows marked unconfirmed are measured readings; the meaning is a guess.

id type description
0000 u8
0001 u8
0002 u8
0003 u8
0004 u8
000a u8
0100 u8 internal power button (0/1)
03e8 u8
03e9 u8
03ea u8
03f0 u8
03f3 u8
03fb u8 ignition state (0/1)
0428 u8
0429 u8
042a u8
042b u8
042c u8
0433 u8
0434 u8
0436 u8
0437 u8
0438 u8
07d0 u8
07d1 u8
07d2 u8
07d3 u8
07d4 u8 barcode power (0/1)
07d5 u8
07d6 u8
07d7 u8
07d8 u8 screen/backlight power (0/1)
07d9 u8 cVEND power (0/1)
07da u8
07db u8 3v9 rail power (0/1)
07dc u8
07dd u8
07de u8
07df u8
07e0 u8 audio power-amp enable: 1 = on, 0 = off
07e1 u8
07e2 u8
07e3 u8
07e4 u8
07e5 u8
07e6 u8
07e7 u8
07e8 u8
07e9 u8
07ea u8
07eb u8
07ec u8
07ed u8
07ee u8
07ef u8
07f0 u8
07f1 u8
07f2 u8
07f3 u8
07f4 u8
07f5 u8
07f6 u8
4000 u16 PIC32 version; 0.20 reads as 20 (cf. 0xc000)
4001 u16 bootloader version; 1.1 reads as 101 (cf. 0xc001)
4002 u16 watchdog residual (seconds)
4003 u16 watchdog timeout seconds, 0 disables
4004 u16 boot watchdog timeout seconds
4005 u16
400a u16
400b u16
400c u16
400d u16
400e u16
400f u16
4010 u16
4011 u16
4030 u16 backlight brightness at ambient 0, 0..10000
4031 u16 backlight brightness at ambient 10000, 0..10000
4032 u16 second brightness pair, likely idle at ambient 0 (reads 200; unconfirmed)
4033 u16 second brightness pair, likely idle at ambient 10000 (reads 2400; unconfirmed)
4034 u16 reads 65535; purpose unknown
4035 u16 reads 150; purpose unknown
4036 u16 reads 1500; purpose unknown
403d u16 reads 314; maybe 31.4 °C (unconfirmed)
403e u16 reads 65472, or -64 signed (unconfirmed)
403f u16 reads 314; maybe 31.4 °C (unconfirmed)
5000 u16
5001 u16
5002 u16 reads 1; purpose unknown
5008 u16 reads about 32400; purpose unknown
500b u16 ambient light, 0..10000
5013 u16 reads 0; purpose unknown
5040 u16 input voltage (mV)
5041 u16 rail, about 3.2 V
5042 u16 rail, about 24.9 V
5043 u16 rail, about 24.9 V
5044 u16 rail, about 23.0 V
504b u16 rail, about 1.28 V (unconfirmed)
504c u16 rail, about 4.04 V (unconfirmed)
504e u16 rail, about 5.02 V (unconfirmed)
504f u16 3V3 rail, about 3.27 V
5050 u16 5V rail, about 5.06 V
5100 u16
5101 u16
5102 u16
5108 u16
510b u16
5113 u16
5140 u16
5141 u16
5142 u16
5143 u16
5144 u16
514b u16
514c u16
514e u16
514f u16
5150 u16
5200 u16
5201 u16
5202 u16
5208 u16
520b u16
5213 u16
5240 u16
5241 u16
5242 u16
5243 u16
5244 u16
524b u16
524c u16
524e u16
524f u16
5250 u16
6100 u16
6101 u16
6102 u16
8012 u32
8020 u32
8030 u32
8100 u32 PwrOnTime
8102 u32 PwrOnCnt
8103 u32 StartCnt
8104 u32 StartIgnCnt
8105 u32
8106 u32
8107 u32 StartButtonCnt
8108 u32 StartUsbCnt
8109 u32 UsbConnectCnt
810a u32 ShutdownCnt
8110 u32 WdCnt
8111 u32 WdCpuCnt
8112 u32 WdCardCnt
8114 u32
8115 u32 WdButtonCnt
8116 u32
8117 u32
8118 u32
8119 u32
c000 string pic32 version
c001 string bootloader version
c010 string
c011 string
c0c0 string timer statistics
d000 string
d001 string
d002 string
d008 string
d00b string
d013 string
d040 string
d041 string
d042 string
d043 string
d044 string
d04b string
d04c string
d04e string
d04f string
d050 string
d100 string
d101 string
d102 string
d108 string
d10b string
d113 string
d140 string
d141 string
d142 string
d143 string
d144 string
d14b string
d14c string
d14e string
d14f string
d150 string
d200 string
d201 string
d202 string
d208 string
d20b string
d213 string
d240 string
d241 string
d242 string
d243 string
d244 string
d24b string
d24c string
d24e string
d24f string
d250 string

EEPROM

The PIC32 is the path to both EEPROMs. The frames use sequence 1; bump it between frames.

stty -F /dev/ttymxc2 115200 cs8 -cstopb -parenb raw -echo

# external EEPROM, mounting plate or dongle
printf '\274\001\000\012\000\007\136\020\000\000\000\000\000\200' > /dev/ttymxc2

# internal EEPROM, device identity
printf '\274\001\000\012\000\007\136\030\000\000\000\000\000\200' > /dev/ttymxc2

# read the reply
timeout -t 2 dd if=/dev/ttymxc2 bs=1 count=128 2>/dev/null | hexdump -C

The reply is type 0x0b. After a five-byte prefix (18 00 00 00 00 for the internal EEPROM) comes the data. The internal one starts with [GeraeteParam]: UTCOffset, CardReaderSerNum, VariantCode, and SerienNr. The external one can hold the [TestMode] payload described on mountingplate.

Watchdog and power

Two watchdogs run: the external PIC32 one at about 60 seconds, fed by nx, and the i.MX6 imx2-wdt at about 10 seconds, fed by systemd. Stopping nx only trips the PIC32 one, so disable it in the same step:

NxExe watchdog 0

or send the ValueWrite directly:

printf '\274\001\000\004\000\004\110\100\003\000\000' > /dev/ttymxc2

When the PIC32 watchdog expires, the unit power-cycles and comes back. IPP 0x0c or 0x0e with an empty payload is different: it powers the unit off and leaves it off. Do not send those unless you can pull power again.

Backlight

The PIC32 owns the panel backlight. 0x500b is the ambient reading; 0x4030 and 0x4031 are the brightness at ambient 0 and ambient 10000. Brightness is 0..10000; equal values hold a fixed level, max above min follows the sensor.

On the units seen, the pair comes up at 200/12000 and nx sets 100/15000 at startup. The presets in opscript.nxs are off 0/0, low 100/100, half 2000/2000, full 10000/10000, auto half 100/5000, and auto full 200/20000. See framebuffer for the frames.

Audio amp

The external speaker amp is key 0x07E0:

stty -F /dev/ttymxc2 115200 cs8 -cstopb -parenb raw -echo

# on
printf '\274\001\000\004\000\003\313\007\340\001' > /dev/ttymxc2

# off
printf '\274\001\000\004\000\003\313\007\340\000' > /dev/ttymxc2

# read
printf '\274\001\000\002\000\002\104\007\340' > /dev/ttymxc2
timeout -t 2 dd if=/dev/ttymxc2 bs=1 count=10 2>/dev/null | hexdump -C

It is a hard latch until the PIC32 resets; it reads back, so query it instead of toggling blind. See alsa.

Sensors and clock

On I2C bus 2 there is the PFUZE100 PMIC at 0x08, the LM75 at 0x48, the module EEPROM at 0x50, and a second 24c64 at 0x57 that did not answer on the units seen.

cat /sys/class/hwmon/hwmon0/temp1_input

That is milli-degrees Celsius. The driver owns the bus, so use hwmon rather than i2cget.

The host clock comes from UTCOffset in the internal EEPROM (-360, CST) on these units. cVEND log timestamps are UTC, which is why they can look off from system clock.

pic32.1795400928.txt.gz · Last modified: by qkb