Репозиторий для Агилии.

Собственно, давно напрашивалось и запилил сабж. Ссылка есть теперь и сбоку. Внутри можно найти фарш самого разнообразного ПО, для тех, кто прошел стадию красноглазия и перешал в стадию “инфракрасноглазия”. А именно, iverilog, кросс-компиляторы для разных архитектур мк, kicad с либами, openscad и прочее.
Работает это безобразие на моем небольшом wl520gU под управлением OpenWRT. Да да, том самом где я память апгрейдил

Scam-o-matic

Well, I’ve been scammed. You might have heard of the SD card scam, when you buy a card, and it reports to be bigger, than it actually is, and whatever you write beyond the boundary of the really available space gets lost.
I ordered a bunch of 5 microSD cards, 4GiB each, and they were a pure scam with about 115 MiB instead of 4 GiB.
Luckily, I managed to get my money back, via opening a dispute and later a claim (Scammers didn’t want to give the money back, did they?), but the cards still remained here.
To test such shitty cards there exist 2 tools: h2testw and f3. First for windows, second for linux. Thy figure out the real capacity for you. I didn’t like them, because they took ages to scan one 4 GiB card. And, they operated upon a upon a filesystem, that I didn’t like as well. So I wrote my own tool.
It’s dumb as hell, and was created while f3 was still scanning one card. And it’s a lot faster. Meet ‘scam-o-matic’.
It writes some preudorandom data to the card, until it detects something bad. Usually that happens when we reach the boundary of ‘good’, somewhat ‘reliable’ memory. Then it double-checks the region, and if everything is fine (e.g. no mismatches between first and second pass) it creates a partition table for you, with one partition that covers only working area of the card.
Now just format it, alter the type with cfdisk, and make use of it.
(more…)

Configuring a Xilinx FPGA from ARM

Okay, it’s time I got down to my Ph.D project which is a 2D/3D GFX accelerator. I really wonder if I’m going to pull it off. So, after playing for a couple of months with a simulator I decided to move on to an FPGA. I doubt that a spartan will allow me to fit in everything I want – but I definetely can test a plenty of stuff there.

I had this board from starterkit.ru, which has an FPGA and an AT91SAM9260, which is a 200Mhz ARM SoC.
(more…)

Reverse engineering STC ISP protocol.

Some time ago, I got myself a bunch of those chips. They were dirt chip, they come from china, they have a 8051 architecture and… They are totally missing a way to get programmed in linux.
You can use sdcc, but you are still made to use their binary sh*t to upload the firmware.  And they were retarded enoght no to open up the protocol.
So, time to hack…
(more…)

Agilia Linux: Немного ABUILD’ов

Не так давно поставил себе субж. Для начала на дачный воркстейшн потестить. И как это не странно, он меня порадовал. Шевелится намного быстрее кубубунты, пакетная система достаточно простая… Настолько, что мейнтейнеры даже пакеты не подписывают. Но это, думаю, вскоре поправят. А нет, так начитавшиеся журнала “хакирь” школьники поторопят =)
Но вот софта маловато. Ни iverilog’a, ни avrdude, ни openocd, kicad’a или mspdebug нет. Пришлось сварганить несколько ABUILD’ов. Оные лежат тут: https://github.com/nekromant/agilia-files
Пока сделал ABUILD’ы только для mspdebug, avrdude и libftdi.

Using android TTS engine remotely

Strangely enough, there appeared some good TTS engines for android that don’t make me go nuts . So, instead of building qemu to run my favorite cepstral synth using x86->arm translation, I decided to move on to a different software. Besides, it supports Russian, so I decided to give it a try.
Time to recall programming in java. Damn, I hate java =), last time I coded something in it was some crappy j2me app 4 years ago. Not much changed.
After a wasted evening here goes a small util: NetTTS.


(more…)

RTL8196 vs OpenWRT

