How to build RISC-V GCC/newlib-nano toolchain

This short article will show you how to quickly setup cross-toolchain for C/C++ RV32IMAC binaries that runs on x86_64 host Linux PC.

git clone
cd riscv-gnu-toolchain/
git submodule update --init --recursive
mkdir build; cd build/
../configure --prefix=/opt/riscv32 --with-arch=rv32imac --with-abi=ilp32
make -j$(nproc)

Please note that /opt/riscv32 directory should be writable by the user running make. This command is the last step here, it will also install compilation results in –prefix directory. You might want to add bin directory to your PATH:

export PATH=/opt/riscv32/bin:$PATH

As a result we will get tools with riscv32-unknown-elf triplet.


GCC arch/ABI reference:

Sometimes it is handy to look at others’ compilation outputs:

07. December 2020 by resset
Categories: Software | Tags: , , , , | Leave a comment

What can I do with all these things?

Something new

Something new

15. January 2017 by resset
Categories: Electronics, Hardware, Software | Tags: , , | Leave a comment

Buildroot and QEMU – the quickest recipe for your own Linux

I will show the quickest way of running your own-built Linux system in QEMU emulator. Did I say quickest? Let’s start then:

$ git clone git://
$ cd buildroot/
$ make qemu_arm_versatile_defconfig

Where qemu_arm_versatile_defconfig is file & defconfig name from buildroot/configs directory. Next:

$ make menuconfig

And menu similar to Linux kernel menuconfig shows up. Since we preconfigured it with the defconfig file, there is almost nothing to change here. Be sure to have all tools from Build options —> Commands menu installed in your host system.

In Build options check Enable compiler cache which will save compiler output files and make consequent compilations faster. It is not necessary though.

Now type this and get some coffee:

$ make

We have now the time to chat a bit. So, what we have just done is we run a massive process of downloading core packages and compiling them into toolchain, kernel and root filesystem that will became our own, small Linux OS. Ever heard that making Linux for embedded devices is hard? Well, it is. But we have taken three huge shortcuts.

First, by using Buildroot which is a big set of Makefiles that configures and compiles GCC, C library and whole OS ecosystem (BusyBox). What it produces in the end are the Linux kernel and the image of root filesystem.

Second shortcut is configuring Buildroot with qemu_arm_versatile_defconfig. There is nothing to change within the kernel thanks to this. This configuration file along with buildroot/board/qemu/arm-versatile/linux-4.9.config tells Buildroot to set kernel configuration to suit ARM Versatile boards template. This is one of the development platforms supported both by Linux and QEMU out of the box.

The last one is the use of QEMU. Because of that, we do not have to configure any bootloader (like U-Boot for instance). All we need to do is to run one command right after the compilation ends:

$ qemu-system-arm -M versatilepb -kernel output/images/zImage -dtb output/images/versatile-pb.dtb -drive file=output/images/rootfs.ext2,if=scsi -append "root=/dev/sda console=ttyAMA0,115200" -nographic

This was inspired by buildroot/board/qemu/arm-versatile/readme.txt.

And there it is!

pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument
vpb_sic_write: Bad register offset 0x2c
Booting Linux on physical CPU 0x0
Linux version 4.9.6 (pillot@pillot) (gcc version 5.4.0 (Buildroot 2017.05-rc2-00013-g4d1c2c82e) ) #1 Sat May 20 00:42:18 CEST 2017
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
OF: fdt:Machine model: ARM Versatile PB
Memory policy: Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
Kernel command line: root=/dev/sda console=ttyAMA0,115200
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 125088K/131072K available (3390K kernel code, 131K rwdata, 756K rodata, 132K init, 207K bss, 5984K reserved, 0K cma-reserved)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xc8800000 - 0xff800000   ( 880 MB)
    lowmem  : 0xc0000000 - 0xc8000000   ( 128 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc0357e80   (3392 kB)
      .init : 0xc042f000 - 0xc0450000   ( 132 kB)
      .data : 0xc0450000 - 0xc0470de0   ( 132 kB)
       .bss : 0xc0470de0 - 0xc04a49f8   ( 208 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:16 nr_irqs:16 16
VIC @c8800000: id 0x00041190, vendor 0x41
FPGA IRQ chip 0 "intc" @ c8802000, 20 irqs, parent IRQ: 47
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
Failed to initialize '/amba/timer@101e3000': -22
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
Console: colour dummy device 80x30
Calibrating delay loop... 464.48 BogoMIPS (lpj=2322432)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x8400 - 0x8458
devtmpfs: initialized
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
OF: amba_device_add() failed (-19) for /amba/smc@10100000
OF: amba_device_add() failed (-19) for /amba/mpmc@10110000
OF: amba_device_add() failed (-19) for /amba/sctl@101e0000
OF: amba_device_add() failed (-19) for /amba/watchdog@101e1000
OF: amba_device_add() failed (-19) for /amba/sci@101f0000
OF: amba_device_add() failed (-19) for /amba/ssp@101f4000
OF: amba_device_add() failed (-19) for /amba/fpga/sci@a000
Serial: AMBA PL011 UART driver
101f1000.uart: ttyAMA0 at MMIO 0x101f1000 (irq = 28, base_baud = 0) is a PL011 rev1
console [ttyAMA0] enabled
101f2000.uart: ttyAMA1 at MMIO 0x101f2000 (irq = 29, base_baud = 0) is a PL011 rev1
101f3000.uart: ttyAMA2 at MMIO 0x101f3000 (irq = 30, base_baud = 0) is a PL011 rev1
uart-pl011 10009000.uart: aliased and non-aliased serial devices found in device tree. Serial port enumeration may be unpredictable.
10009000.uart: ttyAMA3 at MMIO 0x10009000 (irq = 54, base_baud = 0) is a PL011 rev1
vgaarb: loaded
SCSI subsystem initialized
clocksource: Switched to clocksource arm,sp804
NET: Registered protocol family 2
TCP established hash table entries: 1024 (order: 0, 4096 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
futex hash table entries: 256 (order: -1, 3072 bytes)
workingset: timestamp_bits=30 max_order=15 bucket_order=0
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
OF: PCI: host bridge /amba/pci-controller@10001000 ranges:
OF: PCI:    IO 0x43000000..0x4300ffff -> 0x00000000
OF: PCI:   MEM 0x50000000..0x5fffffff -> 0x50000000
OF: PCI:   MEM 0x60000000..0x6fffffff -> 0x60000000
versatile-pci 10001000.pci-controller: PCI core found (slot 11)
versatile-pci 10001000.pci-controller: PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [bus 00-ff]
pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
pci_bus 0000:00: root bus resource [mem 0x50000000-0x5fffffff]
pci_bus 0000:00: root bus resource [mem 0x60000000-0x6fffffff pref]
PCI: bus0: Fast back to back transfers disabled
pci 0000:00:0c.0: BAR 2: assigned [mem 0x50000000-0x50001fff]
pci 0000:00:0c.0: BAR 1: assigned [mem 0x50002000-0x500023ff]
pci 0000:00:0c.0: BAR 0: assigned [io  0x1000-0x10ff]
clcd-pl11x dev:20: PL110 designer 41 rev0 at 0x10120000
clcd-pl11x dev:20: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80x30
sym53c8xx 0000:00:0c.0: enabling device (0100 -> 0103)
sym0: <895a> rev 0x0 at pci 0000:00:0c.0 irq 66
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym0: SCSI BUS has been reset.
scsi host0: sym-2.2.3
random: fast init done
scsi 0:0:0:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
scsi target0:0:0: tagged command queuing enabled, command queue depth 16.
scsi target0:0:0: Beginning Domain Validation
scsi target0:0:0: Domain Validation skipping write tests
scsi target0:0:0: Ending Domain Validation
scsi 0:0:2:0: CD-ROM            QEMU     QEMU CD-ROM      2.5+ PQ: 0 ANSI: 5
scsi target0:0:2: tagged command queuing enabled, command queue depth 16.
scsi target0:0:2: Beginning Domain Validation
scsi target0:0:2: Domain Validation skipping write tests
scsi target0:0:2: Ending Domain Validation
libphy: Fixed MDIO Bus: probed
sd 0:0:0:0: [sda] 122880 512-byte logical blocks: (62.9 MB/60.0 MiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
mousedev: PS/2 mouse device common for all mice
versatile reboot driver registered
NET: Registered protocol family 10
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered protocol family 17
sd 0:0:0:0: [sda] Attached SCSI disk
input: AT Raw Set 2 keyboard as /devices/platform/amba/amba:fpga/10006000.kmi/serio0/input/input0
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/amba/amba:fpga/10007000.kmi/serio1/input/input2
EXT4-fs (sda): couldn't mount as ext3 due to feature incompatibilities
EXT4-fs (sda): mounting ext2 file system using the ext4 subsystem
EXT4-fs (sda): mounted filesystem without journal. Opts: (null)
VFS: Mounted root (ext2 filesystem) readonly on device 8:0.
devtmpfs: mounted
Freeing unused kernel memory: 132K (c042f000 - c0450000)
This architecture does not have kernel memory protection.
EXT4-fs (sda): warning: mounting unchecked fs, running e2fsck is recommended
EXT4-fs (sda): re-mounted. Opts: block_validity,barrier,user_xattr,errors=remount-ro
Starting logging: OK
Initializing random number generator... done.
Starting network: Waiting for interface eth0 to appear............... timeout!
run-parts: /etc/network/if-pre-up.d/wait_iface: exit status 1

Welcome to Buildroot
buildroot login: root
# cat /proc/cpuinfo 
processor       : 0
model name      : ARM926EJ-S rev 5 (v5l)
BogoMIPS        : 464.48
Features        : swp half thumb fastmult edsp java 
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant     : 0x0
CPU part        : 0x926
CPU revision    : 5

Hardware        : ARM-Versatile (Device Tree Support)
Revision        : 0000
Serial          : 0000000000000000

As in every shortcut there is not much to understand here. Please go further:

13. September 2013 by resset
Categories: Software | Tags: , , , , , , , , , | 6 comments

How to install binwalk on Slackware (updated)

Update-even-more: Binwalk has just moved to GitHub.

Update: Second half of this tutorial refers to the binwalk version 1.2.1 only. It appears that with 1.2.2 release, problem with has been resolved. Diff here.

Firstly, a few dependencies.

There is a package “file” in Slackware but it doesn’t have it’s Python bindings installed. You need to download appropriate source file from here: Choose version that you have in your system. In my case it is 5.14.

# tar xzf file-5.14.tar.gz
# cd file-5.14/python
# python install

At this point you should run something like this without getting an exception:

# python
Python 2.7.5 (default, May 29 2013, 02:28:51)
[GCC 4.8.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic

Next, you may want to get matplotlib working. This is not required to and if you don’t want it you can fall back to regular binwalk install procedure (docs/README in binwalk sources) and quit reading this text. From now on, I assume you want to have fancy plotting option in your binwalk.

There is a bunch of packages to install. My preferred way to do this is by getting them from SlackBuilds. You can also use sbopkg tool, to speed up whole process. Install following packages in order: pysetuptools, six, python_dateutil, pytz, numpy and matplotlib.

Before we proceed there is a test to perform. Switch to non-root user and type:

$ python
Python 2.7.5 (default, May 29 2013, 02:28:51)
[GCC 4.8.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot

If you don’t get anything more serious than some fontconfig warnings, It’s OK to proceed.

Get binwalk: In my case current version is 1.2.1. Then, type:

# tar xzf binwalk-1.2.1.tar.gz
# cd binwalk-1.2.1/src

Now it’s tricky part. You want to have your binwalk installed globally since this is how setup script works, but installer (matplotlib.pyplot, actually) needs X server and you don’t have it in root’s python session. Because you verified that matplotlib.pyplot works on non-root user, where one usually runs software from, you can make little ugly hack to binwalk’s file. Let’s change the way how installer checks if matplotlib is present. This is a diff of original and modified file in patch format:

@@ -26,6 +26,8 @@

+       import matplotlib
+       matplotlib.use('Agg')
        import matplotlib.pyplot
 except Exception, e:
        print "\n", "*" * WIDTH

By changing method of plotting (to textual) you bypass the need for X server and installation runs smoothly. And app should work great too.

This is it, enjoy your binwalk:)

You may get a warning each time you run binwalk:

Warning: New continuation level 2 is more than one larger than current level 0

If so, update signatures (as root):

# binwalk -u

P.S. 2
Be sure to check for recommendations for other handy tools.

P.S. 3 (new)
Version 1.2.2 installs flawlessly.

05. August 2013 by resset
Categories: Software | Tags: , , | Leave a comment


Recently I made a small demo:

This is application running in ChibiOS/RT RTOS with addition of µGFX framework. It mimics screen unlocker known from Andriod smartphones. It was tested on Embest DM-STF4BB board with DM-LCD35RT LCD display, but should run on any other supported by µGFX. It works properly in ChibiOS/RT simulator also. For details how to run it there, please visit simulator introduction (link is dead, I’ll update this once it appears somewhere).

It allows to configure number of columns and rows you want to have, colors of the “rings” and few other options. The distance between rings is calculated automatically based on screen size and number of columns and rows. There are two functions to handle unlocker. displayUnlockerSetup() is used to draw and save unlock sequence. displayUnlocker() simply displays unlocker and exits if user drew proper pattern, either set by setup function or hardcoded. There is no persistence mechanism to store patterns.

The code is available at GitHub:

13. July 2013 by resset
Categories: Electronics, Hardware, Software | Tags: , , , , , | Leave a comment

Kate debugs in hardware

Or how to debug embedded devices with Kate editor, GCC toolchain, OpenOCD and JTAG. Or, how to replace Eclipse in embedded developer’s work.

I do most of my work with open source software, including this running on PC desktop. Few years ago my environment of choice became KDE (KDE SC nowadays). One of areas in which this choice (not ideal) shows its superiority over other desktops is multitude of accompanying applications. And the most useful for me are text editors. This backyard is dominated by indissoluble duo: KWrite and Kate. As it appears, these tools (more precisely, Kate – as it is “bigger brother”) can be used to do much more than editing.

So if you sit with KDE and some embedded stuff in front of your eyes why not give Kate a try? Curiously enough, it took me a while to hit on this idea;)

I assume that you:

  • have working GCC toolchain,
  • know how to use GDB (most preferably),
  • have proper Makefile(s), sources, linker scripts, vectors tables etc.,
  • know how to configure and use OpenOCD,
  • have hardware to play with (hardware debugger and target).

Kate setup

Start with regular Kate setup. Make new session, choose directory for it and import some source files – let us have something to play with. After that enable two plugins that Kate comes with: “Build Plugin” and “GDB”.

Kate Plugin Manager

Kate Plugin Manager

First one can execute “make” inside project directory, second gives actual ability to debug. Both of them extend interface of Kate a bit. This is how my editor looks now:

Kate main window

Kate main window

At top toolbar area appeared a bunch of unsurprisingly familiar buttons. I had to manually add first one (“Start debugging”). At the bottom there are two new activators: “Debug View” and “Build Output”. Open the first one and go to “Settings” tab, then click “Advanced Settings”.

GDB advanced settings dialog

GDB advanced settings dialog

This is where your desired setup may start to diverge from mine, but general guidelines should be the same for any case. In “GDB command” field put GDB executable name. Full path here is preferred, I didn’t manage to make it work relying on PATH. From select choose “Remote TCP”, set “localhost” as a host and “3333” as a port that GDB will connect to. OpenOCD usually binds there. In “Custom Startup Commands” type all instructions that GDB have to execute before start debugging. This is important step, as Kate doesn’t know anything about debug server and your target. Every initialization step you have to undertake should go here or to OpenOCD scripts. Most common are loading binary to flash, remapping memory, setting clocks. To program flash you can use either GDB commands (if they work) or pass OpenOCD instructions as argument of “monitor” (or shortly: “mon”) command – as I do. Note last line of my input: I make GDB automatically break on “main” function.

GDB plugin settings

GDB plugin settings

Back to Settings tab, set path to executable file (usually in ELF format). If you set working directory, executable can be just a file name. The nice thing about Kate GDB plugin is that apart from controlling GDB it gives you its command prompt (GDB output tab). To keep focus on GDB console, select “Keep focus”. If your setup handles IO redirection properly, you should be able to control it in tab “IO”, which appears after checking “Redirect IO”. Mine doesn’t, so I did not test it. I saved this setup under “openocd” name; use whichever you like. Configurations are easily selectable in “Debug > Targets” top menu.

Build settings tab

Build settings tab

Next, configure build add-on settings. Hit “Build Output” activator at the bottom and select “Target Settings” tab. Fill in working directory, and next three inputs. I chose “Build” command to run both clean and make so the “Quick compile” executes only make and “Build” rebuilds entire project. Again, you can save this configuration under arbitrary name and load it later in “Build > Targets”. Build plugin doesn’t have its own toolbar so commands will be available in “Build” top menu.

Let’s run it!

Having this done we can move into action. Build your project using menu “Build > Build”. Then go to “Terminal” activator and type OpenOCD startup command. This activator shows up after enabling “Terminal tool view” plugin.

For my target I execute:

openocd -f board/stm32f4discovery.cfg


Kate terminal window

Kate terminal window

Click “Start Debugging” button. GDB Output tab should appear:

GDB console

GDB console

This is just a GDB console. Debugger stopped at “main” function as we told it to do. You can type “c” (continue) directly in highlighted input box, or hit “Continue” button from toolbar. Before doing that set cursor in editor to certain place in main() and make there breakpoint with “Toggle breakpoint” button.

Breakpoint inserted

Breakpoint inserted

Breakpoint line gets light red background. Inserting breakpoints is possible only when program is not being run.

Local variables view

Local variables view

Toggling activator to the right of main window, we get local variables preview.

To sum up

There are few more options that both described plugins provide, but most of “the meat” ends here. This is no equivalent to Eclipse-based toolchain setup (not to mention others), but makes nice distinction (faster! not Java! …and not Java!). And also gives very good quality of text editing, something what KatePart is known of. There is even vi-like mode:) Should you happen to consider improving current state of GDB plugin, maybe to push it more towards embeded world or to contribute to Kate itself – do not hesitate, it’s authors will welcome your efforts warm. So do I!

23. February 2013 by resset
Categories: Electronics, Software | Tags: , , , , , , , , , , | Leave a comment

Canny edge detector

I uploaded one of my student projects to GitHub: Canny algrithm implementation. This is popular method of finding edges in the image invented in 80’s: What you will find here is extremely naive approach, possibly with bugs and certainly not written with memory consumption issues in mind. But that’s just student project, it served well for its purpose:) Make sure to see README:

Below there is an exmple of each step of algorithm being performed:

Original image

Original image

Luminance extracted

Luminance extracted

Gaussian blur

Gaussian blur

Edge magnitude map

Edge magnitude map

Gradient direction map

Gradient direction map

Pixel suppresion result

Pixel suppresion result

After hysteresis thresholding - final image

After hysteresis thresholding – final image

24. December 2012 by resset
Categories: Software | Tags: , , , , | Leave a comment

Benefit of Cortex-M4F

Embedded systems gurus always repeated: don’t use floating-point numbers in your firmware! But what if you have processor with a FPU? Well, then you simply can. Do not forget, however, to carefully look at your disassembly file, as always.

So this is what we get with GCC 4.6.2 on Cortex-M3:

float a = 0.123123f;
 8000350:	4b21      	ldr	r3, [pc, #132]	; (80003d8 )
 8000352:	617b      	str	r3, [r7, #20]
	float b = 0.123123f;
 8000354:	4b20      	ldr	r3, [pc, #128]	; (80003d8 )
 8000356:	613b      	str	r3, [r7, #16]
	float c = 0.0f;
 8000358:	4b20      	ldr	r3, [pc, #128]	; (80003dc )
 800035a:	60fb      	str	r3, [r7, #12]
	c = a * b;
 800035c:	6978      	ldr	r0, [r7, #20]
 800035e:	6939      	ldr	r1, [r7, #16]
 8000360:	f000 f8d6 	bl	8000510 <__aeabi_fmul>
 8000364:	4603      	mov	r3, r0
 8000366:	60fb      	str	r3, [r7, #12]
	b = c;
 8000368:	68fb      	ldr	r3, [r7, #12]
 800036a:	613b      	str	r3, [r7, #16]


08000510 <__aeabi_fmul>:
 8000510:	f04f 0cff 	mov.w	ip, #255	; 0xff
 8000514:	ea1c 52d0 	ands.w	r2, ip, r0, lsr #23
 8000518:	bf1e      	ittt	ne
 800051a:	ea1c 53d1 	andsne.w	r3, ip, r1, lsr #23
 800051e:	ea92 0f0c 	teqne	r2, ip
 8000522:	ea93 0f0c 	teqne	r3, ip
 8000526:	d06f      	beq.n	8000608 <__aeabi_fmul+0xf8>
 8000528:	441a      	add	r2, r3
 800052a:	ea80 0c01 	eor.w	ip, r0, r1
 800052e:	0240      	lsls	r0, r0, #9
 8000530:	bf18      	it	ne
 8000532:	ea5f 2141 	movsne.w	r1, r1, lsl #9
 8000536:	d01e      	beq.n	8000576 <__aeabi_fmul+0x66>
 8000538:	f04f 6300 	mov.w	r3, #134217728	; 0x8000000
 800053c:	ea43 1050 	orr.w	r0, r3, r0, lsr #5
 8000540:	ea43 1151 	orr.w	r1, r3, r1, lsr #5
 8000544:	fba0 3101 	umull	r3, r1, r0, r1
 8000548:	f00c 4000 	and.w	r0, ip, #2147483648	; 0x80000000
 800054c:	f5b1 0f00 	cmp.w	r1, #8388608	; 0x800000
 8000550:	bf3e      	ittt	cc
 8000552:	0049      	lslcc	r1, r1, #1
 8000554:	ea41 71d3 	orrcc.w	r1, r1, r3, lsr #31
 8000558:	005b      	lslcc	r3, r3, #1
 800055a:	ea40 0001 	orr.w	r0, r0, r1
 800055e:	f162 027f 	sbc.w	r2, r2, #127	; 0x7f
 8000562:	2afd      	cmp	r2, #253	; 0xfd
 8000564:	d81d      	bhi.n	80005a2 <__aeabi_fmul+0x92>
 8000566:	f1b3 4f00 	cmp.w	r3, #2147483648	; 0x80000000
 800056a:	eb40 50c2 	adc.w	r0, r0, r2, lsl #23
 800056e:	bf08      	it	eq
 8000570:	f020 0001 	biceq.w	r0, r0, #1
 8000574:	4770      	bx	lr
 8000576:	f090 0f00 	teq	r0, #0
 800057a:	f00c 4c00 	and.w	ip, ip, #2147483648	; 0x80000000
 800057e:	bf08      	it	eq
 8000580:	0249      	lsleq	r1, r1, #9
 8000582:	ea4c 2050 	orr.w	r0, ip, r0, lsr #9
 8000586:	ea40 2051 	orr.w	r0, r0, r1, lsr #9
 800058a:	3a7f      	subs	r2, #127	; 0x7f
 800058c:	bfc2      	ittt	gt
 800058e:	f1d2 03ff 	rsbsgt	r3, r2, #255	; 0xff
 8000592:	ea40 50c2 	orrgt.w	r0, r0, r2, lsl #23
 8000596:	4770      	bxgt	lr
 8000598:	f440 0000 	orr.w	r0, r0, #8388608	; 0x800000
 800059c:	f04f 0300 	mov.w	r3, #0
 80005a0:	3a01      	subs	r2, #1
 80005a2:	dc5d      	bgt.n	8000660 <__aeabi_fmul+0x150>
 80005a4:	f112 0f19 	cmn.w	r2, #25
 80005a8:	bfdc      	itt	le
 80005aa:	f000 4000 	andle.w	r0, r0, #2147483648	; 0x80000000
 80005ae:	4770      	bxle	lr
 80005b0:	f1c2 0200 	rsb	r2, r2, #0
 80005b4:	0041      	lsls	r1, r0, #1
 80005b6:	fa21 f102 	lsr.w	r1, r1, r2
 80005ba:	f1c2 0220 	rsb	r2, r2, #32
 80005be:	fa00 fc02 	lsl.w	ip, r0, r2
 80005c2:	ea5f 0031 	movs.w	r0, r1, rrx
 80005c6:	f140 0000 	adc.w	r0, r0, #0
 80005ca:	ea53 034c 	orrs.w	r3, r3, ip, lsl #1
 80005ce:	bf08      	it	eq
 80005d0:	ea20 70dc 	biceq.w	r0, r0, ip, lsr #31
 80005d4:	4770      	bx	lr
 80005d6:	f092 0f00 	teq	r2, #0
 80005da:	f000 4c00 	and.w	ip, r0, #2147483648	; 0x80000000
 80005de:	bf02      	ittt	eq
 80005e0:	0040      	lsleq	r0, r0, #1
 80005e2:	f410 0f00 	tsteq.w	r0, #8388608	; 0x800000
 80005e6:	3a01      	subeq	r2, #1
 80005e8:	d0f9      	beq.n	80005de <__aeabi_fmul+0xce>
 80005ea:	ea40 000c 	orr.w	r0, r0, ip
 80005ee:	f093 0f00 	teq	r3, #0
 80005f2:	f001 4c00 	and.w	ip, r1, #2147483648	; 0x80000000
 80005f6:	bf02      	ittt	eq
 80005f8:	0049      	lsleq	r1, r1, #1
 80005fa:	f411 0f00 	tsteq.w	r1, #8388608	; 0x800000
 80005fe:	3b01      	subeq	r3, #1
 8000600:	d0f9      	beq.n	80005f6 <__aeabi_fmul+0xe6>
 8000602:	ea41 010c 	orr.w	r1, r1, ip
 8000606:	e78f      	b.n	8000528 <__aeabi_fmul+0x18>
 8000608:	ea0c 53d1 	and.w	r3, ip, r1, lsr #23
 800060c:	ea92 0f0c 	teq	r2, ip
 8000610:	bf18      	it	ne
 8000612:	ea93 0f0c 	teqne	r3, ip
 8000616:	d00a      	beq.n	800062e <__aeabi_fmul+0x11e>
 8000618:	f030 4c00 	bics.w	ip, r0, #2147483648	; 0x80000000
 800061c:	bf18      	it	ne
 800061e:	f031 4c00 	bicsne.w	ip, r1, #2147483648	; 0x80000000
 8000622:	d1d8      	bne.n	80005d6 <__aeabi_fmul+0xc6>
 8000624:	ea80 0001 	eor.w	r0, r0, r1
 8000628:	f000 4000 	and.w	r0, r0, #2147483648	; 0x80000000
 800062c:	4770      	bx	lr
 800062e:	f090 0f00 	teq	r0, #0
 8000632:	bf17      	itett	ne
 8000634:	f090 4f00 	teqne	r0, #2147483648	; 0x80000000
 8000638:	4608      	moveq	r0, r1
 800063a:	f091 0f00 	teqne	r1, #0
 800063e:	f091 4f00 	teqne	r1, #2147483648	; 0x80000000
 8000642:	d014      	beq.n	800066e <__aeabi_fmul+0x15e>
 8000644:	ea92 0f0c 	teq	r2, ip
 8000648:	d101      	bne.n	800064e <__aeabi_fmul+0x13e>
 800064a:	0242      	lsls	r2, r0, #9
 800064c:	d10f      	bne.n	800066e <__aeabi_fmul+0x15e>
 800064e:	ea93 0f0c 	teq	r3, ip
 8000652:	d103      	bne.n	800065c <__aeabi_fmul+0x14c>
 8000654:	024b      	lsls	r3, r1, #9
 8000656:	bf18      	it	ne
 8000658:	4608      	movne	r0, r1
 800065a:	d108      	bne.n	800066e <__aeabi_fmul+0x15e>
 800065c:	ea80 0001 	eor.w	r0, r0, r1
 8000660:	f000 4000 	and.w	r0, r0, #2147483648	; 0x80000000
 8000664:	f040 40fe 	orr.w	r0, r0, #2130706432	; 0x7f000000
 8000668:	f440 0000 	orr.w	r0, r0, #8388608	; 0x800000
 800066c:	4770      	bx	lr
 800066e:	f040 40fe 	orr.w	r0, r0, #2130706432	; 0x7f000000
 8000672:	f440 0040 	orr.w	r0, r0, #12582912	; 0xc00000
 8000676:	4770      	bx	lr

And this is output from the same GCC version on Cortex-M4F (compiled with flags -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffast-math -fsingle-precision-constant):

float a = 0.123123f;
 8000410:	4b3c      	ldr	r3, [pc, #240]	; (8000504 )
 8000412:	617b      	str	r3, [r7, #20]
	float b = 0.123123f;
 8000414:	4b3b      	ldr	r3, [pc, #236]	; (8000504 )
 8000416:	613b      	str	r3, [r7, #16]
	float c = 0.0f;
 8000418:	4b3b      	ldr	r3, [pc, #236]	; (8000508 )
 800041a:	60fb      	str	r3, [r7, #12]
	c = a * b;
 800041c:	ed97 7a05 	vldr	s14, [r7, #20]
 8000420:	edd7 7a04 	vldr	s15, [r7, #16]
 8000424:	ee67 7a27 	vmul.f32	s15, s14, s15
 8000428:	edc7 7a03 	vstr	s15, [r7, #12]
	b = c;
 800042c:	68fb      	ldr	r3, [r7, #12]
 800042e:	613b      	str	r3, [r7, #16]

This is the difference, isn’t it?

08. July 2012 by resset
Categories: Electronics, Software | Tags: , , , | Leave a comment

VMware Workstation 8.0.2 on Linux 3.2.x

There is a great aricle (and blog) on solving problems with running VMware on Linux hosts: What is not said there is that sometimes you are unable even to install Workstation itself. The cause is that installer tries to build modules and it fails to do this, so the installation is reverted and you end up with nothing. The cure, which solved the case for me were following parameters:

# ./VMware-Workstation-Full-8.0.2-591240.x86_64.bundle --console --required --ignore-errors

Thanks to the –ignore-errors, after seeing few ugly Python tracebacks we finally get Installation was successful message. Now just run the patch:

# ./

…and VMware is all yours:)

16. April 2012 by resset
Categories: Software | Tags: , , | Leave a comment

Setting up a locale in PostgreSQL on Linux

After installation of fresh copy of PostgreSQL database server it is often required to configure proper localization settings. This helps to avoid messages like this:

ERROR: invalid locale name en_GB.utf8

where en_GB.utf8 is setting you want to have. In order to create a database with custom locale there are few steps one has to follow.

The first is to enable all locales you might want to use in PostgreSQL in your system config. On Debian, edit file /etc/locale.gen and uncomment lines with your locales names. In my case it looks like this:

# pl_PL ISO-8859-2
pl_PL.UTF-8 UTF-8
# ps_AF UTF-8

Then run command locale-gen which will generate system localization files.

# locale-gen
Generating locales (this might take a while)...
en_US.UTF-8... done
pl_PL.UTF-8... done
Generation complete.

I have two locales enabled: en_US.UTF-8 and pl_PL.UTF-8. Both of them should be available in PostgreSQL. To check that, switch user to postgres and run SQL console, psql:

# su - postgres
$ psql
psql (8.4.9)
Type "help" for help.


Create user (if you haven’t done this yet):

postgres=# CREATE ROLE myuser WITH PASSWORD 'secret' LOGIN;

Then create database with some extra parameters:

postgres=# CREATE DATABASE mydb WITH OWNER myuser ENCODING 'UTF8' LC_COLLATE 'pl_PL.utf8' LC_CTYPE 'pl_PL.utf8' TEMPLATE template0;

Most of this is self-explanatory. Purposes of all parameters are explained in the documentation: CREATE DATABASE. Note, that there is template0 database used as a template. More on this you will find in the manual: Template Databases.

Note: above example was successfully tested also on PostgreSQL 9.1.2.

08. January 2012 by resset
Categories: Software | Tags: , , , | Leave a comment

← Older posts