Embedded Linux Development on Raspberry PI using Buildroot – part2

By | June 20, 2016

In this post, you are going boot raspberry pi with embedded Linux. You will also see the procedure to enable the serial console, as it is disabled by default.

Recall:

In the previous post, we have seen the procedure to create a complete embedded Linux package using buildroot. At the end of the post, we discussed the procedure to flash ‘sdcard.img’ to SD card.

Embedded Linux Development on Raspberry PI using Buildroot – part1

We also covered the steps to connect Raspberry Pi UART to computer.

How to connect Raspberry Pi UART to a computer

Development Environment :

Below components required for the development.

  • Software
    • Ubuntu 14.04
  • Hardware
    • Raspberry Pi
    • SD card with buildroot embedded Linux components
    • USB to UART converter for serial console

Boot Raspberry Pi with Embedded Linux OS:

After flashing sdcard.img to memory card using win32diskimager, you should see two partitions.

Embedded Linux Raspberry Pi

Primary partition :

Primary partition should contain all components as shown below picture. I have briefed about each component in the part-1 post.

Embedded Linux Raspberry pi boot partition

Second partition:

Second partition contains root filesystem. Buildroot took complete pain of creating this folder structure and placing the components into respective folders.

Later, I will discuss about the significance of each folder and the procedure to create your own filesystem.

Embedded Linux Raspberry pi root filesystem

Enable Serial console:

Serial console is very important component in embedded Linux. Since, raspberry pi board has very limited pinouts available, all Linux demos disables serial console and use those pins as GPIOs.

So, when you boot default buildroot demo images will not see any debug information on serial console. You will only see below message.

Uncompressing Linux... done, booting the kernel.

You really don’t know whether the booting is successful or not.

So, to enable serial console, You need to do below modification.

1. Change command Line args:

  • In SD card boot partition, open command cmdline.txt file
  • By default, you will only see below line
root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
  • Delete entire line, and copy and paste below line to enable serial console
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Understanding the arguments

dwc_otg.lpm_enable=0    - Disable LPM support to fix few USB issues
console=ttyAMA0,115200  - To divert serial console log to UART
kgdboc=ttyAMA0,115200   - To divert kernel debug messages to UART
root=/dev/mmcblk0p2     - SD card's second partition has root filesystem
rootfstype=ext4         - Root filesystem partition type
rootwait                - Wait for SD card response

2. Change inittab:

To allow login over serial console, you need to do below steps

  • In the root filesystem partition, go to ‘etc’ folder
  • Find and open ‘inittab’ file, (may be root permissions required)
  • Find below line
# Put a getty on the serial port
  • Now, Add this line after that.
ttyAMA0::respawn:/sbin/getty -L  ttyAMA0 115200 vt100

This line is responsible for getting login prompt, and other shell messages to serial console.

“raspbian os” users may find above line somewhat strange. In raspbian, to enable serial console, you need to add below line in inittab file

T0:23:respawn:/sbin/getty -L  ttyAMA0 115200 vt100

Boot the board:

Now insert the SD card and connect the power supply. You should see console logs and login prompt.

Enter login name as ‘root’.

[    2.964755] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-20980000.usba
[    3.025044] uart-pl011 20201000.uart: no DMA platform data                   
                                                                                
Welcome to Buildroot                                                            
buildroot login:

Yup, your first step towards embedded Linux development is completed.

What’s next ?

In the next post, you will

  • see the procedure to enable u-boot in the buildroot
  • do necessary modification to boot raspberry Pi with uboot.
  • see TFTP boot
  • see NFS boot

Great day

Minion

2 thoughts on “Embedded Linux Development on Raspberry PI using Buildroot – part2

  1. nayn

    what is the default buildroot login and password , or when do I need to configure it ?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *