Showing posts with label raspberry pi. Show all posts
Showing posts with label raspberry pi. Show all posts

Sunday, April 8, 2018

Using Raspbery Pi 3 as wireless client router

The title may seem confusing, but it covers a specific use case: you have a machine with ethernet port only, and you want to connect it to a wifi network. For whatever reason, you can't, or don't want, use a wireless card with your computer. As for me, I have Amiga 500 with Plipbox, and Rapberry Pi B+ with RISC OS 5, and both can be connected to the Internet - but using a few meters long network cable, lying on the floor, to reach a cable TV router is far from what I'd call a comfortable solution.

The Internet is full of recepies of how to use Raspberry Pi 3 as a wireless access point, but I wanted to use it the other way round. I wanted it to be a wireless client, and at the same time act as a router, so I could connect my ethernet-only hardware to the Internet through it. Sadly, I couldn't find any sensible description, so I finally figured it out myself. It's not an ideal solution, and it uses static addresses instead of DHCP, but it's fairly simple, and it works for me. If you have a better one, feel free to point to it in the comments.
My recipie works with Debian 9 (a.k.a. Raspbian Stretch) with desktop. Take note that it may not work with other Linux versions. I assume that you know how to install it on SD card and how to run it, so I'll go straight to the network setup.

First, you need to configure Raspberry Pi to connect to the wifi network. Turn it on and wait for the system to load. Now click on the wifi icon located on the dock and choose your network. Enter the network password and wait until the connection becomes established. You can check if everything works correctly by pinging google.com or some other address.

Now you need to edit a few system files. They are only writeable by the user "root" so you can either use a console editor, like vim or nano, with the "sudo" command, or run "gksu gedit" from the desktop. I prefer the first method, so I'll use this one.

First, you need to disable dhcp for the ethernet interface. It's because Raspberry Pi is meant to work as a client and so it will try to reconfigure the ethernet port everytime it discovers a network cable has been attached to it. So do:
sudo nano /etc/dhcpcd.conf
and add the following line at the end of the file:
denyinterfaces eth0
Next, you need to enable packet forwarding between the network interfaces. To do this, uncomment the following line in /etc/sysctl.conf:
net.ipv4.ip_forward=1
Finally, you need to configure routing. I use 10.0.0.0/24 for my network, but you can use any non-routable addresses for this. So, add the following lines to /etc/rc.local before "exit 0":
ifconfig eth0 10.0.0.1 netmask 255.255.255.0 up
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -j MASQUERADE
iptables -A FORWARD -s 10.0.0.0/24 -j ACCEPT
The first line sets up the IP address and netmask for the ethernet port. The second one enables packet translation, which means that the network packets will be able to get from the 10.0.0.0/24 network to the outside world. The last rule allows those packets to pass through the built-in firewall.

Now reboot the Raspberry Pi. After a while it will connect to the wifi network (you can say when it is when the yellow LED on the board stops binking), and it will allow clients to use its ethernet port as a gateway.

I will not describe client configuration in detail, because it differs very much among operating systems. I'll just give you the parameters you need to enter to make the client work:
1) IP address: anything between 10.0.0.2 and 10.0.0.254. If you use more than one device (for example connected through a switch) rememer that each one of them needs its own unique IP address.
2) Netmask: 255.255.255.0
3) Gateway: 10.0.0.1
4) DNS servers: use 8.8.8.8 as primary and 8.8.4.4 as secondary. Alternatively, you can use your home router's IP address (e.g. 192.168.1.1) or your ISP provider's DNS hosts - if you know what they are.

Saturday, January 23, 2016

Using Raspberry Pi with operating system installed on pendrive

You cannot boot current versions of Raspberry Pi from mediums other than an SD card, which means that for some space consuming operating systems, like Raspbian, you need at least a 4GB or 8GB card. But it doesn't mean that if you have a 1GB or 2GB SD you cannot use a larger system on Pi. You just need a memory stick with sufficiently high capacity.

