[Solved] Manjaro with dmcrypt does not boot after upgrade

If you are using an encrypted root partition (LUKS encryption) on Manjaro, your system could be broken after pamac upgrade. After rebooting the system I wasn’t able to provide the password. Esc key showed some more details:

Check that kernel supports aes-xts-plain64 cipher (check syslog for more info)

According to this post, users can either update dmcrypt or upgrade Linux kernel. In my case upgrading the kernel to 4.4 has worked:

  1. Boot Manjaro Live CD (or Arch live CD). It is possible to create a live stick, using e.g. LiLi for Windows or Unetbootin (cross-platform).
  2. Make sure you have an Internet connection. Open a terminal and sudo:
    sudo su
  3. Determine your disk device. In my case it was /dev/sda. You can start typing /dev/sd and hit a Tab key. Once you have a disk device, check which partition is the encrypted one and which is used for booting the system. The easiest way is to open cfdisk, in my case:
    cfdisk /dev/sda

    The output may be as follows:
    cfdiskThe largest partition is /dev/sda2 – this is my main partition. I can also see a small boot partition – /dev/sda1.

  4. Open and mount the encrypted partition:
    cryptsetup open --type luks /dev/sda2 root
    mount -t ext4 /dev/mapper/root /mnt
  5. Go to /mnt. You can make a backup if you’ve never done it. The time is right. ;)
  6. Chroot to /mnt. In order to allow manjaro update grub and install a new kernel, it is required to mount some additional mounting points:
    cd /mnt
    mount -t proc proc proc/
    mount --rbind /run run/
    mount --rbind /dev dev/
    mount --rbind /sys sys/
    chroot /mnt /bin/bash
  7. Mount a boot partition as well – after chrooting:
    mount -t ext4 /dev/sda1 /boot
  8. Update kernel to 4.4
    mhwd-kernel -i linux44
  9. Keep your fingers crossed. Read all the messages.
  10. Upgrade everything:
    pacman -Syu
  11. Umount all partitions:
    umount /boot
    exit            (quit chroot)
    cd /            (somewhere outside mnt/)
    umount -l /mnt
    cryptsetup close root

    If unmounting fails, simply skip this step.

  12. Reboot system. Manjaro should awake.
    awake
Posted in Manjaro | Tagged , , , | 2 Comments

Leon Instruments tutorial – LCD’s alive

I’ve just finished a LCD part of Leon Instruments tutorial (Polish version). Here’s the proof :)

IMG_20160201_235545

I had no potentiometer so the LCD contrast has been fixed by 22k resistor.

My Makefile had to be modified as well:

.DEFAULT_GOAL := compile
 
# Change this variable to source file name
SRC=main
 
CC=avr-gcc
OBJCOPY=avr-objcopy
DFUPROG=dfu-programmer
 
#
# X3-DIL64 device (atxmega128a3u)
# For other devices, launch:
# 	avr-gcc --targets
#
DEVICE=atxmega128a3u
 
#
# Set F_CPU. Alternatively, put the following line into your code:
# 	#define F_CPU=2000000UL
#
CFLAGS=-g -Os -DF_CPU=2000000UL -mmcu=${DEVICE} -std=gnu99
 
main.hex: main.o hd44780.o main.elf
	${OBJCOPY} -j .text -j .data -O ihex ${SRC}.elf ${SRC}.hex
 
${SRC}.elf: main.o hd44780.o
	${CC} ${CFLAGS} -o main.elf main.o hd44780.o
 
main.o:
	${CC} ${CFLAGS} -c hd44780.c main.c
 
compile: ${SRC}.hex
 
clean:
	rm -f *.elf *.hex *.o
 
install: ${SRC}.hex
	${DFUPROG} ${DEVICE} erase
	${DFUPROG} ${DEVICE} flash ${SRC}.hex
	${DFUPROG} ${DEVICE} launch --no-reset

It needs to be refactored! It works, though.

Am I ready to build my own CNC router? ;)

