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) =))
[root@localhost bootloader]# make
make -C boot boot JUMP_ADDR=0x80500000 RTL865X=1
make[1]: Entering directory `/root/src/jwnr2000v2-V1.0.0.8_1.0.7_GPL/jwnr2000v2/bootloader/boot’
mips-linux-gcc -c -march=4181 -g -fomit-frame-pointer -nostdinc -fno-pic -mno-abicalls -G 0 -I. -I./include -D__KERNEL__ -Dlinux -O -DCONFIG_POST_ENABLE -DJUMP_ADDR=0x80500000 -DRTL865X=1 -DCONFIG_RTL865X=y -DCONFIG_RTL865XC=1 -o ./Output/eth_tftpd.o ./init/eth_tftpd.c
In file included from ./init/eth_tftpd.c:2:
./include/etherboot.h:622: warning: conflicting types for built-in function ‘putchar’
./init/eth_tftpd.c: In function `updateARPTable’:
./init/eth_tftpd.c:394: error: `rx’ undeclared (first use in this function)
./init/eth_tftpd.c:394: error: (Each undeclared identifier is reported only once
./init/eth_tftpd.c:394: error: for each function it appears in.)
./init/eth_tftpd.c: In function `setTFTP_RRQ’:
./init/eth_tftpd.c:457: error: `rx’ undeclared (first use in this function)
./init/eth_tftpd.c: At top level:
./init/eth_tftpd.c:876: error: syntax error before “bool”
./init/eth_tftpd.c: In function `checkAutoFlashing’:
./init/eth_tftpd.c:943: error: `len’ undeclared (first use in this function)
./init/eth_tftpd.c:945: error: `startAddr’ undeclared (first use in this function)
./init/eth_tftpd.c: In function `chk_ST_ID’:
./init/eth_tftpd.c:1160: warning: passing arg 1 of `memcmp’ makes pointer from integer without a cast
./init/eth_tftpd.c:1161: warning: passing arg 1 of `memcmp’ makes pointer from integer without a cast
./init/eth_tftpd.c: At top level:
./init/eth_tftpd.c:1167: error: syntax error before “bool”
./init/eth_tftpd.c: In function `FlashWriteStringTable’:
./init/eth_tftpd.c:1179: error: `STRING_TABLE1_ADDRESS’ undeclared (first use in this function)
./init/eth_tftpd.c:1181: error: `STRING_TABLE2_ADDRESS’ undeclared (first use in this function)
./init/eth_tftpd.c:1189: error: `StringTableStartAddr’ undeclared (first use in this function)
./init/eth_tftpd.c:1190: error: `file_size’ undeclared (first use in this function)
./init/eth_tftpd.c:1203: error: `from_NMRP’ undeclared (first use in this function)
./init/eth_tftpd.c:1204: error: `flash_write_string_table_ok’ undeclared (first use in this function)
./init/eth_tftpd.c:1209: error: `STRING_TABLE_SIZE’ undeclared (first use in this function)
./init/eth_tftpd.c: In function `prepareACK’:
./init/eth_tftpd.c:1485: error: `nmrp_tftp_runing’ undeclared (first use in this function)
make[1]: *** [Output/eth_tftpd.o] Error 1
make[1]: Leaving directory `/root/src/jwnr2000v2-V1.0.0.8_1.0.7_GPL/jwnr2000v2/bootloader/boot’
make: *** [all] Error 2
Your links are broken.
Thanks, I’ve fixed the link to the other post. It’s been a long time and since then I’ve switched domains. As for that openwrt port link – it’s been dead and buried for a long time.