The trick is simple. Write the operating system image on a pendrive instead of an SD card. Format the card just like you do for everyday use with a camera or smartphone, i.e. just create a single partition with regular FAT file system on it. Now mount the memory stick and you will notice that the first partition is also a FAT parition with a couple of different files - they are required to boot the operating system. Copy all files and folders from the stick to the card. Now edit cmdline.txt file located on the SD card (this is important, remove the pendrive before editing to make sure you modify the right file). The file contents will be similar to this:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1
elevator=deadline root=/dev/mmcblk0p2 rootfstype=ext4 fsck.repair=yes rootwait
It's the arguments passed to the kernel on boot up. The root parameter tells the kernel where the main file system is located. Change it from root=/dev/mmcblk0p2 to root=/dev/sda2 and save the file on card. Connect the card and the pendrive to the Pi and turn on the power. It will load the kernel from the card, but will mount as root folder the second partition of the memory stick, containing the actual operating system (and recognized by Linux on boot up as /dev/sda2).

I used this trick to run Minibian, having a few memory sticks and just one small 128MB SD card at my disposal. If the Pi doesn't boot from /dev/sda2 make sure you don't have any other usb storages connected, otherwise try a different device instead of /dev/sda2, like /dev/sdb2, /dev/sdc2, etc.

Wednesday, November 25, 2015

Modern micro with RISC OS Pico

RISC OS Pico is a stripped down distribution of RISC OS which turns Raspberry Pi into a modern micro computer. It was created by RISC OS Open Limited to celebrate 50 years of Basic programming language. Imagine a classic BBC Micro manufactured today: the same black and white text console, the same fun and easy to learn programming language, but much cheaper, with much faster CPU and more RAM, with super fast flash storage, capable to fit into your pocket. This is what Raspberry Pi with RISC OS Pico is.

Pico boots within a few seconds, straight into console Basic interpreter, just like all classic and modern micros. Yes, you heard it right. Micro computers didn't die with the demise of Atari XL/XE, BBC, C64 and Spectrum. There are many modern incarnations, like Micromite Companion, Fignition (using Forth instead of Basic, just like renowned Jupiter ACE), Grant Searle's Multicomp and other homebrew projects. RISC OS Pico has additional advantage, though. Because its shell is BBC Basic VI, it is natively capable of running programs written in BBC Basic. When I was a child I found it very exciting to type in a program printed in a computer magazine and watch it run. Now you can do the same with your kids to teach them programming. You can google around for some ready to use BBC Basic listings or check out the online book and create something yourself. Basic is very easy to learn and great for understanding how the computer works. It lacks many concepts found in other high level languages, like objects, interfaces, first class functions and other stuff, but they have been created for professional programmers, and they don't show you the way the computers really work. For the CPU any program is just a list of instructions (keywords in Basic) located at subsequent memory addresses (line numbers), and the program counter goes over that list one by one, changes the flow when a condition is met (IF...THEN...ENDIF), repeats some instructions in a loop (REPEAT, WHILE) jumps into a subroutine located at different address (GOSUB line-number), then returns from it (RETURN), or jumps to some other place in a program (GOTO line-number). Even threads, when run on a single CPU core, are executed sequentially, it's just very fast switching between them which creates an illusion of parallel processing. This is why people who can program in Basic are able to learn assembly language much quicker than those who come from other languages. Don't be afraid of Basic teaching you "bad habits". Languages are not good or bad, it's programmers that are.

To start using RISC OS Pico you need a distribution which is suitable for your version of Raspberry Pi. If you have model A or B you can use an official ROOL version, otherwise you should download an alternative version, which has been upgraded to work with Raspberry Pi B+ and Raspberry Pi 2. The file is just 4MB and the only thing you need to do is to unpack it to a blank, FAT formatted SD card. You can also buy a ready to use SD card.

When you put the RISC OS Pico on the card and turn the power on, you should see the following prompt on your screen:
RISC OS 192MB
ARM1176JZF-8 Processor
Piccolo Systems SDFS
ARM BBC BASIC VI (C) Acorn 1989
Starting with 97040636 bytes free
>_
The memory size and processor type can be different, depending on the Raspberry Pi model used with Pico. If you see nothing but a blank screen, add the following line to CONFIG.TXT:
hdmi_safe=1
It should solve the video output problem.

Your new BBC Micro is now ready to use, but if you don't have a UK keyboard, you may notice that some keys are mapped differently. To fix his just type in:
*keyboard usa
and press Enter. If you don't use a standard QWERTY layout, replace "usa" with proper country name ("france", "germany", etc). Notice that the aforementioned keyword starts with "*". It's so called "star command", and it's an operating system command called inside Basic - just like DOS command in Atari or Commodore Basics. There are more commands you can use, for example "*cat" lists the contents of a directory, and "*quit" quits from Basic (to go back just type in "basic" and press Enter). Star commands are written in lowercase, unlike Basic keywords, which must be uppercase. You can find star commands reference here.

