Saturday, July 9, 2016

Reference Test Machine - Stm32F4discovery

When building complex software its essential to do reference builds and designate a reference piece of hardware similar to the final target for testing and keep it in good condition. Too often with out this, testing is done on dodgy hardware that just causes strange problems until reference hardware is established.

My target application is for an IoT data logger, polling sensors "southbound", storing locally on an SDcard, or USB drive, and sending to the internet via serial to a WiFi or Cellular interface

I am using an open source hardware Olimex STM32F4 H407 for prototyping - as its industrial strength and likely to have a good product life. I've created a basic configs/olimex-stm32-h407 but it isn't widely used.

As an alternative hardware, for stability integrating similar functions, I'm  choosing the widely available STM32F4discovery that has had a lot of base builds performed on it in nuttx\configs\stm32f4discovery.
It is a demonstration board from ST for trying out their processor..
With the added baseboard this provides a lot of functionality, though I won't be attempting to exercise all the hardware.
For testing you will need
*) USB cable - Type A from the Ubuntu Host to USB mini on the stm32f4discovery card ST
*) USB to TTL/3V logic connector for the the Console - eg adafru.it/954 - also has power if needed.
*) STM baseboard  "STM32F4DIS-BB" or Digikey "497-13545-ND"

For the reference build - I'm going to try and build as much of a realistic project as I can for the target environment I'm looking at.

The reference environment starts from configs\stm32f4discovery\nsh\defconfig - and is built up from there.
On my ubuntu machine
$cd git
$mkdir nxhd47tst
$cd nxhd47tst
$git clone git@bitbucket.org:neilh20/anuttx.git nuttx

$git clone git@bitbucket.org:neilh20/nuttapps.git apps

$cd nuttx
$git checkout -b wkd47tst1   #work discoverystm32F407 test
#then I copy  the configs\stm32f4discovery to configs\stm32f4discotst
$cd configs
$cp -R stm32f4discovery stm32f4discotst
#Then per my previous blog nuttx-traceable-builds I do the following 

~/git/nxd47tst/nuttx (wkd47tst)]$
$nano .gitignore -->   remove /.config  /.Make.defs

$nano include/nuttx/.gitignore --> remove /config.h & /version.h

$cd tools
$  ./configure.sh stm32f4discotst/nsh
$ cd ..
$make menuconfig
Build Setup--> Build Host Platform (Linux)
System TypeàSTM32 Periperal Support [ ] OTG FS - disable CONFIG_STM32_OTGFS
$make
verify builds successfully.
$ size nuttx
   text    data     bss     dec     hex filename
  55961     100    2032   58093    e2ed nuttx

I'm using PA2/PA3 Uart1 for a debug console, so verify
$make menuconfig
System Type-->STM32 Peripheral-->
 [*] PWR
[*] SYSCFG
  [*] USART2
USART2 Driver Configuration (Standard serial driver)  ---> (X) Standard serial driver
Up one level to "System Type"
  [*] Exclude CCM SRAM from the heap
 [*] Dump stack on assertions
Board Selection
    Select target board (STMicro STM32F4-Discovery board)  --->
    [*] Board LED support
    [*] Board button support
(fut) [ ] STM32F4DIS-BB base board
Device Drivers
   [ ] Disable driver poll interfaces
   [*] Enable /dev/null
   [*] RAM Disk Support
   -*- SPI Driver Support  --->      [*]   SPI exchange
   [*] Serial Driver Support  --->
         [*]   Enable standard "upper-half" serial driver
         [*]   Support TIOCSERGSTRUCT
        Serial console (USART2)  --->
        USART2 Configuration  --->
            (128) Receive buffer size
#enable an enhanced debug I'm enabling a large TX buffer.
            (2048) Transmit buffer size
           (115200) BAUD rate
           (8) Character size
           (0) Parity setting
           (0) Uses 2 stop bits
           [ ] USART2 RTS flow control
           [ ] USART2 CTS flow control
           [ ] USART2 DMA support
<Save> <Exit> to "Configuration"
 File Systems  --->
 -*- Writable file system
    [*] FAT file system
    [*]   FAT upper/lower names
    [ ]   FAT long file names
    [*]   FAT timestamps
<save><exit>
Application Configuration-->NSH Library --> Configure Command Options
 [*] df: Enable [-h] man-readable format
<save> <ok> <exit> <exit>
#enable a date facility
Device Drivers-->Timer Driver Support -->RTC Driver Support
   [*]   Date/Time RTC Support
   [  ]   RTC Alarm Support (NEW)
   [*]   RTC Driver Support
   [*]     RTC IOCTLs
Application Configuration-->NSH Library -->Disablei ndividual Commands
 [ ] Disable date    # Ensure date turned off
System Type-->RTC clock source (LSI Clock)--> # select  Low Speed Internal
<save><ok> <exit>   till back to prompt
$mknx.sh      # it rebuilds all
$size nuttx
   text    data     bss     dec     hex filename
  73916     244    3972   78132   13134 nuttx

#Now with the USB cable plugged into an stm32F4disco (STM32F407)  download it
$stwr
#Connect up a console - I use "Tera Term", open the COM port associated with the F4disco
#On the F4disco press reset should get.
NuttShell (NSH) NuttX-17.6
nsh>
# Type in the following proving the build
nsh> uname -a
NuttX 17.6 nxd47wk_wkd47tst1_20160709_1742 arm stm32f4discovery


#Try help to list cmds with no buildin
nsh> help
help usage:  help [-v] [<cmd>]

  [           dirname     help        mkrd        rmdir       umount
  ?           dd          hexdump     mh          set         unset
  basename    df          kill        mount       sh          usleep
  break       echo        ls          mv          sleep       xd
  cat         exec        mb          mw          test
  cd          exit        mkdir       ps          time
  cp          false       mkfatfs     pwd         true
  cmp         free        mkfifo      rm          uname

Builtin Apps:
nsh>
# Make a ram disk to test writing a file to
mkrd 50
# Try ls dev - and checkout "ram0"
#then type
mkfatfs /dev/ram0
mount -t vfat /dev/ram0 /tmp
nsh>ls dev
nsh>ls tmp
nsh>help > /tmp/h.txt
nsh>cat /tmp/h.txt
#Hurrah created and wrote a text file to a temp directory. 
#List the df in human readable form
df -h
Filesystem    Size      Used  Available Mounted on
vfat         7680B        1K      6656B /tmp
nsh> free
             total       used       free    largest
Mem:        191376      33264     158112     123648

# Snap shot this

$git tag -a nxtst17.6_nxd47wk_wkd47tst1_20160709_1820 -m "tag attempt"
$git commit -a -m "version change"
$git push --tags

It can be grabbed with
eg from git
$mkdir wkd47t
$cd wkd47t
$git clone git@bitbucket.org:neilh20/anuttx.git nuttx
$git clone git@bitbucket.org:neilh20/nuttapps.git apps

$cd nuttx
$git checkout wkd47tst1 
$git checkout nxtst17.6_nxd47wk_wkd47tst1_20160709_1820
$make
<download>
<make any modifications and switch it to your own branch with>

git checkout -b <mybranch>

No comments:

Post a Comment