Posted in electronics, programming | Tagged , , , | Leave a comment

X3-DIL64 (ATxmega128A3U) on Manjaro Linux – the first app

Abstract in Polish

Rodzimej produkcji moduł uruchomieniowy X3-DIL64 bazuje na mikrokontrelerze ATxmega128A3U. Poniżej staram się podsumować wyniki moich przebojów z kompilacją i uruchomieniem X3-DIL64 w Manjaro.

Introduction

X3-DIL64 prototyping module is based on ATxmega128A3U. The microcontroller has a FLIP boot loader which lets you program the micro-controller without using any additional devices, by a USB cable. This post shows how to configure, compile and launch your first application.

Required packages

In order to compile and launch your programs on ATxmega128A3U you have to install the following packages:

  • avr-binutils-atmel
  • avr-gcc-atmel
  • avr-libc-atmel
  • dfu-programmer

Compile your first atxmega application

  1. As an example, create test1.c file:
    #include <avr/io.h>
    #include <util/delay.h>
     
    int main(void) {
     
        PORTE.DIRCLR = PIN5_bm;         // E5 -> FLIP button
        PORTF.DIR = PIN3_bm;            // F3 -> external LED
     
        while(1) {
            PORTF.OUTTGL = PIN3_bm;
            if(PORTE.IN & PIN5_bm) {    // if E5 released (FLIP button)
                _delay_ms(100);
            } else {
                _delay_ms(50);
            }
        }
    }
  2. Create Makefile file, in the same directory:
    .DEFAULT_GOAL := compile
     
    # Change this variable to source file name
    SRC=test1
     
    CC=avr-gcc
    OBJCOPY=avr-objcopy
    DFUPROG=dfu-programmer
     
    #
    # X3-DIL64 device (atxmega128a3u)
    # For other devices, launch:
    # 	avr-gcc --targets
    #
    DEVICE=atxmega128a3u
     
    #
    # Set F_CPU. Alternatively, put the following line into your code:
    # 	#define F_CPU=2000000UL
    #
    CFLAGS=-g -Os -DF_CPU=2000000UL -mmcu=${DEVICE}
     
    ${SRC}.hex: ${SRC}.o ${SRC}.elf
    	${OBJCOPY} -j .text -j .data -O ihex ${SRC}.elf ${SRC}.hex
     
    ${SRC}.elf:
    	${CC} ${CFLAGS} -o ${SRC}.elf ${SRC}.o
     
    ${SRC}.o:
    	${CC} ${CFLAGS} -c ${SRC}.c
     
    compile: ${SRC}.hex
     
    clean:
    	rm -f ${SRC}.elf ${SRC}.hex ${SRC}.o
     
    install: ${SRC}.hex
    	${DFUPROG} ${DEVICE} erase
    	${DFUPROG} ${DEVICE} flash ${SRC}.hex
    	${DFUPROG} ${DEVICE} launch --no-reset
  3. Compile the application:
    [kan@pckan test1]$ make
    avr-gcc -g -Os -DF_CPU=2000000UL -mmcu=atxmega128a3u -c test1.c
    avr-gcc -g -Os -DF_CPU=2000000UL -mmcu=atxmega128a3u -o test1.elf test1.o
    avr-objcopy -j .text -j .data -O ihex test1.elf test1.hex
    [kan@pckan test1]$

    As a result, you should get a hex file ready to be uploaded on the device:

    [kan@pckan test1]$ ls -lh
    razem 28K
    -rw-r--r-- 1 kan users  772 01-30 02:42 Makefile
    -rw-r--r-- 1 kan users  383 01-30 13:45 test1.c
    -rwxr-xr-x 1 kan users 7,7K 01-30 13:54 test1.elf
    -rw-r--r-- 1 kan users 1,7K 01-30 13:54 test1.hex
    -rw-r--r-- 1 kan users 4,6K 01-30 13:54 test1.o
    [kan@pckan test1]$

Switch X3-DIL64 into USB DFU programming mode

  1. Open a terminal and type the following:
    watch -n1 lsusb

    The command lists USB devices every 1 second.

  2. Plug your X3-DIL64. You should see an orange LED lightning on the board.
  3. Switch the boards into USB programming mode:
    1. Press both RESET and FLIP buttons.
    2. Release RESET button.
    3. The new USB device should appear on the list.
    4. Release FLIP button.
  4. The new device should appear on the list. In my case the new entry is Atmel Corp. Cactus V6 (DFU).
    Bus 002 Device 005: ID 1d57:0005 Xenta Wireless Receiver (Keyboard and Mouse)
    Bus 002 Device 007: ID 413c:2003 Dell Computer Corp. Keyboard
    Bus 002 Device 004: ID 2001:f103 D-Link Corp. DUB-H7 7-port USB 2.0 hub
    Bus 002 Device 013: ID 03eb:2fe6 Atmel Corp. Cactus V6 (DFU)
    Bus 002 Device 009: ID 0781:7421 SanDisk Corp. Sansa E200 Series (msc)
    Bus 002 Device 008: ID 0451:8043 Texas Instruments, Inc. 
    Bus 002 Device 006: ID 0482:0011 Kyocera Corp. 
    Bus 002 Device 003: ID 0451:8043 Texas Instruments, Inc. 
    Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 003: ID 064e:a219 Suyin Corp. 1.3M WebCam (notebook emachines E730, Acer sub-brand)
    Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  5. Now you are ready to use FLIP bootloader! Just type: make install:
    [kan@pckan test1]$ make install
    dfu-programmer atxmega128a3u erase
    Checking memory from 0x0 to 0x1FFFF...  Not blank at 0x1.
    Erasing flash...  Success
    Checking memory from 0x0 to 0x1FFFF...  Empty.
    dfu-programmer atxmega128a3u flash test1.hex
    Checking memory from 0x0 to 0x3FF...  Empty.
    0%                            100%  Programming 0x400 bytes...
    [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]  Success
    0%                            100%  Reading 0x20000 bytes...
    [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]  Success
    Validating...  Success
    0x400 bytes written into 0x20000 bytes memory (0.78%).
    dfu-programmer atxmega128a3u launch --no-reset
    [kan@pckan test1]$

    The external LED connected to the board should start blinking.

When it’s not working – Q&A

Q: I get errors during compilation
A: Make sure you have installed avr-libc-atmel and avr-gcc-atmel.

Q: I cannot install avr-gcc-atmel:
A: If you have avr-gcc already installed, uninstall it and then install avr-gcc-atmel package.

Q: Why don’t you use avrdude instead of dfu-programmer?
A: I was not able to make it working for ATxmega128A3U. Beside this, dfu-programmer works fine.

Q: What about Atmel FLIP provided on Atmel official website?
A: At the moment, Atmel provides an old version of FLIP from 2007 which cannot handle ATxmega128A3U.

Q: Can I run Atmel Studio 6 on Linux? 
A: AFAIK, no. You cannot run AS6 using Wine. However, if you feel you need it, you can use VirtualBox to run Atmel Studio on Windows. It’s working.

Q: So which edi..
A: Vim! :)

Posted in electronics, programming | Tagged , , | Leave a comment

JHipster – REST controller for authenticated users only

While working on JHipster-based application (Spring Boot and company) I needed to create a REST controller accessible for authenticated users only. The solution was surprisingly easy – @PreAuthorize annotation: Continue reading

Posted in apps, programming | Tagged , , , | Leave a comment

[Solved] Kyocera FS-920 vs. Manjaro Linux

My Kyocera has recently stopped working. However, I’ve found out that sending a text directly to the device was working… Continue reading

Posted in Manjaro | Tagged , | Leave a comment

Parsing httpd.conf