To load a program from the SD card use the Basic keyword LOAD, for example to load SimonSays program located in Examples folder use the following:
LOAD "Examples.SimonSays"
To list a program use LIST. Press Scroll Lock key during listing to pause screen scrolling, or use "LIST 10,50" to show only lines from 10 to 50.

When you type your own program you can number the lines yourself or use AUTO keyword to let Basic do it for you. To turn off this feature just press Esc. It's a good practice to leave a bit of space between subsequent line numbers (use 10,20,30 instead of 1,2,3) in case you need to put some code between existing lines. But don't worry if you get lost in numbering - just use RENUMBER.

To replace a program line with new code just enter it using the same line number, and to delete it use only the number with no instructions to follow, for example to remove line 10:
10 PRINT "Hello"
type in:
10
and press Enter. Editing lines is also very easy. List the program, press up arrow and find the line you want to modify on the screen, than keep pressing End key. The contents of the line gets copied to the prompt, so you can edit it and then confirm changes with Enter.

When your program is ready you can SAVE it with:
SAVE "filename"
and then execute it with RUN. You can break it at any moment with Esc key. If by any chance the program stops responding, you can restart the Pico pressing CTRL and Break keys simultaneously.

Programs written in BBC Basic are very fast. Even when 8-bit computers dominated the world, BBC Basic was considered the fastest and most mature. I wondered if it's still true, so I created an implementation of the sieve of Eratosthenes in Basic (available here) and Python (available here) using exactly the same algorithm, and ran them both on my Raspberry Pi B+. The results are as follows:

InterpreterOperating systemExecution time
BBC Basic VIRISC OS Pico7.84 seconds
BBC Basic VIRISC OS 5.214.59 seconds
Python 2.7.2RISC OS 5.2125.68 seconds
Python 2.7.9Raspbian Jessie17 seconds

To try the BBC Basic version with RISC OS Pico, just put the file "sieve" in the root folder of the Pico SD card, fire up the Pi and do:
LOAD "sieve"
RUN

Saturday, November 7, 2015

Using Raspberry Pi with a VGA monitor

One of the most fantastic Raspberry Pi features is its ability to fit in a pocket. Whether you travel far away from home or just go for a short visit you can always have your whole workplace with you. You don't have to copy all the files to a pendrive and then look for a computer to work on, wondering if you bring back home a virus or find your secret files "backed up" on some peer-to-peer network. You don't have to carry a big case with heavy latop inside, either. All you need is to take your Pi out of your pocket and connect a mouse, a keyboard, and a TV.
But what if there is only one TV set, and suddenly everybody wants to watch TV or play the latest hit on a game console? Yes, you can use a good old (S)VGA monitor! It can be an interesting alternative to a big TV. A flat LCD monitor takes little space on desk and can be a useful way to recycle some old electronic stuff, instead of just throwing it away. You can make the world a better place by reusing an old monitor with Raspberry Pi!
I will show you how to connect Raspberry Pi running RISC OS to a regular computer monitor with VGA input, but most of the tips below should be useful for Linux users as well.

Although Raspberry Pi does not feature a VGA output, there are many adapters available, which can convert digital HDMI data stream into analogue signal required by a VGA monitor. However, you have to pay attention to two very important things.
First, it has to be an adapter with a special DAC (Digital to Analogue Converter) chip. Some adapters just pass the signal through, and they can only work with PCs or laptops which can transfer an analogue signal through HDMI port. Raspberry Pi is not designed to support such feature.
Second, search for an adapter with audio output (the most popular is mini-jack port). It's because the Pi settings required to make it work with a VGA display can make the built-in mini-jack audio output port inactive. It is possible to have video signal passed through the adapter, and sound through a built-in audio jack, but it can be very tricky and the settings described below don't work for everybody. Moreover, if an adapter has an analogue audio output, it indicates that it has some kind of a DAC chip onboard, and is not a simple pass-through.
Hint: adapters advertised to work with a smartphone (or tablet) in most cases also work with the Pi. Anyway, before you buy such adapter, read it's description carefully or, if in doubt, ask the seller whether it was tested with Raspberry Pi. If you are still unsure, you can buy PiView, which is guaranteed to work with all Raspberry Pi models, but it costs almost as much as the Pi itself. Personally, I use an adapter I bought quite cheap on eBay and it works very well.

