Some weeks ago I got a Xperia Z Tablet for free. The former owner was unable to charge it. A plugged in charger didn't do anything. As the battery was already dead, the Xperia Z Tablet only showed a 3 times blinking red light while pressing the ON button, I thought that it could be the charger itself. I tested 3 different chargers one with even 2.1A. Some forums suggested that the tablet should be charged for a longer time, some suggested 24 hours, I let the tablet on the charger for that long, but it didn't charge. From that point I had three options: it was either a dead battery or the USB charging port was damaged, or the circuit board that was in charge for charging had some damage.
Fixing the Hardware problem
The USB port was according to iFixit a simple procedure. I therefore ordered the USB port from EBay (China). Once the part arrived I opened the Z Tablet and followed the iFixit instructions. I replaced the USB port in no time. BUT, still no luck with the battery.
The next part on my shopping list was the battery. This was a little more difficult as there weren't that many companies shipping batteries to Finland. Anyway, I got one within in no time from Germany.
The tablet was still open. I unscrewed the battery, put the new one in and voila: the tablet booted the Android 5.11. But soon I recognized that the tablet wasn't charging. The batteries powered drained and I realized that the problem might be more sewer. I got frustrated at that part because now only the circuit board could be the problem. I realized that I spent money one something that was beyond my capability of repair. At that point I didn't want to give up and went back for the USB port. I checked it and noticed that it was not completely clicked in its mount point. I pushed it in, fixed it with the screws and started the tablet: yes, it was charging!
Upgrading to newer software
From my previous experiences with LineageOS I found in now time that the Sony Xperia Z Tablet (mine is the one with LTE - pollux) could run the custom ROM. I started to prepare everything in accordance with the instructions at the LineageOS wiki.
My first mistake was not to activate the USB debugging. This resulted in being unable to use ADB. I had to get the stock ROM back.
My second mistake was a more difficult one. I didn't notice in the beginning that the there is the Sony Xperia Z Tablet with LTE (pollux) and the Sony Xperia Z Tablet WiFi (pollux windy). I tried to flash the TWRP for the pollux windy on the pollux. Which resulted in a black screen. Because I didn't know during that time that there are different versions available I decided to go back to stock ROM. I flashed the stock ROM from XperiaStockRoms following their instructions and then tried to flash the pollux windy TWRP again. As it resulted in the same boot loop I didn't quit understand what I was doing wrong. I went back to the LineageOS sites Sony device overview page and realized that there are two. I flashed the correct pollux TWRP on it, booted it up and flashed the LineageOS ROM that I pushed onto the sdcard with ADB. Piece of cake.
For the Sony Xperia Z Tablet there is only LineageOS 14 available, which is based on Android 7. If you want an even newer version there is even 8.1 available.