Tuesday, November 8, 2016

STM32f429 Discovery on ucLinux: How to run user programs.

The uClinux is able to run on the STMf429 Discovery board.
But...

What should user programs run to do on the boards?


I have two ideas.
  1) User programs write "romfs" on your PC.
  2) User programs transmit via console.

This document explains two methods.

Chapter 1. Writing to "romfs".

The uClinux environment was installed and built successfully, when you see development directory.
pardus@STM32dev:~/src/stm32f429-linux-builder$ ls
busybox-1.22.1  downloads  mk   README.md  stamp-kernel  u-boot
configs         Makefile   out  rootfs     stamp-uboot   uclinux

That "rootfs" is base image of rootfs and user programs write under "rootfs".
Ex. Writung "hello" at /root/

pardus@STM32dev:~/src/stm32f429-linux-builder$ cp ../hello/hello rootfs/root
pardus@STM32dev:~/src/stm32f429-linux-builder$ ls rootfs/root
hello placeholder

Rebuild and reinstallation run on development PC.
pardus@STM32dev:~/src/stm32f429-linux-builder$ make clean-rootfs
pardus@STM32dev:~/src/stm32f429-linux-builder$ make build-rootfs
pardus@STM32dev:~/src/stm32f429-linux-builder$ make install

When rebooted, you can type command on uClinux to see hello program in board file system.
~ # cd root    
/root # ls
hello
/root # ./hello
   Hello World!!    
/root #


Chapter 2. Transmit via Console.

Method Chapter 1 is previously write romfs, but romfs is read-only file system and romfs must rebuild whenever update programs. I want to transmit running on uClinux.

Let see file system by "mount" and "df" command.
~ # mount
rootfs on / type rootfs (rw)
/dev/root on / type romfs (ro,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
/dev/ram0 on /var type ext2 (rw,relatime,errors=continue,user_xattr,acl)

/root # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                  364       364         0 100% /
/dev/ram0                 1003        17       986   2% /var
 

This system has two file device, one is romfs other is ramfs.
"romfs" isn't writing read only but "ramfs" is possible read and write.
There are several method of transfer programs, I adopt simplest method by copy-paste and linux commands.
Using commands are "uuencode" and "uudecode" in busybox, but they wasn't built. Using commands edits busybox configuration file.
   [your development environment]/stm32f429-linux-builder/configs
   busybox_config

There are two configuration way, one is editing two line in that file.
  # CONFIG_UUDECODE is not set
  # CONFIG_UUENCODE is not set
    Change to
  CONFIG_UUDECODE=y
  CONFIG_UUENCODE=y

More one is able to change by "make menuconfig".


You need configuration file Load/Save!

If you use "make menuconfig" when you need previously installing ncurses.
   apt-get install ncurses-dev  

Configure file changed completely then rebuild file system and installing.
Rebuilding previously clean busybox development environment.

pardus@STM32dev:~/src/stm32f429-linux-builder$ cd busybox-1.22.1/
pardus@STM32dev:~/src/stm32f429-linux-builder$ make clean
pardus@STM32dev:~/src/stm32f429-linux-builder$ make mrproper
pardus@STM32dev:~/src/stm32f429-linux-builder$ cd ..
pardus@STM32dev:~/src/stm32f429-linux-builder$ make clean-rootfs
pardus@STM32dev:~/src/stm32f429-linux-builder$ make build-rootfs
      :
pardus@STM32dev:~/src/stm32f429-linux-builder$ make install

Sample program "hello2.c"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv) {      

    if(argc < 2) {
        printf("I need a arg!\n");
        exit(-1);
    }
    printf("   Hello World!!\n");
    printf("      %s\n", argv[1]);

    exit(0);
}

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

Binary file "hello2" convert text file use "uuencode" command on development PC.
pardus@STM32dev:~/src/hello2$ uuencode hello2 hello2 > hello2.uu  