Now for the software part. The Pi can now speak to the monitor through the adapter, but the monitor will not send back the information the Pi expects to receive, so we need add some information to the Pi's default GPU (Graphics Processing Unit) configuration. This configuration is stored on a boot partition of the RISC OS SD card in a file called CONFIG.TXT. To edit this file on a PC, simply put the card into a reader and after it mounts open CONFIG.TXT from the mounted partition in the editor of your choice. To edit it from RISC OS, open !StrongED, click on the SD card icon on the iconbar, then hold down Shift and double click on !Boot icon, then Loader and drag CONFIG/TXT to !StrongED icon on the iconbar. The reason I recommend !StrongED over !Edit is that the former one can handle PC end-of-line codes better (!Edit displays [0d] at the end of each line).
The contents of the config file for RISC OS should look more or less like this:
fake_vsync_isr=1
framebuffer_swap=0
gpu_mem=64
init_emmc_clock=100000000
kernel=RISCOS.IMG
This is a basic configuration needed to boot RISC OS on Raspberry Pi. It will look a bit different for Raspbian and other Linux distributions, but it doesn't matter now. The parameters are written in "key=value" form, each in separate line. You can find a detailed description of the configuration parameters at Embedded Linux Wiki.
What you should do is to add the following lines to the configuration file. You can place them right after the last parameter, before the first one, or somewhere in the middle:
hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=17
Those lines require some explanation. The "hdmi_force_hotplug=1" tells the Pi to use to use HDMI output even if no connection with an HDMI with display was detected. As I mentioned before, a VGA monitor can't communicate with Raspberry Pi through HDMI, it can only display a picture received via the adapter. Next option "hdmi_group=2" selects DMT (Display Monitor Timig) output mode, which is a VESA (Video Electronics Standard Association) standard for VGA monitors, and "hdmi_mode=17" sets screen resolution to 1024x768 with 70Hz refresh rate. You should tweak that parameter depending on your monitor display capabilities, using information found at RPiconfig in DMT video modes table.

Now for the sound. If you have a VGA adapter with audio output and want to use it, you should add the following lines to your configuration:
hdmi_drive=2
hdmi_force_eid_audio=1
The "hdmi_drive=2" option selects HDMI mode with sound (value "1" means "no sound") and "hdmi_force_eid_audio" makes the Pi skip detection of the display's audio capabilities. Without this option you may get some strange sound problems, like no audio signal after first boot, suddenly reappearing after reboot.

If you want to use the Pi's built-in audio jack instead (you can't have both outputs active at the same time!), you should add these lines in place of the previous two:
hdmi_ignore_edid_audio=1
audio_pwm_mode=2
The first option tells the Pi that there is no digital audio device connected and forces it to use the analogue output, and "audio_pwm_mode=2" reduces some nasty hissing you can sometimes get (if you have very quiet sound output you may try try to remove this parameter from the config file).

And that's it, enjoy your new Raspberry Pi display!

Sunday, October 25, 2015

Back to the Future with RISC OS

RISC OS is an operating system for ARM based computers, originally developed by Acorn for their Archimedes home computers. Acorn is one of the most well known British computer manufacturers of the 80s, and the famous opponent of Sinclair. The rivalry between the two companies and their leaders has become the main motive of a fascinating BBC drama "Micro Men". A few years after the movie plot takes place, Acorn developed a 32-bit RISC processor, which they called ARM (Acorn RISC Machine). That CPU is a grandfather of the chip we all now have in our mobile devices, like smartphones, smartwatches, and tablets. Acorn also built a series of home computers based on that CPU, called Archimedes. While at the same time popular Amiga 500 and Atari ST home computers, featuring a 16/32-bit mixed Motorola 68000 CPU, could barely exceed one million instructions per second, Acorn Archimedes easily reached 4.5 million, having the same 8MHz clock. Although it was called "the fastest micro in the world", Archimedes' price was several times higher than the price of other microcomputers, so it hasn't gained much popularity and was mainly present in British schools and companies only. Acorn also developed a graphical, multitasking operating system for their computers, which they called RISC OS. When the home computer market has become dominated by Intel based PCs and MACs, RISC OS could only be used by a handful of lucky owners of RISC PCs and Iyonix. Nowadays, thanks to Raspberry Pi, RISC OS is back in the game. RPi is an affordable ARM based computer, and it's hardware specification is more than enough for RISC OS. You can either buy it preinstalled on an SD card or download for free and install yourself.

