Samedi 24 novembre 2018

linux on stm32f429I-disco

  • stm32
  • https://github.com/jserv/stm32f429-linux-builder

STM32f429 Discovery on ucLinux Working the ucLinux get on easily the STM32f429 Doscpvery board. And making image can find github and clone your PC.

For running ucLinux on the STM32f429.

1 Host computer setup.
My host computer is VM that is made VitrualBox.
Host OS ubuntu 14.0.4LTS install to VM.

2 Host OS setup.
Network configure on your environments.
“git” install and setup.

$ sudo apt-get update
$ sudo apt-get install git

If your environment use proxy when setup proxy environment.

$ export http_proxy=http://<<PROXY HOST URL>>:<<PORT>>/
$ export ftp_proxy=http://<<PROXY HOST URL>>:<<PORT>>/
$ export https_proxy=http://<<PROXY HOST URL>>:<<PORT>>/

3 Install and Build OpenOCD
OpenOCD needs several packages, so you can find and install them.

$ sudo apt-get install libtool autoconf automake texinfo
$ sudo apt-get install libusb-dev libusb-1.0

OpenOCD download from the github.

$ git clone http://git.code.sf.net/p/openocd/code

Build OpenOCD.

   $ cd code
   $ ./bootstrap
   $ ./configure --prefix=/usr/local --enable-stlink
   $ echo -e "all:\ninstall:" > doc/Makefile
   $ make
   $ sudo make install

4 Installing Toolchain.
Down load “arm-2010q1-189-arm-uclinuxeabi-i686-pc-linux-gnu.tar.bz2”
The file exruct, made arm-2010q1 directory. Toolchain are under bin directory. So make path.

$ export PATH=/home/XXXX/stm32/uclinux/arm-2010q1/bin:$PATH

In case of execute toolchain when fail commands.

$ arm-uclinuxeabi-gcc

bash: /home/XXXX/stm32/uclinux/arm-2010q1/bin/arm-uclinuxeabi-gcc: No such file or directory

The toolchain commands are made by 32bit program, and need 32bit running environment.
(My host OS is ubuntu 64bit)

$ sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

If toolchain behave to below as OKAY.

$ arm-uclinuxeabi-gcc
arm-uclinuxeabi-gcc: no input files

5 Install romfs

$ sudo apt-get install genromfs

6 stm32f429 linux download, build and install.

$ git clone http://github.com/jserv/stm32f429-linux-builder
$ make
$ make install

7 But! I can’t install!!
Installing use STLink v2 that needs USB2.0, but VirtualBox has only USB1.0.
VirtualBox add to USB2.0 function via extension pack.
Latest VirtualBox version download and install, and more download extension pack. Olacle’s VirtualBox here .

And usb device is “root”

$ make install libusb_open() failed with LIBUSB_ERROR_ACCESS

$ sudo make install

If you want to change kernel or busybox configuration when need ncurses for “make menuconfig”. Top level “make” using configuration files exists in ~/stm32f429-linux-builder/configs are busybox_config and kernel_config.

Running needs environment:

  • STM32F429I-Discovery board
  • USB mini B(429) <—> A(PC) for ST-Link

  • USB serial conversion cable, I bought that.
    • Txd and Rxd line cable.
    • Ex. serial connections.
      • STM32 PC11 –> Cable connector Orange Txd(PC)
      • STM32 PC10 –> Cable connector Yellow Rxd(PC)
  • Terminal settings:
    • Baud rate: 115200
    • Data: 8 bit
    • Parity: none
    • Stop: 1 bit
    • Flow control: none

Booting console output.

U-Boot 2010.03-00003-g934021a ( 4? 21 2016 - 10:17:03)

CPU  : STM32F4 (Cortex-M4)
Freqs: SYSCLK=180MHz,HCLK=180MHz,PCLK1=45MHz,PCLK2=90MHz
Board: STM32F429I-DISCOVERY board,Rev 1.0
DRAM:   8 MB
Using default environment