if "uuencode" command isn't installed your PC when you install commands.

   apt-get install sharutils  

Created "hello2.uu" show on PC terminal and all slect and copy.
STM32f4 console type command "uudecode" and paste.
~ # cd /var
/var # uudecode
STOP TERMINAL,
AND YOU CAN PASTE "hello2.uu" TEXT FILE.
       :
       :
/var # ./hello2
I need a arg!
/var # ./hello2 hoge
   Hello World!!
      hoge
/var #

However, you want to transfer STM32f4 to PC, when you can use "uuencode" command on STB32f4 and copy text. For example games save data files...


Have a nice computing!


Thursday, October 27, 2016

STM32F3 Discovery + libopencm3, using USART.

I made STM32 development environment by gcc + libopencm3.
libopencm3 examples include using USART  for STM32F429, but STM32F3 is nothing.
So, I refer usart_console program for STM32F4 then successfully run on the STM32F3 discovery board.
I changed USART register name for running on STM32F3.

void console_putc(char c)
{
        uint32_t        reg;
        do {
                reg = USART_ISR(CONSOLE_UART);
        } while ((reg & USART_ISR_TXE) == 0);
        USART_TDR(CONSOLE_UART) = (uint32_t) c & 0xff;
}

char console_getc(int wait)
{
        uint32_t        reg;
        do {
                reg = USART_ISR(CONSOLE_UART);
        } while ((wait != 0) && ((reg & USART_ISR_RXNE) == 0));
        return (reg & USART_ISR_RXNE) ? USART_RDR(CONSOLE_UART) : '\000';
}


USART_ISR is "Interrupt and status register".(STM32F4 is USART_SR)
USART_TDR is "Transmit Data Register".(STM32F4 is USART_DR)
USART_RDR is "Receive Data Register".(STM32F4 is USART_DR)

Some constitution of registers are different from STM32F4 in STM32F3.
  

Have a good your computing!


Tuesday, October 11, 2016

STM32 develop embed programs by gcc environment.

I made development for STM32f429 discovery uClinux environment.
This time, let it add gcc development on my environment. Because, I have STM32f429 discovery and STM32f303 discovery boards.

First: Installing toolchain.
It needs Arm instruction set compiling and working out binary files tools.
And, the binary files are made by ARM non eabi mode instruction set.
It tools called "Toolchain", that you can be able to get running on your PC binaries from the Web.
binutils-arm-none-eabi, gcc-arm-none-eabi

You can install your PC(Ubuntu) by the "apt-get" command.
$ apt-get install binutils-arm-none-eabi gcc-arm-none-eabi

Confirmation passes installing by below command.
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (4.8.2-1ubuntu1+6) 4.8.2
Copyright (C) 2013 Free software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A particular purpose.
$


Next: Installing STM32 firmware.
There is libopencm3 project that is ARM multi platform hardware farmware developing.
I choice that project.

Getting source tree from git command.
$ git clone https://github.com/libopencm3/libopencm3-examples.git<

Making firmware. 
$ cd libopencm3
$ git submodule init
$ git submodule update
$ make


Examples: Getting start !
Showing a STM32f303 discovery board example doing.
$ cd examples/stm32/f3/stm32f3-discovery/miniblink
$ make

Connection your STM32f303 discovery board on your PC via USB cable, and start openocd.
$ sudo openocd -f /usr/local/share/openocd/script/board/stm32f3discovery.cfg

And, you open other terminal and run telnet to connect openocd and flash operations..
$ telnet 4444
reset halt
flash write_image erase miniblink.elf
reset

If successflly write STM32f303 discovery board, when light blue LED !


Showing a STM32f429 discovery board example doing.
To do STM32f429 discovery board is the same STM32f303 doscovery bord.
$ cd examples/stm32/f4/stm32f429-discovery/miniblink
$ make

Connection your STM32f429 discovery board on your PC via USB cable, and start openocd.
$ sudo openocd -f /usr/local/share/openocd/script/board/stm32f429discovery.cfg