Let’s say you need to configure an httpd for a new project. The configuration file becomes longer and longer so you decide to make use of macros and Use directives. Things go smooth – so far single lengthy flat configuration file is now tree-structured, it also includes a lot of other files. After three years of maintaining such a tree-structured configuration you’re the only person who knows well that magic. Virtual hosts are hidden behind third include and fifth macro. Continue reading

Posted in apps, programming | Tagged , , , , | Leave a comment

Scrabble – challenge accepted!

I wonder how computationally complicated Scrabble can be, taking into account all its aspects. What’s a piece of cake for human brain, is not necessarily easy for a computer. Continue reading

Posted in programming | Tagged , , , , | Leave a comment

jDfm updated

During the weekend I have done a spring cleaning of jDFM source code. The changes improve a parsing of newer versions of dfm files. Going into the details, DfmProperty’s value is not always a Java String any more. The value can be an instance of:

  • String
  • DfmMultiLineString – string split between many lines, concatenated by plus sign (+)
  • DfmOptionsList – comma delimited list of options, surrounded by brackets [ ]
  • DfmList – list of strings/number, each in new line; surrounded by parentheses ( )
  • DfmByteArray – string representation of byte[] array (hex values). The class decodes the value to Java byte[]. Surrounded by curly brackets { }.
  • DfmItemList – list of item objects, surrounded by crocodile brackets < >. Each item contain a list of properties, it can be also an another DfmItemList.

Project page on GitHub

Posted in programming | Tagged , , , , , | Leave a comment

JavaCC in practice?

Ladies and Gentlemen, please find below my first Beamer presentation built on Wronki template. ;)

Download “JavaCC in practice”

JavaCC

Posted in latex | Tagged , | Leave a comment

Wronki – a new Beamer template

You don’t want to create another ordinary Beamer presentation, do you? Despite you changed the colour theme, everyone immediately knows it’s been made in LaTeX, everyone knows those templates. I am not saying it’s wrong (a lot of my slideshows looked like that) but might you consider using a template looking different? How much different? Have a look at my first Beamer template! I hope you will enjoy it!

Requirements

The template uses two non-standard fonts. Both of them are free. You can download them directly from my site (see: below) or from dafont.com:

  1. Libel Suit
  2. Chinatoo

Note that fonts are required at compilation stage only as lualatex includes the fonts into result pdf file.

Installation

  1. Install the fonts
  2. Extract the template files. The template needs to be in directory visible by LaTeX. If you want to just try out the template, place *.sty files together with your *.tex file. To not copy the template each use, you may put the template in LaTeX directory. In case of MiKTeX, move *.sty files to appropriate subdirectories of MiKTeX 2.9\tex\latex\beamer\base\themes\theme. The template consists of 4 files:
    • beamercolorthemeWronki.sty
    • beamerinnerthemeWronki.sty
    • beamerouterthemeWronki.sty
    • beamerthemeWronki.sty

    The 5th file – Wronki-example.tex – is an example slide show.

Compilation

The template needs to be compiled using lualatex – as far as I know, it’s a pdflatex with support of system fonts and Unicode. A compilation does not differ from pdflatex:

lualatex Wronki-example.tex

Extra commands

  • \kTitleFrame – Inserts a title frame
  • \kTOCFrame{Title} – inserts a table of contents with a given title
  • \kSectionFrame – the command may be used to create a frames being displayed (before each section or subsection, for example). There is also a few background images predefined. Look at the example and study beamerinnerthemeWronki.sty for more. The used images are actually single Chinatoo font’s letters.
  • \kQuestionsFrame – end frame with some additional banners on the bottom.

Why is it named Wronki?

Standard Beamer templates are named for capitals’ names. Well, Wronki is not a capital but it’s a town where I grew up so I thought it would be cool to show my love in that way… :-)

Download

  1. Wronki Beamer Template
  2. Fonts
  3. Real example

Licence

It’s free to modify and redistribute. But please be aware it’s my first template and I’m not a Latex guru at all. Most probably, there is a lot of bugs. It works for me, though. If you find the template useful, please leave a comment.

Posted in latex | Tagged , , | 7 Comments