Why should you know all this? It's because I have seen many people downloading RISC OS and expecting to get a better and faster version of Raspbian, and then becoming frustrated because they didn't even know how to use the system. Remember, RISC OS is older than Linux, it's even older than 16-bit Windows for Workgroups. Because of this, it's not only extremely fast and requires very few resources, but it also has it's own philosophy, which is different from what you may know from other operating systems. For example, applications start minimized on the icon bar (a RISC OS equivalent of taskbar or dock), you open the context menu with the middle mouse button, and save a file by dragging it's icon to the destination folder. The same applies to system commands, for example "dir" changes active directory ("cd" in Linux), and "cat" displays it's contents ("dir" in MS-DOS or "ls" in Linux, "cat" in Linux outputs a file). RISC OS uses "." as a path separator ("\" in Windows, "/" in Linux) and "/" to separate extension from the file name ("." in Windows and Linux). Once you understand that, and are ready to learn, you can start exploring RISC OS. There are some introductory materials about RISC OS you can find on Youtube and on RISC OS dedicated sites, there are also two magazines dedicated to RISC OS users: Archive Magazine (paper) and Drag 'N Drop (PDF).

I have been using RISC OS on Rapberry Pi B+ for a couple of months now and I simply love it.

On one hand, it has all the qualities of a good operating system: it uses very little resources (the OS itself occupies about 10MB RAM), leaving as much memory and CPU time as possible to the user (on the contrary to most modern operating systems, which do exactly the opposite). It also does not stand in your way telling you what you can or cannot do with your computer. If you wish, you can talk directly to hardware from the built-in programming environment, which also serves as a command line. What is it? Basic, of course! And it's one of its best dialects: BBC Basic V with built-in assembler, so you can even control the CPU registers directly from the command line. When I had a C64 I wanted to have a language that is as simple as Basic and as quick as machine code - with RISC OS I can now have both. Moreover, if you need a real-time hardware control, RISC OS will also not complain. Because it uses a cooperative multitasking model, your application can simply not return CPU control back to the OS, effectively changing your computer into a single tasking machine. Of course, this way you can shoot yourself in the foot, but if this is what you want, RISC OS allows you to do it.

On the other hand, RISC OS can be used to do many daily tasks, like programming, writing texts, sending and receiving email, listening to the music (including MP3s and online radio stations) and browsing web sites. Even though Netsurf, a built-in web browser, does not support latest HTML and CSS features and has only rudimentary JavaScript support, it is quite enough if you want to read most of the online articles and news. Even GMail (basic HTML version) is fully functional with Netsurf. There are also absolutely no problems with tasks like networking or reading and writing FAT32 external USB drives in RISC OS.

In the world dominated by bloated and restricting operating systems RISC OS is like a breath of fresh air. Working with it is for me equally pleasant to working with Amiga OS. Unfortunately, latest Amiga OS can only run on hardware which is (like Pegasos) no longer produced, or (like AmigaONE X1000) ridiculously expensive - which is a real shame, because it's a great operating system, with support to most of the classic Amiga software. Fortunately, RISC OS supports not only Raspberry Pi, but also other affordable devices like BeagleBoard or PandaBoard, which makes it a great choice for hobbyists and power users, who want a fast and user friendly system with low hardware requirements. There is also a lot of software written for older versions of RISC OS, which can be run with little or no effort on Raspberry Pi, there are emulators for MS-DOS, Atari and ZX Spectrum, some Linux tools like bash or gnu compiler collection have been ported as well. And if you need a program that cannot be found in online repositories, just hit F12 (type in "Basic" in console) and write it yourself! Learn! Experiment! Computing is all about it after all, isn't it?

Monday, July 9, 2012

Streaming Internet radio from Raspberry Pi to Samsung TV

Not much related to programming, but I spent almost a week trying to make it work, so I decided to share my experience in hope someone may find it useful. You've probably heard already about Raspberry Pi - I think it's a great project and I admire thousands of people from all over the world who contribute to its development, but it's still in its experimental stage and has some quirks which sometimes make it very hard to use. One of them is using it as a DLNA server for streaming media straight from the Internet right to your home theater.

