Monthly Archives: December 2019

Remove devices left after kpartx

In case you’ve used kpartx -a on a disk image to mount partitions from it, and then deleted that image (so you cannot kpartx -d anymore, as you would normally do), use this:

dmsetup delete /dev/dm-X

to remove each /dev/dm-X device left over. Use losetup -D to remove the /dev/loopX device left over.

ili9225 and fbtft

I was working on making an ILI9225-based display breakout work with the fbtft drivers. Here’s a page with pics for the exact make of the display breakout I worked with. Here’s a page that claims you can use ILI9341 fbtft commandline – except it’s an obvious copy-paste, the init commands of ILI9341 aren’t even close to what’s needed, and the register width is wrong – register addresses for ILI9225 are 1 byte and not 2 bytes wide, you should be able to verify that with a $6 logic analyzer (and if you don’t have one, buy one ASAP), and it should use the “0x20, 0x21, 0x22” addr set mechanism instead of something like “0x2A, 0x2B, 0x2C”. With a logic analyzer, Pulseview and a working C ILI9225 library for RPi that we could test against, we sat down and analyzed the behaviour of the library.

DSCN7335.JPGOur work setup

DSCN7329.JPG

RPi with the display and the splitter

DSCN7331.JPG

The splitter that allowed us to connect a logic analyzer in a clean way

DSCN7332.JPG

Looking at the known-working data from the C library

We had to lower the SPI clock line – at 16MHz, the “Saleae clone” can’t keep up with 4 channels of data (CS, CLK, MISO and RS). It’s only useful to scope RST in the beginning – just to make sure it works. The SPI decoder worked wonders, even on a netbok with Intel Celeron 847 and 3GB of RAM (long live zram).

6 hours later, here’s a commandline that worked for us in the end, something that creates a framebuffer device that works with fbcp, con2fbmap and fbi:

sudo modprobe flexfb width=220 height=176 regwidth=8 init=-1,0x01,0x01,0x1C,-1,0x02,0x01,0x00,-1,0x03,0x10,0x30,-1,0x08,0x08,0x08,-1,0x0C,0x00,0x00,-1,0x0F,0x08,0x01,-1,0x20,0x00,0x00,-1,0x21,0x00,0x00,-2,50,-1,0x10,0x0A,0x00,-1,0x11,0x10,0x38,-2,50,-1,0x12,0x11,0x21,-1,0x13,0x00,0x66,-1,0x14,0x5F,0x60,-1,0x30,0x00,0x00,-1,0x31,0x00,0xDB,-1,0x32,0x00,0x00,-1,0x33,0x00,0x00,-1,0x34,0x00,0xDB,-1,0x35,0x00,0x00,-1,0x36,0x00,0xAF,-1,0x37,0x00,0x00,-1,0x38,0x00,0xDB,-1,0x39,0x00,0x00,-1,0x50,0x04,0x00,-1,0x51,0x06,0x0B,-1,0x52,0x0C,0x0A,-1,0x53,0x01,0x05,-1,0x54,0x0A,0x0C,-1,0x55,0x0B,0x06,-1,0x56,0x00,0x04,-1,0x57,0x05,0x01,-1,0x58,0x0E,0x00,-1,0x59,0x00,0x0E,-2,50,-1,0x07,0x10,0x17,-3 buswidth=8 setaddrwin=1 && sudo modprobe fbtft_device debug=3 name=flexfb rotate=1 speed=16000000 regwidth=8 buswidth=8 gpios=reset:25,dc:24,led:18,cs:8

There’s probably an easier way to do that – please leave a comment if you find one!

Here’s a picture you can use with fbi in your testing:

you can do wget http://eja.lv/3hm to download this picture from command-line. Use imagemagick to rotate it if necessary.

The flexfb driver is getting removed from the kernel. You should be able to compile it in again – revert this commit and then just go as you’d go about compiling kernel modules, here’s an example for the sh1106 module.

Also, here’s the datasheet. Here’s a mirror of it: Datasheet_ILI9225DS_V022   

The datasheet is good enough as far as datasheets go. For example, in case you need to flip the display (as we did), it’s easy to find that you need to flip the bits in the 0x01 register – to test that on-the-fly, just run

sudo modprobe -r fbtft_device && sudo modprobe -r flexfb

and rerun the init command tweaking the registers that you need, no need to even restart.