Okay, I admit it. I screwed up. Bought some ‘edup’ shit to find out the chip was totally unsupported. Well, it caught my attension and I decided to make it supported. Not just because I can’t buy a supported one… It’s just the fun
Inside is… RTL8196C. Some time ago I already completed an awesome quest called “collect all the pacthes and get a somewhat working outdated toolchain” ( in russian, sorry I’m lazy to translate). A look at the BSP is quite enough for my ‘shit-o-meter’ to say “value out of range”.  This code causes depression, headache, stomachache and an unconventional desire to kill… make sure you have good nerves, before you open it.
Well, all the trash and fun I found in realtek’s BSP follows. THIS shit is running in production use!
Should anybody from realtek be reading this… Guys… Do a favor… Kill yourself, save the planet!

Okay, lets start with the fun stuff.

necromant@ilwyn:/media/NC-OS/pocket_router/linux-2.6.30-veteran/arch/mips/rtl8196b$ ls -la
итого 64
drwxr-xr-x 2 necromant necromant 4096 2010-12-17 11:48 .
drwxr-xr-x 19 necromant necromant 4096 2010-12-17 11:48 ..
-rw-r--r-- 1 necromant necromant 6268 2010-02-22 05:35 int.c
-rw-r--r-- 1 necromant necromant 236 2010-02-22 05:35 Makefile
-rw-r--r-- 1 necromant necromant 2615 2010-02-22 05:35 mem.c
lrwxrwxrwx 1 necromant necromant 84 2011-08-21 14:14 pci.c -> /home/bo_zhao/8196/linux-2.6.19/linux-2.6.x/arch/mips/realtek/rtl8196b/pci-rtl8196.c
-rw-r--r-- 1 necromant necromant 1996 2010-02-22 05:35 pci.h
-rw-r--r-- 1 necromant necromant 14802 2010-02-22 05:35 pci-rtl8196.c
-rw-r--r-- 1 necromant necromant 1111 2010-02-22 05:35 printf.c
-rw-r--r-- 1 necromant necromant 4383 2010-02-22 05:35 setup.c
-rw-r--r-- 1 necromant necromant 2240 2010-02-22 05:35 timer.c

pci.c symlinks to /home/%codemonkeyname%/…, and since %codemonkeyname% != necromant it wouldn’t get compiled. Luckily that was some old redundant stuff. Just a miracle it worked after all. There’s a plenty of this shit in kernel source.

From the kernel tree, lots of symlinks go outside. Without passing some vars to the hacked kernel Makefiles it wouldn’t compile at all. Only from BSP.

 

Board-specific init is not in mach-boardname.c, no way, a whole folder called bsp that is sylinked somewhere outside. And there’s little to no board-specific code in there.

MTD layout is hardwired in driver, not board specific and set via kconfig.

leds’n’buttons, just like the whole gpio subsystem is implemented as a char dev, incompatible with just about anything. Web apps are supposed to read and write to that char device. Forget those /sys/class/leds/, led triggers and such shit! Btw, board-specific led defines are in the led driver, not board-specific stuff.

For LexraCore (A veteran MIPS-like CPU, that got damaged by patent trolls and doesn’t have some instructions) there’s a new kernel arch called rlx, mostly copypaste from mips, with lottsa hacks.

Makefiles of the kernel are hacked to get compiled via an archeological gcc 3.4x.

Guys from realtek write in camelCase at kernel level.Crap!

Comments in dmesg are sucky like “IN WIFI INIT!111”. Why caps?

Kernel images are packed using rtkload, some hacked opensource project. It is put in kernel tree, and the Makefile calls ‘cvimg’ util by realtek, that gets compiled along in some ‘goahead’  (the webserver, yeah!?) Rootfs is attached to the image with ‘mgbin’ from the same ass.

Paths longer than about 20 chars cause mgbin & cvimg to crash. Who the heck is gonna do boundary checks, you ****?!?

Baudrate for earlyprintk is defined somewhere in a header totally unrelated to board init somewhere in в arch/rlx/include. It’s just not funny anymore!111

A COOL BONUS. 

Extract from their GPIO driver:

 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
 kill_proc(1,SIGTERM,1);
 #else
...

This soon made it to the top of the russian site called govnokod.ru ( a collection of MOST shitty code from the known universe) =))

OpenWRT for unbranded-3gn(RT3050F) router (With USB!)