And, you open other terminal and run telnet to connect openocd and flash operations.
$ telnet 4444
reset halt
flash write_image erase miniblink.elf
reset

If successflly write STM32f29 discovery board, when light green LED(LED3) !


Flash writing use OpenOCD.
  How to get and install OpemPCD to see old my blog.


Let's enjoy computing !


Monday, October 10, 2016

Soup curry restaurant, "Firi Firi"

The soup curry is a local specialty in Sapporo Hokkaido Japan.
I didn't have time in Sapporo, but I have craving soup curry in Sapporo !
So, I searched soup curry shop nearest the Sapporo station by using Google Map. Finding shop is "Firi Firi 2 gou"(ヒリヒリ2号) that locate under guard. The shop is hard to find and step to the buck of passageway under the guard.

Shop's waitress recommends hot level 3, because if you are first time to eat this restaurant and you love hot. But I want more hot flavor. If I have chance of to visit this restaurant, when try to Level 4 or 5 !
I had "Soup curry with chicken leg quarters"(骨チキンカリー) that is typical food in the shop.
"Soup curry with chicken leg quarters" include chicken leg quarters, many vegetables and rice.

930Yen.





Evaluation:
☆☆☆☆-

My Impressions:
   Taste:☆☆☆--
   Voume:☆☆☆☆-
   Performance:☆☆☆☆☆

Descent point:
Nohting !
If I had to choose, I should have taken upper hot level...


Sandwich House, in Shin-Chitose Air terminal.

"Sandwich House Gourmet"
I bought sandwich is "Roast beef, vegetables and cheese". This is good aperitif sandwich with wine.





Evaluation:
☆☆☆?-

My Impressions:
   Taste:☆☆☆--
   Voume:☆☆☆--
   Performance:☆☆☆☆-

Descent point:
I like flavor is more a little spicy.


Air Terminal Hotel, in CTS (3F CTS BLD,New Chitose Airport,Bibi,Chitose city, Hokkaido)

Do you love plane?

I stayed runway side room then I saw fronting of boarding bridge and plane. In the night, the lighting of runway was very amazing view.



Guests are able to use hot spring facilities in the airport(CTS 新千歳空港温泉). When you use hot spring, you exchange room key to using ticket. That isn't limit of numbers, for examples you can use night and morning. But! hot spring place locate out of hotel's area that is the airport facilities, and when your traveling don't forget dress.
In the hot spring place rent you free of charge Yukata or Jinbei(Japanese relaxed ware) and you can use relaxation room(The place has lady's room).
You'd check present time in the hot spring place, this airport has many restaurant bat some shop is early closing against showing opening time. Some shops closing start 19:30, food court shop's showing opening time is 10:00-2030 but closing start is around 20:00 (cause of sold out?). You are careful present time that isn't Narita or Haneda... (Some restaurant are opening 22:00 in CTS.)
To take matters worse, the airport shutout 23:00. If you relaxed too hot spring, when you should walk to hotels's entry via outside airport facilities.

And more one, card lounge don't locate inside the restricted area, so I can't experience this airport card lounge.


Saturday, October 8, 2016

Train drinking! Hakodate --> Shin Chitose international air port(CTS).

My traveling is Hakodate for Shin Chitose international air port(CTS) by express train Super Hokuto. Traveling duration is around three hour half minute.
Let me enjoy traveling and drinking !   #Trainbeer

Express Super-Hokuto and Hokuto are different train cars. I recommend to choice Super-Hokuto and reservation seat. Because, between Hakodate-Sapporo section is may congestion suddenly.



Let me drink!

Ika Jaga:
  Whole squid was stuffed potato.
Zangi kusi:
  Zangi is flied chicken Hokkaido style.
Nikuman:
  Limited Hokkaido flavor.
Sapporo Classic:
  Limited Hokkaido.
Haodate wine:
  Hakodate local wine.