Hit any key to stop autoboot:  0
## Booting kernel from Legacy Image at 08020000 ...
   Image Name:   Linux-2.6.33-arm1
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    738336 Bytes = 721 kB
   Load Address: 08020040
   Entry Point:  08020041
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Linux version 2.6.33-arm1 (XXXX@STM32-Dev) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #1 Thu Apr 21 10:19:25 JST 2016
CPU: ARMv7-M Processor [410fc241] revision 1 (ARMv7M)
CPU: NO data cache, NO instruction cache
Machine: STMicro STM32
Ignoring unrecognised tag 0x54410008
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 1778
Kernel command line: stm32_platform=stm32429-disco mem=7M console=ttyS2,115200n8 consoleblank=0 root=/dev/mtdblock0 rdinit=/sbin/init video=vfb:enable,fbmem:0x90700000,fbsize:0x100000
PID hash table entries: 32 (order: -5, 128 bytes)
Dentry cache hash table entries: 1024 (order: 0, 4096 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 7MB = 7MB total
Memory: 6976k/6976k available, 192k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0x00000000 - 0x00001000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0x00000000 - 0xffffffff   (4095 MB)
    lowmem  : 0x90000000 - 0x90700000   (   7 MB)
    modules : 0x90000000 - 0x90800000   (   8 MB)
      .init : 0x9000a000 - 0x9000e000   (  16 kB)
      .text : 0x08028000 - 0x080c4000   ( 624 kB)
      .data : 0x90008000 - 0x90018460   (  66 kB)
Hierarchical RCU implementation.
NR_IRQS:90
Console: colour dummy device 80x30
Calibrating delay loop... 168.34 BogoMIPS (lpj=841728)
Mount-cache hash table entries: 512
bio: create slab <bio-0> at 0
Switching to clocksource cm3-systick
ROMFS MTD (C) 2007 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered (default)
Console: switching to colour frame buffer device 60x53
fb0: Virtual frame buffer device, using 1024K of video memory
Serial: STM32 USART driver
stm32serial.2: ttyS2 at MMIO 0x40004800 (irq = 39) is a STM32 USART Port
console [ttyS2] enabled
brd: module loaded
uclinux[mtd]: ROM probe address=0x8120000 size=0x59000
Creating 1 MTD partitions on "ROM":
0x000000000000-0x000000059000 : "ROMfs"
ARMv7-M VFP Extension supported
VFS: Mounted root (romfs filesystem) readonly on device 31:0.
Freeing init memory: 16K
starting pid 27, tty '/dev/ttyS2': '/bin/login -f root'
Welcome to
          ____ _  _
         /  __| ||_|
    _   _| |  | | _ ____  _   _  _  _
   | | | | |  | || |  _ \| | | |\ \/ /
   | |_| | |__| || | | | | |_| |/    \
   |  ___\____|_||_|_| |_|\____|\_/\_/
   | |
   |_|

For further information check:
http://www.uclinux.org/

Jan  1 00:00:01 login[27]: root login on 'ttyS2'
~ #

cpuinfo

~ # cat /proc/cpuinfo
Processor       : ARMv7-M Processor rev 1 (v7ml)
BogoMIPS        : 168.34
Features        : swp half thumb fastmult vfp edsp
CPU implementer : 0x41
CPU architecture: ?(11)
CPU variant     : 0x0
CPU part        : 0xc24
CPU revision    : 1

Hardware        : STMicro STM32
Revision        : 0000
Serial          : 0000000000000000

meminfo

~ # cat /proc/meminfo
MemTotal:           6992 kB
MemFree:            4144 kB
...

free

~ # free
             total         used         free       shared      buffers
Mem:          6992         2848         4144            0            8
-/+ buffers:               2840         4152

hello.c

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv) {

    printf("   Hello World!!\n");
}

$ arm-uclinuxeabi-gcc  -g  -Os   -g2 -mthumb -mcpu=cortex-m3 -O2 hello.c -o hello

# ./hello
   Hello World!!

Zork

I can play the game for now…

# ./zork
Welcome to Dungeon. This version created 11-MAR-91.
You are in an open field west of a big white house with a boarded
front door.
There is a small mailbox here.
>open mailbox
Opening the mailbox reveals:
A leaflet.
>take leaflet.
Taken.
>read leaflet
Welcome to Dungeon!

Dungeon is a game of adventure, danger, and low cunning. In it you will explore some of the most amazing territory ever seen by mortal man. Hardened adventurers have run screaming from the terrors contained within.

In Dungeon, the intrepid explorer delves into the forgotten secrets of a lost labyrinth deep in the bowels of the earth, searching for vast treasures long hidden from prying eyes, treasures guarded by fearsome monsters and diabolical traps!

No DECsystem should be without one!

Dungeon was created at the Programming Technology Division of the MIT Laboratory for Computer Science by Tim Anderson, Marc Blank, Bruce Daniels, and Dave Lebling. It was inspired by the Adventure game of Crowther and Woods, and the Dungeons and Dragons game of Gygax and Arneson. The original version was written in MDL (alias MUDDLE). The current version was translated from MDL into FORTRAN IV by a somewhat paranoid DEC engineer who prefers to remain anonymous, and was later translated to C.

On-line information may be obtained with the commands HELP and INFO.
>