Okay. As promissed, usb support arrived. Thanks to Layne Edwards for his dwc_otg patches – everything now works.
Since I have this hardware and I use it, I will be updating a page with firmware builds.
So, meet the first version of it and grab on the ….

Release notes:

 

  • comgt for 3g modems is built-in
  • USB host and dwc_otg are compiled in kernel, therefore additional usb kmod packages have to be installed with –force-depends
  • Adjusted mtd partition sizes

 

Known issues: 

Since usb support is compiled-in additional usb kmod packages should be installed with –force-depends

 

 

This router support is now added to OpenWRT trunk under the name of wr512-3gn. Please use the OpenWRT snapshots or compile from source yourself. Beware, that I haven’t tested the if the update via web interface works or not. If it doesn’t, you have to solder in the UART.

Отправляем пинауты на планшет при помощи питона, гтк, и adb

Собственно, когда началась эта планшетная лихорадка, я себе раздобыл flytouch II из китая. Но кроме как посмотреть раз в месяц что-то мозгоразжижающее его не юзал. Разве что разок в виде навигатора.
Потом пришла в голову мысль, а ну как там удобно даташиты смотреть. Увы нет. Ищет в пдфах медленно, так как адобридер на андройде тормознутый. А читать… Читать все равно с мобильника в дороге удобнее.
В общем пришла мне в голову мысля. Хранить в нем распины микросхем, борд и прочего, что жутко надо когда паяешь. Иными словами те кусочки, которые искать не надо.
Начал с того, что при помощи подручных средств переоборудовал настольную лампу в держатель для планшета. прямо над местом, где паяю, чтобы он был перед глазами.
Дальше пошло веселье. Когда выделяешь в окуляре пинаут, да и вообще кусок документа – его можно скопировать как картинку. Но сохранить в файл автоматом – никак. У klipper’a есть действия с буфером обмена, но нужного мне не оказалось.
Ладно, призываем на помощь командную строку.
Сначала подумав немного, я соорудил на питоне и pygtk вот такой костыль:

#! /usr/bin/python
 
import pygtk
pygtk.require('2.0')
import gtk
import os
import sys
 
def save_image(f):
#    assert os.path.exists(f), "file does not exist"
    #image = gtk.gdk.pixbuf_new_from_file(f)
 
    clipboard = gtk.clipboard_get()
    pixbuf = clipboard.wait_for_image()
    pixbuf.save(f, "jpeg", {"quality":"100"})	
 
 
save_image(sys.argv[1]);

Его назначение сохранить картинку из буфера обмена в жопег. Имя файла дается в виде первого и единственного аргумента.
Остальное было делом техники:
При помощи kdialog запрашиваем имя файла, категорию в которую будем сохранять (подпапки на устройстве), после чего сохраняем картинку и отправляем на планшет, откуда ее всегда легко открыть.

Выходит примерно такой скрипт в первом приближении

#!/bin/bash
N=`kdialog --inputbox "Name, please"`
C=`kdialog --inputbox "Category, please"`
getimg /tmp/pin.jpg
adb shell mkdir /sdcard/sdcard2/pinouts/$C
adb push /tmp/pin.jpg /sdcard/sdcard2/pinouts/$C/$N.jpg

Necromant’s MultiDrop UART: The software.

Well, there were quite a few bugs in the device and it looks like the baseboard is going to redesigned, although it will still be compatible with all the extension ‘shields’.
It looked like the transistors gave a .2 volts voltage drop, and the diodes dropped 0.1 more, turning regulated 3.3 into 3.0 volts, so sot-23 mosfets are already on the way.
Meanwhile, I started to write some software. This resulted into a dumb commandline utility called muart-ctl.
And… A KDE4 Plasmoid, that acts as a frontend.

Here goes the obligatory screenshot:
And the full shot of the desktop:

Profile management is not yet ready, and there are still some issues in the electronics, that need further addressing (And a new PCB!), but nevertheless it works.
The plasmoid is written in javascript, which was kind of pain. The bindings are not well documented, so I had to do quite a lot of guessing. Nevertheless, as for my first javascript project it all went fine. Lots of thanks to Nikita Melnichenko, for the plasmoid ‘makeprogress’. I tore that one apart and used as a reference.