I have a Samsung TV with DLNA client on board, which works well with Serviio installed on my laptop, but I didn't feel like turning on a computer just to listen to my favourite online radio station, once I got my hands on Raspberry Pi. So I installed SqueezePlug on an SD card and started to play with it. Unfortunately, it turned out that none of the four pre-installed media servers could provide me with what I needed: MiniDLNA did not support transcoding of live streams (it needed some patches that were not applied), TVMobili was not recognized by my TV, Twonky said that its license expired before I even managed to configure it, and Logitech Media Server simply didn't work (it had some problems with the GUI - it called an AJAX script which always responded with an empty contents).

The only option I was left with was MediaTomb, which fortunately has a very good documentation and a lot of supportive users across different forums. The first thing I learned was that Samsung needs some special headers to be sent by MediaTomb, otherwise it always responds with "file format not recognized" message. Very informative from Samsung I must say - it took me a lot of time just to discover that it was the response header from DLNA server that was not recognized, not the data itself. Next step was to read the radio stream from the Internet and pass it to the TV. I spent next few evenings analyzing why I can stream media from a laptop and I can't from Raspberry Pi using ffmpeg for transcoding, despite using exactly the same version of MediaTomb and the same configuration file. As it turned out, my TV has issues with streams encoded by ffmpeg on ARM CPU (they differ substantially from those produced by ffmpeg on Intel), and it seems that ffmpeg compilation for ARM is simply broken. If you try ffmpeg on different distributions of Debian for Raspberry Pi you will learn that it either crashes with core dump or "illegal instruction" message or produces mpeg audio streams full of bad bytes, which can be corrected by PC players like vlc or foobar, but apparently not by a TV built-in software. So I tried other transcoders, like mencoder (provided by mplayer), until I realized that I need no transcoding at all - it's enough just to pass the original http stream to the output file just as it is, and wget is actually everything that I needed.

Still, one problem remained. After a few seconds of playing the connection between the TV and MediaTomb was breaking up. It was driving me nuts and it took another few hours to discover that MediaTomb sends "Connection: close" header to the client, while the online radio streams use "Connection: keep-alive", which prevents client from disconnecting when there is no data in the stream for a while. I found out that the solution is to use apropriate buffer size for the radio stream - it should be fairly small so that it never stops serving data even for a while and thus prevents the TV from disconnecting, but not too small because it will make the ARM to choke.

So, if you have a Samsung TV and want to listen to Internet radio stations served by a Raspberry Pi, here is my recommended configuration:

1. Install Debian Squeeze following the instructions on Raspberry Pi download page. Then log in to it and install MediaTomb server:
sudo apt-get update
sudo apt-get install mediatomb
2. Modifiy the /etc/mediatomb/config.xml file: Enable web user interface by modifying <ui> entry in the <server> section:
<ui enabled="yes" show-tooltips="yes">
  <accounts enabled="yes" session-timeout="300">
    <account user="mediatomb" password="mediatomb"/>
  </accounts>
</ui>
Add the following entry to the <server> section (as described here):
<custom-http-headers>
   <add header="transferMode.dlna.org: Streaming"/>
   <add header="contentFeatures.dlna.org: 
DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=017000 
00000000000000000000000000"/>
</custom-http-headers>
Change:
<transcoding enabled="no">
to:
<transcoding enabled="yes">
Just below it, in <mimetype-profile-mappings> section add the following entry:
<transcode mimetype="audio/x-shoutcast" using="streaming"/>
Also, add the following section to <profiles>:
<profile name="streaming" enabled="yes" type="external">
  <mimetype>audio/mpeg</mimetype>
  <accept-url>yes</accept-url>
  <first-resource>yes</first-resource>
  <use-chunked-encoding>no</use-chunked-encoding>
  <agent command="wget" arguments="%in -O %out"/>
  <buffer size="8192" chunk-size="1024" fill-size="2048"/>
</profile>
3. Restart MediaTomb server:
sudo service mediatomb restart
Now log in to MediaTomb interface using a web browser (it will be listening at port 49152, so assuming that your Raspberry Pi has IP address 192.168.1.10 you should go to http://192.168.1.10:49152/) with user and password defined in beforementioned <accounts> section (in my example it's mediatomb/mediatomb) and add a new stream:
Type: External Link (URL)
Title: Your radio station title
URL: Radio URL (for example http://nl2.ah.fm:9000)
Protocol: http-get
Class: object.item.audioItem
Mimetype: audio/x-shoutcast
Choose DLNA (MediaTomb) as input source on your TV and enjoy listening to your favourite radio.